changeset 9293:d006c9920e94

Make kind of LIR memory access operations explicit.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 25 Apr 2013 16:12:06 +0200
parents 90ca451a2f28
children 899295127bc4
files graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java
diffstat 5 files changed, 37 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Thu Apr 25 11:39:54 2013 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Thu Apr 25 16:12:06 2013 +0200
@@ -156,7 +156,7 @@
         append(createMove(dst, src));
     }
 
-    private AMD64AddressValue prepareAddress(Kind kind, Value base, long displacement, Value index, int scale) {
+    private AMD64AddressValue prepareAddress(Value base, long displacement, Value index, int scale) {
         AllocatableValue baseRegister;
         long finalDisp = displacement;
         if (isConstant(base)) {
@@ -205,38 +205,38 @@
             }
         }
 
-        return new AMD64AddressValue(kind, baseRegister, indexRegister, scaleEnum, displacementInt);
+        return new AMD64AddressValue(target().wordKind, baseRegister, indexRegister, scaleEnum, displacementInt);
     }
 
     @Override
     public Variable emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting) {
-        AMD64AddressValue loadAddress = prepareAddress(kind, base, displacement, index, scale);
-        Variable result = newVariable(loadAddress.getKind());
-        append(new LoadOp(result, loadAddress, deopting != null ? state(deopting) : null));
+        AMD64AddressValue loadAddress = prepareAddress(base, displacement, index, scale);
+        Variable result = newVariable(kind);
+        append(new LoadOp(kind, result, loadAddress, deopting != null ? state(deopting) : null));
         return result;
     }
 
     @Override
     public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value inputVal, DeoptimizingNode deopting) {
-        AMD64AddressValue storeAddress = prepareAddress(kind, base, displacement, index, scale);
+        AMD64AddressValue storeAddress = prepareAddress(base, displacement, index, scale);
         LIRFrameState state = deopting != null ? state(deopting) : null;
 
         if (isConstant(inputVal)) {
             Constant c = asConstant(inputVal);
             if (canStoreConstant(c)) {
-                append(new StoreConstantOp(storeAddress, c, state));
+                append(new StoreConstantOp(kind, storeAddress, c, state));
                 return;
             }
         }
 
         Variable input = load(inputVal);
-        append(new StoreOp(storeAddress, input, state));
+        append(new StoreOp(kind, storeAddress, input, state));
     }
 
     @Override
     public Variable emitLea(Value base, long displacement, Value index, int scale) {
         Variable result = newVariable(target().wordKind);
-        AMD64AddressValue address = prepareAddress(result.getKind(), base, displacement, index, scale);
+        AMD64AddressValue address = prepareAddress(base, displacement, index, scale);
         append(new LeaOp(result, address));
         return result;
     }
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Thu Apr 25 11:39:54 2013 +0200
+++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java	Thu Apr 25 16:12:06 2013 +0200
@@ -137,7 +137,7 @@
         }
     }
 
-    private PTXAddressValue prepareAddress(Kind kind, Value base, long displacement, Value index, int scale) {
+    private PTXAddressValue prepareAddress(Value base, long displacement, Value index, int scale) {
         AllocatableValue baseRegister;
         long finalDisp = displacement;
         if (isConstant(base)) {
@@ -177,22 +177,22 @@
             }
         }
 
-        return new PTXAddressValue(kind, baseRegister, finalDisp);
+        return new PTXAddressValue(target().wordKind, baseRegister, finalDisp);
     }
 
     @Override
     public Variable emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting) {
-        PTXAddressValue loadAddress = prepareAddress(kind, base, displacement, index, scale);
-        Variable result = newVariable(loadAddress.getKind());
-        append(new LoadOp(result, loadAddress, deopting != null ? state(deopting) : null));
+        PTXAddressValue loadAddress = prepareAddress(base, displacement, index, scale);
+        Variable result = newVariable(kind);
+        append(new LoadOp(kind, result, loadAddress, deopting != null ? state(deopting) : null));
         return result;
     }
 
     @Override
     public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value inputVal, DeoptimizingNode deopting) {
-        PTXAddressValue storeAddress = prepareAddress(kind, base, displacement, index, scale);
+        PTXAddressValue storeAddress = prepareAddress(base, displacement, index, scale);
         Variable input = load(inputVal);
-        append(new StoreOp(storeAddress, input, deopting != null ? state(deopting) : null));
+        append(new StoreOp(kind, storeAddress, input, deopting != null ? state(deopting) : null));
     }
 
     @Override
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java	Thu Apr 25 11:39:54 2013 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java	Thu Apr 25 16:12:06 2013 +0200
@@ -67,8 +67,7 @@
 
     @Override
     public String toString() {
-        StringBuilder s = new StringBuilder();
-        s.append(getKind().getJavaName()).append("[");
+        StringBuilder s = new StringBuilder("[");
         String sep = "";
         if (isLegal(base)) {
             s.append(base);
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java	Thu Apr 25 11:39:54 2013 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java	Thu Apr 25 16:12:06 2013 +0200
@@ -97,10 +97,12 @@
 
     public abstract static class MemOp extends AMD64LIRInstruction {
 
+        protected final Kind kind;
         @Use({COMPOSITE}) protected AMD64AddressValue address;
         @State protected LIRFrameState state;
 
-        public MemOp(AMD64AddressValue address, LIRFrameState state) {
+        public MemOp(Kind kind, AMD64AddressValue address, LIRFrameState state) {
+            this.kind = kind;
             this.address = address;
             this.state = state;
         }
@@ -120,14 +122,14 @@
 
         @Def({REG}) protected AllocatableValue result;
 
-        public LoadOp(AllocatableValue result, AMD64AddressValue address, LIRFrameState state) {
-            super(address, state);
+        public LoadOp(Kind kind, AllocatableValue result, AMD64AddressValue address, LIRFrameState state) {
+            super(kind, address, state);
             this.result = result;
         }
 
         @Override
         public void emitMemAccess(AMD64MacroAssembler masm) {
-            switch (address.getKind()) {
+            switch (kind) {
                 case Boolean:
                 case Byte:
                     masm.movsxb(asRegister(result), address.toAddress());
@@ -163,15 +165,15 @@
 
         @Use({REG}) protected AllocatableValue input;
 
-        public StoreOp(AMD64AddressValue address, AllocatableValue input, LIRFrameState state) {
-            super(address, state);
+        public StoreOp(Kind kind, AMD64AddressValue address, AllocatableValue input, LIRFrameState state) {
+            super(kind, address, state);
             this.input = input;
         }
 
         @Override
         public void emitMemAccess(AMD64MacroAssembler masm) {
             assert isRegister(input);
-            switch (address.getKind()) {
+            switch (kind) {
                 case Boolean:
                 case Byte:
                     masm.movb(address.toAddress(), asRegister(input));
@@ -205,14 +207,14 @@
 
         protected final Constant input;
 
-        public StoreConstantOp(AMD64AddressValue address, Constant input, LIRFrameState state) {
-            super(address, state);
+        public StoreConstantOp(Kind kind, AMD64AddressValue address, Constant input, LIRFrameState state) {
+            super(kind, address, state);
             this.input = input;
         }
 
         @Override
         public void emitMemAccess(AMD64MacroAssembler masm) {
-            switch (address.getKind()) {
+            switch (kind) {
                 case Boolean:
                 case Byte:
                     masm.movb(address.toAddress(), input.asInt() & 0xFF);
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java	Thu Apr 25 11:39:54 2013 +0200
+++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java	Thu Apr 25 16:12:06 2013 +0200
@@ -119,11 +119,13 @@
 
     public static class LoadOp extends PTXLIRInstruction {
 
+        private final Kind kind;
         @Def({REG}) protected AllocatableValue result;
         @Use({COMPOSITE}) protected PTXAddressValue address;
         @State protected LIRFrameState state;
 
-        public LoadOp(AllocatableValue result, PTXAddressValue address, LIRFrameState state) {
+        public LoadOp(Kind kind, AllocatableValue result, PTXAddressValue address, LIRFrameState state) {
+            this.kind = kind;
             this.result = result;
             this.address = address;
             this.state = state;
@@ -132,7 +134,7 @@
         @Override
         public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) {
             PTXAddress addr = address.toAddress();
-            switch (address.getKind()) {
+            switch (kind) {
                 case Byte:
                     masm.ld_global_s8(asRegister(result), addr.getBase(), addr.getDisplacement());
                     break;
@@ -165,11 +167,13 @@
 
     public static class StoreOp extends PTXLIRInstruction {
 
+        private final Kind kind;
         @Use({COMPOSITE}) protected PTXAddressValue address;
         @Use({REG}) protected AllocatableValue input;
         @State protected LIRFrameState state;
 
-        public StoreOp(PTXAddressValue address, AllocatableValue input, LIRFrameState state) {
+        public StoreOp(Kind kind, PTXAddressValue address, AllocatableValue input, LIRFrameState state) {
+            this.kind = kind;
             this.address = address;
             this.input = input;
             this.state = state;
@@ -179,7 +183,7 @@
         public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) {
             assert isRegister(input);
             PTXAddress addr = address.toAddress();
-            switch (address.getKind()) {
+            switch (kind) {
                 case Byte:
                     masm.st_global_s8(addr.getBase(), addr.getDisplacement(), asRegister(input));
                     break;