*/
#include "etnaviv_compiler.h"
+#include "etnaviv_compiler_nir.h"
+#include "etnaviv_debug.h"
#include "util/ralloc.h"
struct etna_compiler *
{
struct etna_compiler *compiler = rzalloc(NULL, struct etna_compiler);
+ if (!DBG_ENABLED(ETNA_DBG_NIR))
+ return compiler;
+
+ compiler->regs = etna_ra_setup(compiler);
+ if (!compiler->regs) {
+ ralloc_free((void *)compiler);
+ compiler = NULL;
+ }
+
return compiler;
}
*/
struct etna_compiler {
uint32_t shader_count;
+ struct ra_regs *regs;
};
/* compiler output per input/output */
/* ra state */
struct ra_graph *g;
- struct ra_regs *regs;
unsigned *live_map;
unsigned num_nodes;
return virt_reg / NUM_REG_TYPES;
}
+struct ra_regs *
+etna_ra_setup(void *mem_ctx);
+
void
etna_ra_assign(struct etna_compile *c, nir_shader *shader);
return 0;
}
-void
-etna_ra_assign(struct etna_compile *c, nir_shader *shader)
+struct ra_regs *
+etna_ra_setup(void *mem_ctx)
{
- struct ra_regs *regs = ra_alloc_reg_set(NULL, ETNA_MAX_TEMPS *
+ struct ra_regs *regs = ra_alloc_reg_set(mem_ctx, ETNA_MAX_TEMPS *
NUM_REG_TYPES, false);
/* classes always be created from index 0, so equal to the class enum
}
ra_set_finalize(regs, q_values);
+ return regs;
+}
+
+void
+etna_ra_assign(struct etna_compile *c, nir_shader *shader)
+{
+ struct etna_compiler *compiler = c->variant->shader->compiler;
+ struct ra_regs *regs = compiler->regs;
+
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
/* liveness and interference */
assert(ok);
c->g = g;
- c->regs = regs;
c->live_map = live_map;
c->num_nodes = num_nodes;
}
}
ralloc_free(c->g);
- ralloc_free(c->regs);
ralloc_free(c->live_map);
return j;
shader->id = p_atomic_inc_return(&compiler->shader_count);
shader->specs = &screen->specs;
+ shader->compiler = screen->compiler;
if (DBG_ENABLED(ETNA_DBG_NIR))
shader->nir = (pss->type == PIPE_SHADER_IR_NIR) ? pss->ir.nir :
struct tgsi_token *tokens;
struct nir_shader *nir;
const struct etna_specs *specs;
+ struct etna_compiler *compiler;
struct etna_shader_variant *variants;
};