changeset 4206:430b5db3e6f8

Remove CiVariable from the CRI
author Christian Wimmer <Christian.Wimmer@Oracle.com>
date Tue, 03 Jan 2012 12:10:27 -0800
parents 2af849af1723
children e2578f3e8ab2
files graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiAddress.java graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiVariable.java graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/package-info.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/LIRVerifier.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/Location.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/LocationMap.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/MoveResolver.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/ValueUtil.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScanWalker.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/RegisterVerifier.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/DebugInfoBuilder.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/StandardOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/Variable.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ArithmeticOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ControlFlowOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DivOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LogicFloatOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MoveOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MulOpcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Op1Opcode.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ShiftOpcode.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/ArrayWriteBarrier.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/FieldWriteBarrier.java graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/WriteBarrier.java graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/nodes/MathIntrinsicNode.java graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/target/amd64/AMD64MathIntrinsicOpcode.java
diffstat 44 files changed, 390 insertions(+), 716 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiAddress.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiAddress.java	Tue Jan 03 12:10:27 2012 -0800
@@ -107,9 +107,6 @@
             this.index = IllegalValue;
             this.scale = Scale.Times1;
         } else {
-            assert isIllegal(base) || isVariable(base) || isRegister(base);
-            assert isIllegal(index) || isVariable(index) || isRegister(index);
-
             this.index = index;
             this.scale = scale;
             this.displacement = displacement;
@@ -192,14 +189,6 @@
         }
     }
 
-    private static String s(CiValue location) {
-        if (isRegister(location)) {
-            return asRegister(location).name;
-        }
-        assert isVariable(location);
-        return "v" + ((CiVariable) location).index;
-    }
-
     private static String signed(int i) {
         if (i >= 0) {
             return "+" + i;
@@ -211,10 +200,10 @@
     public String toString() {
         // Checkstyle: stop
         switch (format()) {
-            case BASE            : return "[" + s(base) + kindSuffix() + "]";
-            case BASE_DISP       : return "[" + s(base) + signed(displacement) + kindSuffix() + "]";
-            case BASE_INDEX      : return "[" + s(base) + "+" + s(index) + kindSuffix() + "]";
-            case BASE_INDEX_DISP : return "[" + s(base) + "+(" + s(index) + "*" + scale.value + ")" + signed(displacement) + kindSuffix() + "]";
+            case BASE            : return "[" + base + kindSuffix() + "]";
+            case BASE_DISP       : return "[" + base + signed(displacement) + kindSuffix() + "]";
+            case BASE_INDEX      : return "[" + base + "+" + index + kindSuffix() + "]";
+            case BASE_INDEX_DISP : return "[" + base + "+(" + index + "*" + scale.value + ")" + signed(displacement) + kindSuffix() + "]";
             case PLACEHOLDER     : return "[<placeholder>]";
             default              : throw new IllegalArgumentException("unknown format: " + format());
         }
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiValueUtil.java	Tue Jan 03 12:10:27 2012 -0800
@@ -38,17 +38,6 @@
     }
 
 
-    public static boolean isVariable(CiValue value) {
-        assert value != null;
-        return value instanceof CiVariable;
-    }
-
-    public static CiVariable asVariable(CiValue value) {
-        assert value != null;
-        return (CiVariable) value;
-    }
-
-
     public static boolean isConstant(CiValue value) {
         assert value != null;
         return value instanceof CiConstant;
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/CiVariable.java	Tue Jan 03 18:22:10 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2010, 2012, 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.ci;
-
-/**
- * Represents a value that is yet to be bound to a machine location (such as
- * a {@linkplain CiRegister register} or stack {@linkplain CiAddress address})
- * by a register allocator.
- */
-public final class CiVariable extends CiValue {
-    private static final long serialVersionUID = 4507578431686109809L;
-
-    /**
-     * The identifier of the variable. This is a non-zero index in a contiguous 0-based name space.
-     */
-    public final int index;
-
-    /**
-     * Creates a new variable.
-     * @param kind
-     * @param index
-     */
-    private CiVariable(CiKind kind, int index) {
-        super(kind);
-        this.index = index;
-    }
-
-    private static CiVariable[] generate(CiKind kind, int count) {
-        CiVariable[] variables = new CiVariable[count];
-        for (int i = 0; i < count; i++) {
-            variables[i] = new CiVariable(kind, i);
-        }
-        return variables;
-    }
-
-    private static final int CACHE_PER_KIND_SIZE = 100;
-
-    /**
-     * Cache of common variables.
-     */
-    private static final CiVariable[][] cache = new CiVariable[CiKind.values().length][];
-    static {
-        for (CiKind kind : CiKind.values()) {
-            cache[kind.ordinal()] = generate(kind, CACHE_PER_KIND_SIZE);
-        }
-    }
-
-    /**
-     * Gets a variable for a given kind and index.
-     *
-     * @param kind
-     * @param index
-     * @return the corresponding {@code CiVariable}
-     */
-    public static CiVariable get(CiKind kind, int index) {
-        //assert kind == kind.stackKind() : "Variables can be only created for stack kinds";
-        assert index >= 0;
-        CiVariable[] cachedVars = cache[kind.ordinal()];
-        if (index < cachedVars.length) {
-            return cachedVars[index];
-        }
-        return new CiVariable(kind, index);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof CiVariable) {
-            CiVariable var = (CiVariable) obj;
-            return kind == var.kind && index == var.index;
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return (index << 4) | kind.ordinal();
-    }
-
-    @Override
-    public String toString() {
-        return "v" + index + kindSuffix();
-    }
-}
--- a/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/package-info.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.cri/src/com/oracle/max/cri/ci/package-info.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, 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
@@ -40,7 +40,7 @@
  * <li>{@link com.oracle.max.cri.ci.CiRegisterValue}: a value stored in a {@linkplain com.oracle.max.cri.ci.CiRegister target machine register}.
  * <li>{@link com.oracle.max.cri.ci.CiStackSlot}: a spill slot or an outgoing stack-based argument in a method's frame.
  * <li>{@link com.oracle.max.cri.ci.CiAddress}: an address in target machine memory.
- * <li>{@link com.oracle.max.cri.ci.CiVariable}: a value (cf. virtual register) that is yet to be bound to a target machine location (physical register or memory address).
+ * <li>{@link com.oracle.max.graal.compiler.lir.CiVariable}: a value (cf. virtual register) that is yet to be bound to a target machine location (physical register or memory address).
  *</ul>
  */
 package com.oracle.max.cri.ci;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/DataFlowAnalysis.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, 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
@@ -38,14 +38,12 @@
 public class DataFlowAnalysis {
     private final GraalContext context;
     private final LIR lir;
-    private final OperandPool operands;
     private final RiRegisterConfig registerConfig;
     private final CiCallingConvention incomingArguments;
 
-    public DataFlowAnalysis(GraalContext context, LIR lir, OperandPool operands, RiRegisterConfig registerConfig, CiCallingConvention incomingArguments) {
+    public DataFlowAnalysis(GraalContext context, LIR lir, RiRegisterConfig registerConfig, CiCallingConvention incomingArguments) {
         this.context = context;
         this.lir = lir;
-        this.operands = operands;
         this.registerConfig = registerConfig;
         this.incomingArguments = incomingArguments;
     }
@@ -62,7 +60,7 @@
     }
 
     private int numVariables() {
-        return operands.numVariables();
+        return lir.numVariables();
     }
 
     private boolean isAllocatableRegister(CiValue value) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/simple/SpillAllAllocator.java	Tue Jan 03 12:10:27 2012 -0800
@@ -22,19 +22,17 @@
  */
 package com.oracle.max.graal.alloc.simple;
 
+import static com.oracle.max.cri.ci.CiValueUtil.*;
 import static com.oracle.max.graal.alloc.util.ValueUtil.*;
 
 import java.util.*;
 
 import com.oracle.max.cri.ci.*;
-import com.oracle.max.cri.ci.CiRegister.*;
+import com.oracle.max.cri.ci.CiRegister.RegisterFlag;
 import com.oracle.max.cri.ri.*;
 import com.oracle.max.criutils.*;
 import com.oracle.max.graal.alloc.util.*;
-import com.oracle.max.graal.alloc.util.MoveResolver;
-import com.oracle.max.graal.alloc.util.RegisterVerifier;
 import com.oracle.max.graal.compiler.*;
-import com.oracle.max.graal.compiler.alloc.*;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure;
 import com.oracle.max.graal.compiler.schedule.*;
@@ -44,21 +42,19 @@
     private final GraalContext context;
     private final LIR lir;
     private final FrameMap frameMap;
-    private final OperandPool operands;
     private final RiRegisterConfig registerConfig;
     private final CiCallingConvention incomingArguments;
 
     private final DataFlowAnalysis dataFlow;
 
-    public SpillAllAllocator(GraalContext context, LIR lir, GraalCompilation compilation, OperandPool pool, RiRegisterConfig registerConfig, CiCallingConvention incomingArguments) {
+    public SpillAllAllocator(GraalContext context, LIR lir, GraalCompilation compilation, RiRegisterConfig registerConfig, CiCallingConvention incomingArguments) {
         this.context = context;
         this.lir = lir;
-        this.operands = pool;
         this.registerConfig = registerConfig;
         this.frameMap = compilation.frameMap();
         this.incomingArguments = incomingArguments;
 
-        this.dataFlow = new DataFlowAnalysis(context, lir, pool, registerConfig, incomingArguments);
+        this.dataFlow = new DataFlowAnalysis(context, lir, registerConfig, incomingArguments);
         this.blockLocations = new LocationMap[lir.linearScanOrder().size()];
         this.moveResolver = new MoveResolver(frameMap);
     }
@@ -120,7 +116,7 @@
     private LIRInstruction curInstruction;
 
     public void execute() {
-        assert LIRVerifier.verify(true, lir, incomingArguments, frameMap, registerConfig, operands);
+        assert LIRVerifier.verify(true, lir, incomingArguments, frameMap, registerConfig);
 
         dataFlow.execute();
 
@@ -142,7 +138,7 @@
 
         context.observable.fireCompilationEvent("After register asignment", lir);
 
-        assert LIRVerifier.verify(true, lir, incomingArguments, frameMap, registerConfig, operands);
+        assert LIRVerifier.verify(true, lir, incomingArguments, frameMap, registerConfig);
     }
 
     private void allocate() {
@@ -161,13 +157,13 @@
         trace(1, "==== start spill all allocation ====");
         curInRegisterState = new Object[maxRegisterNum()];
         curOutRegisterState = new Object[maxRegisterNum()];
-        curRegisterLocations = new LocationMap(operands.numVariables());
+        curRegisterLocations = new LocationMap(lir.numVariables());
         for (LIRBlock block : lir.linearScanOrder()) {
             trace(1, "start block %s  loop %d depth %d", block, block.loopIndex(), block.loopDepth());
             assert checkEmpty(curOutRegisterState);
 
             if (block.numberOfPreds() == 0) {
-                curStackLocations = new LocationMap(operands.numVariables());
+                curStackLocations = new LocationMap(lir.numVariables());
                 trace(1, "  arguments");
                 curInstruction = lir.startBlock().lir().get(0);
                 for (CiValue value : incomingArguments.locations) {
@@ -255,7 +251,7 @@
         if (isVariable(value)) {
             trace(3, "    kill variable %s", value);
 
-            CiVariable variable = asVariable(value);
+            Variable variable = asVariable(value);
             curStackLocations.clear(variable);
 
             Location loc = curRegisterLocations.get(variable);
@@ -371,17 +367,9 @@
         }
     }
 
-    private Location allocateRegister(CiVariable variable, Object[] inRegisterState, Object[] outRegisterState) {
+    private Location allocateRegister(Variable variable, Object[] inRegisterState, Object[] outRegisterState) {
         EnumMap<RegisterFlag, CiRegister[]> categorizedRegs = registerConfig.getCategorizedAllocatableRegisters();
-        CiRegister[] availableRegs;
-        if (operands.mustBeByteRegister(variable)) {
-            assert variable.kind != CiKind.Float && variable.kind != CiKind.Double : "cpu regs only";
-            availableRegs = categorizedRegs.get(RegisterFlag.Byte);
-        } else if (variable.kind == CiKind.Float || variable.kind == CiKind.Double) {
-            availableRegs = categorizedRegs.get(RegisterFlag.FPU);
-        } else {
-            availableRegs = categorizedRegs.get(RegisterFlag.CPU);
-        }
+        CiRegister[] availableRegs = categorizedRegs.get(variable.flag);
 
         for (CiRegister reg : availableRegs) {
             if ((inRegisterState == null || inRegisterState[reg.number] == null) && (outRegisterState == null || outRegisterState[reg.number] == null)) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/LIRVerifier.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/LIRVerifier.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -22,6 +22,7 @@
  */
 package com.oracle.max.graal.alloc.util;
 
+import static com.oracle.max.cri.ci.CiValueUtil.*;
 import static com.oracle.max.graal.alloc.util.ValueUtil.*;
 
 import java.util.*;
@@ -29,7 +30,6 @@
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
 import com.oracle.max.criutils.*;
-import com.oracle.max.graal.compiler.alloc.*;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure;
 import com.oracle.max.graal.compiler.schedule.*;
@@ -61,19 +61,19 @@
     }
 
 
-    public static boolean verify(boolean beforeRegisterAllocation, LIR lir, CiCallingConvention incomingArguments, FrameMap frameMap, RiRegisterConfig registerConfig, OperandPool operands) {
-        LIRVerifier verifier = new LIRVerifier(beforeRegisterAllocation, lir, frameMap, registerConfig, operands);
+    public static boolean verify(boolean beforeRegisterAllocation, LIR lir, CiCallingConvention incomingArguments, FrameMap frameMap, RiRegisterConfig registerConfig) {
+        LIRVerifier verifier = new LIRVerifier(beforeRegisterAllocation, lir, frameMap, registerConfig);
         verifier.verify(incomingArguments);
         return true;
     }
 
-    private LIRVerifier(boolean beforeRegisterAllocation, LIR lir, FrameMap frameMap, RiRegisterConfig registerConfig, OperandPool operands) {
+    private LIRVerifier(boolean beforeRegisterAllocation, LIR lir, FrameMap frameMap, RiRegisterConfig registerConfig) {
         this.beforeRegisterAllocation = beforeRegisterAllocation;
         this.lir = lir;
         this.frameMap = frameMap;
         this.registerConfig = registerConfig;
         this.blockLiveOut = new BitSet[lir.linearScanOrder().size()];
-        this.variableDefinitions = new Object[operands.numVariables()];
+        this.variableDefinitions = new Object[lir.numVariables()];
     }
 
     private BitSet curVariablesLive;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/Location.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/Location.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, 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
@@ -23,14 +23,15 @@
 package com.oracle.max.graal.alloc.util;
 
 import com.oracle.max.cri.ci.*;
+import com.oracle.max.graal.compiler.lir.*;
 
 public class Location extends CiValue {
     private static final long serialVersionUID = -1786677729152726126L;
 
-    public final CiVariable variable;
+    public final Variable variable;
     public final CiValue location;
 
-    public Location(CiVariable variable, CiValue location) {
+    public Location(Variable variable, CiValue location) {
         super(variable.kind);
         this.variable = variable;
         this.location = location;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/LocationMap.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/LocationMap.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, 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
@@ -27,6 +27,7 @@
 import java.util.*;
 
 import com.oracle.max.cri.ci.*;
+import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure;
 
 public class LocationMap {
@@ -40,7 +41,7 @@
         locations = Arrays.copyOf(template.locations, template.locations.length);
     }
 
-    public Location get(CiVariable variable) {
+    public Location get(Variable variable) {
         assert locations[variable.index] == null || locations[variable.index].variable == variable;
         return locations[variable.index];
     }
@@ -49,7 +50,7 @@
         locations[location.variable.index] = location;
     }
 
-    public void clear(CiVariable variable) {
+    public void clear(Variable variable) {
         locations[variable.index] = null;
     }
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/MoveResolver.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/MoveResolver.java	Tue Jan 03 12:10:27 2012 -0800
@@ -257,11 +257,11 @@
         return count == 0 || (count == 1 && isLocation(from) && asLocation(from).location == to.location);
     }
 
-    private static void insertExchange(Location from, Location to) {
+    private void insertExchange(Location from, Location to) {
         trace(3, "mr      XCHG %s, %s", from, to);
+        // TODO create XCHG instruction and use it here
+        insertionBuffer.append(insertPos, null);
         throw Util.unimplemented();
-        // TODO create XCHG instruction and use it here
-        // insertionBuffer.append(StandardOp.XCHG.create(from, to));
     }
 
     private void insertMove(CiValue src, Location dst) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/ValueUtil.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/alloc/util/ValueUtil.java	Tue Jan 03 12:10:27 2012 -0800
@@ -23,9 +23,21 @@
 package com.oracle.max.graal.alloc.util;
 
 import com.oracle.max.cri.ci.*;
+import com.oracle.max.graal.compiler.lir.*;
 
 public class ValueUtil extends CiValueUtil {
 
+    public static boolean isVariable(CiValue value) {
+        assert value != null;
+        return value instanceof Variable;
+    }
+
+    public static Variable asVariable(CiValue value) {
+        assert value != null;
+        return (Variable) value;
+    }
+
+
     public static boolean isLocation(CiValue value) {
         assert value != null;
         return value instanceof Location;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Tue Jan 03 12:10:27 2012 -0800
@@ -350,7 +350,7 @@
                 }
 
                 if (GraalOptions.AllocSSA) {
-                    new SpillAllAllocator(context(), lir, this, lirGenerator.operands, registerConfig, lirGenerator.incomingArguments).execute();
+                    new SpillAllAllocator(context(), lir, this, registerConfig, lirGenerator.incomingArguments).execute();
                 } else {
                     new LinearScan(this, lir, lirGenerator, frameMap()).allocate();
                 }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/Interval.java	Tue Jan 03 12:10:27 2012 -0800
@@ -22,7 +22,7 @@
  */
 package com.oracle.max.graal.compiler.alloc;
 
-import static com.oracle.max.cri.ci.CiValueUtil.*;
+import static com.oracle.max.graal.alloc.util.ValueUtil.*;
 
 import java.util.*;
 
@@ -398,7 +398,7 @@
     }
 
     /**
-     * The {@linkplain CiRegisterValue register} or {@linkplain CiVariable variable} for this interval prior to register allocation.
+     * The {@linkplain CiRegisterValue register} or {@linkplain Variable variable} for this interval prior to register allocation.
      */
     public final CiValue operand;
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Tue Jan 03 12:10:27 2012 -0800
@@ -24,6 +24,7 @@
 
 import static com.oracle.max.cri.ci.CiUtil.*;
 import static com.oracle.max.cri.ci.CiValueUtil.*;
+import static com.oracle.max.graal.alloc.util.ValueUtil.*;
 
 import java.util.*;
 
@@ -40,7 +41,6 @@
 import com.oracle.max.graal.compiler.lir.LIRInstruction.ValueProcedure;
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.graph.*;
-import com.oracle.max.graal.nodes.*;
 
 /**
  * An implementation of the linear scan register allocator algorithm described
@@ -64,8 +64,6 @@
      */
     final LIRBlock[] sortedBlocks;
 
-    final OperandPool operands;
-
     /**
      * Map from {@linkplain #operandNumber(CiValue) operand numbers} to intervals.
      */
@@ -105,6 +103,20 @@
      */
     BitMap2D intervalInLoop;
 
+    /**
+     * The variable operands allocated from this pool. The {@linkplain #operandNumber(CiValue) number}
+     * of the first variable operand in this pool is one greater than the number of the last
+     * register operand in the pool.
+     */
+    private final ArrayList<Variable> variables;
+
+    /**
+     * The {@linkplain #operandNumber(CiValue) number} of the first variable operand
+     * {@linkplain #newVariable(CiKind) allocated} from this pool.
+     */
+    private final int firstVariableNumber;
+
+
     public LinearScan(GraalCompilation compilation, LIR ir, LIRGenerator gen, FrameMap frameMap) {
         this.context = compilation.compiler.context;
         this.compilation = compilation;
@@ -112,13 +124,11 @@
         this.gen = gen;
         this.frameMap = frameMap;
         this.sortedBlocks = ir.linearScanOrder().toArray(new LIRBlock[ir.linearScanOrder().size()]);
-        CiRegister[] allocatableRegisters = compilation.registerConfig.getAllocatableRegisters();
-        this.registers = new CiRegister[CiRegister.maxRegisterNumber(allocatableRegisters) + 1];
-        for (CiRegister reg : allocatableRegisters) {
-            registers[reg.number] = reg;
-        }
         this.registerAttributes = compilation.registerConfig.getAttributesMap();
-        this.operands = gen.operands;
+
+        this.registers = compilation.compiler.target.arch.registers;
+        this.firstVariableNumber = registers.length;
+        this.variables = new ArrayList<>(ir.numVariables() * 3 / 2);
     }
 
     public static boolean isVariableOrRegister(CiValue value) {
@@ -128,13 +138,48 @@
 
     /**
      * Converts an operand (variable or register) to an index in a flat address space covering all the
-     * {@linkplain CiVariable variables} and {@linkplain CiRegisterValue registers} being processed by this
+     * {@linkplain Variable variables} and {@linkplain CiRegisterValue registers} being processed by this
      * allocator.
      */
-    int operandNumber(CiValue operand) {
-        return operands.operandNumber(operand);
+    private int operandNumber(CiValue operand) {
+        if (isRegister(operand)) {
+            int number = asRegister(operand).number;
+            assert number < firstVariableNumber;
+            return number;
+        }
+        assert isVariable(operand) : operand;
+        return firstVariableNumber + ((Variable) operand).index;
     }
 
+    /**
+     * Gets the operand denoted by a given operand number.
+     */
+    private CiValue operandFor(int operandNumber) {
+        if (operandNumber < firstVariableNumber) {
+            assert operandNumber >= 0;
+            return registers[operandNumber].asValue();
+        }
+        int index = operandNumber - firstVariableNumber;
+        Variable variable = variables.get(index);
+        assert variable.index == index;
+        return variable;
+    }
+
+    /**
+     * Gets the number of operands. This value will increase by 1 for new variable.
+     */
+    private int operandSize() {
+        return firstVariableNumber + ir.numVariables();
+    }
+
+    /**
+     * Gets the highest operand number for a register operand. This value will never change.
+     */
+    public int maxRegisterNumber() {
+        return firstVariableNumber - 1;
+    }
+
+
     static final IntervalPredicate IS_PRECOLORED_INTERVAL = new IntervalPredicate() {
         @Override
         public boolean apply(Interval i) {
@@ -206,21 +251,15 @@
             intervals = Arrays.copyOf(intervals, intervals.length * 2);
         }
         intervalsSize++;
-        Interval interval = createInterval(operands.newVariable(source.kind()));
+        Variable variable = new Variable(source.kind(), ir.nextVariable(), asVariable(source.operand).flag);
+        assert variables.size() == variable.index;
+        variables.add(variable);
+
+        Interval interval = createInterval(variable);
         assert intervals[intervalsSize - 1] == interval;
         return interval;
     }
 
-    // copy the variable flags if an interval is split
-    void copyRegisterFlags(Interval from, Interval to) {
-        if (operands.mustBeByteRegister(from.operand)) {
-            operands.setMustBeByteRegister((CiVariable) to.operand);
-        }
-
-        // Note: do not copy the mustStartInMemory flag because it is not necessary for child
-        // intervals (only the very beginning of the interval must be in memory)
-    }
-
     // access to block list (sorted in linear scan order)
     int blockCount() {
         assert sortedBlocks.length == ir.linearScanOrder().size() : "invalid cached block list";
@@ -238,7 +277,7 @@
      * intervals}.
      */
     int liveSetSize() {
-        return firstDerivedIntervalIndex == -1 ? operands.size() : firstDerivedIntervalIndex;
+        return firstDerivedIntervalIndex == -1 ? operandSize() : firstDerivedIntervalIndex;
     }
 
     int numLoops() {
@@ -506,6 +545,20 @@
      * Numbers all instructions in all blocks. The numbering follows the {@linkplain ComputeLinearScanOrder linear scan order}.
      */
     void numberInstructions() {
+        ValueProcedure setVariableProc = new ValueProcedure() {
+            @Override
+            public CiValue doValue(CiValue value) {
+                if (isVariable(value)) {
+                    int variableIdx = asVariable(value).index;
+                    while (variables.size() <= variableIdx) {
+                        variables.add(null);
+                    }
+                    variables.set(variableIdx, asVariable(value));
+                }
+                return value;
+            }
+        };
+
         // Assign IDs to LIR nodes and build a mapping, lirOps, from ID to LIRInstruction node.
         int numBlocks = blockCount();
         int numInstructions = 0;
@@ -534,6 +587,9 @@
                 opIdToBlockMap[index] = block;
                 assert instructionForId(opId) == op : "must match";
 
+                op.forEachTemp(setVariableProc);
+                op.forEachOutput(setVariableProc);
+
                 index++;
                 opId += 2; // numbering of lirOps by two
             }
@@ -541,6 +597,13 @@
         }
         assert index == numInstructions : "must match";
         assert (index << 1) == opId : "must match: " + (index << 1);
+
+        if (GraalOptions.DetailedAsserts) {
+            for (int i = 0; i < variables.size(); i++) {
+                assert variables.get(i) != null && variables.get(i).index == i;
+            }
+            assert variables.size() == ir.numVariables();
+        }
     }
 
     /**
@@ -550,7 +613,7 @@
         int numBlocks = blockCount();
         int liveSize = liveSetSize();
 
-        BitMap2D localIntervalInLoop = new BitMap2D(operands.size(), numLoops());
+        BitMap2D localIntervalInLoop = new BitMap2D(operandSize(), numLoops());
 
         // iterate all blocks
         for (int i = 0; i < numBlocks; i++) {
@@ -802,20 +865,8 @@
         // print some additional information to simplify debugging
         for (int operandNum = 0; operandNum < ir.startBlock().liveIn.size(); operandNum++) {
             if (ir.startBlock().liveIn.get(operandNum)) {
-                CiValue operand = operands.operandFor(operandNum);
-                ValueNode instr = isVariable(operand) ? gen.operands.instructionForResult(((CiVariable) operand)) : null;
-                TTY.println(" var %d (HIR instruction %s); operand=%s", operandNum, instr == null ? " " : instr.toString(), operand.toString());
-
-                if (instr instanceof PhiNode) {
-                    PhiNode phi = (PhiNode) instr;
-                    TTY.println("phi block begin: " + phi.merge());
-                    TTY.println("pred count on blockbegin: " + phi.merge().phiPredecessorCount());
-                    TTY.println("phi values: " + phi.valueCount());
-                    TTY.println("phi block preds:");
-                    for (EndNode n : phi.merge().cfgPredecessors()) {
-                        TTY.println(n.toString());
-                    }
-                }
+                CiValue operand = operandFor(operandNum);
+                TTY.println(" var %d; operand=%s", operandNum, operand.toString());
 
                 for (int j = 0; j < numBlocks; j++) {
                     LIRBlock block = blockAt(j);
@@ -850,7 +901,7 @@
         // (live set must be empty at fixed intervals)
         for (int i = 0; i < numBlocks; i++) {
             LIRBlock block = blockAt(i);
-            for (int j = 0; j <= operands.maxRegisterNumber(); j++) {
+            for (int j = 0; j <= maxRegisterNumber(); j++) {
                 assert !block.liveIn.get(j) : "liveIn  set of fixed register must be empty";
                 assert !block.liveOut.get(j) : "liveOut set of fixed register must be empty";
                 assert !block.liveGen.get(j) : "liveGen set of fixed register must be empty";
@@ -883,11 +934,7 @@
             interval.setKind(kind);
         }
 
-        if (isVariable(operand) && gen.operands.mustStayInMemory((CiVariable) operand)) {
-            interval.addRange(from, maxOpId());
-        } else {
-            interval.addRange(from, to);
-        }
+        interval.addRange(from, to);
 
         // Register use position at even instruction id.
         interval.addUsePos(to & ~1, registerPriority);
@@ -971,28 +1018,14 @@
     /**
      * Determines the register priority for an instruction's output/result operand.
      */
-    RegisterPriority registerPriorityOfOutputOperand(LIRInstruction op, CiValue operand) {
+    static RegisterPriority registerPriorityOfOutputOperand(LIRInstruction op) {
         if (op.code == StandardOpcode.MOVE) {
-            CiValue res = op.result();
-            boolean resultInMemory = isVariable(res) && operands.mustStartInMemory((CiVariable) res);
-
-            if (resultInMemory) {
-                // Begin of an interval with mustStartInMemory set.
-                // This interval will always get a stack slot first, so return noUse.
-                return RegisterPriority.None;
-
-            } else if (isStackSlot(op.input(0))) {
+            if (isStackSlot(op.input(0))) {
                 // method argument (condition must be equal to handleMethodArguments)
                 return RegisterPriority.None;
-
             }
         }
 
-        if (isVariable(operand) && operands.mustStartInMemory((CiVariable) operand)) {
-            // result is a stack-slot, so prevent immediate reloading
-            return RegisterPriority.None;
-        }
-
         // all other operands require a register
         return RegisterPriority.MustHaveRegister;
     }
@@ -1000,17 +1033,9 @@
     /**
      * Determines the priority which with an instruction's input operand will be allocated a register.
      */
-    RegisterPriority registerPriorityOfInputOperand(LIRInstruction op, int operandIndex) {
+    static RegisterPriority registerPriorityOfInputOperand(LIRInstruction op, int operandIndex) {
         if (op.code == StandardOpcode.MOVE) {
-            CiValue res = op.result();
-            boolean resultInMemory = isVariable(res) && operands.mustStartInMemory((CiVariable) res);
-
-            if (resultInMemory) {
-                // Move to an interval with mustStartInMemory set.
-                // To avoid moves from stack to stack (not allowed) force the input operand to a register
-                return RegisterPriority.MustHaveRegister;
-
-            } else if (isVariableOrRegister(op.input(0)) && isVariableOrRegister(op.result())) {
+            if (isVariableOrRegister(op.input(0)) && isVariableOrRegister(op.result())) {
                 // The input operand is not forced to a register (moves from stack to register are allowed),
                 // but it is faster if the input operand is in a register
                 return RegisterPriority.ShouldHaveRegister;
@@ -1074,7 +1099,7 @@
     }
 
     void buildIntervals() {
-        intervalsSize = operands.size();
+        intervalsSize = operandSize();
         intervals = new Interval[intervalsSize + INITIAL_SPLIT_INTERVALS_CAPACITY];
 
         // create a list with all caller-save registers (cpu, fpu, xmm)
@@ -1095,7 +1120,7 @@
             BitMap live = block.liveOut;
             for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) {
                 assert live.get(operandNum) : "should not stop here otherwise";
-                CiValue operand = operands.operandFor(operandNum);
+                CiValue operand = operandFor(operandNum);
                 if (GraalOptions.TraceLinearScanLevel >= 2) {
                     TTY.println("live in %s to %d", operand, blockTo + 2);
                 }
@@ -1138,7 +1163,7 @@
                 for (k = 0; k < n; k++) {
                     CiValue operand = op.operandAt(LIRInstruction.OperandMode.Output, k);
                     if (isVariableOrRegister(operand)) {
-                        addDef(operand, opId, registerPriorityOfOutputOperand(op, operand), operand.kind.stackKind());
+                        addDef(operand, opId, registerPriorityOfOutputOperand(op), operand.kind.stackKind());
                     }
                 }
 
@@ -1405,7 +1430,7 @@
     void resolveCollectMappings(LIRBlock fromBlock, LIRBlock toBlock, MoveResolver moveResolver) {
         assert moveResolver.checkEmpty();
 
-        int numOperands = operands.size();
+        int numOperands = operandSize();
         BitMap liveAtEdge = toBlock.liveIn;
 
         // visit all variables for which the liveAtEdge bit is set
@@ -1413,7 +1438,7 @@
             assert operandNum < numOperands : "live information set for not exisiting interval";
             assert fromBlock.liveOut.get(operandNum) && toBlock.liveIn.get(operandNum) : "interval not live at this edge";
 
-            CiValue liveOperand = operands.operandFor(operandNum);
+            CiValue liveOperand = operandFor(operandNum);
             Interval fromInterval = intervalAtBlockEnd(fromBlock, liveOperand);
             Interval toInterval = intervalAtBlockBegin(toBlock, liveOperand);
 
@@ -1591,7 +1616,7 @@
      * @param mode the usage mode for {@code operand} by the instruction
      * @return the location assigned for the operand
      */
-    private CiValue colorLirOperand(CiVariable operand, int opId, OperandMode mode) {
+    private CiValue colorLirOperand(Variable operand, int opId, OperandMode mode) {
         Interval interval = intervalFor(operand);
         assert interval != null : "interval must exist";
 
@@ -1725,7 +1750,7 @@
                 // Get current location of operand
                 // The operand must be live because debug information is considered when building the intervals
                 // if the interval is not live, colorLirOperand will cause an assert on failure
-                CiValue result = colorLirOperand((CiVariable) operand, tempOpId, mode);
+                CiValue result = colorLirOperand((Variable) operand, tempOpId, mode);
                 assert !hasCall(tempOpId) || isStackSlot(result) || !isCallerSave(result) : "cannot have caller-save register operands at calls";
                 return result;
             }
@@ -1751,7 +1776,7 @@
                 for (int k = 0; k < n; k++) {
                     CiValue operand = op.operandAt(mode, k);
                     if (isVariable(operand)) {
-                        op.setOperandAt(mode, k, colorLirOperand((CiVariable) operand, op.id(), mode));
+                        op.setOperandAt(mode, k, colorLirOperand((Variable) operand, op.id(), mode));
                     }
                 }
             }
@@ -2078,10 +2103,8 @@
                 if (GraalOptions.TraceLinearScanLevel >= 4) {
                     TTY.println("checking interval %d of block B%d", operandNum, block.blockID());
                 }
-                CiValue operand = operands.operandFor(operandNum);
+                CiValue operand = operandFor(operandNum);
                 assert isVariable(operand) : "value must have variable operand";
-                ValueNode value = gen.operands.instructionForResult(((CiVariable) operand));
-                assert value != null : "all intervals live across block boundaries must have Value";
                 // TKR assert value.asConstant() == null || value.isPinned() :
                 // "only pinned constants can be alive accross block boundaries";
             }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScanWalker.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScanWalker.java	Tue Jan 03 12:10:27 2012 -0800
@@ -23,12 +23,12 @@
 package com.oracle.max.graal.compiler.alloc;
 
 import static com.oracle.max.cri.ci.CiUtil.*;
-import static com.oracle.max.cri.ci.CiValueUtil.*;
+import static com.oracle.max.graal.alloc.util.ValueUtil.*;
 
 import java.util.*;
 
 import com.oracle.max.cri.ci.*;
-import com.oracle.max.cri.ci.CiRegister.*;
+import com.oracle.max.cri.ci.CiRegister.RegisterFlag;
 import com.oracle.max.criutils.*;
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.alloc.Interval.RegisterBinding;
@@ -430,7 +430,6 @@
 
         Interval splitPart = interval.split(optimalSplitPos, allocator);
 
-        allocator.copyRegisterFlags(interval, splitPart);
         splitPart.setInsertMoveWhenActivated(moveNecessary);
 
         assert splitPart.from() >= currentInterval.currentFrom() : "cannot append new interval before current walk position";
@@ -817,14 +816,7 @@
 
     void initVarsForAlloc(Interval interval) {
         EnumMap<RegisterFlag, CiRegister[]> categorizedRegs = allocator.compilation.registerConfig.getCategorizedAllocatableRegisters();
-        if (allocator.operands.mustBeByteRegister(interval.operand)) {
-            assert interval.kind()  != CiKind.Float && interval.kind()  != CiKind.Double : "cpu regs only";
-            availableRegs = categorizedRegs.get(RegisterFlag.Byte);
-        } else if (interval.kind()  == CiKind.Float || interval.kind()  == CiKind.Double) {
-            availableRegs = categorizedRegs.get(RegisterFlag.FPU);
-        } else {
-            availableRegs = categorizedRegs.get(RegisterFlag.CPU);
-        }
+        availableRegs = categorizedRegs.get(asVariable(interval.operand).flag);
     }
 
     static boolean isMove(LIRInstruction op, Interval from, Interval to) {
@@ -920,21 +912,7 @@
             result = false;
 
         } else {
-            if (isVariable(operand) && allocator.operands.mustStartInMemory((CiVariable) operand)) {
-                assert interval.location() == null : "register already assigned";
-                allocator.assignSpillSlot(interval);
-
-                if (!allocator.operands.mustStayInMemory((CiVariable) operand)) {
-                    // activating an interval that must start in a stack slot but may get a register later
-                    // used for lirRoundfp: rounding is done by store to stack and reload later
-                    if (GraalOptions.TraceLinearScanLevel >= 4) {
-                        TTY.println("      interval must start in stack slot . split it before first use");
-                    }
-                    splitStackInterval(interval);
-                }
-
-                result = false;
-            } else if (interval.location() == null) {
+            if (interval.location() == null) {
                 // interval has not assigned register . normal allocation
                 // (this is the normal case for most intervals)
                 if (GraalOptions.TraceLinearScanLevel >= 4) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/OperandPool.java	Tue Jan 03 18:22:10 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,287 +0,0 @@
-/*
- * Copyright (c) 2010, 2012, 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.graal.compiler.alloc;
-
-import static com.oracle.max.cri.ci.CiValueUtil.*;
-
-import java.util.*;
-
-import com.oracle.max.cri.ci.*;
-import com.oracle.max.graal.compiler.*;
-import com.oracle.max.graal.graph.*;
-import com.oracle.max.graal.nodes.*;
-
-/**
- * An ordered, 0-based indexable pool of instruction operands for a method being compiled.
- * The physical {@linkplain CiRegister registers} of the platform occupy the front of the
- * pool (starting at index 0) followed by {@linkplain CiVariable variable} operands.
- * The index of an operand in the pool is its {@linkplain #operandNumber(CiValue) operand number}.
- *
- * In the original HotSpot C1 source code, this pool corresponds to the
- * "flat register file" mentioned in c1_LinearScan.cpp.
- */
-public final class OperandPool {
-
-    public static final int INITIAL_VARIABLE_CAPACITY = 20;
-
-    /**
-     * The physical registers occupying the head of the operand pool. This is the complete
-     * {@linkplain CiArchitecture#registers register set} of the target architecture, not
-     * just the allocatable registers.
-     */
-    private final CiRegister[] registers;
-
-    /**
-     * The variable operands allocated from this pool. The {@linkplain #operandNumber(CiValue) number}
-     * of the first variable operand in this pool is one greater than the number of the last
-     * register operand in the pool.
-     */
-    private final ArrayList<CiVariable> variables;
-
-    /**
-     * Map from a {@linkplain CiVariable#index variable index} to the instruction whose result is stored in the denoted variable.
-     * This map is only populated and used if {@link GraalOptions#DetailedAsserts} is {@code true}.
-     */
-    private final ArrayList<ValueNode> variableDefs;
-
-    /**
-     * The {@linkplain #operandNumber(CiValue) number} of the first variable operand
-     * {@linkplain #newVariable(CiKind) allocated} from this pool.
-     */
-    private final int firstVariableNumber;
-
-    /**
-     * Records which variable operands have the {@link VariableFlag#MustBeByteRegister} flag set.
-     */
-    private BitMap mustBeByteRegister;
-
-    /**
-     * Records which variable operands have the {@link VariableFlag#MustStartInMemory} flag set.
-     */
-    private BitMap mustStartInMemory;
-
-    /**
-     * Records which variable operands have the {@link VariableFlag#MustStayInMemory} flag set.
-     */
-    private BitMap mustStayInMemory;
-
-    /**
-     * Flags that can be set for {@linkplain CiValue#xxisVariable() variable} operands.
-     */
-    public enum VariableFlag {
-        /**
-         * Denotes a variable that needs to be assigned a memory location
-         * at the beginning, but may then be loaded in a register.
-         */
-        MustStartInMemory,
-
-        /**
-         * Denotes a variable that needs to be assigned a memory location
-         * at the beginning and never subsequently loaded in a register.
-         */
-        MustStayInMemory,
-
-        /**
-         * Denotes a variable that must be assigned to a byte-sized register.
-         */
-        MustBeByteRegister;
-
-        public static final VariableFlag[] VALUES = values();
-    }
-
-    private static BitMap set(BitMap map, CiVariable variable) {
-        BitMap result = map;
-        if (result == null) {
-            int length = BitMap.roundUpLength(variable.index + 1);
-            result = new BitMap(length);
-        } else if (result.size() <= variable.index) {
-            int length = BitMap.roundUpLength(variable.index + 1);
-            result.grow(length);
-        }
-        result.set(variable.index);
-        return result;
-    }
-
-    private static boolean get(BitMap map, CiVariable variable) {
-        if (map == null || map.size() <= variable.index) {
-            return false;
-        }
-        return map.get(variable.index);
-    }
-
-    /**
-     * Creates a new operand pool.
-     *
-     * @param target description of the target architecture for a compilation
-     */
-    public OperandPool(CiTarget target) {
-        this.registers = target.arch.registers;
-        this.firstVariableNumber = registers.length;
-        variables = new ArrayList<>(INITIAL_VARIABLE_CAPACITY);
-        variableDefs = GraalOptions.DetailedAsserts ? new ArrayList<ValueNode>(INITIAL_VARIABLE_CAPACITY) : null;
-    }
-
-    /**
-     * Creates a new {@linkplain CiVariable variable} operand.
-     *
-     * @param kind the kind of the variable
-     * @return a new variable
-     */
-    public CiVariable newVariable(CiKind kind) {
-        // TODO since we ensure that the variable kind is a stackKind, the checks for Boolean and Byte here are useless!
-        return newVariable(kind, kind == CiKind.Boolean || kind == CiKind.Byte ? VariableFlag.MustBeByteRegister : null);
-    }
-
-    /**
-     * Creates a new {@linkplain CiVariable variable} operand.
-     *
-     * @param kind the kind of the variable
-     * @param flag a flag that is set for the new variable operand (ignored if {@code null})
-     * @return a new variable operand
-     */
-    public CiVariable newVariable(CiKind kind, VariableFlag flag) {
-        assert kind != CiKind.Void;
-        assert kind.stackKind() == kind : "Variables can only be created for stack-kinds";
-
-        int varIndex = variables.size();
-        CiVariable var = CiVariable.get(kind, varIndex);
-        setFlag(var, flag);
-        variables.add(var);
-        return var;
-    }
-
-    /**
-     * Creates a new {@linkplain CiVariable variable} operand.
-     *
-     * @param kind the kind of the variable
-     * @param flag a flag that is set for the new variable operand (ignored if {@code null})
-     * @return a new variable operand
-     */
-    public void setFlag(CiVariable var, VariableFlag flag) {
-        if (flag == VariableFlag.MustBeByteRegister) {
-            mustBeByteRegister = set(mustBeByteRegister, var);
-        } else if (flag == VariableFlag.MustStartInMemory) {
-            mustStartInMemory = set(mustStartInMemory, var);
-        } else if (flag == VariableFlag.MustStayInMemory) {
-            mustStayInMemory = set(mustStayInMemory, var);
-        } else {
-            assert flag == null;
-        }
-    }
-
-    /**
-     * Gets the unique number for an operand contained in this pool.
-     *
-     *
-     * @param operand an operand
-     * @return the unique number for {@code operand} in the range {@code [0 .. size())}
-     */
-    public int operandNumber(CiValue operand) {
-        if (isRegister(operand)) {
-            int number = asRegister(operand).number;
-            assert number < firstVariableNumber;
-            return number;
-        }
-        assert isVariable(operand) : operand;
-        return firstVariableNumber + ((CiVariable) operand).index;
-    }
-
-    /**
-     * Gets the operand in this pool denoted by a given operand number.
-     *
-     * @param operandNumber a value that must be in the range {@code [0 .. size())}
-     * @return the operand in this pool denoted by {@code operandNumber}
-     */
-    public CiValue operandFor(int operandNumber) {
-        if (operandNumber < firstVariableNumber) {
-            assert operandNumber >= 0;
-            return registers[operandNumber].asValue();
-        }
-        int index = operandNumber - firstVariableNumber;
-        CiVariable variable = variables.get(index);
-        assert variable.index == index;
-        return variable;
-    }
-
-    /**
-     * Records that the result of {@code instruction} is stored in {@code result}.
-     *
-     * @param result the variable storing the result of {@code instruction}
-     * @param instruction an instruction that produces a result (i.e. pushes a value to the stack)
-     */
-    public void recordResult(CiVariable result, ValueNode instruction) {
-        while (variableDefs.size() <= result.index) {
-            variableDefs.add(null);
-        }
-        variableDefs.set(result.index, instruction);
-    }
-
-    /**
-     * Gets the instruction whose result is recorded in a given variable.
-     *
-     * @param result the variable storing the result of an instruction
-     * @return the instruction that stores its result in {@code result}
-     */
-    public ValueNode instructionForResult(CiVariable result) {
-        if (variableDefs.size() > result.index) {
-            return variableDefs.get(result.index);
-        }
-        return null;
-    }
-
-    public boolean mustStartInMemory(CiVariable operand) {
-        return get(mustStartInMemory, operand) || get(mustStayInMemory, operand);
-    }
-
-    public boolean mustStayInMemory(CiVariable operand) {
-        return get(mustStayInMemory, operand);
-    }
-
-    public boolean mustBeByteRegister(CiValue operand) {
-        return get(mustBeByteRegister, (CiVariable) operand);
-    }
-
-    public void setMustBeByteRegister(CiVariable operand) {
-        mustBeByteRegister = set(mustBeByteRegister, operand);
-    }
-
-    /**
-     * Gets the number of operands in this pool. This value will increase by 1 for
-     * each new variable operand {@linkplain #newVariable(CiKind) allocated} from this pool.
-     */
-    public int size() {
-        return firstVariableNumber + variables.size();
-    }
-
-    /**
-     * Gets the highest operand number for a register operand in this pool. This value will
-     * never change for the lifetime of this pool.
-     */
-    public int maxRegisterNumber() {
-        return firstVariableNumber - 1;
-    }
-
-    public int numVariables() {
-        return variables.size();
-    }
-}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/RegisterVerifier.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/RegisterVerifier.java	Tue Jan 03 12:10:27 2012 -0800
@@ -51,7 +51,7 @@
 
     // currently, only registers are processed
     int stateSize() {
-        return allocator.operands.maxRegisterNumber() + 1;
+        return allocator.maxRegisterNumber() + 1;
     }
 
     // accessors
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/DebugInfoBuilder.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/DebugInfoBuilder.java	Tue Jan 03 12:10:27 2012 -0800
@@ -161,7 +161,7 @@
 
         } else if (value != null) {
             CiValue operand = compilation.operand(value);
-            assert operand != null && operand instanceof CiVariable || operand instanceof CiConstant;
+            assert operand != null && operand instanceof Variable || operand instanceof CiConstant;
             return operand;
 
         } else {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Tue Jan 03 12:10:27 2012 -0800
@@ -24,6 +24,7 @@
 
 import static com.oracle.max.cri.ci.CiCallingConvention.Type.*;
 import static com.oracle.max.cri.ci.CiValue.*;
+import static com.oracle.max.cri.ci.CiValueUtil.*;
 import static com.oracle.max.cri.util.MemoryBarriers.*;
 import static com.oracle.max.graal.alloc.util.ValueUtil.*;
 
@@ -33,13 +34,16 @@
 import com.oracle.max.asm.*;
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
-import com.oracle.max.cri.ri.RiType.*;
+import com.oracle.max.cri.ri.RiType.Representation;
+import com.oracle.max.cri.xir.CiXirAssembler.XirConstant;
+import com.oracle.max.cri.xir.CiXirAssembler.XirInstruction;
+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.*;
-import com.oracle.max.cri.xir.CiXirAssembler.*;
 import com.oracle.max.criutils.*;
 import com.oracle.max.graal.compiler.*;
-import com.oracle.max.graal.compiler.alloc.*;
-import com.oracle.max.graal.compiler.alloc.OperandPool.VariableFlag;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.schedule.*;
 import com.oracle.max.graal.compiler.stub.*;
@@ -62,7 +66,6 @@
     protected final LIR lir;
     protected final XirSupport xirSupport;
     protected final RiXirGenerator xir;
-    public final OperandPool operands;
     private final DebugInfoBuilder debugInfoBuilder;
 
     public final CiCallingConvention incomingArguments;
@@ -78,7 +81,6 @@
         this.lir = compilation.lir();
         this.xir = xir;
         this.xirSupport = new XirSupport();
-        this.operands = new OperandPool(compilation.compiler.target);
         this.debugInfoBuilder = new DebugInfoBuilder(compilation);
 
         this.incomingArguments = compilation.registerConfig.getCallingConvention(JavaCallee, CiUtil.signatureToKinds(compilation.method), compilation.compiler.target, false);
@@ -101,13 +103,25 @@
     }
 
     /**
-     * Creates a new {@linkplain CiVariable variable}.
+     * Creates a new {@linkplain Variable variable}.
      * @param kind The kind of the new variable.
      * @return a new variable
      */
     @Override
-    public CiVariable newVariable(CiKind kind) {
-        return operands.newVariable(kind.stackKind());
+    public Variable newVariable(CiKind kind) {
+        CiKind stackKind = kind.stackKind();
+        switch (stackKind) {
+            case Jsr:
+            case Int:
+            case Long:
+            case Object:
+                return new Variable(stackKind, lir.nextVariable(), CiRegister.RegisterFlag.CPU);
+            case Float:
+            case Double:
+                return new Variable(stackKind, lir.nextVariable(), CiRegister.RegisterFlag.FPU);
+            default:
+                throw Util.shouldNotReachHere();
+        }
     }
 
     @Override
@@ -115,20 +129,17 @@
         assert (isVariable(operand) && x.kind() == operand.kind) || (isConstant(operand) && x.kind() == operand.kind.stackKind()) : operand.kind + " for node " + x;
 
         compilation.setOperand(x, operand);
-        if (GraalOptions.DetailedAsserts) {
-            if (isVariable(operand)) {
-                operands.recordResult((CiVariable) operand, x);
-            }
-        }
         return operand;
     }
 
+    @Override
+    public abstract Variable emitMove(CiValue input);
 
-    public CiVariable load(CiValue value) {
+    public Variable load(CiValue value) {
         if (!isVariable(value)) {
             return emitMove(value);
         }
-        return (CiVariable) value;
+        return (Variable) value;
     }
 
     public CiValue loadNonConst(CiValue value) {
@@ -143,8 +154,8 @@
             return value;
         }
         if (storeKind == CiKind.Byte || storeKind == CiKind.Boolean) {
-            CiVariable tempVar = emitMove(value);
-            operands.setFlag(tempVar, VariableFlag.MustBeByteRegister);
+            Variable tempVar = new Variable(value.kind, lir.nextVariable(), CiRegister.RegisterFlag.Byte);
+            emitMove(value, tempVar);
             return tempVar;
         }
         return load(value);
@@ -343,7 +354,7 @@
         for (LocalNode local : compilation.graph.getNodes(LocalNode.class)) {
             int i = local.index();
             CiValue src = toStackKind(args.locations[i]);
-            CiVariable dest = emitMove(src);
+            Variable dest = emitMove(src);
             assert src.kind == local.kind().stackKind() : "local type check failed";
             setResult(local, dest);
         }
@@ -569,7 +580,7 @@
     private void emitNullCheckGuard(NullCheckNode node) {
         assert !node.expectedNull;
         NullCheckNode x = node;
-        CiVariable value = load(operand(x.object()));
+        Variable value = load(operand(x.object()));
         LIRDebugInfo info = state();
         append(StandardOpcode.NULL_CHECK.create(value, info));
     }
@@ -636,7 +647,7 @@
         setResult(conditional, emitConditional(conditional.condition(), tVal, fVal));
     }
 
-    public CiVariable emitConditional(BooleanNode node, CiValue trueValue, CiValue falseValue) {
+    public Variable emitConditional(BooleanNode node, CiValue trueValue, CiValue falseValue) {
         assert trueValue instanceof CiConstant && trueValue.kind.stackKind() == CiKind.Int;
         assert falseValue instanceof CiConstant && falseValue.kind.stackKind() == CiKind.Int;
 
@@ -653,24 +664,24 @@
         }
     }
 
-    private CiVariable emitNullCheckConditional(NullCheckNode node, CiValue trueValue, CiValue falseValue) {
+    private Variable emitNullCheckConditional(NullCheckNode node, CiValue trueValue, CiValue falseValue) {
         Condition cond = node.expectedNull ? Condition.EQ : Condition.NE;
         return emitCMove(operand(node.object()), CiConstant.NULL_OBJECT, cond, false, trueValue, falseValue);
     }
 
-    private CiVariable emitInstanceOfConditional(InstanceOfNode x, CiValue trueValue, CiValue falseValue) {
+    private Variable emitInstanceOfConditional(InstanceOfNode x, CiValue trueValue, CiValue falseValue) {
         XirArgument obj = toXirArgument(x.object());
         XirArgument trueArg = toXirArgument(x.negated ? falseValue : trueValue);
         XirArgument falseArg = toXirArgument(x.negated ? trueValue : falseValue);
         XirSnippet snippet = xir.genMaterializeInstanceOf(site(x), obj, toXirArgument(x.targetClassInstruction()), trueArg, falseArg, x.targetClass());
-        return (CiVariable) emitXir(snippet, null, null, null, false);
+        return (Variable) emitXir(snippet, null, null, null, false);
     }
 
-    private CiVariable emitConstantConditional(boolean value, CiValue trueValue, CiValue falseValue) {
+    private Variable emitConstantConditional(boolean value, CiValue trueValue, CiValue falseValue) {
         return emitMove(value ? trueValue : falseValue);
     }
 
-    private CiVariable emitCompareConditional(CompareNode compare, CiValue trueValue, CiValue falseValue) {
+    private Variable emitCompareConditional(CompareNode compare, CiValue trueValue, CiValue falseValue) {
         return emitCMove(operand(compare.x()), operand(compare.y()), compare.condition(), compare.unorderedIsTrue(), trueValue, falseValue);
     }
 
@@ -678,7 +689,7 @@
     public abstract void emitLabel(Label label, boolean align);
     public abstract void emitJump(LabelRef label, LIRDebugInfo info);
     public abstract void emitBranch(CiValue left, CiValue right, Condition cond, boolean unorderedIsTrue, LabelRef label, LIRDebugInfo info);
-    public abstract CiVariable emitCMove(CiValue leftVal, CiValue right, Condition cond, boolean unorderedIsTrue, CiValue trueValue, CiValue falseValue);
+    public abstract Variable emitCMove(CiValue leftVal, CiValue right, Condition cond, boolean unorderedIsTrue, CiValue trueValue, CiValue falseValue);
 
     protected FrameState stateBeforeCallWithArguments(FrameState stateAfter, MethodCallTargetNode call, int bci) {
         return stateAfter.duplicateModified(bci, stateAfter.rethrowException(), call.returnKind(), toJVMArgumentStack(call.targetMethod().signature(), call.isStatic(), call.arguments()));
@@ -821,7 +832,7 @@
     protected abstract LabelRef createDeoptStub(DeoptAction action, LIRDebugInfo info, Object deoptInfo);
 
     @Override
-    public CiVariable emitCallToRuntime(CiRuntimeCall runtimeCall, boolean canTrap, CiValue... args) {
+    public Variable emitCallToRuntime(CiRuntimeCall runtimeCall, boolean canTrap, CiValue... args) {
         LIRDebugInfo info = canTrap ? state() : null;
 
         CiKind result = runtimeCall.resultKind;
@@ -896,7 +907,7 @@
 
     @Override
     public void emitLookupSwitch(LookupSwitchNode x) {
-        CiVariable tag = load(operand(x.value()));
+        Variable tag = load(operand(x.value()));
         if (x.numberOfCases() == 0 || x.numberOfCases() < GraalOptions.SequentialSwitchLimit) {
             int len = x.numberOfCases();
             for (int i = 0; i < len; i++) {
@@ -910,7 +921,7 @@
 
     @Override
     public void emitTableSwitch(TableSwitchNode x) {
-        CiVariable value = load(operand(x.value()));
+        Variable value = load(operand(x.value()));
         // TODO: tune the defaults for the controls used to determine what kind of translation to use
         if (x.numberOfCases() == 0 || x.numberOfCases() <= GraalOptions.SequentialSwitchLimit) {
             int loKey = x.lowKey();
@@ -983,7 +994,7 @@
         return res.toArray(new SwitchRange[res.size()]);
     }
 
-    private void visitSwitchRanges(SwitchRange[] x, CiVariable value, LabelRef defaultSux) {
+    private void visitSwitchRanges(SwitchRange[] x, Variable value, LabelRef defaultSux) {
         for (int i = 0; i < x.length; i++) {
             SwitchRange oneRange = x[i];
             int lowKey = oneRange.lowKey;
@@ -1029,7 +1040,7 @@
         CiValue result = operand(phi);
         if (result == null) {
             // allocate a variable for this phi
-            CiVariable newOperand = newVariable(phi.kind());
+            Variable newOperand = newVariable(phi.kind());
             setResult(phi, newOperand);
             return newOperand;
         } else {
@@ -1077,9 +1088,11 @@
         if (canBeConstant) {
             return value;
         }
-        CiVariable variable = load(value);
+        Variable variable = load(value);
         if (var.kind == CiKind.Byte || var.kind == CiKind.Boolean) {
-            operands.setFlag(variable, VariableFlag.MustBeByteRegister);
+            Variable tempVar = new Variable(value.kind, lir.nextVariable(), CiRegister.RegisterFlag.Byte);
+            emitMove(variable, tempVar);
+            variable = tempVar;
         }
         return variable;
     }
@@ -1232,7 +1245,7 @@
         return physReg;
     }
 
-    protected final CiVariable callRuntimeWithResult(CiRuntimeCall runtimeCall, LIRDebugInfo info, CiValue... args) {
+    protected final Variable callRuntimeWithResult(CiRuntimeCall runtimeCall, LIRDebugInfo info, CiValue... args) {
         CiValue location = callRuntime(runtimeCall, info, args);
         return emitMove(location);
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/PhiResolver.java	Tue Jan 03 12:10:27 2012 -0800
@@ -23,7 +23,7 @@
 package com.oracle.max.graal.compiler.gen;
 
 import static com.oracle.max.cri.ci.CiValue.*;
-import static com.oracle.max.cri.ci.CiValueUtil.*;
+import static com.oracle.max.graal.alloc.util.ValueUtil.*;
 
 import java.util.*;
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIR.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -63,6 +63,8 @@
      */
     public SlowPath methodEndMarker;
 
+    private int numVariables;
+
 
     public interface SlowPath {
         void emitCode(TargetMethodAssembler tasm);
@@ -102,6 +104,13 @@
         return valueToBlock;
     }
 
+    public int numVariables() {
+        return numVariables;
+    }
+
+    public int nextVariable() {
+        return numVariables++;
+    }
 
     public void emitCode(TargetMethodAssembler tasm) {
         if (GraalOptions.PrintLIR && !TTY.isSuppressed()) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/LIRBlock.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -26,7 +26,6 @@
 
 import com.oracle.max.asm.*;
 import com.oracle.max.criutils.*;
-import com.oracle.max.graal.compiler.alloc.*;
 import com.oracle.max.graal.compiler.schedule.*;
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.graph.*;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/StandardOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/StandardOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, 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
@@ -47,7 +47,7 @@
     }
 
     public interface NullCheckOpcode extends LIROpcode {
-        LIRInstruction create(CiVariable input, LIRDebugInfo info);
+        LIRInstruction create(Variable input, LIRDebugInfo info);
     }
 
     public interface CallOpcode extends LIROpcode {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/lir/Variable.java	Tue Jan 03 12:10:27 2012 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2010, 2012, 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.graal.compiler.lir;
+
+import com.oracle.max.cri.ci.*;
+
+/**
+ * Represents a value that is yet to be bound to a machine location (such as
+ * a {@link CiRegisterValue} or {@link CiStackSlot}) by a register allocator.
+ */
+public final class Variable extends CiValue {
+    private static final long serialVersionUID = 4507578431686109809L;
+
+    /**
+     * The identifier of the variable. This is a non-zero index in a contiguous 0-based name space.
+     */
+    public final int index;
+
+    /**
+     * The type of register that this variable needs to get assigned.
+     */
+    public final CiRegister.RegisterFlag flag;
+
+    /**
+     * Creates a new variable.
+     * @param kind
+     * @param index
+     */
+    public Variable(CiKind kind, int index, CiRegister.RegisterFlag flag) {
+        super(kind);
+        assert kind == kind.stackKind() : "Variables can be only created for stack kinds";
+        assert index >= 0;
+        this.index = index;
+        this.flag = flag;
+    }
+
+    @Override
+    public int hashCode() {
+        return (index << 4) | kind.ordinal();
+    }
+
+    @Override
+    public String toString() {
+        return "v" + index + kindSuffix();
+    }
+}
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ArithmeticOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ArithmeticOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -36,7 +36,7 @@
     FADD, FSUB, FMUL, FDIV,
     DADD, DSUB, DMUL, DDIV;
 
-    public LIRInstruction create(CiVariable result, CiValue left, CiValue right) {
+    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
         assert (name().startsWith("I") && result.kind == CiKind.Int && left.kind.stackKind() == CiKind.Int && right.kind.stackKind() == CiKind.Int)
             || (name().startsWith("L") && result.kind == CiKind.Long && left.kind == CiKind.Long && right.kind == CiKind.Long)
             || (name().startsWith("F") && result.kind == CiKind.Float && left.kind == CiKind.Float && right.kind == CiKind.Float)
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -33,7 +33,7 @@
 public enum AMD64CompareOpcode implements LIROpcode {
     ICMP, LCMP, ACMP, FCMP, DCMP;
 
-    public LIRInstruction create(CiVariable left, CiValue right) {
+    public LIRInstruction create(Variable left, CiValue right) {
         assert (name().startsWith("I") && left.kind == CiKind.Int && right.kind.stackKind() == CiKind.Int)
             || (name().startsWith("I") && left.kind == CiKind.Jsr && right.kind == CiKind.Jsr)
             || (name().startsWith("L") && left.kind == CiKind.Long && right.kind == CiKind.Long)
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64CompareToIntOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -40,7 +40,7 @@
 public enum AMD64CompareToIntOpcode implements LIROpcode {
     CMP2INT, CMP2INT_UG, CMP2INT_UL;
 
-    public LIRInstruction create(CiVariable result) {
+    public LIRInstruction create(Variable result) {
         return new AMD64LIRInstruction(this, result, null, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
             @Override
             public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ControlFlowOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ControlFlowOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -137,7 +137,7 @@
     public enum TableSwitchOpcode implements LIROpcode {
         TABLE_SWITCH;
 
-        public LIRInstruction create(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, CiVariable index, CiVariable scratch) {
+        public LIRInstruction create(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, Variable index, Variable scratch) {
             CiValue[] alives = new CiValue[] {index};
             CiValue[] temps = new CiValue[] {scratch};
 
@@ -166,7 +166,7 @@
     public enum CondMoveOpcode implements LIROpcode {
         CMOVE;
 
-        public LIRInstruction create(CiVariable result, final Condition condition, CiVariable trueValue, CiValue falseValue) {
+        public LIRInstruction create(Variable result, final Condition condition, Variable trueValue, CiValue falseValue) {
             CiValue[] inputs = new CiValue[] {falseValue};
             CiValue[] alives = new CiValue[] {trueValue};
 
@@ -193,7 +193,7 @@
     public enum FloatCondMoveOpcode implements LIROpcode {
         FLOAT_CMOVE;
 
-        public LIRInstruction create(CiVariable result, final Condition condition, final boolean unorderedIsTrue, CiVariable trueValue, CiVariable falseValue) {
+        public LIRInstruction create(Variable result, final Condition condition, final boolean unorderedIsTrue, Variable trueValue, Variable falseValue) {
             CiValue[] alives = new CiValue[] {trueValue, falseValue};
 
             return new AMD64LIRInstruction(this, result, null, LIRInstruction.NO_OPERANDS, alives, LIRInstruction.NO_OPERANDS) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFIOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -36,7 +36,7 @@
 public enum AMD64ConvertFIOpcode implements LIROpcode {
     F2I, D2I;
 
-    public LIRInstruction create(CiVariable result, final CompilerStub stub, CiVariable input) {
+    public LIRInstruction create(Variable result, final CompilerStub stub, Variable input) {
         CiValue[] inputs = new CiValue[] {input};
 
         return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertFLOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -36,7 +36,7 @@
 public enum AMD64ConvertFLOpcode implements LIROpcode {
     F2L, D2L;
 
-    public LIRInstruction create(CiVariable result, final CompilerStub stub, CiVariable input, CiVariable scratch) {
+    public LIRInstruction create(Variable result, final CompilerStub stub, Variable input, Variable scratch) {
         CiValue[] inputs = new CiValue[] {input};
         CiValue[] temps = new CiValue[] {scratch};
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ConvertOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -37,7 +37,7 @@
     L2F, L2D,
     MOV_I2F, MOV_L2D, MOV_F2I, MOV_D2L;
 
-    public LIRInstruction create(CiVariable result, CiVariable input) {
+    public LIRInstruction create(Variable result, Variable input) {
         CiValue[] inputs = new CiValue[] {input};
 
         return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DivOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64DivOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -36,7 +36,7 @@
     IDIV, IREM, UIDIV, UIREM,
     LDIV, LREM, ULDIV, ULREM;
 
-    public LIRInstruction create(CiRegisterValue result, LIRDebugInfo info, CiRegisterValue left, CiVariable right) {
+    public LIRInstruction create(CiRegisterValue result, LIRDebugInfo info, CiRegisterValue left, Variable right) {
         CiValue[] inputs = new CiValue[] {left};
         CiValue[] alives = new CiValue[] {right};
         CiValue[] temps = new CiValue[] {result.reg == AMD64.rax ? AMD64.rdx.asValue(result.kind) : AMD64.rax.asValue(result.kind)};
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Jan 03 12:10:27 2012 -0800
@@ -109,8 +109,8 @@
 
 
     @Override
-    public CiVariable emitMove(CiValue input) {
-        CiVariable result = newVariable(input.kind);
+    public Variable emitMove(CiValue input) {
+        Variable result = newVariable(input.kind);
         append(MOVE.create(result, input));
         return result;
     }
@@ -121,8 +121,8 @@
     }
 
     @Override
-    public CiVariable emitLoad(CiAddress loadAddress, CiKind kind, boolean canTrap) {
-        CiVariable result = newVariable(kind);
+    public Variable emitLoad(CiAddress loadAddress, CiKind kind, boolean canTrap) {
+        Variable result = newVariable(kind);
         append(LOAD.create(result, loadAddress.base, loadAddress.index, loadAddress.scale, loadAddress.displacement, kind, canTrap ? state() : null));
         return result;
     }
@@ -134,15 +134,15 @@
     }
 
     @Override
-    public CiVariable emitLea(CiAddress address) {
-        CiVariable result = newVariable(target().wordKind);
+    public Variable emitLea(CiAddress address) {
+        Variable result = newVariable(target().wordKind);
         append(LEA_MEMORY.create(result, address.base, address.index, address.scale, address.displacement));
         return result;
     }
 
     @Override
-    public CiVariable emitLea(CiStackSlot address) {
-        CiVariable result = newVariable(target().wordKind);
+    public Variable emitLea(CiStackSlot address) {
+        Variable result = newVariable(target().wordKind);
         append(LEA_STACK.create(result, address));
         return result;
     }
@@ -172,10 +172,10 @@
     }
 
     @Override
-    public CiVariable emitCMove(CiValue left, CiValue right, Condition cond, boolean unorderedIsTrue, CiValue trueValue, CiValue falseValue) {
+    public Variable emitCMove(CiValue left, CiValue right, Condition cond, boolean unorderedIsTrue, CiValue trueValue, CiValue falseValue) {
         emitCompare(left, right);
 
-        CiVariable result = newVariable(trueValue.kind);
+        Variable result = newVariable(trueValue.kind);
         switch (left.kind) {
             case Boolean:
             case Int:
@@ -189,7 +189,7 @@
     }
 
     private void emitCompare(CiValue a, CiValue b) {
-        CiVariable left = load(a);
+        Variable left = load(a);
         CiValue right = loadNonConst(b);
         switch (left.kind) {
             case Jsr:
@@ -203,8 +203,8 @@
     }
 
     @Override
-    public CiVariable emitNegate(CiValue input) {
-        CiVariable result = newVariable(input.kind);
+    public Variable emitNegate(CiValue input) {
+        Variable result = newVariable(input.kind);
         switch (input.kind) {
             case Int:    append(INEG.create(result, input)); break;
             case Long:   append(LNEG.create(result, input)); break;
@@ -216,8 +216,8 @@
     }
 
     @Override
-    public CiVariable emitAdd(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitAdd(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch(a.kind) {
             case Int:    append(IADD.create(result, a, loadNonConst(b))); break;
             case Long:   append(LADD.create(result, a, loadNonConst(b))); break;
@@ -229,8 +229,8 @@
     }
 
     @Override
-    public CiVariable emitSub(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitSub(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch(a.kind) {
             case Int:    append(ISUB.create(result, a, loadNonConst(b))); break;
             case Long:   append(LSUB.create(result, a, loadNonConst(b))); break;
@@ -242,8 +242,8 @@
     }
 
     @Override
-    public CiVariable emitMul(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitMul(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch(a.kind) {
             case Int:    append(IMUL.create(result, a, loadNonConst(b))); break;
             case Long:   append(LMUL.create(result, a, loadNonConst(b))); break;
@@ -255,7 +255,7 @@
     }
 
     @Override
-    public CiVariable emitDiv(CiValue a, CiValue b) {
+    public Variable emitDiv(CiValue a, CiValue b) {
         switch(a.kind) {
             case Int:
                 append(MOVE.create(RAX_I, a));
@@ -266,12 +266,12 @@
                 append(LDIV.create(RAX_L, state(), RAX_L, load(b)));
                 return emitMove(RAX_L);
             case Float: {
-                CiVariable result = newVariable(a.kind);
+                Variable result = newVariable(a.kind);
                 append(FDIV.create(result, a, loadNonConst(b)));
                 return result;
             }
             case Double: {
-                CiVariable result = newVariable(a.kind);
+                Variable result = newVariable(a.kind);
                 append(DDIV.create(result, a, loadNonConst(b)));
                 return result;
             }
@@ -281,7 +281,7 @@
     }
 
     @Override
-    public CiVariable emitRem(CiValue a, CiValue b) {
+    public Variable emitRem(CiValue a, CiValue b) {
         switch(a.kind) {
             case Int:
                 append(MOVE.create(RAX_I, a));
@@ -301,7 +301,7 @@
     }
 
     @Override
-    public CiVariable emitUDiv(CiValue a, CiValue b) {
+    public Variable emitUDiv(CiValue a, CiValue b) {
         switch(a.kind) {
             case Int:
                 append(MOVE.create(RAX_I, load(a)));
@@ -317,7 +317,7 @@
     }
 
     @Override
-    public CiVariable emitURem(CiValue a, CiValue b) {
+    public Variable emitURem(CiValue a, CiValue b) {
         switch(a.kind) {
             case Int:
                 append(MOVE.create(RAX_I, load(a)));
@@ -334,8 +334,8 @@
 
 
     @Override
-    public CiVariable emitAnd(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitAnd(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch(a.kind) {
             case Int:    append(IAND.create(result, a, loadNonConst(b))); break;
             case Long:   append(LAND.create(result, a, loadNonConst(b))); break;
@@ -345,8 +345,8 @@
     }
 
     @Override
-    public CiVariable emitOr(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitOr(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch(a.kind) {
             case Int:    append(IOR.create(result, a, loadNonConst(b))); break;
             case Long:   append(LOR.create(result, a, loadNonConst(b))); break;
@@ -356,8 +356,8 @@
     }
 
     @Override
-    public CiVariable emitXor(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitXor(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch(a.kind) {
             case Int:    append(IXOR.create(result, a, loadNonConst(b))); break;
             case Long:   append(LXOR.create(result, a, loadNonConst(b))); break;
@@ -368,8 +368,8 @@
 
 
     @Override
-    public CiVariable emitShl(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitShl(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch (a.kind) {
             case Int:    append(ISHL.create(result, a, loadShiftCount(b))); break;
             case Long:   append(LSHL.create(result, a, loadShiftCount(b))); break;
@@ -379,8 +379,8 @@
     }
 
     @Override
-    public CiVariable emitShr(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitShr(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch (a.kind) {
             case Int:    append(ISHR.create(result, a, loadShiftCount(b))); break;
             case Long:   append(LSHR.create(result, a, loadShiftCount(b))); break;
@@ -390,8 +390,8 @@
     }
 
     @Override
-    public CiVariable emitUShr(CiValue a, CiValue b) {
-        CiVariable result = newVariable(a.kind);
+    public Variable emitUShr(CiValue a, CiValue b) {
+        Variable result = newVariable(a.kind);
         switch (a.kind) {
             case Int:    append(UISHR.create(result, a, loadShiftCount(b))); break;
             case Long:   append(ULSHR.create(result, a, loadShiftCount(b))); break;
@@ -411,9 +411,9 @@
 
 
     @Override
-    public CiVariable emitConvert(ConvertNode.Op opcode, CiValue inputVal) {
-        CiVariable input = load(inputVal);
-        CiVariable result = newVariable(opcode.to);
+    public Variable emitConvert(ConvertNode.Op opcode, CiValue inputVal) {
+        Variable input = load(inputVal);
+        Variable result = newVariable(opcode.to);
         switch (opcode) {
             case I2L: append(I2L.create(result, input)); break;
             case L2I: append(L2I.create(result, input)); break;
@@ -462,7 +462,7 @@
     @Override
     protected void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, CiValue index) {
         // Making a copy of the switch value is necessary because jump table destroys the input value
-        CiVariable tmp = emitMove(index);
+        Variable tmp = emitMove(index);
         append(TABLE_SWITCH.create(lowKey, defaultTarget, targets, tmp, newVariable(compilation.compiler.target.wordKind)));
     }
 
@@ -484,15 +484,15 @@
         assert kind == node.expected().kind();
 
         CiValue expected = loadNonConst(operand(node.expected()));
-        CiVariable newValue = load(operand(node.newValue()));
-        CiVariable addrBase = load(operand(node.object()));
+        Variable newValue = load(operand(node.newValue()));
+        Variable addrBase = load(operand(node.object()));
         CiValue addrIndex = loadNonConst(operand(node.offset()));
 
         if (kind == CiKind.Object) {
-            CiVariable loadedAddress = newVariable(compilation.compiler.target.wordKind);
+            Variable loadedAddress = newVariable(compilation.compiler.target.wordKind);
             append(LEA_MEMORY.create(loadedAddress, addrBase, addrIndex, CiAddress.Scale.Times1, 0));
             addrBase = loadedAddress;
-            addrIndex = CiVariable.IllegalValue;
+            addrIndex = Variable.IllegalValue;
 
             preGCWriteBarrier(addrBase, false, null);
         }
@@ -501,7 +501,7 @@
         append(MOVE.create(rax, expected));
         append(CAS.create(rax, addrBase, addrIndex, CiAddress.Scale.Times1, 0, rax, newValue));
 
-        CiVariable result = newVariable(node.kind());
+        Variable result = newVariable(node.kind());
         if (node.directResult()) {
             append(MOVE.create(result, rax));
         } else {
@@ -518,7 +518,7 @@
     @Override
     public void visitNormalizeCompare(NormalizeCompareNode x) {
         emitCompare(operand(x.x()), operand(x.y()));
-        CiVariable result = newVariable(x.kind());
+        Variable result = newVariable(x.kind());
         switch (x.x().kind()){
             case Float:
             case Double:
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LogicFloatOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LogicFloatOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -34,7 +34,7 @@
     FAND, FOR, FXOR,
     DAND, DOR, DXOR;
 
-    public LIRInstruction create(CiVariable result, CiValue left, CiValue right) {
+    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
         assert (name().startsWith("F") && result.kind == CiKind.Float && left.kind == CiKind.Float && right.kind == CiKind.Float)
             || (name().startsWith("D") && result.kind == CiKind.Double && left.kind == CiKind.Double && right.kind == CiKind.Double);
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MoveOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MoveOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -60,7 +60,7 @@
     public enum LoadOpcode implements LIROpcode {
         LOAD;
 
-        public LIRInstruction create(CiVariable result, CiValue addrBase, CiValue addrIndex, final CiAddress.Scale addrScale, final int addrDisplacement, final CiKind kind, LIRDebugInfo info) {
+        public LIRInstruction create(Variable result, CiValue addrBase, CiValue addrIndex, final CiAddress.Scale addrScale, final int addrDisplacement, final CiKind kind, LIRDebugInfo info) {
             CiValue[] inputs = new CiValue[] {addrBase, addrIndex};
 
             return new AMD64LIRInstruction(this, result, info, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
@@ -92,7 +92,7 @@
     public enum LeaOpcode implements LIROpcode {
         LEA;
 
-        public LIRInstruction create(CiVariable result, CiValue addrBase, CiValue addrIndex, final CiAddress.Scale addrScale, final int addrDisplacement) {
+        public LIRInstruction create(Variable result, CiValue addrBase, CiValue addrIndex, final CiAddress.Scale addrScale, final int addrDisplacement) {
             CiValue[] inputs = new CiValue[] {addrBase, addrIndex};
 
             return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
@@ -112,7 +112,7 @@
     public enum LeaStackBlockOpcode implements LIROpcode {
         LEA_STACK_BLOCK;
 
-        public LIRInstruction create(CiVariable result, final CiStackSlot stackBlock) {
+        public LIRInstruction create(Variable result, final CiStackSlot stackBlock) {
             return new AMD64LIRInstruction(this, result, null, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
                 @Override
                 public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
@@ -141,7 +141,7 @@
         NULL_CHECK;
 
         @Override
-        public LIRInstruction create(CiVariable input, LIRDebugInfo info) {
+        public LIRInstruction create(Variable input, LIRDebugInfo info) {
             CiValue[] inputs = new CiValue[] {input};
 
             return new AMD64LIRInstruction(this, CiValue.IllegalValue, info, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
@@ -158,7 +158,7 @@
     public enum CompareAndSwapOpcode implements LIROpcode {
         CAS;
 
-        public LIRInstruction create(CiRegisterValue result, CiValue addrBase, CiValue addrIndex, final CiAddress.Scale addrScale, final int addrDisplacement, CiRegisterValue cmpValue, CiVariable newValue) {
+        public LIRInstruction create(CiRegisterValue result, CiValue addrBase, CiValue addrIndex, final CiAddress.Scale addrScale, final int addrDisplacement, CiRegisterValue cmpValue, Variable newValue) {
             CiValue[] inputs = new CiValue[] {addrBase, addrIndex, cmpValue, newValue};
 
             return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MulOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64MulOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -33,7 +33,7 @@
 public enum AMD64MulOpcode implements LIROpcode {
     IMUL, LMUL;
 
-    public LIRInstruction create(CiVariable result, CiValue left, CiValue right) {
+    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
         CiValue[] inputs = new CiValue[] {left};
         CiValue[] alives = new CiValue[] {right};
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Op1Opcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Op1Opcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -33,7 +33,7 @@
 public enum AMD64Op1Opcode implements LIROpcode {
     INEG, LNEG;
 
-    public LIRInstruction create(CiVariable result, CiValue input) {
+    public LIRInstruction create(Variable result, CiValue input) {
         CiValue[] inputs = new CiValue[] {input};
 
         return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ShiftOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64ShiftOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -34,7 +34,7 @@
     ISHL, ISHR, UISHR,
     LSHL, LSHR, ULSHR;
 
-    public LIRInstruction create(CiVariable result, CiValue left, CiValue right) {
+    public LIRInstruction create(Variable result, CiValue left, CiValue right) {
         CiValue[] inputs = new CiValue[] {left};
         CiValue[] alives = new CiValue[] {right};
 
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/ArrayWriteBarrier.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/ArrayWriteBarrier.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -47,7 +47,7 @@
 
     @Override
     public void generate(LIRGeneratorTool generator) {
-        CiVariable obj = generator.emitLea(location().createAddress(generator, object()));
+        CiValue obj = generator.emitLea(location().createAddress(generator, object()));
         generateBarrier(obj, generator);
     }
 }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/FieldWriteBarrier.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/FieldWriteBarrier.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -40,7 +40,7 @@
 
     @Override
     public void generate(LIRGeneratorTool generator) {
-        CiVariable obj = generator.newVariable(generator.target().wordKind);
+        CiValue obj = generator.newVariable(generator.target().wordKind);
         generator.emitMove(generator.operand(object()), obj);
         generateBarrier(obj, generator);
     }
--- a/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/WriteBarrier.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/nodes/WriteBarrier.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -34,9 +34,9 @@
         super(StampFactory.illegal());
     }
 
-    protected void generateBarrier(CiVariable obj, LIRGeneratorTool gen) {
+    protected void generateBarrier(CiValue obj, LIRGeneratorTool gen) {
         HotSpotVMConfig config = CompilerImpl.getInstance().getConfig();
-        CiVariable base = gen.emitUShr(obj, CiConstant.forInt(config.cardtableShift));
+        CiValue base = gen.emitUShr(obj, CiConstant.forInt(config.cardtableShift));
 
         long startAddress = config.cardtableStartAddress;
         int displacement = 0;
--- a/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.nodes/src/com/oracle/max/graal/nodes/spi/LIRGeneratorTool.java	Tue Jan 03 12:10:27 2012 -0800
@@ -49,37 +49,37 @@
     public abstract boolean canStoreConstant(CiConstant c);
 
     public abstract CiValue operand(ValueNode object);
-    public abstract CiVariable newVariable(CiKind kind);
+    public abstract CiValue newVariable(CiKind kind);
     public abstract CiValue setResult(ValueNode x, CiValue operand);
 
-    public abstract CiVariable emitMove(CiValue input);
+    public abstract CiValue emitMove(CiValue input);
     public abstract void emitMove(CiValue src, CiValue dst);
-    public abstract CiVariable emitLoad(CiAddress loadAddress, CiKind kind, boolean canTrap);
+    public abstract CiValue emitLoad(CiAddress loadAddress, CiKind kind, boolean canTrap);
     public abstract void emitStore(CiAddress storeAddress, CiValue input, CiKind kind, boolean canTrap);
-    public abstract CiVariable emitLea(CiAddress address);
-    public abstract CiVariable emitLea(CiStackSlot address);
+    public abstract CiValue emitLea(CiAddress address);
+    public abstract CiValue emitLea(CiStackSlot address);
 
-    public abstract CiVariable emitNegate(CiValue input);
-    public abstract CiVariable emitAdd(CiValue a, CiValue b);
-    public abstract CiVariable emitSub(CiValue a, CiValue b);
-    public abstract CiVariable emitMul(CiValue a, CiValue b);
-    public abstract CiVariable emitDiv(CiValue a, CiValue b);
-    public abstract CiVariable emitRem(CiValue a, CiValue b);
-    public abstract CiVariable emitUDiv(CiValue a, CiValue b);
-    public abstract CiVariable emitURem(CiValue a, CiValue b);
+    public abstract CiValue emitNegate(CiValue input);
+    public abstract CiValue emitAdd(CiValue a, CiValue b);
+    public abstract CiValue emitSub(CiValue a, CiValue b);
+    public abstract CiValue emitMul(CiValue a, CiValue b);
+    public abstract CiValue emitDiv(CiValue a, CiValue b);
+    public abstract CiValue emitRem(CiValue a, CiValue b);
+    public abstract CiValue emitUDiv(CiValue a, CiValue b);
+    public abstract CiValue emitURem(CiValue a, CiValue b);
 
-    public abstract CiVariable emitAnd(CiValue a, CiValue b);
-    public abstract CiVariable emitOr(CiValue a, CiValue b);
-    public abstract CiVariable emitXor(CiValue a, CiValue b);
+    public abstract CiValue emitAnd(CiValue a, CiValue b);
+    public abstract CiValue emitOr(CiValue a, CiValue b);
+    public abstract CiValue emitXor(CiValue a, CiValue b);
 
-    public abstract CiVariable emitShl(CiValue a, CiValue b);
-    public abstract CiVariable emitShr(CiValue a, CiValue b);
-    public abstract CiVariable emitUShr(CiValue a, CiValue b);
+    public abstract CiValue emitShl(CiValue a, CiValue b);
+    public abstract CiValue emitShr(CiValue a, CiValue b);
+    public abstract CiValue emitUShr(CiValue a, CiValue b);
 
-    public abstract CiVariable emitConvert(ConvertNode.Op opcode, CiValue inputVal);
+    public abstract CiValue emitConvert(ConvertNode.Op opcode, CiValue inputVal);
     public abstract void emitMembar(int barriers);
     public abstract void emitDeoptimizeOn(Condition of, DeoptAction action, Object deoptInfo);
-    public abstract CiVariable emitCallToRuntime(CiRuntimeCall runtimeCall, boolean canTrap, CiValue... args);
+    public abstract CiValue emitCallToRuntime(CiRuntimeCall runtimeCall, boolean canTrap, CiValue... args);
 
     public abstract void emitIf(IfNode i);
     public abstract void emitConditional(ConditionalNode i);
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/nodes/MathIntrinsicNode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/nodes/MathIntrinsicNode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -23,6 +23,7 @@
 package com.oracle.max.graal.snippets.nodes;
 
 import com.oracle.max.cri.ci.*;
+import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.target.amd64.*;
 import com.oracle.max.graal.compiler.util.*;
 import com.oracle.max.graal.graph.*;
@@ -58,8 +59,8 @@
 
     @Override
     public void generateAmd64(AMD64LIRGenerator gen) {
-        CiVariable input = gen.load(gen.operand(x()));
-        CiVariable result = gen.newVariable(kind());
+        Variable input = gen.load(gen.operand(x()));
+        Variable result = gen.newVariable(kind());
         switch (operation()) {
             case ABS:   gen.append(AMD64LogicFloatOpcode.DAND.create(result, input, CiConstant.forDouble(Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL)))); break;
             case SQRT:  gen.append(AMD64MathIntrinsicOpcode.SQRT.create(result, input)); break;
--- a/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/target/amd64/AMD64MathIntrinsicOpcode.java	Tue Jan 03 18:22:10 2012 +0100
+++ b/graal/com.oracle.max.graal.snippets/src/com/oracle/max/graal/snippets/target/amd64/AMD64MathIntrinsicOpcode.java	Tue Jan 03 12:10:27 2012 -0800
@@ -36,7 +36,7 @@
     SIN, COS, TAN,
     LOG, LOG10;
 
-    public LIRInstruction create(CiVariable result, CiVariable input) {
+    public LIRInstruction create(Variable result, Variable input) {
         CiValue[] inputs = new CiValue[] {input};
 
         return new AMD64LIRInstruction(this, result, null, inputs, LIRInstruction.NO_OPERANDS, LIRInstruction.NO_OPERANDS) {