changeset 8972:14c629440b1a

Common base LIR instruction for call ops.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 09 Apr 2013 19:56:30 +0200
parents da39fb4f9b2e
children 0c3dc4951410
files graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java
diffstat 1 files changed, 21 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Tue Apr 09 19:51:24 2013 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Tue Apr 09 19:56:30 2013 +0200
@@ -35,18 +35,14 @@
 
 public class AMD64Call {
 
-    @Opcode("CALL_DIRECT")
-    public static class DirectCallOp extends AMD64LIRInstruction {
+    public abstract static class CallOp extends AMD64LIRInstruction {
 
         @Def({REG, ILLEGAL}) protected Value result;
         @Use({REG, STACK}) protected Value[] parameters;
         @Temp protected Value[] temps;
         @State protected LIRFrameState state;
 
-        protected final ResolvedJavaMethod callTarget;
-
-        public DirectCallOp(ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
-            this.callTarget = callTarget;
+        public CallOp(Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
             this.result = result;
             this.parameters = parameters;
             this.state = state;
@@ -55,32 +51,34 @@
         }
 
         @Override
-        public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
-            directCall(tasm, masm, callTarget, null, true, state);
-        }
-
-        @Override
         public boolean hasCall() {
             return true;
         }
     }
 
-    public abstract static class RuntimeCallOp extends AMD64LIRInstruction {
+    @Opcode("CALL_DIRECT")
+    public static class DirectCallOp extends CallOp {
+
+        protected final ResolvedJavaMethod callTarget;
 
-        @Def({REG, ILLEGAL}) protected Value result;
-        @Use({REG, STACK}) protected Value[] parameters;
-        @Temp protected Value[] temps;
-        @State protected LIRFrameState state;
+        public DirectCallOp(ResolvedJavaMethod callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
+            super(result, parameters, temps, state);
+            this.callTarget = callTarget;
+        }
+
+        @Override
+        public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
+            directCall(tasm, masm, callTarget, null, true, state);
+        }
+    }
+
+    public abstract static class RuntimeCallOp extends CallOp {
 
         protected final RuntimeCallTarget callTarget;
 
         public RuntimeCallOp(RuntimeCallTarget callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState state) {
+            super(result, parameters, temps, state);
             this.callTarget = callTarget;
-            this.result = result;
-            this.parameters = parameters;
-            this.state = state;
-            this.temps = temps;
-            assert temps != null;
         }
 
         @Override
@@ -119,24 +117,16 @@
     }
 
     @Opcode("CALL_INDIRECT")
-    public static class IndirectCallOp extends AMD64LIRInstruction {
+    public static class IndirectCallOp extends CallOp {
 
-        @Def({REG, ILLEGAL}) protected Value result;
-        @Use({REG, STACK}) protected Value[] parameters;
         @Use({REG}) protected Value targetAddress;
-        @Temp protected Value[] temps;
-        @State protected LIRFrameState state;
 
         protected final InvokeTarget callTarget;
 
         public IndirectCallOp(InvokeTarget callTarget, Value result, Value[] parameters, Value[] temps, Value targetAddress, LIRFrameState state) {
+            super(result, parameters, temps, state);
             this.callTarget = callTarget;
-            this.result = result;
-            this.parameters = parameters;
             this.targetAddress = targetAddress;
-            this.state = state;
-            this.temps = temps;
-            assert temps != null;
         }
 
         @Override
@@ -149,11 +139,6 @@
             super.verify();
             assert isRegister(targetAddress) : "The current register allocator cannot handle variables to be used at call sites, it must be in a fixed register for now";
         }
-
-        @Override
-        public boolean hasCall() {
-            return true;
-        }
     }
 
     public static void directCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) {