# HG changeset patch # User Josef Eisl # Date 1395079887 -3600 # Node ID 9334612dd438a8294b49f0bde0b76befb1c40e4c # Parent 056357ac3efbf72a6433ffde2237b51b27a0df99 Introduce LIRGenerationResultBase. diff -r 056357ac3efb -r 9334612dd438 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerationResult.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerationResult.java Mon Mar 17 18:36:58 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerationResult.java Mon Mar 17 19:11:27 2014 +0100 @@ -26,4 +26,6 @@ public interface LIRGenerationResult { FrameMap getFrameMap(); + + LIR getLIR(); } diff -r 056357ac3efb -r 9334612dd438 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerationResultBase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerationResultBase.java Mon Mar 17 19:11:27 2014 +0100 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014, 2014, 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.graal.compiler.gen; + +import com.oracle.graal.lir.*; + +public abstract class LIRGenerationResultBase implements LIRGenerationResult { + private final LIR lir; + + public LIRGenerationResultBase(LIR lir) { + this.lir = lir; + } + + public LIR getLIR() { + return lir; + } + +} diff -r 056357ac3efb -r 9334612dd438 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Mon Mar 17 18:36:58 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Mon Mar 17 19:11:27 2014 +0100 @@ -57,7 +57,7 @@ /** * This class traverses the HIR instructions and generates LIR instructions from them. */ -public abstract class LIRGenerator implements LIRGeneratorTool, LIRTypeTool, LIRGenerationResult { +public abstract class LIRGenerator extends LIRGenerationResultBase implements LIRGeneratorTool, LIRTypeTool, LIRGenerationResult { public static class Options { // @formatter:off @@ -70,7 +70,6 @@ private final FrameMap frameMap; private final NodeMap nodeOperands; - private final LIR lir; private final Providers providers; protected final CallingConvention cc; @@ -171,11 +170,11 @@ public abstract boolean canStoreConstant(Constant c, boolean isCompressed); public LIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { + super(lir); this.providers = providers; this.frameMap = frameMap; this.cc = cc; this.nodeOperands = graph.createNodeMap(); - this.lir = lir; this.debugInfoBuilder = createDebugInfoBuilder(nodeOperands); this.traceLevel = Options.TraceLIRGeneratorLevel.getValue(); this.printIRWithLIR = Options.PrintIRWithLIR.getValue(); @@ -256,17 +255,17 @@ } LoadConstant load = constantLoads.get(value); if (load == null) { - int index = lir.lir(currentBlock).size(); + int index = getLIR().lir(currentBlock).size(); loadedValue = emitMove(value); - LIRInstruction op = lir.lir(currentBlock).get(index); + LIRInstruction op = getLIR().lir(currentBlock).get(index); constantLoads.put(value, new LoadConstant(loadedValue, currentBlock, index, op)); } else { Block dominator = ControlFlowGraph.commonDominator(load.block, currentBlock); loadedValue = load.variable; if (dominator != load.block) { - load.unpin(lir); + load.unpin(getLIR()); } else { - assert load.block != currentBlock || load.index < lir.lir(currentBlock).size(); + assert load.block != currentBlock || load.index < getLIR().lir(currentBlock).size(); } load.block = dominator; } @@ -296,7 +295,7 @@ */ @Override public Variable newVariable(PlatformKind platformKind) { - return new Variable(platformKind, lir.nextVariable()); + return new Variable(platformKind, getLIR().nextVariable()); } @Override @@ -341,12 +340,12 @@ } public LabelRef getLIRBlock(FixedNode b) { - assert lir.getControlFlowGraph() instanceof ControlFlowGraph; - Block result = ((ControlFlowGraph) lir.getControlFlowGraph()).blockFor(b); + assert getLIR().getControlFlowGraph() instanceof ControlFlowGraph; + Block result = ((ControlFlowGraph) getLIR().getControlFlowGraph()).blockFor(b); int suxIndex = currentBlock.getSuccessors().indexOf(result); assert suxIndex != -1 : "Block not in successor list of current block"; - return LabelRef.forSuccessor(lir, currentBlock, suxIndex); + return LabelRef.forSuccessor(getLIR(), currentBlock, suxIndex); } /** @@ -407,7 +406,7 @@ TTY.println(); } assert LIRVerifier.verify(op); - lir.lir(currentBlock).add(op); + getLIR().lir(currentBlock).add(op); } public void doBlock(Block block, StructuredGraph graph, BlockMap> blockMap) { @@ -418,8 +417,8 @@ currentBlock = block; // set up the list of LIR instructions - assert lir.lir(block) == null : "LIR list already computed for this block"; - lir.setLir(block, new ArrayList()); + assert getLIR().lir(block) == null : "LIR list already computed for this block"; + getLIR().setLir(block, new ArrayList()); append(new LabelOp(new Label(block.getId()), block.isAligned())); @@ -427,7 +426,7 @@ TTY.println("BEGIN Generating LIR for block B" + block.getId()); } - if (block == lir.getControlFlowGraph().getStartBlock()) { + if (block == getLIR().getControlFlowGraph().getStartBlock()) { assert block.getPredecessorCount() == 0; emitPrologue(graph); } else { @@ -474,7 +473,7 @@ emitJump(getLIRBlock((FixedNode) successors.first())); } - assert verifyBlock(lir, block); + assert verifyBlock(getLIR(), block); if (traceLevel >= 1) { TTY.println("END Generating LIR for block B" + block.getId()); @@ -490,7 +489,7 @@ protected abstract boolean peephole(ValueNode valueNode); private boolean hasBlockEnd(Block block) { - List ops = lir.lir(block); + List ops = getLIR().lir(block); if (ops.size() == 0) { return false; } @@ -531,8 +530,8 @@ params[i] = toStackKind(incomingArguments.getArgument(i)); if (ValueUtil.isStackSlot(params[i])) { StackSlot slot = ValueUtil.asStackSlot(params[i]); - if (slot.isInCallerFrame() && !lir.hasArgInCallerFrame()) { - lir.setHasArgInCallerFrame(); + if (slot.isInCallerFrame() && !getLIR().hasArgInCallerFrame()) { + getLIR().setHasArgInCallerFrame(); } } } @@ -547,7 +546,7 @@ } public void emitIncomingValues(Value[] params) { - ((LabelOp) lir.lir(currentBlock).get(0)).setIncomingValues(params); + ((LabelOp) getLIR().lir(currentBlock).get(0)).setIncomingValues(params); } @Override @@ -857,10 +856,6 @@ protected abstract void emitTableSwitch(int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value key); - public final LIR getLIR() { - return lir; - } - public final NodeMap getNodeOperands() { return nodeOperands; } @@ -892,13 +887,13 @@ outOfLoopDominator = outOfLoopDominator.getDominator(); } if (outOfLoopDominator != lc.block) { - lc.unpin(lir); + lc.unpin(getLIR()); lc.block = outOfLoopDominator; } } if (lc.index != -1) { - assert lir.lir(lc.block).get(lc.index) == lc.op; + assert getLIR().lir(lc.block).get(lc.index) == lc.op; iter.remove(); } } @@ -919,7 +914,7 @@ } int groupSize = groupEnd - groupBegin; - List ops = lir.lir(block); + List ops = getLIR().lir(block); int lastIndex = ops.size() - 1; assert ops.get(lastIndex) instanceof BlockEndOp; int insertionIndex = lastIndex;