fpu: Reorg float_status
Use bitfields to compress float_status from 18 bytes down to 8 bytes. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Richard Henderson committed
May 1, 2026 at 22:18 UTC
8c86fe2451924658914611f6a4a242fd1ae5c714
1 file changed
+33
-20
include/fpu/softfloat-types.h
+33
-20
@@ -327,7 +327,7 @@ typedef enum __attribute__((__packed__)) {
327
* This is a flag which can be ORed in with any of the above
328
* DNaN behaviour options.
329
*/
330
- float_infzeronan_suppress_invalid = (1 << 7),
330
+ float_infzeronan_suppress_invalid = (1 << 2),
331
} FloatInfZeroNaNRule;
332
333
/*
@@ -402,22 +402,39 @@ typedef enum __attribute__((__packed__)) {
402
*/
403
404
typedef struct float_status {
405
- FloatExceptionFlags float_exception_flags;
406
- FloatRoundMode float_rounding_mode;
407
- FloatX80RoundPrec floatx80_rounding_precision;
408
- FloatX80Behaviour floatx80_behaviour;
409
- Float2NaNPropRule float_2nan_prop_rule;
410
- Float3NaNPropRule float_3nan_prop_rule;
411
- FloatInfZeroNaNRule float_infzeronan_rule;
412
- FloatSNaNRule float_snan_rule;
413
- bool tininess_before_rounding;
405
+ FloatExceptionFlags float_exception_flags : 16;
406
+
407
+ /*
408
+ * Floating point status controls.
409
+ * Items that, in general, may be updated by writes to an architectural
410
+ * floating point control register.
411
+ */
412
+ FloatRoundMode float_rounding_mode : 3;
413
+ FloatX80RoundPrec floatx80_rounding_precision : 2;
414
/* should denormalised results go to zero and set output_denormal_flushed? */
415
- bool flush_to_zero;
416
- /* do we detect and flush denormal results before or after rounding? */
417
- bool ftz_before_rounding;
415
+ bool flush_to_zero : 1;
416
/* should denormalised inputs go to zero and set input_denormal_flushed? */
419
- bool flush_inputs_to_zero;
420
- bool default_nan_mode;
417
+ bool flush_inputs_to_zero : 1;
418
+ /* should default nans be produced instead of propagating an input nan? */
419
+ bool default_nan_mode : 1;
420
+ /* should overflowed results subtract re_bias to its exponent? */
421
+ bool rebias_overflow : 1;
422
+ /* should underflowed results add re_bias to its exponent? */
423
+ bool rebias_underflow : 1;
424
+
425
+ /*
426
+ * Floating point behaviour controls.
427
+ * Items that, in general, will be set at cpu realization because
428
+ * the behaviour is baked into the specific hardware implementation.
429
+ */
430
+ bool tininess_before_rounding : 1;
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
+ Float2NaNPropRule float_2nan_prop_rule : 3;
435
+ Float3NaNPropRule float_3nan_prop_rule : 7;
436
+ FloatInfZeroNaNRule float_infzeronan_rule: 3;
437
+ FloatX80Behaviour floatx80_behaviour : 5;
438
/*
439
* The pattern to use for the default NaN. Here the high bit specifies
440
* the default NaN's sign bit, and bits 6..0 specify the high bits of the
@@ -427,11 +444,7 @@ typedef struct float_status {
444
* this to the correct non-zero value, or we will assert when trying to
445
* create a default NaN.
446
*/
430
- uint8_t default_nan_pattern;
431
- /* should overflowed results subtract re_bias to its exponent? */
432
- bool rebias_overflow;
433
- /* should underflowed results add re_bias to its exponent? */
434
- bool rebias_underflow;
447
+ unsigned default_nan_pattern : 8;
448
} float_status;
449
450
#endif /* SOFTFLOAT_TYPES_H */