public class EstimateBlockFrequencies extends CompilerPhase
This code assumes that the loop structure tree can be constructed for the CFG in question. This implies that the CFG is reducible.
The basic algorithm is as follows:
Modifier and Type | Field and Description |
---|---|
private static Constructor<CompilerPhase> |
constructor
Constructor for this compiler phase
|
private IR |
ir
The IR on which to operate.
|
private LSTGraph |
lst
The loop structure tree of said IR
|
private BasicBlock[] |
topOrder
Topological ordering (ignoring backedges) of CFG
|
container
Constructor and Description |
---|
EstimateBlockFrequencies() |
Modifier and Type | Method and Description |
---|---|
private void |
computeBlockFrequencies() |
private void |
computeInfrequentBlocks(IR ir)
Compute which blocks are infrequent.
|
private float |
computeLoopExitWeight(LSTNode n) |
private void |
computeLoopMultipliers(LSTNode n)
Postorder traversal of LST computing loop multiplier and loop exits
for each loop.
|
private void |
computeMultiplier(LSTNode n)
Compute the loop multiplier for this loop nest
|
private void |
computeNodeWeights(LSTNode n)
Propagate execution frequencies through the loop.
|
Constructor<CompilerPhase> |
getClassConstructor()
Get a constructor object for this compiler phase
|
String |
getName() |
void |
perform(IR _ir)
Compute relative basic block frequencies for the argument IR based on the
branch probability information on each conditional and multiway branch.
|
private void |
processEdge(LSTNode n,
BasicBlock source,
BasicBlock target,
float prob,
float weight) |
void |
reportAdditionalStats()
Called when printing a measure compilation report to enable a phase
to report additional phase-specific statistics.
|
private void |
setDumbFrequencies(IR ir)
Set the frequency of each basic block to 1.0f.
|
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, printingEnabled, setContainer, shouldPerform, verify
private static final Constructor<CompilerPhase> constructor
private BasicBlock[] topOrder
public EstimateBlockFrequencies()
public Constructor<CompilerPhase> getClassConstructor()
getClassConstructor
in class CompilerPhase
public String getName()
getName
in class CompilerPhase
public void reportAdditionalStats()
CompilerPhase
reportAdditionalStats
in class CompilerPhase
public void perform(IR _ir)
Assumptions:
perform
in class CompilerPhase
_ir
- the IR on which to apply the phaseprivate void setDumbFrequencies(IR ir)
ir
- the IR that contains the blocksprivate void computeInfrequentBlocks(IR ir)
Algorithm:
ir
- the governing IR.private void computeLoopMultipliers(LSTNode n)
n
- a nodeprivate void computeMultiplier(LSTNode n)
n
- starting nodeprivate void computeNodeWeights(LSTNode n)
n
- starting nodeprivate void processEdge(LSTNode n, BasicBlock source, BasicBlock target, float prob, float weight)
private float computeLoopExitWeight(LSTNode n)
private void computeBlockFrequencies()