14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGLOOPINFO_H
15 #define LLVM_CLANG_LIB_CODEGEN_CGLOOPINFO_H
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/IR/DebugLoc.h"
20 #include "llvm/IR/Value.h"
21 #include "llvm/Support/Compiler.h"
77 Arrays.emplace_back(A, MD);
86 [
Array](
const auto &Pair) {
return Pair.first ==
Array; });
91 [
Array](const auto &Pair) {
return Pair.first ==
Array; });
95 assert(hasArray(
Array) &&
"Precondition of EraseArray is HasArray");
96 Arrays.erase(getArrayPairItr(
Array));
172 const llvm::DebugLoc &StartLoc,
const llvm::DebugLoc &EndLoc,
176 llvm::MDNode *
getLoopID()
const {
return TempLoopID.get(); }
188 void addIVDepMetadata(
const ValueDecl *Array, llvm::Instruction *GEP)
const;
200 llvm::TempMDTuple TempLoopID;
202 llvm::BasicBlock *Header;
206 llvm::MDNode *AccGroup =
nullptr;
208 llvm::DebugLoc StartLoc;
210 llvm::DebugLoc EndLoc;
216 llvm::MDNode *UnrollAndJamInnerFollowup =
nullptr;
242 bool &HasUserTransforms);
246 bool &HasUserTransforms);
250 bool &HasUserTransforms);
254 bool &HasUserTransforms);
258 bool &HasUserTransforms);
262 bool &HasUserTransforms);
263 void collectIVDepMetadata(
const ValueDecl *Array,
281 bool &HasUserTransforms);
296 void push(llvm::BasicBlock *Header,
const llvm::DebugLoc &StartLoc,
297 const llvm::DebugLoc &EndLoc);
304 const llvm::DebugLoc &EndLoc,
bool MustProgress =
false);
314 return hasInfo() ?
getInfo().getAttributes().IsParallel :
false;
319 void InsertHelper(llvm::Instruction *I)
const;
322 void setParallel(
bool Enable =
true) { StagedAttrs.IsParallel = Enable; }
326 StagedAttrs.VectorizeEnable =
327 Enable ? LoopAttributes::Enable : LoopAttributes::Disable;
332 StagedAttrs.DistributeEnable =
333 Enable ? LoopAttributes::Enable : LoopAttributes::Disable;
338 StagedAttrs.UnrollEnable =
State;
343 StagedAttrs.VectorizePredicateEnable =
State;
348 StagedAttrs.UnrollAndJamEnable =
State;
355 StagedAttrs.VectorizeScalable =
State;
362 void addSYCLIVDepInfo(llvm::LLVMContext &Ctx,
unsigned SafeLen,
365 void addIVDepMetadata(
const ValueDecl *Array, llvm::Instruction *GEP);
372 StagedAttrs.SYCLMaxConcurrencyNThreads = C;
377 StagedAttrs.SYCLLoopCoalesceEnable =
true;
382 StagedAttrs.SYCLLoopCoalesceNLevels = C;
387 StagedAttrs.SYCLLoopPipeliningDisable =
true;
392 StagedAttrs.SYCLMaxInterleavingNInvocations = C;
397 StagedAttrs.SYCLSpeculatedIterationsNIterations = C;
402 StagedAttrs.SYCLIntelFPGAVariantCount.push_back({Var, Count});
416 StagedAttrs.PipelineInitiationInterval = C;
430 StagedAttrs.SYCLMaxReinvocationDelayNCycles = C;
435 StagedAttrs.SYCLLoopPipeliningEnable =
true;
439 bool hasInfo()
const {
return !Active.empty(); }
static const TypeInfo & getInfo(unsigned id)
return(__x >> __y)|(__x<<(32 - __y))
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
A stack of loop information corresponding to loop nesting levels.
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 setSYCLLoopPipeliningDisable()
Set flag of disable_loop_pipelining for the next loop pushed.
void setSYCLSpeculatedIterationsNIterations(unsigned C)
Set value of speculated iterations for the next loop pushed.
void setDistributeState(bool Enable=true)
Set the next pushed loop as a distribution candidate.
void setSYCLLoopPipeliningEnable()
Set flag of enable_loop_pipelining for the next loop pushed.
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 setSYCLMaxReinvocationDelayNCycles(unsigned C)
Set value of max reinvocation delay for the next loop pushed.
void setInterleaveCount(unsigned C)
Set the interleave count for the next loop pushed.
void setSYCLMaxInterleavingNInvocations(unsigned C)
Set value of max interleaved invocations for the next loop pushed.
void setUnrollState(const LoopAttributes::LVEnableState &State)
Set the next pushed loop unroll state.
void setSYCLIntelFPGAVariantCount(const char *Var, unsigned int Count)
Set value of variant and loop count for the next loop pushed.
void setSYCLIInterval(unsigned C)
Set value of an initiation interval for the next loop pushed.
void setVectorizeScalable(const LoopAttributes::LVEnableState &State)
void setVectorizePredicateState(const LoopAttributes::LVEnableState &State)
Set the next pushed vectorize predicate state.
void setCodeAlign(unsigned C)
Set value of code align for the next loop pushed.
void setSYCLMaxConcurrencyNThreads(unsigned C)
Set value of max_concurrency for the next loop pushed.
void setSYCLLoopCoalesceEnable()
Set flag of loop_coalesce for the next loop pushed.
void setSYCLNofusionEnable()
Set flag of nofusion for the next loop pushed.
void push(llvm::BasicBlock *Header, const llvm::DebugLoc &StartLoc, const llvm::DebugLoc &EndLoc)
Begin a new structured loop.
void setSYCLLoopCoalesceNLevels(unsigned C)
Set value of coalesced levels for the next loop pushed.
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.
llvm::MDNode * getCurLoopID() const
Return the top loop id metadata.
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.
llvm::MDNode * getAccessGroup() const
Return this loop's access group or nullptr if it does not have one.
const LoopInfo * getParent() const
Returns the first outer loop containing this loop if any, nullptr otherwise.
llvm::BasicBlock * getHeader() const
Get the header block of this loop.
const LoopAttributes & getAttributes() const
Get the set of attributes active for this loop.
llvm::MDNode * getLoopID() const
Get the loop id metadata for this loop.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
decltype(Arrays) ::iterator getArrayPairItr(const ValueDecl *Array)
SYCLIVDepInfo(unsigned SL)
bool hasArray(const ValueDecl *Array) const
void eraseArray(const ValueDecl *Array)
llvm::SmallVector< std::pair< const ValueDecl *, llvm::MDNode * >, 4 > Arrays
bool isSafeLenGreaterOrEqual(unsigned OtherSL) const
SYCLIVDepInfo(unsigned SL, const ValueDecl *A, llvm::MDNode *MD)
Attributes that may be specified on loops.
unsigned UnrollCount
llvm.unroll.
bool MustProgress
Value for whether the loop is required to make progress.
unsigned InterleaveCount
Value for llvm.loop.interleave.count metadata.
LoopAttributes(bool IsParallel=false)
llvm::SmallVector< SYCLIVDepInfo, 4 > ArraySYCLIVDepInfo
unsigned SYCLLoopCoalesceNLevels
Value for llvm.loop.coalesce.count metadata.
bool IsParallel
Generate llvm.loop.parallel metadata for loads and stores.
bool SYCLLoopCoalesceEnable
Flag for llvm.loop.coalesce metadata.
LVEnableState VectorizeScalable
bool SYCLLoopPipeliningEnable
Flag for llvm.loop.intel.pipelining.enable, i32 1 metadata.
llvm::SmallVector< std::pair< const char *, unsigned int >, 2 > SYCLIntelFPGAVariantCount
Value for count variant (min/max/avg) and count metadata.
std::optional< unsigned > SYCLMaxReinvocationDelayNCycles
LVEnableState UnrollAndJamEnable
Value for llvm.loop.unroll_and_jam.* metadata (enable, disable, or full).
bool SYCLLoopPipeliningDisable
Flag for llvm.loop.intel.pipelining.enable, i32 0 metadata.
std::optional< unsigned > SYCLSpeculatedIterationsNIterations
Value for llvm.loop.intel.speculated.iterations.count metadata.
unsigned UnrollAndJamCount
llvm.unroll.
std::optional< unsigned > SYCLMaxConcurrencyNThreads
Value for llvm.loop.max_concurrency.count metadata.
LVEnableState
State of loop vectorization or unrolling.
std::optional< unsigned > SYCLMaxInterleavingNInvocations
Value for llvm.loop.max_interleaving.count metadata.
unsigned SYCLIInterval
Value for llvm.loop.ii.count metadata.
LVEnableState VectorizePredicateEnable
Value for llvm.loop.vectorize.predicate metadata.
LVEnableState DistributeEnable
Value for llvm.loop.distribute.enable metadata.
bool PipelineDisabled
Value for llvm.loop.pipeline.disable metadata.
unsigned CodeAlign
Value for 'llvm.loop.align' metadata.
bool SYCLNofusionEnable
Flag for llvm.loop.fusion.disable metatdata.
std::optional< SYCLIVDepInfo > GlobalSYCLIVDepInfo
LVEnableState UnrollEnable
Value for llvm.loop.unroll.* metadata (enable, disable, or full).
unsigned VectorizeWidth
Value for llvm.loop.vectorize.width metadata.
unsigned PipelineInitiationInterval
Value for llvm.loop.pipeline.iicount metadata.
LVEnableState VectorizeEnable
Value for llvm.loop.vectorize.enable metadata.