nir: print all fp_math_ctrl bits

Examples:
div 32    %338 = ffma %89, %328.z, %335 // exact, preserve:sz,inf,nan
con 32    %28 = fmul %17.y, %27 (2.000000) // preserve:sz,inf,nan

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40093>
This commit is contained in:
Georg Lehmann 2026-02-25 14:56:51 +01:00 committed by Marge Bot
parent 5e614215ff
commit 5b974a922a

View file

@ -481,6 +481,41 @@ print_alu_src(nir_alu_instr *instr, unsigned src, print_state *state)
}
}
static void
print_fp_math_ctrl(unsigned fp_math_ctrl, print_state *state)
{
FILE *fp = state->fp;
if (fp_math_ctrl & nir_fp_exact) {
fprintf(fp, "exact");
if (fp_math_ctrl & ~nir_fp_exact)
fprintf(fp, ", ");
}
if (fp_math_ctrl & nir_fp_preserve_sz_inf_nan) {
fprintf(fp, "preserve:");
static const struct {
nir_fp_math_control bit;
const char *name;
} preserve_bits[] = {
{ nir_fp_preserve_signed_zero, "sz" },
{ nir_fp_preserve_inf, "inf" },
{ nir_fp_preserve_nan, "nan" },
};
bool first = true;
for (unsigned i = 0; i < ARRAY_SIZE(preserve_bits); i++) {
if (fp_math_ctrl & preserve_bits[i].bit) {
if (!first)
fprintf(fp, ",");
first = false;
fprintf(fp, "%s", preserve_bits[i].name);
}
}
}
}
static void
print_alu_instr(nir_alu_instr *instr, print_state *state)
{
@ -489,8 +524,6 @@ print_alu_instr(nir_alu_instr *instr, print_state *state)
print_def(&instr->def, state);
fprintf(fp, " = %s", nir_op_infos[instr->op].name);
if (nir_alu_instr_is_exact(instr))
fprintf(fp, "!");
if (instr->no_signed_wrap)
fprintf(fp, ".nsw");
if (instr->no_unsigned_wrap)
@ -503,6 +536,11 @@ print_alu_instr(nir_alu_instr *instr, print_state *state)
print_alu_src(instr, i, state);
}
if (instr->fp_math_ctrl) {
fprintf(fp, " // ");
print_fp_math_ctrl(instr->fp_math_ctrl, state);
}
}
static const char *