changeset 16303:66c7e50a9a32

SPARCMove.java: Adding constant float and double loads SPARCConstDataOp.java, SPARCLIRGenerator.java: Introducing CSTrings as constant value (Used for debugging) SPARCHotSpotLIRGenerationResult.java, SPARCHotSpotBackend.java: Adapting to new LIR interface SPARCAssembler.java: Introducing comments for some instructions
author Stefan Anzinger <stefan.anzinger@gmail.com>
date Sat, 19 Apr 2014 15:29:48 +0200
parents 4c68a0eb69ca
children 12f2b3baa163
files graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerationResult.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCConstDataOp.java graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java
diffstat 6 files changed, 170 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java	Sat Apr 19 00:41:04 2014 +0200
+++ b/graal/com.oracle.graal.asm.sparc/src/com/oracle/graal/asm/sparc/SPARCAssembler.java	Sat Apr 19 15:29:48 2014 +0200
@@ -37,7 +37,7 @@
 
     /**
      * Constructs an assembler for the SPARC architecture.
-     * 
+     *
      * @param registerConfig the register configuration used to bind {@link Register#Frame} and
      *            {@link Register#CallerFrame} to physical registers. This value can be null if this
      *            assembler instance will not be used to assemble instructions using these logical
@@ -50,7 +50,7 @@
     // @formatter:off
     /**
      * Instruction format for sethi.
-     * 
+     *
      * | 00  |  rd    | op2 |               imm22                     |
      * |31 30|29    25|24 22|21                                      0|
      */
@@ -123,7 +123,7 @@
     // @formatter:off
     /**
      * Instruction format for branches.
-     * 
+     *
      * | 00  |a | cond | op2 |             disp22                      |
      * |31 30|29|28  25|24 22|21                                      0|
      */
@@ -142,7 +142,7 @@
     // @formatter:off
     /**
      * Instruction format for conditional branches.
-     * 
+     *
      * | 00  |a | cond | op2 |cc1|cc0|p |             disp19           |
      * |31 30|29|28  25|24 22|21 |20 |19|                             0|
      */
@@ -330,7 +330,7 @@
     // @formatter:off
     /**
      * Instruction format for calls.
-     * 
+     *
      * | 01  |                      disp30                             |
      * |31 30|29                                                      0|
      */
@@ -457,7 +457,7 @@
     // @formatter:off
     /**
      * Instruction format for Arithmetic, Logical, Moves, Tcc, Prefetch, and Misc.
-     * 
+     *
      * | 10  |   rd   |   op3   |   rs1   | i|     imm_asi   |   rs2   |
      * | 10  |   rd   |   op3   |   rs1   | i|          simm13         |
      * | 10  |   rd   |   op3   |   rs1   | i| x|            |   rs2   |
@@ -594,7 +594,7 @@
     // @formatter:off
     /**
      * Instruction format for Loads, Stores and Misc.
-     * 
+     *
      * | 11  |   rd   |   op3   |   rs1   | i|   imm_asi   |   rs2   |
      * | 11  |   rd   |   op3   |   rs1   | i|        simm13         |
      * |31 30|29    25|24     19|18     14|13|12          5|4       0|
@@ -749,7 +749,7 @@
     // @formatter:off
     /**
      * Instruction format for Movcc.
-     * 
+     *
      * | 10  |   rd   |   op3   |cc2|   cond  | i|cc1|cc0|      -      |   rs2   |
      * | 10  |   rd   |   op3   |cc2|   cond  | i|cc1|cc0|        simm11         |
      * |31 30|29    25|24     19| 18|17     14|13| 12| 11|10          5|4       0|
@@ -1278,10 +1278,18 @@
         }
     }
 
+    /**
+     * Condition Codes to use for instruction
+     */
     public enum CC {
         // @formatter:off
-
+        /**
+         * Condition is considered as 32bit operation condition
+         */
         Icc(0b00, "icc"),
+        /**
+         * Condition is considered as 64bit operation condition
+         */
         Xcc(0b10, "xcc"),
         Ptrcc(getHostWordKind() == Kind.Long ? Xcc.getValue() : Icc.getValue(), "ptrcc"),
         Fcc0(0b00, "fcc0"),
@@ -1402,6 +1410,9 @@
         }
     }
 
+    /**
+     * Represents the <b>Address Space Identifier</b> defined in the SPARC architec
+     */
     public enum Asi {
         // @formatter:off
 
@@ -1906,6 +1917,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Carry Clear ( Greater not C Than or Equal, Unsigned )
+     */
     public static class Cwbcc extends Fmt00e {
 
         public Cwbcc(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1917,6 +1931,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Carry Set (Less Than, Unsigned)
+     */
     public static class Cwbcs extends Fmt00e {
 
         public Cwbcs(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1928,6 +1945,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Equal
+     */
     public static class Cwbe extends Fmt00e {
 
         public Cwbe(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1939,6 +1959,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Greater
+     */
     public static class Cwbg extends Fmt00e {
 
         public Cwbg(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1950,6 +1973,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Greater or Equal
+     */
     public static class Cwbge extends Fmt00e {
 
         public Cwbge(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1961,6 +1987,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Greater Unsigned
+     */
     public static class Cwbgu extends Fmt00e {
 
         public Cwbgu(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1972,6 +2001,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Less
+     */
     public static class Cwbl extends Fmt00e {
 
         public Cwbl(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1983,6 +2015,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Less or Equal
+     */
     public static class Cwble extends Fmt00e {
 
         public Cwble(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -1994,6 +2029,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Less or Equal Unsigned
+     */
     public static class Cwbleu extends Fmt00e {
 
         public Cwbleu(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -2005,6 +2043,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Not Equal
+     */
     public static class Cwbne extends Fmt00e {
 
         public Cwbne(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -2016,6 +2057,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Negative
+     */
     public static class Cwbneg extends Fmt00e {
 
         public Cwbneg(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -2027,6 +2071,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Positive
+     */
     public static class Cwbpos extends Fmt00e {
 
         public Cwbpos(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -2038,6 +2085,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Overflow Clear
+     */
     public static class Cwbvc extends Fmt00e {
 
         public Cwbvc(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -2049,6 +2099,9 @@
         }
     }
 
+    /**
+     * Compare and Branch if Overflow Set
+     */
     public static class Cwbvs extends Fmt00e {
 
         public Cwbvs(SPARCAssembler asm, Register src1, Register src2, int simm10) {
@@ -2340,6 +2393,9 @@
         }
     }
 
+    /**
+     * Floating-point multiply-add single (fused)
+     */
     public static class Fmadds extends Fmt5a {
 
         public Fmadds(SPARCAssembler asm, Register src1, Register src2, Register src3, Register dst) {
@@ -2347,6 +2403,9 @@
         }
     }
 
+    /**
+     * Floating-point multiply-add double (fused)
+     */
     public static class Fmaddd extends Fmt5a {
 
         public Fmaddd(SPARCAssembler asm, Register src1, Register src2, Register src3, Register dst) {
@@ -2354,6 +2413,9 @@
         }
     }
 
+    /**
+     * 16-bit partitioned average
+     */
     public static class Fmean16 extends Fmt3p {
 
         public Fmean16(Register src1, Register src2, Register dst) {
@@ -2551,6 +2613,9 @@
         }
     }
 
+    /**
+     * Convert Double to 32-bit Integer
+     */
     public static class Fdtoi extends Fmt3n {
 
         public Fdtoi(SPARCAssembler masm, Register src2, Register dst) {
@@ -2558,6 +2623,9 @@
         }
     }
 
+    /**
+     * Flush register windows
+     */
     public static class Flushw extends Fmt10 {
 
         public Flushw() {
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Sat Apr 19 00:41:04 2014 +0200
+++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java	Sat Apr 19 15:29:48 2014 +0200
@@ -131,7 +131,8 @@
 
     @Override
     public void emitData(AllocatableValue dst, byte[] data) {
-        throw GraalInternalError.unimplemented();
+        // throw GraalInternalError.unimplemented();
+        append(new SPARCConstDataOp(dst, data));
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Sat Apr 19 00:41:04 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java	Sat Apr 19 15:29:48 2014 +0200
@@ -192,7 +192,7 @@
 
     @Override
     public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub) {
-        return new LIRGenerationResultBase(lir, frameMap);
+        return new SPARCHotSpotLIRGenerationResult(lir, frameMap, stub);
     }
 
     @Override
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerationResult.java	Sat Apr 19 00:41:04 2014 +0200
+++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotLIRGenerationResult.java	Sat Apr 19 15:29:48 2014 +0200
@@ -22,14 +22,49 @@
  */
 package com.oracle.graal.hotspot.sparc;
 
+import java.util.*;
+
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.hotspot.stubs.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.StandardOp.*;
 
-public interface SPARCHotSpotLIRGenerationResult extends LIRGenerationResult {
+public class SPARCHotSpotLIRGenerationResult extends LIRGenerationResultBase {
+
+    /**
+     * The slot reserved for storing the original return address when a frame is marked for
+     * deoptimization. The return address slot in the callee is overwritten with the address of a
+     * deoptimization stub.
+     */
+    private StackSlot deoptimizationRescueSlot;
+    private final Object stub;
+
+    /**
+     * Map from debug infos that need to be updated with callee save information to the operations
+     * that provide the information.
+     */
+    private Map<LIRFrameState, SaveRegistersOp> calleeSaveInfo = new HashMap<>();
 
-    StackSlot getDeoptimizationRescueSlot();
+    public SPARCHotSpotLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub) {
+        super(lir, frameMap);
+        this.stub = stub;
+    }
+
+    StackSlot getDeoptimizationRescueSlot() {
+        return deoptimizationRescueSlot;
+    }
 
-    Stub getStub();
+    public final void setDeoptimizationRescueSlot(StackSlot deoptimizationRescueSlot) {
+        this.deoptimizationRescueSlot = deoptimizationRescueSlot;
+    }
+
+    Stub getStub() {
+        return (Stub) stub;
+    }
+
+    Map<LIRFrameState, SaveRegistersOp> getCalleeSaveInfo() {
+        return calleeSaveInfo;
+    }
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCConstDataOp.java	Sat Apr 19 15:29:48 2014 +0200
@@ -0,0 +1,27 @@
+package com.oracle.graal.lir.sparc;
+
+import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
+
+import com.oracle.graal.api.code.CompilationResult.RawData;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.asm.sparc.*;
+import com.oracle.graal.lir.asm.*;
+import com.oracle.graal.lir.sparc.SPARCMove.LoadAddressOp;
+
+public class SPARCConstDataOp extends SPARCLIRInstruction {
+
+    @Def({REG}) private AllocatableValue dst;
+    private byte[] val;
+
+    public SPARCConstDataOp(AllocatableValue dst, byte[] val) {
+        this.dst = dst;
+        this.val = val;
+    }
+
+    @Override
+    public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
+        RawData data = new RawData(val, 16);
+        new LoadAddressOp(dst, (SPARCAddress) crb.recordDataReferenceInCode(data)).emitCode(crb);
+    }
+
+}
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Sat Apr 19 00:41:04 2014 +0200
+++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java	Sat Apr 19 15:29:48 2014 +0200
@@ -190,20 +190,28 @@
     public static class LoadAddressOp extends SPARCLIRInstruction {
 
         @Def({REG}) protected AllocatableValue result;
-        @Use({COMPOSITE, UNINITIALIZED}) protected SPARCAddressValue address;
+        @Use({COMPOSITE, UNINITIALIZED}) protected SPARCAddressValue addressValue;
+        protected SPARCAddress address;
 
         public LoadAddressOp(AllocatableValue result, SPARCAddressValue address) {
             this.result = result;
+            this.addressValue = address;
+        }
+
+        public LoadAddressOp(AllocatableValue result, SPARCAddress address) {
+            this.result = result;
             this.address = address;
         }
 
         @Override
         public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
-            SPARCAddress addr = address.toAddress();
-            if (addr.hasIndex()) {
-                new Add(addr.getBase(), addr.getIndex(), asLongReg(result)).emit(masm);
+            if (address == null) {
+                address = addressValue.toAddress();
+            }
+            if (address.hasIndex()) {
+                new Add(address.getBase(), address.getIndex(), asLongReg(result)).emit(masm);
             } else {
-                new Add(addr.getBase(), addr.getDisplacement(), asLongReg(result)).emit(masm);
+                new Add(address.getBase(), address.getDisplacement(), asLongReg(result)).emit(masm);
             }
         }
     }
@@ -474,6 +482,18 @@
                 }
                 break;
             }
+            case Double: {
+                // This is *not* the same as 'constant == 0.0d' in the case where constant is -0.0d
+                assert !crb.codeCache.needsDataPatch(input);
+                new Setx(Double.doubleToRawLongBits(input.asDouble()), asDoubleReg(result)).emit(masm);
+                break;
+            }
+            case Float: {
+                // This is *not* the same as 'constant == 0.0d' in the case where constant is -0.0d
+                assert !crb.codeCache.needsDataPatch(input);
+                new Setx(Double.doubleToRawLongBits(input.asFloat()), asFloatReg(result)).emit(masm);
+                break;
+            }
             case Object: {
                 if (input.isNull()) {
                     new Clr(asRegister(result)).emit(masm);