[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PULL 15/27] s390x/tcg: Factor out conversion of softfloat
From: |
Cornelia Huck |
Subject: |
[qemu-s390x] [PULL 15/27] s390x/tcg: Factor out conversion of softfloat exceptions |
Date: |
Mon, 4 Mar 2019 13:01:58 +0100 |
From: David Hildenbrand <address@hidden>
We want to reuse that function in vector instruction context. While at it,
cleanup the code, using defines for magic values and avoiding the
handcrafted bit conversion.
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
target/s390x/fpu_helper.c | 25 +++++++++++++------------
target/s390x/internal.h | 7 +++++++
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c
index 21236caed869..de02cf792d87 100644
--- a/target/s390x/fpu_helper.c
+++ b/target/s390x/fpu_helper.c
@@ -36,10 +36,18 @@
#define RET128(F) (env->retxl = F.low, F.high)
-#define convert_bit(mask, from, to) \
- (to < from \
- ? (mask / (from / to)) & to \
- : (mask & from) * (to / from))
+uint8_t s390_softfloat_exc_to_ieee(unsigned int exc)
+{
+ uint8_t s390_exc = 0;
+
+ s390_exc |= (exc & float_flag_invalid) ? S390_IEEE_MASK_INVALID : 0;
+ s390_exc |= (exc & float_flag_divbyzero) ? S390_IEEE_MASK_DIVBYZERO : 0;
+ s390_exc |= (exc & float_flag_overflow) ? S390_IEEE_MASK_OVERFLOW : 0;
+ s390_exc |= (exc & float_flag_underflow) ? S390_IEEE_MASK_UNDERFLOW : 0;
+ s390_exc |= (exc & float_flag_inexact) ? S390_IEEE_MASK_INEXACT : 0;
+
+ return s390_exc;
+}
/* Should be called after any operation that may raise IEEE exceptions. */
static void handle_exceptions(CPUS390XState *env, uintptr_t retaddr)
@@ -53,14 +61,7 @@ static void handle_exceptions(CPUS390XState *env, uintptr_t
retaddr)
return;
}
env->fpu_status.float_exception_flags = 0;
-
- /* Convert softfloat exception bits to s390 exception bits. */
- s390_exc = 0;
- s390_exc |= convert_bit(qemu_exc, float_flag_invalid, 0x80);
- s390_exc |= convert_bit(qemu_exc, float_flag_divbyzero, 0x40);
- s390_exc |= convert_bit(qemu_exc, float_flag_overflow, 0x20);
- s390_exc |= convert_bit(qemu_exc, float_flag_underflow, 0x10);
- s390_exc |= convert_bit(qemu_exc, float_flag_inexact, 0x08);
+ s390_exc = s390_softfloat_exc_to_ieee(qemu_exc);
/* Install the exceptions that we raised. */
env->fpc |= s390_exc << 16;
diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index 9d0a45d1fef7..4db736b6acfd 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -311,6 +311,13 @@ void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr
addr,
uint32_t set_cc_nz_f32(float32 v);
uint32_t set_cc_nz_f64(float64 v);
uint32_t set_cc_nz_f128(float128 v);
+#define S390_IEEE_MASK_INVALID 0x80
+#define S390_IEEE_MASK_DIVBYZERO 0x40
+#define S390_IEEE_MASK_OVERFLOW 0x20
+#define S390_IEEE_MASK_UNDERFLOW 0x10
+#define S390_IEEE_MASK_INEXACT 0x08
+#define S390_IEEE_MASK_QUANTUM 0x04
+uint8_t s390_softfloat_exc_to_ieee(unsigned int exc);
/* gdbstub.c */
--
2.17.2
- [qemu-s390x] [PULL 04/27] s390x/vfio-ap: Implement hot plug/unplug of vfio-ap device, (continued)
- [qemu-s390x] [PULL 04/27] s390x/vfio-ap: Implement hot plug/unplug of vfio-ap device, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 08/27] s390x/tcg: Clarify terminology in vec_reg_offset(), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 06/27] s390x/tcg: RXE has an optional M3 field, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 07/27] s390x/tcg: Simplify disassembler operands initialization, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 10/27] s390x/tcg: Factor out gen_addi_and_wrap_i64() from get_address(), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 09/27] s390x/tcg: Factor out vec_full_reg_offset(), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 11/27] s390x/tcg: Implement LOAD LENGTHENED short HFP to long HFP, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 12/27] s390x/tcg: Implement LOAD COUNT TO BLOCK BOUNDARY, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 13/27] s390x/tcg: Fix TEST DATA CLASS instructions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 14/27] s390x/tcg: Fix rounding from float128 to uint64_t/uint32_t, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 15/27] s390x/tcg: Factor out conversion of softfloat exceptions,
Cornelia Huck <=
- [qemu-s390x] [PULL 17/27] s390x/tcg: Hide IEEE underflows in some scenarios, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 16/27] s390x/tcg: Fix parts of IEEE exception handling, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 18/27] s390x/tcg: Refactor SET FPC AND SIGNAL handling, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 19/27] s390x/tcg: Fix simulated-IEEE exceptions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 20/27] s390x/tcg: Handle SET FPC AND LOAD FPC 3-bit BFP rounding modes, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 21/27] s390x/tcg: Check for exceptions in SET BFP ROUNDING MODE, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 23/27] s390x/tcg: Prepare for IEEE-inexact-exception control (XxC), Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 22/27] s390x/tcg: Refactor saving/restoring the bfp rounding mode, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 26/27] s390x/tcg: Handle all rounding modes overwritten by BFP instructions, Cornelia Huck, 2019/03/04
- [qemu-s390x] [PULL 24/27] s390x/tcg: Implement XxC and checks for most FP instructions, Cornelia Huck, 2019/03/04