[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 05/12] softfpu: Add float_round_to_odd_inf
From: |
Richard Henderson |
Subject: |
[PATCH v2 05/12] softfpu: Add float_round_to_odd_inf |
Date: |
Tue, 25 May 2021 15:58:10 -0700 |
For Arm BFDOT and BFMMLA, we need a version of round-to-odd
that overflows to infinity, instead of the max normal number.
Cc: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/fpu/softfloat-types.h | 4 +++-
fpu/softfloat-parts.c.inc | 6 ++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 8a3f20fae9..3b757c3d6a 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -134,8 +134,10 @@ typedef enum __attribute__((__packed__)) {
float_round_up = 2,
float_round_to_zero = 3,
float_round_ties_away = 4,
- /* Not an IEEE rounding mode: round to the closest odd mantissa value */
+ /* Not an IEEE rounding mode: round to closest odd, overflow to max */
float_round_to_odd = 5,
+ /* Not an IEEE rounding mode: round to closest odd, overflow to inf */
+ float_round_to_odd_inf = 6,
} FloatRoundMode;
/*
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index a897a5a743..7f69da1d8f 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -176,13 +176,12 @@ static void partsN(uncanon)(FloatPartsN *p, float_status
*s,
g_assert_not_reached();
}
+ overflow_norm = false;
switch (s->float_rounding_mode) {
case float_round_nearest_even:
- overflow_norm = false;
inc = ((p->frac_lo & roundeven_mask) != frac_lsbm1 ? frac_lsbm1 : 0);
break;
case float_round_ties_away:
- overflow_norm = false;
inc = frac_lsbm1;
break;
case float_round_to_zero:
@@ -199,6 +198,8 @@ static void partsN(uncanon)(FloatPartsN *p, float_status *s,
break;
case float_round_to_odd:
overflow_norm = true;
+ /* fall through */
+ case float_round_to_odd_inf:
inc = p->frac_lo & frac_lsb ? 0 : round_mask;
break;
default:
@@ -259,6 +260,7 @@ static void partsN(uncanon)(FloatPartsN *p, float_status *s,
? frac_lsbm1 : 0);
break;
case float_round_to_odd:
+ case float_round_to_odd_inf:
inc = p->frac_lo & frac_lsb ? 0 : round_mask;
break;
default:
--
2.25.1
- [PATCH v2 00/12] target/arm: Implement BFloat16, Richard Henderson, 2021/05/25
- [PATCH v2 02/12] target/arm: Unify unallocated path in disas_fp_1src, Richard Henderson, 2021/05/25
- [PATCH v2 01/12] target/arm: Add isar_feature_{aa32, aa64, aa64_sve}_bf16, Richard Henderson, 2021/05/25
- [PATCH v2 05/12] softfpu: Add float_round_to_odd_inf,
Richard Henderson <=
- [PATCH v2 03/12] target/arm: Implement scalar float32 to bfloat16 conversion, Richard Henderson, 2021/05/25
- [PATCH v2 04/12] target/arm: Implement vector float32 to bfloat16 conversion, Richard Henderson, 2021/05/25
- [PATCH v2 08/12] target/arm: Implement bfloat16 matrix multiply accumulate, Richard Henderson, 2021/05/25
- [PATCH v2 07/12] target/arm: Implement bfloat16 dot product (indexed), Richard Henderson, 2021/05/25
- [PATCH v2 09/12] target/arm: Implement bfloat widening fma (vector), Richard Henderson, 2021/05/25
- [PATCH v2 10/12] target/arm: Implement bfloat widening fma (indexed), Richard Henderson, 2021/05/25
- [PATCH v2 12/12] target/arm: Enable BFloat16 extensions, Richard Henderson, 2021/05/25
- [PATCH v2 06/12] target/arm: Implement bfloat16 dot product (vector), Richard Henderson, 2021/05/25
- [PATCH v2 11/12] linux-user/aarch64: Enable hwcap bits for bfloat16, Richard Henderson, 2021/05/25