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::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
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
PHINodegetCanonicalInductionVariable () const
InstructiongetCanonicalInductionVariableIncrement () const
ValuegetTripCount () const
void addBasicBlockToLoop (BasicBlock *NewBB, LoopInfo &LI)
void replaceChildLoopWith (Loop *OldChild, Loop *NewChild)
void addChildLoop (Loop *NewChild)
LoopremoveChildLoop (iterator OldChild)
void addBlockEntry (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<BasicBlock*>::const_iterator llvm::Loop::block_iterator
 

Definition at line 84 of file LoopInfo.h.

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

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

Definition at line 77 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

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

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

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

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

References ParentLoop.

Referenced by CloneLoop().

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

Definition at line 78 of file LoopInfo.h.

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

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

Definition at line 85 of file LoopInfo.h.

Referenced by CloneLoop().

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

Definition at line 86 of file LoopInfo.h.

Referenced by CloneLoop().

bool Loop::contains const BasicBlock BB  )  const
 

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

Definition at line 35 of file LoopInfo.cpp.

Referenced by FindPHIToPartitionLoops(), getCanonicalInductionVariable(), getCanonicalInductionVariableIncrement(), getConstantEvolvingPHI(), getExitBlocks(), getLoopPreheader(), getNumBackEdges(), getTripCount(), InsertPHINodesForUsesOutsideLoop(), isLoopExit(), llvm::SCEVUnknown::isLoopInvariant(), llvm::SCEVAddRecExpr::isLoopInvariant(), and isLoopInvariant().

void Loop::dump  )  const
 

Definition at line 82 of file LoopInfo.cpp.

References print().

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

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

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

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

References Add(), llvm::BasicBlock::begin(), contains(), getHeader(), llvm::PHINode::getIncomingValueForBlock(), llvm::Constant::getOperand(), H, 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 423 of file LoopInfo.cpp.

References contains(), and getCanonicalInductionVariable().

Referenced by getTripCount().

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

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

Referenced by PrintLoopInfo().

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

Definition at line 68 of file LoopInfo.h.

Referenced by addBasicBlockToLoop(), ApproximateLoopSize(), FindPHIToPartitionLoops(), getCanonicalInductionVariable(), getConstantEvolvingPHI(), getLoopPreheader(), getNumBackEdges(), getTripCount(), llvm::LoopInfo::isLoopHeader(), llvm::SCEVAddRecExpr::isLoopInvariant(), llvm::SCEVAddRecExpr::print(), and PrintLoopInfo().

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

Definition at line 62 of file LoopInfo.h.

References D.

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

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

References contains(), getHeader(), Out, llvm::pred_begin(), llvm::pred_end(), 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 50 of file LoopInfo.cpp.

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

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(), and llvm::LoopInfo::removeLoop().

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

References contains(), getCanonicalInductionVariableIncrement(), getHeader(), llvm::PHINode::getIncomingBlock(), llvm::User::getOperand(), llvm::BasicBlock::getTerminator(), llvm::ISD::SetEQ, and llvm::ISD::SetNE.

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

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

bool Loop::isLoopInvariant Value V  )  const
 

isLoopInvariant - Return true if the specified value is loop invariant

Definition at line 63 of file LoopInfo.cpp.

References contains(), and I.

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

Definition at line 69 of file LoopInfo.cpp.

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

Referenced by dump().

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

References RemoveFromVector().

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

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

References begin(), and ParentLoop.

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

References ParentLoop.


Friends And Related Function Documentation

friend class LoopInfo [friend]
 

Definition at line 186 of file LoopInfo.h.


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