summaryrefslogtreecommitdiffstats
path: root/target-s390x/cc_helper.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2012-08-21 13:13:09 -0700
committerRichard Henderson <rth@twiddle.net>2013-01-05 12:18:38 -0800
commit58a9e35bcc23d44142a2a58ddf3fae51749f3f01 (patch)
treeff22a2046b2ed83ad8a4f6422fc09d36b0c1272b /target-s390x/cc_helper.c
parent443aaeb8991022f3eadd2b65e14e805093e2a0e6 (diff)
downloadhqemu-58a9e35bcc23d44142a2a58ddf3fae51749f3f01.zip
hqemu-58a9e35bcc23d44142a2a58ddf3fae51749f3f01.tar.gz
target-s390: Convert INSERT CHARACTERS UNDER MASK
Change the CC handling to be more like TEST UNDER MASK, with val & mask. This lets us handle ICMH much more like ICM. Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target-s390x/cc_helper.c')
-rw-r--r--target-s390x/cc_helper.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/target-s390x/cc_helper.c b/target-s390x/cc_helper.c
index 3d89fb9..575f7c3 100644
--- a/target-s390x/cc_helper.c
+++ b/target-s390x/cc_helper.c
@@ -331,35 +331,18 @@ static uint32_t cc_calc_comp_32(int32_t dst)
}
/* calculate condition code for insert character under mask insn */
-static uint32_t cc_calc_icm_32(uint32_t mask, uint32_t val)
+static uint32_t cc_calc_icm(uint64_t mask, uint64_t val)
{
- uint32_t cc;
-
- HELPER_LOG("%s: mask 0x%x val %d\n", __func__, mask, val);
- if (mask == 0xf) {
- if (!val) {
- return 0;
- } else if (val & 0x80000000) {
+ if ((val & mask) == 0) {
+ return 0;
+ } else {
+ int top = clz64(mask);
+ if ((int64_t)(val << top) < 0) {
return 1;
} else {
return 2;
}
}
-
- if (!val || !mask) {
- cc = 0;
- } else {
- while (mask != 1) {
- mask >>= 1;
- val >>= 8;
- }
- if (val & 0x80) {
- cc = 1;
- } else {
- cc = 2;
- }
- }
- return cc;
}
static uint32_t cc_calc_slag(uint64_t src, uint64_t shift)
@@ -488,7 +471,7 @@ static uint32_t do_calc_cc(CPUS390XState *env, uint32_t cc_op,
break;
case CC_OP_ICM:
- r = cc_calc_icm_32(src, dst);
+ r = cc_calc_icm(src, dst);
break;
case CC_OP_SLAG:
r = cc_calc_slag(src, dst);
OpenPOWER on IntegriCloud