# HG changeset patch # User Doug Simon # Date 1349178496 -7200 # Node ID d93bff9fecb6a15c265390bc5663e70c5a6a2971 # Parent 64d6e2343a68457e239f2fc73ffcb20394235744 added temps used by a call to CallingConvention diff -r 64d6e2343a68 -r d93bff9fecb6 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java --- 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() { diff -r 64d6e2343a68 -r d93bff9fecb6 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java --- 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