From: Caio Marcelo de Oliveira Filho Date: Wed, 19 Dec 2018 20:13:46 +0000 (-0800) Subject: nir: add a way to print the deref chain X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d6babf995d48d64e383c4180f9b660522958f86;p=mesa.git nir: add a way to print the deref chain Makes debugging easier when we care about the deref chain and not the deref instruction itself. To make it take a const pointer, constify some of the static functions in nir_print.c. Reviewed-by: Eric Anholt --- diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 39041ec084b..c6aeba96ba4 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2725,6 +2725,7 @@ void nir_index_blocks(nir_function_impl *impl); void nir_print_shader(nir_shader *shader, FILE *fp); void nir_print_shader_annotated(nir_shader *shader, FILE *fp, struct hash_table *errors); void nir_print_instr(const nir_instr *instr, FILE *fp); +void nir_print_deref(const nir_deref_instr *deref, FILE *fp); nir_shader *nir_shader_clone(void *mem_ctx, const nir_shader *s); nir_function_impl *nir_function_impl_clone(const nir_function_impl *fi); diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 47932e99639..5f1b547ea37 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -123,10 +123,10 @@ print_ssa_use(nir_ssa_def *def, print_state *state) fprintf(fp, "ssa_%u", def->index); } -static void print_src(nir_src *src, print_state *state); +static void print_src(const nir_src *src, print_state *state); static void -print_reg_src(nir_reg_src *src, print_state *state) +print_reg_src(const nir_reg_src *src, print_state *state) { FILE *fp = state->fp; print_register(src->reg, state); @@ -156,7 +156,7 @@ print_reg_dest(nir_reg_dest *dest, print_state *state) } static void -print_src(nir_src *src, print_state *state) +print_src(const nir_src *src, print_state *state) { if (src->is_ssa) print_ssa_use(src->ssa, state); @@ -577,7 +577,7 @@ print_var_decl(nir_variable *var, print_state *state) } static void -print_deref_link(nir_deref_instr *instr, bool whole_chain, print_state *state) +print_deref_link(const nir_deref_instr *instr, bool whole_chain, print_state *state) { FILE *fp = state->fp; @@ -1386,3 +1386,12 @@ nir_print_instr(const nir_instr *instr, FILE *fp) print_instr(instr, &state, 0); } + +void +nir_print_deref(const nir_deref_instr *deref, FILE *fp) +{ + print_state state = { + .fp = fp, + }; + print_deref_link(deref, true, &state); +}