qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] target/mips: Misc patches
@ 2020-09-08 12:44 Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 1/4] target/mips: Demacro helpers for <ABS|CHS>.<D|S|PS> Aleksandar Markovic
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Aleksandar Markovic @ 2020-09-08 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: aleksandar.rikalo, Aleksandar Markovic, aurelien

A set of several, mostly FP, refactorings and improvements.

Aleksandar Markovic (4):
  target/mips: Demacro helpers for <ABS|CHS>.<D|S|PS>
  target/mips: Demacro helpers for M<ADD|SUB>F.<D|S>
  target/mips: Demacro helpers for <MAX|MAXA|MIN|MINA>.<D|S>
  target/mips: Refactor helpers for fp comparison instructions

 target/mips/fpu_helper.c | 276 +++++++++++++++++++++++++++------------
 1 file changed, 195 insertions(+), 81 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] target/mips: Demacro helpers for <ABS|CHS>.<D|S|PS>
  2020-09-08 12:44 [PATCH 0/4] target/mips: Misc patches Aleksandar Markovic
@ 2020-09-08 12:44 ` Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 2/4] target/mips: Demacro helpers for M<ADD|SUB>F.<D|S> Aleksandar Markovic
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Aleksandar Markovic @ 2020-09-08 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: aleksandar.rikalo, Aleksandar Markovic, aurelien

Remove function definitions via macros to achieve better code clarity.

Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
---
 target/mips/fpu_helper.c | 61 ++++++++++++++++++++++++++--------------
 1 file changed, 40 insertions(+), 21 deletions(-)

diff --git a/target/mips/fpu_helper.c b/target/mips/fpu_helper.c
index 7a3a61cab3..f89213947f 100644
--- a/target/mips/fpu_helper.c
+++ b/target/mips/fpu_helper.c
@@ -983,27 +983,46 @@ uint32_t helper_float_floor_2008_w_s(CPUMIPSState *env, uint32_t fst0)
 }
 
 /* unary operations, not modifying fp status  */
-#define FLOAT_UNOP(name)                                       \
-uint64_t helper_float_ ## name ## _d(uint64_t fdt0)                \
-{                                                              \
-    return float64_ ## name(fdt0);                             \
-}                                                              \
-uint32_t helper_float_ ## name ## _s(uint32_t fst0)                \
-{                                                              \
-    return float32_ ## name(fst0);                             \
-}                                                              \
-uint64_t helper_float_ ## name ## _ps(uint64_t fdt0)               \
-{                                                              \
-    uint32_t wt0;                                              \
-    uint32_t wth0;                                             \
-                                                               \
-    wt0 = float32_ ## name(fdt0 & 0XFFFFFFFF);                 \
-    wth0 = float32_ ## name(fdt0 >> 32);                       \
-    return ((uint64_t)wth0 << 32) | wt0;                       \
-}
-FLOAT_UNOP(abs)
-FLOAT_UNOP(chs)
-#undef FLOAT_UNOP
+
+uint64_t helper_float_abs_d(uint64_t fdt0)
+{
+   return float64_abs(fdt0);
+}
+
+uint32_t helper_float_abs_s(uint32_t fst0)
+{
+    return float32_abs(fst0);
+}
+
+uint64_t helper_float_abs_ps(uint64_t fdt0)
+{
+    uint32_t wt0;
+    uint32_t wth0;
+
+    wt0 = float32_abs(fdt0 & 0XFFFFFFFF);
+    wth0 = float32_abs(fdt0 >> 32);
+    return ((uint64_t)wth0 << 32) | wt0;
+}
+
+uint64_t helper_float_chs_d(uint64_t fdt0)
+{
+   return float64_chs(fdt0);
+}
+
+uint32_t helper_float_chs_s(uint32_t fst0)
+{
+    return float32_chs(fst0);
+}
+
+uint64_t helper_float_chs_ps(uint64_t fdt0)
+{
+    uint32_t wt0;
+    uint32_t wth0;
+
+    wt0 = float32_chs(fdt0 & 0XFFFFFFFF);
+    wth0 = float32_chs(fdt0 >> 32);
+    return ((uint64_t)wth0 << 32) | wt0;
+}
 
 /* MIPS specific unary operations */
 uint64_t helper_float_recip_d(CPUMIPSState *env, uint64_t fdt0)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] target/mips: Demacro helpers for M<ADD|SUB>F.<D|S>
  2020-09-08 12:44 [PATCH 0/4] target/mips: Misc patches Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 1/4] target/mips: Demacro helpers for <ABS|CHS>.<D|S|PS> Aleksandar Markovic
@ 2020-09-08 12:44 ` Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 3/4] target/mips: Demacro helpers for <MAX|MAXA|MIN|MINA>.<D|S> Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 4/4] target/mips: Refactor helpers for fp comparison instructions Aleksandar Markovic
  3 siblings, 0 replies; 5+ messages in thread
From: Aleksandar Markovic @ 2020-09-08 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: aleksandar.rikalo, Aleksandar Markovic, aurelien

Remove function definitions via macros to achieve better code clarity.

Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
---
 target/mips/fpu_helper.c | 63 +++++++++++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 17 deletions(-)

diff --git a/target/mips/fpu_helper.c b/target/mips/fpu_helper.c
index f89213947f..98313951cb 100644
--- a/target/mips/fpu_helper.c
+++ b/target/mips/fpu_helper.c
@@ -1666,25 +1666,54 @@ uint64_t helper_float_nmsub_ps(CPUMIPSState *env, uint64_t fdt0,
 }
 
 
-#define FLOAT_FMADDSUB(name, bits, muladd_arg)                          \
-uint ## bits ## _t helper_float_ ## name(CPUMIPSState *env,             \
-                                         uint ## bits ## _t fs,         \
-                                         uint ## bits ## _t ft,         \
-                                         uint ## bits ## _t fd)         \
-{                                                                       \
-    uint ## bits ## _t fdret;                                           \
-                                                                        \
-    fdret = float ## bits ## _muladd(fs, ft, fd, muladd_arg,            \
-                                     &env->active_fpu.fp_status);       \
-    update_fcr31(env, GETPC());                                         \
-    return fdret;                                                       \
+uint32_t helper_float_maddf_s(CPUMIPSState *env, uint32_t fs,
+                              uint32_t ft, uint32_t fd)
+{
+    uint32_t fdret;
+
+    fdret = float32_muladd(fs, ft, fd, 0,
+                           &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint64_t helper_float_maddf_d(CPUMIPSState *env, uint64_t fs,
+                              uint64_t ft, uint64_t fd)
+{
+    uint64_t fdret;
+
+    fdret = float64_muladd(fs, ft, fd, 0,
+                           &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint32_t helper_float_msubf_s(CPUMIPSState *env, uint32_t fs,
+                              uint32_t ft, uint32_t fd)
+{
+    uint32_t fdret;
+
+    fdret = float32_muladd(fs, ft, fd, float_muladd_negate_product,
+                           &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint64_t helper_float_msubf_d(CPUMIPSState *env, uint64_t fs,
+                              uint64_t ft, uint64_t fd)
+{
+    uint64_t fdret;
+
+    fdret = float64_muladd(fs, ft, fd, float_muladd_negate_product,
+                           &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
 }
 
-FLOAT_FMADDSUB(maddf_s, 32, 0)
-FLOAT_FMADDSUB(maddf_d, 64, 0)
-FLOAT_FMADDSUB(msubf_s, 32, float_muladd_negate_product)
-FLOAT_FMADDSUB(msubf_d, 64, float_muladd_negate_product)
-#undef FLOAT_FMADDSUB
 
 /* compare operations */
 #define FOP_COND_D(op, cond)                                   \
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] target/mips: Demacro helpers for <MAX|MAXA|MIN|MINA>.<D|S>
  2020-09-08 12:44 [PATCH 0/4] target/mips: Misc patches Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 1/4] target/mips: Demacro helpers for <ABS|CHS>.<D|S|PS> Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 2/4] target/mips: Demacro helpers for M<ADD|SUB>F.<D|S> Aleksandar Markovic
@ 2020-09-08 12:44 ` Aleksandar Markovic
  2020-09-08 12:44 ` [PATCH 4/4] target/mips: Refactor helpers for fp comparison instructions Aleksandar Markovic
  3 siblings, 0 replies; 5+ messages in thread
From: Aleksandar Markovic @ 2020-09-08 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: aleksandar.rikalo, Aleksandar Markovic, aurelien

Remove function definitions via macros to achieve better code clarity.

Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
---
 target/mips/fpu_helper.c | 104 ++++++++++++++++++++++++++++++---------
 1 file changed, 81 insertions(+), 23 deletions(-)

diff --git a/target/mips/fpu_helper.c b/target/mips/fpu_helper.c
index 98313951cb..f480c7296e 100644
--- a/target/mips/fpu_helper.c
+++ b/target/mips/fpu_helper.c
@@ -1475,29 +1475,87 @@ uint64_t helper_float_mulr_ps(CPUMIPSState *env, uint64_t fdt0, uint64_t fdt1)
     return ((uint64_t)fsth2 << 32) | fstl2;
 }
 
-#define FLOAT_MINMAX(name, bits, minmaxfunc)                            \
-uint ## bits ## _t helper_float_ ## name(CPUMIPSState *env,             \
-                                         uint ## bits ## _t fs,         \
-                                         uint ## bits ## _t ft)         \
-{                                                                       \
-    uint ## bits ## _t fdret;                                           \
-                                                                        \
-    fdret = float ## bits ## _ ## minmaxfunc(fs, ft,                    \
-                                           &env->active_fpu.fp_status); \
-    update_fcr31(env, GETPC());                                         \
-    return fdret;                                                       \
-}
-
-FLOAT_MINMAX(max_s, 32, maxnum)
-FLOAT_MINMAX(max_d, 64, maxnum)
-FLOAT_MINMAX(maxa_s, 32, maxnummag)
-FLOAT_MINMAX(maxa_d, 64, maxnummag)
-
-FLOAT_MINMAX(min_s, 32, minnum)
-FLOAT_MINMAX(min_d, 64, minnum)
-FLOAT_MINMAX(mina_s, 32, minnummag)
-FLOAT_MINMAX(mina_d, 64, minnummag)
-#undef FLOAT_MINMAX
+
+uint32_t helper_float_max_s(CPUMIPSState *env, uint32_t fs, uint32_t ft)
+{
+    uint32_t fdret;
+
+    fdret = float32_maxnum(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint64_t helper_float_max_d(CPUMIPSState *env, uint64_t fs, uint64_t ft)
+{
+    uint64_t fdret;
+
+    fdret = float64_maxnum(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint32_t helper_float_maxa_s(CPUMIPSState *env, uint32_t fs, uint32_t ft)
+{
+    uint32_t fdret;
+
+    fdret = float32_maxnummag(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint64_t helper_float_maxa_d(CPUMIPSState *env, uint64_t fs, uint64_t ft)
+{
+    uint64_t fdret;
+
+    fdret = float64_maxnummag(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint32_t helper_float_min_s(CPUMIPSState *env, uint32_t fs, uint32_t ft)
+{
+    uint32_t fdret;
+
+    fdret = float32_minnum(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint64_t helper_float_min_d(CPUMIPSState *env, uint64_t fs, uint64_t ft)
+{
+    uint64_t fdret;
+
+    fdret = float64_minnum(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint32_t helper_float_mina_s(CPUMIPSState *env, uint32_t fs, uint32_t ft)
+{
+    uint32_t fdret;
+
+    fdret = float32_minnummag(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
+uint64_t helper_float_mina_d(CPUMIPSState *env, uint64_t fs, uint64_t ft)
+{
+    uint64_t fdret;
+
+    fdret = float64_minnummag(fs, ft, &env->active_fpu.fp_status);
+
+    update_fcr31(env, GETPC());
+    return fdret;
+}
+
 
 /* ternary operations */
 
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] target/mips: Refactor helpers for fp comparison instructions
  2020-09-08 12:44 [PATCH 0/4] target/mips: Misc patches Aleksandar Markovic
                   ` (2 preceding siblings ...)
  2020-09-08 12:44 ` [PATCH 3/4] target/mips: Demacro helpers for <MAX|MAXA|MIN|MINA>.<D|S> Aleksandar Markovic
@ 2020-09-08 12:44 ` Aleksandar Markovic
  3 siblings, 0 replies; 5+ messages in thread
From: Aleksandar Markovic @ 2020-09-08 12:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: aleksandar.rikalo, Aleksandar Markovic, aurelien

This change causes slighlty better performance of emulation of fp
comparison instructions via better compiler optimization of refactored
code. The functionality is otherwise unchanged.

Signed-off-by: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>
---
 target/mips/fpu_helper.c | 56 +++++++++++++++++++++++-----------------
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/target/mips/fpu_helper.c b/target/mips/fpu_helper.c
index f480c7296e..22d533322b 100644
--- a/target/mips/fpu_helper.c
+++ b/target/mips/fpu_helper.c
@@ -1780,11 +1780,12 @@ void helper_cmp_d_ ## op(CPUMIPSState *env, uint64_t fdt0,     \
 {                                                              \
     int c;                                                     \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }                                                              \
 void helper_cmpabs_d_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
                             uint64_t fdt1, int cc)             \
@@ -1793,11 +1794,12 @@ void helper_cmpabs_d_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
     fdt0 = float64_abs(fdt0);                                  \
     fdt1 = float64_abs(fdt1);                                  \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }
 
 /*
@@ -1859,11 +1861,12 @@ void helper_cmp_s_ ## op(CPUMIPSState *env, uint32_t fst0,     \
 {                                                              \
     int c;                                                     \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }                                                              \
 void helper_cmpabs_s_ ## op(CPUMIPSState *env, uint32_t fst0,  \
                             uint32_t fst1, int cc)             \
@@ -1872,11 +1875,12 @@ void helper_cmpabs_s_ ## op(CPUMIPSState *env, uint32_t fst0,  \
     fst0 = float32_abs(fst0);                                  \
     fst1 = float32_abs(fst1);                                  \
     c = cond;                                                  \
-    update_fcr31(env, GETPC());                                \
-    if (c)                                                     \
+    if (c) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                      \
-    else                                                       \
+    } else {                                                   \
         CLEAR_FP_COND(cc, env->active_fpu);                    \
+    }                                                          \
+    update_fcr31(env, GETPC());                                \
 }
 
 /*
@@ -1944,15 +1948,17 @@ void helper_cmp_ps_ ## op(CPUMIPSState *env, uint64_t fdt0,     \
     fsth1 = fdt1 >> 32;                                         \
     cl = condl;                                                 \
     ch = condh;                                                 \
-    update_fcr31(env, GETPC());                                 \
-    if (cl)                                                     \
+    if (cl) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                       \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc, env->active_fpu);                     \
-    if (ch)                                                     \
+    }                                                           \
+    if (ch) {                                                   \
         SET_FP_COND(cc + 1, env->active_fpu);                   \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc + 1, env->active_fpu);                 \
+    }                                                           \
+    update_fcr31(env, GETPC());                                 \
 }                                                               \
 void helper_cmpabs_ps_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
                              uint64_t fdt1, int cc)             \
@@ -1965,15 +1971,17 @@ void helper_cmpabs_ps_ ## op(CPUMIPSState *env, uint64_t fdt0,  \
     fsth1 = float32_abs(fdt1 >> 32);                            \
     cl = condl;                                                 \
     ch = condh;                                                 \
-    update_fcr31(env, GETPC());                                 \
-    if (cl)                                                     \
+    if (cl) {                                                   \
         SET_FP_COND(cc, env->active_fpu);                       \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc, env->active_fpu);                     \
-    if (ch)                                                     \
+    }                                                           \
+    if (ch) {                                                   \
         SET_FP_COND(cc + 1, env->active_fpu);                   \
-    else                                                        \
+    } else {                                                    \
         CLEAR_FP_COND(cc + 1, env->active_fpu);                 \
+    }                                                           \
+    update_fcr31(env, GETPC());                                 \
 }
 
 /*
@@ -2080,12 +2088,12 @@ uint64_t helper_r6_cmp_d_ ## op(CPUMIPSState *env, uint64_t fdt0,   \
 {                                                                   \
     uint64_t c;                                                     \
     c = cond;                                                       \
-    update_fcr31(env, GETPC());                                     \
     if (c) {                                                        \
         return -1;                                                  \
     } else {                                                        \
         return 0;                                                   \
     }                                                               \
+    update_fcr31(env, GETPC());                                     \
 }
 
 /*
@@ -2175,12 +2183,12 @@ uint32_t helper_r6_cmp_s_ ## op(CPUMIPSState *env, uint32_t fst0,   \
 {                                                                   \
     uint64_t c;                                                     \
     c = cond;                                                       \
-    update_fcr31(env, GETPC());                                     \
     if (c) {                                                        \
         return -1;                                                  \
     } else {                                                        \
         return 0;                                                   \
     }                                                               \
+    update_fcr31(env, GETPC());                                     \
 }
 
 /*
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-08 12:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 12:44 [PATCH 0/4] target/mips: Misc patches Aleksandar Markovic
2020-09-08 12:44 ` [PATCH 1/4] target/mips: Demacro helpers for <ABS|CHS>.<D|S|PS> Aleksandar Markovic
2020-09-08 12:44 ` [PATCH 2/4] target/mips: Demacro helpers for M<ADD|SUB>F.<D|S> Aleksandar Markovic
2020-09-08 12:44 ` [PATCH 3/4] target/mips: Demacro helpers for <MAX|MAXA|MIN|MINA>.<D|S> Aleksandar Markovic
2020-09-08 12:44 ` [PATCH 4/4] target/mips: Refactor helpers for fp comparison instructions Aleksandar Markovic

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).