Search in sources :

Example 91 with BasicBlock

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);
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 92 with BasicBlock

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);
    }
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 93 with BasicBlock

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);
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 94 with BasicBlock

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);
        }
    }
}
Also used : WeightedBranchTargets(org.jikesrvm.compilers.opt.ir.WeightedBranchTargets) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 95 with BasicBlock

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);
    }
}
Also used : BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Aggregations

BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)219 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)117 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)93 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)66 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)52 Register (org.jikesrvm.compilers.opt.ir.Register)50 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)48 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)37 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)33 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)27 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)24 HeapOperand (org.jikesrvm.compilers.opt.ir.operand.HeapOperand)21 BasicBlockOperand (org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand)20 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)19 TypeReference (org.jikesrvm.classloader.TypeReference)18 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)18 Test (org.junit.Test)17 BranchOperand (org.jikesrvm.compilers.opt.ir.operand.BranchOperand)16 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)14 MemoryOperand (org.jikesrvm.compilers.opt.ir.operand.MemoryOperand)14