@samitouri / QOSamiQemu / commits / a9717332d7

fpu: Introduce FloatExceptionFlags

We have, in the past, used any of uint8_t, uint16_t or int to hold the set of exception flags. Use a typedef instead. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Richard Henderson committed May 1, 2026 at 13:05 UTC a9717332d743e5c65149d7bf694e260c2b1704d5
5 files changed +13 -8
fpu/softfloat-parts.c.inc
+4 -3
@@ -297,7 +297,8 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
297 const uint64_t roundeven_mask = round_mask | frac_lsb;
298 uint64_t inc;
299 bool overflow_norm = saturate;
300 - int exp, flags = 0;
300 + int exp;
301 + FloatExceptionFlags flags = 0;
302
303 switch (s->float_rounding_mode) {
304 case float_round_nearest_even_max:
@@ -1256,7 +1257,7 @@ static int64_t partsN(float_to_sint)(FloatPartsN *p, FloatRoundMode rmode,
1257 int scale, int64_t min, int64_t max,
1258 float_status *s)
1259 {
1259 - int flags = 0;
1260 + FloatExceptionFlags flags = 0;
1261 uint64_t r;
1262
1263 switch (p->cls) {
@@ -1324,7 +1325,7 @@ static int64_t partsN(float_to_sint)(FloatPartsN *p, FloatRoundMode rmode,
1325 static uint64_t partsN(float_to_uint)(FloatPartsN *p, FloatRoundMode rmode,
1326 int scale, uint64_t max, float_status *s)
1327 {
1327 - int flags = 0;
1328 + FloatExceptionFlags flags = 0;
1329 uint64_t r;
1330
1331 switch (p->cls) {
fpu/softfloat.c
+1 -1
@@ -2976,7 +2976,7 @@ static int64_t float128_to_int64_scalbn(float128 a, FloatRoundMode rmode,
2976 static Int128 float128_to_int128_scalbn(float128 a, FloatRoundMode rmode,
2977 int scale, float_status *s)
2978 {
2979 - int flags = 0;
2979 + FloatExceptionFlags flags = 0;
2980 Int128 r;
2981 FloatParts128 p = float128_unpack_canonical(a, s);
2982
include/fpu/softfloat-helpers.h
+4 -2
@@ -64,7 +64,8 @@ static inline void set_float_rounding_mode(FloatRoundMode val,
64 status->float_rounding_mode = val;
65 }
66
67 -static inline void set_float_exception_flags(int val, float_status *status)
67 +static inline void
68 +set_float_exception_flags(FloatExceptionFlags val, float_status *status)
69 {
70 status->float_exception_flags = val;
71 }
@@ -146,7 +147,8 @@ static inline FloatRoundMode get_float_rounding_mode(const float_status *status)
147 return status->float_rounding_mode;
148 }
149
149 -static inline int get_float_exception_flags(const float_status *status)
150 +static inline FloatExceptionFlags
151 +get_float_exception_flags(const float_status *status)
152 {
153 return status->float_exception_flags;
154 }
include/fpu/softfloat-types.h
+3 -1
@@ -181,6 +181,8 @@ enum {
181 float_flag_input_denormal_used = 0x4000,
182 };
183
184 +typedef uint16_t FloatExceptionFlags;
185 +
186 /*
187 * Rounding precision for floatx80.
188 */
@@ -385,7 +387,7 @@ typedef enum __attribute__((__packed__)) {
387 */
388
389 typedef struct float_status {
388 - uint16_t float_exception_flags;
390 + FloatExceptionFlags float_exception_flags;
391 FloatRoundMode float_rounding_mode;
392 FloatX80RoundPrec floatx80_rounding_precision;
393 FloatX80Behaviour floatx80_behaviour;
include/fpu/softfloat.h
+1 -1
@@ -101,7 +101,7 @@ typedef enum {
101 | Routine to raise any or all of the software IEC/IEEE floating-point
102 | exception flags.
103 *----------------------------------------------------------------------------*/
104 -static inline void float_raise(uint16_t flags, float_status *status)
104 +static inline void float_raise(FloatExceptionFlags flags, float_status *status)
105 {
106 status->float_exception_flags |= flags;
107 }