aboutsummaryrefslogtreecommitdiff
path: root/target-s390x/cc_helper.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2012-08-20 16:20:58 -0700
committerRichard Henderson <rth@twiddle.net>2013-01-05 12:18:37 -0800
commit00d2dc192fb866d077935f0dd298472d65d87eb6 (patch)
tree34f79bdd716b8fe1bb51acc6348acb3e10d3456b /target-s390x/cc_helper.c
parentb4e2bd3563af75ba5b9fe809c8cf79d2d34aecf3 (diff)
downloadqemu-00d2dc192fb866d077935f0dd298472d65d87eb6.zip
qemu-00d2dc192fb866d077935f0dd298472d65d87eb6.tar.gz
qemu-00d2dc192fb866d077935f0dd298472d65d87eb6.tar.bz2
target-s390: Convert TEST UNDER MASK
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target-s390x/cc_helper.c')
-rw-r--r--target-s390x/cc_helper.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c
index 880e3b2..d20342c 100644
--- a/target-s390x/cc_helper.c
+++ b/target-s390x/cc_helper.c
@@ -20,6 +20,7 @@
#include "cpu.h"
#include "helper.h"
+#include "qemu/host-utils.h"
/* #define DEBUG_HELPER */
#ifdef DEBUG_HELPER
@@ -86,13 +87,11 @@ static inline uint32_t cc_calc_ltugtu_64(CPUS390XState *env, uint64_t src,
}
}
-static inline uint32_t cc_calc_tm_32(CPUS390XState *env, uint32_t val,
- uint32_t mask)
+static uint32_t cc_calc_tm_32(CPUS390XState *env, uint32_t val, uint32_t mask)
{
- uint16_t r = val & mask;
+ uint32_t r = val & mask;
- HELPER_LOG("%s: val 0x%x mask 0x%x\n", __func__, val, mask);
- if (r == 0 || mask == 0) {
+ if (r == 0) {
return 0;
} else if (r == mask) {
return 3;
@@ -101,23 +100,17 @@ static inline uint32_t cc_calc_tm_32(CPUS390XState *env, uint32_t val,
}
}
-/* set condition code for test under mask */
-static inline uint32_t cc_calc_tm_64(CPUS390XState *env, uint64_t val,
- uint32_t mask)
+static uint32_t cc_calc_tm_64(CPUS390XState *env, uint64_t val, uint64_t mask)
{
- uint16_t r = val & mask;
+ uint64_t r = val & mask;
- HELPER_LOG("%s: val 0x%lx mask 0x%x r 0x%x\n", __func__, val, mask, r);
- if (r == 0 || mask == 0) {
+ if (r == 0) {
return 0;
} else if (r == mask) {
return 3;
} else {
- while (!(mask & 0x8000)) {
- mask <<= 1;
- val <<= 1;
- }
- if (val & 0x8000) {
+ int top = clz64(mask);
+ if ((int64_t)(val << top) < 0) {
return 2;
} else {
return 1;