diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index f967a1afe15..cb38dd285d6 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -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 *