use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class DominatorTree method dominates.
/**
* Does basic block number "master" dominate basic block number "slave"?
*
* @param master the number of the proposed "master" basic block
* @param slave the number of the proposed "slave block
* @return "master dominates slave"
*/
public boolean dominates(int master, int slave) {
BasicBlock masterBlock = ir.getBasicBlock(master);
BasicBlock slaveBlock = ir.getBasicBlock(slave);
DominatorTreeNode masterNode = dominatorInfoMap[masterBlock.getNumber()];
DominatorTreeNode slaveNode = dominatorInfoMap[slaveBlock.getNumber()];
return slaveNode.isDominatedBy(masterNode);
}
use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class Dominators method printDominators.
/**
* Print the (already calculated) dominators.
* @param ir the IR
*/
public void printDominators(IR ir) {
for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
BasicBlock b = e.nextElement();
DominatorInfo i = dominatorInfo.get(b);
System.out.println("Dominators of " + b + ":" + i.dominators);
}
}
use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class EstimateBlockFrequencies method perform.
/**
* Compute relative basic block frequencies for the argument IR based on the
* branch probability information on each conditional and multiway branch.<p>
*
* Assumptions:
* <ol>
* <li>LST is valid
* <li>basic block numbering is dense (compact has been called)
* </ol>
*
* @param _ir the IR on which to apply the phase
*/
@Override
public void perform(IR _ir) {
// Prepare
ir = _ir;
if (ir.options.PROFILE_FREQUENCY_STRATEGY == OptOptions.PROFILE_DUMB_FREQ) {
setDumbFrequencies(ir);
return;
}
ir.cfg.resetTopSorted();
ir.cfg.buildTopSort();
topOrder = new BasicBlock[ir.cfg.numberOfNodes()];
int idx = 0;
for (BasicBlock ptr = ir.cfg.entry(); ptr != null; ptr = (BasicBlock) ptr.getForwardSortedNext()) {
topOrder[idx++] = ptr;
ptr.setExecutionFrequency(0f);
ptr.clearScratchFlag();
}
// Get pre-computed LST from IR.
lst = ir.HIRInfo.loopStructureTree;
// Compute loop multipliers
if (lst != null) {
computeLoopMultipliers(lst.getRoot());
for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
BasicBlock bb = e.nextElement();
bb.setExecutionFrequency(0f);
bb.clearScratchFlag();
}
}
// Compute execution frequency of each basic block
computeBlockFrequencies();
// Set infrequent bits on basic blocks
computeInfrequentBlocks(ir);
}
use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class EstimateBlockFrequencies method computeNodeWeights.
/**
* Propagate execution frequencies through the loop.
* Also records loop exit edges in loopExits.
*
* @param n starting node
*/
private void computeNodeWeights(LSTNode n) {
n.header.setExecutionFrequency(1f);
int idx = 0;
while (topOrder[idx] != n.header) idx++;
for (int numNodes = n.getLoop().populationCount(); numNodes > 0; ) {
if (idx >= topOrder.length) {
numNodes--;
continue;
}
BasicBlock cur = topOrder[idx++];
if (cur == null) {
numNodes--;
continue;
}
// node was not in the loop nest being processed.
if (!n.getLoop().get(cur.getNumber()))
continue;
LSTNode other = lst.getLoop(cur);
if (other != n) {
if (cur == other.header) {
// loop header of nested loop
numNodes -= other.getLoop().populationCount();
}
// skip over nodes in nested loop.
continue;
}
numNodes--;
cur.setScratchFlag();
float weight = cur.getExecutionFrequency();
for (WeightedBranchTargets wbt = new WeightedBranchTargets(cur); wbt.hasMoreElements(); wbt.advance()) {
processEdge(n, cur, wbt.curBlock(), wbt.curWeight(), weight);
}
}
}
use of org.jikesrvm.compilers.opt.ir.BasicBlock in project JikesRVM by JikesRVM.
the class EstimateBlockFrequencies method setDumbFrequencies.
/**
* Set the frequency of each basic block to 1.0f.
*
* @param ir the IR that contains the blocks
*/
private void setDumbFrequencies(IR ir) {
for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
BasicBlock bb = e.nextElement();
bb.setExecutionFrequency(1f);
}
}
Aggregations