public final class ComputeBlockOrder extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
ComputeBlockOrder.BlockOrderComparator<T extends AbstractBlockBase<T>>
Comparator for sorting blocks based on loop depth and probability.
|
Modifier and Type | Field and Description |
---|---|
private static int |
INITIAL_WORKLIST_CAPACITY
The initial capacities of the worklists used for iteratively finding the block order.
|
private static int |
PENALTY_VERSUS_UNSCHEDULED
Divisor used for degrading the probability of the current path versus unscheduled paths at a
merge node when calculating the linear scan order.
|
Constructor and Description |
---|
ComputeBlockOrder() |
Modifier and Type | Method and Description |
---|---|
private static <T extends AbstractBlockBase<T>> |
addBlock(T header,
List<T> order)
Adds a block to the ordering.
|
private static <T extends AbstractBlockBase<T>> |
addPathToCodeEmittingOrder(T initialBlock,
List<T> order,
PriorityQueue<T> worklist,
BitSet visitedBlocks)
Add a linear path to the code emission order greedily following the most likely successor.
|
private static <T extends AbstractBlockBase<T>> |
addPathToLinearScanOrder(T block,
List<T> order,
PriorityQueue<T> worklist,
BitSet visitedBlocks)
Add a linear path to the linear scan order greedily following the most likely successor.
|
private static boolean |
checkOrder(List<? extends AbstractBlockBase<?>> order,
int expectedBlockCount)
Checks that the ordering contains the expected number of blocks.
|
static <T extends AbstractBlockBase<T>> |
computeCodeEmittingOrder(int blockCount,
T startBlock)
Computes the block order used for code emission.
|
private static <T extends AbstractBlockBase<T>> |
computeCodeEmittingOrder(List<T> order,
PriorityQueue<T> worklist,
BitSet visitedBlocks)
Iteratively adds paths to the code emission block order.
|
static <T extends AbstractBlockBase<T>> |
computeLinearScanOrder(int blockCount,
T startBlock)
Computes the block order used for the linear scan register allocator.
|
private static <T extends AbstractBlockBase<T>> |
computeLinearScanOrder(List<T> order,
PriorityQueue<T> worklist,
BitSet visitedBlocks)
Iteratively adds paths to the linear scan block order.
|
private static <T extends AbstractBlockBase<T>> |
enqueueSuccessors(T block,
PriorityQueue<T> worklist,
BitSet visitedBlocks)
Add successor blocks into the given work list if they are not already marked as visited.
|
private static <T extends AbstractBlockBase<T>> |
findAndMarkMostLikelySuccessor(T block,
BitSet visitedBlocks)
Find the highest likely unvisited successor block of a given block.
|
private static <T extends AbstractBlockBase<T>> |
initializeWorklist(T startBlock,
BitSet visitedBlocks)
Initializes the priority queue used for the work list of blocks and adds the start block.
|
private static <T extends AbstractBlockBase<T>> |
skipLoopHeader(AbstractBlockBase<T> block)
Skip the loop header block if the loop consists of more than one block and it has only a
single loop end block.
|
private static final int INITIAL_WORKLIST_CAPACITY
private static final int PENALTY_VERSUS_UNSCHEDULED
public ComputeBlockOrder()
public static <T extends AbstractBlockBase<T>> List<T> computeLinearScanOrder(int blockCount, T startBlock)
public static <T extends AbstractBlockBase<T>> List<T> computeCodeEmittingOrder(int blockCount, T startBlock)
private static <T extends AbstractBlockBase<T>> void computeCodeEmittingOrder(List<T> order, PriorityQueue<T> worklist, BitSet visitedBlocks)
private static <T extends AbstractBlockBase<T>> void computeLinearScanOrder(List<T> order, PriorityQueue<T> worklist, BitSet visitedBlocks)
private static <T extends AbstractBlockBase<T>> PriorityQueue<T> initializeWorklist(T startBlock, BitSet visitedBlocks)
private static <T extends AbstractBlockBase<T>> void addPathToLinearScanOrder(T block, List<T> order, PriorityQueue<T> worklist, BitSet visitedBlocks)
private static <T extends AbstractBlockBase<T>> void addPathToCodeEmittingOrder(T initialBlock, List<T> order, PriorityQueue<T> worklist, BitSet visitedBlocks)
private static <T extends AbstractBlockBase<T>> void addBlock(T header, List<T> order)
private static <T extends AbstractBlockBase<T>> T findAndMarkMostLikelySuccessor(T block, BitSet visitedBlocks)
private static <T extends AbstractBlockBase<T>> void enqueueSuccessors(T block, PriorityQueue<T> worklist, BitSet visitedBlocks)
private static <T extends AbstractBlockBase<T>> boolean skipLoopHeader(AbstractBlockBase<T> block)
private static boolean checkOrder(List<? extends AbstractBlockBase<?>> order, int expectedBlockCount)