LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

llvm::LoopBase< BlockT > Class Template Reference

#include <LoopInfo.h>

Inheritance diagram for llvm::LoopBase< BlockT >:

Inheritance graph
[legend]
Collaboration diagram for llvm::LoopBase< BlockT >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< LoopBase<
BlockT > * >::const_iterator 
iterator
typedef std::vector< BlockT
* >::const_iterator 
block_iterator

Public Member Functions

 LoopBase ()
 Loop ctor - This creates an empty loop.
 ~LoopBase ()
unsigned getLoopDepth () const
BlockT * getHeader () const
LoopBase< BlockT > * getParentLoop () const
bool contains (const BlockT *BB) const
const std::vector< LoopBase<
BlockT > * > & 
getSubLoops () const
iterator begin () const
iterator end () const
bool empty () const
const std::vector< BlockT * > & getBlocks () const
block_iterator block_begin () const
block_iterator block_end () const
bool isLoopExit (const BlockT *BB) const
unsigned getNumBackEdges () const
bool isLoopInvariant (Value *V) const
void getExitingBlocks (SmallVectorImpl< BlockT * > &ExitingBlocks) const
void getExitBlocks (SmallVectorImpl< BlockT * > &ExitBlocks) const
void getUniqueExitBlocks (SmallVectorImpl< BlockT * > &ExitBlocks) const
BlockT * getLoopPreheader () const
BlockT * getLoopLatch () const
PHINodegetCanonicalInductionVariable () const
InstructiongetCanonicalInductionVariableIncrement () const
ValuegetTripCount () const
unsigned getSmallConstantTripCount () const
unsigned getSmallConstantTripMultiple () const
bool isLCSSAForm () const
 isLCSSAForm - Return true if the Loop is in LCSSA form
void addBasicBlockToLoop (BlockT *NewBB, LoopInfoBase< BlockT > &LI)
void replaceChildLoopWith (LoopBase< BlockT > *OldChild, LoopBase< BlockT > *NewChild)
void addChildLoop (LoopBase< BlockT > *NewChild)
LoopBase< BlockT > * removeChildLoop (iterator I)
void addBlockEntry (BlockT *BB)
void moveToHeader (BlockT *BB)
void removeBlockFromLoop (BlockT *BB)
void verifyLoop () const
 verifyLoop - Verify loop structure
void print (std::ostream &OS, unsigned Depth=0) const
void print (std::ostream *O, unsigned Depth=0) const
void dump () const

Friends

class LoopInfoBase<BlockT>

Detailed Description

template<class BlockT>
class llvm::LoopBase< BlockT >

LoopBase class - Instances of this class are used to represent loops that are detected in the flow graph

Definition at line 69 of file LoopInfo.h.


Member Typedef Documentation

template<class BlockT>
typedef std::vector<BlockT*>::const_iterator llvm::LoopBase< BlockT >::block_iterator
 

Definition at line 117 of file LoopInfo.h.

template<class BlockT>
typedef std::vector<LoopBase<BlockT>*>::const_iterator llvm::LoopBase< BlockT >::iterator
 

Definition at line 109 of file LoopInfo.h.


Constructor & Destructor Documentation

template<class BlockT>
llvm::LoopBase< BlockT >::LoopBase  )  [inline]
 

Loop ctor - This creates an empty loop.

Definition at line 81 of file LoopInfo.h.

template<class BlockT>
llvm::LoopBase< BlockT >::~LoopBase  )  [inline]
 

Definition at line 82 of file LoopInfo.h.


Member Function Documentation

template<class BlockT>
void llvm::LoopBase< BlockT >::addBasicBlockToLoop BlockT *  NewBB,
LoopInfoBase< BlockT > &  LI
 

addBasicBlockToLoop - This method is used by other analyses to update loop information. NewBB is set to be a new member of the current loop. Because of this, it is added as a member of all parent loops, and is added to the specified LoopInfo object as being in the current basic block. It is not valid to replace the loop header with this method.

Definition at line 1049 of file LoopInfo.h.

References llvm::LoopInfoBase< BlockT >::BBMap, llvm::LoopBase< BlockT >::Blocks, llvm::LoopBase< BlockT >::getHeader(), and llvm::LoopBase< BlockT >::getParentLoop().

Referenced by CloneLoop(), llvm::CloneLoop(), LoopRotate::preserveCanonicalLoopForm(), llvm::SplitBlock(), llvm::SplitCriticalEdge(), and llvm::UnrollLoop().

template<class BlockT>
void llvm::LoopBase< BlockT >::addBlockEntry BlockT *  BB  )  [inline]
 

addBlockEntry - This adds a basic block directly to the basic block list. This should only be used by transformations that create new loops. Other transformations should use addBasicBlockToLoop.

Definition at line 553 of file LoopInfo.h.

template<class BlockT>
void llvm::LoopBase< BlockT >::addChildLoop LoopBase< BlockT > *  NewChild  )  [inline]
 

addChildLoop - Add the specified loop to be a child of this loop. This updates the loop depth of the new child.

Definition at line 532 of file LoopInfo.h.

Referenced by llvm::LPPassManager::deleteLoopFromQueue(), and llvm::LPPassManager::insertLoop().

template<class BlockT>
iterator llvm::LoopBase< BlockT >::begin  )  const [inline]
 

Definition at line 110 of file LoopInfo.h.

Referenced by addLoopIntoQueue(), llvm::LoopBase< MachineBasicBlock >::begin(), llvm::LoopBase< MachineBasicBlock >::block_begin(), llvm::GraphTraits< MachineLoop * >::child_begin(), llvm::GraphTraits< const MachineLoop * >::child_begin(), CloneLoop(), llvm::CloneLoop(), llvm::LPPassManager::deleteLoopFromQueue(), llvm::LoopInfo::empty(), llvm::LoopInfoBase< MachineBasicBlock >::empty(), PrintLoopInfo(), LoopExtractor::runOnFunction(), LoopDeletion::runOnLoop(), and LICM::runOnLoop().

template<class BlockT>
block_iterator llvm::LoopBase< BlockT >::block_begin  )  const [inline]
 

Definition at line 118 of file LoopInfo.h.

Referenced by ApproximateLoopSize(), CloneLoop(), llvm::CloneLoop(), llvm::LPPassManager::deleteLoopFromQueue(), LoopDeletion::IsLoopDead(), LoopRotate::preserveCanonicalLoopForm(), LoopUnswitch::processCurrentLoop(), LoopDeletion::runOnLoop(), LICM::runOnLoop(), LCSSA::runOnLoop(), and IndVarSimplify::runOnLoop().

template<class BlockT>
block_iterator llvm::LoopBase< BlockT >::block_end  )  const [inline]
 

Definition at line 119 of file LoopInfo.h.

Referenced by ApproximateLoopSize(), CloneLoop(), llvm::CloneLoop(), llvm::LPPassManager::deleteLoopFromQueue(), LoopDeletion::IsLoopDead(), LoopRotate::preserveCanonicalLoopForm(), LoopUnswitch::processCurrentLoop(), LoopDeletion::runOnLoop(), LICM::runOnLoop(), LCSSA::runOnLoop(), and IndVarSimplify::runOnLoop().

template<class BlockT>
bool llvm::LoopBase< BlockT >::contains const BlockT *  BB  )  const [inline]
 

contains - Return true if the specified basic block is in this loop

Definition at line 102 of file LoopInfo.h.

Referenced by FindPHIToPartitionLoops(), getConstantEvolvingPHI(), ScalarEvolutionsImpl::getSCEVAtScope(), llvm::LoopInfoBase< MachineBasicBlock >::InsertLoopInto(), llvm::SCEVUnknown::isLoopInvariant(), llvm::SCEVAddRecExpr::isLoopInvariant(), LoopDeletion::IsLoopInvariantInst(), isTrivialLoopExitBlockHelper(), IVUseShouldUsePostIncValue(), BasedUser::RewriteInstructionToUseNewBase(), LoopRotate::rotateLoop(), llvm::SplitCriticalEdge(), llvm::UnrollLoop(), LoopRotate::usedOutsideOriginalHeader(), and llvm::SCEVExpander::visitAddRecExpr().

template<class BlockT>
void llvm::LoopBase< BlockT >::dump  )  const [inline]
 

Definition at line 608 of file LoopInfo.h.

Referenced by LoopStrengthReduce::runOnLoop().

template<class BlockT>
bool llvm::LoopBase< BlockT >::empty  )  const [inline]
 

Definition at line 112 of file LoopInfo.h.

Referenced by llvm::LPPassManager::deleteLoopFromQueue(), llvm::LoopBase< MachineBasicBlock >::empty(), and LoopIndexSplit::runOnLoop().

template<class BlockT>
iterator llvm::LoopBase< BlockT >::end  )  const [inline]
 

Definition at line 111 of file LoopInfo.h.

Referenced by addLoopIntoQueue(), llvm::LoopBase< MachineBasicBlock >::block_end(), llvm::GraphTraits< MachineLoop * >::child_end(), llvm::GraphTraits< const MachineLoop * >::child_end(), CloneLoop(), llvm::CloneLoop(), llvm::LoopBase< MachineBasicBlock >::contains(), llvm::LPPassManager::deleteLoopFromQueue(), llvm::LoopBase< MachineBasicBlock >::end(), llvm::LoopInfoBase< MachineBasicBlock >::getLoopFor(), PrintLoopInfo(), LoopExtractor::runOnFunction(), LoopDeletion::runOnLoop(), and LICM::runOnLoop().

template<class BlockT>
const std::vector<BlockT*>& llvm::LoopBase< BlockT >::getBlocks  )  const [inline]
 

getBlocks - Get a list of the basic blocks which make up this loop.

Definition at line 116 of file LoopInfo.h.

Referenced by llvm::LPPassManager::deleteLoopFromQueue(), llvm::ExtractLoop(), MSILWriter::printLoop(), LoopRotate::rotateLoop(), and llvm::UnrollLoop().

template<class BlockT>
PHINode* llvm::LoopBase< BlockT >::getCanonicalInductionVariable  )  const [inline]
 

getCanonicalInductionVariable - Check to see if the loop has a canonical induction variable: an integer recurrence that starts at 0 and increments by one each time through the loop. If so, return the phi node that corresponds to it.

Definition at line 339 of file LoopInfo.h.

template<class BlockT>
Instruction* llvm::LoopBase< BlockT >::getCanonicalInductionVariableIncrement  )  const [inline]
 

getCanonicalInductionVariableIncrement - Return the LLVM value that holds the canonical induction variable value for the "next" iteration of the loop. This always succeeds if getCanonicalInductionVariable succeeds.

Definition at line 381 of file LoopInfo.h.

template<class BlockT>
void llvm::LoopBase< BlockT >::getExitBlocks SmallVectorImpl< BlockT * > &  ExitBlocks  )  const [inline]
 

getExitBlocks - Return all of the successor blocks of this loop. These are the blocks _outside of the current loop_ which are branched to.

Definition at line 193 of file LoopInfo.h.

Referenced by PrintLoopInfo(), LoopRotate::rotateLoop(), LoopExtractor::runOnFunction(), and LCSSA::runOnLoop().

template<class BlockT>
void llvm::LoopBase< BlockT >::getExitingBlocks SmallVectorImpl< BlockT * > &  ExitingBlocks  )  const [inline]
 

getExitingBlocks - Return all blocks inside the loop that have successors outside of the loop. These are the blocks _inside of the current loop_ which branch out. The returned list is always unique.

Definition at line 171 of file LoopInfo.h.

Referenced by LoopDeletion::runOnLoop().

template<class BlockT>
BlockT* llvm::LoopBase< BlockT >::getHeader  )  const [inline]
 

Definition at line 97 of file LoopInfo.h.

Referenced by llvm::LoopBase< BlockT >::addBasicBlockToLoop(), ApproximateLoopSize(), llvm::CloneLoop(), IndVarSimplify::doInitialization(), FindPHIToPartitionLoops(), getConstantEvolvingPHI(), ScalarEvolutionsImpl::getSCEVAtScope(), getSCEVStartAndStride(), llvm::LoopInfoBase< MachineBasicBlock >::InsertLoopInto(), llvm::LoopInfoBase< MachineBasicBlock >::isLoopHeader(), llvm::SCEVAddRecExpr::isLoopInvariant(), isTrivialLoopExitBlock(), LoopRotate::preserveCanonicalLoopForm(), llvm::SCEVAddRecExpr::print(), MSILWriter::printFunctionBody(), MSILWriter::printLoop(), PrintLoopInfo(), BasedUser::RewriteInstructionToUseNewBase(), LoopRotate::rotateLoop(), LoopSimplify::runOnFunction(), LoopExtractor::runOnFunction(), LoopUnswitch::runOnLoop(), LoopUnroll::runOnLoop(), LoopStrengthReduce::runOnLoop(), LoopDeletion::runOnLoop(), LICM::runOnLoop(), IndVarSimplify::runOnLoop(), llvm::SplitCriticalEdge(), llvm::UnrollLoop(), and llvm::SCEVExpander::visitAddRecExpr().

template<class BlockT>
unsigned llvm::LoopBase< BlockT >::getLoopDepth  )  const [inline]
 

getLoopDepth - Return the nesting level of this loop. An outer-most loop has depth 1, for consistency with loop depth values used for basic blocks, where depth 0 is used for blocks not inside any loops.

Definition at line 90 of file LoopInfo.h.

Referenced by llvm::ScalarEvolution::getAddRecExpr(), llvm::LoopInfo::getLoopDepth(), llvm::LoopInfoBase< MachineBasicBlock >::getLoopDepth(), and llvm::LoopInfoBase< MachineBasicBlock >::print().

template<class BlockT>
BlockT* llvm::LoopBase< BlockT >::getLoopLatch  )  const [inline]
 

getLoopLatch - If there is a latch block for this loop, return it. A latch block is the canonical backedge for a loop. A loop header in normal form has two edges into it: one from a preheader and one from a latch block.

Definition at line 309 of file LoopInfo.h.

Referenced by llvm::CloneLoop(), IVUseShouldUsePostIncValue(), LoopRotate::preserveCanonicalLoopForm(), LoopRotate::rotateLoop(), LoopDeletion::SingleDominatingExit(), and llvm::UnrollLoop().

template<class BlockT>
BlockT* llvm::LoopBase< BlockT >::getLoopPreheader  )  const [inline]
 

getLoopPreheader - If there is a preheader for this loop, return it. A loop has a preheader if there is only one edge to the header of the loop from outside of the loop. If this is the case, the block branching to the header of the loop is the preheader node.

This method returns null if there is no preheader for the loop.

Definition at line 276 of file LoopInfo.h.

Referenced by IndVarSimplify::doInitialization(), BasedUser::InsertCodeForBaseAtPosition(), LoopRotate::preserveCanonicalLoopForm(), LoopRotate::rotateLoop(), LoopDeletion::runOnLoop(), LICM::runOnLoop(), llvm::UnrollLoop(), and llvm::SCEVExpander::visitAddRecExpr().

template<class BlockT>
unsigned llvm::LoopBase< BlockT >::getNumBackEdges  )  const [inline]
 

getNumBackEdges - Calculate the number of back edges to the loop header

Definition at line 137 of file LoopInfo.h.

template<class BlockT>
LoopBase<BlockT>* llvm::LoopBase< BlockT >::getParentLoop  )  const [inline]
 

Definition at line 98 of file LoopInfo.h.

Referenced by llvm::LoopBase< BlockT >::addBasicBlockToLoop(), llvm::LoopInfoBase< MachineBasicBlock >::addTopLevelLoop(), llvm::CloneLoop(), llvm::LPPassManager::deleteLoopFromQueue(), ScalarEvolutionsImpl::getSCEVAtScope(), BasedUser::InsertCodeForBaseAtPosition(), llvm::LoopInfoBase< MachineBasicBlock >::isNotAlreadyContainedIn(), llvm::LoopInfoBase< MachineBasicBlock >::MoveSiblingLoopInto(), llvm::ScalarEvolution::print(), MSILWriter::printFunctionBody(), MSILWriter::printLoop(), llvm::LoopInfoBase< MachineBasicBlock >::removeBlock(), llvm::LoopInfoBase< MachineBasicBlock >::removeLoop(), LoopSimplify::runOnFunction(), llvm::SplitCriticalEdge(), and llvm::SCEVExpander::visitAddRecExpr().

template<class BlockT>
unsigned llvm::LoopBase< BlockT >::getSmallConstantTripCount  )  const [inline]
 

getSmallConstantTripCount - Returns the trip count of this loop as a normal unsigned value, if possible. Returns 0 if the trip count is unknown of not constant. Will also return 0 if the trip count is very large (>= 2^32)

Definition at line 425 of file LoopInfo.h.

Referenced by LoopUnroll::runOnLoop(), and llvm::UnrollLoop().

template<class BlockT>
unsigned llvm::LoopBase< BlockT >::getSmallConstantTripMultiple  )  const [inline]
 

getSmallConstantTripMultiple - Returns the largest constant divisor of the trip count of this loop as a normal unsigned value, if possible. This means that the actual trip count is always a multiple of the returned value (don't forget the trip count could very well be zero as well!).

Returns 1 if the trip count is unknown or not guaranteed to be the multiple of a constant (which is also the case if the trip count is simply constant, use getSmallConstantTripCount for that case), Will also return 1 if the trip count is very large (>= 2^32).

Definition at line 447 of file LoopInfo.h.

Referenced by llvm::UnrollLoop().

template<class BlockT>
const std::vector<LoopBase<BlockT>*>& llvm::LoopBase< BlockT >::getSubLoops  )  const [inline]
 

iterator/begin/end - Return the loops contained entirely within this loop.

Definition at line 108 of file LoopInfo.h.

Referenced by LoopIndexSplit::runOnLoop().

template<class BlockT>
Value* llvm::LoopBase< BlockT >::getTripCount  )  const [inline]
 

getTripCount - Return a loop-invariant LLVM value indicating the number of times the loop will be executed. Note that this means that the backedge of the loop executes N-1 times. If the trip-count cannot be determined, this returns null.

Definition at line 394 of file LoopInfo.h.

template<class BlockT>
void llvm::LoopBase< BlockT >::getUniqueExitBlocks SmallVectorImpl< BlockT * > &  ExitBlocks  )  const [inline]
 

getUniqueExitBlocks - Return all unique successor blocks of this loop. These are the blocks _outside of the current loop_ which are branched to. This assumes that loop is in canonical form.

Definition at line 214 of file LoopInfo.h.

Referenced by LoopDeletion::runOnLoop().

template<class BlockT>
bool llvm::LoopBase< BlockT >::isLCSSAForm  )  const [inline]
 

isLCSSAForm - Return true if the Loop is in LCSSA form

Definition at line 475 of file LoopInfo.h.

Referenced by LoopUnswitch::runOnLoop(), LoopUnroll::runOnLoop(), LCSSA::runOnLoop(), IndVarSimplify::runOnLoop(), and llvm::UnrollLoop().

template<class BlockT>
bool llvm::LoopBase< BlockT >::isLoopExit const BlockT *  BB  )  const [inline]
 

isLoopExit - True if terminator in the block can branch to another block that is outside of the current loop.

Definition at line 124 of file LoopInfo.h.

Referenced by LoopRotate::rotateLoop().

template<class BlockT>
bool llvm::LoopBase< BlockT >::isLoopInvariant Value V  )  const [inline]
 

isLoopInvariant - Return true if the specified value is loop invariant

Definition at line 153 of file LoopInfo.h.

Referenced by FindLIVLoopCondition(), LoopDeletion::IsLoopInvariantInst(), and llvm::SCEVExpander::visitAddRecExpr().

template<class BlockT>
void llvm::LoopBase< BlockT >::moveToHeader BlockT *  BB  )  [inline]
 

moveToHeader - This method is used to move BB (which must be part of this loop) to be the loop header of the loop (the block that dominates all others).

Definition at line 560 of file LoopInfo.h.

Referenced by LoopRotate::rotateLoop().

template<class BlockT>
void llvm::LoopBase< BlockT >::print std::ostream *  O,
unsigned  Depth = 0
const [inline]
 

Definition at line 604 of file LoopInfo.h.

template<class BlockT>
void llvm::LoopBase< BlockT >::print std::ostream &  OS,
unsigned  Depth = 0
const [inline]
 

Definition at line 591 of file LoopInfo.h.

Referenced by llvm::LoopInfoBase< MachineBasicBlock >::print(), and llvm::LoopBase< MachineBasicBlock >::print().

template<class BlockT>
void llvm::LoopBase< BlockT >::removeBlockFromLoop BlockT *  BB  )  [inline]
 

removeBlockFromLoop - This removes the specified basic block from the current loop, updating the Blocks as appropriate. This does not update the mapping in the LoopInfo class.

Definition at line 575 of file LoopInfo.h.

Referenced by llvm::LoopInfoBase< MachineBasicBlock >::removeBlock().

template<class BlockT>
LoopBase<BlockT>* llvm::LoopBase< BlockT >::removeChildLoop iterator  I  )  [inline]
 

removeChildLoop - This removes the specified child from being a subloop of this loop. The loop is not deleted, as it will presumably be inserted into another loop.

Definition at line 541 of file LoopInfo.h.

Referenced by llvm::LPPassManager::deleteLoopFromQueue().

template<class BlockT>
void llvm::LoopBase< BlockT >::replaceChildLoopWith LoopBase< BlockT > *  OldChild,
LoopBase< BlockT > *  NewChild
[inline]
 

replaceChildLoopWith - This is used when splitting loops up. It replaces the OldChild entry in our children list with NewChild, and updates the parent pointer of OldChild to be null and the NewChild to be this loop. This updates the loop depth of the new child.

Definition at line 517 of file LoopInfo.h.

template<class BlockT>
void llvm::LoopBase< BlockT >::verifyLoop  )  const [inline]
 

verifyLoop - Verify loop structure

Definition at line 580 of file LoopInfo.h.

Referenced by llvm::LoopBase< MachineBasicBlock >::verifyLoop().


Friends And Related Function Documentation

template<class BlockT>
friend class LoopInfoBase<BlockT> [friend]
 

Definition at line 613 of file LoopInfo.h.


The documentation for this class was generated from the following file:


This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.