/** * Look up a BasicBlock by its unique label. * * @param blockLabel the label of a BasicBlock * @return the BasicBlock with the given label, or null if there is no such BasicBlock */ public BasicBlock lookupBlockByLabel(int blockLabel) { for (Iterator<BasicBlock> i = blockIterator(); i.hasNext(); ) { BasicBlock basicBlock = i.next(); if (basicBlock.getLabel() == blockLabel) { return basicBlock; } } return null; }
/** * Get Collection of basic blocks whose IDs are specified by given BitSet. * * @param labelSet BitSet of block labels * @return a Collection containing the blocks whose IDs are given */ public Collection<BasicBlock> getBlocks(BitSet labelSet) { LinkedList<BasicBlock> result = new LinkedList<BasicBlock>(); for (Iterator<BasicBlock> i = blockIterator(); i.hasNext(); ) { BasicBlock block = i.next(); if (labelSet.get(block.getLabel())) { result.add(block); } } return result; }
public void checkIntegrity() { // Ensure that basic blocks have only consecutive instructions for (Iterator<BasicBlock> i = blockIterator(); i.hasNext(); ) { BasicBlock basicBlock = i.next(); InstructionHandle prev = null; for (Iterator<InstructionHandle> j = basicBlock.instructionIterator(); j.hasNext(); ) { InstructionHandle handle = j.next(); if (prev != null && prev.getNext() != handle) { throw new IllegalStateException( "Non-consecutive instructions in block " + basicBlock.getLabel() + ": prev=" + prev + ", handle=" + handle); } prev = handle; } } }
/** * Gets the register set associated with the start of the given block. This is just convenient * shorthand for <code>getStarts(block.getLabel())</code>. * * @param block non-null; the block in question * @return non-null; the associated register set */ public RegisterSpecSet getStarts(BasicBlock block) { return getStarts(block.getLabel()); }