changeset 6477:d93bff9fecb6

added temps used by a call to CallingConvention
author Doug Simon <doug.simon@oracle.com>
date Tue, 02 Oct 2012 13:48:16 +0200
parents 64d6e2343a68
children 62878ae057a5
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java
diffstat 2 files changed, 62 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java	Mon Oct 01 22:38:44 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java	Tue Oct 02 13:48:16 2012 +0200
@@ -28,8 +28,9 @@
 
 
 /**
- * A calling convention describes the locations in which the arguments for a call are placed
- * and the location in which the return value is placed if the call is not void.
+ * A calling convention describes the locations in which the arguments for a call are placed,
+ * the location in which the return value is placed if the call is not void and any
+ * temporary locations used (and killed) by the call.
  */
 public class CallingConvention {
 
@@ -82,10 +83,24 @@
      */
     private final Value[] argumentLocations;
 
-    public CallingConvention(int stackSize, Value returnLocation, Value... locations) {
-        this.argumentLocations = locations;
+    /**
+     * The locations used by the call in addition to the arguments are placed.
+     * From the perspective of register allocation, these locations are killed by the call.
+     */
+    private final Value[] temporaryLocations;
+
+    public CallingConvention(int stackSize, Value returnLocation, Value... argumentLocations) {
+        this(Value.NONE, stackSize, returnLocation, argumentLocations);
+    }
+
+    public CallingConvention(Value[] temporaryLocations, int stackSize, Value returnLocation, Value... argumentLocations) {
+        assert argumentLocations != null;
+        assert temporaryLocations != null;
+        assert returnLocation != null;
+        this.argumentLocations = argumentLocations;
         this.stackSize = stackSize;
         this.returnLocation = returnLocation;
+        this.temporaryLocations = temporaryLocations;
         assert verify();
     }
 
@@ -117,20 +132,55 @@
         return argumentLocations.length;
     }
 
+    /**
+     * Gets a location used by the call in addition to the arguments are placed.
+     * From the perspective of register allocation, these locations are killed by the call.
+     *
+     * @return the {@code index}'th temporary location used by the call
+     */
+    public Value getTemporary(int index) {
+        return temporaryLocations[index];
+    }
+
+    /**
+     * @return the number of temporary locations used by the call
+     */
+    public int getTemporaryCount() {
+        return temporaryLocations.length;
+    }
+
+    /**
+     * Gets the temporary locations used (and killed) by the call.
+     */
+    public Value[] getTemporaries() {
+        if (temporaryLocations.length == 0) {
+            return temporaryLocations;
+        }
+        return temporaryLocations.clone();
+    }
+
     @Override
     public String toString() {
-        StringBuilder result = new StringBuilder();
-        result.append("CallingConvention[");
+        StringBuilder sb = new StringBuilder();
+        sb.append("CallingConvention[");
         String sep = "";
         for (Value op : argumentLocations) {
-            result.append(sep).append(op);
+            sb.append(sep).append(op);
             sep = ", ";
         }
         if (returnLocation != Value.IllegalValue) {
-            result.append(" -> ").append(returnLocation);
+            sb.append(" -> ").append(returnLocation);
         }
-        result.append("]");
-        return result.toString();
+        if (temporaryLocations.length != 0) {
+            sb.append("; temps=");
+            sep = "";
+            for (Value op : temporaryLocations) {
+                sb.append(sep).append(op);
+                sep = ", ";
+            }
+        }
+        sb.append("]");
+        return sb.toString();
     }
 
     private boolean verify() {
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java	Mon Oct 01 22:38:44 2012 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java	Tue Oct 02 13:48:16 2012 +0200
@@ -30,6 +30,8 @@
 public abstract class Value implements Serializable {
     private static final long serialVersionUID = -6909397188697766469L;
 
+    public static final Value[] NONE = {};
+
     @SuppressWarnings("serial")
     public static final Value IllegalValue = new Value(Kind.Illegal) {
         @Override