changeset 4260:78379b4203ec

remove a number of GraalCompilation usages in backend and CFGPrinter (breaks CFGPrinter lir output)
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 10 Jan 2012 13:24:00 +0100
parents e53926b0a6cb
children 57b0da88576a
files 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/IntervalWalker.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/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/target/Backend.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinter.java graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java mx/projects
diffstat 12 files changed, 129 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompilation.java	Tue Jan 10 13:24:00 2012 +0100
@@ -23,13 +23,11 @@
 
 package com.oracle.max.graal.compiler;
 
-import static com.oracle.max.cri.ci.CiValueUtil.*;
-
 import java.util.*;
 
 import com.oracle.max.asm.*;
 import com.oracle.max.cri.ci.*;
-import com.oracle.max.cri.ci.CiCompiler.*;
+import com.oracle.max.cri.ci.CiCompiler.DebugInfoLevel;
 import com.oracle.max.cri.ri.*;
 import com.oracle.max.cri.xir.*;
 import com.oracle.max.criutils.*;
@@ -44,7 +42,6 @@
 import com.oracle.max.graal.compiler.schedule.*;
 import com.oracle.max.graal.graph.*;
 import com.oracle.max.graal.nodes.*;
-import com.oracle.max.graal.nodes.virtual.*;
 
 /**
  * This class encapsulates global information about the compilation of a particular method,
@@ -59,7 +56,6 @@
 
     public final StructuredGraph graph;
     public final CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null;
-    public NodeMap<CiValue> nodeOperands;
 
     private FrameMap frameMap;
 
@@ -104,21 +100,6 @@
         return lir;
     }
 
-    public CiValue operand(ValueNode valueNode) {
-        if (nodeOperands == null) {
-            return null;
-        }
-        return nodeOperands.get(valueNode);
-    }
-
-    public void setOperand(ValueNode valueNode, CiValue operand) {
-        assert operand(valueNode) == null : "operand cannot be set twice";
-        assert operand != null && isLegal(operand) : "operand must be legal";
-        assert operand.kind.stackKind() == valueNode.kind();
-        assert !(valueNode instanceof VirtualObjectNode);
-        nodeOperands.set(valueNode, operand);
-    }
-
     /**
      * Converts this compilation to a string.
      * @return a string representation of this compilation
@@ -314,7 +295,7 @@
     }
 
     public void initFrameMap() {
-        frameMap = this.compiler.backend.newFrameMap(this);
+        frameMap = this.compiler.backend.newFrameMap(compiler.runtime, compiler.target, registerConfig);
     }
 
     private void emitLIR(RiXirGenerator xir) {
@@ -322,7 +303,6 @@
         try {
             if (GraalOptions.GenLIR) {
                 context().timers.startScope("Create LIR");
-                nodeOperands = graph.createNodeMap();
                 LIRGenerator lirGenerator = null;
                 try {
                     initFrameMap();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/IntervalWalker.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/IntervalWalker.java	Tue Jan 10 13:24:00 2012 +0100
@@ -32,7 +32,6 @@
  */
 public class IntervalWalker {
 
-    protected final GraalCompilation compilation;
     protected final LinearScan allocator;
 
     /**
@@ -91,7 +90,6 @@
      * @param unhandledAny the list of unhandled {@linkplain RegisterBinding#Any non-fixed} intervals
      */
     IntervalWalker(LinearScan allocator, Interval unhandledFixed, Interval unhandledAny) {
-        this.compilation = allocator.compilation;
         this.allocator = allocator;
 
         unhandledLists = new RegisterBindingLists(unhandledFixed, unhandledAny);
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScan.java	Tue Jan 10 13:24:00 2012 +0100
@@ -50,6 +50,7 @@
 
     final GraalContext context;
     final GraalCompilation compilation;
+    final RiMethod method;
     final LIR ir;
     final LIRGenerator gen;
     final FrameMap frameMap;
@@ -118,6 +119,7 @@
 
     public LinearScan(GraalCompilation compilation, LIR ir, LIRGenerator gen, FrameMap frameMap) {
         this.context = compilation.compiler.context;
+        this.method = compilation.method;
         this.compilation = compilation;
         this.ir = ir;
         this.gen = gen;
@@ -814,7 +816,7 @@
     }
 
     private void reportFailure(int numBlocks) {
-        TTY.println(compilation.method.toString());
+        TTY.println(method.toString());
         TTY.println("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined)");
         TTY.print("affected registers:");
         TTY.println(ir.startBlock().liveIn.toString());
@@ -1339,7 +1341,7 @@
         notPrecoloredIntervals = result.second;
 
         // allocate cpu registers
-        LinearScanWalker lsw = new LinearScanWalker(this, precoloredIntervals, notPrecoloredIntervals);
+        LinearScanWalker lsw = new LinearScanWalker(this, precoloredIntervals, notPrecoloredIntervals, !compilation.compiler.target.arch.isX86());
         lsw.walk();
         lsw.finishAllocation();
     }
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScanWalker.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/alloc/LinearScanWalker.java	Tue Jan 10 13:24:00 2012 +0100
@@ -42,6 +42,8 @@
  */
 final class LinearScanWalker extends IntervalWalker {
 
+    private final boolean hasCalleeSavedRegisters;
+
     private CiRegister[] availableRegs;
 
     private final int[] usePos;
@@ -51,6 +53,7 @@
 
     private MoveResolver moveResolver; // for ordering spill moves
 
+
     // accessors mapped to same functions in class LinearScan
     int blockCount() {
         return allocator.blockCount();
@@ -64,8 +67,9 @@
         return allocator.blockForId(opId);
     }
 
-    LinearScanWalker(LinearScan allocator, Interval unhandledFixedFirst, Interval unhandledAnyFirst) {
+    LinearScanWalker(LinearScan allocator, Interval unhandledFixedFirst, Interval unhandledAnyFirst, boolean hasCalleeSavedRegisters) {
         super(allocator, unhandledFixedFirst, unhandledAnyFirst);
+        this.hasCalleeSavedRegisters = hasCalleeSavedRegisters;
         moveResolver = new MoveResolver(allocator);
         spillIntervals = Util.uncheckedCast(new List[allocator.registers.length]);
         for (int i = 0; i < allocator.registers.length; i++) {
@@ -789,7 +793,7 @@
 
     boolean noAllocationPossible(Interval interval) {
 
-        if (compilation.compiler.target.arch.isX86()) {
+        if (!hasCalleeSavedRegisters) {
             // fast calculation of intervals that can never get a register because the
             // the next instruction is a call that blocks all registers
             // Note: this does not work if callee-saved registers are available (e.g. on Sparc)
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/DebugInfoBuilder.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/DebugInfoBuilder.java	Tue Jan 10 13:24:00 2012 +0100
@@ -26,25 +26,26 @@
 import java.util.Map.Entry;
 
 import com.oracle.max.cri.ci.*;
-import com.oracle.max.graal.compiler.*;
-import com.oracle.max.graal.compiler.gen.LIRGenerator.*;
+import com.oracle.max.graal.compiler.gen.LIRGenerator.LockScope;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.graph.*;
 import com.oracle.max.graal.nodes.*;
 import com.oracle.max.graal.nodes.virtual.*;
 
 public class DebugInfoBuilder {
-    public final GraalCompilation compilation;
+    private final boolean disable;
+    private final NodeMap<CiValue> nodeOperands;
 
-    public DebugInfoBuilder(GraalCompilation compilation) {
-        this.compilation = compilation;
+    public DebugInfoBuilder(NodeMap<CiValue> nodeOperands, boolean disable) {
+        this.nodeOperands = nodeOperands;
+        this.disable = disable;
     }
 
 
     private HashMap<VirtualObjectNode, CiVirtualObject> virtualObjects = new HashMap<>();
 
     public LIRDebugInfo build(FrameState topState, LockScope locks, List<CiStackSlot> pointerSlots, LabelRef exceptionEdge) {
-        if (compilation.placeholderState != null) {
+        if (disable) {
             return null;
         }
 
@@ -158,7 +159,7 @@
             return ((ConstantNode) value).value;
 
         } else if (value != null) {
-            CiValue operand = compilation.operand(value);
+            CiValue operand = nodeOperands.get(value);
             assert operand != null && operand instanceof Variable || operand instanceof CiConstant;
             return operand;
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/gen/LIRGenerator.java	Tue Jan 10 13:24:00 2012 +0100
@@ -58,13 +58,23 @@
 import com.oracle.max.graal.nodes.extended.*;
 import com.oracle.max.graal.nodes.java.*;
 import com.oracle.max.graal.nodes.spi.*;
+import com.oracle.max.graal.nodes.virtual.*;
 
 /**
  * This class traverses the HIR instructions and generates LIR instructions from them.
  */
 public abstract class LIRGenerator extends LIRGeneratorTool {
     public final GraalContext context;
-    public final GraalCompilation compilation;
+
+    protected final Graph graph;
+    private final GraalCompiler compiler;
+    protected final RiRuntime runtime;
+    protected final CiTarget target;
+    protected final RiResolvedMethod method;
+    protected final FrameMap frameMap;
+    protected final RiRegisterConfig registerConfig;
+    public final NodeMap<CiValue> nodeOperands;
+
     protected final LIR lir;
     protected final XirSupport xirSupport;
     protected final RiXirGenerator xir;
@@ -133,17 +143,24 @@
 
     public LIRGenerator(GraalCompilation compilation, RiXirGenerator xir) {
         this.context = compilation.compiler.context;
-        this.compilation = compilation;
+        this.graph = compilation.graph;
+        this.compiler = compilation.compiler;
+        this.runtime = compilation.compiler.runtime;
+        this.target = compilation.compiler.target;
+        this.frameMap = compilation.frameMap();
+        this.method = compilation.method;
+        this.registerConfig = compilation.registerConfig;
+        this.nodeOperands = graph.createNodeMap();
         this.lir = compilation.lir();
         this.xir = xir;
         this.xirSupport = new XirSupport();
-        this.debugInfoBuilder = new DebugInfoBuilder(compilation);
+        this.debugInfoBuilder = new DebugInfoBuilder(nodeOperands, compilation.placeholderState != null);
         this.blockLocks = new LockScope[lir.linearScanOrder().size()];
     }
 
     @Override
     public CiTarget target() {
-        return compilation.compiler.target;
+        return target;
     }
 
     private LockScope locksFor(LIRBlock block) {
@@ -161,7 +178,10 @@
      */
     @Override
     public CiValue operand(ValueNode node) {
-        return compilation.operand(node);
+        if (nodeOperands == null) {
+            return null;
+        }
+        return nodeOperands.get(node);
     }
 
     /**
@@ -190,7 +210,11 @@
     public CiValue setResult(ValueNode x, CiValue operand) {
         assert (isVariable(operand) && x.kind() == operand.kind) || (isConstant(operand) && x.kind() == operand.kind.stackKind()) : operand.kind + " for node " + x;
 
-        compilation.setOperand(x, operand);
+        assert operand(x) == null : "operand cannot be set twice";
+        assert operand != null && isLegal(operand) : "operand must be legal";
+        assert operand.kind.stackKind() == x.kind();
+        assert !(x instanceof VirtualObjectNode);
+        nodeOperands.set(x, operand);
         return operand;
     }
 
@@ -254,7 +278,7 @@
         if (kind == CiKind.Void) {
             return IllegalValue;
         }
-        return compilation.registerConfig.getReturnRegister(kind).asValue(kind);
+        return registerConfig.getReturnRegister(kind).asValue(kind);
     }
 
 
@@ -405,7 +429,7 @@
         emitNode(instr);
 
         if (GraalOptions.TraceLIRVisit) {
-            TTY.println("Operand for " + instr + " = " + compilation.operand(instr));
+            TTY.println("Operand for " + instr + " = " + operand(instr));
         }
     }
 
@@ -419,7 +443,7 @@
     }
 
     private void emitPrologue() {
-        CiCallingConvention incomingArguments = compilation.registerConfig.getCallingConvention(JavaCallee, CiUtil.signatureToKinds(compilation.method), compilation.compiler.target, false);
+        CiCallingConvention incomingArguments = registerConfig.getCallingConvention(JavaCallee, CiUtil.signatureToKinds(method), target, false);
 
         CiValue[] params = new CiValue[incomingArguments.locations.length];
         for (int i = 0; i < params.length; i++) {
@@ -427,12 +451,12 @@
         }
         append(PARAMS.create(params));
 
-        XirSnippet prologue = xir.genPrologue(null, compilation.method);
+        XirSnippet prologue = xir.genPrologue(null, method);
         if (prologue != null) {
             emitXir(prologue, null, null, null, false);
         }
 
-        for (LocalNode local : compilation.graph.getNodes(LocalNode.class)) {
+        for (LocalNode local : graph.getNodes(LocalNode.class)) {
             CiValue param = params[local.index()];
             assert param.kind == local.kind().stackKind();
             setResult(local, emitMove(param));
@@ -440,9 +464,9 @@
     }
 
     private boolean checkStartOperands(Node node, FrameState fs) {
-        if (!Modifier.isNative(compilation.method.accessFlags())) {
+        if (!Modifier.isNative(method.accessFlags())) {
             if (node == ((StructuredGraph) node.graph()).start()) {
-                CiKind[] arguments = CiUtil.signatureToKinds(compilation.method);
+                CiKind[] arguments = CiUtil.signatureToKinds(method);
                 int slot = 0;
                 for (CiKind kind : arguments) {
                     ValueNode arg = fs.localAt(slot);
@@ -476,9 +500,9 @@
 
     @Override
     public void visitMonitorEnter(MonitorEnterNode x) {
-        CiStackSlot lockData = compilation.frameMap().allocateStackBlock(compilation.compiler.runtime.sizeOfLockData(), false);
+        CiStackSlot lockData = frameMap.allocateStackBlock(runtime.sizeOfLockData(), false);
         if (x.eliminated()) {
-            // No code is emitted for elimianted locks, but for proper debug information generation we need to
+            // No code is emitted for eliminated locks, but for proper debug information generation we need to
             // register the monitor and its lock data.
             curLocks = new LockScope(curLocks, x.stateAfter().outerFrameState(), x, lockData);
             return;
@@ -490,7 +514,7 @@
         LIRDebugInfo stateBefore = state();
         // The state before the monitor enter is used for null checks, so it must not contain the newly locked object.
         curLocks = new LockScope(curLocks, x.stateAfter().outerFrameState(), x, lockData);
-        // The state after the monitor enter is used for deotpimization, after the montior has blocked, so it must contain the newly locked object.
+        // The state after the monitor enter is used for deoptimization, after the monitor has blocked, so it must contain the newly locked object.
         LIRDebugInfo stateAfter = stateFor(x.stateAfter());
 
         XirSnippet snippet = xir.genMonitorEnter(site(x), obj, lockAddress);
@@ -610,9 +634,9 @@
             operand = resultOperandFor(x.kind());
             emitMove(operand(x.result()), operand);
         }
-        XirSnippet epilogue = xir.genEpilogue(site(x), compilation.method);
+        XirSnippet epilogue = xir.genEpilogue(site(x), method);
         if (epilogue != null) {
-            emitXir(epilogue, x, null, compilation.method, false);
+            emitXir(epilogue, x, null, method, false);
             append(StandardOpcode.RETURN.create(operand));
         }
     }
@@ -697,7 +721,7 @@
         LIRDebugInfo info = state();
         XirArgument clazz = toXirArgument(node.type().getEncoding(Representation.ObjectHub));
         XirSnippet typeCheck = xir.genTypeCheck(site(node), toXirArgument(node.object()), clazz, node.type());
-        emitXir(typeCheck, node, info, compilation.method, false);
+        emitXir(typeCheck, node, info, method, false);
     }
 
 
@@ -834,27 +858,27 @@
     @Override
     public void emitInvoke(Invoke x) {
         MethodCallTargetNode callTarget = x.callTarget();
-        RiMethod target = callTarget.targetMethod();
+        RiMethod targetMethod = callTarget.targetMethod();
 
         XirSnippet snippet = null;
         XirArgument receiver;
         switch (callTarget.invokeKind()) {
             case Static:
-                snippet = xir.genInvokeStatic(site(x.node()), target);
+                snippet = xir.genInvokeStatic(site(x.node()), targetMethod);
                 break;
             case Special:
                 receiver = toXirArgument(callTarget.receiver());
-                snippet = xir.genInvokeSpecial(site(x.node()), receiver, target);
+                snippet = xir.genInvokeSpecial(site(x.node()), receiver, targetMethod);
                 break;
             case Virtual:
                 assert callTarget.receiver().kind() == CiKind.Object : callTarget + ": " + callTarget.targetMethod().toString();
                 receiver = toXirArgument(callTarget.receiver());
-                snippet = xir.genInvokeVirtual(site(x.node()), receiver, target);
+                snippet = xir.genInvokeVirtual(site(x.node()), receiver, targetMethod);
                 break;
             case Interface:
                 assert callTarget.receiver().kind() == CiKind.Object : callTarget;
                 receiver = toXirArgument(callTarget.receiver());
-                snippet = xir.genInvokeInterface(site(x.node()), receiver, target);
+                snippet = xir.genInvokeInterface(site(x.node()), receiver, targetMethod);
                 break;
         }
 
@@ -869,8 +893,8 @@
         CiValue resultOperand = resultOperandFor(x.node().kind());
 
         CiKind[] signature = CiUtil.signatureToKinds(callTarget.targetMethod().signature(), callTarget.isStatic() ? null : callTarget.targetMethod().holder().kind(true));
-        CiCallingConvention cc = compilation.registerConfig.getCallingConvention(JavaCall, signature, target(), false);
-        compilation.frameMap().callsMethod(cc, JavaCall);
+        CiCallingConvention cc = registerConfig.getCallingConvention(JavaCall, signature, target(), false);
+        frameMap.callsMethod(cc, JavaCall);
         List<CiStackSlot> pointerSlots = new ArrayList<>(2);
         List<CiValue> argList = visitInvokeArguments(cc, callTarget.arguments(), pointerSlots);
 
@@ -886,10 +910,10 @@
         if (destinationAddress instanceof CiConstant) {
             // Direct call
             assert ((CiConstant) destinationAddress).isDefaultValue() : "destination address should be zero";
-            append(StandardOpcode.DIRECT_CALL.create(target, resultOperand, argList, null, callInfo, snippet.marks));
+            append(StandardOpcode.DIRECT_CALL.create(targetMethod, resultOperand, argList, null, callInfo, snippet.marks));
         } else {
             // Indirect call
-            append(StandardOpcode.INDIRECT_CALL.create(target, resultOperand, argList, destinationAddress, callInfo, snippet.marks));
+            append(StandardOpcode.INDIRECT_CALL.create(targetMethod, resultOperand, argList, destinationAddress, callInfo, snippet.marks));
         }
 
         if (isLegal(resultOperand)) {
@@ -949,8 +973,8 @@
         List<CiValue> argumentList;
         if (arguments.length > 0) {
             // move the arguments into the correct location
-            CiCallingConvention cc = compilation.registerConfig.getCallingConvention(RuntimeCall, arguments, target(), false);
-            compilation.frameMap().callsMethod(cc, RuntimeCall);
+            CiCallingConvention cc = registerConfig.getCallingConvention(RuntimeCall, arguments, target(), false);
+            frameMap.callsMethod(cc, RuntimeCall);
             assert cc.locations.length == args.length : "argument count mismatch";
             for (int i = 0; i < args.length; i++) {
                 CiValue arg = args[i];
@@ -978,8 +1002,8 @@
         // TODO Merge with emitCallToRuntime() method above.
 
         CiValue resultOperand = resultOperandFor(x.kind());
-        CiCallingConvention cc = compilation.registerConfig.getCallingConvention(RuntimeCall, x.call().arguments, target(), false);
-        compilation.frameMap().callsMethod(cc, RuntimeCall);
+        CiCallingConvention cc = registerConfig.getCallingConvention(RuntimeCall, x.call().arguments, target(), false);
+        frameMap.callsMethod(cc, RuntimeCall);
         List<CiStackSlot> pointerSlots = new ArrayList<>(2);
         List<CiValue> argList = visitInvokeArguments(cc, x.arguments(), pointerSlots);
 
@@ -1001,14 +1025,14 @@
     }
 
     protected CompilerStub stubFor(CompilerStub.Id id) {
-        CompilerStub stub = compilation.compiler.lookupStub(id);
-        compilation.frameMap().usesStub(stub);
+        CompilerStub stub = compiler.lookupStub(id);
+        frameMap.usesStub(stub);
         return stub;
     }
 
     protected CompilerStub stubFor(XirTemplate template) {
-        CompilerStub stub = compilation.compiler.lookupStub(template);
-        compilation.frameMap().usesStub(stub);
+        CompilerStub stub = compiler.lookupStub(template);
+        frameMap.usesStub(stub);
         return stub;
     }
 
@@ -1204,18 +1228,18 @@
         return variable;
     }
 
-    protected CiValue emitXir(XirSnippet snippet, ValueNode x, LIRDebugInfo info, RiMethod method, boolean setInstructionResult) {
-        return emitXir(snippet, x, info, null, method, setInstructionResult);
+    protected CiValue emitXir(XirSnippet snippet, ValueNode x, LIRDebugInfo info, RiMethod currentMethod, boolean setInstructionResult) {
+        return emitXir(snippet, x, info, null, currentMethod, setInstructionResult);
     }
 
-    protected CiValue emitXir(XirSnippet snippet, ValueNode instruction, LIRDebugInfo info, LIRDebugInfo infoAfter, RiMethod method, boolean setInstructionResult) {
+    protected CiValue emitXir(XirSnippet snippet, ValueNode instruction, LIRDebugInfo info, LIRDebugInfo infoAfter, RiMethod currentMethod, boolean setInstructionResult) {
         if (GraalOptions.PrintXirTemplates) {
             TTY.println("Emit XIR template " + snippet.template.name);
         }
 
         final CiValue[] operandsArray = new CiValue[snippet.template.variableCount];
 
-        compilation.frameMap().reserveOutgoing(snippet.template.outgoingStackSize);
+        frameMap.reserveOutgoing(snippet.template.outgoingStackSize);
 
         XirOperand resultOperand = snippet.template.resultOperand;
 
@@ -1298,7 +1322,7 @@
         }
 
         if (setInstructionResult && isLegal(allocatedResultOperand)) {
-            CiValue operand = compilation.operand(instruction);
+            CiValue operand = operand(instruction);
             if (operand == null) {
                 setResult(instruction, allocatedResultOperand);
             } else {
@@ -1313,7 +1337,7 @@
             append(StandardOpcode.XIR.create(snippet, operandsArray, allocatedResultOperand,
                     inputOperandArray, tempOperandArray, inputOperandIndicesArray, tempOperandIndicesArray,
                     (allocatedResultOperand == IllegalValue) ? -1 : resultOperand.index,
-                    info, infoAfter, method));
+                    info, infoAfter, currentMethod));
             if (GraalOptions.Meter) {
                 context.metrics.LIRXIRInstructions++;
             }
@@ -1332,8 +1356,8 @@
         List<CiValue> argumentList;
         if (arguments.length > 0) {
             // move the arguments into the correct location
-            CiCallingConvention cc = compilation.registerConfig.getCallingConvention(RuntimeCall, arguments, target(), false);
-            compilation.frameMap().callsMethod(cc, RuntimeCall);
+            CiCallingConvention cc = registerConfig.getCallingConvention(RuntimeCall, arguments, target(), false);
+            frameMap.callsMethod(cc, RuntimeCall);
             assert cc.locations.length == args.length : "argument count mismatch";
             for (int i = 0; i < args.length; i++) {
                 CiValue arg = args[i];
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/Backend.java	Tue Jan 10 13:24:00 2012 +0100
@@ -54,7 +54,7 @@
         }
     }
 
-    public abstract FrameMap newFrameMap(GraalCompilation compilation);
+    public abstract FrameMap newFrameMap(RiRuntime runtime, CiTarget target, RiRegisterConfig registerConfig);
     public abstract LIRGenerator newLIRGenerator(GraalCompilation compilation, RiXirGenerator xir);
     public abstract AbstractAssembler newAssembler(RiRegisterConfig registerConfig);
     public abstract CiXirAssembler newXirAssembler();
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64Backend.java	Tue Jan 10 13:24:00 2012 +0100
@@ -54,8 +54,8 @@
     }
 
     @Override
-    public FrameMap newFrameMap(GraalCompilation compilation) {
-        return new FrameMap(compilation.compiler.runtime, compilation.compiler.target, compilation.registerConfig);
+    public FrameMap newFrameMap(RiRuntime runtime, CiTarget target, RiRegisterConfig registerConfig) {
+        return new FrameMap(runtime, target, registerConfig);
     }
 
     @Override
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/target/amd64/AMD64LIRGenerator.java	Tue Jan 10 13:24:00 2012 +0100
@@ -453,8 +453,8 @@
 
     @Override
     public void emitMembar(int barriers) {
-        int necessaryBarriers = compilation.compiler.target.arch.requiredBarriers(barriers);
-        if (compilation.compiler.target.isMP && necessaryBarriers != 0) {
+        int necessaryBarriers = target.arch.requiredBarriers(barriers);
+        if (target.isMP && necessaryBarriers != 0) {
             append(MEMBAR.create(necessaryBarriers));
         }
     }
@@ -463,7 +463,7 @@
     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
         Variable tmp = emitMove(index);
-        append(TABLE_SWITCH.create(lowKey, defaultTarget, targets, tmp, newVariable(compilation.compiler.target.wordKind)));
+        append(TABLE_SWITCH.create(lowKey, defaultTarget, targets, tmp, newVariable(target.wordKind)));
     }
 
     @Override
@@ -496,7 +496,7 @@
         }
 
         if (kind == CiKind.Object) {
-            Variable loadedAddress = newVariable(compilation.compiler.target.wordKind);
+            Variable loadedAddress = newVariable(target.wordKind);
             append(LEA_MEMORY.create(loadedAddress, addrBase, addrIndex, CiAddress.Scale.Times1, addrDisplacement));
             preGCWriteBarrier(loadedAddress, false, null);
 
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinter.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinter.java	Tue Jan 10 13:24:00 2012 +0100
@@ -33,6 +33,7 @@
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.alloc.*;
 import com.oracle.max.graal.compiler.alloc.Interval.UsePosList;
+import com.oracle.max.graal.compiler.gen.*;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.schedule.*;
 import com.oracle.max.graal.graph.*;
@@ -48,7 +49,8 @@
 class CFGPrinter extends CompilationPrinter {
 
     public final ByteArrayOutputStream buffer;
-    public final GraalCompilation compilation;
+    private final LIR lir;
+    private LIRGenerator lirGenerator;
     public final CiTarget target;
     public final RiRuntime runtime;
 
@@ -56,11 +58,12 @@
      * Creates a control flow graph printer.
      *
      * @param buffer where the output generated via this printer shown be written
+     * @param nodeOperands
      */
     public CFGPrinter(ByteArrayOutputStream buffer, GraalCompilation compilation) {
         super(buffer);
         this.buffer = buffer;
-        this.compilation = compilation;
+        this.lir = compilation.lir();
         this.target = compilation.compiler.target;
         this.runtime = compilation.compiler.runtime;
     }
@@ -68,11 +71,15 @@
     public CFGPrinter(ByteArrayOutputStream buffer, GraalCompilation compilation, CiTarget target, RiRuntime runtime) {
         super(buffer);
         this.buffer = buffer;
-        this.compilation = compilation;
+        this.lir = compilation.lir();
         this.target = target;
         this.runtime = runtime;
     }
 
+    public void setLIRGenerator(LIRGenerator lirGenerator) {
+        this.lirGenerator = lirGenerator;
+    }
+
     /**
      * Prints the control flow graph denoted by a given block map.
      *
@@ -230,8 +237,8 @@
         } else if (node instanceof FloatingNode) {
             out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END);
         }
-        if (compilation.nodeOperands != null && node instanceof ValueNode) {
-            CiValue operand = compilation.operand((ValueNode) node);
+        if (lirGenerator != null && lirGenerator.nodeOperands != null && node instanceof ValueNode) {
+            CiValue operand = lirGenerator.nodeOperands.get(node);
             if (operand != null) {
                 out.print("result ").print(operand.toString()).println(COLUMN_END);
             }
@@ -330,8 +337,8 @@
 
     private String stateValueToString(ValueNode value) {
         String result = nodeToString(value);
-        if (value != null) {
-            CiValue operand = compilation.operand(value);
+        if (lirGenerator != null && lirGenerator.nodeOperands != null && value != null) {
+            CiValue operand = lirGenerator.nodeOperands.get(value);
             if (operand != null) {
                 result += ": " + operand;
             }
@@ -345,8 +352,8 @@
      * @param block the block to print
      */
     private void printLIR(LIRBlock block) {
-        List<LIRInstruction> lir = block.lir();
-        if (lir == null) {
+        List<LIRInstruction> lirInstructions = block.lir();
+        if (lirInstructions == null) {
             return;
         }
 
@@ -366,8 +373,8 @@
             }
         }
 
-        for (int i = 0; i < lir.size(); i++) {
-            LIRInstruction inst = lir.get(i);
+        for (int i = 0; i < lirInstructions.size(); i++) {
+            LIRInstruction inst = lirInstructions.get(i);
             out.printf("nr %4d ", inst.id()).print(COLUMN_END);
 
             if (inst.info != null) {
@@ -396,7 +403,7 @@
             return "-";
         }
         String prefix;
-        if (node instanceof BeginNode && compilation != null && compilation.lir() == null) {
+        if (node instanceof BeginNode && lir == null) {
             prefix = "B";
         } else if (node instanceof ValueNode) {
             ValueNode value = (ValueNode) node;
@@ -412,7 +419,7 @@
     }
 
     private String blockToString(Block block) {
-        if (compilation != null && compilation.lir() == null) {
+        if (lir == null) {
             // During all the front-end phases, the block schedule is built only for the debug output.
             // Therefore, the block numbers would be different for every CFG printed -> use the id of the first instruction.
             return "B" + block.firstNode().toString(Verbosity.Id);
--- a/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java	Mon Jan 09 17:15:03 2012 +0100
+++ b/graal/com.oracle.max.graal.printer/src/com/oracle/max/graal/printer/CFGPrinterObserver.java	Tue Jan 10 13:24:00 2012 +0100
@@ -30,6 +30,7 @@
 import com.oracle.max.criutils.*;
 import com.oracle.max.graal.compiler.*;
 import com.oracle.max.graal.compiler.alloc.*;
+import com.oracle.max.graal.compiler.gen.*;
 import com.oracle.max.graal.compiler.lir.*;
 import com.oracle.max.graal.compiler.observer.*;
 import com.oracle.max.graal.compiler.schedule.*;
@@ -75,6 +76,7 @@
         }
 
         RiRuntime runtime = cfgPrinter.runtime;
+        cfgPrinter.setLIRGenerator(event.debugObject(LIRGenerator.class));
         BlockMap blockMap = event.debugObject(BlockMap.class);
         Graph graph = event.debugObject(Graph.class);
         IdentifyBlocksPhase schedule = event.debugObject(IdentifyBlocksPhase.class);
--- a/mx/projects	Mon Jan 09 17:15:03 2012 +0100
+++ b/mx/projects	Tue Jan 10 13:24:00 2012 +0100
@@ -70,6 +70,18 @@
 project@com.oracle.max.graal.compiler@dependencies=com.oracle.max.asm,com.oracle.max.graal.nodes
 project@com.oracle.max.graal.compiler@checkstyle=com.oracle.max.graal.graph
 
+# graal.phases
+project@com.oracle.max.graal.phases@subDir=graal
+project@com.oracle.max.graal.phases@sourceDirs=src
+project@com.oracle.max.graal.phases@dependencies=com.oracle.max.graal.compiler
+project@com.oracle.max.graal.phases@checkstyle=com.oracle.max.graal.graph
+
+# graal.compilation
+project@com.oracle.max.graal.compilation@subDir=graal
+project@com.oracle.max.graal.compilation@sourceDirs=src
+project@com.oracle.max.graal.compilation@dependencies=com.oracle.max.graal.compiler
+project@com.oracle.max.graal.compilation@checkstyle=com.oracle.max.graal.graph
+
 # graal.java
 project@com.oracle.max.graal.java@subDir=graal
 project@com.oracle.max.graal.java@sourceDirs=src