14#ifndef LLVM_CLANG_LIB_CODEGEN_CGLOOPINFO_H
15#define LLVM_CLANG_LIB_CODEGEN_CGLOOPINFO_H
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/SmallVector.h"
20#include "llvm/IR/DebugLoc.h"
21#include "llvm/IR/Value.h"
22#include "llvm/Support/Compiler.h"
45 const llvm::DebugLoc &StartLoc,
const llvm::DebugLoc &EndLoc,
49 llvm::MDNode *
getLoopID()
const {
return TempLoopID.get(); }
52 llvm::BasicBlock *
getHeader()
const {
return Header; }
70 llvm::TempMDTuple TempLoopID;
72 llvm::BasicBlock *Header;
76 llvm::MDNode *AccGroup =
nullptr;
78 llvm::DebugLoc StartLoc;
80 llvm::DebugLoc EndLoc;
86 std::optional<llvm::SmallVector<llvm::Metadata *, 4>>
87 UnrollAndJamInnerFollowup;
91 createFollowupMetadata(
const char *FollowupName,
114 bool &HasUserTransforms);
118 bool &HasUserTransforms);
122 bool &HasUserTransforms);
126 bool &HasUserTransforms);
130 bool &HasUserTransforms);
134 bool &HasUserTransforms);
152 bool &HasUserTransforms);
160 void operator=(
const LoopInfoStack &) =
delete;
167 void push(llvm::BasicBlock *Header,
const llvm::DebugLoc &StartLoc,
168 const llvm::DebugLoc &EndLoc);
175 const llvm::DebugLoc &EndLoc,
bool MustProgress =
false);
193 void setParallel(
bool Enable =
true) { StagedAttrs.IsParallel = Enable; }
197 StagedAttrs.VectorizeEnable =
203 StagedAttrs.DistributeEnable =
209 StagedAttrs.LICMDisabled = Disabled;
214 StagedAttrs.UnrollEnable = State;
219 StagedAttrs.VectorizePredicateEnable = State;
224 StagedAttrs.UnrollAndJamEnable = State;
231 StagedAttrs.VectorizeScalable = State;
248 StagedAttrs.PipelineInitiationInterval =
C;
258 bool hasInfo()
const {
return !Active.empty(); }
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Attr - This represents one attribute.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
void setPipelineDisabled(bool S)
Set the pipeline disabled state.
void setUnrollCount(unsigned C)
Set the unroll count for the next loop pushed.
bool hasInfo() const
Returns true if there is LoopInfo on the stack.
void setVectorizeWidth(unsigned W)
Set the vectorize width for the next loop pushed.
void InsertHelper(llvm::Instruction *I) const
Function called by the CodeGenFunction when an instruction is created.
void setDistributeState(bool Enable=true)
Set the next pushed loop as a distribution candidate.
void setParallel(bool Enable=true)
Set the next pushed loop as parallel.
void push(llvm::BasicBlock *Header, clang::ASTContext &Ctx, const clang::CodeGenOptions &CGOpts, llvm::ArrayRef< const Attr * > Attrs, const llvm::DebugLoc &StartLoc, const llvm::DebugLoc &EndLoc, bool MustProgress=false)
Begin a new structured loop.
void setInterleaveCount(unsigned C)
Set the interleave count for the next loop pushed.
void setUnrollState(const LoopAttributes::LVEnableState &State)
Set the next pushed loop unroll state.
llvm::MDNode * getCurLoopID() const
Return the top loop id metadata.
void setVectorizeScalable(const LoopAttributes::LVEnableState &State)
void setVectorizePredicateState(const LoopAttributes::LVEnableState &State)
Set the next pushed vectorize predicate state.
void pop()
End the current loop.
void setCodeAlign(unsigned C)
Set value of code align for the next loop pushed.
void setLICMDisabled(bool Disabled=true)
Set the next pushed loop LICM disable state.
void push(llvm::BasicBlock *Header, const llvm::DebugLoc &StartLoc, const llvm::DebugLoc &EndLoc)
Begin a new structured loop.
bool getCurLoopParallel() const
Return true if the top loop is parallel.
void setMustProgress(bool P)
Set no progress for the next loop pushed.
void setUnrollAndJamState(const LoopAttributes::LVEnableState &State)
Set the next pushed loop unroll_and_jam state.
void setUnrollAndJamCount(unsigned C)
Set the unroll count for the next loop pushed.
const LoopInfo & getInfo() const
Return the LoopInfo for the current loop.
void setPipelineInitiationInterval(unsigned C)
Set the pipeline initiation interval.
void setVectorizeEnable(bool Enable=true)
Set the next pushed loop 'vectorize.enable'.
Information used when generating a structured loop.
void finish()
Create the loop's metadata.
llvm::BasicBlock * getHeader() const
Get the header block of this loop.
LoopInfo(llvm::BasicBlock *Header, const LoopAttributes &Attrs, const llvm::DebugLoc &StartLoc, const llvm::DebugLoc &EndLoc, LoopInfo *Parent)
Construct a new LoopInfo for the loop with entry Header.
llvm::MDNode * getAccessGroup() const
Return this loop's access group or nullptr if it does not have one.
llvm::MDNode * getLoopID() const
Get the loop id metadata for this loop.
const LoopInfo * getParent() const
Returns the first outer loop containing this loop if any, nullptr otherwise.
const LoopAttributes & getAttributes() const
Get the set of attributes active for this loop.
clang::CodeGenUtils::LoopAttributes LoopAttributes
Attributes that may be specified on loops.
Top level wrappers for InstallAPI frontend operations.
Diagnostic wrappers for TextAPI types for error reporting.
Attributes that may be specified on loops.
bool IsParallel
Generate llvm.loop.parallel metadata for loads and stores.
LVEnableState
State of loop vectorization or unrolling.