fix zero-extension of constants in x86 compiler

scalac may emit a ldc followed by an i2c, whereas javac does the
conversion (including zero extension if necessary) at compile time.
This commit ensures we handle the i2c case properly.
This commit is contained in:
Joel Dice 2013-04-22 19:00:54 -06:00
parent f38c4e25c6
commit d8729a7a8d
3 changed files with 17 additions and 1 deletions

View File

@ -107,7 +107,7 @@ void populateTables(ArchitectureContext* c) {
bo[index(c, lir::MoveZ, R, R)] = CAST2(moveZRR);
bo[index(c, lir::MoveZ, M, R)] = CAST2(moveZMR);
bo[index(c, lir::MoveZ, C, R)] = CAST2(moveCR);
bo[index(c, lir::MoveZ, C, R)] = CAST2(moveZCR);
bo[index(c, lir::Add, R, R)] = CAST2(addRR);
bo[index(c, lir::Add, C, R)] = CAST2(addCR);

View File

@ -226,6 +226,19 @@ void moveCR(Context* c, unsigned aSize, lir::Constant* a,
}
}
void moveZCR(Context* c, unsigned aSize UNUSED, lir::Constant* a,
unsigned bSize UNUSED, lir::Register* b)
{
assert(c, not isFloatReg(b));
assert(c, aSize == 2);
assert(c, bSize == vm::TargetBytesPerWord);
assert(c, a->value->resolved());
maybeRex(c, vm::TargetBytesPerWord, b);
opcode(c, 0xb8 + regCode(b));
c->code.appendTargetAddress(static_cast<uint16_t>(a->value->value()));
}
void swapRR(Context* c, unsigned aSize UNUSED, lir::Register* a,
unsigned bSize UNUSED, lir::Register* b)
{

View File

@ -65,6 +65,9 @@ void negateRR(Context* c, unsigned aSize, lir::Register* a,
void moveCR(Context* c, unsigned aSize, lir::Constant* a,
unsigned bSize, lir::Register* b);
void moveZCR(Context* c, unsigned aSize, lir::Constant* a,
unsigned bSize, lir::Register* b);
void swapRR(Context* c, unsigned aSize UNUSED, lir::Register* a,
unsigned bSize UNUSED, lir::Register* b);