Search in sources :

Example 11 with BitVector

use of org.jikesrvm.util.BitVector in project JikesRVM by JikesRVM.

the class DominatorTreeNode method dominators.

/**
 *   This method returns the set of blocks that dominates the passed
 *   block, i.e., it answers the question "Who dominates me?"
 *
 *   @param ir the governing IR
 *   @return a BitVector containing those blocks that dominate me
 */
BitVector dominators(IR ir) {
    // but we cache it for the next time.
    if (dominators == null) {
        dominators = new BitVector(ir.getMaxBasicBlockNumber() + 1);
        dominators.set(block.getNumber());
        DominatorTreeNode node = this;
        while ((node = (DominatorTreeNode) getParent()) != null) {
            dominators.set(node.getBlock().getNumber());
        }
    }
    return dominators;
}
Also used : BitVector(org.jikesrvm.util.BitVector)

Example 12 with BitVector

use of org.jikesrvm.util.BitVector in project JikesRVM by JikesRVM.

the class EnterSSA method getDefSets.

/**
 * Calculate the set of blocks that contain defs for each
 *    symbolic register in an IR.  <em> Note: </em> This routine skips
 *    registers marked  already having a single static
 *    definition, physical registers, and guard registeres.
 *
 * @return an array of BitVectors, where element <em>i</em> represents the
 *    basic blocks that contain defs for symbolic register <em>i</em>
 */
private BitVector[] getDefSets() {
    int nBlocks = ir.getMaxBasicBlockNumber();
    BitVector[] result = new BitVector[ir.getNumberOfSymbolicRegisters()];
    for (int i = 0; i < result.length; i++) {
        result[i] = new BitVector(nBlocks + 1);
    }
    // loop over each basic block
    for (Enumeration<BasicBlock> e = ir.getBasicBlocks(); e.hasMoreElements(); ) {
        BasicBlock bb = e.nextElement();
        int bbNumber = bb.getNumber();
        // visit each instruction in the basic block
        for (Enumeration<Instruction> ie = bb.forwardInstrEnumerator(); ie.hasMoreElements(); ) {
            Instruction s = ie.nextElement();
            // skip SSA defs
            for (int j = 0; j < s.getNumberOfDefs(); j++) {
                Operand operand = s.getOperand(j);
                if (operand == null)
                    continue;
                if (!operand.isRegister())
                    continue;
                if (operand.asRegister().getRegister().isSSA())
                    continue;
                if (operand.asRegister().getRegister().isPhysical())
                    continue;
                int reg = operand.asRegister().getRegister().getNumber();
                result[reg].set(bbNumber);
            }
        }
    }
    return result;
}
Also used : BitVector(org.jikesrvm.util.BitVector) UnreachableOperand(org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand) BasicBlockOperand(org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) HeapOperand(org.jikesrvm.compilers.opt.ir.operand.HeapOperand) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Example 13 with BitVector

use of org.jikesrvm.util.BitVector in project JikesRVM by JikesRVM.

the class EnterSSA method insertPhiFunctions.

/**
 * Insert the necessary phi functions into an IR.
 * <p> Algorithm:
 * <p>For register r, let S be the set of all blocks that
 *    contain defs of r.  Let D be the iterated dominance frontier
 *    of S.  Each block in D needs a phi-function for r.
 *
 * <p> Special Java case: if node N dominates all defs of r, then N
 *                      does not need a phi-function for r
 *
 * @param ir the governing IR
 * @param defs defs[i] represents the basic blocks that define
 *            symbolic register i.
 * @param symbolics symbolics[i] is symbolic register number i
 * @param excludeGuards whether guard registers should be excluded
 *  from SSA
 */
private void insertPhiFunctions(IR ir, BitVector[] defs, Register[] symbolics, boolean excludeGuards) {
    for (int r = 0; r < defs.length; r++) {
        if (symbolics[r] == null)
            continue;
        if (symbolics[r].isSSA())
            continue;
        if (symbolics[r].isPhysical())
            continue;
        if (excludeGuards && symbolics[r].isValidation())
            continue;
        if (DEBUG)
            System.out.println("Inserting phis for register " + r);
        if (DEBUG)
            System.out.println("Start iterated frontier...");
        BitVector needsPhi = DominanceFrontier.getIteratedDominanceFrontier(ir, defs[r]);
        removePhisThatDominateAllDefs(needsPhi, ir, defs[r]);
        if (DEBUG)
            System.out.println("Done.");
        for (int b = 0; b < needsPhi.length(); b++) {
            if (needsPhi.get(b)) {
                BasicBlock bb = ir.getBasicBlock(b);
                if (live.getLiveInfo(bb).getIn().contains(symbolics[r])) {
                    insertPhi(bb, symbolics[r]);
                }
            }
        }
    }
}
Also used : BitVector(org.jikesrvm.util.BitVector) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Example 14 with BitVector

use of org.jikesrvm.util.BitVector in project JikesRVM by JikesRVM.

the class AnnotatedLSTNode method getBasicBlocks.

/**
 * Return an enumeration of basic blocks corresponding to a depth
 * first traversal of the blocks in the loops graphs
 *
 * @return Blocks in loop with header first and exit last
 */
public Enumeration<BasicBlock> getBasicBlocks() {
    BitVector blocksLeftToVisit = new BitVector(loop);
    BBEnum bbs = getBasicBlocks(header, new BBEnum(), blocksLeftToVisit);
    if (exit != null) {
        // place the exit block at the end of the list if we've recognized one
        bbs.add(exit);
    }
    return bbs;
}
Also used : BitVector(org.jikesrvm.util.BitVector)

Example 15 with BitVector

use of org.jikesrvm.util.BitVector in project JikesRVM by JikesRVM.

the class CFGTransformations method inLoopPredecessors.

private static BasicBlock[] inLoopPredecessors(LSTNode n) {
    BasicBlock header = n.header;
    BitVector loop = n.getLoop();
    int i = 0;
    Enumeration<BasicBlock> be = header.getIn();
    while (be.hasMoreElements()) if (inLoop(be.nextElement(), loop))
        i++;
    BasicBlock[] res = new BasicBlock[i];
    i = 0;
    be = header.getIn();
    while (be.hasMoreElements()) {
        BasicBlock in = be.nextElement();
        if (inLoop(in, loop))
            res[i++] = in;
    }
    return res;
}
Also used : BitVector(org.jikesrvm.util.BitVector) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock)

Aggregations

BitVector (org.jikesrvm.util.BitVector)20 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)12 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)3 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)2 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)2 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)2 HashSet (java.util.HashSet)1 IR (org.jikesrvm.compilers.opt.ir.IR)1 Register (org.jikesrvm.compilers.opt.ir.Register)1 BasicBlockOperand (org.jikesrvm.compilers.opt.ir.operand.BasicBlockOperand)1 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)1 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)1 ConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ConstantOperand)1 HeapOperand (org.jikesrvm.compilers.opt.ir.operand.HeapOperand)1 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)1 UnreachableOperand (org.jikesrvm.compilers.opt.ir.operand.UnreachableOperand)1 TreeNode (org.jikesrvm.compilers.opt.util.TreeNode)1