[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 047/102] target/ppc: Add helpers for fmadds et al
From: |
Cédric Le Goater |
Subject: |
[PULL 047/102] target/ppc: Add helpers for fmadds et al |
Date: |
Wed, 15 Dec 2021 18:03:02 +0100 |
From: Richard Henderson <richard.henderson@linaro.org>
Use float64r32_muladd. Fixes a double-rounding issue with performing
the compuation in float64 and then rounding afterward.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20211119160502.17432-29-richard.henderson@linaro.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
target/ppc/helper.h | 4 ++++
target/ppc/fpu_helper.c | 17 ++++++++++++++++-
target/ppc/translate/fp-impl.c.inc | 13 +++++--------
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index 632a81c6766f..8a9f2ee7ed4f 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -101,6 +101,10 @@ DEF_HELPER_4(fmadd, i64, env, i64, i64, i64)
DEF_HELPER_4(fmsub, i64, env, i64, i64, i64)
DEF_HELPER_4(fnmadd, i64, env, i64, i64, i64)
DEF_HELPER_4(fnmsub, i64, env, i64, i64, i64)
+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(fre, i64, env, i64)
DEF_HELPER_2(fres, i64, env, i64)
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index aef81a818f63..12dd889fb5f8 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -705,10 +705,25 @@ static float64 do_fmadd(CPUPPCState *env, float64 a,
float64 b,
return ret;
}
+static uint64_t do_fmadds(CPUPPCState *env, float64 a, float64 b,
+ float64 c, int madd_flags, uintptr_t retaddr)
+{
+ float64 ret = float64r32_muladd(a, b, c, madd_flags, &env->fp_status);
+ int flags = get_float_exception_flags(&env->fp_status);
+
+ if (unlikely(flags & float_flag_invalid)) {
+ float_invalid_op_madd(env, flags, 1, retaddr);
+ }
+ return ret;
+}
+
#define FPU_FMADD(op, madd_flags) \
uint64_t helper_##op(CPUPPCState *env, uint64_t arg1, \
uint64_t arg2, uint64_t arg3) \
- { return do_fmadd(env, arg1, arg2, arg3, madd_flags, GETPC()); }
+ { return do_fmadd(env, arg1, arg2, arg3, madd_flags, GETPC()); } \
+ uint64_t helper_##op##s(CPUPPCState *env, uint64_t arg1, \
+ uint64_t arg2, uint64_t arg3) \
+ { return do_fmadds(env, arg1, arg2, arg3, madd_flags, GETPC()); }
#define MADD_FLGS 0
#define MSUB_FLGS float_muladd_negate_c
diff --git a/target/ppc/translate/fp-impl.c.inc
b/target/ppc/translate/fp-impl.c.inc
index 0767e45d87d8..2e3162d3e7c0 100644
--- a/target/ppc/translate/fp-impl.c.inc
+++ b/target/ppc/translate/fp-impl.c.inc
@@ -31,7 +31,7 @@ static void gen_set_cr1_from_fpscr(DisasContext *ctx)
#endif
/*** Floating-Point arithmetic ***/
-#define _GEN_FLOAT_ACB(name, op, op1, op2, isfloat, set_fprf, type) \
+#define _GEN_FLOAT_ACB(name, op1, op2, set_fprf, type) \
static void gen_f##name(DisasContext *ctx) \
{ \
TCGv_i64 t0; \
@@ -50,10 +50,7 @@ static void gen_f##name(DisasContext *ctx)
\
get_fpr(t0, rA(ctx->opcode)); \
get_fpr(t1, rC(ctx->opcode)); \
get_fpr(t2, rB(ctx->opcode)); \
- gen_helper_f##op(t3, cpu_env, t0, t1, t2); \
- if (isfloat) { \
- gen_helper_frsp(t3, cpu_env, t3); \
- } \
+ gen_helper_f##name(t3, cpu_env, t0, t1, t2); \
set_fpr(rD(ctx->opcode), t3); \
if (set_fprf) { \
gen_compute_fprf_float64(t3); \
@@ -68,8 +65,8 @@ static void gen_f##name(DisasContext *ctx)
\
}
#define GEN_FLOAT_ACB(name, op2, set_fprf, type) \
-_GEN_FLOAT_ACB(name, name, 0x3F, op2, 0, set_fprf, type); \
-_GEN_FLOAT_ACB(name##s, name, 0x3B, op2, 1, set_fprf, type);
+_GEN_FLOAT_ACB(name, 0x3F, op2, set_fprf, type); \
+_GEN_FLOAT_ACB(name##s, 0x3B, op2, set_fprf, type);
#define _GEN_FLOAT_AB(name, op, op1, op2, inval, isfloat, set_fprf, type) \
static void gen_f##name(DisasContext *ctx) \
@@ -233,7 +230,7 @@ static void gen_frsqrtes(DisasContext *ctx)
}
/* fsel */
-_GEN_FLOAT_ACB(sel, sel, 0x3F, 0x17, 0, 0, PPC_FLOAT_FSEL);
+_GEN_FLOAT_ACB(sel, 0x3F, 0x17, 0, PPC_FLOAT_FSEL);
/* fsub - fsubs */
GEN_FLOAT_AB(sub, 0x14, 0x000007C0, 1, PPC_FLOAT);
/* Optional: */
--
2.31.1
- [PULL 041/102] target/ppc: Update do_frsp for new flags, (continued)
- [PULL 041/102] target/ppc: Update do_frsp for new flags, Cédric Le Goater, 2021/12/15
- [PULL 029/102] target/ppc: Update float_invalid_op_div for new flags, Cédric Le Goater, 2021/12/15
- [PULL 039/102] target/ppc: Do not call do_float_check_status from do_fmadd, Cédric Le Goater, 2021/12/15
- [PULL 032/102] target/ppc: Fix VXCVI return value, Cédric Le Goater, 2021/12/15
- [PULL 030/102] target/ppc: Move float_check_status from FPU_FCTI to translate, Cédric Le Goater, 2021/12/15
- [PULL 040/102] target/ppc: Split out do_frsp, Cédric Le Goater, 2021/12/15
- [PULL 036/102] target/ppc: Clean up do_fri, Cédric Le Goater, 2021/12/15
- [PULL 038/102] target/ppc: Split out do_fmadd, Cédric Le Goater, 2021/12/15
- [PULL 050/102] target/ppc: Add helper for fmuls, Cédric Le Goater, 2021/12/15
- [PULL 048/102] target/ppc: Add helper for fsqrts, Cédric Le Goater, 2021/12/15
- [PULL 047/102] target/ppc: Add helpers for fmadds et al,
Cédric Le Goater <=
- [PULL 033/102] target/ppc: Remove inline from do_fri, Cédric Le Goater, 2021/12/15
- [PULL 053/102] target/ppc: Use helper_todouble/tosingle in helper_xststdcsp, Cédric Le Goater, 2021/12/15
- [PULL 052/102] target/ppc: Update fres to new flags and float64r32, Cédric Le Goater, 2021/12/15
- [PULL 051/102] target/ppc: Add helper for frsqrtes, Cédric Le Goater, 2021/12/15
- [PULL 042/102] target/ppc: Use helper_todouble in do_frsp, Cédric Le Goater, 2021/12/15
- [PULL 049/102] target/ppc: Add helpers for fadds, fsubs, fdivs, Cédric Le Goater, 2021/12/15
- [PULL 054/102] target/ppc: Disable software TLB for the 7450 family, Cédric Le Goater, 2021/12/15
- [PULL 060/102] target/ppc: remove 401/403 CPUs, Cédric Le Goater, 2021/12/15
- [PULL 055/102] target/ppc: Disable unused facilities in the e600 CPU, Cédric Le Goater, 2021/12/15
- [PULL 046/102] softfloat: Add float64r32 arithmetic routines, Cédric Le Goater, 2021/12/15