freedreno/ir3: add ir3_cp_ctx
authorRob Clark <robclark@freedesktop.org>
Mon, 11 Apr 2016 18:33:01 +0000 (14:33 -0400)
committerRob Clark <robclark@freedesktop.org>
Wed, 4 May 2016 15:25:55 +0000 (11:25 -0400)
Needed in next commit.. just split out to reduce noise.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/ir3/ir3.h
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/ir3/ir3_cp.c

index e58618ca4322cc9e913c43e1e632d6b9c50506fa..e0d0eeebc815110c02812ebaa53d4fff363d8acb 100644 (file)
@@ -910,7 +910,8 @@ void ir3_insert_by_depth(struct ir3_instruction *instr, struct list_head *list);
 void ir3_depth(struct ir3 *ir);
 
 /* copy-propagate: */
-void ir3_cp(struct ir3 *ir);
+struct ir3_shader_variant;
+void ir3_cp(struct ir3 *ir, struct ir3_shader_variant *so);
 
 /* group neighbors and insert mov's to resolve conflicts: */
 void ir3_group(struct ir3 *ir);
index 6b7bb9f1dfc62414e4128bc36ac8f185daf3a2c1..69e8335a2039dea358c334bc6c00666edb8357b0 100644 (file)
@@ -2419,7 +2419,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
                ir3_print(ir);
        }
 
-       ir3_cp(ir);
+       ir3_cp(ir, so);
 
        if (fd_mesa_debug & FD_DBG_OPTMSGS) {
                printf("BEFORE GROUPING:\n");
index cec26fa4f57f9c747ff66b3c3afd3ff019bc07cc..267664c961a02ad774bed696622af0b121700881 100644 (file)
  * Copy Propagate:
  */
 
+struct ir3_cp_ctx {
+       struct ir3_shader_variant *so;
+};
+
 /* is it a type preserving mov, with ok flags? */
 static bool is_eligible_mov(struct ir3_instruction *instr, bool allow_flags)
 {
@@ -237,7 +241,8 @@ static void combine_flags(unsigned *dstflags, struct ir3_instruction *src)
  * instruction).
  */
 static void
-reg_cp(struct ir3_instruction *instr, struct ir3_register *reg, unsigned n)
+reg_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr,
+               struct ir3_register *reg, unsigned n)
 {
        struct ir3_instruction *src = ssa(reg);
 
@@ -404,7 +409,7 @@ eliminate_output_mov(struct ir3_instruction *instr)
  * the mov dst with the mov src
  */
 static void
-instr_cp(struct ir3_instruction *instr)
+instr_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr)
 {
        struct ir3_register *reg;
 
@@ -421,7 +426,7 @@ instr_cp(struct ir3_instruction *instr)
                if (!src)
                        continue;
 
-               instr_cp(src);
+               instr_cp(ctx, src);
 
                /* TODO non-indirect access we could figure out which register
                 * we actually want and allow cp..
@@ -429,17 +434,17 @@ instr_cp(struct ir3_instruction *instr)
                if (reg->flags & IR3_REG_ARRAY)
                        continue;
 
-               reg_cp(instr, reg, n);
+               reg_cp(ctx, instr, reg, n);
        }
 
        if (instr->regs[0]->flags & IR3_REG_ARRAY) {
                struct ir3_instruction *src = ssa(instr->regs[0]);
                if (src)
-                       instr_cp(src);
+                       instr_cp(ctx, src);
        }
 
        if (instr->address) {
-               instr_cp(instr->address);
+               instr_cp(ctx, instr->address);
                ir3_instr_set_address(instr, eliminate_output_mov(instr->address));
        }
 
@@ -476,25 +481,29 @@ instr_cp(struct ir3_instruction *instr)
 }
 
 void
-ir3_cp(struct ir3 *ir)
+ir3_cp(struct ir3 *ir, struct ir3_shader_variant *so)
 {
+       struct ir3_cp_ctx ctx = {
+                       .so = so,
+       };
+
        ir3_clear_mark(ir);
 
        for (unsigned i = 0; i < ir->noutputs; i++) {
                if (ir->outputs[i]) {
-                       instr_cp(ir->outputs[i]);
+                       instr_cp(&ctx, ir->outputs[i]);
                        ir->outputs[i] = eliminate_output_mov(ir->outputs[i]);
                }
        }
 
        for (unsigned i = 0; i < ir->keeps_count; i++) {
-               instr_cp(ir->keeps[i]);
+               instr_cp(&ctx, ir->keeps[i]);
                ir->keeps[i] = eliminate_output_mov(ir->keeps[i]);
        }
 
        list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
                if (block->condition) {
-                       instr_cp(block->condition);
+                       instr_cp(&ctx, block->condition);
                        block->condition = eliminate_output_mov(block->condition);
                }
        }