Mesa (main): nir/print: move print_load_const_instr up
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Dec 17 10:40:06 UTC 2021
Module: Mesa
Branch: main
Commit: d2b4051ea99bb203f7177a73f1328d1de76a4ad5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d2b4051ea99bb203f7177a73f1328d1de76a4ad5
Author: Marcin Ślusarz <marcin.slusarz at intel.com>
Date: Fri Nov 19 15:28:49 2021 +0100
nir/print: move print_load_const_instr up
... to avoid forward declarations in future commit
Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13880>
---
src/compiler/nir/nir_print.c | 86 ++++++++++++++++++++++----------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index e058e10df4e..1573b606e52 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -110,6 +110,49 @@ print_ssa_def(nir_ssa_def *def, print_state *state)
def->index);
}
+static void
+print_load_const_instr(nir_load_const_instr *instr, print_state *state)
+{
+ FILE *fp = state->fp;
+
+ print_ssa_def(&instr->def, state);
+
+ fprintf(fp, " = load_const (");
+
+ for (unsigned i = 0; i < instr->def.num_components; i++) {
+ if (i != 0)
+ fprintf(fp, ", ");
+
+ /*
+ * we don't really know the type of the constant (if it will be used as a
+ * float or an int), so just print the raw constant in hex for fidelity
+ * and then print the float in a comment for readability.
+ */
+
+ switch (instr->def.bit_size) {
+ case 64:
+ fprintf(fp, "0x%016" PRIx64 " /* %f */", instr->value[i].u64,
+ instr->value[i].f64);
+ break;
+ case 32:
+ fprintf(fp, "0x%08x /* %f */", instr->value[i].u32, instr->value[i].f32);
+ break;
+ case 16:
+ fprintf(fp, "0x%04x /* %f */", instr->value[i].u16,
+ _mesa_half_to_float(instr->value[i].u16));
+ break;
+ case 8:
+ fprintf(fp, "0x%02x", instr->value[i].u8);
+ break;
+ case 1:
+ fprintf(fp, "%s", instr->value[i].b ? "true" : "false");
+ break;
+ }
+ }
+
+ fprintf(fp, ")");
+}
+
static void
print_ssa_use(nir_ssa_def *def, print_state *state)
{
@@ -1250,49 +1293,6 @@ print_call_instr(nir_call_instr *instr, print_state *state)
}
}
-static void
-print_load_const_instr(nir_load_const_instr *instr, print_state *state)
-{
- FILE *fp = state->fp;
-
- print_ssa_def(&instr->def, state);
-
- fprintf(fp, " = load_const (");
-
- for (unsigned i = 0; i < instr->def.num_components; i++) {
- if (i != 0)
- fprintf(fp, ", ");
-
- /*
- * we don't really know the type of the constant (if it will be used as a
- * float or an int), so just print the raw constant in hex for fidelity
- * and then print the float in a comment for readability.
- */
-
- switch (instr->def.bit_size) {
- case 64:
- fprintf(fp, "0x%016" PRIx64 " /* %f */", instr->value[i].u64,
- instr->value[i].f64);
- break;
- case 32:
- fprintf(fp, "0x%08x /* %f */", instr->value[i].u32, instr->value[i].f32);
- break;
- case 16:
- fprintf(fp, "0x%04x /* %f */", instr->value[i].u16,
- _mesa_half_to_float(instr->value[i].u16));
- break;
- case 8:
- fprintf(fp, "0x%02x", instr->value[i].u8);
- break;
- case 1:
- fprintf(fp, "%s", instr->value[i].b ? "true" : "false");
- break;
- }
- }
-
- fprintf(fp, ")");
-}
-
static void
print_jump_instr(nir_jump_instr *instr, print_state *state)
{
More information about the mesa-commit
mailing list