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 <eric@anholt.net>
This commit is contained in:
@@ -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);
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user