Skip to content
Browse files

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.
  • Loading branch information...
1 parent f38c4e2 commit d8729a7a8db9071e54b66143d53441b39f8378b8 @dicej dicej committed Apr 22, 2013
View
2 src/codegen/target/x86/multimethod.cpp
@@ -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
13 src/codegen/target/x86/operations.cpp
@@ -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
3 src/codegen/target/x86/operations.h
@@ -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);

0 comments on commit d8729a7

Please sign in to comment.
Something went wrong with that request. Please try again.