nir/print: print large floats as mantissa + exponent

This is silly:
con 64    %18698 = load_const (0xf0f0f0f0f0f0f0f0 = -107730874267432137203343331820822035577514310242782965586097631855966576162301880634213986293205127792322062538351156704152182839736964151026851280176102232488321269248467172131803507875122376996725092200401040958124190100858265776685056.000000 = -1085102592571150096 = 17361641481138401520)

This is better:
con 64    %18698 = load_const (0xf0f0f0f0f0f0f0f0 = -1.077309e+236 = -1085102592571150096 = 17361641481138401520)

Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33456>
This commit is contained in:
Georg Lehmann 2025-02-08 18:38:55 +01:00 committed by Marge Bot
parent 6b0ba1109a
commit f921b42c8c

View file

@ -210,19 +210,12 @@ print_hex_terse_const_value(const nir_const_value *value, unsigned bit_size, FIL
static void
print_float_const_value(const nir_const_value *value, unsigned bit_size, FILE *fp)
{
switch (bit_size) {
case 64:
fprintf(fp, "%f", value->f64);
break;
case 32:
fprintf(fp, "%f", value->f32);
break;
case 16:
fprintf(fp, "%f", _mesa_half_to_float(value->u16));
break;
default:
unreachable("unhandled bit size");
}
double dval = nir_const_value_as_float(*value, bit_size);
if (fabs(dval) >= 1000000.0)
fprintf(fp, "%e", dval);
else
fprintf(fp, "%f", dval);
}
static void