[Mesa-dev] [PATCH 06/16] nir/print: show deref instruction type

Jason Ekstrand jason at jlekstrand.net
Sat Apr 7 18:21:40 UTC 2018


On Sat, Apr 7, 2018 at 10:04 AM, Rob Clark <robdclark at gmail.com> wrote:

> On Sat, Apr 7, 2018 at 12:56 PM, Jason Ekstrand <jason at jlekstrand.net>
> wrote:
> > I thought that was fairly obvious from "<var_name>", "(type *)thing",
> > "thing->thing", and "thing[thing]"
>
> You can tell from the format of what comes after the "deref".. but I'm
> a fan of making it *really* obvious (ie. helps when trying to read
> large shaders, and I guess should help for folks who spend less time
> reading nir_print dumps ;-))
>

Here's what I've come up with:

vec1 32 ssa_35 = deref &ssa_34->d (local float) /* s[ssa_4].d */

I think that contains about everything that might be useful.  It makes the
print function a bit more of a mess but not as bad as you'd expect.


> > I guess it's probably ok but it didn't seem necessary to me.  One thing I
> > did sort-of want to do was to make it print the full deref back to the
> > variable if possible.  I'll give a go at that and send out a fixup.
>
> sgtm, feel free to squash this and some variation of 07/16 into your
> patch which intially adds deref instructions if you want
>
> BR,
> -R
>
> >
> > On Sat, Apr 7, 2018 at 9:13 AM, Rob Clark <robdclark at gmail.com> wrote:
> >>
> >> Makes it more obvious what sort of deref instruction something is.
> >>
> >> Signed-off-by: Rob Clark <robdclark at gmail.com>
> >> ---
> >>  src/compiler/nir/nir_print.c | 8 +++++---
> >>  1 file changed, 5 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
> >> index 6e6fd421c60..7d7542a4113 100644
> >> --- a/src/compiler/nir/nir_print.c
> >> +++ b/src/compiler/nir/nir_print.c
> >> @@ -494,17 +494,19 @@ print_deref_instr(nir_deref_instr *instr,
> >> print_state *state)
> >>     print_dest(&instr->dest, state);
> >>
> >>     if (instr->deref_type == nir_deref_type_var) {
> >> -      fprintf(fp, " = deref %s", get_var_name(instr->var, state));
> >> +      fprintf(fp, " = deref_var %s", get_var_name(instr->var, state));
> >>        return;
> >>     } else if (instr->deref_type == nir_deref_type_cast) {
> >> -      fprintf(fp, " = deref (%s) (%s *)&",
> >> +      fprintf(fp, " = deref_cast (%s) (%s *)&",
> >>                get_variable_mode_str(instr->mode),
> >>                glsl_get_type_name(instr->type));
> >>        print_src(&instr->parent, state);
> >>        return;
> >>     }
> >>
> >> -   fprintf(fp, " = deref (%s) &", get_variable_mode_str(instr->mode));
> >> +   fprintf(fp, " = deref_%s (%s) &",
> >> +          (instr->deref_type == nir_deref_type_struct) ? "struct" :
> >> "array",
> >> +          get_variable_mode_str(instr->mode));
> >>     print_src(&instr->parent, state);
> >>
> >>     assert(instr->parent.is_ssa);
> >> --
> >> 2.14.3
> >>
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180407/cb933643/attachment.html>


More information about the mesa-dev mailing list