[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/17] target/ppc: Merge fsqrt and fsqrts helpers
From: |
Daniel Henrique Barboza |
Subject: |
[PULL 06/17] target/ppc: Merge fsqrt and fsqrts helpers |
Date: |
Tue, 20 Sep 2022 16:41:51 -0300 |
From: Víctor Colombo <victor.colombo@eldorado.org.br>
These two helpers are almost identical, differing only by the softfloat
operation it calls. Merge them into one using a macro.
Also, take this opportunity to capitalize the helper name as we moved
the instruction to decodetree in a previous patch.
Signed-off-by: Víctor Colombo <victor.colombo@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220905123746.54659-4-victor.colombo@eldorado.org.br>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
target/ppc/fpu_helper.c | 35 +++++++++++-------------------
target/ppc/helper.h | 4 ++--
target/ppc/translate/fp-impl.c.inc | 4 ++--
3 files changed, 17 insertions(+), 26 deletions(-)
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 0f045b70f8..32995179b5 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -830,30 +830,21 @@ static void float_invalid_op_sqrt(CPUPPCState *env, int
flags,
}
}
-/* fsqrt - fsqrt. */
-float64 helper_fsqrt(CPUPPCState *env, float64 arg)
-{
- float64 ret = float64_sqrt(arg, &env->fp_status);
- int flags = get_float_exception_flags(&env->fp_status);
-
- if (unlikely(flags & float_flag_invalid)) {
- float_invalid_op_sqrt(env, flags, 1, GETPC());
- }
-
- return ret;
+#define FPU_FSQRT(name, op) \
+float64 helper_##name(CPUPPCState *env, float64 arg) \
+{ \
+ float64 ret = op(arg, &env->fp_status); \
+ int flags = get_float_exception_flags(&env->fp_status); \
+ \
+ if (unlikely(flags & float_flag_invalid)) { \
+ float_invalid_op_sqrt(env, flags, 1, GETPC()); \
+ } \
+ \
+ return ret; \
}
-/* fsqrts - fsqrts. */
-float64 helper_fsqrts(CPUPPCState *env, float64 arg)
-{
- float64 ret = float64r32_sqrt(arg, &env->fp_status);
- int flags = get_float_exception_flags(&env->fp_status);
-
- if (unlikely(flags & float_flag_invalid)) {
- float_invalid_op_sqrt(env, flags, 1, GETPC());
- }
- return ret;
-}
+FPU_FSQRT(FSQRT, float64_sqrt)
+FPU_FSQRT(FSQRTS, float64r32_sqrt)
/* fre - fre. */
float64 helper_fre(CPUPPCState *env, float64 arg)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 122b2e9359..57eee07256 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -120,8 +120,8 @@ DEF_HELPER_4(fmadds, i64, env, i64, i64, i64)
DEF_HELPER_4(fmsubs, i64, env, i64, i64, i64)
DEF_HELPER_4(fnmadds, i64, env, i64, i64, i64)
DEF_HELPER_4(fnmsubs, i64, env, i64, i64, i64)
-DEF_HELPER_2(fsqrt, f64, env, f64)
-DEF_HELPER_2(fsqrts, f64, env, f64)
+DEF_HELPER_2(FSQRT, f64, env, f64)
+DEF_HELPER_2(FSQRTS, f64, env, f64)
DEF_HELPER_2(fre, i64, env, i64)
DEF_HELPER_2(fres, i64, env, i64)
DEF_HELPER_2(frsqrte, i64, env, i64)
diff --git a/target/ppc/translate/fp-impl.c.inc
b/target/ppc/translate/fp-impl.c.inc
index 7a90c0e350..8d5cf0f982 100644
--- a/target/ppc/translate/fp-impl.c.inc
+++ b/target/ppc/translate/fp-impl.c.inc
@@ -280,8 +280,8 @@ static bool do_helper_fsqrt(DisasContext *ctx, arg_A_tb *a,
return true;
}
-TRANS(FSQRT, do_helper_fsqrt, gen_helper_fsqrt);
-TRANS(FSQRTS, do_helper_fsqrt, gen_helper_fsqrts);
+TRANS(FSQRT, do_helper_fsqrt, gen_helper_FSQRT);
+TRANS(FSQRTS, do_helper_fsqrt, gen_helper_FSQRTS);
/*** Floating-Point multiply-and-add ***/
/* fmadd - fmadds */
--
2.37.3
- [PULL 04/17] target/ppc: Move fsqrt to decodetree, (continued)
- [PULL 04/17] target/ppc: Move fsqrt to decodetree, Daniel Henrique Barboza, 2022/09/20
- [PULL 03/17] target/ppc: Implement hashstp and hashchkp, Daniel Henrique Barboza, 2022/09/20
- [PULL 13/17] target/ppc: Zero second doubleword of VSR registers for FPR insns, Daniel Henrique Barboza, 2022/09/20
- [PULL 16/17] hw/pci-host: pnv_phb{3, 4}: Fix heap out-of-bound access failure, Daniel Henrique Barboza, 2022/09/20
- [PULL 05/17] target/ppc: Move fsqrts to decodetree, Daniel Henrique Barboza, 2022/09/20
- [PULL 07/17] target/ppc: Remove extra space from s128 field in ppc_vsr_t, Daniel Henrique Barboza, 2022/09/20
- [PULL 14/17] target/ppc: Clear fpstatus flags on helpers missing it, Daniel Henrique Barboza, 2022/09/20
- [PULL 08/17] target/ppc: Remove unused xer_* macros, Daniel Henrique Barboza, 2022/09/20
- [PULL 15/17] hw/ppc: spapr: Use qemu_vfree() to free spapr->htab, Daniel Henrique Barboza, 2022/09/20
- [PULL 12/17] target/ppc: Set OV32 when OV is set, Daniel Henrique Barboza, 2022/09/20
- [PULL 06/17] target/ppc: Merge fsqrt and fsqrts helpers,
Daniel Henrique Barboza <=
- [PULL 11/17] target/ppc: Zero second doubleword for VSX madd instructions, Daniel Henrique Barboza, 2022/09/20
- [PULL 09/17] target/ppc: Zero second doubleword in DFP instructions, Daniel Henrique Barboza, 2022/09/20
- [PULL 10/17] target/ppc: Set result to QNaN for DENBCD when VXCVI occurs, Daniel Henrique Barboza, 2022/09/20
- [PULL 17/17] hw/ppc/spapr: Fix code style problems reported by checkpatch, Daniel Henrique Barboza, 2022/09/20
- Re: [PULL 00/17] ppc queue, Stefan Hajnoczi, 2022/09/21