changeset 22006:985f49785f06

AMD64Move: add AMD64PushPopStackMove.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 18 Jun 2015 09:59:29 +0200
parents f00f1f9df48e
children 4ad715543ea2
files graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java
diffstat 2 files changed, 50 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Thu Jun 18 09:58:29 2015 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Thu Jun 18 09:59:29 2015 +0200
@@ -59,6 +59,7 @@
 import com.oracle.graal.lir.amd64.AMD64ControlFlow.ReturnOp;
 import com.oracle.graal.lir.amd64.AMD64ControlFlow.StrategySwitchOp;
 import com.oracle.graal.lir.amd64.AMD64ControlFlow.TableSwitchOp;
+import com.oracle.graal.lir.amd64.AMD64Move.AMD64PushPopStackMove;
 import com.oracle.graal.lir.amd64.AMD64Move.AMD64StackMove;
 import com.oracle.graal.lir.amd64.AMD64Move.CompareAndSwapOp;
 import com.oracle.graal.lir.amd64.AMD64Move.LeaDataOp;
@@ -164,10 +165,23 @@
     }
 
     protected LIRInstruction createStackMove(AllocatableValue result, Value input) {
-        RegisterBackupPair backup = getScratchRegister(input.getPlatformKind());
-        Register scratchRegister = backup.register;
-        StackSlotValue backupSlot = backup.backupSlot;
-        return createStackMove(result, input, scratchRegister, backupSlot);
+        Kind kind = result.getKind();
+        OperandSize size;
+        switch (kind) {
+            case Long:
+            case Double:
+                size = QWORD;
+                break;
+            case Short:
+                size = WORD;
+                break;
+            default:
+                RegisterBackupPair backup = getScratchRegister(input.getPlatformKind());
+                Register scratchRegister = backup.register;
+                StackSlotValue backupSlot = backup.backupSlot;
+                return createStackMove(result, input, scratchRegister, backupSlot);
+        }
+        return new AMD64PushPopStackMove(size, result, input);
     }
 
     protected LIRInstruction createStackMove(AllocatableValue result, Value input, Register scratchRegister, StackSlotValue backupSlot) {
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java	Thu Jun 18 09:58:29 2015 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java	Thu Jun 18 09:59:29 2015 +0200
@@ -156,6 +156,38 @@
         }
     }
 
+    @Opcode("STACKMOVE")
+    public static final class AMD64PushPopStackMove extends AMD64LIRInstruction implements MoveOp {
+        public static final LIRInstructionClass<AMD64PushPopStackMove> TYPE = LIRInstructionClass.create(AMD64PushPopStackMove.class);
+
+        @Def({STACK}) protected AllocatableValue result;
+        @Use({STACK, HINT}) protected Value input;
+        private final OperandSize size;
+
+        public AMD64PushPopStackMove(OperandSize size, AllocatableValue result, Value input) {
+            super(TYPE);
+            this.result = result;
+            this.input = input;
+            this.size = size;
+        }
+
+        @Override
+        public Value getInput() {
+            return input;
+        }
+
+        @Override
+        public AllocatableValue getResult() {
+            return result;
+        }
+
+        @Override
+        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
+            AMD64MOp.PUSH.emit(masm, size, (AMD64Address) crb.asAddress(input));
+            AMD64MOp.POP.emit(masm, size, (AMD64Address) crb.asAddress(result));
+        }
+    }
+
     public static final class LeaOp extends AMD64LIRInstruction {
         public static final LIRInstructionClass<LeaOp> TYPE = LIRInstructionClass.create(LeaOp.class);