[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/69] target/arm: Define FPCR AH, FIZ, NEP bits
From: |
Peter Maydell |
Subject: |
[PATCH v2 06/69] target/arm: Define FPCR AH, FIZ, NEP bits |
Date: |
Sat, 1 Feb 2025 16:39:09 +0000 |
The Armv8.7 FEAT_AFP feature defines three new control bits in
the FPCR:
* FPCR.AH: "alternate floating point mode"; this changes floating
point behaviour in a variety of ways, including:
- the sign of a default NaN is 1, not 0
- if FPCR.FZ is also 1, denormals detected after rounding
with an unbounded exponent has been applied are flushed to zero
- FPCR.FZ does not cause denormalized inputs to be flushed to zero
- miscellaneous other corner-case behaviour changes
* FPCR.FIZ: flush denormalized numbers to zero on input for
most instructions
* FPCR.NEP: makes scalar SIMD operations merge the result with
higher vector elements in one of the source registers, instead
of zeroing the higher elements of the destination
This commit defines the new bits in the FPCR, and allows them to be
read or written when FEAT_AFP is implemented. Actual behaviour
changes will be implemented in subsequent commits.
Note that these are the first FPCR bits which don't appear in the
AArch32 FPSCR view of the register, and which share bit positions
with FPSR bits.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/cpu-features.h | 5 +++++
target/arm/cpu.h | 3 +++
target/arm/vfp_helper.c | 11 ++++++++---
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h
index 30302d6c5b4..7bf24c506b3 100644
--- a/target/arm/cpu-features.h
+++ b/target/arm/cpu-features.h
@@ -802,6 +802,11 @@ static inline bool isar_feature_aa64_hcx(const
ARMISARegisters *id)
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, HCX) != 0;
}
+static inline bool isar_feature_aa64_afp(const ARMISARegisters *id)
+{
+ return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, AFP) != 0;
+}
+
static inline bool isar_feature_aa64_tidcp1(const ARMISARegisters *id)
{
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, TIDCP1) != 0;
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 2213c277348..7ba227ac4c5 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1713,6 +1713,9 @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val);
*/
/* FPCR bits */
+#define FPCR_FIZ (1 << 0) /* Flush Inputs to Zero (FEAT_AFP) */
+#define FPCR_AH (1 << 1) /* Alternate Handling (FEAT_AFP) */
+#define FPCR_NEP (1 << 2) /* SIMD scalar ops preserve elts (FEAT_AFP) */
#define FPCR_IOE (1 << 8) /* Invalid Operation exception trap enable */
#define FPCR_DZE (1 << 9) /* Divide by Zero exception trap enable */
#define FPCR_OFE (1 << 10) /* Overflow exception trap enable */
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
index 3c8f3e65887..8c79ab4fc8a 100644
--- a/target/arm/vfp_helper.c
+++ b/target/arm/vfp_helper.c
@@ -242,6 +242,9 @@ static void vfp_set_fpcr_masked(CPUARMState *env, uint32_t
val, uint32_t mask)
if (!cpu_isar_feature(any_fp16, cpu)) {
val &= ~FPCR_FZ16;
}
+ if (!cpu_isar_feature(aa64_afp, cpu)) {
+ val &= ~(FPCR_FIZ | FPCR_AH | FPCR_NEP);
+ }
if (!cpu_isar_feature(aa64_ebf16, cpu)) {
val &= ~FPCR_EBF;
@@ -271,12 +274,14 @@ static void vfp_set_fpcr_masked(CPUARMState *env,
uint32_t val, uint32_t mask)
* We don't implement trapped exception handling, so the
* trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
*
- * The FPCR bits we keep in vfp.fpcr are AHP, DN, FZ, RMode, EBF
- * and FZ16. Len, Stride and LTPSIZE we just handled. Store those bits
+ * The FPCR bits we keep in vfp.fpcr are AHP, DN, FZ, RMode, EBF, FZ16,
+ * FIZ, AH, and NEP.
+ * Len, Stride and LTPSIZE we just handled. Store those bits
* there, and zero any of the other FPCR bits and the RES0 and RAZ/WI
* bits.
*/
- val &= FPCR_AHP | FPCR_DN | FPCR_FZ | FPCR_RMODE_MASK | FPCR_FZ16 |
FPCR_EBF;
+ val &= FPCR_AHP | FPCR_DN | FPCR_FZ | FPCR_RMODE_MASK | FPCR_FZ16 |
+ FPCR_EBF | FPCR_FIZ | FPCR_AH | FPCR_NEP;
env->vfp.fpcr &= ~mask;
env->vfp.fpcr |= val;
}
--
2.34.1
- [PATCH v2 00/69] target/arm: FEAT_AFP and FEAT_RPRES, Peter Maydell, 2025/02/01
- [PATCH v2 01/69] target/i386: Do not raise Invalid for 0 * Inf + QNaN, Peter Maydell, 2025/02/01
- [PATCH v2 02/69] tests/tcg/x86_64/fma: Test some x86 fused-multiply-add cases, Peter Maydell, 2025/02/01
- [PATCH v2 03/69] fpu: Add float_class_denormal, Peter Maydell, 2025/02/01
- [PATCH v2 05/69] fpu: allow flushing of output denormals to be after rounding, Peter Maydell, 2025/02/01
- [PATCH v2 06/69] target/arm: Define FPCR AH, FIZ, NEP bits,
Peter Maydell <=
- [PATCH v2 04/69] fpu: Implement float_flag_input_denormal_used, Peter Maydell, 2025/02/01
- [PATCH v2 11/69] target/arm: Set up float_status to use for FPCR.AH=1 behaviour, Peter Maydell, 2025/02/01
- [PATCH v2 07/69] target/arm: Implement FPCR.FIZ handling, Peter Maydell, 2025/02/01
- [PATCH v2 14/69] target/arm: Use FPST_FPCR_AH for BFMLAL*, BFMLSL* insns, Peter Maydell, 2025/02/01
- [PATCH v2 08/69] target/arm: Adjust FP behaviour for FPCR.AH = 1, Peter Maydell, 2025/02/01
- [PATCH v2 09/69] target/arm: Adjust exception flag handling for AH = 1, Peter Maydell, 2025/02/01
- [PATCH v2 10/69] target/arm: Add FPCR.AH to tbflags, Peter Maydell, 2025/02/01
- [PATCH v2 13/69] target/arm: Use FPST_FPCR_AH for BFCVT* insns, Peter Maydell, 2025/02/01
- [PATCH v2 19/69] target/arm: Handle FPCR.NEP for 1-input scalar operations, Peter Maydell, 2025/02/01