[Mesa-dev] [PATCH 1.5/3] nir: Add a nir_instr_move helper

Caio Marcelo de Oliveira Filho caio.oliveira at intel.com
Thu Jul 5 19:55:20 UTC 2018


On Wed, Jul 04, 2018 at 09:55:26AM -0700, Jason Ekstrand wrote:
> Removes an instruction from one place and inserts it at another while
> working around a weird cursor corner-case.

Is the weird corner case the move to the same place case?


> --- a/src/compiler/nir/nir.c
> +++ b/src/compiler/nir/nir.c
> @@ -845,6 +845,21 @@ nir_instr_insert(nir_cursor cursor, nir_instr *instr)
>        nir_handle_add_jump(instr->block);
>  }
>  
> +void
> +nir_instr_move(nir_cursor cursor, nir_instr *instr)
> +{
> +   /* If the cursor happens to refer to this instruction (either before or
> +    * after), don't do anything.
> +    */
> +   if ((cursor.option == nir_cursor_before_instr ||
> +        cursor.option == nir_cursor_after_instr) &&
> +       cursor.instr == instr)
> +      return;

Should we also consider the block-based cursor options here? Moving
the first instruction of a block before that block
(nir_cursor_before_block), etc.


Thanks,
Caio


More information about the mesa-dev mailing list