ir3: Add ir3_start_block()
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 4 May 2021 09:11:04 +0000 (11:11 +0200)
committerEmma Anholt <emma@anholt.net>
Thu, 10 Jun 2021 19:20:38 +0000 (12:20 -0700)
Name based on nir_start_block(). A number of places were already
open-coding this, convert them.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9842>

src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_legalize.c
src/freedreno/ir3/tests/delay.c

index 6a37afa..3fdcdfe 100644 (file)
@@ -584,6 +584,12 @@ block_id(struct ir3_block *block)
 #endif
 }
 
+static inline struct ir3_block *
+ir3_start_block(struct ir3 *ir)
+{
+       return list_first_entry(&ir->block_list, struct ir3_block, node);
+}
+
 void ir3_block_add_predecessor(struct ir3_block *block, struct ir3_block *pred);
 void ir3_block_remove_predecessor(struct ir3_block *block, struct ir3_block *pred);
 unsigned ir3_block_get_pred_index(struct ir3_block *block, struct ir3_block *pred);
index 72073f6..d706506 100644 (file)
@@ -127,7 +127,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
         * with the end of the program.
         */
        assert(input_count == 0 || !ctx->early_input_release ||
-                  block == list_first_entry(&block->shader->block_list, struct ir3_block, node));
+                  block == ir3_start_block(block->shader));
 
        /* remove all the instructions from the list, we'll be adding
         * them back in as we go
@@ -793,11 +793,10 @@ ir3_legalize(struct ir3 *ir, struct ir3_shader_variant *so, int *max_bary)
         * a5xx and a6xx do automatically release varying storage at the end.
         */
        ctx->early_input_release = true;
-       struct ir3_block *first_block =
-               list_first_entry(&ir->block_list, struct ir3_block, node);
+       struct ir3_block *start_block = ir3_start_block(ir);
        foreach_block (block, &ir->block_list) {
                foreach_instr (instr, &block->instr_list) {
-                       if (is_input(instr) && block != first_block) {
+                       if (is_input(instr) && block != start_block) {
                                ctx->early_input_release = false;
                                break;
                        }
index ef6cd55..79a66d2 100644 (file)
@@ -122,8 +122,7 @@ static void
 regs_to_ssa(struct ir3 *ir)
 {
        struct ir3_instruction *regfile[2 * MAX_REG] = {};
-       struct ir3_block *block =
-               list_first_entry(&ir->block_list, struct ir3_block, node);
+       struct ir3_block *block = ir3_start_block(ir);
 
        foreach_instr_safe (instr, &block->instr_list) {
                foreach_src (reg, instr) {