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

Jason Ekstrand jason at jlekstrand.net
Thu Jul 5 21:12:41 UTC 2018


On Thu, Jul 5, 2018 at 12:55 PM, Caio Marcelo de Oliveira Filho <
caio.oliveira at intel.com> wrote:

> 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?
>

Yes


> > --- 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.
>

That should be fine as-is as nir_instr_insert should do the right thing.
The reason the cursor.instr == instr case is a problem is because you can't
insert an instruction relative to itself.

--Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180705/12c42c95/attachment.html>


More information about the mesa-dev mailing list