aboutsummaryrefslogtreecommitdiff
path: root/target/s390x/fpu_helper.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2019-02-18 13:26:58 +0100
committerCornelia Huck <cohuck@redhat.com>2019-03-04 11:49:31 +0100
commit4b70fc54975b3b09eeec30be33419bd03456fe45 (patch)
tree0c2dd361fd72d4ae7c7b3957f010d7c5f3ba5a25 /target/s390x/fpu_helper.c
parent3af471f9152b8e84534f8b0ff303b5f0a5ced819 (diff)
downloadqemu-4b70fc54975b3b09eeec30be33419bd03456fe45.zip
qemu-4b70fc54975b3b09eeec30be33419bd03456fe45.tar.gz
qemu-4b70fc54975b3b09eeec30be33419bd03456fe45.tar.bz2
s390x/tcg: Factor out conversion of softfloat exceptions
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 <richard.henderson@linaro.org> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20190218122710.23639-4-david@redhat.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'target/s390x/fpu_helper.c')
-rw-r--r--target/s390x/fpu_helper.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c
index 21236ca..de02cf7 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;