fix addCR and subtractCR for cases of 64-bit constants on amd64

This commit is contained in:
Joel Dice 2008-07-02 08:52:35 -06:00
parent 0f94bea5a6
commit 107ac01304
2 changed files with 64 additions and 2 deletions

View File

@ -959,6 +959,10 @@ addCM(Context* c, unsigned size UNUSED, Assembler::Constant* a,
}
}
void
addRR(Context* c, unsigned size, Assembler::Register* a,
Assembler::Register* b);
void
addCR(Context* c, unsigned size, Assembler::Constant* a,
Assembler::Register* b)
@ -987,7 +991,10 @@ addCR(Context* c, unsigned size, Assembler::Constant* a,
c->code.append(0xc0 | b->low);
c->code.append4(v);
} else {
abort(c);
Assembler::Register tmp(c->client->acquireTemporary());
moveCR(c, size, a, &tmp);
addRR(c, size, &tmp, b);
c->client->releaseTemporary(tmp.low);
}
}
}
@ -1009,6 +1016,10 @@ subtractBorrowCR(Context* c, unsigned size UNUSED, Assembler::Constant* a,
}
}
void
subtractRR(Context* c, unsigned size, Assembler::Register* a,
Assembler::Register* b);
void
subtractCR(Context* c, unsigned size, Assembler::Constant* a,
Assembler::Register* b)
@ -1037,7 +1048,10 @@ subtractCR(Context* c, unsigned size, Assembler::Constant* a,
c->code.append(0xe8 | b->low);
c->code.append4(v);
} else {
abort(c);
Assembler::Register tmp(c->client->acquireTemporary());
moveCR(c, size, a, &tmp);
subtractRR(c, size, &tmp, b);
c->client->releaseTemporary(tmp.low);
}
}
}

View File

@ -234,6 +234,54 @@ public class Misc {
expect(~a == ~25214903884L);
}
{ long b = 2;
expect((-25214903884L) >> b == -25214903884L >> 2);
expect((-25214903884L) >>> b == -25214903884L >>> 2);
expect((-25214903884L) << b == -25214903884L << 2);
expect((-25214903884L) + b == -25214903884L + 2L);
expect((-25214903884L) - b == -25214903884L - 2L);
expect((-25214903884L) * b == -25214903884L * 2L);
expect((-25214903884L) / b == -25214903884L / 2L);
expect((-25214903884L) % b == -25214903884L % 2L);
expect(((-25214903884L) & b) == (-25214903884L & 2L));
expect(((-25214903884L) | b) == (-25214903884L | 2L));
expect(((-25214903884L) ^ b) == (-25214903884L ^ 2L));
b = 2;
expect(25214903884L >> b == 25214903884L >> 2);
expect(25214903884L >>> b == 25214903884L >>> 2);
expect(25214903884L << b == 25214903884L << 2);
expect(25214903884L + b == 25214903884L + 2L);
expect(25214903884L - b == 25214903884L - 2L);
expect(25214903884L * b == 25214903884L * 2L);
expect(25214903884L / b == 25214903884L / 2L);
expect(25214903884L % b == 25214903884L % 2L);
expect((25214903884L & b) == (25214903884L & 2L));
expect((25214903884L | b) == (25214903884L | 2L));
expect((25214903884L ^ b) == (25214903884L ^ 2L));
}
{ long a = 2L;
expect(a + (-25214903884L) == 2L + (-25214903884L));
expect(a - (-25214903884L) == 2L - (-25214903884L));
expect(a * (-25214903884L) == 2L * (-25214903884L));
expect(a / (-25214903884L) == 2L / (-25214903884L));
expect(a % (-25214903884L) == 2L % (-25214903884L));
expect((a & (-25214903884L)) == (2L & (-25214903884L)));
expect((a | (-25214903884L)) == (2L | (-25214903884L)));
expect((a ^ (-25214903884L)) == (2L ^ (-25214903884L)));
a = 2L;
expect(a + 25214903884L == 2L + 25214903884L);
expect(a - 25214903884L == 2L - 25214903884L);
expect(a * 25214903884L == 2L * 25214903884L);
expect(a / 25214903884L == 2L / 25214903884L);
expect(a % 25214903884L == 2L % 25214903884L);
expect((a & 25214903884L) == (2L & 25214903884L));
expect((a | 25214903884L) == (2L | 25214903884L));
expect((a ^ 25214903884L) == (2L ^ 25214903884L));
}
byte2 = 0;
expect(byte2 == 0);