[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/29] softfloat: Split out parts_uncanon_normal
From: |
Richard Henderson |
Subject: |
[PULL 09/29] softfloat: Split out parts_uncanon_normal |
Date: |
Thu, 3 Jun 2021 14:41:11 -0700 |
We will need to treat the non-normal cases of floatx80 specially,
so split out the normal case that we can reuse.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
fpu/softfloat.c | 8 ++++++
fpu/softfloat-parts.c.inc | 59 +++++++++++++++++++++------------------
2 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 0f2eed8d29..ea7ee13201 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -764,6 +764,14 @@ static void parts128_canonicalize(FloatParts128 *p,
float_status *status,
#define parts_canonicalize(A, S, F) \
PARTS_GENERIC_64_128(canonicalize, A)(A, S, F)
+static void parts64_uncanon_normal(FloatParts64 *p, float_status *status,
+ const FloatFmt *fmt);
+static void parts128_uncanon_normal(FloatParts128 *p, float_status *status,
+ const FloatFmt *fmt);
+
+#define parts_uncanon_normal(A, S, F) \
+ PARTS_GENERIC_64_128(uncanon_normal, A)(A, S, F)
+
static void parts64_uncanon(FloatParts64 *p, float_status *status,
const FloatFmt *fmt);
static void parts128_uncanon(FloatParts128 *p, float_status *status,
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index d69f357352..e05909db8c 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -140,8 +140,8 @@ static void partsN(canonicalize)(FloatPartsN *p,
float_status *status,
* fraction; these bits will be removed. The exponent will be biased
* by EXP_BIAS and must be bounded by [EXP_MAX-1, 0].
*/
-static void partsN(uncanon)(FloatPartsN *p, float_status *s,
- const FloatFmt *fmt)
+static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s,
+ const FloatFmt *fmt)
{
const int exp_max = fmt->exp_max;
const int frac_shift = fmt->frac_shift;
@@ -150,33 +150,9 @@ static void partsN(uncanon)(FloatPartsN *p, float_status
*s,
const uint64_t round_mask = fmt->round_mask;
const uint64_t roundeven_mask = fmt->roundeven_mask;
uint64_t inc;
- bool overflow_norm;
+ bool overflow_norm = false;
int exp, flags = 0;
- if (unlikely(p->cls != float_class_normal)) {
- switch (p->cls) {
- case float_class_zero:
- p->exp = 0;
- frac_clear(p);
- return;
- case float_class_inf:
- g_assert(!fmt->arm_althp);
- p->exp = fmt->exp_max;
- frac_clear(p);
- return;
- case float_class_qnan:
- case float_class_snan:
- g_assert(!fmt->arm_althp);
- p->exp = fmt->exp_max;
- frac_shr(p, fmt->frac_shift);
- return;
- default:
- break;
- }
- g_assert_not_reached();
- }
-
- overflow_norm = false;
switch (s->float_rounding_mode) {
case float_round_nearest_even:
inc = ((p->frac_lo & roundeven_mask) != frac_lsbm1 ? frac_lsbm1 : 0);
@@ -284,6 +260,35 @@ static void partsN(uncanon)(FloatPartsN *p, float_status
*s,
float_raise(flags, s);
}
+static void partsN(uncanon)(FloatPartsN *p, float_status *s,
+ const FloatFmt *fmt)
+{
+ if (likely(p->cls == float_class_normal)) {
+ parts_uncanon_normal(p, s, fmt);
+ } else {
+ switch (p->cls) {
+ case float_class_zero:
+ p->exp = 0;
+ frac_clear(p);
+ return;
+ case float_class_inf:
+ g_assert(!fmt->arm_althp);
+ p->exp = fmt->exp_max;
+ frac_clear(p);
+ return;
+ case float_class_qnan:
+ case float_class_snan:
+ g_assert(!fmt->arm_althp);
+ p->exp = fmt->exp_max;
+ frac_shr(p, fmt->frac_shift);
+ return;
+ default:
+ break;
+ }
+ g_assert_not_reached();
+ }
+}
+
/*
* Returns the result of adding or subtracting the values of the
* floating-point values `a' and `b'. The operation is performed
--
2.25.1
- [PULL 00/29] softfloat patch queue, Richard Henderson, 2021/06/03
- [PULL 01/29] softfloat: Move round_to_uint_and_pack to softfloat-parts.c.inc, Richard Henderson, 2021/06/03
- [PULL 02/29] softfloat: Move int_to_float to softfloat-parts.c.inc, Richard Henderson, 2021/06/03
- [PULL 04/29] softfloat: Move minmax_flags to softfloat-parts.c.inc, Richard Henderson, 2021/06/03
- [PULL 05/29] softfloat: Implement float128_(min|minnum|minnummag|max|maxnum|maxnummag), Richard Henderson, 2021/06/03
- [PULL 03/29] softfloat: Move uint_to_float to softfloat-parts.c.inc, Richard Henderson, 2021/06/03
- [PULL 06/29] softfloat: Move compare_floats to softfloat-parts.c.inc, Richard Henderson, 2021/06/03
- [PULL 07/29] softfloat: Move scalbn_decomposed to softfloat-parts.c.inc, Richard Henderson, 2021/06/03
- [PULL 09/29] softfloat: Split out parts_uncanon_normal,
Richard Henderson <=
- [PULL 08/29] softfloat: Move sqrt_float to softfloat-parts.c.inc, Richard Henderson, 2021/06/03
- [PULL 12/29] softfloat: Adjust parts_uncanon_normal for floatx80, Richard Henderson, 2021/06/03
- [PULL 11/29] softfloat: Introduce Floatx80RoundPrec, Richard Henderson, 2021/06/03
- [PULL 13/29] tests/fp/fp-test: Reverse order of floatx80 precision tests, Richard Henderson, 2021/06/03
- [PULL 10/29] softfloat: Reduce FloatFmt, Richard Henderson, 2021/06/03
- [PULL 14/29] softfloat: Convert floatx80_add/sub to FloatParts, Richard Henderson, 2021/06/03
- [PULL 18/29] softfloat: Convert floatx80_round to FloatParts, Richard Henderson, 2021/06/03
- [PULL 19/29] softfloat: Convert floatx80_round_to_int to FloatParts, Richard Henderson, 2021/06/03
- [PULL 16/29] softfloat: Convert floatx80_div to FloatParts, Richard Henderson, 2021/06/03
- [PULL 22/29] softfloat: Convert floatx80 to integer to FloatParts, Richard Henderson, 2021/06/03