[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] ppc64: fix comparisons on ppc64
From: |
Kimplul |
Subject: |
[PATCH 2/3] ppc64: fix comparisons on ppc64 |
Date: |
Sun, 28 Aug 2022 22:30:57 +0300 |
Signed-off-by: Kimplul <kimi.h.kuparinen@gmail.com>
---
lib/jit_ppc-cpu.c | 144 +++++++++++++++++++++++++---------------------
1 file changed, 78 insertions(+), 66 deletions(-)
diff --git a/lib/jit_ppc-cpu.c b/lib/jit_ppc-cpu.c
index 60de8cf..51a57fb 100644
--- a/lib/jit_ppc-cpu.c
+++ b/lib/jit_ppc-cpu.c
@@ -876,6 +876,18 @@ static void _vaarg_d(jit_state_t*, jit_int32_t,
jit_int32_t);
static void _patch_at(jit_state_t*,jit_word_t,jit_word_t);
#endif
+#if __WORDSIZE == 64
+#define CMP(r0, r1) CMPD(r0, r1)
+#define CMPL(r0, r1) CMPLD(r0, r1)
+#define CMPI(r0, i0) CMPDI(r0, i0)
+#define CMPLI(r0, i0) CMPLDI(r0, i0)
+#else
+#define CMP(r0, r1) CMPW(r0, r1)
+#define CMPL(r0, r1) CMPLW(r0, r1)
+#define CMPI(r0, i0) CMPWI(r0, i0)
+#define CMPLI(r0, i0) CMPLWI(r0, i0)
+#endif
+
#if CODE
# define _u16(v) ((v) & 0xffff)
# define _u26(v) ((v) & 0x3ffffff)
@@ -1118,7 +1130,7 @@ _movi(jit_state_t *_jit, jit_int32_t r0, jit_word_t i0)
static void
_movnr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPWI(r2, 0);
+ CMPI(r2, 0);
BEQ(8);
MR(r0, r1);
}
@@ -1126,7 +1138,7 @@ _movnr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_int32_t r2)
static void
_movzr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPWI(r2, 0);
+ CMPI(r2, 0);
BNE(8);
MR(r0, r1);
}
@@ -1574,7 +1586,7 @@ _rshi_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t
r1, jit_word_t i0)
static void
_ltr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPW(r1, r2);
+ CMP(r1, r2);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_LT);
}
@@ -1584,11 +1596,11 @@ _lti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
{
jit_int32_t reg;
if (can_sign_extend_short_p(i0))
- CMPWI(r1, i0);
+ CMPI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPW(r1, rn(reg));
+ CMP(r1, rn(reg));
jit_unget_reg(reg);
}
MFCR(r0);
@@ -1598,7 +1610,7 @@ _lti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_ltr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPLW(r1, r2);
+ CMPL(r1, r2);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_LT);
}
@@ -1608,11 +1620,11 @@ _lti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t
r1, jit_word_t i0)
{
jit_int32_t reg;
if (can_zero_extend_short_p(i0))
- CMPLWI(r1, i0);
+ CMPLI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPLW(r1, rn(reg));
+ CMPL(r1, rn(reg));
jit_unget_reg(reg);
}
MFCR(r0);
@@ -1622,7 +1634,7 @@ _lti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_ler(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPW(r1, r2);
+ CMP(r1, r2);
CRNOT(CR_GT, CR_GT);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_GT);
@@ -1633,11 +1645,11 @@ _lei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
{
jit_int32_t reg;
if (can_sign_extend_short_p(i0))
- CMPWI(r1, i0);
+ CMPI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPW(r1, rn(reg));
+ CMP(r1, rn(reg));
jit_unget_reg(reg);
}
CRNOT(CR_GT, CR_GT);
@@ -1648,7 +1660,7 @@ _lei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_ler_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPLW(r1, r2);
+ CMPL(r1, r2);
CRNOT(CR_GT, CR_GT);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_GT);
@@ -1659,11 +1671,11 @@ _lei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t
r1, jit_word_t i0)
{
jit_int32_t reg;
if (can_zero_extend_short_p(i0))
- CMPLWI(r1, i0);
+ CMPLI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPLW(r1, rn(reg));
+ CMPL(r1, rn(reg));
jit_unget_reg(reg);
}
CRNOT(CR_GT, CR_GT);
@@ -1674,7 +1686,7 @@ _lei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_eqr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPW(r1, r2);
+ CMP(r1, r2);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_EQ);
}
@@ -1684,13 +1696,13 @@ _eqi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
{
jit_int32_t reg;
if (can_sign_extend_short_p(i0))
- CMPWI(r1, i0);
+ CMPI(r1, i0);
else if (can_zero_extend_short_p(i0))
- CMPLWI(r1, i0);
+ CMPLI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPW(r1, rn(reg));
+ CMP(r1, rn(reg));
jit_unget_reg(reg);
}
MFCR(r0);
@@ -1700,7 +1712,7 @@ _eqi(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_ger(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPW(r1, r2);
+ CMP(r1, r2);
CRNOT(CR_LT, CR_LT);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_LT);
@@ -1711,11 +1723,11 @@ _gei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
{
jit_int32_t reg;
if (can_sign_extend_short_p(i0))
- CMPWI(r1, i0);
+ CMPI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPW(r1, rn(reg));
+ CMP(r1, rn(reg));
jit_unget_reg(reg);
}
CRNOT(CR_LT, CR_LT);
@@ -1726,7 +1738,7 @@ _gei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_ger_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPLW(r1, r2);
+ CMPL(r1, r2);
CRNOT(CR_LT, CR_LT);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_LT);
@@ -1737,11 +1749,11 @@ _gei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t
r1, jit_word_t i0)
{
jit_int32_t reg;
if (can_zero_extend_short_p(i0))
- CMPLWI(r1, i0);
+ CMPLI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPLW(r1, rn(reg));
+ CMPL(r1, rn(reg));
jit_unget_reg(reg);
}
CRNOT(CR_LT, CR_LT);
@@ -1752,7 +1764,7 @@ _gei_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_gtr(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPW(r1, r2);
+ CMP(r1, r2);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_GT);
}
@@ -1762,11 +1774,11 @@ _gti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
{
jit_int32_t reg;
if (can_sign_extend_short_p(i0))
- CMPWI(r1, i0);
+ CMPI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPW(r1, rn(reg));
+ CMP(r1, rn(reg));
jit_unget_reg(reg);
}
MFCR(r0);
@@ -1776,7 +1788,7 @@ _gti(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_gtr_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPLW(r1, r2);
+ CMPL(r1, r2);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_GT);
}
@@ -1786,11 +1798,11 @@ _gti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t
r1, jit_word_t i0)
{
jit_int32_t reg;
if (can_zero_extend_short_p(i0))
- CMPLWI(r1, i0);
+ CMPLI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPLW(r1, rn(reg));
+ CMPL(r1, rn(reg));
jit_unget_reg(reg);
}
MFCR(r0);
@@ -1800,7 +1812,7 @@ _gti_u(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
static void
_ner(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1, jit_int32_t r2)
{
- CMPW(r1, r2);
+ CMP(r1, r2);
CRNOT(CR_EQ, CR_EQ);
MFCR(r0);
EXTRWI(r0, r0, 1, CR_EQ);
@@ -1811,13 +1823,13 @@ _nei(jit_state_t *_jit, jit_int32_t r0, jit_int32_t r1,
jit_word_t i0)
{
jit_int32_t reg;
if (can_sign_extend_short_p(i0))
- CMPWI(r1, i0);
+ CMPI(r1, i0);
else if (can_zero_extend_short_p(i0))
- CMPLWI(r1, i0);
+ CMPLI(r1, i0);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i0);
- CMPW(r1, rn(reg));
+ CMP(r1, rn(reg));
jit_unget_reg(reg);
}
CRNOT(CR_EQ, CR_EQ);
@@ -1829,7 +1841,7 @@ static jit_word_t
_bltr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPW(r0, r1);
+ CMP(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BLT(d);
@@ -1842,11 +1854,11 @@ _blti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0,
jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_sign_extend_short_p(i1))
- CMPWI(r0, i1);
+ CMPI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPW(r0, rn(reg));
+ CMP(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -1859,7 +1871,7 @@ static jit_word_t
_bltr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPLW(r0, r1);
+ CMPL(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BLT(d);
@@ -1872,11 +1884,11 @@ _blti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t
r0, jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_zero_extend_short_p(i1))
- CMPLWI(r0, i1);
+ CMPLI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPLW(r0, rn(reg));
+ CMPL(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -1889,7 +1901,7 @@ static jit_word_t
_bler(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPW(r0, r1);
+ CMP(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BLE(d);
@@ -1902,11 +1914,11 @@ _blei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0,
jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_sign_extend_short_p(i1))
- CMPWI(r0, i1);
+ CMPI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPW(r0, rn(reg));
+ CMP(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -1919,7 +1931,7 @@ static jit_word_t
_bler_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPLW(r0, r1);
+ CMPL(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BLE(d);
@@ -1932,11 +1944,11 @@ _blei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t
r0, jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_zero_extend_short_p(i1))
- CMPLWI(r0, i1);
+ CMPLI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPLW(r0, rn(reg));
+ CMPL(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -1949,7 +1961,7 @@ static jit_word_t
_beqr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPW(r0, r1);
+ CMP(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BEQ(d);
@@ -1962,13 +1974,13 @@ _beqi(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0,
jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_sign_extend_short_p(i1))
- CMPWI(r0, i1);
+ CMPI(r0, i1);
else if (can_zero_extend_short_p(i1))
- CMPLWI(r0, i1);
+ CMPLI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPW(r0, rn(reg));
+ CMP(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -1981,7 +1993,7 @@ static jit_word_t
_bger(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPW(r0, r1);
+ CMP(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BGE(d);
@@ -1994,11 +2006,11 @@ _bgei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0,
jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_sign_extend_short_p(i1))
- CMPWI(r0, i1);
+ CMPI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPW(r0, rn(reg));
+ CMP(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -2011,7 +2023,7 @@ static jit_word_t
_bger_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPLW(r0, r1);
+ CMPL(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BGE(d);
@@ -2024,11 +2036,11 @@ _bgei_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t
r0, jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_zero_extend_short_p(i1))
- CMPLWI(r0, i1);
+ CMPLI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPLW(r0, rn(reg));
+ CMPL(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -2041,7 +2053,7 @@ static jit_word_t
_bgtr(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPW(r0, r1);
+ CMP(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BGT(d);
@@ -2054,11 +2066,11 @@ _bgti(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0,
jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_sign_extend_short_p(i1))
- CMPWI(r0, i1);
+ CMPI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPW(r0, rn(reg));
+ CMP(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -2071,7 +2083,7 @@ static jit_word_t
_bgtr_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPLW(r0, r1);
+ CMPL(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BGT(d);
@@ -2084,11 +2096,11 @@ _bgti_u(jit_state_t *_jit, jit_word_t i0, jit_int32_t
r0, jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_zero_extend_short_p(i1))
- CMPLWI(r0, i1);
+ CMPLI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPLW(r0, rn(reg));
+ CMPL(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
@@ -2101,7 +2113,7 @@ static jit_word_t
_bner(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0, jit_int32_t r1)
{
jit_word_t d, w;
- CMPW(r0, r1);
+ CMP(r0, r1);
w = _jit->pc.w;
d = (i0 - w) & ~3;
BNE(d);
@@ -2114,13 +2126,13 @@ _bnei(jit_state_t *_jit, jit_word_t i0, jit_int32_t r0,
jit_word_t i1)
jit_int32_t reg;
jit_word_t d, w;
if (can_sign_extend_short_p(i1))
- CMPWI(r0, i1);
+ CMPI(r0, i1);
else if (can_zero_extend_short_p(i1))
- CMPLWI(r0, i1);
+ CMPLI(r0, i1);
else {
reg = jit_get_reg(jit_class_gpr);
movi(rn(reg), i1);
- CMPW(r0, rn(reg));
+ CMP(r0, rn(reg));
jit_unget_reg(reg);
}
w = _jit->pc.w;
--
2.35.1