[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 for-10.0 29/54] target/loongarch: Use normal float_status in f
From: |
Peter Maydell |
Subject: |
[PATCH v2 for-10.0 29/54] target/loongarch: Use normal float_status in fclass_s and fclass_d helpers |
Date: |
Mon, 2 Dec 2024 13:13:22 +0000 |
In target/loongarch's helper_fclass_s() and helper_fclass_d() we pass
a zero-initialized float_status struct to float32_is_quiet_nan() and
float64_is_quiet_nan(), with the cryptic comment "for
snan_bit_is_one".
This pattern appears to have been copied from target/riscv, where it
is used because the functions there do not have ready access to the
CPU state struct. The comment presumably refers to the fact that the
main reason the is_quiet_nan() functions want the float_state is
because they want to know about the snan_bit_is_one config.
In the loongarch helpers, though, we have the CPU state struct
to hand. Use the usual env->fp_status here. This avoids our needing
to track that we need to update the initializer of the local
float_status structs when the core softfloat code adds new
options for targets to configure their behaviour.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
It would be nice to get the riscv fclass_s etc also not to use a
stunt float_status, but plumbing the env through would require
fiddling with the macro magic, and in practice for the is_quiet_nan
functions it works out OK.
---
target/loongarch/tcg/fpu_helper.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/target/loongarch/tcg/fpu_helper.c
b/target/loongarch/tcg/fpu_helper.c
index 37a48599366..aea5e0fe5e6 100644
--- a/target/loongarch/tcg/fpu_helper.c
+++ b/target/loongarch/tcg/fpu_helper.c
@@ -359,8 +359,7 @@ uint64_t helper_fclass_s(CPULoongArchState *env, uint64_t
fj)
} else if (float32_is_zero_or_denormal(f)) {
return sign ? 1 << 4 : 1 << 8;
} else if (float32_is_any_nan(f)) {
- float_status s = { }; /* for snan_bit_is_one */
- return float32_is_quiet_nan(f, &s) ? 1 << 1 : 1 << 0;
+ return float32_is_quiet_nan(f, &env->fp_status) ? 1 << 1 : 1 << 0;
} else {
return sign ? 1 << 3 : 1 << 7;
}
@@ -378,8 +377,7 @@ uint64_t helper_fclass_d(CPULoongArchState *env, uint64_t
fj)
} else if (float64_is_zero_or_denormal(f)) {
return sign ? 1 << 4 : 1 << 8;
} else if (float64_is_any_nan(f)) {
- float_status s = { }; /* for snan_bit_is_one */
- return float64_is_quiet_nan(f, &s) ? 1 << 1 : 1 << 0;
+ return float64_is_quiet_nan(f, &env->fp_status) ? 1 << 1 : 1 << 0;
} else {
return sign ? 1 << 3 : 1 << 7;
}
--
2.34.1
- [PATCH v2 for-10.0 14/54] softfloat: Pass have_snan to pickNaNMulAdd, (continued)
- [PATCH v2 for-10.0 14/54] softfloat: Pass have_snan to pickNaNMulAdd, Peter Maydell, 2024/12/02
- [PATCH v2 for-10.0 09/54] target/sparc: Set FloatInfZeroNaNRule explicitly, Peter Maydell, 2024/12/02
- [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 <=
- [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, 2024/12/02
- [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