[PATCH 21/21] etnaviv: nir: globalize local registers
Philipp Zabel
p.zabel at pengutronix.de
Tue Jun 5 14:38:45 UTC 2018
We represent allocated temporaries as NIR global registers. Turn local
registers left over by the nir_convert_from_ssa pass into global
registers with the correct temporary number.
Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
---
src/gallium/drivers/etnaviv/etnaviv_nir.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 36ec21fbd623..b50c9f16a456 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -920,6 +920,26 @@ etna_assign_registers(nir_shader *shader)
ralloc_free(regs);
}
+/* Replace local registers created by the nir_convert_from_ssa pass to global
+ * registers, order them after the global registers created by register
+ * assignment.
+ */
+static void
+etna_globalize_local_registers(nir_shader *shader)
+{
+ nir_foreach_function(function, shader) {
+ nir_foreach_register_safe(reg, &function->impl->registers) {
+ nir_register *global_reg = nir_global_reg_create(shader);
+ global_reg->num_components = reg->num_components;
+ nir_foreach_use_safe(src, reg)
+ nir_instr_rewrite_src(src->parent_instr, src, nir_src_for_reg(global_reg));
+ nir_foreach_def_safe(dest, reg)
+ nir_instr_rewrite_dest(dest->reg.parent_instr, dest, nir_dest_for_reg(global_reg));
+ nir_reg_remove(reg);
+ }
+ }
+}
+
/* Uniforms cannot directly be used as output. Add a move to register for
* uniforms that are used as output. */
static void
@@ -1062,6 +1082,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_fix_alu_uniform_src);
NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
+ NIR_PASS_V(s, etna_globalize_local_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
NIR_PASS_V(s, nir_opt_dce);
--
2.17.1
More information about the etnaviv
mailing list