ir3: Add ir3_start_block()

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>
This commit is contained in:
Connor Abbott 2021-05-04 11:11:04 +02:00 committed by Emma Anholt
parent ef4e07a1a2
commit 0ef021be4a
3 changed files with 10 additions and 6 deletions

View 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);

View 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;
}

View 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) {