@samitouri / QOSamiQemu / commits / 0dea2bdd4b

fpu: Use accessors for ftz_before_rounding

Drop FloatFTZDetection and use #defines, like we do for tininess_before_rounding. Rename get_float_ftz_detection to get_ftz_before_rounding and move to softfloat.c, as there are no external users. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Richard Henderson committed May 1, 2026 at 20:05 UTC 0dea2bdd4b46a41de0a8384609456ea070a3b31d
4 files changed +12 -16
fpu/softfloat-parts.c.inc
+2 -3
@@ -411,8 +411,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
411 p->frac_lo &= ~round_mask;
412 }
413 fracN(shr)(p, frac_shift);
414 - } else if (get_flush_to_zero(s) &&
415 - s->ftz_detection == float_ftz_before_rounding) {
414 + } else if (get_flush_to_zero(s) && get_ftz_before_rounding(s)) {
415 flags |= float_flag_output_denormal_flushed;
416 p->cls = float_class_zero;
417 exp = 0;
@@ -463,7 +462,7 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
462
463 if (is_tiny) {
464 if (get_flush_to_zero(s)) {
466 - assert(s->ftz_detection == float_ftz_after_rounding);
465 + assert(!get_ftz_before_rounding(s));
466 flags |= float_flag_output_denormal_flushed;
467 p->cls = float_class_zero;
468 exp = 0;
fpu/softfloat-specialize.c.inc
+5
@@ -84,6 +84,11 @@ static inline bool get_tininess_before_rounding(const float_status *status)
84 return status->tininess_before_rounding;
85 }
86
87 +static inline bool get_ftz_before_rounding(const float_status *status)
88 +{
89 + return status->ftz_before_rounding;
90 +}
91 +
92 /*----------------------------------------------------------------------------
93 | For the deconstructed floating-point with fraction FRAC, return true
94 | if the fraction represents a signalling NaN; otherwise false.
include/fpu/softfloat-helpers.h
+2 -8
@@ -116,10 +116,9 @@ static inline void set_flush_inputs_to_zero(bool val, float_status *status)
116 status->flush_inputs_to_zero = val;
117 }
118
119 -static inline void set_float_ftz_detection(FloatFTZDetection d,
120 - float_status *status)
119 +static inline void set_float_ftz_detection(bool val, float_status *status)
120 {
122 - status->ftz_detection = d;
121 + status->ftz_before_rounding = val;
122 }
123
124 static inline void set_default_nan_mode(bool val, float_status *status)
@@ -198,9 +197,4 @@ static inline FloatSNaNRule get_snan_rule(float_status *status)
197 return status->float_snan_rule;
198 }
199
201 -static inline FloatFTZDetection get_float_ftz_detection(const float_status *status)
202 -{
203 - return status->ftz_detection;
204 -}
205 -
200 #endif /* SOFTFLOAT_HELPERS_H */
include/fpu/softfloat-types.h
+3 -5
@@ -341,10 +341,8 @@ typedef enum __attribute__((__packed__)) {
341 * configure it matches the default for tininess_before_rounding
342 * (i.e. "after rounding").
343 */
344 -typedef enum __attribute__((__packed__)) {
345 - float_ftz_after_rounding = 0,
346 - float_ftz_before_rounding = 1,
347 -} FloatFTZDetection;
344 +#define float_ftz_after_rounding false
345 +#define float_ftz_before_rounding true
346
347 /*
348 * floatx80 is primarily used by x86 and m68k, and there are
@@ -416,7 +414,7 @@ typedef struct float_status {
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? */
419 - FloatFTZDetection ftz_detection;
417 + bool ftz_before_rounding;
418 /* should denormalised inputs go to zero and set input_denormal_flushed? */
419 bool flush_inputs_to_zero;
420 bool default_nan_mode;