public class LinearScan extends Object
Modifier and Type | Class and Description |
---|---|
static class |
LinearScan.BlockData |
(package private) class |
LinearScan.CheckConsumer |
(package private) static class |
LinearScan.IntervalPredicate |
static class |
LinearScan.Options |
Modifier | Constructor and Description |
---|---|
protected |
LinearScan(TargetDescription target,
LIRGenerationResult res,
LIRGeneratorTool.SpillMoveFactory spillMoveFactory,
RegisterAllocationConfig regAllocConfig,
List<? extends AbstractBlockBase<?>> sortedBlocks) |
Modifier and Type | Method and Description |
---|---|
(package private) static Interval |
addToList(Interval first,
Interval prev,
Interval interval) |
protected <B extends AbstractBlockBase<B>> |
allocate(TargetDescription target,
LIRGenerationResult lirGenRes,
List<B> codeEmittingOrder,
List<B> linearScanOrder,
LIRGeneratorTool.SpillMoveFactory spillMoveFactory,
RegisterAllocationConfig registerAllocationConfig) |
(package private) void |
assignSpillSlot(Interval interval) |
RegisterAttributes |
attributes(Register reg)
Gets an object describing the attributes of a given register according to this register
configuration.
|
protected void |
beforeSpillMoveElimination() |
AbstractBlockBase<?> |
blockAt(int index) |
int |
blockCount() |
AbstractBlockBase<?> |
blockForId(int opId)
Gets the block containing a given instruction.
|
boolean |
callKillsRegisters() |
(package private) static StackSlotValue |
canonicalSpillOpr(Interval interval) |
(package private) boolean |
coversBlockBegin(int opId1,
int opId2) |
protected LinearScanAssignLocationsPhase |
createAssignLocationsPhase() |
(package private) Interval |
createDerivedInterval(Interval source)
Creates an interval as a result of splitting or spilling another interval.
|
(package private) Interval |
createInterval(AllocatableValue operand)
Creates a new interval.
|
protected LinearScanLifetimeAnalysisPhase |
createLifetimeAnalysisPhase() |
protected MoveResolver |
createMoveResolver() |
protected LinearScanOptimizeSpillPositionPhase |
createOptimizeSpillPositionPhase() |
protected LinearScanRegisterAllocationPhase |
createRegisterAllocationPhase() |
protected LinearScanResolveDataFlowPhase |
createResolveDataFlowPhase() |
protected LinearScanEliminateSpillMovePhase |
createSpillMoveEliminationPhase() |
(package private) Interval.Pair |
createUnhandledLists(LinearScan.IntervalPredicate isList1,
LinearScan.IntervalPredicate isList2) |
LinearScan.BlockData |
getBlockData(AbstractBlockBase<?> block) |
int |
getFirstLirInstructionId(AbstractBlockBase<?> block) |
FrameMapBuilder |
getFrameMapBuilder() |
int |
getLastLirInstructionId(AbstractBlockBase<?> block) |
LIR |
getLIR() |
Interval |
getOrCreateInterval(AllocatableValue operand) |
RegisterAllocationConfig |
getRegisterAllocationConfig() |
Register[] |
getRegisters() |
LIRGeneratorTool.SpillMoveFactory |
getSpillMoveFactory() |
(package private) boolean |
hasCall(int opId)
Determines if an
LIRInstruction destroys all caller saved registers. |
(package private) void |
initBlockData(AbstractBlockBase<?> block) |
(package private) void |
initIntervals() |
(package private) void |
initOpIdMaps(int numInstructions) |
LIRInstruction |
instructionForId(int opId)
Retrieves the
LIRInstruction based on its id. |
(package private) Interval |
intervalFor(int operandNumber) |
Interval |
intervalFor(Value operand) |
Interval[] |
intervals()
Map from operand numbers to intervals.
|
(package private) boolean |
isBlockBegin(int opId) |
(package private) boolean |
isCallerSave(Value operand) |
(package private) boolean |
isMaterialized(AllocatableValue operand,
int opId,
LIRInstruction.OperandMode mode) |
boolean |
isProcessed(Value operand) |
private static boolean |
isSorted(Interval[] intervals) |
static boolean |
isVariableOrRegister(Value value) |
int |
liveSetSize()
Gets the size of the
LinearScan.BlockData.liveIn and LinearScan.BlockData.liveOut sets for a basic
block. |
(package private) int |
maxOpId()
Gets the highest instruction id allocated by this object.
|
(package private) int |
maxRegisterNumber()
Gets the highest operand number for a register operand.
|
(package private) int |
numLoops() |
(package private) int |
operandNumber(Value operand)
|
(package private) int |
operandSize()
Gets the number of operands.
|
private static int |
opIdToIndex(int opId)
Converts an instruction id to an instruction index.
|
void |
printIntervals(String label) |
void |
printLir(String label,
boolean hirValid) |
(package private) void |
putOpIdMaps(int index,
LIRInstruction op,
AbstractBlockBase<?> block) |
List<? extends AbstractBlockBase<?>> |
sortedBlocks() |
(package private) void |
sortIntervalsAfterAllocation() |
protected void |
sortIntervalsBeforeAllocation() |
Interval |
splitChildAtOpId(Interval interval,
int opId,
LIRInstruction.OperandMode mode) |
(package private) boolean |
verify() |
protected void |
verifyIntervals() |
(package private) void |
verifyNoOopsInFixedIntervals() |
private void |
verifyRegisters() |
public static final int DOMINATOR_SPILL_MOVE_ID
private static final int SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT
private final FrameMapBuilder frameMapBuilder
private final RegisterAttributes[] registerAttributes
private final RegisterAllocationConfig regAllocConfig
private final LIRGeneratorTool.SpillMoveFactory moveFactory
private final BlockMap<LinearScan.BlockData> blockData
private final List<? extends AbstractBlockBase<?>> sortedBlocks
private Interval[] intervals
intervals()
private int intervalsSize
intervals
.private int firstDerivedIntervalIndex
intervals
for a
derived interval.private Interval[] sortedIntervals
Interval.from()
.private LIRInstruction[] opIdToInstructionMap
instructionForId(int)
as the id is not simply an index into this
array.private AbstractBlockBase<?>[] opIdToBlockMap
blockForId(int)
as the id is not simply an index into this array.private final int firstVariableNumber
static final LinearScan.IntervalPredicate IS_PRECOLORED_INTERVAL
static final LinearScan.IntervalPredicate IS_VARIABLE_INTERVAL
static final LinearScan.IntervalPredicate IS_STACK_INTERVAL
protected LinearScan(TargetDescription target, LIRGenerationResult res, LIRGeneratorTool.SpillMoveFactory spillMoveFactory, RegisterAllocationConfig regAllocConfig, List<? extends AbstractBlockBase<?>> sortedBlocks)
public int getFirstLirInstructionId(AbstractBlockBase<?> block)
public int getLastLirInstructionId(AbstractBlockBase<?> block)
public LIRGeneratorTool.SpillMoveFactory getSpillMoveFactory()
protected MoveResolver createMoveResolver()
public static boolean isVariableOrRegister(Value value)
int operandNumber(Value operand)
int operandSize()
int maxRegisterNumber()
public LinearScan.BlockData getBlockData(AbstractBlockBase<?> block)
void initBlockData(AbstractBlockBase<?> block)
public RegisterAttributes attributes(Register reg)
void assignSpillSlot(Interval interval)
public Interval[] intervals()
void initIntervals()
Interval createInterval(AllocatableValue operand)
operand
- the operand for the intervalInterval createDerivedInterval(Interval source)
source
- an interval being split of spilledsource
public int blockCount()
public AbstractBlockBase<?> blockAt(int index)
public int liveSetSize()
LinearScan.BlockData.liveIn
and LinearScan.BlockData.liveOut
sets for a basic
block. These sets do not include any operands allocated as a result of creating
derived intervals.int numLoops()
Interval intervalFor(int operandNumber)
public Interval intervalFor(Value operand)
public Interval getOrCreateInterval(AllocatableValue operand)
void initOpIdMaps(int numInstructions)
void putOpIdMaps(int index, LIRInstruction op, AbstractBlockBase<?> block)
int maxOpId()
private static int opIdToIndex(int opId)
public LIRInstruction instructionForId(int opId)
LIRInstruction
based on its id.opId
- an instruction id== id
public AbstractBlockBase<?> blockForId(int opId)
opId
- an instruction idopId
boolean isBlockBegin(int opId)
boolean coversBlockBegin(int opId1, int opId2)
boolean hasCall(int opId)
LIRInstruction
destroys all caller saved registers.opId
- an instruction idtrue
if the instruction denoted by id
destroys all caller saved
registers.public boolean isProcessed(Value operand)
Interval.Pair createUnhandledLists(LinearScan.IntervalPredicate isList1, LinearScan.IntervalPredicate isList2)
protected void sortIntervalsBeforeAllocation()
void sortIntervalsAfterAllocation()
public Interval splitChildAtOpId(Interval interval, int opId, LIRInstruction.OperandMode mode)
static StackSlotValue canonicalSpillOpr(Interval interval)
boolean isMaterialized(AllocatableValue operand, int opId, LIRInstruction.OperandMode mode)
boolean isCallerSave(Value operand)
protected <B extends AbstractBlockBase<B>> void allocate(TargetDescription target, LIRGenerationResult lirGenRes, List<B> codeEmittingOrder, List<B> linearScanOrder, LIRGeneratorTool.SpillMoveFactory spillMoveFactory, RegisterAllocationConfig registerAllocationConfig)
protected void beforeSpillMoveElimination()
protected LinearScanLifetimeAnalysisPhase createLifetimeAnalysisPhase()
protected LinearScanRegisterAllocationPhase createRegisterAllocationPhase()
protected LinearScanOptimizeSpillPositionPhase createOptimizeSpillPositionPhase()
protected LinearScanResolveDataFlowPhase createResolveDataFlowPhase()
protected LinearScanEliminateSpillMovePhase createSpillMoveEliminationPhase()
protected LinearScanAssignLocationsPhase createAssignLocationsPhase()
public void printIntervals(String label)
boolean verify()
private void verifyRegisters()
protected void verifyIntervals()
void verifyNoOopsInFixedIntervals()
public FrameMapBuilder getFrameMapBuilder()
public List<? extends AbstractBlockBase<?>> sortedBlocks()
public Register[] getRegisters()
public RegisterAllocationConfig getRegisterAllocationConfig()
public boolean callKillsRegisters()