Mercurial > hg > graal-compiler
changeset 22354:d6f1915f5a63
LinearScan: clean up members.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Fri, 24 Jul 2015 09:29:36 +0200 |
parents | 45333ae5f428 |
children | 2fc1b037a48b |
files | graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/RegisterVerifier.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScan.java |
diffstat | 6 files changed, 36 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Fri Jul 24 09:22:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Fri Jul 24 09:29:36 2015 +0200 @@ -55,18 +55,6 @@ */ public class LinearScan { - private final LIR ir; - private final FrameMapBuilder frameMapBuilder; - final RegisterAttributes[] registerAttributes; - final Register[] registers; - final RegisterAllocationConfig regAllocConfig; - private final SpillMoveFactory moveFactory; - - final boolean callKillsRegisters; - - public static final int DOMINATOR_SPILL_MOVE_ID = -2; - static final int SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT = 1; - public static class Options { // @formatter:off @Option(help = "Enable spill position optimization", type = OptionType.Debug) @@ -106,6 +94,16 @@ public BitSet liveKill; } + public static final int DOMINATOR_SPILL_MOVE_ID = -2; + private static final int SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT = 1; + + private final LIR ir; + private final FrameMapBuilder frameMapBuilder; + private final RegisterAttributes[] registerAttributes; + private final Register[] registers; + private final RegisterAllocationConfig regAllocConfig; + private final SpillMoveFactory moveFactory; + private final BlockMap<BlockData> blockData; /** @@ -114,7 +112,7 @@ private final List<? extends AbstractBlockBase<?>> sortedBlocks; /** @see #intervals() */ - protected Interval[] intervals; + private Interval[] intervals; /** * The number of valid entries in {@link #intervals}. @@ -161,14 +159,8 @@ this.regAllocConfig = regAllocConfig; this.registers = target.arch.getRegisters(); - this.firstVariableNumber = registers.length; + this.firstVariableNumber = getRegisters().length; this.blockData = new BlockMap<>(ir.getControlFlowGraph()); - - /* - * If all allocatable registers are caller saved, then no registers are live across a call - * site. The register allocator can save time not trying to find a register at a call site. - */ - this.callKillsRegisters = regAllocConfig.getRegisterConfig().areAllAllocatableRegistersCallerSaved(); } public int getFirstLirInstructionId(AbstractBlockBase<?> block) { @@ -883,4 +875,16 @@ return sortedBlocks; } + public Register[] getRegisters() { + return registers; + } + + public RegisterAllocationConfig getRegisterAllocationConfig() { + return regAllocConfig; + } + + public boolean callKillsRegisters() { + return regAllocConfig.getRegisterConfig().areAllAllocatableRegistersCallerSaved(); + } + }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java Fri Jul 24 09:22:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java Fri Jul 24 09:29:36 2015 +0200 @@ -708,7 +708,7 @@ }; // create a list with all caller-save registers (cpu, fpu, xmm) - Register[] callerSaveRegs = allocator.regAllocConfig.getRegisterConfig().getCallerSaveRegisters(); + Register[] callerSaveRegs = allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters(); // iterate all blocks in reverse order for (int i = allocator.blockCount() - 1; i >= 0; i--) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java Fri Jul 24 09:22:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanWalker.java Fri Jul 24 09:29:36 2015 +0200 @@ -84,12 +84,12 @@ super(allocator, unhandledFixedFirst, unhandledAnyFirst); moveResolver = allocator.createMoveResolver(); - spillIntervals = Util.uncheckedCast(new List[allocator.registers.length]); - for (int i = 0; i < allocator.registers.length; i++) { + spillIntervals = Util.uncheckedCast(new List[allocator.getRegisters().length]); + for (int i = 0; i < allocator.getRegisters().length; i++) { spillIntervals[i] = EMPTY_LIST; } - usePos = new int[allocator.registers.length]; - blockPos = new int[allocator.registers.length]; + usePos = new int[allocator.getRegisters().length]; + blockPos = new int[allocator.getRegisters().length]; } void initUseLists(boolean onlyProcessUsePos) { @@ -892,7 +892,7 @@ } boolean noAllocationPossible(Interval interval) { - if (allocator.callKillsRegisters) { + if (allocator.callKillsRegisters()) { // fast calculation of intervals that can never get a register because the // the next instruction is a call that blocks all registers // Note: this only works if a call kills all registers @@ -917,7 +917,7 @@ } void initVarsForAlloc(Interval interval) { - AllocatableRegisters allocatableRegisters = allocator.regAllocConfig.getAllocatableRegisters(interval.kind().getPlatformKind()); + AllocatableRegisters allocatableRegisters = allocator.getRegisterAllocationConfig().getAllocatableRegisters(interval.kind().getPlatformKind()); availableRegs = allocatableRegisters.allocatableRegisters; minReg = allocatableRegisters.minRegisterNumber; maxReg = allocatableRegisters.maxRegisterNumber;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java Fri Jul 24 09:22:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/MoveResolver.java Fri Jul 24 09:29:36 2015 +0200 @@ -90,12 +90,12 @@ this.mappingTo = new ArrayList<>(8); this.insertIdx = -1; this.insertionBuffer = new LIRInsertionBuffer(); - this.registerBlocked = new int[allocator.registers.length]; + this.registerBlocked = new int[allocator.getRegisters().length]; } protected boolean checkEmpty() { assert mappingFrom.size() == 0 && mappingFromOpr.size() == 0 && mappingTo.size() == 0 : "list must be empty before and after processing"; - for (int i = 0; i < getAllocator().registers.length; i++) { + for (int i = 0; i < getAllocator().getRegisters().length; i++) { assert registerBlocked[i] == 0 : "register map must be empty before and after processing"; } checkMultipleReads();
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/RegisterVerifier.java Fri Jul 24 09:22:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/RegisterVerifier.java Fri Jul 24 09:29:36 2015 +0200 @@ -120,7 +120,7 @@ protected void printState(Interval[] inputState) { for (int i = 0; i < stateSize(); i++) { - Register reg = allocator.registers[i]; + Register reg = allocator.getRegisters()[i]; assert reg.number == i; if (inputState[i] != null) { Debug.log(" %6s %4d -- %s", reg, inputState[i].operandNumber, inputState[i]); @@ -242,7 +242,7 @@ op.visitEachInput(useConsumer); // invalidate all caller save registers at calls if (op.destroysCallerSavedRegisters()) { - for (Register r : allocator.regAllocConfig.getRegisterConfig().getCallerSaveRegisters()) { + for (Register r : allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters()) { statePut(inputState, r.asValue(), null); } }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScan.java Fri Jul 24 09:22:56 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScan.java Fri Jul 24 09:29:36 2015 +0200 @@ -62,7 +62,7 @@ createLifetimeAnalysisPhase().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, false); - try (Scope s = Debug.scope("AfterLifetimeAnalysis", (Object) intervals)) { + try (Scope s = Debug.scope("AfterLifetimeAnalysis", (Object) intervals())) { sortIntervalsBeforeAllocation(); createRegisterAllocationPhase().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, false);