LLVM 19.0.0git
Public Member Functions | Friends | List of all members
llvm::MachineLoop Class Reference

#include "llvm/CodeGen/MachineLoopInfo.h"

Inheritance diagram for llvm::MachineLoop:
Inheritance graph
[legend]

Public Member Functions

MachineBasicBlockgetTopBlock ()
 Return the "top" block in the loop, which is the first block in the linear layout, ignoring any parts of the loop not contiguous with the part that contains the header.
 
MachineBasicBlockgetBottomBlock ()
 Return the "bottom" block in the loop, which is the last block in the linear layout, ignoring any parts of the loop not contiguous with the part that contains the header.
 
MachineBasicBlockfindLoopControlBlock () const
 Find the block that contains the loop control variable and the loop test.
 
DebugLoc getStartLoc () const
 Return the debug location of the start of this loop.
 
MDNodegetLoopID () const
 Find the llvm.loop metadata for this loop.
 
bool isLoopInvariant (MachineInstr &I, const Register ExcludeReg=0) const
 Returns true if the instruction is loop invariant.
 
void dump () const
 
- Public Member Functions inherited from llvm::LoopBase< MachineBasicBlock, MachineLoop >
unsigned getLoopDepth () const
 Return the nesting level of this loop.
 
MachineBasicBlockgetHeader () const
 
MachineLoopgetParentLoop () const
 Return the parent loop if it exists or nullptr for top level loops.
 
const MachineLoopgetOutermostLoop () const
 Get the outermost loop in which this loop is contained.
 
MachineLoopgetOutermostLoop ()
 
void setParentLoop (MachineLoop *L)
 This is a raw interface for bypassing addChildLoop.
 
bool contains (const MachineLoop *L) const
 Return true if the specified loop is contained within in this loop.
 
bool contains (const MachineBasicBlock *BB) const
 Return true if the specified basic block is in this loop.
 
bool contains (const InstT *Inst) const
 Return true if the specified instruction is in this loop.
 
const std::vector< MachineLoop * > & getSubLoops () const
 Return the loops contained entirely within this loop.
 
std::vector< MachineLoop * > & getSubLoopsVector ()
 
iterator begin () const
 
iterator end () const
 
reverse_iterator rbegin () const
 
reverse_iterator rend () const
 
bool isInnermost () const
 Return true if the loop does not contain any (natural) loops.
 
bool isOutermost () const
 Return true if the loop does not have a parent (natural) loop.
 
ArrayRef< MachineBasicBlock * > getBlocks () const
 Get a list of the basic blocks which make up this loop.
 
block_iterator block_begin () const
 
block_iterator block_end () const
 
iterator_range< block_iteratorblocks () const
 
unsigned getNumBlocks () const
 Get the number of blocks in this loop in constant time.
 
std::vector< MachineBasicBlock * > & getBlocksVector ()
 Return a direct, mutable handle to the blocks vector so that we can mutate it efficiently with techniques like std::remove.
 
SmallPtrSetImpl< const MachineBasicBlock * > & getBlocksSet ()
 Return a direct, mutable handle to the blocks set so that we can mutate it efficiently.
 
const SmallPtrSetImpl< const MachineBasicBlock * > & getBlocksSet () const
 Return a direct, immutable handle to the blocks set.
 
bool isInvalid () const
 Return true if this loop is no longer valid.
 
bool isLoopExiting (const MachineBasicBlock *BB) const
 True if terminator in the block can branch to another block that is outside of the current loop.
 
bool isLoopLatch (const MachineBasicBlock *BB) const
 
unsigned getNumBackEdges () const
 Calculate the number of back edges to the loop header.
 
void getExitingBlocks (SmallVectorImpl< MachineBasicBlock * > &ExitingBlocks) const
 Return all blocks inside the loop that have successors outside of the loop.
 
MachineBasicBlockgetExitingBlock () const
 If getExitingBlocks would return exactly one block, return that block.
 
void getExitBlocks (SmallVectorImpl< MachineBasicBlock * > &ExitBlocks) const
 Return all of the successor blocks of this loop.
 
MachineBasicBlockgetExitBlock () const
 If getExitBlocks would return exactly one block, return that block.
 
bool hasDedicatedExits () const
 Return true if no exit block for the loop has a predecessor that is outside the loop.
 
void getUniqueExitBlocks (SmallVectorImpl< MachineBasicBlock * > &ExitBlocks) const
 Return all unique successor blocks of this loop.
 
void getUniqueNonLatchExitBlocks (SmallVectorImpl< MachineBasicBlock * > &ExitBlocks) const
 Return all unique successor blocks of this loop except successors from Latch block are not considered.
 
MachineBasicBlockgetUniqueExitBlock () const
 If getUniqueExitBlocks would return exactly one block, return that block.
 
bool hasNoExitBlocks () const
 Return true if this loop does not have any exit blocks.
 
void getExitEdges (SmallVectorImpl< Edge > &ExitEdges) const
 Return all pairs of (inside_block,outside_block).
 
MachineBasicBlockgetLoopPreheader () const
 If there is a preheader for this loop, return it.
 
MachineBasicBlockgetLoopPredecessor () const
 If the given loop's header has exactly one unique predecessor outside the loop, return it.
 
MachineBasicBlockgetLoopLatch () const
 If there is a single latch block for this loop, return it.
 
void getLoopLatches (SmallVectorImpl< MachineBasicBlock * > &LoopLatches) const
 Return all loop latch blocks of this loop.
 
SmallVector< const MachineLoop *, 4 > getLoopsInPreorder () const
 Return all loops in the loop nest rooted by the loop in preorder, with siblings in forward program order.
 
SmallVector< MachineLoop *, 4 > getLoopsInPreorder ()
 
void addBasicBlockToLoop (MachineBasicBlock *NewBB, LoopInfoBase< MachineBasicBlock, MachineLoop > &LI)
 This method is used by other analyses to update loop information.
 
void replaceChildLoopWith (MachineLoop *OldChild, MachineLoop *NewChild)
 This is used when splitting loops up.
 
void addChildLoop (MachineLoop *NewChild)
 Add the specified loop to be a child of this loop.
 
MachineLoopremoveChildLoop (iterator I)
 This removes the specified child from being a subloop of this loop.
 
MachineLoopremoveChildLoop (MachineLoop *Child)
 This removes the specified child from being a subloop of this loop.
 
void addBlockEntry (MachineBasicBlock *BB)
 This adds a basic block directly to the basic block list.
 
void reverseBlock (unsigned from)
 interface to reverse Blocks[from, end of loop] in this loop
 
void reserveBlocks (unsigned size)
 interface to do reserve() for Blocks
 
void moveToHeader (MachineBasicBlock *BB)
 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).
 
void removeBlockFromLoop (MachineBasicBlock *BB)
 This removes the specified basic block from the current loop, updating the Blocks as appropriate.
 
void verifyLoop () const
 Verify loop structure.
 
void verifyLoopNest (DenseSet< const MachineLoop * > *Loops) const
 Verify loop structure of this loop and all nested loops.
 
bool isAnnotatedParallel () const
 Returns true if the loop is annotated parallel.
 
void print (raw_ostream &OS, bool Verbose=false, bool PrintNested=true, unsigned Depth=0) const
 Print loop with all the BBs inside it.
 

Friends

class LoopInfoBase< MachineBasicBlock, MachineLoop >
 

Additional Inherited Members

- Public Types inherited from llvm::LoopBase< MachineBasicBlock, MachineLoop >
typedef std::vector< MachineLoop * >::const_iterator iterator
 
typedef std::vector< MachineLoop * >::const_reverse_iterator reverse_iterator
 
typedef ArrayRef< MachineBasicBlock * >::const_iterator block_iterator
 
typedef std::pair< MachineBasicBlock *, MachineBasicBlock * > Edge
 Edge type.
 
- Static Public Member Functions inherited from llvm::LoopBase< MachineBasicBlock, MachineLoop >
static void getInnerLoopsInPreorder (const MachineLoop &L, SmallVectorImpl< Type > &PreOrderLoops)
 Return all inner loops in the loop nest rooted by the loop in preorder, with siblings in forward program order.
 
- Protected Member Functions inherited from llvm::LoopBase< MachineBasicBlock, MachineLoop >
 LoopBase ()
 This creates an empty loop.
 
 LoopBase (MachineBasicBlock *BB)
 
 ~LoopBase ()
 

Detailed Description

Definition at line 45 of file MachineLoopInfo.h.

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void MachineLoop::dump ( ) const

◆ findLoopControlBlock()

MachineBasicBlock * MachineLoop::findLoopControlBlock ( ) const

Find the block that contains the loop control variable and the loop test.

This will return the latch block if it's one of the exiting blocks. Otherwise, return the exiting block. Return 'null' when multiple exiting blocks are present.

Definition at line 91 of file MachineLoopInfo.cpp.

References llvm::LoopBase< MachineBasicBlock, MachineLoop >::getExitingBlock(), llvm::LoopBase< MachineBasicBlock, MachineLoop >::getLoopLatch(), and llvm::LoopBase< MachineBasicBlock, MachineLoop >::isLoopExiting().

Referenced by getLoopID().

◆ getBottomBlock()

MachineBasicBlock * MachineLoop::getBottomBlock ( )

Return the "bottom" block in the loop, which is the last block in the linear layout, ignoring any parts of the loop not contiguous with the part that contains the header.

Definition at line 76 of file MachineLoopInfo.cpp.

References llvm::LoopBase< MachineBasicBlock, MachineLoop >::contains(), llvm::MachineFunction::end(), End, llvm::LoopBase< MachineBasicBlock, MachineLoop >::getHeader(), llvm::ilist_node_impl< OptionsT >::getIterator(), and llvm::MachineBasicBlock::getParent().

◆ getLoopID()

MDNode * MachineLoop::getLoopID ( ) const

Find the llvm.loop metadata for this loop.

If each branch to the header of this loop contains the same llvm.loop metadata, then this metadata node is returned. Otherwise, if any latch instruction does not contain the llvm.loop metadata or multiple latch instructions contain different llvm.loop metadata nodes, then null is returned.

Definition at line 154 of file MachineLoopInfo.cpp.

References llvm::LoopBase< MachineBasicBlock, MachineLoop >::blocks(), findLoopControlBlock(), llvm::MachineBasicBlock::getBasicBlock(), llvm::LoopBase< MachineBasicBlock, MachineLoop >::getHeader(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), llvm::BasicBlock::getTerminator(), MBB, and llvm::successors().

◆ getStartLoc()

DebugLoc MachineLoop::getStartLoc ( ) const

Return the debug location of the start of this loop.

This looks for a BB terminating instruction with a known debug location by looking at the preheader and header blocks. If it cannot find a terminating instruction with location information, it returns an unknown location.

Definition at line 101 of file MachineLoopInfo.cpp.

References DL, llvm::LoopBase< MachineBasicBlock, MachineLoop >::getHeader(), and llvm::LoopBase< MachineBasicBlock, MachineLoop >::getLoopPreheader().

◆ getTopBlock()

MachineBasicBlock * MachineLoop::getTopBlock ( )

◆ isLoopInvariant()

bool MachineLoop::isLoopInvariant ( MachineInstr I,
const Register  ExcludeReg = 0 
) const

Returns true if the instruction is loop invariant.

I.e., all virtual register operands are defined outside of the loop, physical registers aren't accessed explicitly, and there are no side effects that aren't captured by the operands or other flags. ExcludeReg can be used to exclude the given register from the check i.e. when we're considering hoisting it's definition but not hoisted it yet

Definition at line 218 of file MachineLoopInfo.cpp.

References assert(), llvm::LoopBase< MachineBasicBlock, MachineLoop >::contains(), llvm::LoopBase< MachineBasicBlock, MachineLoop >::getHeader(), llvm::MachineFunction::getRegInfo(), llvm::MachineFunction::getSubtarget(), I, MRI, TII, and TRI.

Friends And Related Function Documentation

◆ LoopInfoBase< MachineBasicBlock, MachineLoop >

friend class LoopInfoBase< MachineBasicBlock, MachineLoop >
friend

Definition at line 87 of file MachineLoopInfo.h.


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