fpu: Introduce float_status.e4m3_nan_is_snan
Introduce a separate control from float_snan_rule that applies only to the OCP E4M3 format. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Richard Henderson committed
May 19, 2026 at 08:43 UTC
41044b5475da078a0f988e83a8738626c37afee0
4 files changed
+16
-1
fpu/softfloat-parts.c.inc
+1
-1
@@ -246,7 +246,7 @@ static void partsN(canonicalize)(FloatPartsN *p, float_status *status,
246
case float_expmax_e4m3:
247
if (p->frac_hi == 0b111) {
248
fracN(shl)(p, fmt->frac_shift);
249
- p->cls = (parts_is_snan_frac(p->frac_hi, status)
249
+ p->cls = (get_float_e4m3_nan_is_snan(status)
250
? float_class_snan : float_class_qnan);
251
return;
252
}
fpu/softfloat-specialize.c.inc
+5
@@ -104,6 +104,11 @@ static inline bool get_float_rebias_underflow(const float_status *status)
104
return status->rebias_underflow;
105
}
106
107
+static inline bool get_float_e4m3_nan_is_snan(const float_status *status)
108
+{
109
+ return status->e4m3_nan_is_snan;
110
+}
111
+
112
/*----------------------------------------------------------------------------
113
| For the deconstructed floating-point with fraction FRAC, return true
114
| if the fraction represents a signalling NaN; otherwise false.
include/fpu/softfloat-helpers.h
+5
@@ -131,6 +131,11 @@ static inline void set_snan_rule(FloatSNaNRule val, float_status *status)
131
status->float_snan_rule = val;
132
}
133
134
+static inline void set_float_e4m3_nan_is_snan(bool val, float_status *status)
135
+{
136
+ status->e4m3_nan_is_snan = val;
137
+}
138
+
139
static inline void set_float_rebias_overflow(bool val, float_status *status)
140
{
141
status->rebias_overflow = val;
include/fpu/softfloat-types.h
+5
@@ -431,6 +431,11 @@ typedef struct float_status {
431
/* do we detect and flush denormal results before or after rounding? */
432
bool ftz_before_rounding : 1;
433
FloatSNaNRule float_snan_rule : 2;
434
+ /*
435
+ * Overriding float_snan_rule, is the single NaN representation for
436
+ * the OCP E4M3 format an SNaN or QNaN?
437
+ */
438
+ bool e4m3_nan_is_snan : 1;
439
Float2NaNPropRule float_2nan_prop_rule : 3;
440
Float3NaNPropRule float_3nan_prop_rule : 7;
441
FloatInfZeroNaNRule float_infzeronan_rule: 3;