[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/59] linux-user/arm: Simplify accumulating and raising fpa11 exc
From: |
Laurent Vivier |
Subject: |
[PULL 06/59] linux-user/arm: Simplify accumulating and raising fpa11 exceptions |
Date: |
Tue, 18 May 2021 07:30:38 +0200 |
From: Richard Henderson <richard.henderson@linaro.org>
Use bit masking instead of an if tree.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20210423165413.338259-5-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/arm/cpu_loop.c | 50 ++++++++++++++-------------------------
1 file changed, 18 insertions(+), 32 deletions(-)
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
index 5f61d25717c3..69632d15be18 100644
--- a/linux-user/arm/cpu_loop.c
+++ b/linux-user/arm/cpu_loop.c
@@ -228,6 +228,7 @@ static bool emulate_arm_fpa11(CPUARMState *env, uint32_t
opcode)
{
TaskState *ts = env_cpu(env)->opaque;
int rc = EmulateAll(opcode, &ts->fpa, env);
+ int raise, enabled;
if (rc == 0) {
/* Illegal instruction */
@@ -240,28 +241,31 @@ static bool emulate_arm_fpa11(CPUARMState *env, uint32_t
opcode)
}
/* FP exception */
- int arm_fpe = 0;
+ rc = -rc;
+ raise = 0;
/* Translate softfloat flags to FPSR flags */
- if (-rc & float_flag_invalid) {
- arm_fpe |= BIT_IOC;
+ if (rc & float_flag_invalid) {
+ raise |= BIT_IOC;
}
- if (-rc & float_flag_divbyzero) {
- arm_fpe |= BIT_DZC;
+ if (rc & float_flag_divbyzero) {
+ raise |= BIT_DZC;
}
- if (-rc & float_flag_overflow) {
- arm_fpe |= BIT_OFC;
+ if (rc & float_flag_overflow) {
+ raise |= BIT_OFC;
}
- if (-rc & float_flag_underflow) {
- arm_fpe |= BIT_UFC;
+ if (rc & float_flag_underflow) {
+ raise |= BIT_UFC;
}
- if (-rc & float_flag_inexact) {
- arm_fpe |= BIT_IXC;
+ if (rc & float_flag_inexact) {
+ raise |= BIT_IXC;
}
- /* Exception enabled? */
- FPSR fpsr = ts->fpa.fpsr;
- if (fpsr & (arm_fpe << 16)) {
+ /* Accumulate unenabled exceptions */
+ enabled = ts->fpa.fpsr >> 16;
+ ts->fpa.fpsr |= raise & ~enabled;
+
+ if (raise & enabled) {
target_siginfo_t info = { };
/*
@@ -275,24 +279,6 @@ static bool emulate_arm_fpa11(CPUARMState *env, uint32_t
opcode)
} else {
env->regs[15] += 4;
}
-
- /* Accumulate unenabled exceptions */
- if ((!(fpsr & BIT_IXE)) && (arm_fpe & BIT_IXC)) {
- fpsr |= BIT_IXC;
- }
- if ((!(fpsr & BIT_UFE)) && (arm_fpe & BIT_UFC)) {
- fpsr |= BIT_UFC;
- }
- if ((!(fpsr & BIT_OFE)) && (arm_fpe & BIT_OFC)) {
- fpsr |= BIT_OFC;
- }
- if ((!(fpsr & BIT_DZE)) && (arm_fpe & BIT_DZC)) {
- fpsr |= BIT_DZC;
- }
- if ((!(fpsr & BIT_IOE)) && (arm_fpe & BIT_IOC)) {
- fpsr |= BIT_IOC;
- }
- ts->fpa.fpsr = fpsr;
return true;
}
--
2.31.1
- [PULL 38/59] linux-user/s390x: Fix sigcontext sregs value, (continued)
- [PULL 38/59] linux-user/s390x: Fix sigcontext sregs value, Laurent Vivier, 2021/05/17
- Re: [PULL 00/59] Linux user for 6.1 patches, no-reply, 2021/05/17
- [PULL 00/59] Linux user for 6.1 patches, Laurent Vivier, 2021/05/18
- [PULL 05/59] linux-user/arm: Do not fill in si_code for fpa11 exceptions, Laurent Vivier, 2021/05/18
- [PULL 07/59] linux-user: Add strace support for printing arguments of llseek, Laurent Vivier, 2021/05/18
- [PULL 04/59] linux-user/arm: Do not emulate fpa11 in thumb mode, Laurent Vivier, 2021/05/18
- [PULL 03/59] linux-user/arm: Split out emulate_arm_fpa11, Laurent Vivier, 2021/05/18
- [PULL 02/59] linux-user: strace now handles unshare syscall args correctly, Laurent Vivier, 2021/05/18
- [PULL 09/59] linux-user: Use target_restore_altstack in all sigreturn, Laurent Vivier, 2021/05/18
- [PULL 06/59] linux-user/arm: Simplify accumulating and raising fpa11 exceptions,
Laurent Vivier <=
- [PULL 10/59] linux-user: Pass CPUArchState to do_sigaltstack, Laurent Vivier, 2021/05/18
- [PULL 11/59] linux-user: Pass CPUArchState to target_restore_altstack, Laurent Vivier, 2021/05/18
- [PULL 15/59] linux-user/sparc: Merge sparc64 target_elf.h, Laurent Vivier, 2021/05/18
- [PULL 12/59] linux-user/sparc: Include TARGET_STACK_BIAS in get_sp_from_cpustate, Laurent Vivier, 2021/05/18
- [PULL 17/59] linux-user/sparc: Merge sparc64 termbits.h, Laurent Vivier, 2021/05/18
- [PULL 01/59] linux-user: Remove dead code, Laurent Vivier, 2021/05/18
- [PULL 13/59] linux-user/sparc: Clean up init_thread, Laurent Vivier, 2021/05/18
- [PULL 16/59] linux-user/sparc: Merge sparc64 target_structs.h, Laurent Vivier, 2021/05/18
- [PULL 08/59] linux-user: Split out target_restore_altstack, Laurent Vivier, 2021/05/18
- [PULL 14/59] linux-user/sparc: Merge sparc64 target_syscall.h, Laurent Vivier, 2021/05/18