cmpbge emulation improvements

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJV500WAAoJEK0ScMxN0CebePEH/RkxQTmYv61ji2MDY0ouswQR
 jlGJeKoZlyZxmyWMqerXK892SI13HpQpH3lVoJMsSrFnUIG79VFN+I22+MfkNI6S
 XbRWPCk+AxoXat2O8zSX1f40GJE3go1ZDT8h4/OQ3fveFi+q95ngPFHXSuDg17GP
 hU5LYHdpzlDm0wqKnz5+57RW5XjRvO285Zo+ludewnZWzFK8Dp9YNgH2Of8hj1Z0
 a6NNZ9T8/U09VbtC5NKDEeZajl+2aFjjNC5A4qUUliW1kWy/2mfRnSnN3oFQXWr3
 vn6wemKClWeyX6ch4yQzCOKGBq52RSjn+VsKYVrmesfBP1sclggJ1uvJXzfYqNI=
 =iazd
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/rth/tags/pull-axp-20150902' into staging

cmpbge emulation improvements

# gpg: Signature made Wed 02 Sep 2015 20:25:10 BST using RSA key ID 4DD0279B
# gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
# gpg:                 aka "Richard Henderson <rth@redhat.com>"
# gpg:                 aka "Richard Henderson <rth@twiddle.net>"

* remotes/rth/tags/pull-axp-20150902:
  target-alpha: Special case cmpbge with zero
  target-alpha: Rewrite helper_cmpbge using bit tests

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-09-03 12:09:41 +01:00
commit fc8135a46d
3 changed files with 46 additions and 13 deletions

View File

@ -10,6 +10,7 @@ DEF_HELPER_FLAGS_1(cttz, TCG_CALL_NO_RWG_SE, i64, i64)
DEF_HELPER_FLAGS_2(zap, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(zap, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(zapnot, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(zapnot, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_1(cmpbe0, TCG_CALL_NO_RWG_SE, i64, i64)
DEF_HELPER_FLAGS_2(cmpbge, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(cmpbge, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(minub8, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(minub8, TCG_CALL_NO_RWG_SE, i64, i64, i64)

View File

@ -58,20 +58,47 @@ uint64_t helper_zap(uint64_t val, uint64_t mask)
return helper_zapnot(val, ~mask); return helper_zapnot(val, ~mask);
} }
uint64_t helper_cmpbge(uint64_t op1, uint64_t op2) uint64_t helper_cmpbe0(uint64_t a)
{ {
uint8_t opa, opb, res; uint64_t m = 0x7f7f7f7f7f7f7f7fULL;
int i; uint64_t c = ~(((a & m) + m) | a | m);
/* a.......b.......c.......d.......e.......f.......g.......h....... */
c |= c << 7;
/* ab......bc......cd......de......ef......fg......gh......h....... */
c |= c << 14;
/* abcd....bcde....cdef....defg....efgh....fgh.....gh......h....... */
c |= c << 28;
/* abcdefghbcdefgh.cdefgh..defgh...efgh....fgh.....gh......h....... */
return c >> 56;
}
res = 0; uint64_t helper_cmpbge(uint64_t a, uint64_t b)
for (i = 0; i < 8; i++) { {
opa = op1 >> (i * 8); uint64_t mask = 0x00ff00ff00ff00ffULL;
opb = op2 >> (i * 8); uint64_t test = 0x0100010001000100ULL;
if (opa >= opb) { uint64_t al, ah, bl, bh, cl, ch;
res |= 1 << i;
} /* Separate the bytes to avoid false positives. */
} al = a & mask;
return res; bl = b & mask;
ah = (a >> 8) & mask;
bh = (b >> 8) & mask;
/* "Compare". If a byte in B is greater than a byte in A,
it will clear the test bit. */
cl = ((al | test) - bl) & test;
ch = ((ah | test) - bh) & test;
/* Fold all of the test bits into a contiguous set. */
/* ch=.......a...............c...............e...............g........ */
/* cl=.......b...............d...............f...............h........ */
cl += ch << 1;
/* cl=......ab..............cd..............ef..............gh........ */
cl |= cl << 14;
/* cl=......abcd............cdef............efgh............gh........ */
cl |= cl << 28;
/* cl=......abcdefgh........cdefgh..........efgh............gh........ */
return cl >> 50;
} }
uint64_t helper_minub8(uint64_t op1, uint64_t op2) uint64_t helper_minub8(uint64_t op1, uint64_t op2)

View File

@ -1562,7 +1562,12 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)
break; break;
case 0x0F: case 0x0F:
/* CMPBGE */ /* CMPBGE */
gen_helper_cmpbge(vc, va, vb); if (ra == 31) {
/* Special case 0 >= X as X == 0. */
gen_helper_cmpbe0(vc, vb);
} else {
gen_helper_cmpbge(vc, va, vb);
}
break; break;
case 0x12: case 0x12:
/* S8ADDL */ /* S8ADDL */