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>
This commit is contained in:
Richard Henderson
2026-05-19 08:43:57 -07:00
parent 8c86fe2451
commit 41044b5475
4 changed files with 16 additions and 1 deletions

View File

@@ -246,7 +246,7 @@ static void partsN(canonicalize)(FloatPartsN *p, float_status *status,
case float_expmax_e4m3:
if (p->frac_hi == 0b111) {
fracN(shl)(p, fmt->frac_shift);
p->cls = (parts_is_snan_frac(p->frac_hi, status)
p->cls = (get_float_e4m3_nan_is_snan(status)
? float_class_snan : float_class_qnan);
return;
}

View File

@@ -104,6 +104,11 @@ static inline bool get_float_rebias_underflow(const float_status *status)
return status->rebias_underflow;
}
static inline bool get_float_e4m3_nan_is_snan(const float_status *status)
{
return status->e4m3_nan_is_snan;
}
/*----------------------------------------------------------------------------
| For the deconstructed floating-point with fraction FRAC, return true
| if the fraction represents a signalling NaN; otherwise false.

View File

@@ -131,6 +131,11 @@ static inline void set_snan_rule(FloatSNaNRule val, float_status *status)
status->float_snan_rule = val;
}
static inline void set_float_e4m3_nan_is_snan(bool val, float_status *status)
{
status->e4m3_nan_is_snan = val;
}
static inline void set_float_rebias_overflow(bool val, float_status *status)
{
status->rebias_overflow = val;

View File

@@ -431,6 +431,11 @@ typedef struct float_status {
/* do we detect and flush denormal results before or after rounding? */
bool ftz_before_rounding : 1;
FloatSNaNRule float_snan_rule : 2;
/*
* Overriding float_snan_rule, is the single NaN representation for
* the OCP E4M3 format an SNaN or QNaN?
*/
bool e4m3_nan_is_snan : 1;
Float2NaNPropRule float_2nan_prop_rule : 3;
Float3NaNPropRule float_3nan_prop_rule : 7;
FloatInfZeroNaNRule float_infzeronan_rule: 3;