Mercurial > hg > truffle
diff graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java @ 14945:b14cb2d9253d
Make compression and uncompression explicit in the high level graph.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 02 Apr 2014 15:26:58 +0200 |
parents | 96f8e6b6a81a |
children | 64dcb92ee75a |
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Wed Apr 02 14:43:52 2014 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Wed Apr 02 15:26:58 2014 +0200 @@ -42,23 +42,38 @@ public class AMD64Move { + private abstract static class AbstractMoveOp extends AMD64LIRInstruction implements MoveOp { + + private Kind moveKind; + + public AbstractMoveOp(Kind moveKind) { + if (moveKind == Kind.Illegal) { + // unknown operand size, conservatively move the whole register + this.moveKind = Kind.Long; + } else { + this.moveKind = moveKind; + } + } + + @Override + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + move(moveKind, crb, masm, getResult(), getInput()); + } + } + @Opcode("MOVE") - public static class MoveToRegOp extends AMD64LIRInstruction implements MoveOp { + public static class MoveToRegOp extends AbstractMoveOp { @Def({REG, HINT}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; - public MoveToRegOp(AllocatableValue result, Value input) { + public MoveToRegOp(Kind moveKind, AllocatableValue result, Value input) { + super(moveKind); this.result = result; this.input = input; } @Override - public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - move(crb, masm, getResult(), getInput()); - } - - @Override public Value getInput() { return input; } @@ -70,22 +85,18 @@ } @Opcode("MOVE") - public static class MoveFromRegOp extends AMD64LIRInstruction implements MoveOp { + public static class MoveFromRegOp extends AbstractMoveOp { @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, CONST, HINT}) protected Value input; - public MoveFromRegOp(AllocatableValue result, Value input) { + public MoveFromRegOp(Kind moveKind, AllocatableValue result, Value input) { + super(moveKind); this.result = result; this.input = input; } @Override - public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { - move(crb, masm, getResult(), getInput()); - } - - @Override public Value getInput() { return input; } @@ -404,17 +415,21 @@ } public static void move(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { + move(result.getKind(), crb, masm, result, input); + } + + public static void move(Kind moveKind, CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { if (isRegister(input)) { if (isRegister(result)) { - reg2reg(masm, result, input); + reg2reg(moveKind, masm, result, input); } else if (isStackSlot(result)) { - reg2stack(crb, masm, result, input); + reg2stack(moveKind, crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isStackSlot(input)) { if (isRegister(result)) { - stack2reg(crb, masm, result, input); + stack2reg(moveKind, crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -431,11 +446,11 @@ } } - private static void reg2reg(AMD64MacroAssembler masm, Value result, Value input) { + private static void reg2reg(Kind kind, AMD64MacroAssembler masm, Value result, Value input) { if (asRegister(input).equals(asRegister(result))) { return; } - switch (input.getKind()) { + switch (kind.getStackKind()) { case Int: masm.movl(asRegister(result), asRegister(input)); break; @@ -456,9 +471,9 @@ } } - private static void reg2stack(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { + private static void reg2stack(Kind kind, CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { AMD64Address dest = (AMD64Address) crb.asAddress(result); - switch (input.getKind()) { + switch (kind) { case Boolean: case Byte: masm.movb(dest, asRegister(input)); @@ -487,9 +502,9 @@ } } - private static void stack2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { + private static void stack2reg(Kind kind, CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { AMD64Address src = (AMD64Address) crb.asAddress(input); - switch (input.getKind()) { + switch (kind) { case Boolean: masm.movzbl(asRegister(result), src); break;