Mercurial > hg > graal-compiler
changeset 14145:4ff08c0366ae
Encapsulate LIR class fields.
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Tue Mar 11 16:55:57 2014 +0100 @@ -89,7 +89,7 @@ public AMD64LIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new AMD64SpillMoveFactory(); + lir.setSpillMoveFactory(new AMD64SpillMoveFactory()); } @Override
--- a/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler.hsail/src/com/oracle/graal/compiler/hsail/HSAILLIRGenerator.java Tue Mar 11 16:55:57 2014 +0100 @@ -78,7 +78,7 @@ public HSAILLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new HSAILSpillMoveFactory(); + lir.setSpillMoveFactory(new HSAILSpillMoveFactory()); } @Override
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Tue Mar 11 16:55:57 2014 +0100 @@ -91,7 +91,7 @@ public PTXLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new PTXSpillMoveFactory(); + lir.setSpillMoveFactory(new PTXSpillMoveFactory()); int callVariables = cc.getArgumentCount() + (cc.getReturn().equals(Value.ILLEGAL) ? 0 : 1); lir.setFirstVariableNumber(callVariables); nextPredRegNum = 0;
--- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Tue Mar 11 16:55:57 2014 +0100 @@ -80,7 +80,7 @@ public SPARCLIRGenerator(StructuredGraph graph, Providers providers, FrameMap frameMap, CallingConvention cc, LIR lir) { super(graph, providers, frameMap, cc, lir); - lir.spillMoveFactory = new SPARCSpillMoveFactory(); + lir.setSpillMoveFactory(new SPARCSpillMoveFactory()); } @Override
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Tue Mar 11 16:55:57 2014 +0100 @@ -168,7 +168,7 @@ this.registers = target.arch.getRegisters(); this.firstVariableNumber = registers.length; this.variables = new ArrayList<>(ir.numVariables() * 3 / 2); - this.blockData = new BlockMap<>(ir.cfg); + this.blockData = new BlockMap<>(ir.getControlFlowGraph()); } public int getFirstLirInstructionId(Block block) { @@ -335,7 +335,7 @@ } int numLoops() { - return ir.cfg.getLoops().length; + return ir.getControlFlowGraph().getLoops().length; } boolean isIntervalInLoop(int interval, int loop) { @@ -562,7 +562,7 @@ assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); assert isStackSlot(toLocation) : "to operand must be a stack slot"; - insertionBuffer.append(j + 1, ir.spillMoveFactory.createMove(toLocation, fromLocation)); + insertionBuffer.append(j + 1, ir.getSpillMoveFactory().createMove(toLocation, fromLocation)); Debug.log("inserting move after definition of interval %d to stack slot %s at opId %d", interval.operandNumber, interval.spillSlot(), opId); } @@ -785,7 +785,7 @@ // this is checked by these assertions to be sure about it. // the entry block may have incoming // values in registers, which is ok. - if (isRegister(operand) && block != ir.cfg.getStartBlock()) { + if (isRegister(operand) && block != ir.getControlFlowGraph().getStartBlock()) { if (isProcessed(operand)) { assert liveKill.get(operandNumber(operand)) : "using fixed register that is not defined in this block"; } @@ -869,7 +869,7 @@ } // check that the liveIn set of the first block is empty - Block startBlock = ir.cfg.getStartBlock(); + Block startBlock = ir.getControlFlowGraph().getStartBlock(); if (blockData.get(startBlock).liveIn.cardinality() != 0) { if (DetailedAsserts.getValue()) { reportFailure(numBlocks); @@ -901,7 +901,7 @@ try (Scope s = Debug.forceLog()) { Indent indent = Debug.logAndIndent("report failure"); - BitSet startBlockLiveIn = blockData.get(ir.cfg.getStartBlock()).liveIn; + BitSet startBlockLiveIn = blockData.get(ir.getControlFlowGraph().getStartBlock()).liveIn; try (Indent indent2 = Debug.logAndIndent("Error: liveIn set of first block must be empty (when this fails, variables are used before they are defined):")) { for (int operandNum = startBlockLiveIn.nextSetBit(0); operandNum >= 0; operandNum = startBlockLiveIn.nextSetBit(operandNum + 1)) { Value operand = operandFor(operandNum);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Tue Mar 11 16:55:57 2014 +0100 @@ -202,7 +202,7 @@ AllocatableValue fromOpr = fromInterval.operand; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from %s to %s at %d", fromInterval, toInterval, insertIdx); } @@ -212,7 +212,7 @@ assert insertIdx != -1 : "must setup insert position first"; AllocatableValue toOpr = toInterval.operand; - insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); + insertionBuffer.append(insertIdx, allocator.ir.getSpillMoveFactory().createMove(toOpr, fromOpr)); Debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx); }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Tue Mar 11 16:55:57 2014 +0100 @@ -341,7 +341,7 @@ } public LabelRef getLIRBlock(FixedNode b) { - Block result = lir.cfg.blockFor(b); + Block result = lir.getControlFlowGraph().blockFor(b); int suxIndex = currentBlock.getSuccessors().indexOf(result); assert suxIndex != -1 : "Block not in successor list of current block"; @@ -426,7 +426,7 @@ TTY.println("BEGIN Generating LIR for block B" + block.getId()); } - if (block == lir.cfg.getStartBlock()) { + if (block == lir.getControlFlowGraph().getStartBlock()) { assert block.getPredecessorCount() == 0; emitPrologue(graph); } else {
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Tue Mar 11 16:55:57 2014 +0100 @@ -392,7 +392,7 @@ asm.emitString(""); // Get the start block - Block startBlock = lir.cfg.getStartBlock(); + Block startBlock = lir.getControlFlowGraph().getStartBlock(); // Keep a list of ParameterOp instructions to delete from the // list of instructions in the block. ArrayList<LIRInstruction> deleteOps = new ArrayList<>();
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Tue Mar 11 16:55:57 2014 +0100 @@ -35,7 +35,7 @@ */ public class LIR { - public final ControlFlowGraph cfg; + private final ControlFlowGraph cfg; /** * The linear-scan ordered list of blocks. @@ -51,9 +51,9 @@ private int numVariables; - public SpillMoveFactory spillMoveFactory; + private SpillMoveFactory spillMoveFactory; - public final BlockMap<List<LIRInstruction>> lirInstructions; + private final BlockMap<List<LIRInstruction>> lirInstructions; public interface SpillMoveFactory { @@ -72,6 +72,10 @@ this.lirInstructions = new BlockMap<>(cfg); } + public ControlFlowGraph getControlFlowGraph() { + return cfg; + } + /** * Determines if any instruction in the LIR has debug info associated with it. */ @@ -86,6 +90,10 @@ return false; } + public SpillMoveFactory getSpillMoveFactory() { + return spillMoveFactory; + } + public List<LIRInstruction> lir(Block block) { return lirInstructions.get(block); } @@ -199,4 +207,8 @@ } return true; } + + public void setSpillMoveFactory(SpillMoveFactory spillMoveFactory) { + this.spillMoveFactory = spillMoveFactory; + } }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Tue Mar 11 16:43:18 2014 +0100 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/CFGPrinterObserver.java Tue Mar 11 16:55:57 2014 +0100 @@ -141,7 +141,7 @@ cfgPrinter.target = cfgPrinter.lirGenerator.target(); } if (cfgPrinter.lir != null) { - cfgPrinter.cfg = cfgPrinter.lir.cfg; + cfgPrinter.cfg = cfgPrinter.lir.getControlFlowGraph(); } CodeCacheProvider codeCache = Debug.contextLookup(CodeCacheProvider.class);