Re: [Mesa-dev] [PATCH v3 019/104] nir: Support deref instructions in lower_var_copies

2018-04-06 Thread Caio Marcelo de Oliveira Filho
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.olive...@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
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 019/104] nir: Support deref instructions in lower_var_copies

2018-04-05 Thread Jason Ekstrand
On Thu, Apr 5, 2018 at 12:55 PM, Caio Marcelo de Oliveira Filho <
caio.olive...@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.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 019/104] nir: Support deref instructions in lower_var_copies

2018-04-05 Thread Caio Marcelo de Oliveira Filho
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)?


Thanks,
Caio
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev