From 3b8feefd9c324387263962d8a1a7aa3440a0e873 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 12 Dec 2019 15:30:49 -0800 Subject: [PATCH] freedreno/ir3: add iterator macros So many open coded list iterators were getting annoying. Signed-off-by: Rob Clark --- src/freedreno/ir3/ir3.c | 18 +++++++------- src/freedreno/ir3/ir3.h | 18 ++++++++++++++ src/freedreno/ir3/ir3_a6xx.c | 8 +++---- src/freedreno/ir3/ir3_compiler_nir.c | 17 +++++++------ src/freedreno/ir3/ir3_context.c | 2 +- src/freedreno/ir3/ir3_cp.c | 6 ++--- src/freedreno/ir3/ir3_depth.c | 12 +++++----- src/freedreno/ir3/ir3_group.c | 2 +- src/freedreno/ir3/ir3_legalize.c | 12 +++++----- src/freedreno/ir3/ir3_print.c | 4 ++-- src/freedreno/ir3/ir3_ra.c | 36 ++++++++++++++-------------- src/freedreno/ir3/ir3_sched.c | 32 ++++++++++++------------- src/freedreno/ir3/ir3_sun.c | 2 +- 13 files changed, 93 insertions(+), 76 deletions(-) diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c index af3d5152724..bcf6a5dd989 100644 --- a/src/freedreno/ir3/ir3.c +++ b/src/freedreno/ir3/ir3.c @@ -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; diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h index 888cf5fcbed..70d7d5e9cb3 100644 --- a/src/freedreno/ir3/ir3.h +++ b/src/freedreno/ir3/ir3.h @@ -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); diff --git a/src/freedreno/ir3/ir3_a6xx.c b/src/freedreno/ir3/ir3_a6xx.c index 457b20d0071..fe3355bf2eb 100644 --- a/src/freedreno/ir3/ir3_a6xx.c +++ b/src/freedreno/ir3/ir3_a6xx.c @@ -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) { diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 398480ea346..bc4cdae0e93 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -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; } diff --git a/src/freedreno/ir3/ir3_context.c b/src/freedreno/ir3/ir3_context.c index c358b37a896..334b0ae0bab 100644 --- a/src/freedreno/ir3/ir3_context.c +++ b/src/freedreno/ir3/ir3_context.c @@ -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; } diff --git a/src/freedreno/ir3/ir3_cp.c b/src/freedreno/ir3/ir3_cp.c index f8298d60752..e04f1daae6b 100644 --- a/src/freedreno/ir3/ir3_cp.c +++ b/src/freedreno/ir3/ir3_cp.c @@ -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); diff --git a/src/freedreno/ir3/ir3_depth.c b/src/freedreno/ir3/ir3_depth.c index 4bbd1e56d7c..d2ab9feaa45 100644 --- a/src/freedreno/ir3/ir3_depth.c +++ b/src/freedreno/ir3/ir3_depth.c @@ -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); } diff --git a/src/freedreno/ir3/ir3_group.c b/src/freedreno/ir3/ir3_group.c index f86397565f0..6689afe1bd5 100644 --- a/src/freedreno/ir3/ir3_group.c +++ b/src/freedreno/ir3/ir3_group.c @@ -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); diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c index 4470eabd352..025a8537c18 100644 --- a/src/freedreno/ir3/ir3_legalize.c +++ b/src/freedreno/ir3/ir3_legalize.c @@ -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); diff --git a/src/freedreno/ir3/ir3_print.c b/src/freedreno/ir3/ir3_print.c index db4cc98df90..244239dd240 100644 --- a/src/freedreno/ir3/ir3_print.c +++ b/src/freedreno/ir3/ir3_print.c @@ -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; diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c index c3d8e88f54a..9f0d71f9f4e 100644 --- a/src/freedreno/ir3/ir3_ra.c +++ b/src/freedreno/ir3/ir3_ra.c @@ -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); } diff --git a/src/freedreno/ir3/ir3_sched.c b/src/freedreno/ir3/ir3_sched.c index 0756eaf5140..c2f6b3e020d 100644 --- a/src/freedreno/ir3/ir3_sched.c +++ b/src/freedreno/ir3/ir3_sched.c @@ -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); } } diff --git a/src/freedreno/ir3/ir3_sun.c b/src/freedreno/ir3/ir3_sun.c index c31e03129f0..ed518736de9 100644 --- a/src/freedreno/ir3/ir3_sun.c +++ b/src/freedreno/ir3/ir3_sun.c @@ -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) -- 2.30.2