LLVM 20.0.0git
|
#include "llvm/CodeGen/MachineLoopInfo.h"
Public Member Functions | |
MachineBasicBlock * | getTopBlock () |
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. | |
MachineBasicBlock * | 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. | |
MachineBasicBlock * | findLoopControlBlock () 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. | |
MDNode * | getLoopID () 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. | |
MachineBasicBlock * | getHeader () const |
MachineLoop * | getParentLoop () const |
Return the parent loop if it exists or nullptr for top level loops. | |
const MachineLoop * | getOutermostLoop () const |
Get the outermost loop in which this loop is contained. | |
MachineLoop * | getOutermostLoop () |
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_iterator > | blocks () 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. | |
MachineBasicBlock * | getExitingBlock () 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. | |
MachineBasicBlock * | getExitBlock () 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. | |
MachineBasicBlock * | getUniqueExitBlock () const |
If getUniqueExitBlocks would return exactly one block, return that block. | |
MachineBasicBlock * | getUniqueLatchExitBlock () const |
Return the unique exit block for the latch, or null if there are multiple different exit blocks or the latch is not exiting. | |
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). | |
MachineBasicBlock * | getLoopPreheader () const |
If there is a preheader for this loop, return it. | |
MachineBasicBlock * | getLoopPredecessor () const |
If the given loop's header has exactly one unique predecessor outside the loop, return it. | |
MachineBasicBlock * | getLoopLatch () 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. | |
MachineLoop * | removeChildLoop (iterator I) |
This removes the specified child from being a subloop of this loop. | |
MachineLoop * | removeChildLoop (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 () | |
Definition at line 46 of file MachineLoopInfo.h.
LLVM_DUMP_METHOD void MachineLoop::dump | ( | ) | const |
Definition at line 307 of file MachineLoopInfo.cpp.
References llvm::dbgs(), and llvm::LoopBase< MachineBasicBlock, MachineLoop >::print().
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 119 of file MachineLoopInfo.cpp.
References llvm::LoopBase< MachineBasicBlock, MachineLoop >::getExitingBlock(), llvm::LoopBase< MachineBasicBlock, MachineLoop >::getLoopLatch(), and llvm::LoopBase< MachineBasicBlock, MachineLoop >::isLoopExiting().
Referenced by getLoopID().
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 104 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().
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 182 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().
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 129 of file MachineLoopInfo.cpp.
References DL, llvm::LoopBase< MachineBasicBlock, MachineLoop >::getHeader(), and llvm::LoopBase< MachineBasicBlock, MachineLoop >::getLoopPreheader().
MachineBasicBlock * MachineLoop::getTopBlock | ( | ) |
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.
Definition at line 89 of file MachineLoopInfo.cpp.
References llvm::MachineFunction::begin(), llvm::LoopBase< MachineBasicBlock, MachineLoop >::contains(), llvm::LoopBase< MachineBasicBlock, MachineLoop >::getHeader(), llvm::ilist_node_impl< OptionsT >::getIterator(), and llvm::MachineBasicBlock::getParent().
Referenced by llvm::ModuloScheduleExpander::expand(), llvm::PeelingModuloScheduleExpander::expand(), llvm::ModuloScheduleExpanderMVE::expand(), and llvm::PeelingModuloScheduleExpander::validateAgainstModuloScheduleExpander().
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 246 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.
|
friend |
Definition at line 88 of file MachineLoopInfo.h.