mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
nir/print: extract nir_print_function_body
this will be used for more concise prints in vtn_bindgen2. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33099>
This commit is contained in:
parent
7e467daac4
commit
646903ed7a
2 changed files with 22 additions and 5 deletions
|
|
@ -5278,6 +5278,7 @@ unsigned nir_shader_index_vars(nir_shader *shader, nir_variable_mode modes);
|
|||
unsigned nir_function_impl_index_vars(nir_function_impl *impl);
|
||||
|
||||
void nir_print_shader(nir_shader *shader, FILE *fp);
|
||||
void nir_print_function_body(nir_function_impl *impl, 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);
|
||||
|
|
|
|||
|
|
@ -2291,15 +2291,17 @@ print_cf_node(nir_cf_node *node, print_state *state, unsigned int tabs)
|
|||
}
|
||||
|
||||
static void
|
||||
print_function_impl(nir_function_impl *impl, print_state *state)
|
||||
print_function_impl(nir_function_impl *impl, print_state *state, bool print_name)
|
||||
{
|
||||
FILE *fp = state->fp;
|
||||
|
||||
state->max_dest_index = impl->ssa_alloc;
|
||||
|
||||
fprintf(fp, "\nimpl %s ", impl->function->name);
|
||||
if (print_name) {
|
||||
fprintf(fp, "\nimpl %s ", impl->function->name);
|
||||
|
||||
fprintf(fp, "{\n");
|
||||
fprintf(fp, "{\n");
|
||||
}
|
||||
|
||||
if (impl->preamble) {
|
||||
print_indentation(1, fp);
|
||||
|
|
@ -2328,7 +2330,11 @@ print_function_impl(nir_function_impl *impl, print_state *state)
|
|||
}
|
||||
|
||||
print_indentation(1, fp);
|
||||
fprintf(fp, "block b%u:\n}\n\n", impl->end_block->index);
|
||||
fprintf(fp, "block b%u:\n", impl->end_block->index);
|
||||
|
||||
if (print_name) {
|
||||
fprintf(fp, "}\n\n");
|
||||
}
|
||||
|
||||
free(state->float_types);
|
||||
free(state->int_types);
|
||||
|
|
@ -2380,7 +2386,7 @@ print_function(nir_function *function, print_state *state)
|
|||
fprintf(fp, "\n");
|
||||
|
||||
if (function->impl != NULL) {
|
||||
print_function_impl(function->impl, state);
|
||||
print_function_impl(function->impl, state, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2740,6 +2746,16 @@ print_shader_info(const struct shader_info *info, FILE *fp)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nir_print_function_body(nir_function_impl *impl, FILE *fp)
|
||||
{
|
||||
print_state state = { 0 };
|
||||
init_print_state(&state, impl->function->shader, fp);
|
||||
state.def_prefix = "%";
|
||||
print_function_impl(impl, &state, false);
|
||||
destroy_print_state(&state);
|
||||
}
|
||||
|
||||
static void
|
||||
_nir_print_shader_annotated(nir_shader *shader, FILE *fp,
|
||||
struct hash_table *annotations,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue