[Mesa-dev] [PATCH v3 022/104] nir: Support deref instructions in lower_indirect_derefs

Jason Ekstrand jason at jlekstrand.net
Sat Apr 7 05:41:13 UTC 2018


On Fri, Apr 6, 2018 at 2:23 PM, Caio Marcelo de Oliveira Filho <
caio.oliveira at intel.com> wrote:

> Hi,
>
> > +static void
> > +emit_load_store_deref(nir_builder *b, nir_intrinsic_instr *orig_instr,
> > +                      nir_deref_instr *parent,
> > +                      nir_deref_instr **deref_arr,
> > +                      nir_ssa_def **dest, nir_ssa_def *src)
> > +{
> > +   for (; *deref_arr; deref_arr++) {
> > +      nir_deref_instr *deref = *deref_arr;
> > +      if (deref->deref_type == nir_deref_type_array &&
> > +          nir_src_as_const_value(deref->arr.index) == NULL) {
> > +         int length = glsl_get_length(parent->type);
> > +
> > +         emit_indirect_load_store_deref(b, orig_instr, parent,
> deref_arr,
> > +                                        0, length, dest, src);
>
> Side note: after reading the existing code (that goes from
> -base_offset to length - base_offset, and later adds base_offset), I'm
> kind of glad this goes from 0 to length.
>
>
> > +static bool
> > +lower_indirect_derefs_block(nir_block *block, nir_builder *b,
> > +                            nir_variable_mode modes)
> > +{
>
> (...)
>
> > +      nir_deref_instr *deref =
> > +         nir_instr_as_deref(intrin->src[0].ssa->parent_instr);
>
> Maybe use the helper 'nir_src_as_deref(intrin->src[0])'?
>
> > +
> > +      /* Walk the deref chain back to the base and look for indirects */
> > +      bool has_indirect = false;
> > +      nir_deref_instr *base = deref;
> > +      while (base->deref_type != nir_deref_type_var) {
> > +         if (base->deref_type == nir_deref_type_array &&
> > +             nir_src_as_const_value(base->arr.index) == NULL)
> > +            has_indirect = true;
> > +
> > +         base = nir_instr_as_deref(base->parent.ssa->parent_instr);
>
> Maybe use the helper 'base = nir_deref_instr_parent(base);'?
>

Yeah, due to rebasing, this patch predates those helpers.  Changed locally.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180406/0196f15d/attachment-0001.html>


More information about the mesa-dev mailing list