From: Rob Clark Date: Fri, 15 May 2020 19:03:56 +0000 (-0700) Subject: freedreno/ir3: add helpers to move instructions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=92d6eb4dd539f48355ebfe5408f6a18c5a4c3efd;p=mesa.git freedreno/ir3: add helpers to move instructions A bit cleaner than open coding the list manipulation. Plus I want to use it in the next patch, rather than adding more open coded list futzing. Signed-off-by: Rob Clark Part-of: --- diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h index 218fc04ab5a..90086294de8 100644 --- a/src/freedreno/ir3/ir3.h +++ b/src/freedreno/ir3/ir3.h @@ -593,6 +593,28 @@ void ir3_clear_mark(struct ir3 *shader); unsigned ir3_count_instructions(struct ir3 *ir); unsigned ir3_count_instructions_ra(struct ir3 *ir); +/** + * Move 'instr' to just before 'after' + */ +static inline void +ir3_instr_move_before(struct ir3_instruction *instr, + struct ir3_instruction *after) +{ + list_delinit(&instr->node); + list_addtail(&instr->node, &after->node); +} + +/** + * Move 'instr' to just after 'before': + */ +static inline void +ir3_instr_move_after(struct ir3_instruction *instr, + struct ir3_instruction *before) +{ + list_delinit(&instr->node); + list_add(&instr->node, &before->node); +} + void ir3_find_ssa_uses(struct ir3 *ir, void *mem_ctx, bool falsedeps); void ir3_set_dst_type(struct ir3_instruction *instr, bool half); diff --git a/src/freedreno/ir3/ir3_a6xx.c b/src/freedreno/ir3/ir3_a6xx.c index 39549d44b1d..a8c6553a518 100644 --- a/src/freedreno/ir3/ir3_a6xx.c +++ b/src/freedreno/ir3/ir3_a6xx.c @@ -404,8 +404,7 @@ get_atomic_dest_mov(struct ir3_instruction *atomic) /* it will have already been appended to the end of the block, which * isn't where we want it, so fix-up the location: */ - list_delinit(&mov->node); - list_add(&mov->node, &atomic->node); + ir3_instr_move_after(mov, atomic); return atomic->data = mov; } diff --git a/src/freedreno/ir3/ir3_group.c b/src/freedreno/ir3/ir3_group.c index 182afde222a..61ecd5320b3 100644 --- a/src/freedreno/ir3/ir3_group.c +++ b/src/freedreno/ir3/ir3_group.c @@ -44,8 +44,7 @@ insert_mov(struct ir3_instruction *collect, int idx) * it should be safe to leave at the end of the block it is in: */ if (src->block == collect->block) { - list_delinit(&mov->node); - list_addtail(&mov->node, &collect->node); + ir3_instr_move_before(mov, collect); } } diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c index ce3d4fdebb8..3dc6a6c7371 100644 --- a/src/freedreno/ir3/ir3_legalize.c +++ b/src/freedreno/ir3/ir3_legalize.c @@ -303,8 +303,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block) ir3_reg_create(baryf, regid(0, 0), 0); /* insert the dummy bary.f after last_input: */ - list_delinit(&baryf->node); - list_add(&baryf->node, &last_input->node); + ir3_instr_move_after(baryf, last_input); last_input = baryf;