qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 27/76] target/arm: Define FPCR AH, FIZ, NEP bits


From: Richard Henderson
Subject: Re: [PATCH 27/76] target/arm: Define FPCR AH, FIZ, NEP bits
Date: Sat, 25 Jan 2025 09:08:24 -0800
User-agent: Mozilla Thunderbird

On 1/24/25 08:27, Peter Maydell wrote:
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);
+    }

I suppose this aa64 check, without is_a64(), is ok because the a32 caller has already applied FPSCR_FPCR_MASK. And similarly for the ebf16 check below.

if (!cpu_isar_feature(aa64_ebf16, cpu)) {
          val &= ~FPCR_EBF;

But it does feel like we could usefully move these to vfp_set_fpcr, or such?


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]