freedreno/ir3: add iterator macros
authorRob Clark <robdclark@chromium.org>
Thu, 12 Dec 2019 23:30:49 +0000 (15:30 -0800)
committerRob Clark <robdclark@chromium.org>
Fri, 13 Dec 2019 17:25:40 +0000 (09:25 -0800)
So many open coded list iterators were getting annoying.

Signed-off-by: Rob Clark <robdclark@chromium.org>
13 files changed:
src/freedreno/ir3/ir3.c
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_a6xx.c
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_context.c
src/freedreno/ir3/ir3_cp.c
src/freedreno/ir3/ir3_depth.c
src/freedreno/ir3/ir3_group.c
src/freedreno/ir3/ir3_legalize.c
src/freedreno/ir3/ir3_print.c
src/freedreno/ir3/ir3_ra.c
src/freedreno/ir3/ir3_sched.c
src/freedreno/ir3/ir3_sun.c

index af3d51527248d6a887ab440aaab49c6195982b8c..bcf6a5dd98926991599ddef84454bc0b695c4ebd 100644 (file)
@@ -892,8 +892,8 @@ void * ir3_assemble(struct ir3 *shader, struct ir3_info *info,
        info->sizedwords    = 0;
        info->ss = info->sy = 0;
 
-       list_for_each_entry (struct ir3_block, block, &shader->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &shader->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        info->sizedwords += 2;
                }
        }
@@ -910,8 +910,8 @@ void * ir3_assemble(struct ir3 *shader, struct ir3_info *info,
 
        ptr = dwords = calloc(4, info->sizedwords);
 
-       list_for_each_entry (struct ir3_block, block, &shader->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &shader->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        int ret = emit[opc_cat(instr->opc)](instr, dwords, info);
                        if (ret)
                                goto fail;
@@ -1082,14 +1082,14 @@ ir3_instr_set_address(struct ir3_instruction *instr,
 void
 ir3_block_clear_mark(struct ir3_block *block)
 {
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node)
+       foreach_instr (instr, &block->instr_list)
                instr->flags &= ~IR3_INSTR_MARK;
 }
 
 void
 ir3_clear_mark(struct ir3 *ir)
 {
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                ir3_block_clear_mark(block);
        }
 }
@@ -1099,10 +1099,10 @@ unsigned
 ir3_count_instructions(struct ir3 *ir)
 {
        unsigned cnt = 0;
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                block->start_ip = cnt;
                block->end_ip = cnt;
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+               foreach_instr (instr, &block->instr_list) {
                        instr->ip = cnt++;
                        block->end_ip = instr->ip;
                }
@@ -1113,7 +1113,7 @@ ir3_count_instructions(struct ir3 *ir)
 struct ir3_array *
 ir3_lookup_array(struct ir3 *ir, unsigned id)
 {
-       list_for_each_entry (struct ir3_array, arr, &ir->array_list, node)
+       foreach_array (arr, &ir->array_list)
                if (arr->id == id)
                        return arr;
        return NULL;
index 888cf5fcbed7252bc1ee2e90b0f2ddbcd27a54cd..70d7d5e9cb360824de8c214f557dcfa06f26b1a3 100644 (file)
@@ -1089,6 +1089,24 @@ static inline bool __is_false_dep(struct ir3_instruction *instr, unsigned n)
 #define foreach_output(__outinstr, __ir) \
        foreach_output_n(__outinstr, __i, __ir)
 
+/* iterators for instructions: */
+#define foreach_instr(__instr, __list) \
+       list_for_each_entry(struct ir3_instruction, __instr, __list, node)
+#define foreach_instr_rev(__instr, __list) \
+       list_for_each_entry_rev(struct ir3_instruction, __instr, __list, node)
+#define foreach_instr_safe(__instr, __list) \
+       list_for_each_entry_safe(struct ir3_instruction, __instr, __list, node)
+
+/* iterators for blocks: */
+#define foreach_block(__block, __list) \
+       list_for_each_entry(struct ir3_block, __block, __list, node)
+#define foreach_block_safe(__block, __list) \
+       list_for_each_entry_safe(struct ir3_block, __block, __list, node)
+
+/* iterators for arrays: */
+#define foreach_array(__array, __list) \
+       list_for_each_entry(struct ir3_array, __array, __list, node)
+
 /* dump: */
 void ir3_print(struct ir3 *ir);
 void ir3_print_instr(struct ir3_instruction *instr);
index 457b20d00716d84861a53aa6707fc4b46d3c7b20..fe3355bf2eb31f518905e9dca92b97724cc7a8ef 100644 (file)
@@ -386,14 +386,14 @@ ir3_a6xx_fixup_atomic_dests(struct ir3 *ir, struct ir3_shader_variant *so)
        if (so->image_mapping.num_ibo == 0)
                return;
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ir->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        instr->data = NULL;
                }
        }
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
-               list_for_each_entry_safe (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ir->block_list) {
+               foreach_instr_safe (instr, &block->instr_list) {
                        struct ir3_register *reg;
 
                        foreach_src(reg, instr) {
index 398480ea346a78a8bc5619d4b86291bcdd62f8c4..bc4cdae0e93b9ff2b240921cf89c56f03fe84611 100644 (file)
@@ -2806,8 +2806,8 @@ pack_inlocs(struct ir3_context *ctx)
         * First Step: scan shader to find which bary.f/ldlv remain:
         */
 
-       list_for_each_entry (struct ir3_block, block, &ctx->ir->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ctx->ir->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        if (is_input(instr)) {
                                unsigned inloc = instr->regs[1]->iim_val;
                                unsigned i = inloc / 4;
@@ -2870,8 +2870,8 @@ pack_inlocs(struct ir3_context *ctx)
         * Third Step: reassign packed inloc's:
         */
 
-       list_for_each_entry (struct ir3_block, block, &ctx->ir->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ctx->ir->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        if (is_input(instr)) {
                                unsigned inloc = instr->regs[1]->iim_val;
                                unsigned i = inloc / 4;
@@ -3185,9 +3185,8 @@ collect_tex_prefetches(struct ir3_context *ctx, struct ir3 *ir)
        unsigned idx = 0;
 
        /* Collect sampling instructions eligible for pre-dispatch. */
-       list_for_each_entry(struct ir3_block, block, &ir->block_list, node) {
-               list_for_each_entry_safe(struct ir3_instruction, instr,
-                               &block->instr_list, node) {
+       foreach_block (block, &ir->block_list) {
+               foreach_instr_safe (instr, &block->instr_list) {
                        if (instr->opc == OPC_META_TEX_PREFETCH) {
                                assert(idx < ARRAY_SIZE(ctx->so->sampler_prefetch));
                                struct ir3_sampler_prefetch *fetch =
@@ -3522,8 +3521,8 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
         */
        if (so->type == MESA_SHADER_TESS_CTRL ||
                so->type == MESA_SHADER_GEOMETRY ) {
-               list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
-                       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+               foreach_block (block, &ir->block_list) {
+                       foreach_instr (instr, &block->instr_list) {
                                instr->flags |= IR3_INSTR_SS | IR3_INSTR_SY;
                                break;
                        }
index c358b37a896f8885c504b577bad183f8cd13da11..334b0ae0bab5ce39a6d80f0f5b4023613d0629b0 100644 (file)
@@ -483,7 +483,7 @@ ir3_declare_array(struct ir3_context *ctx, nir_register *reg)
 struct ir3_array *
 ir3_get_array(struct ir3_context *ctx, nir_register *reg)
 {
-       list_for_each_entry (struct ir3_array, arr, &ctx->ir->array_list, node) {
+       foreach_array (arr, &ctx->ir->array_list) {
                if (arr->r == reg)
                        return arr;
        }
index f8298d6075273a8c1d596ec6a4d114841a010345..e04f1daae6b8a6cc17e1665958e5ac9d7efcf0a8 100644 (file)
@@ -742,8 +742,8 @@ ir3_cp(struct ir3 *ir, struct ir3_shader_variant *so)
         * a mov, so we need to do a pass to first count consumers of a
         * mov.
         */
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ir->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        struct ir3_instruction *src;
 
                        /* by the way, we don't account for false-dep's, so the CP
@@ -765,7 +765,7 @@ ir3_cp(struct ir3 *ir, struct ir3_shader_variant *so)
                ir->outputs[n] = eliminate_output_mov(out);
        }
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                if (block->condition) {
                        instr_cp(&ctx, block->condition);
                        block->condition = eliminate_output_mov(block->condition);
index 4bbd1e56d7c1156761a7603b330f3ee41ce97e9a..d2ab9feaa4564f38417c2a3b82cf861cfcf80b95 100644 (file)
@@ -121,7 +121,7 @@ ir3_insert_by_depth(struct ir3_instruction *instr, struct list_head *list)
        list_delinit(&instr->node);
 
        /* find where to re-insert instruction: */
-       list_for_each_entry (struct ir3_instruction, pos, list, node) {
+       foreach_instr (pos, list) {
                if (pos->depth > instr->depth) {
                        list_add(&instr->node, &pos->node);
                        return;
@@ -171,7 +171,7 @@ static bool
 remove_unused_by_block(struct ir3_block *block)
 {
        bool progress = false;
-       list_for_each_entry_safe (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr_safe (instr, &block->instr_list) {
                if (instr->opc == OPC_END || instr->opc == OPC_CHSH || instr->opc == OPC_CHMASK)
                        continue;
                if (instr->flags & IR3_INSTR_UNUSED) {
@@ -217,8 +217,8 @@ compute_depth_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so)
        /* initially mark everything as unused, we'll clear the flag as we
         * visit the instructions:
         */
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ir->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        /* special case, if pre-fs texture fetch used, we cannot
                         * eliminate the barycentric i/j input
                         */
@@ -234,7 +234,7 @@ compute_depth_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so)
        foreach_output(out, ir)
                ir3_instr_depth(out, 0, false);
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                for (i = 0; i < block->keeps_count; i++)
                        ir3_instr_depth(block->keeps[i], 0, false);
 
@@ -244,7 +244,7 @@ compute_depth_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so)
        }
 
        /* mark un-used instructions: */
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                progress |= remove_unused_by_block(block);
        }
 
index f86397565f0e646395f068cf64c42adb1cd58d6b..6689afe1bd53227437973edf3fc0a17590517bf9 100644 (file)
@@ -166,7 +166,7 @@ find_neighbors(struct ir3 *ir)
        foreach_output(out, ir)
                instr_find_neighbors(out);
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                for (i = 0; i < block->keeps_count; i++) {
                        struct ir3_instruction *instr = block->keeps[i];
                        instr_find_neighbors(instr);
index 4470eabd35278d7153d99a1d1646feb792689f85..025a8537c18deaee169b0b0530a5cfe2598ba595 100644 (file)
@@ -113,7 +113,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
        list_replace(&block->instr_list, &instr_list);
        list_inithead(&block->instr_list);
 
-       list_for_each_entry_safe (struct ir3_instruction, n, &instr_list, node) {
+       foreach_instr_safe (n, &instr_list) {
                struct ir3_register *reg;
                unsigned i;
 
@@ -521,8 +521,8 @@ resolve_jump(struct ir3_instruction *instr)
 static bool
 resolve_jumps(struct ir3 *ir)
 {
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node)
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node)
+       foreach_block (block, &ir->block_list)
+               foreach_instr (instr, &block->instr_list)
                        if (is_flow(instr) && instr->cat0.target)
                                if (resolve_jump(instr))
                                        return true;
@@ -547,7 +547,7 @@ static void mark_jp(struct ir3_block *block)
 static void
 mark_xvergence_points(struct ir3 *ir)
 {
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                if (block->predecessors->entries > 1) {
                        /* if a block has more than one possible predecessor, then
                         * the first instruction is a convergence point.
@@ -578,14 +578,14 @@ ir3_legalize(struct ir3 *ir, bool *has_ssbo, bool *need_pixlod, int *max_bary)
        ctx->type = ir->type;
 
        /* allocate per-block data: */
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                block->data = rzalloc(ctx, struct ir3_legalize_block_data);
        }
 
        /* process each block: */
        do {
                progress = false;
-               list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+               foreach_block (block, &ir->block_list) {
                        progress |= legalize_block(ctx, block);
                }
        } while (progress);
index db4cc98df904228449ae63f3b5cc971cee96fbb6..244239dd24096a76555a5cd01e1520593e7f6fa6 100644 (file)
@@ -290,7 +290,7 @@ print_block(struct ir3_block *block, int lvl)
                printf("\n");
        }
 
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr (instr, &block->instr_list) {
                print_instr(instr, lvl+1);
        }
 
@@ -319,7 +319,7 @@ print_block(struct ir3_block *block, int lvl)
 void
 ir3_print(struct ir3 *ir)
 {
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node)
+       foreach_block (block, &ir->block_list)
                print_block(block, 0);
 
        struct ir3_instruction *out;
index c3d8e88f54a523e1fb87c865e9cab89b1f5b1cd0..9f0d71f9f4e91ddde5f585af56d0f02328f56e4a 100644 (file)
@@ -529,7 +529,7 @@ get_definer(struct ir3_ra_ctx *ctx, struct ir3_instruction *instr,
 static void
 ra_block_find_definers(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 {
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr (instr, &block->instr_list) {
                struct ir3_ra_instr_data *id = &ctx->instrd[instr->ip];
                if (instr->regs_count == 0)
                        continue;
@@ -579,7 +579,7 @@ ra_block_find_definers(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 static void
 ra_block_name_instructions(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 {
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr (instr, &block->instr_list) {
                struct ir3_ra_instr_data *id = &ctx->instrd[instr->ip];
 
 #ifdef DEBUG
@@ -614,11 +614,11 @@ ra_init(struct ir3_ra_ctx *ctx)
 
        ctx->instrd = rzalloc_array(NULL, struct ir3_ra_instr_data, n);
 
-       list_for_each_entry (struct ir3_block, block, &ctx->ir->block_list, node) {
+       foreach_block (block, &ctx->ir->block_list) {
                ra_block_find_definers(ctx, block);
        }
 
-       list_for_each_entry (struct ir3_block, block, &ctx->ir->block_list, node) {
+       foreach_block (block, &ctx->ir->block_list) {
                ra_block_name_instructions(ctx, block);
        }
 
@@ -633,7 +633,7 @@ ra_init(struct ir3_ra_ctx *ctx)
 
        /* and vreg names for array elements: */
        base = ctx->class_base[total_class_count];
-       list_for_each_entry (struct ir3_array, arr, &ctx->ir->array_list, node) {
+       foreach_array (arr, &ctx->ir->array_list) {
                arr->base = base;
                ctx->class_alloc_count[total_class_count] += arr->length;
                base += arr->length;
@@ -702,7 +702,7 @@ ra_block_compute_live_ranges(struct ir3_ra_ctx *ctx, struct ir3_block *block)
        block->data = bd;
 
        struct ir3_instruction *first_non_input = NULL;
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr (instr, &block->instr_list) {
                if (instr->opc != OPC_META_INPUT) {
                        first_non_input = instr;
                        break;
@@ -710,7 +710,7 @@ ra_block_compute_live_ranges(struct ir3_ra_ctx *ctx, struct ir3_block *block)
        }
 
 
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr (instr, &block->instr_list) {
                struct ir3_instruction *src;
                struct ir3_register *reg;
 
@@ -832,7 +832,7 @@ ra_compute_livein_liveout(struct ir3_ra_ctx *ctx)
        unsigned bitset_words = BITSET_WORDS(ctx->alloc_count);
        bool progress = false;
 
-       list_for_each_entry (struct ir3_block, block, &ctx->ir->block_list, node) {
+       foreach_block (block, &ctx->ir->block_list) {
                struct ir3_ra_block_data *bd = block->data;
 
                /* update livein: */
@@ -893,7 +893,7 @@ ra_add_interference(struct ir3_ra_ctx *ctx)
        struct ir3 *ir = ctx->ir;
 
        /* initialize array live ranges: */
-       list_for_each_entry (struct ir3_array, arr, &ir->array_list, node) {
+       foreach_array (arr, &ir->array_list) {
                arr->start_ip = ~0;
                arr->end_ip = 0;
        }
@@ -902,7 +902,7 @@ ra_add_interference(struct ir3_ra_ctx *ctx)
         * block's def/use bitmasks (used below to calculate per-block
         * livein/liveout):
         */
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                ra_block_compute_live_ranges(ctx, block);
        }
 
@@ -911,7 +911,7 @@ ra_add_interference(struct ir3_ra_ctx *ctx)
 
        if (ir3_shader_debug & IR3_DBG_OPTMSGS) {
                debug_printf("AFTER LIVEIN/OUT:\n");
-               list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+               foreach_block (block, &ir->block_list) {
                        struct ir3_ra_block_data *bd = block->data;
                        debug_printf("block%u:\n", block_id(block));
                        print_bitset("  def", bd->def, ctx->alloc_count);
@@ -919,7 +919,7 @@ ra_add_interference(struct ir3_ra_ctx *ctx)
                        print_bitset("  l/i", bd->livein, ctx->alloc_count);
                        print_bitset("  l/o", bd->liveout, ctx->alloc_count);
                }
-               list_for_each_entry (struct ir3_array, arr, &ir->array_list, node) {
+               foreach_array (arr, &ir->array_list) {
                        debug_printf("array%u:\n", arr->id);
                        debug_printf("  length:   %u\n", arr->length);
                        debug_printf("  start_ip: %u\n", arr->start_ip);
@@ -928,7 +928,7 @@ ra_add_interference(struct ir3_ra_ctx *ctx)
        }
 
        /* extend start/end ranges based on livein/liveout info from cfg: */
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                struct ir3_ra_block_data *bd = block->data;
 
                for (unsigned i = 0; i < ctx->alloc_count; i++) {
@@ -943,7 +943,7 @@ ra_add_interference(struct ir3_ra_ctx *ctx)
                        }
                }
 
-               list_for_each_entry (struct ir3_array, arr, &ctx->ir->array_list, node) {
+               foreach_array (arr, &ctx->ir->array_list) {
                        for (unsigned i = 0; i < arr->length; i++) {
                                if (BITSET_TEST(bd->livein, i + arr->base)) {
                                        arr->start_ip = MIN2(arr->start_ip, block->start_ip);
@@ -1075,7 +1075,7 @@ reg_assign(struct ir3_ra_ctx *ctx, struct ir3_register *reg,
 static void
 ra_block_alloc(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 {
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr (instr, &block->instr_list) {
                struct ir3_register *reg;
 
                if (writes_gpr(instr)) {
@@ -1141,7 +1141,7 @@ ra_precolor(struct ir3_ra_ctx *ctx, struct ir3_instruction **precolor, unsigned
 
        /* pre-assign array elements:
         */
-       list_for_each_entry (struct ir3_array, arr, &ctx->ir->array_list, node) {
+       foreach_array (arr, &ctx->ir->array_list) {
                unsigned base = 0;
 
                if (arr->end_ip == 0)
@@ -1151,7 +1151,7 @@ ra_precolor(struct ir3_ra_ctx *ctx, struct ir3_instruction **precolor, unsigned
                 * been assigned:
                 */
 retry:
-               list_for_each_entry (struct ir3_array, arr2, &ctx->ir->array_list, node) {
+               foreach_array (arr2, &ctx->ir->array_list) {
                        if (arr2 == arr)
                                break;
                        if (arr2->end_ip == 0)
@@ -1213,7 +1213,7 @@ ra_alloc(struct ir3_ra_ctx *ctx)
        if (!ra_allocate(ctx->g))
                return -1;
 
-       list_for_each_entry (struct ir3_block, block, &ctx->ir->block_list, node) {
+       foreach_block (block, &ctx->ir->block_list) {
                ra_block_alloc(ctx, block);
        }
 
index 0756eaf51408d66c0369830ada258f3d323ddd74..c2f6b3e020d8aab4e4cf15d90d0448a0b1ba13fb 100644 (file)
@@ -168,14 +168,14 @@ update_live_values(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr)
 static void
 update_use_count(struct ir3 *ir)
 {
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ir->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        instr->use_count = 0;
                }
        }
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
-               list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_block (block, &ir->block_list) {
+               foreach_instr (instr, &block->instr_list) {
                        if ((instr->opc == OPC_META_COLLECT) || (instr->opc == OPC_META_SPLIT))
                                continue;
 
@@ -195,7 +195,7 @@ update_use_count(struct ir3 *ir)
 static void
 clear_cache(struct ir3_sched_ctx *ctx, struct ir3_instruction *instr)
 {
-       list_for_each_entry (struct ir3_instruction, instr2, &ctx->depth_list, node) {
+       foreach_instr (instr2, &ctx->depth_list) {
                if ((instr2->data == instr) || (instr2->data == NULL_INSTR) || !instr)
                        instr2->data = NULL;
        }
@@ -285,7 +285,7 @@ distance(struct ir3_block *block, struct ir3_instruction *instr,
 {
        unsigned d = 0;
 
-       list_for_each_entry_rev (struct ir3_instruction, n, &block->instr_list, node) {
+       foreach_instr_rev (n, &block->instr_list) {
                if ((n == instr) || (d >= maxd))
                        return d;
                /* NOTE: don't count branch/jump since we don't know yet if they will
@@ -603,7 +603,7 @@ find_eligible_instr(struct ir3_sched_ctx *ctx, struct ir3_sched_notes *notes,
         * get traversed both when they appear as ssa src to a later instruction
         * as well as where they appear in the depth_list.
         */
-       list_for_each_entry_rev (struct ir3_instruction, instr, &ctx->depth_list, node) {
+       foreach_instr_rev (instr, &ctx->depth_list) {
                struct ir3_instruction *candidate;
 
                candidate = find_instr_recursive(ctx, notes, instr);
@@ -619,7 +619,7 @@ find_eligible_instr(struct ir3_sched_ctx *ctx, struct ir3_sched_notes *notes,
        /* traverse the list a second time.. but since we cache the result of
         * find_instr_recursive() it isn't as bad as it looks.
         */
-       list_for_each_entry_rev (struct ir3_instruction, instr, &ctx->depth_list, node) {
+       foreach_instr_rev (instr, &ctx->depth_list) {
                struct ir3_instruction *candidate;
 
                candidate = find_instr_recursive(ctx, notes, instr);
@@ -807,15 +807,15 @@ sched_block(struct ir3_sched_ctx *ctx, struct ir3_block *block)
         * Finally, move all the remaining instructions to the depth-
         * list
         */
-       list_for_each_entry_safe (struct ir3_instruction, instr, &unscheduled_list, node)
+       foreach_instr_safe (instr, &unscheduled_list)
                if (instr->opc == OPC_META_INPUT)
                        schedule(ctx, instr);
 
-       list_for_each_entry_safe (struct ir3_instruction, instr, &unscheduled_list, node)
+       foreach_instr_safe (instr, &unscheduled_list)
                if (instr->opc == OPC_META_TEX_PREFETCH)
                        schedule(ctx, instr);
 
-       list_for_each_entry_safe (struct ir3_instruction, instr, &unscheduled_list, node)
+       foreach_instr_safe (instr, &unscheduled_list)
                ir3_insert_by_depth(instr, &ctx->depth_list);
 
        while (!list_is_empty(&ctx->depth_list)) {
@@ -939,7 +939,7 @@ sched_intra_block(struct ir3_sched_ctx *ctx, struct ir3_block *block)
 
        ctx->block = block;
 
-       list_for_each_entry_safe (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr_safe (instr, &block->instr_list) {
                unsigned delay = 0;
 
                set_foreach(block->predecessors, entry) {
@@ -971,12 +971,12 @@ int ir3_sched(struct ir3 *ir)
        ir3_clear_mark(ir);
        update_use_count(ir);
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                ctx.live_values = 0;
                sched_block(&ctx, block);
        }
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                sched_intra_block(&ctx, block);
        }
 
@@ -1091,7 +1091,7 @@ add_barrier_deps(struct ir3_block *block, struct ir3_instruction *instr)
 static void
 calculate_deps(struct ir3_block *block)
 {
-       list_for_each_entry (struct ir3_instruction, instr, &block->instr_list, node) {
+       foreach_instr (instr, &block->instr_list) {
                if (instr->barrier_class) {
                        add_barrier_deps(block, instr);
                }
@@ -1101,7 +1101,7 @@ calculate_deps(struct ir3_block *block)
 void
 ir3_sched_add_deps(struct ir3 *ir)
 {
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                calculate_deps(block);
        }
 }
index c31e03129f0a4a56c0969e6522184b412c277909..ed518736de92409f0240634fc92d76afae1a39fe 100644 (file)
@@ -100,7 +100,7 @@ ir3_sun(struct ir3 *ir)
        foreach_output(out, ir)
                max = MAX2(max, number_instr(out));
 
-       list_for_each_entry (struct ir3_block, block, &ir->block_list, node) {
+       foreach_block (block, &ir->block_list) {
                for (unsigned i = 0; i < block->keeps_count; i++)
                        max = MAX2(max, number_instr(block->keeps[i]));
                if (block->condition)