[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 03/21] target/tricore: Correctly handle FPU RM from PSW
From: |
Bastian Koppelmann |
Subject: |
[PULL v2 03/21] target/tricore: Correctly handle FPU RM from PSW |
Date: |
Thu, 28 Sep 2023 10:52:45 +0200 |
when we reconstructed PSW using psw_read(), we were trying to clear the
cached USB bits out of env->PSW. The mask was wrong and we would clear
PSW.RM as well.
when we write the PSW using psw_write() we update the rounding modes in
env->fp_status for softfloat. The order of bits used by TriCore is not
the one used by softfloat.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Message-ID: <20230828112651.522058-4-kbastian@mail.uni-paderborn.de>
---
target/tricore/helper.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/target/tricore/helper.c b/target/tricore/helper.c
index 6d076ac36f..e615c3d6d4 100644
--- a/target/tricore/helper.c
+++ b/target/tricore/helper.c
@@ -120,7 +120,21 @@ void tricore_cpu_list(void)
void fpu_set_state(CPUTriCoreState *env)
{
- set_float_rounding_mode(env->PSW & MASK_PSW_FPU_RM, &env->fp_status);
+ switch (extract32(env->PSW, 24, 2)) {
+ case 0:
+ set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
+ break;
+ case 1:
+ set_float_rounding_mode(float_round_up, &env->fp_status);
+ break;
+ case 2:
+ set_float_rounding_mode(float_round_down, &env->fp_status);
+ break;
+ case 3:
+ set_float_rounding_mode(float_round_to_zero, &env->fp_status);
+ break;
+ }
+
set_flush_inputs_to_zero(1, &env->fp_status);
set_flush_to_zero(1, &env->fp_status);
set_default_nan_mode(1, &env->fp_status);
@@ -129,7 +143,7 @@ void fpu_set_state(CPUTriCoreState *env)
uint32_t psw_read(CPUTriCoreState *env)
{
/* clear all USB bits */
- env->PSW &= 0x6ffffff;
+ env->PSW &= 0x7ffffff;
/* now set them from the cache */
env->PSW |= ((env->PSW_USB_C != 0) << 31);
env->PSW |= ((env->PSW_USB_V & (1 << 31)) >> 1);
--
2.42.0
- [PULL v2 00/21] tricore queue, Bastian Koppelmann, 2023/09/28
- [PULL v2 01/21] tests/tcg/tricore: Bump cpu to tc37x, Bastian Koppelmann, 2023/09/28
- [PULL v2 02/21] target/tricore: Implement CRCN insn, Bastian Koppelmann, 2023/09/28
- [PULL v2 03/21] target/tricore: Correctly handle FPU RM from PSW,
Bastian Koppelmann <=
- [PULL v2 04/21] target/tricore: Implement FTOU insn, Bastian Koppelmann, 2023/09/28
- [PULL v2 05/21] target/tricore: Clarify special case for FTOUZ insn, Bastian Koppelmann, 2023/09/28
- [PULL v2 06/21] target/tricore: Implement ftohp insn, Bastian Koppelmann, 2023/09/28
- [PULL v2 07/21] target/tricore: Implement hptof insn, Bastian Koppelmann, 2023/09/28
- [PULL v2 08/21] target/tricore: Fix RCPW/RRPW_INSERT insns for width = 0, Bastian Koppelmann, 2023/09/28
- [PULL v2 09/21] target/tricore: Swap src and dst reg for RCRR_INSERT, Bastian Koppelmann, 2023/09/28
- [PULL v2 10/21] target/tricore: Replace cpu_*_code with translator_*, Bastian Koppelmann, 2023/09/28
- [PULL v2 11/21] target/tricore: Fix FTOUZ being ISA v1.3.1 up, Bastian Koppelmann, 2023/09/28
- [PULL v2 12/21] tests/tcg/tricore: Extended and non-extened regs now match, Bastian Koppelmann, 2023/09/28
- [PULL v2 13/21] hw/tricore: Log failing test in testdevice, Bastian Koppelmann, 2023/09/28