ir3: add ir3_cursor_current_block helper

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32454>
This commit is contained in:
Job Noorman
2025-03-03 09:58:54 +01:00
committed by Marge Bot
parent 69982e6f2f
commit ac18eccd74
2 changed files with 16 additions and 16 deletions

View File

@@ -770,25 +770,10 @@ add_to_address_users(struct ir3_instruction *instr)
}
}
static struct ir3_block *
get_block(struct ir3_cursor cursor)
{
switch (cursor.option) {
case IR3_CURSOR_BEFORE_BLOCK:
case IR3_CURSOR_AFTER_BLOCK:
return cursor.block;
case IR3_CURSOR_BEFORE_INSTR:
case IR3_CURSOR_AFTER_INSTR:
return cursor.instr->block;
}
unreachable("illegal cursor option");
}
struct ir3_instruction *
ir3_instr_create_at(struct ir3_cursor cursor, opc_t opc, int ndst, int nsrc)
{
struct ir3_block *block = get_block(cursor);
struct ir3_block *block = ir3_cursor_current_block(cursor);
struct ir3_instruction *instr = instr_create(block, opc, ndst, nsrc);
instr->block = block;
instr->opc = opc;

View File

@@ -2379,6 +2379,21 @@ ir3_instr_move_after_phis(struct ir3_instruction *instr,
ir3_instr_move_before_block(instr, block);
}
static inline struct ir3_block *
ir3_cursor_current_block(struct ir3_cursor cursor)
{
switch (cursor.option) {
case IR3_CURSOR_BEFORE_BLOCK:
case IR3_CURSOR_AFTER_BLOCK:
return cursor.block;
case IR3_CURSOR_BEFORE_INSTR:
case IR3_CURSOR_AFTER_INSTR:
return cursor.instr->block;
}
unreachable("illegal cursor option");
}
static inline struct ir3_cursor
ir3_before_block(struct ir3_block *block)
{