[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 for-10.0 32/54] target/sparc: Initialize local scratch float_s
From: |
Peter Maydell |
Subject: |
[PATCH v2 for-10.0 32/54] target/sparc: Initialize local scratch float_status from env->fp_status |
Date: |
Mon, 2 Dec 2024 13:13:25 +0000 |
In the helper functions flcmps and flcmpd we use a scratch float_status
so that we don't change the CPU state if the comparison raises any
floating point exception flags. Instead of zero-initializing this
scratch float_status, initialize it as a copy of env->fp_status. This
avoids the need to explicitly initialize settings like the NaN
propagation rule or others we might add to softfloat in future.
To do this we need to pass the CPU env pointer in to the helper.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/sparc/helper.h | 4 ++--
target/sparc/fop_helper.c | 8 ++++----
target/sparc/translate.c | 4 ++--
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/target/sparc/helper.h b/target/sparc/helper.h
index 134e519a377..1ae3f0c467d 100644
--- a/target/sparc/helper.h
+++ b/target/sparc/helper.h
@@ -51,8 +51,8 @@ DEF_HELPER_FLAGS_3(fcmpd, TCG_CALL_NO_WG, i32, env, f64, f64)
DEF_HELPER_FLAGS_3(fcmped, TCG_CALL_NO_WG, i32, env, f64, f64)
DEF_HELPER_FLAGS_3(fcmpq, TCG_CALL_NO_WG, i32, env, i128, i128)
DEF_HELPER_FLAGS_3(fcmpeq, TCG_CALL_NO_WG, i32, env, i128, i128)
-DEF_HELPER_FLAGS_2(flcmps, TCG_CALL_NO_RWG_SE, i32, f32, f32)
-DEF_HELPER_FLAGS_2(flcmpd, TCG_CALL_NO_RWG_SE, i32, f64, f64)
+DEF_HELPER_FLAGS_3(flcmps, TCG_CALL_NO_RWG_SE, i32, env, f32, f32)
+DEF_HELPER_FLAGS_3(flcmpd, TCG_CALL_NO_RWG_SE, i32, env, f64, f64)
DEF_HELPER_2(raise_exception, noreturn, env, int)
DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64)
diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c
index 6f9ccc008a0..236d27b19c1 100644
--- a/target/sparc/fop_helper.c
+++ b/target/sparc/fop_helper.c
@@ -490,13 +490,13 @@ uint32_t helper_fcmpeq(CPUSPARCState *env, Int128 src1,
Int128 src2)
return finish_fcmp(env, r, GETPC());
}
-uint32_t helper_flcmps(float32 src1, float32 src2)
+uint32_t helper_flcmps(CPUSPARCState *env, float32 src1, float32 src2)
{
/*
* FLCMP never raises an exception nor modifies any FSR fields.
* Perform the comparison with a dummy fp environment.
*/
- float_status discard = { };
+ float_status discard = env->fp_status;
FloatRelation r;
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
@@ -518,9 +518,9 @@ uint32_t helper_flcmps(float32 src1, float32 src2)
g_assert_not_reached();
}
-uint32_t helper_flcmpd(float64 src1, float64 src2)
+uint32_t helper_flcmpd(CPUSPARCState *env, float64 src1, float64 src2)
{
- float_status discard = { };
+ float_status discard = env->fp_status;
FloatRelation r;
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index cdd0a95c03d..322319a1288 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -5584,7 +5584,7 @@ static bool trans_FLCMPs(DisasContext *dc, arg_FLCMPs *a)
src1 = gen_load_fpr_F(dc, a->rs1);
src2 = gen_load_fpr_F(dc, a->rs2);
- gen_helper_flcmps(cpu_fcc[a->cc], src1, src2);
+ gen_helper_flcmps(cpu_fcc[a->cc], tcg_env, src1, src2);
return advance_pc(dc);
}
@@ -5601,7 +5601,7 @@ static bool trans_FLCMPd(DisasContext *dc, arg_FLCMPd *a)
src1 = gen_load_fpr_D(dc, a->rs1);
src2 = gen_load_fpr_D(dc, a->rs2);
- gen_helper_flcmpd(cpu_fcc[a->cc], src1, src2);
+ gen_helper_flcmpd(cpu_fcc[a->cc], tcg_env, src1, src2);
return advance_pc(dc);
}
--
2.34.1
- [PATCH v2 for-10.0 06/54] target/s390: Set FloatInfZeroNaNRule explicitly, (continued)
- [PATCH v2 for-10.0 06/54] target/s390: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 20/54] target/s390x: Set Float3NaNPropRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 15/54] softfloat: Allow runtime choice of NaN propagation for muladd, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 10/54] target/xtensa: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 17/54] target/arm: Set Float3NaNPropRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 08/54] target/mips: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 23/54] target/xtensa: Set Float3NaNPropRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 35/54] tests/fp: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 29/54] target/loongarch: Use normal float_status in fclass_s and fclass_d helpers, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 44/54] target/openrisc: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 32/54] target/sparc: Initialize local scratch float_status from env->fp_status,
Peter Maydell <=
- [PATCH v2 for-10.0 46/54] target/sh4: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 40/54] target/arm: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 25/54] target/hppa: Set Float3NaNPropRule explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 26/54] fpu: Remove use_first_nan field from float_status, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 27/54] target/m68k: Don't pass NULL float_status to floatx80_default_nan(), Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 30/54] target/m68k: In frem helper, initialize local float_status from env->fp_status, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 50/54] target/xtensa: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 45/54] target/ppc: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 37/54] target/i386: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 47/54] target/rx: Set default NaN pattern explicitly, Peter Maydell, 2024/12/02