changeset 9426:0f8683ac4009

Use register categories to determine spill slot size.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 30 Apr 2013 12:14:31 +0200
parents 3ec29630cfb4
children 334b014a70a3
files graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CalleeSaveLayout.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java
diffstat 5 files changed, 77 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java	Tue Apr 30 12:13:21 2013 +0200
+++ b/graal/com.oracle.graal.amd64/src/com/oracle/graal/amd64/AMD64.java	Tue Apr 30 12:14:31 2013 +0200
@@ -42,23 +42,23 @@
     // @formatter:off
 
     // General purpose CPU registers
-    public static final Register rax = new Register(0, 0, 8, "rax", CPU);
-    public static final Register rcx = new Register(1, 1, 8, "rcx", CPU);
-    public static final Register rdx = new Register(2, 2, 8, "rdx", CPU);
-    public static final Register rbx = new Register(3, 3, 8, "rbx", CPU);
-    public static final Register rsp = new Register(4, 4, 8, "rsp", CPU);
-    public static final Register rbp = new Register(5, 5, 8, "rbp", CPU);
-    public static final Register rsi = new Register(6, 6, 8, "rsi", CPU);
-    public static final Register rdi = new Register(7, 7, 8, "rdi", CPU);
+    public static final Register rax = new Register(0, 0, "rax", CPU);
+    public static final Register rcx = new Register(1, 1, "rcx", CPU);
+    public static final Register rdx = new Register(2, 2, "rdx", CPU);
+    public static final Register rbx = new Register(3, 3, "rbx", CPU);
+    public static final Register rsp = new Register(4, 4, "rsp", CPU);
+    public static final Register rbp = new Register(5, 5, "rbp", CPU);
+    public static final Register rsi = new Register(6, 6, "rsi", CPU);
+    public static final Register rdi = new Register(7, 7, "rdi", CPU);
 
-    public static final Register r8  = new Register(8,  8,  8, "r8", CPU);
-    public static final Register r9  = new Register(9,  9,  8, "r9", CPU);
-    public static final Register r10 = new Register(10, 10, 8, "r10", CPU);
-    public static final Register r11 = new Register(11, 11, 8, "r11", CPU);
-    public static final Register r12 = new Register(12, 12, 8, "r12", CPU);
-    public static final Register r13 = new Register(13, 13, 8, "r13", CPU);
-    public static final Register r14 = new Register(14, 14, 8, "r14", CPU);
-    public static final Register r15 = new Register(15, 15, 8, "r15", CPU);
+    public static final Register r8  = new Register(8,  8,  "r8", CPU);
+    public static final Register r9  = new Register(9,  9,  "r9", CPU);
+    public static final Register r10 = new Register(10, 10, "r10", CPU);
+    public static final Register r11 = new Register(11, 11, "r11", CPU);
+    public static final Register r12 = new Register(12, 12, "r12", CPU);
+    public static final Register r13 = new Register(13, 13, "r13", CPU);
+    public static final Register r14 = new Register(14, 14, "r14", CPU);
+    public static final Register r15 = new Register(15, 15, "r15", CPU);
 
     public static final Register[] cpuRegisters = {
         rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi,
@@ -66,23 +66,23 @@
     };
 
     // XMM registers
-    public static final Register xmm0 = new Register(16, 0, 8, "xmm0", XMM);
-    public static final Register xmm1 = new Register(17, 1, 8, "xmm1", XMM);
-    public static final Register xmm2 = new Register(18, 2, 8, "xmm2", XMM);
-    public static final Register xmm3 = new Register(19, 3, 8, "xmm3", XMM);
-    public static final Register xmm4 = new Register(20, 4, 8, "xmm4", XMM);
-    public static final Register xmm5 = new Register(21, 5, 8, "xmm5", XMM);
-    public static final Register xmm6 = new Register(22, 6, 8, "xmm6", XMM);
-    public static final Register xmm7 = new Register(23, 7, 8, "xmm7", XMM);
+    public static final Register xmm0 = new Register(16, 0, "xmm0", XMM);
+    public static final Register xmm1 = new Register(17, 1, "xmm1", XMM);
+    public static final Register xmm2 = new Register(18, 2, "xmm2", XMM);
+    public static final Register xmm3 = new Register(19, 3, "xmm3", XMM);
+    public static final Register xmm4 = new Register(20, 4, "xmm4", XMM);
+    public static final Register xmm5 = new Register(21, 5, "xmm5", XMM);
+    public static final Register xmm6 = new Register(22, 6, "xmm6", XMM);
+    public static final Register xmm7 = new Register(23, 7, "xmm7", XMM);
 
-    public static final Register xmm8 =  new Register(24,  8, 8, "xmm8",  XMM);
-    public static final Register xmm9 =  new Register(25,  9, 8, "xmm9",  XMM);
-    public static final Register xmm10 = new Register(26, 10, 8, "xmm10", XMM);
-    public static final Register xmm11 = new Register(27, 11, 8, "xmm11", XMM);
-    public static final Register xmm12 = new Register(28, 12, 8, "xmm12", XMM);
-    public static final Register xmm13 = new Register(29, 13, 8, "xmm13", XMM);
-    public static final Register xmm14 = new Register(30, 14, 8, "xmm14", XMM);
-    public static final Register xmm15 = new Register(31, 15, 8, "xmm15", XMM);
+    public static final Register xmm8 =  new Register(24,  8, "xmm8",  XMM);
+    public static final Register xmm9 =  new Register(25,  9, "xmm9",  XMM);
+    public static final Register xmm10 = new Register(26, 10, "xmm10", XMM);
+    public static final Register xmm11 = new Register(27, 11, "xmm11", XMM);
+    public static final Register xmm12 = new Register(28, 12, "xmm12", XMM);
+    public static final Register xmm13 = new Register(29, 13, "xmm13", XMM);
+    public static final Register xmm14 = new Register(30, 14, "xmm14", XMM);
+    public static final Register xmm15 = new Register(31, 15, "xmm15", XMM);
 
     public static final Register[] xmmRegisters = {
         xmm0, xmm1, xmm2,  xmm3,  xmm4,  xmm5,  xmm6,  xmm7,
@@ -99,7 +99,7 @@
     /**
      * Register used to construct an instruction-relative address.
      */
-    public static final Register rip = new Register(32, -1, 0, "rip", SPECIAL);
+    public static final Register rip = new Register(32, -1, "rip", SPECIAL);
 
     public static final Register[] allRegisters = {
         rax,  rcx,  rdx,   rbx,   rsp,   rbp,   rsi,   rdi,
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CalleeSaveLayout.java	Tue Apr 30 12:13:21 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CalleeSaveLayout.java	Tue Apr 30 12:14:31 2013 +0200
@@ -24,6 +24,8 @@
 
 import java.util.*;
 
+import com.oracle.graal.api.meta.*;
+
 /**
  * The callee save area (CSA) is a contiguous space in a stack frame used to save (and restore) the
  * values of the caller's registers. This class describes the layout of a CSA in terms of its
@@ -69,7 +71,7 @@
      *            CSA
      * @param registers the registers that can be saved in the CSA
      */
-    public CalleeSaveLayout(int frameOffsetToCSA, int size, int slotSize, Register... registers) {
+    public CalleeSaveLayout(Architecture architecture, int frameOffsetToCSA, int size, int slotSize, Register... registers) {
         this.frameOffsetToCSA = frameOffsetToCSA;
         assert slotSize == 0 || CodeUtil.isPowerOf2(slotSize);
         this.slotSize = slotSize;
@@ -86,7 +88,8 @@
             if (offset > maxOffset) {
                 maxOffset = offset;
             }
-            offset += reg.spillSlotSize;
+            PlatformKind kind = architecture.getLargestStorableKind(reg.getRegisterCategory());
+            offset += architecture.getSizeInBytes(kind);
         }
         if (size == -1) {
             this.size = offset;
@@ -103,7 +106,8 @@
             int index = offset / slotSize;
             regNumToIndex[reg.number] = index;
             indexToReg[index] = reg;
-            offset += reg.spillSlotSize;
+            PlatformKind kind = architecture.getLargestStorableKind(reg.getRegisterCategory());
+            offset += architecture.getSizeInBytes(kind);
         }
     }
 
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java	Tue Apr 30 12:13:21 2013 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java	Tue Apr 30 12:14:31 2013 +0200
@@ -39,15 +39,15 @@
     /**
      * Invalid register.
      */
-    public static final Register None = new Register(-1, -1, 0, "noreg", SPECIAL);
+    public static final Register None = new Register(-1, -1, "noreg", SPECIAL);
 
     /**
      * Frame pointer of the current method. All spill slots and outgoing stack-based arguments are
      * addressed relative to this register.
      */
-    public static final Register Frame = new Register(-2, -2, 0, "framereg", SPECIAL);
+    public static final Register Frame = new Register(-2, -2, "framereg", SPECIAL);
 
-    public static final Register CallerFrame = new Register(-3, -3, 0, "callerframereg", SPECIAL);
+    public static final Register CallerFrame = new Register(-3, -3, "callerframereg", SPECIAL);
 
     /**
      * The identifier for this register that is unique across all the registers in a
@@ -74,11 +74,6 @@
     }
 
     /**
-     * The size of the stack slot used to spill the value of this register.
-     */
-    public final int spillSlotSize;
-
-    /**
      * A platform specific register category that describes which values can be stored in a
      * register.
      */
@@ -112,14 +107,12 @@
      * 
      * @param number unique identifier for the register
      * @param encoding the target machine encoding for the register
-     * @param spillSlotSize the size of the stack slot used to spill the value of the register
      * @param name the mnemonic name for the register
      * @param registerCategory the register category
      */
-    public Register(int number, int encoding, int spillSlotSize, String name, RegisterCategory registerCategory) {
+    public Register(int number, int encoding, String name, RegisterCategory registerCategory) {
         this.number = number;
         this.name = name;
-        this.spillSlotSize = spillSlotSize;
         this.registerCategory = registerCategory;
         this.encoding = encoding;
         this.values = new HashMap<>();
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Tue Apr 30 12:13:21 2013 +0200
+++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java	Tue Apr 30 12:14:31 2013 +0200
@@ -124,7 +124,7 @@
                 xmm0, xmm1, xmm2,  xmm3,  xmm4,  xmm5,  xmm6,  xmm7,
                 xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15
             };
-            csl = new CalleeSaveLayout(0, -1, 8, regs);
+            csl = new CalleeSaveLayout(architecture, 0, -1, 8, regs);
         } else {
             csl = null;
         }
--- a/graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java	Tue Apr 30 12:13:21 2013 +0200
+++ b/graal/com.oracle.graal.ptx/src/com/oracle/graal/ptx/PTX.java	Tue Apr 30 12:14:31 2013 +0200
@@ -52,23 +52,23 @@
      */
 
     // General purpose registers
-    public static final Register r0  = new Register(0,  0,  8, "r0",  CPU);
-    public static final Register r1  = new Register(1,  1,  8, "r1",  CPU);
-    public static final Register r2  = new Register(2,  2,  8, "r2",  CPU);
-    public static final Register r3  = new Register(3,  3,  8, "r3",  CPU);
-    public static final Register r4  = new Register(4,  4,  8, "r4",  CPU);
-    public static final Register r5  = new Register(5,  5,  8, "r5",  CPU);
-    public static final Register r6  = new Register(6,  6,  8, "r6",  CPU);
-    public static final Register r7  = new Register(7,  7,  8, "r7",  CPU);
+    public static final Register r0  = new Register(0,  0,  "r0",  CPU);
+    public static final Register r1  = new Register(1,  1,  "r1",  CPU);
+    public static final Register r2  = new Register(2,  2,  "r2",  CPU);
+    public static final Register r3  = new Register(3,  3,  "r3",  CPU);
+    public static final Register r4  = new Register(4,  4,  "r4",  CPU);
+    public static final Register r5  = new Register(5,  5,  "r5",  CPU);
+    public static final Register r6  = new Register(6,  6,  "r6",  CPU);
+    public static final Register r7  = new Register(7,  7,  "r7",  CPU);
 
-    public static final Register r8  = new Register(8,  8,  8, "r8",  CPU);
-    public static final Register r9  = new Register(9,  9,  8, "r9",  CPU);
-    public static final Register r10 = new Register(10, 10, 8, "r10", CPU);
-    public static final Register r11 = new Register(11, 11, 8, "r11", CPU);
-    public static final Register r12 = new Register(12, 12, 8, "r12", CPU);
-    public static final Register r13 = new Register(13, 13, 8, "r13", CPU);
-    public static final Register r14 = new Register(14, 14, 8, "r14", CPU);
-    public static final Register r15 = new Register(15, 15, 8, "r15", CPU);
+    public static final Register r8  = new Register(8,  8,  "r8",  CPU);
+    public static final Register r9  = new Register(9,  9,  "r9",  CPU);
+    public static final Register r10 = new Register(10, 10, "r10", CPU);
+    public static final Register r11 = new Register(11, 11, "r11", CPU);
+    public static final Register r12 = new Register(12, 12, "r12", CPU);
+    public static final Register r13 = new Register(13, 13, "r13", CPU);
+    public static final Register r14 = new Register(14, 14, "r14", CPU);
+    public static final Register r15 = new Register(15, 15, "r15", CPU);
 
     public static final Register[] gprRegisters = {
         r0,  r1,  r2,  r3,  r4,  r5,  r6,  r7,
@@ -76,23 +76,23 @@
     };
 
     // Floating point registers
-    public static final Register f0  = new Register(16, 0,  8, "f0",  FPU);
-    public static final Register f1  = new Register(17, 1,  8, "f1",  FPU);
-    public static final Register f2  = new Register(18, 2,  8, "f2",  FPU);
-    public static final Register f3  = new Register(19, 3,  8, "f3",  FPU);
-    public static final Register f4  = new Register(20, 4,  8, "f4",  FPU);
-    public static final Register f5  = new Register(21, 5,  8, "f5",  FPU);
-    public static final Register f6  = new Register(22, 6,  8, "f6",  FPU);
-    public static final Register f7  = new Register(23, 7,  8, "f7",  FPU);
+    public static final Register f0  = new Register(16, 0,  "f0",  FPU);
+    public static final Register f1  = new Register(17, 1,  "f1",  FPU);
+    public static final Register f2  = new Register(18, 2,  "f2",  FPU);
+    public static final Register f3  = new Register(19, 3,  "f3",  FPU);
+    public static final Register f4  = new Register(20, 4,  "f4",  FPU);
+    public static final Register f5  = new Register(21, 5,  "f5",  FPU);
+    public static final Register f6  = new Register(22, 6,  "f6",  FPU);
+    public static final Register f7  = new Register(23, 7,  "f7",  FPU);
 
-    public static final Register f8  = new Register(24, 8,  8, "f8",  FPU);
-    public static final Register f9  = new Register(25, 9,  8, "f9",  FPU);
-    public static final Register f10 = new Register(26, 10, 8, "f10", FPU);
-    public static final Register f11 = new Register(27, 11, 8, "f11", FPU);
-    public static final Register f12 = new Register(28, 12, 8, "f12", FPU);
-    public static final Register f13 = new Register(29, 13, 8, "f13", FPU);
-    public static final Register f14 = new Register(30, 14, 8, "f14", FPU);
-    public static final Register f15 = new Register(31, 15, 8, "f15", FPU);
+    public static final Register f8  = new Register(24, 8,  "f8",  FPU);
+    public static final Register f9  = new Register(25, 9,  "f9",  FPU);
+    public static final Register f10 = new Register(26, 10, "f10", FPU);
+    public static final Register f11 = new Register(27, 11, "f11", FPU);
+    public static final Register f12 = new Register(28, 12, "f12", FPU);
+    public static final Register f13 = new Register(29, 13, "f13", FPU);
+    public static final Register f14 = new Register(30, 14, "f14", FPU);
+    public static final Register f15 = new Register(31, 15, "f15", FPU);
 
     public static final Register[] fpuRegisters = {
         f0,  f1,  f2,  f3,  f4,  f5,  f6,  f7,