From: Max Chou Date: Thu, 5 Feb 2026 05:37:37 +0000 (+1000) Subject: fpu: Add overflow_raises_invalid to FloatFmt X-Git-Tag: v11.0.0-rc0~52^2~4 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=2c2e54428b3e4c4921e4c83ccc8b43b1ff7158d0;p=thirdparty%2Fqemu.git fpu: Add overflow_raises_invalid to FloatFmt ARM Alt HP raises different exceptions on overflow than is standard for IEEE when saturating a value. Add a flag to control this effect. Reviewed-by: Chao Liu Signed-off-by: Max Chou [rth: Split out of a larger patch] Signed-off-by: Richard Henderson --- diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 455bbf281ef..4909ff74182 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -348,7 +348,9 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s, case float_expmax_normal: if (unlikely(exp > exp_max)) { /* Overflow. Return the maximum normal. */ - flags = float_flag_invalid; + flags = (fmt->overflow_raises_invalid + ? float_flag_invalid + : float_flag_overflow | float_flag_inexact); exp = exp_max; frac_allones(p); p->frac_lo &= ~round_mask; diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 8d8e5767573..9d06a1bb59f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -542,7 +542,9 @@ typedef enum __attribute__((__packed__)) { * The following optional modifiers are available: * exp_max_kind: affects how exp == exp_max is interpreted * has_explicit_bit: has an explicit integer bit; this affects whether - * the float_status floatx80_behaviour handling applies + * the float_status floatx80_behaviour handling applies + * overflow_raises_invalid: for float_expmax_normal, raise invalid + * instead of overflow. */ typedef struct { int exp_size; @@ -553,6 +555,7 @@ typedef struct { int frac_shift; FloatFmtExpMaxKind exp_max_kind; bool has_explicit_bit; + bool overflow_raises_invalid; uint64_t round_mask; } FloatFmt; @@ -576,6 +579,7 @@ static const FloatFmt float16_params = { static const FloatFmt float16_params_ahp = { FLOAT_PARAMS(5, 10), .exp_max_kind = float_expmax_normal, + .overflow_raises_invalid = true, }; static const FloatFmt bfloat16_params = {