changeset 5774:a1db0ea58b53

Removed left over Ci* prefixed identifiers
author Doug Simon <doug.simon@oracle.com>
date Thu, 05 Jul 2012 21:39:22 +0200
parents 772118da9f68
children 2c088af17e59
files graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Address.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BailoutException.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DebugInfo.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RegisterValue.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ControlFlowOptimizer.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CheckCastEliminationPhase.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirAssembler.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetMethod.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotXirGenerator.java graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackStore.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/CiXirAssembler.java graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirAssembler.java graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirTemplate.java graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/package-info.java
diffstat 31 files changed, 1066 insertions(+), 1096 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Address.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Address.java	Thu Jul 05 21:39:22 2012 +0200
@@ -45,7 +45,8 @@
     private final int displacement;
 
     /**
-     * Creates a {@code CiAddress} with given base register, no scaling and no displacement.
+     * Creates an {@link Address} with given base register, no scaling and no displacement.
+     *
      * @param kind the kind of the value being addressed
      * @param base the base register
      */
@@ -54,7 +55,8 @@
     }
 
     /**
-     * Creates a {@code CiAddress} with given base register, no scaling and a given displacement.
+     * Creates an {@link Address} with given base register, no scaling and a given displacement.
+     *
      * @param kind the kind of the value being addressed
      * @param base the base register
      * @param displacement the displacement
@@ -64,8 +66,9 @@
     }
 
     /**
-     * Creates a {@code CiAddress} with given base and index registers, scaling and displacement.
-     * This is the most general constructor..
+     * Creates an {@link Address} with given base and index registers, scaling and displacement.
+     * This is the most general constructor.
+     *
      * @param kind the kind of the value being addressed
      * @param base the base register
      * @param index the index register
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BailoutException.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/BailoutException.java	Thu Jul 05 21:39:22 2012 +0200
@@ -25,7 +25,7 @@
 import java.util.*;
 
 /**
- * {@code CiBailout} is thrown when the compiler refuses to compile a method because of problems with the method.
+ * Exception thrown when the compiler refuses to compile a method because of problems with the method.
  * e.g. bytecode wouldn't verify, too big, JSR/ret too complicated, etc. This exception is <i>not</i>
  * meant to indicate problems with the compiler itself.
  */
@@ -34,7 +34,8 @@
     public static final long serialVersionUID = 8974598793458772L;
 
     /**
-     * Create a new {@code CiBailout}.
+     * Creates a new {@link BailoutException}.
+     *
      * @param reason a message indicating the reason
      */
     public BailoutException(String reason) {
@@ -42,7 +43,8 @@
     }
 
     /**
-     * Create a new {@code CiBailout}.
+     * Creates a new {@link BailoutException}.
+     *
      * @param args parameters to the formatter
      */
     public BailoutException(String format, Object... args) {
@@ -50,7 +52,8 @@
     }
 
     /**
-     * Create a new {@code CiBailout} t due to an internal exception being thrown.
+     * Creates a new {@link BailoutException} due to an internal exception being thrown.
+     *
      * @param reason a message indicating the reason
      * @param cause the throwable that was the cause of the bailout
      */
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DebugInfo.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/DebugInfo.java	Thu Jul 05 21:39:22 2012 +0200
@@ -38,7 +38,7 @@
     private final BitSet frameRefMap;
 
     /**
-     * Creates a new {@code CiDebugInfo} from the given values.
+     * Creates a new {@link DebugInfo} from the given values.
      *
      * @param codePos the {@linkplain BytecodePosition code position} or {@linkplain BytecodeFrame frame} info
      * @param registerRefMap the register map
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/Register.java	Thu Jul 05 21:39:22 2012 +0200
@@ -104,7 +104,7 @@
     }
 
     /**
-     * Creates a {@code CiRegister} instance.
+     * Creates a {@link Register} instance.
      *
      * @param number unique identifier for the register
      * @param encoding the target machine encoding for the register
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RegisterValue.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/RegisterValue.java	Thu Jul 05 21:39:22 2012 +0200
@@ -25,8 +25,8 @@
 import com.oracle.graal.api.meta.*;
 
 /**
- * Denotes a register that stores a value of a fixed kind. There is exactly one (canonical) instance of {@code
- * CiRegisterValue} for each ({@link Register}, {@link Kind}) pair. Use {@link Register#asValue(Kind)} to
+ * Denotes a register that stores a value of a fixed kind. There is exactly one (canonical) instance of {@link
+ * RegisterValue} for each ({@link Register}, {@link Kind}) pair. Use {@link Register#asValue(Kind)} to
  * retrieve the canonical {@link RegisterValue} instance for a given (register,kind) pair.
  */
 public final class RegisterValue extends Value {
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/TargetDescription.java	Thu Jul 05 21:39:22 2012 +0200
@@ -53,7 +53,7 @@
     public final int wordSize;
 
     /**
-     * The CiKind to be used for representing raw pointers and CPU registers.
+     * The kind to be used for representing raw pointers and CPU registers.
      */
     public final Kind wordKind;
 
--- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/VirtualObject.java	Thu Jul 05 21:39:22 2012 +0200
@@ -36,12 +36,17 @@
     private final int id;
 
     /**
-     * Creates a new CiVirtualObject for the given type, with the given fields. If the type is an instance class then the values array needs to have one entry for each field, ordered in
-     * like the fields returned by {@link ResolvedJavaType#declaredFields()}. If the type is an array then the length of the values array determines the reallocated array length.
-     * @param type the type of the object whose allocation was removed during compilation. This can be either an instance of an array type.
+     * Creates a new {@link VirtualObject} for the given type, with the given fields. If the type is an instance class
+     * then the values array needs to have one entry for each field, ordered in like the fields returned by
+     * {@link ResolvedJavaType#declaredFields()}. If the type is an array then the length of the values array determines
+     * the reallocated array length.
+     *
+     * @param type the type of the object whose allocation was removed during compilation. This can be either an
+     *            instance of an array type.
      * @param values an array containing all the values to be stored into the object when it is recreated.
-     * @param id a unique id that identifies the object within the debug information for one position in the compiled code.
-     * @return a new CiVirtualObject instance.
+     * @param id a unique id that identifies the object within the debug information for one position in the compiled
+     *            code.
+     * @return a new {@link VirtualObject} instance.
      */
     public static VirtualObject get(JavaType type, Value[] values, int id) {
         return new VirtualObject(type, values, id);
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Constant.java	Thu Jul 05 21:39:22 2012 +0200
@@ -397,6 +397,7 @@
 
     /**
      * Creates a boxed object constant.
+     *
      * @param o the object value to box
      * @return a boxed copy of {@code value}
      */
@@ -410,8 +411,9 @@
     /**
      * Creates a boxed constant for the given kind from an Object.
      * The object needs to be of the Java boxed type corresponding to the kind.
+     *
      * @param kind the kind of the constant to create
-     * @param value the Java boxed value: a Byte instance for CiKind Byte, etc.
+     * @param value the Java boxed value: a {@link Byte} instance for {@link Kind#Byte}, etc.
      * @return the boxed copy of {@code value}
      */
     public static Constant forBoxed(Kind kind, Object value) {
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaUtil.java	Thu Jul 05 21:39:22 2012 +0200
@@ -369,7 +369,8 @@
      *     java.lang.String.valueOf(String.java:2930) [bci: 12]
      * </pre>
      *
-     * Otherwise, the string returned is the value of {@code CiUtil.format("%H.%n(%p)"}, suffixed by the bci location.
+     * Otherwise, the string returned is the value of applying {@link #format(String, JavaMethod)}
+     * with the format string {@code "%H.%n(%p)"}, suffixed by the bci location.
      * For example:
      *
      * <pre>
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ControlFlowOptimizer.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/ControlFlowOptimizer.java	Thu Jul 05 21:39:22 2012 +0200
@@ -211,7 +211,7 @@
                 // this may lead to unnecesary return instructions in the final code
 
                 assert curLastOp.info == null : "return instructions do not have debug information";
-                CiValue returnOpr = curLastOp.input(0);
+                Value returnOpr = curLastOp.input(0);
 
                 for (int j = block.numberOfPreds() - 1; j >= 0; j--) {
                     LIRBlock pred = block.predAt(j);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/DebugInfoBuilder.java	Thu Jul 05 21:39:22 2012 +0200
@@ -62,8 +62,8 @@
                 }
                 current = current.outerFrameState();
             } while (current != null);
-            // fill in the CiVirtualObject values:
-            // during this process new CiVirtualObjects might be discovered, so repeat until no more changes occur.
+            // fill in the VirtualObject values:
+            // during this process new VirtualObjects might be discovered, so repeat until no more changes occur.
             boolean changed;
             do {
                 changed = false;
@@ -73,7 +73,7 @@
                         VirtualObjectNode vobj = entry.getKey();
                         if (vobj instanceof BoxedVirtualObjectNode) {
                             BoxedVirtualObjectNode boxedVirtualObjectNode = (BoxedVirtualObjectNode) vobj;
-                            entry.getValue().setValues(new Value[]{toCiValue(boxedVirtualObjectNode.getUnboxedValue())});
+                            entry.getValue().setValues(new Value[]{toValue(boxedVirtualObjectNode.getUnboxedValue())});
                         } else {
                             Value[] values = new Value[vobj.fieldsCount()];
                             entry.getValue().setValues(values);
@@ -82,7 +82,7 @@
                                 VirtualObjectState currentField = objectStates.get(vobj);
                                 assert currentField != null;
                                 for (int i = 0; i < vobj.fieldsCount(); i++) {
-                                    values[i] = toCiValue(currentField.fieldValues().get(i));
+                                    values[i] = toValue(currentField.fieldValues().get(i));
                                 }
                             }
                         }
@@ -104,17 +104,17 @@
 
         Value[] values = new Value[numLocals + numStack + numLocks];
         for (int i = 0; i < numLocals; i++) {
-            values[i] = toCiValue(state.localAt(i));
+            values[i] = toValue(state.localAt(i));
         }
         for (int i = 0; i < numStack; i++) {
-            values[numLocals + i] = toCiValue(state.stackAt(i));
+            values[numLocals + i] = toValue(state.stackAt(i));
         }
 
         LockScope nextLock = locks;
         for (int i = numLocks - 1; i >= 0; i--) {
             assert locks != null && nextLock.inliningIdentifier == state.inliningIdentifier() && nextLock.stateDepth == i;
 
-            Value owner = toCiValue(nextLock.monitor.object());
+            Value owner = toValue(nextLock.monitor.object());
             Value lockData = nextLock.lockData;
             boolean eliminated = nextLock.monitor.eliminated();
             values[numLocals + numStack + nextLock.stateDepth] = new MonitorValue(owner, lockData, eliminated);
@@ -135,7 +135,7 @@
         return frame;
     }
 
-    private Value toCiValue(ValueNode value) {
+    private Value toValue(ValueNode value) {
         if (value instanceof VirtualObjectNode) {
             VirtualObjectNode obj = (VirtualObjectNode) value;
             VirtualObject ciObj = virtualObjects.get(value);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java	Thu Jul 05 21:39:22 2012 +0200
@@ -55,13 +55,13 @@
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.virtual.*;
 import com.oracle.max.asm.*;
-import com.oracle.max.cri.xir.CiXirAssembler.XirConstant;
-import com.oracle.max.cri.xir.CiXirAssembler.XirInstruction;
-import com.oracle.max.cri.xir.CiXirAssembler.XirMark;
-import com.oracle.max.cri.xir.CiXirAssembler.XirOperand;
-import com.oracle.max.cri.xir.CiXirAssembler.XirParameter;
-import com.oracle.max.cri.xir.CiXirAssembler.XirRegister;
-import com.oracle.max.cri.xir.CiXirAssembler.XirTemp;
+import com.oracle.max.cri.xir.XirAssembler.XirConstant;
+import com.oracle.max.cri.xir.XirAssembler.XirInstruction;
+import com.oracle.max.cri.xir.XirAssembler.XirMark;
+import com.oracle.max.cri.xir.XirAssembler.XirOperand;
+import com.oracle.max.cri.xir.XirAssembler.XirParameter;
+import com.oracle.max.cri.xir.XirAssembler.XirRegister;
+import com.oracle.max.cri.xir.XirAssembler.XirTemp;
 import com.oracle.max.cri.xir.*;
 import com.oracle.max.criutils.*;
 
@@ -504,7 +504,7 @@
     }
 
     private static boolean canBeNullCheck(LocationNode location) {
-        // TODO: Make this part of CiTarget
+        // TODO: Make this part of TargetDescription
         return !(location instanceof IndexedLocationNode) && location.displacement() < 4096;
     }
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CheckCastEliminationPhase.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CheckCastEliminationPhase.java	Thu Jul 05 21:39:22 2012 +0200
@@ -166,7 +166,7 @@
             // this piece of code handles phis (merges the types and knownNull/knownNotNull of the values)
             if (!(merge instanceof LoopBeginNode)) {
                 for (PhiNode phi : merge.phis()) {
-                    if (phi.type() == PhiType.Value && phi.kind() == CiKind.Object) {
+                    if (phi.type() == PhiType.Value && phi.kind() == Kind.Object) {
                         ValueNode firstValue = phi.valueAt(0);
                         RiResolvedType type = getNodeType(firstValue);
                         boolean notNull = knownNotNull.contains(firstValue);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java	Thu Jul 05 21:39:22 2012 +0200
@@ -76,7 +76,7 @@
 
     public abstract TargetMethodAssembler newAssembler(FrameMap frameMap, LIR lir);
 
-    public abstract CiXirAssembler newXirAssembler();
+    public abstract XirAssembler newXirAssembler();
 
     /**
      * Emits code to do stack overflow checking.
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64LIRGenerator.java	Thu Jul 05 21:39:22 2012 +0200
@@ -32,7 +32,7 @@
 import com.oracle.max.asm.*;
 import com.oracle.max.asm.target.amd64.*;
 import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag;
-import com.oracle.max.cri.xir.CiXirAssembler.XirMark;
+import com.oracle.max.cri.xir.XirAssembler.XirMark;
 import com.oracle.max.cri.xir.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.code.CompilationResult.*;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirAssembler.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirAssembler.java	Thu Jul 05 21:39:22 2012 +0200
@@ -32,10 +32,10 @@
 import com.oracle.max.cri.xir.*;
 
 /**
- * AMD64 version of {@link CiXirAssembler}.
+ * AMD64 version of {@link XirAssembler}.
  *
  */
-public class AMD64XirAssembler extends CiXirAssembler {
+public class AMD64XirAssembler extends XirAssembler {
     public AMD64XirAssembler(TargetDescription target) {
         super(target);
     }
@@ -216,7 +216,7 @@
     }
 
     @Override
-    public CiXirAssembler copy() {
+    public XirAssembler copy() {
         return new AMD64XirAssembler(target);
     }
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/amd64/AMD64XirOp.java	Thu Jul 05 21:39:22 2012 +0200
@@ -39,10 +39,10 @@
 import com.oracle.max.asm.target.amd64.*;
 import com.oracle.max.asm.target.amd64.AMD64Assembler.ConditionFlag;
 import com.oracle.max.cri.xir.*;
-import com.oracle.max.cri.xir.CiXirAssembler.RuntimeCallInformation;
-import com.oracle.max.cri.xir.CiXirAssembler.XirInstruction;
-import com.oracle.max.cri.xir.CiXirAssembler.XirLabel;
-import com.oracle.max.cri.xir.CiXirAssembler.XirMark;
+import com.oracle.max.cri.xir.XirAssembler.RuntimeCallInformation;
+import com.oracle.max.cri.xir.XirAssembler.XirInstruction;
+import com.oracle.max.cri.xir.XirAssembler.XirLabel;
+import com.oracle.max.cri.xir.XirAssembler.XirMark;
 
 public class AMD64XirOp extends LIRXirInstruction {
     public AMD64XirOp(XirSnippet snippet, Value[] operands, Value outputOperand, Value[] inputs, Value[] temps, int[] inputOperandIndices, int[] tempOperandIndices, int outputOperandIndex,
@@ -179,7 +179,7 @@
                 }
 
                 case PointerLoadDisp: {
-                    CiXirAssembler.AddressAccessInformation addressInformation = (CiXirAssembler.AddressAccessInformation) inst.extra;
+                    XirAssembler.AddressAccessInformation addressInformation = (XirAssembler.AddressAccessInformation) inst.extra;
                     boolean canTrap = addressInformation.canTrap;
 
                     Address.Scale scale = addressInformation.scale;
@@ -206,7 +206,7 @@
                 }
 
                 case LoadEffectiveAddress: {
-                    CiXirAssembler.AddressAccessInformation addressInformation = (CiXirAssembler.AddressAccessInformation) inst.extra;
+                    XirAssembler.AddressAccessInformation addressInformation = (XirAssembler.AddressAccessInformation) inst.extra;
 
                     Address.Scale scale = addressInformation.scale;
                     int displacement = addressInformation.disp;
@@ -223,7 +223,7 @@
                 }
 
                 case PointerStoreDisp: {
-                    CiXirAssembler.AddressAccessInformation addressInformation = (CiXirAssembler.AddressAccessInformation) inst.extra;
+                    XirAssembler.AddressAccessInformation addressInformation = (XirAssembler.AddressAccessInformation) inst.extra;
                     boolean canTrap = addressInformation.canTrap;
 
                     Address.Scale scale = addressInformation.scale;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetMethod.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotTargetMethod.java	Thu Jul 05 21:39:22 2012 +0200
@@ -30,28 +30,28 @@
 import com.oracle.graal.hotspot.meta.*;
 
 /**
- * CiTargetMethod augmented with HotSpot-specific information.
+ * Augments a {@link CompilationResult} with HotSpot-specific information.
  */
 public final class HotSpotTargetMethod extends CompilerObject {
 
     private static final long serialVersionUID = 7807321392203253218L;
-    public final CompilationResult targetMethod;
+    public final CompilationResult compResult;
     public final HotSpotResolvedJavaMethod method; // used only for methods
     public final String name; // used only for stubs
 
     public final Site[] sites;
     public final ExceptionHandler[] exceptionHandlers;
 
-    public HotSpotTargetMethod(HotSpotResolvedJavaMethod method, CompilationResult targetMethod) {
+    public HotSpotTargetMethod(HotSpotResolvedJavaMethod method, CompilationResult compResult) {
         this.method = method;
-        this.targetMethod = targetMethod;
+        this.compResult = compResult;
         this.name = null;
 
-        sites = getSortedSites(targetMethod);
-        if (targetMethod.getExceptionHandlers() == null) {
+        sites = getSortedSites(compResult);
+        if (compResult.getExceptionHandlers() == null) {
             exceptionHandlers = null;
         } else {
-            exceptionHandlers = targetMethod.getExceptionHandlers().toArray(new ExceptionHandler[targetMethod.getExceptionHandlers().size()]);
+            exceptionHandlers = compResult.getExceptionHandlers().toArray(new ExceptionHandler[compResult.getExceptionHandlers().size()]);
         }
     }
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/MethodFilter.java	Thu Jul 05 21:39:22 2012 +0200
@@ -107,7 +107,7 @@
     }
 
     public boolean matches(JavaMethod o) {
-        // check method name first, since CiUtil.toJavaName is expensive
+        // check method name first, since MetaUtil.toJavaName is expensive
         if (methodName != null && !methodName.matcher(o.name()).matches()) {
             return false;
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotXirGenerator.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotXirGenerator.java	Thu Jul 05 21:39:22 2012 +0200
@@ -39,11 +39,11 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.max.asm.target.amd64.*;
 import com.oracle.max.cri.xir.*;
-import com.oracle.max.cri.xir.CiXirAssembler.XirConstant;
-import com.oracle.max.cri.xir.CiXirAssembler.XirLabel;
-import com.oracle.max.cri.xir.CiXirAssembler.XirMark;
-import com.oracle.max.cri.xir.CiXirAssembler.XirOperand;
-import com.oracle.max.cri.xir.CiXirAssembler.XirParameter;
+import com.oracle.max.cri.xir.XirAssembler.XirConstant;
+import com.oracle.max.cri.xir.XirAssembler.XirLabel;
+import com.oracle.max.cri.xir.XirAssembler.XirMark;
+import com.oracle.max.cri.xir.XirAssembler.XirOperand;
+import com.oracle.max.cri.xir.XirAssembler.XirParameter;
 
 public class HotSpotXirGenerator implements RiXirGenerator {
 
@@ -77,7 +77,7 @@
     private final HotSpotGraalRuntime compiler;
 
 
-    private CiXirAssembler globalAsm;
+    private XirAssembler globalAsm;
 
     public HotSpotXirGenerator(HotSpotVMConfig config, TargetDescription target, RegisterConfig registerConfig, HotSpotGraalRuntime compiler) {
         this.config = config;
@@ -86,7 +86,7 @@
         this.compiler = compiler;
     }
 
-    private XirConstant wordConst(CiXirAssembler asm, long value) {
+    private XirConstant wordConst(XirAssembler asm, long value) {
         if (target.wordKind == Kind.Long) {
             return asm.createConstant(Constant.forLong(value));
         } else {
@@ -107,7 +107,7 @@
     private SimpleTemplates invokeInterfaceTemplates = new SimpleTemplates(NULL_CHECK) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
+        protected XirTemplate create(XirAssembler asm, long flags) {
             asm.restart();
             XirParameter receiver = asm.createInputParameter("receiver", Kind.Object);
             XirParameter addr = asm.createConstantInputParameter("addr", target.wordKind);
@@ -128,7 +128,7 @@
     private SimpleTemplates invokeVirtualTemplates = new SimpleTemplates(NULL_CHECK) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
+        protected XirTemplate create(XirAssembler asm, long flags) {
             asm.restart();
             XirParameter receiver = asm.createInputParameter("receiver", Kind.Object);
             XirParameter addr = asm.createConstantInputParameter("addr", target.wordKind);
@@ -149,7 +149,7 @@
     private IndexTemplates inlinedInvokeVirtualTemplates = new IndexTemplates(NULL_CHECK) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags, int vtableEntryOffset) {
+        protected XirTemplate create(XirAssembler asm, long flags, int vtableEntryOffset) {
             asm.restart();
             XirParameter receiver = asm.createInputParameter("receiver", Kind.Object);
             XirOperand temp = asm.createRegisterTemp("temp", target.wordKind, AMD64.rax);
@@ -174,7 +174,7 @@
     private SimpleTemplates invokeSpecialTemplates = new SimpleTemplates(NULL_CHECK) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
+        protected XirTemplate create(XirAssembler asm, long flags) {
             asm.restart();
             XirParameter receiver = asm.createInputParameter("receiver", Kind.Object);
             XirParameter addr = asm.createConstantInputParameter("addr", target.wordKind);
@@ -203,7 +203,7 @@
     private SimpleTemplates invokeStaticTemplates = new SimpleTemplates() {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
+        protected XirTemplate create(XirAssembler asm, long flags) {
             asm.restart();
             XirParameter addr = asm.createConstantInputParameter("addr", target.wordKind);
 
@@ -226,7 +226,7 @@
     private SimpleTemplates monitorEnterTemplates = new SimpleTemplates(NULL_CHECK) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
+        protected XirTemplate create(XirAssembler asm, long flags) {
             asm.restart(Kind.Void);
             XirParameter object = asm.createInputParameter("object", Kind.Object);
             XirParameter lock = asm.createInputParameter("lock", target.wordKind);
@@ -265,7 +265,7 @@
     private SimpleTemplates monitorExitTemplates = new SimpleTemplates(NULL_CHECK) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
+        protected XirTemplate create(XirAssembler asm, long flags) {
             asm.restart(Kind.Void);
             XirParameter object = asm.createInputParameter("object", Kind.Object);
             XirParameter lock = asm.createInputParameter("lock", target.wordKind);
@@ -288,7 +288,7 @@
     private final IndexTemplates newInstanceTemplates = new IndexTemplates() {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags, int size) {
+        protected XirTemplate create(XirAssembler asm, long flags, int size) {
             XirOperand result = asm.restart(target.wordKind);
             XirOperand hub = asm.createInputParameter("hub", Kind.Object);
 
@@ -341,13 +341,13 @@
     private SimpleTemplates newObjectArrayTemplates = new SimpleTemplates() {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags) {
+        protected XirTemplate create(XirAssembler asm, long flags) {
             emitNewTypeArray(asm, Kind.Object, config.useFastNewObjectArray, config.newObjectArrayStub);
             return asm.finishTemplate("newObjectArray");
         }
     };
 
-    private void emitNewTypeArray(CiXirAssembler asm, Kind kind, boolean useFast, long slowPathStub) {
+    private void emitNewTypeArray(XirAssembler asm, Kind kind, boolean useFast, long slowPathStub) {
         XirOperand result = asm.restart(target.wordKind);
 
         XirParameter lengthParam = asm.createInputParameter("length", Kind.Int, true);
@@ -431,7 +431,7 @@
 
     private KindTemplates newTypeArrayTemplates = new KindTemplates() {
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags, Kind kind) {
+        protected XirTemplate create(XirAssembler asm, long flags, Kind kind) {
             emitNewTypeArray(asm, kind, config.useFastNewTypeArray, config.newTypeArrayStub);
             return asm.finishTemplate("newTypeArray<" + kind.toString() + ">");
         }
@@ -440,7 +440,7 @@
     private final IndexTemplates multiNewArrayTemplate = new IndexTemplates() {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags, int dimensions) {
+        protected XirTemplate create(XirAssembler asm, long flags, int dimensions) {
             XirOperand result = asm.restart(Kind.Object);
 
             XirOperand hub = asm.createRegisterTemp("hub", Kind.Object, AMD64.rax);
@@ -485,7 +485,7 @@
 
     private IndexTemplates checkCastTemplates = new IndexTemplates(NULL_CHECK, EXACT_HINTS) {
 
-        private void incCounter(CiXirAssembler asm, XirOperand counter, XirParameter counters, CheckcastCounter offset) {
+        private void incCounter(XirAssembler asm, XirOperand counter, XirParameter counters, CheckcastCounter offset) {
             int disp = Unsafe.getUnsafe().arrayBaseOffset(long[].class);
             Scale scale = Scale.fromInt(Unsafe.getUnsafe().arrayIndexScale(long[].class));
             XirConstant index = asm.i(offset.ordinal());
@@ -495,7 +495,7 @@
         }
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags, int hintCount) {
+        protected XirTemplate create(XirAssembler asm, long flags, int hintCount) {
             asm.restart(Kind.Void);
             boolean exact = is(EXACT_HINTS, flags);
             XirParameter counters = GraalOptions.SnippetCounters ? asm.createConstantInputParameter("counters", Kind.Object) : null;
@@ -591,7 +591,7 @@
     private IndexTemplates instanceOfTemplates = new IndexTemplates(NULL_CHECK, EXACT_HINTS) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags, int hintCount) {
+        protected XirTemplate create(XirAssembler asm, long flags, int hintCount) {
             asm.restart(Kind.Void);
             XirParameter object = asm.createInputParameter("object", Kind.Object);
             final XirOperand hub = is(EXACT_HINTS, flags) ? null : asm.createConstantInputParameter("hub", Kind.Object);
@@ -650,7 +650,7 @@
     private IndexTemplates materializeInstanceOfTemplates = new IndexTemplates(NULL_CHECK, EXACT_HINTS) {
 
         @Override
-        protected XirTemplate create(CiXirAssembler asm, long flags, int hintCount) {
+        protected XirTemplate create(XirAssembler asm, long flags, int hintCount) {
             XirOperand result = asm.restart(Kind.Int);
             XirParameter object = asm.createInputParameter("object", Kind.Object);
             final XirOperand hub = is(EXACT_HINTS, flags) ? null : asm.createConstantInputParameter("hub", Kind.Object);
@@ -716,7 +716,7 @@
 
     private SimpleTemplates typeCheckTemplates = new SimpleTemplates(NULL_CHECK) {
        @Override
-       protected XirTemplate create(CiXirAssembler asm, long flags) {
+       protected XirTemplate create(XirAssembler asm, long flags) {
            asm.restart(Kind.Void);
            XirParameter objHub = asm.createInputParameter("objectHub", Kind.Object);
            XirOperand hub = asm.createConstantInputParameter("hub", Kind.Object);
@@ -891,11 +891,11 @@
     }
 
     @Override
-    public void initialize(CiXirAssembler asm) {
+    public void initialize(XirAssembler asm) {
         this.globalAsm = asm;
     }
 
-    private void checkSubtype(CiXirAssembler asm, XirOperand result, XirOperand objHub, XirOperand hub) {
+    private void checkSubtype(XirAssembler asm, XirOperand result, XirOperand objHub, XirOperand hub) {
         asm.push(objHub);
         asm.push(hub);
         asm.callRuntime(config.instanceofStub, null);
@@ -903,7 +903,7 @@
         asm.pop(result);
     }
 
-    private static void useRegisters(CiXirAssembler asm, Register... registers) {
+    private static void useRegisters(XirAssembler asm, Register... registers) {
         if (registers != null) {
             for (Register register : registers) {
                 asm.createRegisterTemp("reg", Kind.Illegal, register);
@@ -931,7 +931,7 @@
             this.mask = getBits((int) INDEX_MASK, null, flags);
         }
 
-        protected abstract XirTemplate create(CiXirAssembler asm, long flags);
+        protected abstract XirTemplate create(XirAssembler asm, long flags);
 
         protected long getBits(int index, XirSite site, TemplateFlag... flags) {
             long bits = index;
@@ -979,11 +979,11 @@
         }
 
         @Override
-        protected final XirTemplate create(CiXirAssembler asm, long flags) {
+        protected final XirTemplate create(XirAssembler asm, long flags) {
             return create(asm, flags & FLAGS_MASK, (int) (flags & INDEX_MASK));
         }
 
-        protected abstract XirTemplate create(CiXirAssembler asm, long flags, int index);
+        protected abstract XirTemplate create(XirAssembler asm, long flags, int index);
 
         public XirTemplate get(XirSite site, int size, TemplateFlag... flags) {
             return getInternal(getBits(size, site, flags));
@@ -997,11 +997,11 @@
         }
 
         @Override
-        protected final XirTemplate create(CiXirAssembler asm, long flags) {
+        protected final XirTemplate create(XirAssembler asm, long flags) {
             return create(asm, flags & FLAGS_MASK, Kind.VALUES[(int) (flags & INDEX_MASK)]);
         }
 
-        protected abstract XirTemplate create(CiXirAssembler asm, long flags, Kind kind);
+        protected abstract XirTemplate create(XirAssembler asm, long flags, Kind kind);
 
         public XirTemplate get(XirSite site, Kind kind, TemplateFlag... flags) {
             return getInternal(getBits(kind.ordinal(), site, flags));
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java	Thu Jul 05 21:39:22 2012 +0200
@@ -34,7 +34,7 @@
 import com.oracle.graal.lir.LIRInstruction.Opcode;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.max.asm.target.amd64.*;
-import com.oracle.max.cri.xir.CiXirAssembler.XirMark;
+import com.oracle.max.cri.xir.XirAssembler.XirMark;
 
 public class AMD64Call {
 
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java	Thu Jul 05 21:39:22 2012 +0200
@@ -111,51 +111,7 @@
         Debug.metric("SafepointsEmitted").add(targetMethod.getSafepoints().size());
         Debug.metric("DataPatches").add(targetMethod.getDataReferences().size());
         Debug.metric("ExceptionHandlersEmitted").add(targetMethod.getExceptionHandlers().size());
-
         Debug.log("Finished target method %s, isStub %b", name, isStub);
-/*
-        if (GraalOptions.PrintAssembly && !TTY.isSuppressed() && !isStub) {
-            Util.printSection("Target Method", Util.SECTION_CHARACTER);
-            TTY.println("Name: " + name);
-            TTY.println("Frame size: " + targetMethod.frameSize());
-            TTY.println("Register size: " + asm.target.arch.registerReferenceMapBitCount);
-
-            if (GraalOptions.PrintCodeBytes) {
-                Util.printSection("Code", Util.SUB_SECTION_CHARACTER);
-                TTY.println("Code: %d bytes", targetMethod.targetCodeSize());
-                Util.printBytes(0L, targetMethod.targetCode(), 0, targetMethod.targetCodeSize(), GraalOptions.PrintAssemblyBytesPerLine);
-            }
-
-            Util.printSection("Disassembly", Util.SUB_SECTION_CHARACTER);
-            String disassembly = runtime.disassemble(targetMethod);
-            TTY.println(disassembly);
-            boolean noDis = disassembly == null || disassembly.length() == 0;
-
-            Util.printSection("Safepoints", Util.SUB_SECTION_CHARACTER);
-            for (CiTargetMethod.Safepoint x : targetMethod.safepoints) {
-                TTY.println(x.toString());
-                if (noDis && x.debugInfo != null) {
-                    TTY.println(CiUtil.indent(x.debugInfo.toString(), "  "));
-                }
-            }
-
-            Util.printSection("Data Patches", Util.SUB_SECTION_CHARACTER);
-            for (CiTargetMethod.DataPatch x : targetMethod.dataReferences) {
-                TTY.println(x.toString());
-            }
-
-            Util.printSection("Marks", Util.SUB_SECTION_CHARACTER);
-            for (CiTargetMethod.Mark x : targetMethod.marks) {
-                TTY.println(x.toString());
-            }
-
-            Util.printSection("Exception Handlers", Util.SUB_SECTION_CHARACTER);
-            for (CiTargetMethod.ExceptionHandler x : targetMethod.exceptionHandlers) {
-                TTY.println(x.toString());
-            }
-        }
-*/
-
         return targetMethod;
     }
 
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackStore.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/types/ObjectTypeFeedbackStore.java	Thu Jul 05 21:39:22 2012 +0200
@@ -498,9 +498,9 @@
     /*
 //    equals contains all the values that might happen to be in this variable. If it is null then there is no information about possible values.
 //    If it is empty, then we're currently in a branch that will be removed by canonicalization later on.
-    private Set<CiConstant> equals;
+    private Set<Constant> equals;
 //    notEquals contains all the values that cannot be in this variable.
-    private Set<CiConstant> notEquals;
+    private Set<Constant> notEquals;
 
     private HashMap<ValueNode, Condition> valueBounds;
 
@@ -536,7 +536,7 @@
     }
 
     @Override
-    public void constantBound(Condition condition, CiConstant constant) {
+    public void constantBound(Condition condition, Constant constant) {
         assert condition == Condition.EQ || condition == Condition.NE;
 
         if (condition == Condition.EQ) {
@@ -633,7 +633,7 @@
             }
         }
         if (nonNull) {
-            constantBound(Condition.NE, CiConstant.NULL_OBJECT);
+            constantBound(Condition.NE, Constant.NULL_OBJECT);
         }
     }
 
@@ -653,7 +653,7 @@
                 exactTypes.clear();
             }
         }
-        constantBound(Condition.NE, CiConstant.NULL_OBJECT);
+        constantBound(Condition.NE, Constant.NULL_OBJECT);
     }
 
     @Override
@@ -673,8 +673,8 @@
             equals = null;
         }
         if (notEquals != null && !notEquals.isEmpty() && other.notEquals != null && !other.notEquals.isEmpty()) {
-            for (Iterator<CiConstant> iter = notEquals.iterator(); iter.hasNext();) {
-                CiConstant constant = iter.next();
+            for (Iterator<Constant> iter = notEquals.iterator(); iter.hasNext();) {
+                Constant constant = iter.next();
                 if (!other.notEquals.contains(constant)) {
                     iter.remove();
                 }
@@ -727,7 +727,7 @@
                 str.append(equals.iterator().next());
             } else {
                 str.append("(");
-                for (CiConstant constant : equals) {
+                for (Constant constant : equals) {
                     str.append(constant).append(',');
                 }
                 str.setLength(str.length() - 1);
@@ -741,7 +741,7 @@
                 str.append(notEquals.iterator().next());
             } else {
                 str.append("(");
-                for (CiConstant constant : notEquals) {
+                for (Constant constant : notEquals) {
                     str.append(constant).append(',');
                 }
                 str.setLength(str.length() - 1);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/type/StampFactory.java	Thu Jul 05 21:39:22 2012 +0200
@@ -120,7 +120,7 @@
             ResolvedJavaType type = value.isNull() ? null : runtime.getTypeOf(value);
             return new ObjectStamp(type, value.isNonNull(), value.isNonNull());
         } else {
-            throw new GraalInternalError("CiKind.Object expected, actual kind: %s", value.kind);
+            throw new GraalInternalError(Kind.Object + " expected, actual kind: %s", value.kind);
         }
     }
 
--- a/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.max.asm/src/com/oracle/max/asm/target/amd64/AMD64Assembler.java	Thu Jul 05 21:39:22 2012 +0200
@@ -202,8 +202,8 @@
         if (base == Register.Frame) {
             assert frameRegister != null : "cannot use register " + Register.Frame + " in assembler with null register configuration";
             base = frameRegister;
-//        } else if (base == CiRegister.CallerFrame) {
-//            assert frameRegister != null : "cannot use register " + CiRegister.Frame + " in assembler with null register configuration";
+//        } else if (base == Register.CallerFrame) {
+//            assert frameRegister != null : "cannot use register " + Register.Frame + " in assembler with null register configuration";
 //            base = frameRegister;
 //            disp += targetMethod.frameSize() + 8;
         }
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/CiXirAssembler.java	Thu Jul 05 17:53:27 2012 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,939 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.max.cri.xir;
-
-import static com.oracle.max.cri.xir.CiXirAssembler.XirOp.*;
-
-import java.util.*;
-
-import com.oracle.graal.api.code.*;
-import com.oracle.graal.api.code.Address.*;
-import com.oracle.graal.api.meta.*;
-
-/**
- * Represents an assembler that allows a client such as the runtime system to
- * create {@link XirTemplate XIR templates}.
- */
-public abstract class CiXirAssembler {
-
-    protected XirOperand resultOperand;
-    protected boolean allocateResultOperand;
-
-    protected final List<XirInstruction> instructions = new ArrayList<>();
-    protected final List<XirLabel> labels = new ArrayList<>(5);
-    protected final List<XirParameter> parameters = new ArrayList<>(5);
-    protected final List<XirTemp> temps = new ArrayList<>(5);
-    protected final List<XirConstant> constants = new ArrayList<>(5);
-    protected final List<XirMark> marks = new ArrayList<>(5);
-
-    protected int outgoingStackSize = 0;
-
-    /**
-     * Increases by one for every {@link XirOperand operand} created.
-     */
-    protected int variableCount;
-
-    /**
-     * Marks the assembly complete.
-     */
-    protected boolean finished = true;
-
-    protected final TargetDescription target;
-
-    public CiXirAssembler(TargetDescription target) {
-        this.target = target;
-    }
-
-    public static class RuntimeCallInformation {
-        public final Object target;
-        public final boolean useInfoAfter;
-
-        public RuntimeCallInformation(Object target, boolean useInfoAfter) {
-            this.target = target;
-            this.useInfoAfter = useInfoAfter;
-        }
-    }
-
-    /**
-     * Represents additional address calculation information.
-     */
-    public static final class AddressAccessInformation {
-
-        /**
-         * The scaling factor for the scaled-index part of an address computation.
-         */
-        public final Scale scale;
-
-        /**
-         * The constant byte-sized displacement part of an address computation.
-         */
-        public final int disp;
-
-        /**
-         * Determines if the memory access through the address can trap.
-         */
-        public final boolean canTrap;
-
-        private AddressAccessInformation(boolean canTrap) {
-            this.canTrap = canTrap;
-            this.scale = Scale.Times1;
-            this.disp = 0;
-        }
-
-        private AddressAccessInformation(boolean canTrap, int disp) {
-            this.canTrap = canTrap;
-            this.scale = Scale.Times1;
-            this.disp = disp;
-        }
-
-        private AddressAccessInformation(boolean canTrap, int disp, Scale scale) {
-            this.canTrap = canTrap;
-            this.scale = scale;
-            this.disp = disp;
-        }
-    }
-
-    /**
-     * A label that is the target of a control flow instruction.
-     */
-    public static final class XirLabel {
-        public static final String TrueSuccessor = "TrueSuccessor";
-        public static final String FalseSuccessor = "FalseSuccessor";
-        public final String name;
-        public final int index;
-        /**
-         * If {@code true} the label is to an instruction in the fast path sequence, otherwise to the slow path.
-         */
-        public final boolean inline;
-
-        private XirLabel(String name, int index, boolean inline) {
-            this.name = name;
-            this.index = index;
-            this.inline = inline;
-        }
-
-        @Override
-        public String toString() {
-            return name;
-        }
-    }
-
-    /**
-     * Tagging interface that indicates that an {@link XirOperand} is a constant.
-     */
-    public interface XirConstantOperand {
-        int getIndex();
-    }
-
-    public static final XirOperand VOID = null;
-
-    /**
-     * Operands for {@link XirInstruction instructions}.
-     * There are three basic variants, {@link XirConstant constant}, {@link XirParameter parameter} and {@link XirTemp}.
-     */
-    public abstract static class XirOperand {
-
-        public final Kind kind;
-
-        /**
-         * Unique id in range {@code 0} to {@link #variableCount variableCount - 1}.
-         */
-        public final int index;
-
-        /**
-         * Value whose {@link #toString()} method provides a name for this operand.
-         */
-        public final Object name;
-
-        public XirOperand(CiXirAssembler asm, Object name, Kind kind) {
-            this.kind = kind;
-            this.name = name;
-            this.index = asm.variableCount++;
-        }
-
-        @Override
-        public String toString() {
-            return String.valueOf(name);
-        }
-
-        public String detailedToString() {
-
-            StringBuffer sb = new StringBuffer();
-
-            sb.append(name);
-            sb.append('$');
-            sb.append(kind.typeChar);
-            return sb.toString();
-        }
-    }
-
-    /**
-     * Parameters to {@link XirTemplate templates}.
-     */
-    public static class XirParameter extends XirOperand {
-        /**
-         * Unique id in range {@code 0} to {@code parameters.Size()  - 1}.
-         */
-        public final int parameterIndex;
-
-        public final boolean canBeConstant;
-
-        XirParameter(CiXirAssembler asm, String name, Kind kind, boolean canBeConstant) {
-            super(asm, name, kind);
-            this.parameterIndex = asm.parameters.size();
-            this.canBeConstant = canBeConstant;
-            asm.parameters.add(this);
-        }
-
-    }
-
-    public static class XirConstantParameter extends XirParameter implements XirConstantOperand {
-        XirConstantParameter(CiXirAssembler asm, String name, Kind kind) {
-            super(asm, name, kind, true);
-        }
-
-        public int getIndex() {
-            return index;
-        }
-    }
-
-    public static class XirVariableParameter extends XirParameter {
-        XirVariableParameter(CiXirAssembler asm, String name, Kind kind, boolean canBeConstant) {
-            super(asm, name, kind, canBeConstant);
-        }
-    }
-
-    public static class XirConstant extends XirOperand implements XirConstantOperand {
-        public final Constant value;
-
-        XirConstant(CiXirAssembler asm, Constant value) {
-            super(asm, value, value.kind);
-            this.value = value;
-        }
-
-        public int getIndex() {
-            return index;
-        }
-    }
-
-    public static class XirTemp extends XirOperand {
-        public final boolean reserve;
-
-        XirTemp(CiXirAssembler asm, String name, Kind kind, boolean reserve) {
-            super(asm, name, kind);
-            this.reserve = reserve;
-        }
-    }
-
-    public static class XirRegister extends XirTemp {
-        public final Value register;
-
-        XirRegister(CiXirAssembler asm, String name, RegisterValue register, boolean reserve) {
-            super(asm, name, register.kind, reserve);
-            this.register = register;
-        }
-    }
-
-    /**
-     * Start a new assembly with no initial {@link #resultOperand result operand}.
-     */
-    public void restart() {
-        reset();
-        resultOperand = null;
-    }
-
-    /**
-     * Start a new assembly with a {@link #resultOperand result operand} of type {@code kind}.
-     * @param kind the result kind
-     * @return an {@code XirOperand} for the result operand
-     */
-    public XirOperand restart(Kind kind) {
-        reset();
-        resultOperand = new XirTemp(this, "result", kind, true);
-        allocateResultOperand = true;
-        return resultOperand;
-    }
-
-    /**
-     * Reset the state of the class to the initial conditions to facilitate a new assembly.
-     */
-    private void reset() {
-        assert finished : "must be finished before!";
-        variableCount = 0;
-        allocateResultOperand = false;
-        finished = false;
-        instructions.clear();
-        labels.clear();
-        parameters.clear();
-        temps.clear();
-        constants.clear();
-        marks.clear();
-        outgoingStackSize = 0;
-    }
-
-    /**
-     * Represents an XIR instruction, characterized by an {@link XirOp operation}, a {@link Kind kind}, an optional {@link XirOperand result}, a variable number of {@link XirOperand arguments},
-     * and some optional instruction-specific state. The {@link #x}, {@link #y} and {@link #z} methods are convenient ways to access the first, second and third
-     * arguments, respectively. Only {@link XirOp#CallRuntime} instructions can have more than three arguments.
-     *
-     */
-    public static final class XirInstruction {
-        /**
-         * The {@link Kind kind} of values the instruction operates on.
-         */
-        public final Kind kind;
-        /**
-         * The {@link XirOp operation}.
-         */
-        public final XirOp op;
-        /**
-         * The result, if any.
-         */
-        public final XirOperand result;
-        /**
-         * The arguments.
-         */
-        public final XirOperand[] arguments;
-        /**
-         * Arbitrary additional data associated with the instruction.
-         */
-        public final Object extra;
-
-        public XirInstruction(Kind kind, XirOp op, XirOperand result, XirOperand... arguments) {
-            this(kind, null, op, result, arguments);
-        }
-
-        public XirInstruction(Kind kind, Object extra, XirOp op, XirOperand result, XirOperand... arguments) {
-            this.extra = extra;
-            this.kind = kind;
-            this.op = op;
-            this.result = result;
-            this.arguments = arguments;
-        }
-
-        public XirOperand x() {
-            assert arguments.length > 0 : "no x operand for this instruction";
-            return arguments[0];
-        }
-
-        public XirOperand y() {
-            assert arguments.length > 1 : "no y operand for this instruction";
-            return arguments[1];
-        }
-
-        public XirOperand z() {
-            assert arguments.length > 2 : "no z operand for this instruction";
-            return arguments[2];
-        }
-
-        @Override
-        public String toString() {
-            StringBuffer sb = new StringBuffer();
-
-            if (result != null) {
-                sb.append(result.toString());
-                sb.append(" = ");
-            }
-
-            sb.append(op.name());
-
-            if (kind != Kind.Void) {
-                sb.append('$');
-                sb.append(kind.typeChar);
-            }
-
-            if (arguments != null && arguments.length > 0) {
-                sb.append("(");
-
-                for (int i = 0; i < arguments.length; i++) {
-                    if (i != 0) {
-                        sb.append(", ");
-                    }
-                    sb.append(arguments[i]);
-                }
-
-                sb.append(")");
-            }
-
-            if (extra != null) {
-                sb.append(" ");
-                sb.append(extra);
-            }
-
-            return sb.toString();
-        }
-    }
-
-    /**
-     * These marks let the RiXirGenerator mark positions in the generated native code and bring them in relationship with on another.
-     * This is necessary for code patching, etc.
-     */
-    public static class XirMark {
-        public final XirMark[] references;
-        public final Object id;
-
-        // special mark used to refer to the actual call site of an invoke
-        public static final XirMark CALLSITE = new XirMark(null);
-
-        public XirMark(Object id, XirMark... references) {
-            this.id = id;
-            this.references = references;
-        }
-    }
-
-    /**
-     * The set of opcodes for XIR instructions.
-     * {@link XirInstruction} defines {@code x}, {@code y} and {@code z} as the first, second and third arguments, respectively.
-     * We use these mnemonics, plus {@code args} for the complete set of arguments, {@code r} for the result, and {@code extra}
-     * for the instruction-specific extra data, in the opcode specifications. Note that the opcodes that operate on values do not directly
-     * specify the size (kind) of the data operated on;  this is is encoded in {@link XirInstruction#kind}.
-     * Note: If the instruction kind differs from the argument/result kinds, the behavior is undefined.
-     *
-     */
-    public enum XirOp {
-        /**
-         * Move {@code x} to {@code r}.
-         */
-        Mov,
-        /**
-         * Add {@code y} to {@code x} and put the result in {@code r}.
-         */
-        Add,
-        /**
-         * Subtract {@code y} from {@code x} and put the result in {@code r}.
-         */
-        Sub,
-        /**
-         * Divide {@code y} by {@code x} and put the result in {@code r}.
-         */
-        Div,
-        /**
-         * Multiply {@code y} by {@code x} and put the result in {@code r}.
-         */
-        Mul,
-        /**
-         * {@code y} modulus {@code x} and put the result in {@code r}.
-         */
-        Mod,
-        /**
-         * Shift  {@code y} left by {@code x} and put the result in {@code r}.
-         */
-        Shl,
-        /**
-         * Arithmetic shift  {@code y} right by {@code x} and put the result in {@code r}.
-         */
-        Sar,
-        /**
-         * Shift  {@code y} right by {@code x} and put the result in {@code r}.
-         */
-        Shr,
-        /**
-         * And {@code y} by {@code x} and put the result in {@code r}.
-         */
-        And,
-        /**
-         * Or {@code y} by {@code x} and put the result in {@code r}.
-         */
-        Or,
-        /**
-         * Exclusive Or {@code y} by {@code x} and put the result in {@code r}.
-         */
-        Xor,
-        /**
-         * Null check on {@code x}.
-         */
-        NullCheck,
-        /**
-         * Load value at address {@code x} and put the result in {@code r}.
-         */
-        PointerLoad,
-        /**
-         * Store {@code y} at address {@code x}.
-         */
-        PointerStore,
-        /**
-         * Load value at an effective address defined by base {@code x} and either a scaled index {@code y} plus displacement
-         * or an offset {@code y} and put the result in {@code r}.
-         */
-        PointerLoadDisp,
-        /**
-         * Load an effective address defined by base {@code x} and either a scaled index {@code y} plus displacement
-         * or an offset {@code y} and put the result in {@code r}.
-         */
-        LoadEffectiveAddress,
-        /**
-         * Store {@code z} at address defined by base {@code x} and index {@code y}.
-         */
-        PointerStoreDisp,
-        /**
-         * Repeat move from {@code x} to {@code y} using {@code z} words.
-         */
-        RepeatMoveWords,
-        /**
-         * Repeat move from {@code x} to {@code y} using {@code z} words.
-         */
-        RepeatMoveBytes,
-        /**
-         * Compare value at at address {@code x} with value in {@code y} and store value {@code z} at address {@code x}
-         * if it was equal to {@code y}.
-         */
-        PointerCAS,
-        /**
-         * Call the {@link JavaMethod} defined by {@code extra}  with {@code args} and put the result in {@code r}.
-         */
-        CallRuntime,
-        /**
-         * Transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jmp,
-       /**
-         * If {@code x == y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jeq,
-        /**
-         * If {@code x != y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jneq,
-        /**
-         * If {@code x > y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jgt,
-        /**
-         * If {@code x >= y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jgteq,
-        /**
-         * If {@code x unsigned >= y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jugteq,
-        /**
-         * If {@code x < y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jlt,
-        /**
-         * If {@code x <= y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jlteq,
-        /**
-         * Decreases the input by one and jumps to the target if the input is not 0.
-         */
-        DecAndJumpNotZero,
-        /**
-         * If bit designated by {@code z} at effective address defined by base {@code x} and offset {@code y}
-         * is set transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
-         */
-        Jbset,
-        /**
-         * Bind the {@link XirLabel label} identified by {@code extra} to the current instruction and update any references to it.
-         * A label may be bound more than once to the same location.
-         */
-        Bind,
-        /**
-         * Record a safepoint.
-         */
-        Safepoint,
-        /**
-         * Pushes a value onto the stack.
-         */
-        Push,
-        /**
-         * Pops a value from the stack.
-         */
-        Pop,
-        /**
-         * Marks a position in the generated native code.
-         */
-        Mark,
-        /**
-         * Load instruction pointer of the next instruction in a destination register.
-         */
-        Here,
-        /**
-         * Inserts nop instructions, with the given size in bytes.
-         */
-        Nop,
-        /**
-         * This instruction should never be reached, this is useful for debugging purposes.
-         */
-         ShouldNotReachHere
-    }
-
-    public/*private*/ void append(XirInstruction xirInstruction) {
-        assert !finished : "no instructions can be added to finished template";
-        instructions.add(xirInstruction);
-    }
-
-    public XirLabel createInlineLabel(String name) {
-        final XirLabel result = new XirLabel(name, this.labels.size(), true);
-        labels.add(result);
-        return result;
-    }
-
-    public XirLabel createOutOfLineLabel(String name) {
-        final XirLabel result = new XirLabel(name, this.labels.size(), false);
-        labels.add(result);
-        return result;
-    }
-
-    public void mov(XirOperand result, XirOperand a) {
-        append(new XirInstruction(result.kind, Mov, result, a));
-    }
-
-    public void add(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Add, result, a, b));
-    }
-
-    public void sub(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Sub, result, a, b));
-    }
-
-    public void div(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Div, result, a, b));
-    }
-
-    public void mul(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Mul, result, a, b));
-    }
-
-    public void mod(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Mod, result, a, b));
-    }
-
-    public void shl(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Shl, result, a, b));
-    }
-
-    public void shr(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Shr, result, a, b));
-    }
-
-    public void and(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, And, result, a, b));
-    }
-
-    public void or(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Or, result, a, b));
-    }
-
-    public void xor(XirOperand result, XirOperand a, XirOperand b) {
-        append(new XirInstruction(result.kind, Xor, result, a, b));
-    }
-
-    public void nullCheck(XirOperand pointer) {
-        append(new XirInstruction(Kind.Object, NullCheck, VOID, pointer));
-    }
-
-    public void pload(Kind kind, XirOperand result, XirOperand pointer, boolean canTrap) {
-        append(new XirInstruction(kind, canTrap, PointerLoad, result, pointer));
-    }
-
-    public void pstore(Kind kind, XirOperand pointer, XirOperand value, boolean canTrap) {
-        append(new XirInstruction(kind, canTrap, PointerStore, null, pointer, value));
-    }
-
-    public void pload(Kind kind, XirOperand result, XirOperand pointer, XirOperand offset, boolean canTrap) {
-        append(new XirInstruction(kind, new AddressAccessInformation(canTrap), PointerLoadDisp, result, pointer, offset));
-    }
-
-    public void pstore(Kind kind, XirOperand pointer, XirOperand offset, XirOperand value, boolean canTrap) {
-        append(new XirInstruction(kind, new AddressAccessInformation(canTrap), PointerStoreDisp, VOID, pointer, offset, value));
-    }
-
-    public void pload(Kind kind, XirOperand result, XirOperand pointer, XirOperand index, int disp, Scale scale,  boolean canTrap) {
-        append(new XirInstruction(kind, new AddressAccessInformation(canTrap, disp, scale), PointerLoadDisp, result, pointer, index));
-    }
-
-    public void lea(XirOperand result, XirOperand pointer, XirOperand index, int disp, Scale scale) {
-        append(new XirInstruction(target.wordKind, new AddressAccessInformation(false, disp, scale), LoadEffectiveAddress, result, pointer, index));
-    }
-
-    public void repmov(XirOperand src, XirOperand dest, XirOperand length) {
-        append(new XirInstruction(target.wordKind, null, RepeatMoveWords, null, src, dest, length));
-    }
-
-    public void here(XirOperand dst) {
-        append(new XirInstruction(target.wordKind, null, Here, dst));
-    }
-
-    public void repmovb(XirOperand src, XirOperand dest, XirOperand length) {
-        append(new XirInstruction(target.wordKind, null, RepeatMoveBytes, null, src, dest, length));
-    }
-
-    public void pstore(Kind kind, XirOperand pointer, XirOperand index, XirOperand value, int disp, Scale scale, boolean canTrap) {
-        append(new XirInstruction(kind, new AddressAccessInformation(canTrap, disp, scale), PointerStoreDisp, VOID, pointer, index, value));
-    }
-
-    public void pcas(Kind kind, XirOperand result, XirOperand pointer, XirOperand newValue, XirOperand oldValue) {
-        append(new XirInstruction(kind, null, PointerCAS, result, pointer, newValue, oldValue));
-    }
-
-    public void jmp(XirLabel l) {
-        append(new XirInstruction(Kind.Void, l, Jmp, null));
-    }
-
-    public void decAndJumpNotZero(XirLabel l, XirOperand val) {
-        append(new XirInstruction(Kind.Void, l, DecAndJumpNotZero, null, val));
-    }
-
-    public void jmpRuntime(Object rt) {
-        append(new XirInstruction(Kind.Void, rt, Jmp, null));
-    }
-
-    public void jeq(XirLabel l, XirOperand a, XirOperand b) {
-        jcc(Jeq, l, a, b);
-    }
-
-    private void jcc(XirOp op, XirLabel l, XirOperand a, XirOperand b) {
-        append(new XirInstruction(Kind.Void, l, op, null, a, b));
-    }
-
-    public void jneq(XirLabel l, XirOperand a, XirOperand b) {
-        jcc(Jneq, l, a, b);
-    }
-
-    public void jgt(XirLabel l, XirOperand a, XirOperand b) {
-        jcc(Jgt, l, a, b);
-    }
-
-    public void jgteq(XirLabel l, XirOperand a, XirOperand b) {
-        jcc(Jgteq, l, a, b);
-    }
-
-    public void jugteq(XirLabel l, XirOperand a, XirOperand b) {
-        jcc(Jugteq, l, a, b);
-    }
-
-    public void jlt(XirLabel l, XirOperand a, XirOperand b) {
-        jcc(Jlt, l, a, b);
-    }
-
-    public void jlteq(XirLabel l, XirOperand a, XirOperand b) {
-        jcc(Jlteq, l, a, b);
-    }
-
-    public void jbset(XirLabel l, XirOperand a, XirOperand b, XirOperand c) {
-        append(new XirInstruction(Kind.Void, l, Jbset, null, a, b, c));
-    }
-
-    public void bindInline(XirLabel l) {
-        assert l.inline;
-        append(new XirInstruction(Kind.Void, l, Bind, null));
-    }
-
-    public void bindOutOfLine(XirLabel l) {
-        assert !l.inline;
-        append(new XirInstruction(Kind.Void, l, Bind, null));
-    }
-
-    public void safepoint() {
-        append(new XirInstruction(Kind.Void, null, Safepoint, null));
-    }
-
-    public void push(XirOperand value) {
-        append(new XirInstruction(Kind.Void, Push, VOID, value));
-    }
-
-    public void pop(XirOperand result) {
-        append(new XirInstruction(result.kind, Pop, result));
-    }
-
-    public XirMark mark(Object id, XirMark... references) {
-        XirMark mark = new XirMark(id, references);
-        marks.add(mark);
-        append(new XirInstruction(Kind.Void, mark, Mark, null));
-        return mark;
-    }
-
-    public void nop(int size) {
-        append(new XirInstruction(Kind.Void, size, Nop, null));
-    }
-
-    public void shouldNotReachHere() {
-        append(new XirInstruction(Kind.Void, null, ShouldNotReachHere, null));
-    }
-
-    public void shouldNotReachHere(String message) {
-        append(new XirInstruction(Kind.Void, message, ShouldNotReachHere, null));
-    }
-
-    public void callRuntime(Object rt, XirOperand result, XirOperand... args) {
-        callRuntime(rt, result, false, args);
-    }
-
-    public void callRuntime(Object rt, XirOperand result, boolean useInfoAfter, XirOperand... args) {
-        Kind resultKind = result == null ? Kind.Void : result.kind;
-        append(new XirInstruction(resultKind, new RuntimeCallInformation(rt, useInfoAfter), CallRuntime, result, args));
-    }
-
-    /**
-     * Terminates the assembly, checking invariants, in particular that {@link #resultOperand} is set, and setting {@link #finished} to {@code true}.
-     */
-    private void end() {
-        assert !finished : "template may only be finished once!";
-        assert resultOperand != null : "result operand should be set";
-        finished = true;
-    }
-
-    /**
-     * Creates an {@link XirVariableParameter variable input parameter}  of given name and {@link Kind kind}.
-     * @param name a name for the parameter
-     * @param kind the parameter kind
-     * @return the  {@link XirVariableParameter}
-     */
-    public XirVariableParameter createInputParameter(String name, Kind kind, boolean canBeConstant) {
-        assert !finished;
-        return new XirVariableParameter(this, name, kind, canBeConstant);
-    }
-
-    public XirVariableParameter createInputParameter(String name, Kind kind) {
-        return createInputParameter(name, kind, false);
-    }
-
-    /**
-     * Creates an {@link XirConstantParameter constant input parameter}  of given name and {@link Kind kind}.
-     * @param name a name for the parameter
-     * @param kind the parameter kind
-     * @return the  {@link XirConstantParameter}
-     */
-    public XirConstantParameter createConstantInputParameter(String name, Kind kind) {
-        assert !finished;
-        return new XirConstantParameter(this, name, kind);
-    }
-
-    public XirConstant createConstant(Constant constant) {
-        assert !finished;
-        XirConstant temp = new XirConstant(this, constant);
-        constants.add(temp);
-        return temp;
-    }
-
-    public XirOperand createTemp(String name, Kind kind) {
-        assert !finished;
-        XirTemp temp = new XirTemp(this, name, kind, true);
-        temps.add(temp);
-        return temp;
-    }
-
-    public XirOperand createRegister(String name, Kind kind, Register register) {
-        return createRegister(name, kind, register, false);
-    }
-
-    public XirOperand createRegisterTemp(String name, Kind kind, Register register) {
-        return createRegister(name, kind, register, true);
-    }
-
-    private XirOperand createRegister(String name, Kind kind, Register register, boolean reserve) {
-        assert !finished;
-        XirRegister fixed = new XirRegister(this, name, register.asValue(kind), reserve);
-        temps.add(fixed);
-        return fixed;
-    }
-
-    public XirParameter getParameter(String name) {
-        for (XirParameter param : parameters) {
-            if (param.name.toString().equals(name)) {
-                return param;
-            }
-        }
-        throw new IllegalArgumentException("no parameter: " + name);
-    }
-
-    public XirTemp getTemp(String name) {
-        for (XirTemp temp : temps) {
-            if (temp.name.toString().equals(name)) {
-                return temp;
-            }
-        }
-        throw new IllegalArgumentException("no temp: " + name);
-    }
-
-    public XirConstant i(int v) {
-        return createConstant(Constant.forInt(v));
-    }
-
-    public XirConstant l(long v) {
-        return createConstant(Constant.forLong(v));
-    }
-
-    public XirConstant b(boolean v) {
-        return createConstant(Constant.forBoolean(v));
-    }
-
-    public XirConstant o(Object obj) {
-        return createConstant(Constant.forObject(obj));
-    }
-
-    public void reserveOutgoingStack(int size) {
-        outgoingStackSize = Math.max(outgoingStackSize, size);
-    }
-
-    /**
-     * Finishes the assembly of a non-stub template, providing the {@link #resultOperand} and constructs the {@link XirTemplate}.
-     * @param result the {@link XirOperand} to be set as the {@link #resultOperand}
-     * @param name the name of the template
-     * @return the generated template
-     */
-    public XirTemplate finishTemplate(XirOperand result, String name) {
-        assert this.resultOperand == null;
-        assert result != null;
-        this.resultOperand = result;
-        final XirTemplate template = buildTemplate(name, false);
-        end();
-        return template;
-    }
-
-    /**
-     * Finishes the assembly of a non-stub template and constructs the {@link XirTemplate}.
-     * @param name the name of the template
-     * @return the generated template
-     */
-    public XirTemplate finishTemplate(String name) {
-        final XirTemplate template = buildTemplate(name, false);
-        end();
-        return template;
-    }
-
-    /**
-     * Finishes the assembly of a {@link XirTemplate.GlobalFlags#GLOBAL_STUB stub} and constructs the {@link XirTemplate}.
-     * @param name the name of the template
-     * @return the generated template
-     */
-    public XirTemplate finishStub(String name) {
-        final XirTemplate template = buildTemplate(name, true);
-        end();
-        return template;
-    }
-
-    /**
-     * Builds the {@link XirTemplate} from the assembly state in this object.
-     * The actual assembly is dependent on the target architecture and implemented
-     * in a concrete subclass.
-     * @param name the name of the template
-     * @param isStub {@code true} if the template represents a {@link XirTemplate.GlobalFlags#GLOBAL_STUB stub}
-     * @return the generated template
-     */
-    protected abstract XirTemplate buildTemplate(String name, boolean isStub);
-
-    public abstract CiXirAssembler copy();
-
-}
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/RiXirGenerator.java	Thu Jul 05 21:39:22 2012 +0200
@@ -71,6 +71,6 @@
      *
      * @param asm the XIR assembler
      */
-    void initialize(CiXirAssembler asm);
+    void initialize(XirAssembler asm);
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirAssembler.java	Thu Jul 05 21:39:22 2012 +0200
@@ -0,0 +1,939 @@
+/*
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.max.cri.xir;
+
+import static com.oracle.max.cri.xir.XirAssembler.XirOp.*;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.code.Address.*;
+import com.oracle.graal.api.meta.*;
+
+/**
+ * Represents an assembler that allows a client such as the runtime system to
+ * create {@link XirTemplate XIR templates}.
+ */
+public abstract class XirAssembler {
+
+    protected XirOperand resultOperand;
+    protected boolean allocateResultOperand;
+
+    protected final List<XirInstruction> instructions = new ArrayList<>();
+    protected final List<XirLabel> labels = new ArrayList<>(5);
+    protected final List<XirParameter> parameters = new ArrayList<>(5);
+    protected final List<XirTemp> temps = new ArrayList<>(5);
+    protected final List<XirConstant> constants = new ArrayList<>(5);
+    protected final List<XirMark> marks = new ArrayList<>(5);
+
+    protected int outgoingStackSize = 0;
+
+    /**
+     * Increases by one for every {@link XirOperand operand} created.
+     */
+    protected int variableCount;
+
+    /**
+     * Marks the assembly complete.
+     */
+    protected boolean finished = true;
+
+    protected final TargetDescription target;
+
+    public XirAssembler(TargetDescription target) {
+        this.target = target;
+    }
+
+    public static class RuntimeCallInformation {
+        public final Object target;
+        public final boolean useInfoAfter;
+
+        public RuntimeCallInformation(Object target, boolean useInfoAfter) {
+            this.target = target;
+            this.useInfoAfter = useInfoAfter;
+        }
+    }
+
+    /**
+     * Represents additional address calculation information.
+     */
+    public static final class AddressAccessInformation {
+
+        /**
+         * The scaling factor for the scaled-index part of an address computation.
+         */
+        public final Scale scale;
+
+        /**
+         * The constant byte-sized displacement part of an address computation.
+         */
+        public final int disp;
+
+        /**
+         * Determines if the memory access through the address can trap.
+         */
+        public final boolean canTrap;
+
+        private AddressAccessInformation(boolean canTrap) {
+            this.canTrap = canTrap;
+            this.scale = Scale.Times1;
+            this.disp = 0;
+        }
+
+        private AddressAccessInformation(boolean canTrap, int disp) {
+            this.canTrap = canTrap;
+            this.scale = Scale.Times1;
+            this.disp = disp;
+        }
+
+        private AddressAccessInformation(boolean canTrap, int disp, Scale scale) {
+            this.canTrap = canTrap;
+            this.scale = scale;
+            this.disp = disp;
+        }
+    }
+
+    /**
+     * A label that is the target of a control flow instruction.
+     */
+    public static final class XirLabel {
+        public static final String TrueSuccessor = "TrueSuccessor";
+        public static final String FalseSuccessor = "FalseSuccessor";
+        public final String name;
+        public final int index;
+        /**
+         * If {@code true} the label is to an instruction in the fast path sequence, otherwise to the slow path.
+         */
+        public final boolean inline;
+
+        private XirLabel(String name, int index, boolean inline) {
+            this.name = name;
+            this.index = index;
+            this.inline = inline;
+        }
+
+        @Override
+        public String toString() {
+            return name;
+        }
+    }
+
+    /**
+     * Tagging interface that indicates that an {@link XirOperand} is a constant.
+     */
+    public interface XirConstantOperand {
+        int getIndex();
+    }
+
+    public static final XirOperand VOID = null;
+
+    /**
+     * Operands for {@link XirInstruction instructions}.
+     * There are three basic variants, {@link XirConstant constant}, {@link XirParameter parameter} and {@link XirTemp}.
+     */
+    public abstract static class XirOperand {
+
+        public final Kind kind;
+
+        /**
+         * Unique id in range {@code 0} to {@link #variableCount variableCount - 1}.
+         */
+        public final int index;
+
+        /**
+         * Value whose {@link #toString()} method provides a name for this operand.
+         */
+        public final Object name;
+
+        public XirOperand(XirAssembler asm, Object name, Kind kind) {
+            this.kind = kind;
+            this.name = name;
+            this.index = asm.variableCount++;
+        }
+
+        @Override
+        public String toString() {
+            return String.valueOf(name);
+        }
+
+        public String detailedToString() {
+
+            StringBuffer sb = new StringBuffer();
+
+            sb.append(name);
+            sb.append('$');
+            sb.append(kind.typeChar);
+            return sb.toString();
+        }
+    }
+
+    /**
+     * Parameters to {@link XirTemplate templates}.
+     */
+    public static class XirParameter extends XirOperand {
+        /**
+         * Unique id in range {@code 0} to {@code parameters.Size()  - 1}.
+         */
+        public final int parameterIndex;
+
+        public final boolean canBeConstant;
+
+        XirParameter(XirAssembler asm, String name, Kind kind, boolean canBeConstant) {
+            super(asm, name, kind);
+            this.parameterIndex = asm.parameters.size();
+            this.canBeConstant = canBeConstant;
+            asm.parameters.add(this);
+        }
+
+    }
+
+    public static class XirConstantParameter extends XirParameter implements XirConstantOperand {
+        XirConstantParameter(XirAssembler asm, String name, Kind kind) {
+            super(asm, name, kind, true);
+        }
+
+        public int getIndex() {
+            return index;
+        }
+    }
+
+    public static class XirVariableParameter extends XirParameter {
+        XirVariableParameter(XirAssembler asm, String name, Kind kind, boolean canBeConstant) {
+            super(asm, name, kind, canBeConstant);
+        }
+    }
+
+    public static class XirConstant extends XirOperand implements XirConstantOperand {
+        public final Constant value;
+
+        XirConstant(XirAssembler asm, Constant value) {
+            super(asm, value, value.kind);
+            this.value = value;
+        }
+
+        public int getIndex() {
+            return index;
+        }
+    }
+
+    public static class XirTemp extends XirOperand {
+        public final boolean reserve;
+
+        XirTemp(XirAssembler asm, String name, Kind kind, boolean reserve) {
+            super(asm, name, kind);
+            this.reserve = reserve;
+        }
+    }
+
+    public static class XirRegister extends XirTemp {
+        public final Value register;
+
+        XirRegister(XirAssembler asm, String name, RegisterValue register, boolean reserve) {
+            super(asm, name, register.kind, reserve);
+            this.register = register;
+        }
+    }
+
+    /**
+     * Start a new assembly with no initial {@link #resultOperand result operand}.
+     */
+    public void restart() {
+        reset();
+        resultOperand = null;
+    }
+
+    /**
+     * Start a new assembly with a {@link #resultOperand result operand} of type {@code kind}.
+     * @param kind the result kind
+     * @return an {@code XirOperand} for the result operand
+     */
+    public XirOperand restart(Kind kind) {
+        reset();
+        resultOperand = new XirTemp(this, "result", kind, true);
+        allocateResultOperand = true;
+        return resultOperand;
+    }
+
+    /**
+     * Reset the state of the class to the initial conditions to facilitate a new assembly.
+     */
+    private void reset() {
+        assert finished : "must be finished before!";
+        variableCount = 0;
+        allocateResultOperand = false;
+        finished = false;
+        instructions.clear();
+        labels.clear();
+        parameters.clear();
+        temps.clear();
+        constants.clear();
+        marks.clear();
+        outgoingStackSize = 0;
+    }
+
+    /**
+     * Represents an XIR instruction, characterized by an {@link XirOp operation}, a {@link Kind kind}, an optional {@link XirOperand result}, a variable number of {@link XirOperand arguments},
+     * and some optional instruction-specific state. The {@link #x}, {@link #y} and {@link #z} methods are convenient ways to access the first, second and third
+     * arguments, respectively. Only {@link XirOp#CallRuntime} instructions can have more than three arguments.
+     *
+     */
+    public static final class XirInstruction {
+        /**
+         * The {@link Kind kind} of values the instruction operates on.
+         */
+        public final Kind kind;
+        /**
+         * The {@link XirOp operation}.
+         */
+        public final XirOp op;
+        /**
+         * The result, if any.
+         */
+        public final XirOperand result;
+        /**
+         * The arguments.
+         */
+        public final XirOperand[] arguments;
+        /**
+         * Arbitrary additional data associated with the instruction.
+         */
+        public final Object extra;
+
+        public XirInstruction(Kind kind, XirOp op, XirOperand result, XirOperand... arguments) {
+            this(kind, null, op, result, arguments);
+        }
+
+        public XirInstruction(Kind kind, Object extra, XirOp op, XirOperand result, XirOperand... arguments) {
+            this.extra = extra;
+            this.kind = kind;
+            this.op = op;
+            this.result = result;
+            this.arguments = arguments;
+        }
+
+        public XirOperand x() {
+            assert arguments.length > 0 : "no x operand for this instruction";
+            return arguments[0];
+        }
+
+        public XirOperand y() {
+            assert arguments.length > 1 : "no y operand for this instruction";
+            return arguments[1];
+        }
+
+        public XirOperand z() {
+            assert arguments.length > 2 : "no z operand for this instruction";
+            return arguments[2];
+        }
+
+        @Override
+        public String toString() {
+            StringBuffer sb = new StringBuffer();
+
+            if (result != null) {
+                sb.append(result.toString());
+                sb.append(" = ");
+            }
+
+            sb.append(op.name());
+
+            if (kind != Kind.Void) {
+                sb.append('$');
+                sb.append(kind.typeChar);
+            }
+
+            if (arguments != null && arguments.length > 0) {
+                sb.append("(");
+
+                for (int i = 0; i < arguments.length; i++) {
+                    if (i != 0) {
+                        sb.append(", ");
+                    }
+                    sb.append(arguments[i]);
+                }
+
+                sb.append(")");
+            }
+
+            if (extra != null) {
+                sb.append(" ");
+                sb.append(extra);
+            }
+
+            return sb.toString();
+        }
+    }
+
+    /**
+     * These marks let the RiXirGenerator mark positions in the generated native code and bring them in relationship with on another.
+     * This is necessary for code patching, etc.
+     */
+    public static class XirMark {
+        public final XirMark[] references;
+        public final Object id;
+
+        // special mark used to refer to the actual call site of an invoke
+        public static final XirMark CALLSITE = new XirMark(null);
+
+        public XirMark(Object id, XirMark... references) {
+            this.id = id;
+            this.references = references;
+        }
+    }
+
+    /**
+     * The set of opcodes for XIR instructions.
+     * {@link XirInstruction} defines {@code x}, {@code y} and {@code z} as the first, second and third arguments, respectively.
+     * We use these mnemonics, plus {@code args} for the complete set of arguments, {@code r} for the result, and {@code extra}
+     * for the instruction-specific extra data, in the opcode specifications. Note that the opcodes that operate on values do not directly
+     * specify the size (kind) of the data operated on;  this is is encoded in {@link XirInstruction#kind}.
+     * Note: If the instruction kind differs from the argument/result kinds, the behavior is undefined.
+     *
+     */
+    public enum XirOp {
+        /**
+         * Move {@code x} to {@code r}.
+         */
+        Mov,
+        /**
+         * Add {@code y} to {@code x} and put the result in {@code r}.
+         */
+        Add,
+        /**
+         * Subtract {@code y} from {@code x} and put the result in {@code r}.
+         */
+        Sub,
+        /**
+         * Divide {@code y} by {@code x} and put the result in {@code r}.
+         */
+        Div,
+        /**
+         * Multiply {@code y} by {@code x} and put the result in {@code r}.
+         */
+        Mul,
+        /**
+         * {@code y} modulus {@code x} and put the result in {@code r}.
+         */
+        Mod,
+        /**
+         * Shift  {@code y} left by {@code x} and put the result in {@code r}.
+         */
+        Shl,
+        /**
+         * Arithmetic shift  {@code y} right by {@code x} and put the result in {@code r}.
+         */
+        Sar,
+        /**
+         * Shift  {@code y} right by {@code x} and put the result in {@code r}.
+         */
+        Shr,
+        /**
+         * And {@code y} by {@code x} and put the result in {@code r}.
+         */
+        And,
+        /**
+         * Or {@code y} by {@code x} and put the result in {@code r}.
+         */
+        Or,
+        /**
+         * Exclusive Or {@code y} by {@code x} and put the result in {@code r}.
+         */
+        Xor,
+        /**
+         * Null check on {@code x}.
+         */
+        NullCheck,
+        /**
+         * Load value at address {@code x} and put the result in {@code r}.
+         */
+        PointerLoad,
+        /**
+         * Store {@code y} at address {@code x}.
+         */
+        PointerStore,
+        /**
+         * Load value at an effective address defined by base {@code x} and either a scaled index {@code y} plus displacement
+         * or an offset {@code y} and put the result in {@code r}.
+         */
+        PointerLoadDisp,
+        /**
+         * Load an effective address defined by base {@code x} and either a scaled index {@code y} plus displacement
+         * or an offset {@code y} and put the result in {@code r}.
+         */
+        LoadEffectiveAddress,
+        /**
+         * Store {@code z} at address defined by base {@code x} and index {@code y}.
+         */
+        PointerStoreDisp,
+        /**
+         * Repeat move from {@code x} to {@code y} using {@code z} words.
+         */
+        RepeatMoveWords,
+        /**
+         * Repeat move from {@code x} to {@code y} using {@code z} words.
+         */
+        RepeatMoveBytes,
+        /**
+         * Compare value at at address {@code x} with value in {@code y} and store value {@code z} at address {@code x}
+         * if it was equal to {@code y}.
+         */
+        PointerCAS,
+        /**
+         * Call the {@link JavaMethod} defined by {@code extra}  with {@code args} and put the result in {@code r}.
+         */
+        CallRuntime,
+        /**
+         * Transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jmp,
+       /**
+         * If {@code x == y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jeq,
+        /**
+         * If {@code x != y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jneq,
+        /**
+         * If {@code x > y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jgt,
+        /**
+         * If {@code x >= y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jgteq,
+        /**
+         * If {@code x unsigned >= y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jugteq,
+        /**
+         * If {@code x < y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jlt,
+        /**
+         * If {@code x <= y}, transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jlteq,
+        /**
+         * Decreases the input by one and jumps to the target if the input is not 0.
+         */
+        DecAndJumpNotZero,
+        /**
+         * If bit designated by {@code z} at effective address defined by base {@code x} and offset {@code y}
+         * is set transfer control to the instruction at the {@link XirLabel label} identified by {@code extra}.
+         */
+        Jbset,
+        /**
+         * Bind the {@link XirLabel label} identified by {@code extra} to the current instruction and update any references to it.
+         * A label may be bound more than once to the same location.
+         */
+        Bind,
+        /**
+         * Record a safepoint.
+         */
+        Safepoint,
+        /**
+         * Pushes a value onto the stack.
+         */
+        Push,
+        /**
+         * Pops a value from the stack.
+         */
+        Pop,
+        /**
+         * Marks a position in the generated native code.
+         */
+        Mark,
+        /**
+         * Load instruction pointer of the next instruction in a destination register.
+         */
+        Here,
+        /**
+         * Inserts nop instructions, with the given size in bytes.
+         */
+        Nop,
+        /**
+         * This instruction should never be reached, this is useful for debugging purposes.
+         */
+         ShouldNotReachHere
+    }
+
+    public/*private*/ void append(XirInstruction xirInstruction) {
+        assert !finished : "no instructions can be added to finished template";
+        instructions.add(xirInstruction);
+    }
+
+    public XirLabel createInlineLabel(String name) {
+        final XirLabel result = new XirLabel(name, this.labels.size(), true);
+        labels.add(result);
+        return result;
+    }
+
+    public XirLabel createOutOfLineLabel(String name) {
+        final XirLabel result = new XirLabel(name, this.labels.size(), false);
+        labels.add(result);
+        return result;
+    }
+
+    public void mov(XirOperand result, XirOperand a) {
+        append(new XirInstruction(result.kind, Mov, result, a));
+    }
+
+    public void add(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Add, result, a, b));
+    }
+
+    public void sub(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Sub, result, a, b));
+    }
+
+    public void div(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Div, result, a, b));
+    }
+
+    public void mul(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Mul, result, a, b));
+    }
+
+    public void mod(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Mod, result, a, b));
+    }
+
+    public void shl(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Shl, result, a, b));
+    }
+
+    public void shr(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Shr, result, a, b));
+    }
+
+    public void and(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, And, result, a, b));
+    }
+
+    public void or(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Or, result, a, b));
+    }
+
+    public void xor(XirOperand result, XirOperand a, XirOperand b) {
+        append(new XirInstruction(result.kind, Xor, result, a, b));
+    }
+
+    public void nullCheck(XirOperand pointer) {
+        append(new XirInstruction(Kind.Object, NullCheck, VOID, pointer));
+    }
+
+    public void pload(Kind kind, XirOperand result, XirOperand pointer, boolean canTrap) {
+        append(new XirInstruction(kind, canTrap, PointerLoad, result, pointer));
+    }
+
+    public void pstore(Kind kind, XirOperand pointer, XirOperand value, boolean canTrap) {
+        append(new XirInstruction(kind, canTrap, PointerStore, null, pointer, value));
+    }
+
+    public void pload(Kind kind, XirOperand result, XirOperand pointer, XirOperand offset, boolean canTrap) {
+        append(new XirInstruction(kind, new AddressAccessInformation(canTrap), PointerLoadDisp, result, pointer, offset));
+    }
+
+    public void pstore(Kind kind, XirOperand pointer, XirOperand offset, XirOperand value, boolean canTrap) {
+        append(new XirInstruction(kind, new AddressAccessInformation(canTrap), PointerStoreDisp, VOID, pointer, offset, value));
+    }
+
+    public void pload(Kind kind, XirOperand result, XirOperand pointer, XirOperand index, int disp, Scale scale,  boolean canTrap) {
+        append(new XirInstruction(kind, new AddressAccessInformation(canTrap, disp, scale), PointerLoadDisp, result, pointer, index));
+    }
+
+    public void lea(XirOperand result, XirOperand pointer, XirOperand index, int disp, Scale scale) {
+        append(new XirInstruction(target.wordKind, new AddressAccessInformation(false, disp, scale), LoadEffectiveAddress, result, pointer, index));
+    }
+
+    public void repmov(XirOperand src, XirOperand dest, XirOperand length) {
+        append(new XirInstruction(target.wordKind, null, RepeatMoveWords, null, src, dest, length));
+    }
+
+    public void here(XirOperand dst) {
+        append(new XirInstruction(target.wordKind, null, Here, dst));
+    }
+
+    public void repmovb(XirOperand src, XirOperand dest, XirOperand length) {
+        append(new XirInstruction(target.wordKind, null, RepeatMoveBytes, null, src, dest, length));
+    }
+
+    public void pstore(Kind kind, XirOperand pointer, XirOperand index, XirOperand value, int disp, Scale scale, boolean canTrap) {
+        append(new XirInstruction(kind, new AddressAccessInformation(canTrap, disp, scale), PointerStoreDisp, VOID, pointer, index, value));
+    }
+
+    public void pcas(Kind kind, XirOperand result, XirOperand pointer, XirOperand newValue, XirOperand oldValue) {
+        append(new XirInstruction(kind, null, PointerCAS, result, pointer, newValue, oldValue));
+    }
+
+    public void jmp(XirLabel l) {
+        append(new XirInstruction(Kind.Void, l, Jmp, null));
+    }
+
+    public void decAndJumpNotZero(XirLabel l, XirOperand val) {
+        append(new XirInstruction(Kind.Void, l, DecAndJumpNotZero, null, val));
+    }
+
+    public void jmpRuntime(Object rt) {
+        append(new XirInstruction(Kind.Void, rt, Jmp, null));
+    }
+
+    public void jeq(XirLabel l, XirOperand a, XirOperand b) {
+        jcc(Jeq, l, a, b);
+    }
+
+    private void jcc(XirOp op, XirLabel l, XirOperand a, XirOperand b) {
+        append(new XirInstruction(Kind.Void, l, op, null, a, b));
+    }
+
+    public void jneq(XirLabel l, XirOperand a, XirOperand b) {
+        jcc(Jneq, l, a, b);
+    }
+
+    public void jgt(XirLabel l, XirOperand a, XirOperand b) {
+        jcc(Jgt, l, a, b);
+    }
+
+    public void jgteq(XirLabel l, XirOperand a, XirOperand b) {
+        jcc(Jgteq, l, a, b);
+    }
+
+    public void jugteq(XirLabel l, XirOperand a, XirOperand b) {
+        jcc(Jugteq, l, a, b);
+    }
+
+    public void jlt(XirLabel l, XirOperand a, XirOperand b) {
+        jcc(Jlt, l, a, b);
+    }
+
+    public void jlteq(XirLabel l, XirOperand a, XirOperand b) {
+        jcc(Jlteq, l, a, b);
+    }
+
+    public void jbset(XirLabel l, XirOperand a, XirOperand b, XirOperand c) {
+        append(new XirInstruction(Kind.Void, l, Jbset, null, a, b, c));
+    }
+
+    public void bindInline(XirLabel l) {
+        assert l.inline;
+        append(new XirInstruction(Kind.Void, l, Bind, null));
+    }
+
+    public void bindOutOfLine(XirLabel l) {
+        assert !l.inline;
+        append(new XirInstruction(Kind.Void, l, Bind, null));
+    }
+
+    public void safepoint() {
+        append(new XirInstruction(Kind.Void, null, Safepoint, null));
+    }
+
+    public void push(XirOperand value) {
+        append(new XirInstruction(Kind.Void, Push, VOID, value));
+    }
+
+    public void pop(XirOperand result) {
+        append(new XirInstruction(result.kind, Pop, result));
+    }
+
+    public XirMark mark(Object id, XirMark... references) {
+        XirMark mark = new XirMark(id, references);
+        marks.add(mark);
+        append(new XirInstruction(Kind.Void, mark, Mark, null));
+        return mark;
+    }
+
+    public void nop(int size) {
+        append(new XirInstruction(Kind.Void, size, Nop, null));
+    }
+
+    public void shouldNotReachHere() {
+        append(new XirInstruction(Kind.Void, null, ShouldNotReachHere, null));
+    }
+
+    public void shouldNotReachHere(String message) {
+        append(new XirInstruction(Kind.Void, message, ShouldNotReachHere, null));
+    }
+
+    public void callRuntime(Object rt, XirOperand result, XirOperand... args) {
+        callRuntime(rt, result, false, args);
+    }
+
+    public void callRuntime(Object rt, XirOperand result, boolean useInfoAfter, XirOperand... args) {
+        Kind resultKind = result == null ? Kind.Void : result.kind;
+        append(new XirInstruction(resultKind, new RuntimeCallInformation(rt, useInfoAfter), CallRuntime, result, args));
+    }
+
+    /**
+     * Terminates the assembly, checking invariants, in particular that {@link #resultOperand} is set, and setting {@link #finished} to {@code true}.
+     */
+    private void end() {
+        assert !finished : "template may only be finished once!";
+        assert resultOperand != null : "result operand should be set";
+        finished = true;
+    }
+
+    /**
+     * Creates an {@link XirVariableParameter variable input parameter}  of given name and {@link Kind kind}.
+     * @param name a name for the parameter
+     * @param kind the parameter kind
+     * @return the  {@link XirVariableParameter}
+     */
+    public XirVariableParameter createInputParameter(String name, Kind kind, boolean canBeConstant) {
+        assert !finished;
+        return new XirVariableParameter(this, name, kind, canBeConstant);
+    }
+
+    public XirVariableParameter createInputParameter(String name, Kind kind) {
+        return createInputParameter(name, kind, false);
+    }
+
+    /**
+     * Creates an {@link XirConstantParameter constant input parameter}  of given name and {@link Kind kind}.
+     * @param name a name for the parameter
+     * @param kind the parameter kind
+     * @return the  {@link XirConstantParameter}
+     */
+    public XirConstantParameter createConstantInputParameter(String name, Kind kind) {
+        assert !finished;
+        return new XirConstantParameter(this, name, kind);
+    }
+
+    public XirConstant createConstant(Constant constant) {
+        assert !finished;
+        XirConstant temp = new XirConstant(this, constant);
+        constants.add(temp);
+        return temp;
+    }
+
+    public XirOperand createTemp(String name, Kind kind) {
+        assert !finished;
+        XirTemp temp = new XirTemp(this, name, kind, true);
+        temps.add(temp);
+        return temp;
+    }
+
+    public XirOperand createRegister(String name, Kind kind, Register register) {
+        return createRegister(name, kind, register, false);
+    }
+
+    public XirOperand createRegisterTemp(String name, Kind kind, Register register) {
+        return createRegister(name, kind, register, true);
+    }
+
+    private XirOperand createRegister(String name, Kind kind, Register register, boolean reserve) {
+        assert !finished;
+        XirRegister fixed = new XirRegister(this, name, register.asValue(kind), reserve);
+        temps.add(fixed);
+        return fixed;
+    }
+
+    public XirParameter getParameter(String name) {
+        for (XirParameter param : parameters) {
+            if (param.name.toString().equals(name)) {
+                return param;
+            }
+        }
+        throw new IllegalArgumentException("no parameter: " + name);
+    }
+
+    public XirTemp getTemp(String name) {
+        for (XirTemp temp : temps) {
+            if (temp.name.toString().equals(name)) {
+                return temp;
+            }
+        }
+        throw new IllegalArgumentException("no temp: " + name);
+    }
+
+    public XirConstant i(int v) {
+        return createConstant(Constant.forInt(v));
+    }
+
+    public XirConstant l(long v) {
+        return createConstant(Constant.forLong(v));
+    }
+
+    public XirConstant b(boolean v) {
+        return createConstant(Constant.forBoolean(v));
+    }
+
+    public XirConstant o(Object obj) {
+        return createConstant(Constant.forObject(obj));
+    }
+
+    public void reserveOutgoingStack(int size) {
+        outgoingStackSize = Math.max(outgoingStackSize, size);
+    }
+
+    /**
+     * Finishes the assembly of a non-stub template, providing the {@link #resultOperand} and constructs the {@link XirTemplate}.
+     * @param result the {@link XirOperand} to be set as the {@link #resultOperand}
+     * @param name the name of the template
+     * @return the generated template
+     */
+    public XirTemplate finishTemplate(XirOperand result, String name) {
+        assert this.resultOperand == null;
+        assert result != null;
+        this.resultOperand = result;
+        final XirTemplate template = buildTemplate(name, false);
+        end();
+        return template;
+    }
+
+    /**
+     * Finishes the assembly of a non-stub template and constructs the {@link XirTemplate}.
+     * @param name the name of the template
+     * @return the generated template
+     */
+    public XirTemplate finishTemplate(String name) {
+        final XirTemplate template = buildTemplate(name, false);
+        end();
+        return template;
+    }
+
+    /**
+     * Finishes the assembly of a {@link XirTemplate.GlobalFlags#GLOBAL_STUB stub} and constructs the {@link XirTemplate}.
+     * @param name the name of the template
+     * @return the generated template
+     */
+    public XirTemplate finishStub(String name) {
+        final XirTemplate template = buildTemplate(name, true);
+        end();
+        return template;
+    }
+
+    /**
+     * Builds the {@link XirTemplate} from the assembly state in this object.
+     * The actual assembly is dependent on the target architecture and implemented
+     * in a concrete subclass.
+     * @param name the name of the template
+     * @param isStub {@code true} if the template represents a {@link XirTemplate.GlobalFlags#GLOBAL_STUB stub}
+     * @return the generated template
+     */
+    protected abstract XirTemplate buildTemplate(String name, boolean isStub);
+
+    public abstract XirAssembler copy();
+
+}
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirSnippet.java	Thu Jul 05 21:39:22 2012 +0200
@@ -26,7 +26,7 @@
 
 import com.oracle.graal.api.code.CompilationResult.*;
 import com.oracle.graal.api.meta.*;
-import com.oracle.max.cri.xir.CiXirAssembler.*;
+import com.oracle.max.cri.xir.XirAssembler.*;
 
 /**
  * Represents a {@link XirTemplate template of XIR} along with the {@link XirArgument arguments} to be passed to the
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirTemplate.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/XirTemplate.java	Thu Jul 05 21:39:22 2012 +0200
@@ -25,7 +25,7 @@
 import java.io.*;
 import java.util.*;
 
-import com.oracle.max.cri.xir.CiXirAssembler.*;
+import com.oracle.max.cri.xir.XirAssembler.*;
 
 /**
  * Represents a completed template of XIR code that has been first assembled by
@@ -71,12 +71,12 @@
     /**
      * The sequence of instructions for the fast (inline) path.
      */
-    public final CiXirAssembler.XirInstruction[] fastPath;
+    public final XirAssembler.XirInstruction[] fastPath;
 
     /**
      * The sequence of instructions for the slow (out of line) path.
      */
-    public final CiXirAssembler.XirInstruction[] slowPath;
+    public final XirAssembler.XirInstruction[] slowPath;
 
     /**
      * Labels used in control transfers.
@@ -130,8 +130,8 @@
                        int variableCount,
                        boolean allocateResultOperand,
                        XirOperand resultOperand,
-                       CiXirAssembler.XirInstruction[] fastPath,
-                       CiXirAssembler.XirInstruction[] slowPath,
+                       XirAssembler.XirInstruction[] fastPath,
+                       XirAssembler.XirInstruction[] slowPath,
                        XirLabel[] labels,
                        XirParameter[] parameters,
                        XirTemp[] temps,
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/package-info.java	Thu Jul 05 17:53:27 2012 +0200
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/xir/package-info.java	Thu Jul 05 21:39:22 2012 +0200
@@ -24,14 +24,14 @@
  * XIR defines a domain specific instruction set for expressing the lowering of bytecode operations. The details of the
  * lowering operations are entirely encapsulated in the runtime and are provided to the compiler on request using
  * {@link com.oracle.max.cri.xir.XirSnippet XIR snippets}. A snippet is a combination of a {@link com.oracle.max.cri.xir.XirTemplate
- * template}, which is a sequence of {@link com.oracle.max.cri.xir.CiXirAssembler.XirInstruction XIR instructions} that has
- * unbound {@link com.oracle.max.cri.xir.CiXirAssembler.XirParameter parameters}, and site-specific
+ * template}, which is a sequence of {@link com.oracle.max.cri.xir.XirAssembler.XirInstruction XIR instructions} that has
+ * unbound {@link com.oracle.max.cri.xir.XirAssembler.XirParameter parameters}, and site-specific
  * {@link com.oracle.max.cri.xir.XirArgument arguments} that are bound to the parameters.
  * <p>
  * The runtime is responsible for creating the {@link com.oracle.max.cri.xir.XirTemplate templates} and provides these to the
  * compiler as part of the initialization process.
  * <p>
  * The XIR instruction set has no textual representation, and therefore no parser. An assembly is represented by an
- * instance of {@link com.oracle.max.cri.xir.CiXirAssembler}, which provides methods to create instructions and operands.
+ * instance of {@link com.oracle.max.cri.xir.XirAssembler}, which provides methods to create instructions and operands.
  */
 package com.oracle.max.cri.xir;