LLVM API Documentation

llvm::LoopBase< BlockT > Class Template Reference

#include <LoopInfo.h>

Collaboration diagram for llvm::LoopBase< BlockT >:
[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
PHINode * getCanonicalInductionVariable () const
Instruction * getCanonicalInductionVariableIncrement () const
Value * getTripCount () 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
template<>
PHINode * getCanonicalInductionVariable () const
template<>
Instruction * getCanonicalInductionVariableIncrement () const
template<>
bool isLoopInvariant (Value *V) const
template<>
Value * getTripCount () const
template<>
bool isLCSSAForm () 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 67 of file LoopInfo.h.


Member Typedef Documentation

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

Definition at line 107 of file LoopInfo.h.

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

Definition at line 115 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 79 of file LoopInfo.h.

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

Definition at line 80 of file LoopInfo.h.


Member Function Documentation

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 88 of file LoopInfo.h.

References CurLoop, and llvm::LoopBase< BlockT >::ParentLoop.

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

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

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

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

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 106 of file LoopInfo.h.

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

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

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

Definition at line 110 of file LoopInfo.h.

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

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 114 of file LoopInfo.h.

Referenced by llvm::LPPassManager::deleteLoopFromQueue(), llvm::ExtractLoop(), llvm::LoopBase< BlockT >::print(), and llvm::UnrollLoop().

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

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

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 122 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::contains(), and SE.

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

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

Definition at line 135 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::contains(), E, llvm::LoopBase< BlockT >::getHeader(), and H.

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 151 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::contains().

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

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 169 of file LoopInfo.h.

References llvm::SmallVectorImpl< T >::begin(), llvm::LoopBase< BlockT >::block_begin(), llvm::LoopBase< BlockT >::block_end(), E, llvm::SmallVectorImpl< T >::end(), and llvm::SmallVectorImpl< T >::push_back().

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 191 of file LoopInfo.h.

References llvm::SmallVectorImpl< T >::begin(), llvm::LoopBase< BlockT >::block_begin(), llvm::LoopBase< BlockT >::block_end(), E, llvm::SmallVectorImpl< T >::end(), and llvm::SmallVectorImpl< T >::push_back().

Referenced by PrintLoopInfo().

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 212 of file LoopInfo.h.

References llvm::SmallVectorImpl< T >::begin(), llvm::LoopBase< BlockT >::block_begin(), llvm::LoopBase< BlockT >::block_end(), E, llvm::SmallVectorImpl< T >::end(), PI, and llvm::SmallVectorImpl< T >::push_back().

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 274 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::contains(), llvm::LoopBase< BlockT >::getHeader(), Header, Out, and PI.

Referenced by getSCEVStartAndStride(), LoopIsOuterMostWithPreheader(), llvm::UnrollLoop(), llvm::LoopBase< BlockT >::verifyLoop(), and llvm::SCEVExpander::visitAddRecExpr().

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 307 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::contains(), llvm::LoopBase< BlockT >::getHeader(), Header, and PI.

Referenced by llvm::CloneLoop(), IVUseShouldUsePostIncValue(), llvm::UnrollLoop(), and llvm::LoopBase< BlockT >::verifyLoop().

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 337 of file LoopInfo.h.

References Add(), llvm::LoopBase< BlockT >::contains(), llvm::LoopBase< BlockT >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::Constant::getOperand(), H, PI, and std::swap().

Referenced by llvm::LoopBase< BlockT >::getCanonicalInductionVariableIncrement().

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 379 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::contains(), and llvm::LoopBase< BlockT >::getCanonicalInductionVariable().

Referenced by llvm::LoopBase< BlockT >::getTripCount().

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 392 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::contains(), llvm::LoopBase< BlockT >::getCanonicalInductionVariableIncrement(), llvm::LoopBase< BlockT >::getHeader(), llvm::PHINode::getIncomingBlock(), llvm::User::getOperand(), llvm::CmpInst::ICMP_EQ, and llvm::CmpInst::ICMP_NE.

Referenced by llvm::LoopBase< BlockT >::getSmallConstantTripCount(), and llvm::LoopBase< BlockT >::getSmallConstantTripMultiple().

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 423 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::getTripCount().

Referenced by 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 445 of file LoopInfo.h.

References llvm::dyn_cast(), llvm::APInt::getActiveBits(), llvm::LoopBase< BlockT >::getTripCount(), llvm::ConstantInt::getValue(), and llvm::ConstantInt::getZExtValue().

Referenced by llvm::UnrollLoop().

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

template<class BlockT>
void llvm::LoopBase< BlockT >::addBasicBlockToLoop ( BlockT *  NewBB,
LoopInfoBase< BlockT > &  LI 
) [inline]

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 1048 of file LoopInfo.h.

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

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

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 514 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::ParentLoop.

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 529 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::ParentLoop.

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

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 538 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::begin().

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

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 550 of file LoopInfo.h.

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 557 of file LoopInfo.h.

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 572 of file LoopInfo.h.

References llvm::RemoveFromVector().

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

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

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

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

Definition at line 601 of file LoopInfo.h.

References llvm::LoopBase< BlockT >::print().

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

Definition at line 605 of file LoopInfo.h.

References llvm::cerr(), and llvm::LoopBase< BlockT >::print().

template<>
PHINode * llvm::LoopBase< MachineBasicBlock >::getCanonicalInductionVariable (  )  const [inline]

Definition at line 40 of file MachineLoopInfo.h.

template<>
Instruction * llvm::LoopBase< MachineBasicBlock >::getCanonicalInductionVariableIncrement (  )  const [inline]

Definition at line 46 of file MachineLoopInfo.h.

template<>
bool llvm::LoopBase< MachineBasicBlock >::isLoopInvariant ( Value *  V  )  const [inline]

Definition at line 53 of file MachineLoopInfo.h.

template<>
Value * llvm::LoopBase< MachineBasicBlock >::getTripCount (  )  const [inline]

Definition at line 59 of file MachineLoopInfo.h.

template<>
bool llvm::LoopBase< MachineBasicBlock >::isLCSSAForm (  )  const [inline]

Definition at line 65 of file MachineLoopInfo.h.


Friends And Related Function Documentation

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

Definition at line 610 of file LoopInfo.h.


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