On Wed, Jan 21, 2015 at 5:25 PM, Eric Anholt <e...@anholt.net> wrote:

> It's nice to have this present in your default cases so you can see what
> instruction is triggering an abort.
> ---
>  src/glsl/nir/nir.h       |  1 +
>  src/glsl/nir/nir_print.c | 14 ++++++++++++--
>  2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index 7b5794d..761f20a 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1480,6 +1480,7 @@ void nir_index_ssa_defs(nir_function_impl *impl);
>  void nir_index_blocks(nir_function_impl *impl);
>
>  void nir_print_shader(nir_shader *shader, FILE *fp);
> +void nir_print_instr(nir_instr *instr, FILE *fp);
>
>  #ifdef DEBUG
>  void nir_validate_shader(nir_shader *shader);
> diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
> index 1a50ae9..924989a 100644
> --- a/src/glsl/nir/nir_print.c
> +++ b/src/glsl/nir/nir_print.c
> @@ -611,8 +611,6 @@ print_instr(nir_instr *instr, print_var_state *state,
> unsigned tabs, FILE *fp)
>        unreachable("Invalid instruction type");
>        break;
>     }
> -
> -   fprintf(fp, "\n");
>  }
>
>  static int
> @@ -658,6 +656,7 @@ print_block(nir_block *block, print_var_state *state,
> unsigned tabs, FILE *fp)
>
>     nir_foreach_instr(block, instr) {
>        print_instr(instr, state, tabs, fp);
> +      fprintf(fp, "\n");
>     }
>
>     print_tabs(tabs, fp);
> @@ -871,3 +870,14 @@ nir_print_shader(nir_shader *shader, FILE *fp)
>
>     destroy_print_state(&state);
>  }
> +
> +void
> +nir_print_instr(nir_instr *instr, FILE *fp)
> +{
> +   print_var_state state;
> +   init_print_state(&state);
> +
> +   print_instr(instr, &state, 0, fp);
>

This won't work with intrinsics because, while we've created the table of
variable names, we haven't filled it out by printing the variables.  Maybe
the thing to do would be to make print_var use the variable's nominal name
if the print state is NULL and then just call print_instr(instr, NULL, 0,
fp) here.

Otherwise, I really want this.
--Jason


> +
> +   destroy_print_state(&state);
> +}
> --
> 2.1.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to