[Mesa-dev] [PATCH v3 019/104] nir: Support deref instructions in lower_var_copies
Caio Marcelo de Oliveira Filho
caio.oliveira at intel.com
Fri Apr 6 16:00:00 UTC 2018
On Thu, Apr 05, 2018 at 01:53:46PM -0700, Jason Ekstrand wrote:
> On Thu, Apr 5, 2018 at 12:55 PM, Caio Marcelo de Oliveira Filho <
> caio.oliveira at intel.com> wrote:
>
> > Hello,
> >
> > > +static nir_deref_instr *
> > > +build_deref_to_next_wildcard(nir_builder *b,
> > > + nir_deref_instr *parent,
> > > + nir_deref_instr ***deref_arr)
> > > +{
> > > + for (; **deref_arr; (*deref_arr)++) {
> > > + if ((**deref_arr)->deref_type == nir_deref_type_array_wildcard)
> > > + return parent;
> > > +
> > > + parent = nir_build_deref_follower(b, parent, **deref_arr);
> > > + }
> > > +
> > > + assert(**deref_arr == NULL);
> > > + *deref_arr = NULL;
> > > + return parent;
> > > +}
> >
> > Question: in a scenario where there are no wildcards in the chain,
> > could we just return the original deref (i.e. the last element in
> > deref_arr)?
> >
>
> Yes, and nir_build_deref_follower magically does that. :-) It's admittedly
> a bit sketchy because we don't know if the if the follower actually
> dominates the current builder cursor but all of the callers in this series
> do have that guarantee.
Ah, I see how it works now. And it also covers partial reuse of the
original deref chain. I'd consider adding a note about the fact that
it might reuse pieces of the chain to the function comment.
Thanks,
Caio
More information about the mesa-dev
mailing list