All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Yang Zhong" <yang.zhong@intel.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Andrew Jones" <drjones@redhat.com>,
	"Samuel Ortiz" <sameo@linux.intel.com>,
	"Rob Bradford" <robert.bradford@intel.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-arm@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: [Qemu-devel] [PATCH v3 15/27] target/arm/vfp_helper: Extract vfp_set_fpscr_to_host()
Date: Mon,  1 Jul 2019 15:25:04 +0200	[thread overview]
Message-ID: <20190701132516.26392-16-philmd@redhat.com> (raw)
In-Reply-To: <20190701132516.26392-1-philmd@redhat.com>

The vfp_set_fpscr() helper contains code specific to the host
floating point implementation (here the SoftFloat library).
Extract this code to vfp_set_fpscr_to_host().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 target/arm/vfp_helper.c | 127 +++++++++++++++++++++-------------------
 1 file changed, 66 insertions(+), 61 deletions(-)

diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
index d54e325324..b19a395b67 100644
--- a/target/arm/vfp_helper.c
+++ b/target/arm/vfp_helper.c
@@ -81,71 +81,11 @@ static inline int vfp_exceptbits_to_host(int target_bits)
     return host_bits;
 }
 
-uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
-{
-    uint32_t i, fpscr;
-
-    fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
-            | (env->vfp.vec_len << 16)
-            | (env->vfp.vec_stride << 20);
-
-    i = get_float_exception_flags(&env->vfp.fp_status);
-    i |= get_float_exception_flags(&env->vfp.standard_fp_status);
-    /* FZ16 does not generate an input denormal exception.  */
-    i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
-          & ~float_flag_input_denormal);
-    fpscr |= vfp_exceptbits_from_host(i);
-
-    i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
-    fpscr |= i ? FPCR_QC : 0;
-
-    return fpscr;
-}
-
-uint32_t vfp_get_fpscr(CPUARMState *env)
-{
-    return HELPER(vfp_get_fpscr)(env);
-}
-
-void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
+static void vfp_set_fpscr_to_host(CPUARMState *env, uint32_t val)
 {
     int i;
     uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR];
 
-    /* When ARMv8.2-FP16 is not supported, FZ16 is RES0.  */
-    if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) {
-        val &= ~FPCR_FZ16;
-    }
-
-    if (arm_feature(env, ARM_FEATURE_M)) {
-        /*
-         * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
-         * and also for the trapped-exception-handling bits IxE.
-         */
-        val &= 0xf7c0009f;
-    }
-
-    /*
-     * We don't implement trapped exception handling, so the
-     * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
-     *
-     * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC
-     * (which are stored in fp_status), and the other RES0 bits
-     * in between, then we clear all of the low 16 bits.
-     */
-    env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000;
-    env->vfp.vec_len = (val >> 16) & 7;
-    env->vfp.vec_stride = (val >> 20) & 3;
-
-    /*
-     * The bit we set within fpscr_q is arbitrary; the register as a
-     * whole being zero/non-zero is what counts.
-     */
-    env->vfp.qc[0] = val & FPCR_QC;
-    env->vfp.qc[1] = 0;
-    env->vfp.qc[2] = 0;
-    env->vfp.qc[3] = 0;
-
     changed ^= val;
     if (changed & (3 << 22)) {
         i = (val >> 22) & 3;
@@ -193,6 +133,71 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
     set_float_exception_flags(0, &env->vfp.standard_fp_status);
 }
 
+uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env)
+{
+    uint32_t i, fpscr;
+
+    fpscr = env->vfp.xregs[ARM_VFP_FPSCR]
+            | (env->vfp.vec_len << 16)
+            | (env->vfp.vec_stride << 20);
+
+    i = get_float_exception_flags(&env->vfp.fp_status);
+    i |= get_float_exception_flags(&env->vfp.standard_fp_status);
+    /* FZ16 does not generate an input denormal exception.  */
+    i |= (get_float_exception_flags(&env->vfp.fp_status_f16)
+          & ~float_flag_input_denormal);
+    fpscr |= vfp_exceptbits_from_host(i);
+
+    i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3];
+    fpscr |= i ? FPCR_QC : 0;
+
+    return fpscr;
+}
+
+uint32_t vfp_get_fpscr(CPUARMState *env)
+{
+    return HELPER(vfp_get_fpscr)(env);
+}
+
+void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
+{
+    /* When ARMv8.2-FP16 is not supported, FZ16 is RES0.  */
+    if (!cpu_isar_feature(aa64_fp16, env_archcpu(env))) {
+        val &= ~FPCR_FZ16;
+    }
+
+    if (arm_feature(env, ARM_FEATURE_M)) {
+        /*
+         * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
+         * and also for the trapped-exception-handling bits IxE.
+         */
+        val &= 0xf7c0009f;
+    }
+
+    /*
+     * We don't implement trapped exception handling, so the
+     * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
+     *
+     * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC
+     * (which are stored in fp_status), and the other RES0 bits
+     * in between, then we clear all of the low 16 bits.
+     */
+    env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000;
+    env->vfp.vec_len = (val >> 16) & 7;
+    env->vfp.vec_stride = (val >> 20) & 3;
+
+    /*
+     * The bit we set within fpscr_q is arbitrary; the register as a
+     * whole being zero/non-zero is what counts.
+     */
+    env->vfp.qc[0] = val & FPCR_QC;
+    env->vfp.qc[1] = 0;
+    env->vfp.qc[2] = 0;
+    env->vfp.qc[3] = 0;
+
+    vfp_set_fpscr_to_host(env, val);
+}
+
 void vfp_set_fpscr(CPUARMState *env, uint32_t val)
 {
     HELPER(vfp_set_fpscr)(env, val);
-- 
2.20.1



  parent reply	other threads:[~2019-07-01 13:46 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 13:24 [Qemu-devel] [PATCH v3 00/27] Support disabling TCG on ARM Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 01/27] target/arm: Makefile cleanup (Aarch64) Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 02/27] target/arm: Makefile cleanup (ARM) Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 03/27] target/arm: Makefile cleanup (KVM) Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 04/27] target/arm: Makefile cleanup (softmmu) Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 05/27] target/arm: Add copyright boilerplate Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 06/27] target/arm/helper: Remove unused include Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 07/27] target/arm: Fix multiline comment syntax Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 08/27] target/arm: Fix coding style issues Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 09/27] target/arm: Move the DC ZVA helper into op_helper Philippe Mathieu-Daudé
2019-07-01 13:24 ` [Qemu-devel] [PATCH v3 10/27] target/arm: Move CPU state dumping routines to cpu.c Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 11/27] target/arm: Declare get_phys_addr() function publicly Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 12/27] target/arm: Move TLB related routines to tlb_helper.c Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 13/27] target/arm: Move debug routines to debug_helper.c Philippe Mathieu-Daudé
2019-07-01 15:19   ` Peter Maydell
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 14/27] target/arm/vfp_helper: Move code around Philippe Mathieu-Daudé
2019-07-01 13:25 ` Philippe Mathieu-Daudé [this message]
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 16/27] target/arm/vfp_helper: Extract vfp_set_fpscr_from_host() Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 17/27] target/arm/vfp_helper: Restrict the SoftFloat use to TCG Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 18/27] target/arm: Restrict semi-hosting " Philippe Mathieu-Daudé
2019-07-01 15:25   ` Peter Maydell
2019-07-01 15:38     ` Philippe Mathieu-Daudé
2019-07-01 16:10       ` Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 19/27] target/arm: Restrict PSCI " Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 20/27] target/arm: Declare arm_log_exception() function publicly Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 21/27] target/arm: Declare some M-profile functions publicly Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 22/27] target/arm/helper: Move M profile routines to m_helper.c Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [RFC PATCH v3 23/27] target/arm: Restrict pre-ARMv7 cpus to TCG Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [RFC PATCH v3 24/27] target/arm: Do not build pre-ARMv7 cpus when using KVM Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [RFC PATCH v3 25/27] target/arm: Restrict R and M profiles to TCG Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [RFC PATCH v3 26/27] target/arm: Do not build A/M-profile cpus when using KVM Philippe Mathieu-Daudé
2019-07-01 13:25 ` [Qemu-devel] [PATCH v3 27/27] target/arm: Do not build TCG objects when TCG is off Philippe Mathieu-Daudé
2019-07-01 15:41 ` [Qemu-devel] [PATCH v3 00/27] Support disabling TCG on ARM Peter Maydell
2019-07-01 15:44   ` Philippe Mathieu-Daudé
2019-07-01 15:51     ` Samuel Ortiz
2019-07-01 15:55     ` Peter Maydell
2019-07-01 18:41 ` no-reply
2019-07-01 21:15   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190701132516.26392-16-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=drjones@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=robert.bradford@intel.com \
    --cc=sameo@linux.intel.com \
    --cc=yang.zhong@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.