LLVM API Documentation

llvm::Loop Class Reference

#include <LoopInfo.h>

Collaboration diagram for llvm::Loop:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< Loop
* >::const_iterator 
iterator
typedef std::vector< BasicBlock
* >::const_iterator 
block_iterator

Public Member Functions

 Loop ()
 Loop ctor - This creates an empty loop.
 ~Loop ()
unsigned getLoopDepth () const
BasicBlockgetHeader () const
LoopgetParentLoop () const
bool contains (const BasicBlock *BB) const
const std::vector< Loop * > & getSubLoops () const
iterator begin () const
iterator end () const
const std::vector< BasicBlock * > & getBlocks () const
block_iterator block_begin () const
block_iterator block_end () const
bool isLoopExit (const BasicBlock *BB) const
unsigned getNumBackEdges () const
bool isLoopInvariant (Value *V) const
void getExitBlocks (std::vector< BasicBlock * > &Blocks) const
BasicBlockgetLoopPreheader () const
BasicBlockgetLoopLatch () const
PHINodegetCanonicalInductionVariable () const
InstructiongetCanonicalInductionVariableIncrement () const
ValuegetTripCount () const
bool isLCSSAForm () const
 isLCSSAForm - Return true if the Loop is in LCSSA form
void addBasicBlockToLoop (BasicBlock *NewBB, LoopInfo &LI)
void replaceChildLoopWith (Loop *OldChild, Loop *NewChild)
void addChildLoop (Loop *NewChild)
LoopremoveChildLoop (iterator OldChild)
void addBlockEntry (BasicBlock *BB)
void moveToHeader (BasicBlock *BB)
void removeBlockFromLoop (BasicBlock *BB)
void print (std::ostream &O, unsigned Depth=0) const
void dump () const

Friends

class LoopInfo

Detailed Description

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

Definition at line 47 of file LoopInfo.h.


Member Typedef Documentation

typedef std::vector<Loop*>::const_iterator llvm::Loop::iterator

Definition at line 78 of file LoopInfo.h.

typedef std::vector<BasicBlock*>::const_iterator llvm::Loop::block_iterator

Definition at line 85 of file LoopInfo.h.


Constructor & Destructor Documentation

llvm::Loop::Loop (  )  [inline]

Loop ctor - This creates an empty loop.

Definition at line 56 of file LoopInfo.h.

llvm::Loop::~Loop (  )  [inline]

Definition at line 57 of file LoopInfo.h.


Member Function Documentation

unsigned llvm::Loop::getLoopDepth (  )  const [inline]

Definition at line 62 of file LoopInfo.h.

References CurLoop, D, and ParentLoop.

Referenced by llvm::LoopInfo::getLoopDepth().

BasicBlock* llvm::Loop::getHeader (  )  const [inline]

Definition at line 68 of file LoopInfo.h.

Referenced by addBasicBlockToLoop(), ApproximateLoopSize(), FindPHIToPartitionLoops(), getCanonicalInductionVariable(), getConstantEvolvingPHI(), getLoopLatch(), getLoopPreheader(), getNumBackEdges(), getSCEVStartAndStride(), getTripCount(), llvm::LoopInfo::isLoopHeader(), llvm::SCEVAddRecExpr::isLoopInvariant(), isTrivialLoopExitBlock(), IsTrivialUnswitchCondition(), llvm::SCEVAddRecExpr::print(), PrintLoopInfo(), and llvm::SCEVExpander::visitAddRecExpr().

Loop* llvm::Loop::getParentLoop (  )  const [inline]

Definition at line 69 of file LoopInfo.h.

Referenced by addBasicBlockToLoop(), llvm::LoopInfo::addTopLevelLoop(), isNotAlreadyContainedIn(), llvm::ScalarEvolution::print(), llvm::LoopInfo::removeBlock(), llvm::LoopInfo::removeLoop(), and llvm::SCEVExpander::visitAddRecExpr().

bool Loop::contains ( const BasicBlock BB  )  const

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

Definition at line 34 of file LoopInfo.cpp.

References BB.

Referenced by FindPHIToPartitionLoops(), getCanonicalInductionVariable(), getCanonicalInductionVariableIncrement(), getConstantEvolvingPHI(), getExitBlocks(), getLoopLatch(), getLoopPreheader(), getNumBackEdges(), getTripCount(), isLCSSAForm(), isLoopExit(), llvm::SCEVUnknown::isLoopInvariant(), llvm::SCEVAddRecExpr::isLoopInvariant(), isLoopInvariant(), isTrivialLoopExitBlockHelper(), IVUseShouldUsePostIncValue(), and llvm::SCEVExpander::visitAddRecExpr().

const std::vector<Loop*>& llvm::Loop::getSubLoops (  )  const [inline]

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

Definition at line 77 of file LoopInfo.h.

iterator llvm::Loop::begin (  )  const [inline]

Definition at line 79 of file LoopInfo.h.

Referenced by llvm::GraphTraits< Loop * >::child_begin(), llvm::GraphTraits< const Loop * >::child_begin(), CloneLoop(), print(), PrintLoopInfo(), and removeChildLoop().

iterator llvm::Loop::end (  )  const [inline]

Definition at line 80 of file LoopInfo.h.

Referenced by llvm::GraphTraits< Loop * >::child_end(), llvm::GraphTraits< const Loop * >::child_end(), CloneLoop(), print(), and PrintLoopInfo().

const std::vector<BasicBlock*>& llvm::Loop::getBlocks (  )  const [inline]

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

Definition at line 84 of file LoopInfo.h.

Referenced by ApproximateLoopSize(), llvm::ExtractLoop(), and print().

block_iterator llvm::Loop::block_begin (  )  const [inline]

Definition at line 86 of file LoopInfo.h.

Referenced by CloneLoop(), and isLCSSAForm().

block_iterator llvm::Loop::block_end (  )  const [inline]

Definition at line 87 of file LoopInfo.h.

Referenced by CloneLoop(), and isLCSSAForm().

bool Loop::isLoopExit ( const BasicBlock BB  )  const

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

Definition at line 38 of file LoopInfo.cpp.

References BB, contains(), SE, llvm::succ_begin(), and llvm::succ_end().

unsigned Loop::getNumBackEdges (  )  const

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

Definition at line 49 of file LoopInfo.cpp.

References contains(), E, getHeader(), H, NumBackEdges, llvm::pred_begin(), and llvm::pred_end().

bool Loop::isLoopInvariant ( Value V  )  const

isLoopInvariant - Return true if the specified value is loop invariant

Definition at line 62 of file LoopInfo.cpp.

References contains(), and V.

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

void Loop::getExitBlocks ( std::vector< BasicBlock * > &  Blocks  )  const

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 338 of file LoopInfo.cpp.

References contains(), E, llvm::succ_begin(), and llvm::succ_end().

Referenced by PrintLoopInfo().

BasicBlock * Loop::getLoopPreheader (  )  const

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 354 of file LoopInfo.cpp.

References contains(), getHeader(), Out, PI, llvm::pred_begin(), llvm::pred_end(), llvm::succ_begin(), and llvm::succ_end().

Referenced by llvm::SCEVExpander::visitAddRecExpr().

BasicBlock * Loop::getLoopLatch (  )  const

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 384 of file LoopInfo.cpp.

References contains(), getHeader(), PI, llvm::pred_begin(), and llvm::pred_end().

Referenced by IVUseShouldUsePostIncValue().

PHINode * Loop::getCanonicalInductionVariable (  )  const

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 410 of file LoopInfo.cpp.

References contains(), getHeader(), H, PI, llvm::pred_begin(), and llvm::pred_end().

Referenced by getCanonicalInductionVariableIncrement().

Instruction * Loop::getCanonicalInductionVariableIncrement (  )  const

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 445 of file LoopInfo.cpp.

References contains(), and getCanonicalInductionVariable().

Referenced by getTripCount().

Value * Loop::getTripCount (  )  const

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 458 of file LoopInfo.cpp.

References contains(), getCanonicalInductionVariableIncrement(), getHeader(), llvm::PHINode::getIncomingBlock(), and llvm::User::getOperand().

bool Loop::isLCSSAForm (  )  const

isLCSSAForm - Return true if the Loop is in LCSSA form

Definition at line 483 of file LoopInfo.cpp.

References block_begin(), block_end(), contains(), and E.

void Loop::addBasicBlockToLoop ( BasicBlock NewBB,
LoopInfo 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 514 of file LoopInfo.cpp.

References llvm::LoopInfo::BBMap, Blocks, getHeader(), getParentLoop(), and LI.

void Loop::replaceChildLoopWith ( Loop OldChild,
Loop NewChild 
)

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 534 of file LoopInfo.cpp.

References ParentLoop.

void Loop::addChildLoop ( Loop NewChild  ) 

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

Definition at line 547 of file LoopInfo.cpp.

References ParentLoop.

Referenced by CloneLoop().

Loop * Loop::removeChildLoop ( iterator  OldChild  ) 

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 563 of file LoopInfo.cpp.

References begin().

void llvm::Loop::addBlockEntry ( BasicBlock 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 184 of file LoopInfo.h.

References BB.

void llvm::Loop::moveToHeader ( BasicBlock 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 191 of file LoopInfo.h.

References BB.

void Loop::removeBlockFromLoop ( BasicBlock BB  ) 

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 576 of file LoopInfo.cpp.

References BB, and RemoveFromVector().

Referenced by llvm::LoopInfo::removeBlock().

void Loop::print ( std::ostream &  O,
unsigned  Depth = 0 
) const

Definition at line 68 of file LoopInfo.cpp.

References begin(), E, end(), getBlocks(), and llvm::WriteAsOperand().

Referenced by dump().

void Loop::dump (  )  const

Definition at line 81 of file LoopInfo.cpp.

References print().


Friends And Related Function Documentation

friend class LoopInfo [friend]

Definition at line 211 of file LoopInfo.h.


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