diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-11 08:36:31 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-11 20:28:20 +0000 |
commit | 5aaaf7b12c037b25f4c0a06af4744a8893c25e50 (patch) | |
tree | b3cd38e37fb0828a23317fcf796f6acde8da57d2 /src/panfrost/midgard | |
parent | c5dd1d542dea49a19ad3686d26a895395f7f7849 (diff) |
pan/midgard: Subclass midgard_block from pan_block
Promote as much as we feasibly can while keeping it Midgard/Bifrost
agnostic.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4150>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r-- | src/panfrost/midgard/compiler.h | 84 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_compile.c | 70 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_liveness.c | 14 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_opt_dce.c | 2 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_print.c | 14 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_ra.c | 14 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_ra_pipeline.c | 4 | ||||
-rw-r--r-- | src/panfrost/midgard/midgard_schedule.c | 7 | ||||
-rw-r--r-- | src/panfrost/midgard/mir_promote_uniforms.c | 5 |
9 files changed, 127 insertions, 87 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index f7e69f91655..f9b0c8c2198 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -165,27 +165,18 @@ typedef struct midgard_instruction { }; } midgard_instruction; -typedef struct midgard_block { +typedef struct pan_block { /* Link to next block. Must be first for mir_get_block */ struct list_head link; - /* List of midgard_instructions emitted for the current block */ + /* List of instructions emitted for the current block */ struct list_head instructions; /* Index of the block in source order */ unsigned name; - bool scheduled; - - /* List of midgard_bundles emitted (after the scheduler has run) */ - struct util_dynarray bundles; - - /* Number of quadwords _actually_ emitted, as determined after scheduling */ - unsigned quadword_count; - - /* Succeeding blocks. The compiler should not necessarily rely on - * source-order traversal */ - struct midgard_block *successors[2]; + /* Control flow graph */ + struct pan_block *successors[2]; unsigned nr_successors; struct set *predecessors; @@ -195,6 +186,18 @@ typedef struct midgard_block { * simple bit fields, but for us, liveness is a vector idea. */ uint16_t *live_in; uint16_t *live_out; +} pan_block; + +typedef struct midgard_block { + pan_block base; + + bool scheduled; + + /* List of midgard_bundles emitted (after the scheduler has run) */ + struct util_dynarray bundles; + + /* Number of quadwords _actually_ emitted, as determined after scheduling */ + unsigned quadword_count; /* Indicates this is a fixed-function fragment epilogue block */ bool epilogue; @@ -331,7 +334,7 @@ static inline midgard_instruction * emit_mir_instruction(struct compiler_context *ctx, struct midgard_instruction ins) { midgard_instruction *u = mir_upload_ins(ctx, ins); - list_addtail(&u->link, &ctx->current_block->instructions); + list_addtail(&u->link, &ctx->current_block->base.instructions); return u; } @@ -364,27 +367,30 @@ mir_next_op(struct midgard_instruction *ins) } #define mir_foreach_block(ctx, v) \ - list_for_each_entry(struct midgard_block, v, &ctx->blocks, link) + list_for_each_entry(pan_block, v, &ctx->blocks, link) #define mir_foreach_block_from(ctx, from, v) \ - list_for_each_entry_from(struct midgard_block, v, from, &ctx->blocks, link) + list_for_each_entry_from(pan_block, v, &from->base, &ctx->blocks, link) #define mir_foreach_instr_in_block(block, v) \ - list_for_each_entry(struct midgard_instruction, v, &block->instructions, link) + list_for_each_entry(struct midgard_instruction, v, &block->base.instructions, link) #define mir_foreach_instr_in_block_rev(block, v) \ + list_for_each_entry_rev(struct midgard_instruction, v, &block->base.instructions, link) + +#define pan_foreach_instr_in_block_rev(block, v) \ list_for_each_entry_rev(struct midgard_instruction, v, &block->instructions, link) #define mir_foreach_instr_in_block_safe(block, v) \ - list_for_each_entry_safe(struct midgard_instruction, v, &block->instructions, link) + list_for_each_entry_safe(struct midgard_instruction, v, &block->base.instructions, link) #define mir_foreach_instr_in_block_safe_rev(block, v) \ - list_for_each_entry_safe_rev(struct midgard_instruction, v, &block->instructions, link) + list_for_each_entry_safe_rev(struct midgard_instruction, v, &block->base.instructions, link) #define mir_foreach_instr_in_block_from(block, v, from) \ - list_for_each_entry_from(struct midgard_instruction, v, from, &block->instructions, link) + list_for_each_entry_from(struct midgard_instruction, v, from, &block->base.instructions, link) #define mir_foreach_instr_in_block_from_rev(block, v, from) \ - list_for_each_entry_from_rev(struct midgard_instruction, v, from, &block->instructions, link) + list_for_each_entry_from_rev(struct midgard_instruction, v, from, &block->base.instructions, link) #define mir_foreach_bundle_in_block(block, v) \ util_dynarray_foreach(&block->bundles, midgard_bundle, v) @@ -402,18 +408,26 @@ mir_next_op(struct midgard_instruction *ins) #define mir_foreach_instr_global(ctx, v) \ mir_foreach_block(ctx, v_block) \ - mir_foreach_instr_in_block(v_block, v) + mir_foreach_instr_in_block(((midgard_block *) v_block), v) #define mir_foreach_instr_global_safe(ctx, v) \ mir_foreach_block(ctx, v_block) \ - mir_foreach_instr_in_block_safe(v_block, v) + mir_foreach_instr_in_block_safe(((midgard_block *) v_block), v) #define mir_foreach_successor(blk, v) \ struct midgard_block *v; \ struct midgard_block **_v; \ - for (_v = &blk->successors[0], \ + for (_v = &blk->base.successors[0], \ + v = *_v; \ + v != NULL && _v < &blk->base.successors[2]; \ + _v++, v = *_v) \ + +#define pan_foreach_successor(blk, v) \ + pan_block *v; \ + pan_block **_v; \ + for (_v = (pan_block **) &blk->successors[0], \ v = *_v; \ - v != NULL && _v < &blk->successors[2]; \ + v != NULL && _v < (pan_block **) &blk->successors[2]; \ _v++, v = *_v) \ /* Based on set_foreach, expanded with automatic type casts */ @@ -421,19 +435,28 @@ mir_next_op(struct midgard_instruction *ins) #define mir_foreach_predecessor(blk, v) \ struct set_entry *_entry_##v; \ struct midgard_block *v; \ - for (_entry_##v = _mesa_set_next_entry(blk->predecessors, NULL), \ + for (_entry_##v = _mesa_set_next_entry(blk->base.predecessors, NULL), \ v = (struct midgard_block *) (_entry_##v ? _entry_##v->key : NULL); \ _entry_##v != NULL; \ - _entry_##v = _mesa_set_next_entry(blk->predecessors, _entry_##v), \ + _entry_##v = _mesa_set_next_entry(blk->base.predecessors, _entry_##v), \ v = (struct midgard_block *) (_entry_##v ? _entry_##v->key : NULL)) +#define pan_foreach_predecessor(blk, v) \ + struct set_entry *_entry_##v; \ + struct pan_block *v; \ + for (_entry_##v = _mesa_set_next_entry(blk->predecessors, NULL), \ + v = (struct pan_block *) (_entry_##v ? _entry_##v->key : NULL); \ + _entry_##v != NULL; \ + _entry_##v = _mesa_set_next_entry(blk->predecessors, _entry_##v), \ + v = (struct pan_block *) (_entry_##v ? _entry_##v->key : NULL)) + #define mir_foreach_src(ins, v) \ for (unsigned v = 0; v < ARRAY_SIZE(ins->src); ++v) static inline midgard_instruction * mir_last_in_block(struct midgard_block *block) { - return list_last_entry(&block->instructions, struct midgard_instruction, link); + return list_last_entry(&block->base.instructions, struct midgard_instruction, link); } static inline midgard_block * @@ -450,15 +473,14 @@ mir_get_block(compiler_context *ctx, int idx) static inline midgard_block * mir_exit_block(struct compiler_context *ctx) { - midgard_block *last = list_last_entry(&ctx->blocks, - struct midgard_block, link); + pan_block *last = list_last_entry(&ctx->blocks, pan_block, link); /* The last block must be empty logically but contains branch writeout * for fragment shaders */ assert(last->nr_successors == 0); - return last; + return (midgard_block *) last; } static inline bool diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index df51f19c762..9ff11a003cf 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -74,24 +74,24 @@ create_empty_block(compiler_context *ctx) { midgard_block *blk = rzalloc(ctx, midgard_block); - blk->predecessors = _mesa_set_create(blk, + blk->base.predecessors = _mesa_set_create(blk, _mesa_hash_pointer, _mesa_key_pointer_equal); - blk->name = ctx->block_source_count++; + blk->base.name = ctx->block_source_count++; return blk; } static void -midgard_block_add_successor(midgard_block *block, midgard_block *successor) +pan_block_add_successor(pan_block *block, pan_block *successor) { assert(block); assert(successor); /* Deduplicate */ for (unsigned i = 0; i < block->nr_successors; ++i) { - if (block->successors[i] == successor) + if ((pan_block *) block->successors[i] == successor) return; } @@ -108,9 +108,9 @@ schedule_barrier(compiler_context *ctx) midgard_block *temp = ctx->after_block; ctx->after_block = create_empty_block(ctx); ctx->block_count++; - list_addtail(&ctx->after_block->link, &ctx->blocks); - list_inithead(&ctx->after_block->instructions); - midgard_block_add_successor(ctx->current_block, ctx->after_block); + list_addtail(&ctx->after_block->base.link, &ctx->blocks); + list_inithead(&ctx->after_block->base.instructions); + pan_block_add_successor(&ctx->current_block->base, &ctx->after_block->base); ctx->current_block = ctx->after_block; ctx->after_block = temp; } @@ -2364,13 +2364,13 @@ emit_block(compiler_context *ctx, nir_block *block) if (!this_block) this_block = create_empty_block(ctx); - list_addtail(&this_block->link, &ctx->blocks); + list_addtail(&this_block->base.link, &ctx->blocks); this_block->scheduled = false; ++ctx->block_count; /* Set up current block */ - list_inithead(&this_block->instructions); + list_inithead(&this_block->base.instructions); ctx->current_block = this_block; nir_foreach_instr(instr, block) { @@ -2427,11 +2427,11 @@ emit_if(struct compiler_context *ctx, nir_if *nif) ctx->after_block = create_empty_block(ctx); - midgard_block_add_successor(before_block, then_block); - midgard_block_add_successor(before_block, else_block); + pan_block_add_successor(&before_block->base, &then_block->base); + pan_block_add_successor(&before_block->base, &else_block->base); - midgard_block_add_successor(end_then_block, ctx->after_block); - midgard_block_add_successor(end_else_block, ctx->after_block); + pan_block_add_successor(&end_then_block->base, &ctx->after_block->base); + pan_block_add_successor(&end_else_block->base, &ctx->after_block->base); } static void @@ -2455,8 +2455,8 @@ emit_loop(struct compiler_context *ctx, nir_loop *nloop) emit_mir_instruction(ctx, br_back); /* Mark down that branch in the graph. */ - midgard_block_add_successor(start_block, loop_block); - midgard_block_add_successor(ctx->current_block, loop_block); + pan_block_add_successor(&start_block->base, &loop_block->base); + pan_block_add_successor(&ctx->current_block->base, &loop_block->base); /* Find the index of the block about to follow us (note: we don't add * one; blocks are 0-indexed so we get a fencepost problem) */ @@ -2466,8 +2466,8 @@ emit_loop(struct compiler_context *ctx, nir_loop *nloop) * now that we can allocate a block number for them */ ctx->after_block = create_empty_block(ctx); - list_for_each_entry_from(struct midgard_block, block, start_block, &ctx->blocks, link) { - mir_foreach_instr_in_block(block, ins) { + mir_foreach_block_from(ctx, start_block, _block) { + mir_foreach_instr_in_block(((midgard_block *) _block), ins) { if (ins->type != TAG_ALU_4) continue; if (!ins->compact_branch) continue; @@ -2483,7 +2483,7 @@ emit_loop(struct compiler_context *ctx, nir_loop *nloop) ins->branch.target_type = TARGET_GOTO; ins->branch.target_block = break_block_idx; - midgard_block_add_successor(block, ctx->after_block); + pan_block_add_successor(_block, &ctx->after_block->base); } } @@ -2537,7 +2537,8 @@ midgard_get_first_tag_from_block(compiler_context *ctx, unsigned block_idx) { midgard_block *initial_block = mir_get_block(ctx, block_idx); - mir_foreach_block_from(ctx, initial_block, v) { + mir_foreach_block_from(ctx, initial_block, _v) { + midgard_block *v = (midgard_block *) _v; if (v->quadword_count) { midgard_bundle *initial_bundle = util_dynarray_element(&v->bundles, midgard_bundle, 0); @@ -2615,7 +2616,7 @@ mir_add_writeout_loops(compiler_context *ctx) if (!br) continue; unsigned popped = br->branch.target_block; - midgard_block_add_successor(mir_get_block(ctx, popped - 1), ctx->current_block); + pan_block_add_successor(&(mir_get_block(ctx, popped - 1)->base), &ctx->current_block->base); br->branch.target_block = emit_fragment_epilogue(ctx, rt); /* If we have more RTs, we'll need to restore back after our @@ -2625,7 +2626,7 @@ mir_add_writeout_loops(compiler_context *ctx) midgard_instruction uncond = v_branch(false, false); uncond.branch.target_block = popped; emit_mir_instruction(ctx, uncond); - midgard_block_add_successor(ctx->current_block, mir_get_block(ctx, popped)); + pan_block_add_successor(&ctx->current_block->base, &(mir_get_block(ctx, popped)->base)); schedule_barrier(ctx); } else { /* We're last, so we can terminate here */ @@ -2734,7 +2735,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b /* Per-block lowering before opts */ - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; inline_alu_constants(ctx, block); midgard_opt_promote_fmov(ctx, block); embedded_to_inline_constant(ctx, block); @@ -2746,7 +2748,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b do { progress = false; - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; progress |= midgard_opt_pos_propagate(ctx, block); progress |= midgard_opt_copy_prop(ctx, block); progress |= midgard_opt_dead_code_eliminate(ctx, block); @@ -2761,7 +2764,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b } } while (progress); - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; midgard_lower_invert(ctx, block); midgard_lower_derivatives(ctx, block); } @@ -2769,7 +2773,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b /* Nested control-flow can result in dead branches at the end of the * block. This messes with our analysis and is just dead code, so cull * them */ - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; midgard_opt_cull_dead_branch(ctx, block); } @@ -2790,7 +2795,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b int br_block_idx = 0; - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; util_dynarray_foreach(&block->bundles, midgard_bundle, bundle) { for (int c = 0; c < bundle->instruction_count; ++c) { midgard_instruction *ins = bundle->instructions[c]; @@ -2902,12 +2908,14 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b /* Cache _all_ bundles in source order for lookahead across failed branches */ int bundle_count = 0; - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; bundle_count += block->bundles.size / sizeof(midgard_bundle); } midgard_bundle **source_order_bundles = malloc(sizeof(midgard_bundle *) * bundle_count); int bundle_idx = 0; - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; util_dynarray_foreach(&block->bundles, midgard_bundle, bundle) { source_order_bundles[bundle_idx++] = bundle; } @@ -2919,7 +2927,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b * need to lookahead. Unless this is the last instruction, in * which we return 1. */ - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; mir_foreach_bundle_in_block(block, bundle) { int lookahead = 1; @@ -2954,7 +2963,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b /* Count instructions and bundles */ - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; nr_bundles += util_dynarray_num_elements( &block->bundles, midgard_bundle); diff --git a/src/panfrost/midgard/midgard_liveness.c b/src/panfrost/midgard/midgard_liveness.c index 0769874a66d..9481cded56a 100644 --- a/src/panfrost/midgard/midgard_liveness.c +++ b/src/panfrost/midgard/midgard_liveness.c @@ -73,9 +73,9 @@ mir_liveness_ins_update(uint16_t *live, midgard_instruction *ins, unsigned max) /* live_out[s] = sum { p in succ[s] } ( live_in[p] ) */ static void -liveness_block_live_out(midgard_block *blk, unsigned temp_count) +liveness_block_live_out(pan_block *blk, unsigned temp_count) { - mir_foreach_successor(blk, succ) { + pan_foreach_successor(blk, succ) { for (unsigned i = 0; i < temp_count; ++i) blk->live_out[i] |= succ->live_in[i]; } @@ -86,7 +86,7 @@ liveness_block_live_out(midgard_block *blk, unsigned temp_count) * returns whether progress was made. */ static bool -liveness_block_update(midgard_block *blk, unsigned temp_count) +liveness_block_update(pan_block *blk, unsigned temp_count) { bool progress = false; @@ -95,7 +95,7 @@ liveness_block_update(midgard_block *blk, unsigned temp_count) uint16_t *live = ralloc_array(blk, uint16_t, temp_count); memcpy(live, blk->live_out, temp_count * sizeof(uint16_t)); - mir_foreach_instr_in_block_rev(blk, ins) + pan_foreach_instr_in_block_rev(blk, ins) mir_liveness_ins_update(live, ins, temp_count); /* To figure out progress, diff live_in */ @@ -151,7 +151,7 @@ mir_compute_liveness(compiler_context *ctx) do { /* Pop off a block */ - midgard_block *blk = (struct midgard_block *) cur->key; + pan_block *blk = (struct pan_block *) cur->key; _mesa_set_remove(work_list, cur); /* Update its liveness information */ @@ -160,7 +160,7 @@ mir_compute_liveness(compiler_context *ctx) /* If we made progress, we need to process the predecessors */ if (progress || !_mesa_set_search(visited, blk)) { - mir_foreach_predecessor(blk, pred) + pan_foreach_predecessor(blk, pred) _mesa_set_add(work_list, pred); } @@ -205,7 +205,7 @@ mir_is_live_after(compiler_context *ctx, midgard_block *block, midgard_instructi /* Check whether we're live in the successors */ - if (liveness_get(block->live_out, src, ctx->temp_count)) + if (liveness_get(block->base.live_out, src, ctx->temp_count)) return true; /* Check the rest of the block for liveness */ diff --git a/src/panfrost/midgard/midgard_opt_dce.c b/src/panfrost/midgard/midgard_opt_dce.c index f55db21cef2..71395ca36c7 100644 --- a/src/panfrost/midgard/midgard_opt_dce.c +++ b/src/panfrost/midgard/midgard_opt_dce.c @@ -71,7 +71,7 @@ midgard_opt_dead_code_eliminate(compiler_context *ctx, midgard_block *block) mir_invalidate_liveness(ctx); mir_compute_liveness(ctx); - uint16_t *live = mem_dup(block->live_out, ctx->temp_count * sizeof(uint16_t)); + uint16_t *live = mem_dup(block->base.live_out, ctx->temp_count * sizeof(uint16_t)); mir_foreach_instr_in_block_rev(block, ins) { if (can_cull_mask(ctx, ins)) { diff --git a/src/panfrost/midgard/midgard_print.c b/src/panfrost/midgard/midgard_print.c index c90f6465037..e5e3e16c6c7 100644 --- a/src/panfrost/midgard/midgard_print.c +++ b/src/panfrost/midgard/midgard_print.c @@ -377,7 +377,7 @@ mir_print_instruction(midgard_instruction *ins) void mir_print_block(midgard_block *block) { - printf("block%u: {\n", block->name); + printf("block%u: {\n", block->base.name); if (block->scheduled) { mir_foreach_bundle_in_block(block, bundle) { @@ -394,17 +394,17 @@ mir_print_block(midgard_block *block) printf("}"); - if (block->nr_successors) { + if (block->base.nr_successors) { printf(" -> "); - for (unsigned i = 0; i < block->nr_successors; ++i) { - printf("block%u%s", block->successors[i]->name, - (i + 1) != block->nr_successors ? ", " : ""); + for (unsigned i = 0; i < block->base.nr_successors; ++i) { + printf("block%u%s", block->base.successors[i]->name, + (i + 1) != block->base.nr_successors ? ", " : ""); } } printf(" from { "); mir_foreach_predecessor(block, pred) - printf("block%u ", pred->name); + printf("block%u ", pred->base.name); printf("}"); printf("\n\n"); @@ -414,6 +414,6 @@ void mir_print_shader(compiler_context *ctx) { mir_foreach_block(ctx, block) { - mir_print_block(block); + mir_print_block((midgard_block *) block); } } diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index 92dbc1fe63c..ae6d0efc6d2 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -385,7 +385,8 @@ mir_compute_interference( if (ctx->is_blend) { unsigned r1w = ~0; - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; mir_foreach_instr_in_block_rev(block, ins) { if (ins->writeout) r1w = ins->src[2]; @@ -405,8 +406,9 @@ mir_compute_interference( * interference by walking each block linearly. Take live_out at the * end of each block and walk the block backwards. */ - mir_foreach_block(ctx, blk) { - uint16_t *live = mem_dup(blk->live_out, ctx->temp_count * sizeof(uint16_t)); + mir_foreach_block(ctx, _blk) { + midgard_block *blk = (midgard_block *) _blk; + uint16_t *live = mem_dup(_blk->live_out, ctx->temp_count * sizeof(uint16_t)); mir_foreach_instr_in_block_rev(blk, ins) { /* Mark all registers live after the instruction as @@ -834,7 +836,8 @@ mir_spill_register( if (is_special_w) spill_slot = spill_index++; - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; mir_foreach_instr_in_block_safe(block, ins) { if (ins->dest != spill_node) continue; @@ -876,7 +879,8 @@ mir_spill_register( * work registers to back special registers; TLS * spilling is to use memory to back work registers) */ - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; mir_foreach_instr_in_block(block, ins) { /* We can't rewrite the moves used to spill in the * first place. These moves are hinted. */ diff --git a/src/panfrost/midgard/midgard_ra_pipeline.c b/src/panfrost/midgard/midgard_ra_pipeline.c index 7a8c7b118e2..48f45cb9adb 100644 --- a/src/panfrost/midgard/midgard_ra_pipeline.c +++ b/src/panfrost/midgard/midgard_ra_pipeline.c @@ -108,7 +108,9 @@ mir_create_pipeline_registers(compiler_context *ctx) { mir_invalidate_liveness(ctx); - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; + mir_foreach_bundle_in_block(block, bundle) { if (!mir_is_alu_bundle(bundle)) continue; if (bundle->instruction_count < 2) continue; diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 2ca0f95656c..3e9992554ed 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -245,7 +245,7 @@ bytes_for_instruction(midgard_instruction *ains) static midgard_instruction ** flatten_mir(midgard_block *block, unsigned *len) { - *len = list_length(&block->instructions); + *len = list_length(&block->base.instructions); if (!(*len)) return NULL; @@ -1167,7 +1167,7 @@ schedule_block(compiler_context *ctx, midgard_block *block) } mir_foreach_instr_in_block_scheduled_rev(block, ins) { - list_add(&ins->link, &block->instructions); + list_add(&ins->link, &block->base.instructions); } free(instructions); /* Allocated by flatten_mir() */ @@ -1186,7 +1186,8 @@ midgard_schedule_program(compiler_context *ctx) /* Lowering can introduce some dead moves */ - mir_foreach_block(ctx, block) { + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; midgard_opt_dead_move_eliminate(ctx, block); schedule_block(ctx, block); } diff --git a/src/panfrost/midgard/mir_promote_uniforms.c b/src/panfrost/midgard/mir_promote_uniforms.c index 2d7aabed49c..396308450ef 100644 --- a/src/panfrost/midgard/mir_promote_uniforms.c +++ b/src/panfrost/midgard/mir_promote_uniforms.c @@ -82,8 +82,9 @@ mir_estimate_pressure(compiler_context *ctx) unsigned max_live = 0; - mir_foreach_block(ctx, block) { - uint16_t *live = mem_dup(block->live_out, ctx->temp_count * sizeof(uint16_t)); + mir_foreach_block(ctx, _block) { + midgard_block *block = (midgard_block *) _block; + uint16_t *live = mem_dup(block->base.live_out, ctx->temp_count * sizeof(uint16_t)); mir_foreach_instr_in_block_rev(block, ins) { unsigned count = mir_count_live(live, ctx->temp_count); |