nir: Look up the shader when printing a single instruction.
authorEric Anholt <eric@anholt.net>
Fri, 28 Aug 2020 19:27:04 +0000 (12:27 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 31 Aug 2020 17:20:43 +0000 (17:20 +0000)
If you've inserted the instruction into a block, then we can get to the
shader.  This improves our instruction output, giving you i/o semantics
and variable names in intrinsics.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6496>

src/compiler/nir/nir_print.c

index 6e871b6c9506ff968d454966b406dbfaafa6f41e..c5a8efd1ec51753ae95b957f56f9458196f12db5 100644 (file)
@@ -1586,6 +1586,11 @@ nir_print_instr(const nir_instr *instr, FILE *fp)
    print_state state = {
       .fp = fp,
    };
+   if (instr->block) {
+      nir_function_impl *impl = nir_cf_node_get_function(&instr->block->cf_node);
+      state.shader = impl->function->shader;
+   }
+
    print_instr(instr, &state, 0);
 
 }