qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH v3 08/12] target/arm: Split out flags setting from vfp compares
Date: Fri,  8 Feb 2019 19:38:43 -0800	[thread overview]
Message-ID: <20190209033847.9014-9-richard.henderson@linaro.org> (raw)
In-Reply-To: <20190209033847.9014-1-richard.henderson@linaro.org>

Minimize the code within a macro by splitting out a helper function.
Use deposit32 instead of manual bit manipulation.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/helper.c | 45 +++++++++++++++++++++++++++------------------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 6ac81c2ca2..51be3fa16f 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -12752,31 +12752,40 @@ float64 VFP_HELPER(sqrt, d)(float64 a, CPUARMState *env)
     return float64_sqrt(a, &env->vfp.fp_status);
 }
 
+static void softfloat_to_vfp_compare(CPUARMState *env, int cmp)
+{
+    uint32_t flags;
+    switch (cmp) {
+    case float_relation_equal:
+        flags = 0x6;
+        break;
+    case float_relation_less:
+        flags = 0x8;
+        break;
+    case float_relation_greater:
+        flags = 0x2;
+        break;
+    case float_relation_unordered:
+        flags = 0x3;
+        break;
+    default:
+        g_assert_not_reached();
+    }
+    env->vfp.xregs[ARM_VFP_FPSCR] =
+        deposit32(env->vfp.xregs[ARM_VFP_FPSCR], 28, 4, flags);
+}
+
 /* XXX: check quiet/signaling case */
 #define DO_VFP_cmp(p, type) \
 void VFP_HELPER(cmp, p)(type a, type b, CPUARMState *env)  \
 { \
-    uint32_t flags; \
-    switch(type ## _compare_quiet(a, b, &env->vfp.fp_status)) { \
-    case 0: flags = 0x6; break; \
-    case -1: flags = 0x8; break; \
-    case 1: flags = 0x2; break; \
-    default: case 2: flags = 0x3; break; \
-    } \
-    env->vfp.xregs[ARM_VFP_FPSCR] = (flags << 28) \
-        | (env->vfp.xregs[ARM_VFP_FPSCR] & 0x0fffffff); \
+    softfloat_to_vfp_compare(env, \
+        type ## _compare_quiet(a, b, &env->vfp.fp_status)); \
 } \
 void VFP_HELPER(cmpe, p)(type a, type b, CPUARMState *env) \
 { \
-    uint32_t flags; \
-    switch(type ## _compare(a, b, &env->vfp.fp_status)) { \
-    case 0: flags = 0x6; break; \
-    case -1: flags = 0x8; break; \
-    case 1: flags = 0x2; break; \
-    default: case 2: flags = 0x3; break; \
-    } \
-    env->vfp.xregs[ARM_VFP_FPSCR] = (flags << 28) \
-        | (env->vfp.xregs[ARM_VFP_FPSCR] & 0x0fffffff); \
+    softfloat_to_vfp_compare(env, \
+        type ## _compare(a, b, &env->vfp.fp_status)); \
 }
 DO_VFP_cmp(s, float32)
 DO_VFP_cmp(d, float64)
-- 
2.17.2

  parent reply	other threads:[~2019-02-09  3:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-09  3:38 [Qemu-devel] [PATCH v3 00/12] target/arm: tcg vector cleanups Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 01/12] target/arm: Rely on optimization within tcg_gen_gvec_or Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 02/12] target/arm: Use vector minmax expanders for aarch64 Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 03/12] target/arm: Use vector minmax expanders for aarch32 Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 04/12] target/arm: Use tcg integer min/max primitives for neon Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 05/12] target/arm: Remove neon min/max helpers Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 06/12] target/arm: Fix vfp_gdb_get/set_reg vs FPSCR Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 07/12] target/arm: Fix arm_cpu_dump_state " Richard Henderson
2019-02-09  3:38 ` Richard Henderson [this message]
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 09/12] target/arm: Fix set of bits kept in xregs[ARM_VFP_FPSCR] Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 10/12] target/arm: Split out FPSCR.QC to a vector field Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 11/12] target/arm: Use vector operations for saturation Richard Henderson
2019-02-09  3:38 ` [Qemu-devel] [PATCH v3 12/12] target/arm: Add missing clear_tail calls Richard Henderson
2019-02-09  3:56 ` [Qemu-devel] [PATCH v3 00/12] target/arm: tcg vector cleanups no-reply
2019-02-09  4:00 ` no-reply
2019-02-14 16:12 ` Peter Maydell

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=20190209033847.9014-9-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).