freedreno/ir3: move 'keeps' to block level
authorRob Clark <robdclark@gmail.com>
Wed, 5 Apr 2017 00:29:53 +0000 (20:29 -0400)
committerRob Clark <robdclark@gmail.com>
Fri, 14 Apr 2017 16:46:12 +0000 (12:46 -0400)
For things like SSBOs and atomics we'll want to track this at a block
level.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/ir3/ir3.h
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/ir3/ir3_cp.c
src/gallium/drivers/freedreno/ir3/ir3_depth.c
src/gallium/drivers/freedreno/ir3/ir3_group.c

index c205c8fac48d66d820cf75ce815a5f0aea59e63f..480b27ce5dae37183fafaecb532a2923a4187f46 100644 (file)
@@ -369,12 +369,6 @@ struct ir3 {
        unsigned predicates_count, predicates_sz;
        struct ir3_instruction **predicates;
 
-       /* Track instructions which do not write a register but other-
-        * wise must not be discarded (such as kill, stg, etc)
-        */
-       unsigned keeps_count, keeps_sz;
-       struct ir3_instruction **keeps;
-
        /* Track texture sample instructions which need texture state
         * patched in (for astc-srgb workaround):
         */
@@ -435,6 +429,12 @@ struct ir3_block {
 
        uint16_t start_ip, end_ip;
 
+       /* Track instructions which do not write a register but other-
+        * wise must not be discarded (such as kill, stg, etc)
+        */
+       unsigned keeps_count, keeps_sz;
+       struct ir3_instruction **keeps;
+
        /* used for per-pass extra block data.  Mainly used right
         * now in RA step to track livein/liveout.
         */
index 7932a6f18a37a2d2cd66f3e6dcff5b4dc44de21f..22619e852c24182b8a65dede233d80aaacac6de7 100644 (file)
@@ -1308,7 +1308,7 @@ emit_intrinsic(struct ir3_compile *ctx, nir_intrinsic_instr *intr)
                kill = ir3_KILL(b, cond, 0);
                array_insert(ctx->ir, ctx->ir->predicates, kill);
 
-               array_insert(ctx->ir, ctx->ir->keeps, kill);
+               array_insert(b, b->keeps, kill);
                ctx->so->has_kill = true;
 
                break;
@@ -1972,7 +1972,7 @@ emit_stream_out(struct ir3_compile *ctx)
                        stg->cat6.type = TYPE_U32;
                        stg->cat6.dst_offset = (strmout->output[i].dst_offset + j) * 4;
 
-                       array_insert(ctx->ir, ctx->ir->keeps, stg);
+                       array_insert(ctx->block, ctx->block->keeps, stg);
                }
        }
 
index 71e02615c75e81366ddf91f2eb8e8932ea666005..a9023ce571c858e58c311b453f8b6f7a2de0fac5 100644 (file)
@@ -576,15 +576,15 @@ ir3_cp(struct ir3 *ir, struct ir3_shader_variant *so)
                }
        }
 
-       for (unsigned i = 0; i < ir->keeps_count; 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(&ctx, block->condition);
                        block->condition = eliminate_output_mov(block->condition);
                }
+
+               for (unsigned i = 0; i < block->keeps_count; i++) {
+                       instr_cp(&ctx, block->keeps[i]);
+                       block->keeps[i] = eliminate_output_mov(block->keeps[i]);
+               }
        }
 }
index 1b8a446ca652411234e68f737bf34ca9c6a37762..be39027b6a0b79fe895bf6473ae271e9a992683d 100644 (file)
@@ -159,11 +159,11 @@ ir3_depth(struct ir3 *ir)
                if (ir->outputs[i])
                        ir3_instr_depth(ir->outputs[i]);
 
-       for (i = 0; i < ir->keeps_count; i++)
-               ir3_instr_depth(ir->keeps[i]);
-
-       /* We also need to account for if-condition: */
        list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+               for (i = 0; i < block->keeps_count; i++)
+                       ir3_instr_depth(block->keeps[i]);
+
+               /* We also need to account for if-condition: */
                if (block->condition)
                        ir3_instr_depth(block->condition);
        }
index 633d66c58d436cba039bd6441f61cb380c8123ca..2719b6459e31978ebfdc32a9be062b9cda38ab0b 100644 (file)
@@ -254,9 +254,11 @@ find_neighbors(struct ir3 *ir)
                }
        }
 
-       for (i = 0; i < ir->keeps_count; i++) {
-               struct ir3_instruction *instr = ir->keeps[i];
-               instr_find_neighbors(instr);
+       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+               for (i = 0; i < block->keeps_count; i++) {
+                       struct ir3_instruction *instr = block->keeps[i];
+                       instr_find_neighbors(instr);
+               }
        }
 }