13#ifndef LLVM_ANALYSIS_LOOPINFO_H 
   14#define LLVM_ANALYSIS_LOOPINFO_H 
   40class LLVM_ABI Loop : 
public LoopBase<BasicBlock, Loop> {
 
   58    explicit operator bool()
 const { 
return Start && End; }
 
 
   62  bool isLoopInvariant(
const Value *V) 
const;
 
   66  bool hasLoopInvariantOperands(
const Instruction *
I) 
const;
 
  105  PHINode *getCanonicalInductionVariable() 
const;
 
  161    LLVM_ABI static std::optional<Loop::LoopBounds>
 
  224        : L(Loop), InitialIVValue(
I), StepInst(
SI), StepValue(SV),
 
  225          FinalIVValue(
F), SE(SE) {}
 
  230    Value &InitialIVValue;
 
 
  247  std::optional<LoopBounds> getBounds(ScalarEvolution &SE) 
const;
 
  256  PHINode *getInductionVariable(ScalarEvolution &SE) 
const;
 
  260  bool getInductionDescriptor(ScalarEvolution &SE,
 
  261                              InductionDescriptor &IndDesc) 
const;
 
  270  bool isAuxiliaryInductionVariable(PHINode &AuxIndVar,
 
  271                                    ScalarEvolution &SE) 
const;
 
  291  BranchInst *getLoopGuardBranch() 
const;
 
  315  bool isLCSSAForm(
const DominatorTree &DT, 
bool IgnoreTokens = 
true) 
const;
 
  321                              bool IgnoreTokens = 
true) 
const;
 
  325  bool isLoopSimplifyForm() 
const;
 
  328  bool isSafeToClone() 
const;
 
  342  bool isAnnotatedParallel() 
const;
 
  350  MDNode *getLoopID() 
const;
 
  358  void setLoopID(
MDNode *LoopID) 
const;
 
  366  void setLoopAlreadyUnrolled();
 
  369  void setLoopMustProgress();
 
  372  void dumpVerbose() 
const;
 
  382  LocRange getLocRange() 
const;
 
  387  std::string getLocStr() 
const;
 
  391      if (Header->hasName())
 
  392        return Header->getName();
 
  393    return "<unnamed loop>";
 
 
  400  friend class LoopBase<BasicBlock, Loop>;
 
 
  408class LoopInfo : 
public LoopInfoBase<BasicBlock, Loop> {
 
  409  typedef LoopInfoBase<BasicBlock, Loop> BaseT;
 
  413  void operator=(
const LoopInfo &) = 
delete;
 
  414  LoopInfo(
const LoopInfo &) = 
delete;
 
  423    BaseT::operator=(std::move(
static_cast<BaseT &
>(
RHS)));
 
 
  429                           FunctionAnalysisManager::Invalidator &);
 
  469           "Can't reason about IPO!");
 
  482    if (OldLoop == NewLoop)
 
  488      return !Outer || Outer->contains(Inner);
 
  503        if (UBB != NewBB && 
getLoopFor(UBB) != NewLoop)
 
  524        auto *DefBlock = DefI->getParent();
 
  525        if (DefBlock != NewBB && 
getLoopFor(DefBlock) != NewLoop)
 
 
  538  wouldBeOutOfLoopUseRequiringLCSSA(
const Value *V,
 
 
  610  void verifyAnalysis() 
const override;
 
 
  621                        const std::string &Banner = 
"");
 
  654LLVM_ABI std::optional<const MDOperand *>
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_TEMPLATE_ABI
static bool runOnFunction(Function &F, bool PostInlining)
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
This header defines various interfaces for pass management in LLVM.
Loop::LoopBounds::Direction Direction
static bool Contains(directive::VersionRange V, int P)
Represent the analysis usage information of a pass.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Core dominator tree base class.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
This instruction compares its operands according to the predicate given to the constructor.
A struct for saving information about induction variables.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
This is an important class for using LLVM in a threaded context.
Analysis pass that exposes the LoopInfo for a function.
LLVM_ABI LoopInfo run(Function &F, FunctionAnalysisManager &AM)
Instances of this class are used to represent loops that are detected in the flow graph.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
BasicBlock * getLoopLatch() const
BasicBlock * getHeader() const
bool isLoopExiting(const BasicBlock *BB) const
This class builds and contains all of the top-level loop structures in the specified function.
Loop * getLoopFor(const BasicBlock *BB) const
std::vector< Loop * >::const_iterator iterator
const LoopInfo & getLoopInfo() const
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
LoopInfo & operator=(LoopInfo &&RHS)
bool replacementPreservesLCSSAForm(Instruction *From, Value *To)
Returns true if replacing From with To everywhere is guaranteed to preserve LCSSA form.
LLVM_ABI LoopInfo(const DominatorTreeBase< BasicBlock, false > &DomTree)
bool movementPreservesLCSSAForm(Instruction *Inst, Instruction *NewLoc)
Checks if moving a specific instruction can break LCSSA in any loop.
LoopPrinterPass(raw_ostream &OS)
LocRange(DebugLoc Start, DebugLoc End)
const DebugLoc & getStart() const
const DebugLoc & getEnd() const
Represents a single loop in the control flow graph.
bool isGuarded() const
Return true iff the loop is.
BranchInst * getLoopGuardBranch() const
Return the loop guard branch, if it exists.
StringRef getName() const
bool isRotatedForm() const
Return true if the loop is in rotated form.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
The main scalar evolution driver.
StringRef - Represent a constant reference to a string, i.e.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
iterator_range< use_iterator > uses()
const ParentTy * getParent() const
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
LLVM_ABI bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name)
Returns true if Name is applied to TheLoop and enabled.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI std::optional< bool > getOptionalBoolLoopAttribute(const Loop *TheLoop, StringRef Name)
LLVM_ABI int getIntLoopAttribute(const Loop *TheLoop, StringRef Name, int Default=0)
Find named metadata for a loop with an integer value.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI std::optional< const MDOperand * > findStringMetadataForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for loop.
LLVM_ABI MDNode * findOptionMDForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for a loop.
LLVM_ABI bool hasMustProgress(const Loop *L)
Look for the loop attribute that requires progress within the loop.
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
LLVM_ABI bool isMustProgress(const Loop *L)
Return true if this loop can be assumed to make progress.
LLVM_ABI CallBase * getLoopConvergenceHeart(const Loop *TheLoop)
Find the convergence heart of the loop.
LLVM_ABI bool isFinite(const Loop *L)
Return true if this loop can be assumed to run for a finite number of iterations.
LLVM_ABI bool VerifyLoopInfo
Enable verification of loop info.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI std::optional< int > getOptionalIntLoopAttribute(const Loop *TheLoop, StringRef Name)
Find named metadata for a loop with an integer value.
LLVM_ABI bool isValidAsAccessGroup(MDNode *AccGroup)
Return whether an MDNode might represent an access group.
LLVM_ABI void printLoop(const Loop &L, raw_ostream &OS, const std::string &Banner="")
Function to print a loop's contents as LLVM's text IR assembly.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI llvm::MDNode * makePostTransformationMetadata(llvm::LLVMContext &Context, MDNode *OrigLoopID, llvm::ArrayRef< llvm::StringRef > RemovePrefixes, llvm::ArrayRef< llvm::MDNode * > AddAttrs)
Create a new LoopID after the loop has been transformed.
template class LLVM_TEMPLATE_ABI LoopInfoBase< BasicBlock, Loop >
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI MDNode * findOptionMDForLoopID(MDNode *LoopID, StringRef Name)
Find and return the loop attribute node for the attribute Name in LoopID.
Implement std::hash so that hash_code can be used in STL containers.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
static NodeRef getEntryNode(Loop *L)
LoopInfo::iterator ChildIteratorType
static ChildIteratorType child_begin(NodeRef N)
static ChildIteratorType child_end(NodeRef N)
static ChildIteratorType child_begin(NodeRef N)
static ChildIteratorType child_end(NodeRef N)
static NodeRef getEntryNode(const Loop *L)
LoopInfo::iterator ChildIteratorType
Incoming for lane maks phi as machine instruction, incoming register Reg and incoming block Block are...
Verifier pass for the LoopAnalysis results.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Below are some utilities to get the loop guard, loop bounds and induction variable,...
static LLVM_ABI std::optional< Loop::LoopBounds > getBounds(const Loop &L, PHINode &IndVar, ScalarEvolution &SE)
Return the LoopBounds object if.
Direction
An enum for the direction of the loop.
Value & getFinalIVValue() const
Get the final value of the loop induction variable.
Value * getStepValue() const
Get the step that the loop induction variable gets updated by in each loop iteration.
Instruction & getStepInst() const
Get the instruction that updates the loop induction variable.
Value & getInitialIVValue() const
Get the initial value of the loop induction variable.
A CRTP mix-in to automatically provide informational APIs needed for passes.