LLVM  14.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
llvm::LoopNest Class Reference

This class represents a loop nest and can be used to query its properties. More...

#include "llvm/Analysis/LoopNestAnalysis.h"

Collaboration diagram for llvm::LoopNest:
Collaboration graph
[legend]

Public Types

using InstrVectorTy = SmallVector< const Instruction * >
 

Public Member Functions

 LoopNest (Loop &Root, ScalarEvolution &SE)
 Construct a loop nest rooted by loop Root. More...
 
 LoopNest ()=delete
 
LoopgetOutermostLoop () const
 Return the outermost loop in the loop nest. More...
 
LoopgetInnermostLoop () const
 Return the innermost loop in the loop nest if the nest has only one innermost loop, and a nullptr otherwise. More...
 
LoopgetLoop (unsigned Index) const
 Return the loop at the given Index. More...
 
size_t getNumLoops () const
 Return the number of loops in the nest. More...
 
ArrayRef< Loop * > getLoops () const
 Get the loops in the nest. More...
 
SmallVector< LoopVectorTy, 4 > getPerfectLoops (ScalarEvolution &SE) const
 Retrieve a vector of perfect loop nests contained in the current loop nest. More...
 
unsigned getNestDepth () const
 Return the loop nest depth (i.e. More...
 
unsigned getMaxPerfectDepth () const
 Return the maximum perfect nesting depth. More...
 
bool areAllLoopsSimplifyForm () const
 Return true if all loops in the loop nest are in simplify form. More...
 
bool areAllLoopsRotatedForm () const
 Return true if all loops in the loop nest are in rotated form. More...
 
FunctiongetParent () const
 Return the function to which the loop-nest belongs. More...
 
StringRef getName () const
 

Static Public Member Functions

static std::unique_ptr< LoopNestgetLoopNest (Loop &Root, ScalarEvolution &SE)
 Construct a LoopNest object. More...
 
static bool arePerfectlyNested (const Loop &OuterLoop, const Loop &InnerLoop, ScalarEvolution &SE)
 Return true if the given loops OuterLoop and InnerLoop are perfectly nested with respect to each other, and false otherwise. More...
 
static InstrVectorTy getInterveningInstructions (const Loop &OuterLoop, const Loop &InnerLoop, ScalarEvolution &SE)
 Return a vector of instructions that prevent the LoopNest given by loops OuterLoop and InnerLoop from being perfect. More...
 
static unsigned getMaxPerfectDepth (const Loop &Root, ScalarEvolution &SE)
 Return the maximum nesting depth of the loop nest rooted by loop Root. More...
 
static const BasicBlockskipEmptyBlockUntil (const BasicBlock *From, const BasicBlock *End, bool CheckUniquePred=false)
 Recursivelly traverse all empty 'single successor' basic blocks of From (if there are any). More...
 

Protected Attributes

const unsigned MaxPerfectDepth
 
LoopVectorTy Loops
 

Detailed Description

This class represents a loop nest and can be used to query its properties.

Definition at line 28 of file LoopNestAnalysis.h.

Member Typedef Documentation

◆ InstrVectorTy

Definition at line 30 of file LoopNestAnalysis.h.

Constructor & Destructor Documentation

◆ LoopNest() [1/2]

LoopNest::LoopNest ( Loop Root,
ScalarEvolution SE 
)

Construct a loop nest rooted by loop Root.

Definition at line 43 of file LoopNestAnalysis.cpp.

References llvm::append_range(), llvm::breadth_first(), and Loops.

◆ LoopNest() [2/2]

llvm::LoopNest::LoopNest ( )
delete

Member Function Documentation

◆ areAllLoopsRotatedForm()

bool llvm::LoopNest::areAllLoopsRotatedForm ( ) const
inline

Return true if all loops in the loop nest are in rotated form.

Definition at line 148 of file LoopNestAnalysis.h.

References llvm::all_of(), llvm::Loop::isRotatedForm(), and Loops.

◆ areAllLoopsSimplifyForm()

bool llvm::LoopNest::areAllLoopsSimplifyForm ( ) const
inline

Return true if all loops in the loop nest are in simplify form.

Definition at line 143 of file LoopNestAnalysis.h.

References llvm::all_of(), llvm::Loop::isLoopSimplifyForm(), and Loops.

◆ arePerfectlyNested()

bool LoopNest::arePerfectlyNested ( const Loop OuterLoop,
const Loop InnerLoop,
ScalarEvolution SE 
)
static

Return true if the given loops OuterLoop and InnerLoop are perfectly nested with respect to each other, and false otherwise.

Example:

for(i)
for(j)
for(k)

arePerfectlyNested(loop_i, loop_j, SE) would return true. arePerfectlyNested(loop_j, loop_k, SE) would return true. arePerfectlyNested(loop_i, loop_k, SE) would return false.

Definition at line 104 of file LoopNestAnalysis.cpp.

Referenced by getMaxPerfectDepth(), and getPerfectLoops().

◆ getInnermostLoop()

Loop* llvm::LoopNest::getInnermostLoop ( ) const
inline

Return the innermost loop in the loop nest if the nest has only one innermost loop, and a nullptr otherwise.

Note: the innermost loop returned is not necessarily perfectly nested.

Definition at line 85 of file LoopNestAnalysis.h.

References llvm::LoopBase< BlockT, LoopT >::getLoopDepth(), and Loops.

◆ getInterveningInstructions()

LoopNest::InstrVectorTy LoopNest::getInterveningInstructions ( const Loop OuterLoop,
const Loop InnerLoop,
ScalarEvolution SE 
)
static

◆ getLoop()

Loop* llvm::LoopNest::getLoop ( unsigned  Index) const
inline

Return the loop at the given Index.

Definition at line 100 of file LoopNestAnalysis.h.

References assert(), Index, and Loops.

◆ getLoopNest()

std::unique_ptr< LoopNest > LoopNest::getLoopNest ( Loop Root,
ScalarEvolution SE 
)
static

◆ getLoops()

ArrayRef<Loop *> llvm::LoopNest::getLoops ( ) const
inline

Get the loops in the nest.

Definition at line 109 of file LoopNestAnalysis.h.

References Loops.

Referenced by Flatten(), llvm::operator<<(), and tryToUnrollAndJamLoop().

◆ getMaxPerfectDepth() [1/2]

unsigned llvm::LoopNest::getMaxPerfectDepth ( ) const
inline

Return the maximum perfect nesting depth.

Definition at line 140 of file LoopNestAnalysis.h.

◆ getMaxPerfectDepth() [2/2]

unsigned LoopNest::getMaxPerfectDepth ( const Loop Root,
ScalarEvolution SE 
)
static

Return the maximum nesting depth of the loop nest rooted by loop Root.

For example given the loop nest:

for(i) // loop at level 1 and Root of the nest
for(j) // loop at level 2
<code>
for(k) // loop at level 3

getMaxPerfectDepth(Loop_i) would return 2.

Definition at line 262 of file LoopNestAnalysis.cpp.

References arePerfectlyNested(), llvm::dbgs(), llvm::Loop::getName(), llvm::LoopBase< BlockT, LoopT >::getSubLoops(), and LLVM_DEBUG.

Referenced by llvm::operator<<().

◆ getName()

StringRef llvm::LoopNest::getName ( ) const
inline

Definition at line 157 of file LoopNestAnalysis.h.

References Loops.

◆ getNestDepth()

unsigned llvm::LoopNest::getNestDepth ( ) const
inline

Return the loop nest depth (i.e.

the loop depth of the 'deepest' loop) For example given the loop nest:

for(i) // loop at level 1 and Root of the nest
for(j1) // loop at level 2
for(k) // loop at level 3
for(j2) // loop at level 2

getNestDepth() would return 3.

Definition at line 132 of file LoopNestAnalysis.h.

References assert(), and Loops.

Referenced by llvm::operator<<().

◆ getNumLoops()

size_t llvm::LoopNest::getNumLoops ( ) const
inline

Return the number of loops in the nest.

Definition at line 106 of file LoopNestAnalysis.h.

References Loops.

◆ getOutermostLoop()

Loop& llvm::LoopNest::getOutermostLoop ( ) const
inline

Return the outermost loop in the loop nest.

Definition at line 80 of file LoopNestAnalysis.h.

References Loops.

Referenced by llvm::operator<<(), llvm::LNICMPass::run(), and tryToUnrollAndJamLoop().

◆ getParent()

Function* llvm::LoopNest::getParent ( ) const
inline

Return the function to which the loop-nest belongs.

Definition at line 153 of file LoopNestAnalysis.h.

References Loops.

Referenced by llvm::LoopInterchangePass::run(), llvm::LoopUnrollAndJamPass::run(), and llvm::LNICMPass::run().

◆ getPerfectLoops()

SmallVector< LoopVectorTy, 4 > LoopNest::getPerfectLoops ( ScalarEvolution SE) const

Retrieve a vector of perfect loop nests contained in the current loop nest.

For example, given the following nest containing 4 loops, this member function would return {{L1,L2},{L3,L4}}.

for(i) // L1
for(j) // L2
<code>
for(k) // L3
for(l) // L4

Definition at line 242 of file LoopNestAnalysis.cpp.

References arePerfectlyNested(), llvm::SmallVectorImpl< T >::clear(), llvm::depth_first(), and Loops.

◆ skipEmptyBlockUntil()

const BasicBlock & LoopNest::skipEmptyBlockUntil ( const BasicBlock From,
const BasicBlock End,
bool  CheckUniquePred = false 
)
static

Recursivelly traverse all empty 'single successor' basic blocks of From (if there are any).

When CheckUniquePred is set to true, check if each of the empty single successors has a unique predecessor. Return the last basic block found or End if it was reached during the search.

Definition at line 289 of file LoopNestAnalysis.cpp.

Referenced by llvm::Loop::getLoopGuardBranch().

Member Data Documentation

◆ Loops

LoopVectorTy llvm::LoopNest::Loops
protected

Definition at line 161 of file LoopNestAnalysis.h.

Referenced by getPerfectLoops(), and LoopNest().

◆ MaxPerfectDepth

const unsigned llvm::LoopNest::MaxPerfectDepth
protected

Definition at line 160 of file LoopNestAnalysis.h.


The documentation for this class was generated from the following files:
i
i
Definition: README.txt:29
l
This requires reassociating to forms of expressions that are already something that reassoc doesn t think about yet These two functions should generate the same code on big endian int * l
Definition: README.txt:100
j
return j(j<< 16)
code
*Add support for compiling functions in both ARM and Thumb then taking the smallest *Add support for compiling individual basic blocks in thumb when in a larger ARM function This can be used for presumed cold code
Definition: README-Thumb.txt:9