13 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H 14 #define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H 22 #include "llvm/ADT/DenseMap.h" 23 #include "llvm/ADT/SmallPtrSet.h" 24 #include "llvm/ADT/StringMap.h" 25 #include "llvm/ADT/StringSet.h" 26 #include "llvm/Frontend/OpenMP/OMPConstants.h" 27 #include "llvm/IR/Function.h" 28 #include "llvm/IR/ValueHandle.h" 43 class OMPExecutableDirective;
44 class OMPLoopDirective;
46 class OMPDeclareReductionDecl;
51 class CodeGenFunction;
73 template <
typename Callable>
74 static void CallbackFn(intptr_t CodeGen, CodeGenFunction &CGF,
76 return (*reinterpret_cast<Callable *>(CodeGen))(CGF, Action);
80 template <
typename Callable>
83 typename std::enable_if<
86 : CodeGen(reinterpret_cast<intptr_t>(&CodeGen)),
87 Callback(CallbackFn<typename
std::remove_reference<Callable>::
type>),
88 PrePostAction(nullptr) {}
90 void operator()(CodeGenFunction &CGF)
const;
105 llvm::PointerIntPair<llvm::Value *, 1, bool>
Final;
106 llvm::PointerIntPair<llvm::Value *, 1, bool>
Schedule;
107 llvm::PointerIntPair<llvm::Value *, 1, bool>
Priority;
109 unsigned NumberOfParts = 0;
111 bool Nogroup =
false;
118 struct ReductionData {
120 const Expr *Ref =
nullptr;
122 const Expr *Private =
nullptr;
124 const Expr *ReductionOp =
nullptr;
125 ReductionData(
const Expr *Ref,
const Expr *Private,
const Expr *ReductionOp)
126 : Ref(Ref), Private(Private), ReductionOp(ReductionOp) {}
176 bool needCleanups(
unsigned N);
191 std::pair<llvm::Value *, llvm::Value *>
getSizes(
unsigned N)
const {
200 bool usesReductionInitializer(
unsigned N)
const;
209 bool SavedShouldMarkAsGlobal;
219 const bool NeedToPush;
240 bool UseOriginalIV =
false;
245 const bool NeedToPush;
259 StringRef Separator);
263 virtual void createOffloadEntry(llvm::Constant *
ID, llvm::Constant *Addr,
264 uint64_t Size, int32_t Flags,
265 llvm::GlobalValue::LinkageTypes
Linkage);
277 StringRef ParentName,
278 llvm::Function *&OutlinedFn,
279 llvm::Constant *&OutlinedFnID,
290 llvm::Type *getIdentTyPointerTy();
303 llvm::FunctionCallee Callee,
311 bool AtCurrentPoint =
false);
328 virtual bool tryEmitDeclareVariant(
const GlobalDecl &NewGD,
330 llvm::GlobalValue *OrigAddr,
331 bool IsForDefinition);
345 llvm::Value *getCriticalRegionLock(StringRef CriticalName);
350 llvm::Constant *DefaultOpenMPPSource =
nullptr;
351 using FlagsTy = std::pair<unsigned, unsigned>;
353 using OpenMPDefaultLocMapTy = llvm::DenseMap<FlagsTy, llvm::Value *>;
354 OpenMPDefaultLocMapTy OpenMPDefaultLocMap;
355 Address getOrCreateDefaultLocation(
unsigned Flags);
358 llvm::StructType *IdentTy =
nullptr;
360 typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy;
361 OpenMPDebugLocMapTy OpenMPDebugLocMap;
365 llvm::FunctionType *Kmpc_MicroTy =
nullptr;
367 struct DebugLocThreadIdTy {
371 llvm::AssertingVH<llvm::Instruction> ServiceInsertPt =
nullptr;
374 typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy>
375 OpenMPLocThreadIDMapTy;
376 OpenMPLocThreadIDMapTy OpenMPLocThreadIDMap;
379 std::pair<llvm::Function *, llvm::Function *>>
383 typedef llvm::DenseMap<llvm::Function *,
386 FunctionUDRMapTy FunctionUDRMap;
389 llvm::DenseMap<const OMPDeclareMapperDecl *, llvm::Function *> UDMMap;
391 using FunctionUDMMapTy =
392 llvm::DenseMap<llvm::Function *,
394 FunctionUDMMapTy FunctionUDMMap;
397 llvm::ArrayType *KmpCriticalNameTy;
403 llvm::StringMap<llvm::AssertingVH<llvm::Constant>, llvm::BumpPtrAllocator>
406 llvm::Type *KmpRoutineEntryPtrTy =
nullptr;
452 unsigned OffloadingEntriesNum = 0;
461 OffloadingEntryInfoTargetRegion = 0,
463 OffloadingEntryInfoDeviceGlobalVar = 1,
465 OffloadingEntryInfoInvalid = ~0u
473 : Flags(Flags), Order(Order), Kind(Kind) {}
481 void setFlags(uint32_t NewFlags) { Flags = NewFlags; }
483 return cast_or_null<llvm::Constant>(Addr);
486 assert(!Addr.pointsToAliveValue() &&
"Address has been set before!");
493 llvm::WeakTrackingVH Addr;
499 unsigned Order = ~0u;
507 unsigned size()
const {
return OffloadingEntriesNum; }
517 OMPTargetRegionEntryTargetRegion = 0x0,
519 OMPTargetRegionEntryCtor = 0x02,
521 OMPTargetRegionEntryDtor = 0x04,
527 llvm::Constant *
ID =
nullptr;
533 llvm::Constant *Addr,
543 assert(!ID &&
"ID has been set before!");
547 return Info->
getKind() == OffloadingEntryInfoTargetRegion;
552 void initializeTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
553 StringRef ParentName,
unsigned LineNum,
556 void registerTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
557 StringRef ParentName,
unsigned LineNum,
558 llvm::Constant *Addr, llvm::Constant *
ID,
562 bool hasTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
563 StringRef ParentName,
unsigned LineNum)
const;
565 typedef llvm::function_ref<void(
unsigned,
unsigned, StringRef,
unsigned,
568 void actOnTargetRegionEntriesInfo(
578 OMPTargetGlobalVarEntryTo = 0x0,
580 OMPTargetGlobalVarEntryLink = 0x1,
587 llvm::GlobalValue::LinkageTypes
Linkage;
596 unsigned Order, llvm::Constant *Addr,
CharUnits VarSize,
598 llvm::GlobalValue::LinkageTypes Linkage)
600 VarSize(VarSize), Linkage(Linkage) {
609 return Info->
getKind() == OffloadingEntryInfoDeviceGlobalVar;
614 void initializeDeviceGlobalVarEntryInfo(StringRef Name,
620 registerDeviceGlobalVarEntryInfo(StringRef VarName, llvm::Constant *Addr,
623 llvm::GlobalValue::LinkageTypes
Linkage);
626 return OffloadEntriesDeviceGlobalVar.count(VarName) > 0;
629 typedef llvm::function_ref<void(StringRef,
632 void actOnDeviceGlobalVarEntriesInfo(
638 typedef llvm::DenseMap<unsigned, OffloadEntryInfoTargetRegion>
639 OffloadEntriesTargetRegionPerLine;
640 typedef llvm::StringMap<OffloadEntriesTargetRegionPerLine>
641 OffloadEntriesTargetRegionPerParentName;
642 typedef llvm::DenseMap<unsigned, OffloadEntriesTargetRegionPerParentName>
643 OffloadEntriesTargetRegionPerFile;
644 typedef llvm::DenseMap<unsigned, OffloadEntriesTargetRegionPerFile>
645 OffloadEntriesTargetRegionPerDevice;
646 typedef OffloadEntriesTargetRegionPerDevice OffloadEntriesTargetRegionTy;
647 OffloadEntriesTargetRegionTy OffloadEntriesTargetRegion;
650 typedef llvm::StringMap<OffloadEntryInfoDeviceGlobalVar>
651 OffloadEntriesDeviceGlobalVarTy;
652 OffloadEntriesDeviceGlobalVarTy OffloadEntriesDeviceGlobalVar;
669 llvm::MapVector<CanonicalDeclPtr<const FunctionDecl>,
670 std::pair<GlobalDecl, GlobalDecl>>
752 const llvm::Twine &Name,
753 unsigned AddressSpace = 0);
777 llvm::BasicBlock *ExitBB,
bool IsInit);
781 llvm::Function *TaskEntry =
nullptr;
811 llvm::Function *TaskFunction,
QualType SharedsTy,
833 virtual void clear();
856 const OMPDeclareReductionDecl *D);
858 virtual std::pair<llvm::Function *, llvm::Function *>
908 bool Tied,
unsigned &NumberOfParts);
925 llvm::Function *OutlinedFn,
937 const Expr *Hint =
nullptr);
984 bool EmitChecks =
true,
985 bool ForceSimpleCall =
false);
1001 bool Chunked)
const;
1008 bool Chunked)
const;
1015 bool Chunked)
const;
1034 : LB(LB), UB(UB), Chunk(Chunk) {}
1058 unsigned IVSize,
bool IVSigned,
bool Ordered,
1064 unsigned IVSize = 0;
1066 bool IVSigned =
false;
1068 bool Ordered =
false;
1087 : IVSize(IVSize), IVSigned(IVSigned), Ordered(Ordered), IL(IL), LB(LB),
1088 UB(UB), ST(ST), Chunk(Chunk) {}
1158 unsigned IVSize,
bool IVSigned,
1173 llvm::omp::ProcBindKind ProcBind,
1199 virtual llvm::Function *
1209 llvm::GlobalVariable *Addr,
1254 llvm::Function *TaskFunction,
QualType SharedsTy,
1289 llvm::Function *TaskFunction,
1303 bool HasCancel =
false);
1313 llvm::Type *ArgsType,
1321 const Expr *ReductionOp,
1322 const Expr *PrivateRef,
1455 StringRef ParentName,
1456 llvm::Function *&OutlinedFn,
1457 llvm::Constant *&OutlinedFnID,
1458 bool IsOffloadEntry,
1475 llvm::Function *OutlinedFn,
llvm::Value *OutlinedFnID,
1476 const Expr *IfCond,
const Expr *Device,
1495 llvm::Constant *Addr);
1540 bool RequiresDevicePointerInfo =
false;
1552 unsigned NumberOfPtrs = 0u;
1559 : RequiresDevicePointerInfo(RequiresDevicePointerInfo) {}
1562 BasePointersArray =
nullptr;
1563 PointersArray =
nullptr;
1564 SizesArray =
nullptr;
1565 MapTypesArray =
nullptr;
1570 return BasePointersArray && PointersArray && SizesArray &&
1571 MapTypesArray && NumberOfPtrs;
1586 const Expr *IfCond,
const Expr *Device,
1600 const Expr *Device);
1607 llvm::Function *Fn);
1624 const VarDecl *NativeParam)
const {
1634 const VarDecl *TargetParam)
const;
1646 const Expr *&ChunkExpr)
const;
1652 llvm::FunctionCallee OutlinedFn,
1744 const RegionCodeGenTy &CodeGen)
override;
1758 const RegionCodeGenTy &CodeGen)
override;
1779 bool Tied,
unsigned &NumberOfParts)
override;
1792 llvm::Function *OutlinedFn,
1794 const Expr *IfCond)
override;
1802 const RegionCodeGenTy &CriticalOpGen,
1804 const Expr *Hint =
nullptr)
override;
1810 const RegionCodeGenTy &MasterOpGen,
1820 const RegionCodeGenTy &TaskgroupOpGen,
1837 const RegionCodeGenTy &OrderedOpGen,
1850 bool ForceSimpleCall =
false)
override;
1870 unsigned IVSize,
bool IVSigned,
bool Ordered,
1871 const DispatchRTInput &DispatchValues)
override;
1891 const StaticRTInput &Values)
override;
1901 const StaticRTInput &Values)
override;
1912 unsigned IVSize,
bool IVSigned)
override;
1939 unsigned IVSize,
bool IVSigned, Address IL,
1940 Address LB, Address UB, Address ST)
override;
1952 llvm::omp::ProcBindKind ProcBind,
1975 CodeGenFunction *CGF =
nullptr)
override;
1983 StringRef Name)
override;
2019 llvm::Function *TaskFunction,
QualType SharedsTy,
2020 Address Shareds,
const Expr *IfCond,
2021 const OMPTaskDataTy &Data)
override;
2054 QualType SharedsTy, Address Shareds,
const Expr *IfCond,
2055 const OMPTaskDataTy &Data)
override;
2104 ReductionOptionsTy Options)
override;
2129 const OMPTaskDataTy &Data)
override;
2139 ReductionCodeGen &RCG,
unsigned N)
override;
2148 LValue SharedLVal)
override;
2179 StringRef ParentName,
2180 llvm::Function *&OutlinedFn,
2181 llvm::Constant *&OutlinedFnID,
2182 bool IsOffloadEntry,
2183 const RegionCodeGenTy &CodeGen)
override;
2197 llvm::Function *OutlinedFn,
llvm::Value *OutlinedFnID,
2198 const Expr *IfCond,
const Expr *Device,
2199 llvm::function_ref<
llvm::Value *(CodeGenFunction &CGF,
2201 SizeEmitter)
override;
2249 const Expr *Device,
const RegionCodeGenTy &CodeGen,
2250 TargetDataInfo &Info)
override;
2262 const Expr *Device)
override;
2279 const VarDecl *NativeParam)
const override;
2286 const VarDecl *TargetParam)
const override;
2291 return Address::invalid();
llvm::SmallVector< NontemporalDeclsSet, 4 > NontemporalDeclsStack
Stack for list of declarations in current context marked as nontemporal.
llvm::GlobalValue::LinkageTypes getLinkage() const
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
llvm::function_ref< void(unsigned, unsigned, StringRef, unsigned, const OffloadEntryInfoTargetRegion &)> OffloadTargetRegionEntryInfoActTy
brief Applies action Action on all registered entries.
Represents a function declaration or definition.
OMPTargetRegionEntryKind
Kind of the target registry entry.
bool hasRequiresUnifiedSharedMemory() const
Return whether the unified_shared_memory has been specified.
void setAddress(llvm::Constant *V)
virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable.
llvm::SmallVector< LastprivateConditionalData, 4 > LastprivateConditionalStack
Stack for list of addresses of declarations in current context marked as lastprivate conditional...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final list of privates etc *TaskResultTy emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, const OMPExecutableDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const OMPTaskDataTy &Data)
Scheduling data for loop-based OpenMP directives.
A (possibly-)qualified type.
Allows to disable automatic handling of functions used in target regions as those marked as omp decla...
llvm::Function * emitReductionFunction(SourceLocation Loc, llvm::Type *ArgsType, ArrayRef< const Expr *> Privates, ArrayRef< const Expr *> LHSExprs, ArrayRef< const Expr *> RHSExprs, ArrayRef< const Expr *> ReductionOps)
Emits reduction function.
llvm::Constant * getID() const
void emitSingleReductionCombiner(CodeGenFunction &CGF, const Expr *ReductionOp, const Expr *PrivateRef, const DeclRefExpr *LHS, const DeclRefExpr *RHS)
Emits single reduction combiner.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Manages list of lastprivate conditional decls for the specified directive.
Stmt - This represents one statement.
virtual void emitUserDefinedReduction(CodeGenFunction *CGF, const OMPDeclareReductionDecl *D)
Emit code for the specified user defined reduction construct.
OffloadEntriesInfoManagerTy(CodeGenModule &CGM)
C Language Family Type Representation.
SmallVector< std::pair< OpenMPDependClauseKind, const Expr * >, 4 > Dependences
virtual void initLastprivateConditionalCounter(CodeGenFunction &CGF, const OMPExecutableDirective &S)
Initializes global counter for lastprivate conditional.
SmallVector< const Expr *, 4 > LastprivateCopies
Decl - This represents one declaration (or definition), e.g.
virtual llvm::Value * emitTaskReductionInit(CodeGenFunction &CGF, SourceLocation Loc, ArrayRef< const Expr *> LHSExprs, ArrayRef< const Expr *> RHSExprs, const OMPTaskDataTy &Data)
Emit a code for initialization of task reduction clause.
llvm::SmallDenseSet< const VarDecl * > DeferredGlobalVariables
List of variables that can become declare target implicitly and, thus, must be emitted.
virtual Address getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name)
Creates artificial threadprivate variable with name Name and type VarType.
OffloadingEntryInfoKinds getKind() const
bool markAsGlobalTarget(GlobalDecl GD)
Marks the declaration as already emitted for the device code and returns true, if it was marked alrea...
void emitIfClause(CodeGenFunction &CGF, const Expr *Cond, const RegionCodeGenTy &ThenGen, const RegionCodeGenTy &ElseGen)
Emits code for OpenMP 'if' clause using specified CodeGen function.
OffloadEntryInfoDeviceGlobalVar(unsigned Order, OMPTargetGlobalVarEntryKind Flags)
virtual void checkArchForUnifiedAddressing(const OMPRequiresDecl *D)
Perform check on requires decl to ensure that target architecture supports unified addressing...
void scanForTargetRegionsFunctions(const Stmt *S, StringRef ParentName)
Start scanning from statement S and and emit all target regions found along the way.
SmallVector< const Expr *, 4 > ReductionCopies
static const Stmt * getSingleCompoundChild(ASTContext &Ctx, const Stmt *Body)
Checks if the Body is the CompoundStmt and returns its child statement iff there is only one that is ...
Represents a variable declaration or definition.
uint32_t getFlags() const
bool isValid()
Return true if the current target data information has valid arrays.
llvm::DenseMap< const ValueDecl *, Address > CaptureDeviceAddrMap
Map between the a declaration of a capture and the corresponding base pointer address where the runti...
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Class supports emissionof SIMD-only code.
virtual llvm::Value * emitForNext(CodeGenFunction &CGF, SourceLocation Loc, unsigned IVSize, bool IVSigned, Address IL, Address LB, Address UB, Address ST)
Call __kmpc_dispatch_next( ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter, kmp_int[32|64] *p_lowe...
virtual void Exit(CodeGenFunction &CGF)
OpenMPDirectiveKind ReductionKind
OffloadEntryInfoTargetRegion()
OffloadingEntryInfoKinds
Kind of a given entry.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
void createOffloadEntriesAndInfoMetadata()
Creates all the offload entries in the current compilation unit along with the associated metadata...
llvm::FunctionCallee createForStaticInitFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_for_static_init_* runtime function for the specified size IVSize and sign IVSigned...
Struct that keeps all the relevant information that should be kept throughout a 'target data' region...
QualType getTgtOffloadEntryQTy()
Returns __tgt_offload_entry type.
virtual void emitTargetDataStandAloneCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond, const Expr *Device)
Emit the data mapping/movement code associated with the directive D that should be of the form 'targe...
SmallVector< const Expr *, 4 > PrivateVars
Represents a struct/union/class.
llvm::StringMap< llvm::WeakTrackingVH > EmittedNonTargetVariables
List of the global variables with their addresses that should not be emitted for the target...
bool HasEmittedTargetRegion
Flag for keeping track of weather a target region has been emitted.
virtual llvm::Function * emitParallelOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen)
Emits outlined function for the specified OpenMP parallel directive D.
~CGOpenMPSIMDRuntime() override
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param IfCond Not a nullptr if if clause was nullptr *otherwise *param Data Additional data for task generation like final list of privates etc *virtual void emitTaskLoopCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPLoopDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
virtual void emitMasterRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MasterOpGen, SourceLocation Loc)
Emits a master region.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
virtual void emitTargetCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond, const Expr *Device, llvm::function_ref< llvm::Value *(CodeGenFunction &CGF, const OMPLoopDirective &D)> SizeEmitter)
Emit the target offloading code associated with D.
virtual void emitForOrderedIterationEnd(CodeGenFunction &CGF, SourceLocation Loc, unsigned IVSize, bool IVSigned)
Call the appropriate runtime routine to notify that we finished iteration of the ordered loop with th...
SmallVector< const Expr *, 4 > LastprivateVars
virtual void emitDoacrossOrdered(CodeGenFunction &CGF, const OMPDependClause *C)
Emit code for doacross ordered directive with 'depend' clause.
Represents a member of a struct/union/class.
llvm::SmallDenseMap< CanonicalDeclPtr< const Decl >, SmallString< 16 > > DeclToUniqeName
bool isNontemporalDecl(const ValueDecl *VD) const
Checks if the VD variable is marked as nontemporal declaration in current context.
std::pair< llvm::Value *, llvm::Value * > getSizes(unsigned N) const
Returns the size of the reduction item (in chars and total number of elements in the item)...
OMPTargetGlobalVarEntryKind
Kind of the global variable entry..
virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const
Check if the specified ScheduleKind is dynamic.
Defines some OpenMP-specific enums and functions.
llvm::Type * getKmpc_MicroPointerTy()
Returns pointer to kmpc_micro type.
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc...
void setFlags(uint32_t NewFlags)
static bool classof(const OffloadEntryInfo *Info)
virtual bool emitTargetFunctions(GlobalDecl GD)
Emit the target regions enclosed in GD function definition or the function itself in case it is a val...
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
bool requiresDevicePointerInfo()
virtual void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D, ArrayRef< Expr *> NumIterations)
Emit initialization for doacross loop nesting support.
void emitUserDefinedMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit the function for the user defined mapper construct.
QualType TgtOffloadEntryQTy
Type struct __tgt_offload_entry{ void *addr; // Pointer to the offload entry info.
Manages list of nontemporal decls for the specified directive.
CharUnits - This is an opaque type for sizes expressed in character units.
virtual void emitTargetDataCalls(CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond, const Expr *Device, const RegionCodeGenTy &CodeGen, TargetDataInfo &Info)
Emit the target data mapping code associated with D.
llvm::ArrayType * getKmpCriticalNameTy() const
Get the LLVM type for the critical name.
llvm::StringSet ThreadPrivateWithDefinition
Set of threadprivate variables with the generated initializer.
virtual std::pair< llvm::Function *, llvm::Function * > getUserDefinedReduction(const OMPDeclareReductionDecl *D)
Get combiner/initializer for the specified user-defined reduction, if any.
SmallVector< const Expr *, 4 > PrivateCopies
Base class of the entries info.
virtual void emitDeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn)
Marks function Fn with properly mangled versions of vector functions.
SmallVector< const Expr *, 4 > FirstprivateCopies
virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D)
Emits OpenMP-specific function prolog.
const VarDecl * getBaseDecl(unsigned N) const
Returns the base declaration of the reduction item.
SmallVector< const Expr *, 4 > ReductionOps
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
SmallVector< const Expr *, 4 > ReductionVars
virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS)
Checks if the variable has associated OMPAllocateDeclAttr attribute with the predefined allocator and...
virtual void emitForStaticFinish(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind DKind)
Call the appropriate runtime routine to notify that we finished all the work with current loop...
virtual bool emitDeclareVariant(GlobalDecl GD, bool IsForDefinition)
Emits the definition of the declare variant function.
void emitTargetNumIterationsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, llvm::Value *DeviceID, llvm::function_ref< llvm::Value *(CodeGenFunction &CGF, const OMPLoopDirective &D)> SizeEmitter)
Emit code that pushes the trip count of loops associated with constructs 'target teams distribute' an...
virtual Address getParameterAddress(CodeGenFunction &CGF, const VarDecl *NativeParam, const VarDecl *TargetParam) const
Gets the address of the native argument basing on the address of the target-specific parameter...
TargetDataInfo(bool RequiresDevicePointerInfo)
Class intended to support codegen of all kind of the reduction clauses.
llvm::FunctionCallee createRuntimeFunction(unsigned Function)
Returns specified OpenMP runtime function.
void setVarSize(CharUnits Size)
This represents '#pragma omp requires...' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
virtual unsigned getDefaultFirstprivateAddressSpace() const
Returns default address space for the constant firstprivates, 0 by default.
void emitDeferredTargetDecls() const
Emit deferred declare target variables marked for deferred emission.
virtual void emitTaskReductionFixups(CodeGenFunction &CGF, SourceLocation Loc, ReductionCodeGen &RCG, unsigned N)
Required to resolve existing problems in the runtime.
virtual void emitFlush(CodeGenFunction &CGF, ArrayRef< const Expr *> Vars, SourceLocation Loc)
Emit flush of the variables specified in 'omp flush' directive.
OffloadEntryInfo(OffloadingEntryInfoKinds Kind, unsigned Order, uint32_t Flags)
RegionCodeGenTy(Callable &&CodeGen, typename std::enable_if< !std::is_same< typename std::remove_reference< Callable >::type, RegionCodeGenTy >::value >::type *=nullptr)
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
void loadOffloadInfoMetadata()
Loads all the offload entries information from the host IR metadata.
void emitKmpRoutineEntryT(QualType KmpInt32Ty)
Build type kmp_routine_entry_t (if not built yet).
virtual const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const
Translates the native parameter of outlined function if this is required for target.
QualType SavedKmpTaskloopTQTy
Saved kmp_task_t for taskloop-based directive.
virtual ~CGOpenMPRuntime()
virtual bool isStaticNonchunked(OpenMPDistScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static non-chunked.
llvm::FunctionCallee createDispatchNextFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_dispatch_next_* runtime function for the specified size IVSize and sign IVSigned...
CGOpenMPRuntime(CodeGenModule &CGM)
void clearArrayInfo()
Clear information about the data arrays.
llvm::SmallDenseSet< CanonicalDeclPtr< const Decl > > NontemporalDeclsSet
SmallVector< const Expr *, 4 > FirstprivateVars
virtual Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc)
Returns address of the threadprivate variable for the current thread.
virtual bool isStaticChunked(OpenMPDistScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static non-chunked.
virtual void emitProcBindClause(CodeGenFunction &CGF, llvm::omp::ProcBindKind ProcBind, SourceLocation Loc)
Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32 global_tid, int proc_bind) to generat...
virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr)
Emits a critical region.
GlobalDecl - represents a global declaration.
virtual bool emitTargetGlobalVariable(GlobalDecl GD)
Emit the global variable if it is a valid device global variable.
QualType KmpDependInfoTy
Type typedef struct kmp_depend_info { kmp_intptr_t base_addr; size_t len; struct { bool in:1; bool ou...
virtual ~PrePostActionTy()
virtual Address getAddrOfDeclareTargetVar(const VarDecl *VD)
Returns the address of the variable marked as declare target with link clause OR as declare target wi...
Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) override
Gets the OpenMP-specific address of the local variable.
virtual void registerTargetGlobalVariable(const VarDecl *VD, llvm::Constant *Addr)
Checks if the provided global decl GD is a declare target variable and registers it when emitting cod...
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
llvm::Function * emitRequiresDirectiveRegFun()
Creates and returns a registration function for when at least one requires directives was used in the...
static bool classof(const OffloadEntryInfo *Info)
Encodes a location in the source.
llvm::FunctionCallee createDispatchFiniFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_dispatch_fini_* runtime function for the specified size IVSize and sign IVSigned...
This represents '#pragma omp declare reduction ...' directive.
llvm::PointerIntPair< llvm::Value *, 1, bool > Final
virtual void emitSingleRegion(CodeGenFunction &CGF, const RegionCodeGenTy &SingleOpGen, SourceLocation Loc, ArrayRef< const Expr *> CopyprivateVars, ArrayRef< const Expr *> DestExprs, ArrayRef< const Expr *> SrcExprs, ArrayRef< const Expr *> AssignmentOps)
Emits a single region.
virtual void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams, const Expr *ThreadLimit, SourceLocation Loc)
Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_teams...
This is a basic class for representing single OpenMP executable directive.
virtual void emitCancellationPointCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancellation point' construct.
virtual llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr)
Emit a code for initialization of threadprivate variable.
Target region entries info.
This file defines OpenMP nodes for declarative directives.
Device global variable entries info.
virtual void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value *> CapturedVars, const Expr *IfCond)
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
virtual void emitLastprivateConditionalFinalUpdate(CodeGenFunction &CGF, LValue PrivLVal, const VarDecl *VD, SourceLocation Loc)
Gets the address of the global copy used for lastprivate conditional update, if any.
Maps the expression for the lastprivate variable to the global copy used to store new value because o...
unsigned size() const
Return number of entries defined so far.
virtual void Enter(CodeGenFunction &CGF)
llvm::FunctionCallee createDispatchInitFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_dispatch_init_* runtime function for the specified size IVSize and sign IVSigned...
OffloadEntryInfo(OffloadingEntryInfoKinds Kind)
bool hasDeviceGlobalVarEntryInfo(StringRef VarName) const
Checks if the variable with the given name has been registered already.
void emitThreadPrivateVarInit(CodeGenFunction &CGF, Address VDAddr, llvm::Value *Ctor, llvm::Value *CopyCtor, llvm::Value *Dtor, SourceLocation Loc)
Emits initialization code for the threadprivate variables.
virtual void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc)
Emits code for a taskyield directive.
OffloadEntryInfoDeviceGlobalVar(unsigned Order, llvm::Constant *Addr, CharUnits VarSize, OMPTargetGlobalVarEntryKind Flags, llvm::GlobalValue::LinkageTypes Linkage)
virtual void functionFinished(CodeGenFunction &CGF)
Cleans up references to the objects in finished function.
virtual void emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::FunctionCallee OutlinedFn, ArrayRef< llvm::Value *> Args=llvm::None) const
Emits call of the outlined function with the provided arguments, translating these arguments to corre...
const Expr * getRefExpr(unsigned N) const
Returns the base declaration of the reduction item.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
void setAction(PrePostActionTy &Action) const
This class organizes the cross-function state that is used while generating LLVM code.
Optional< types::ID > Type
Dataflow Directional Tag Classes.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param IfCond Not a nullptr if if clause was nullptr *otherwise *param Data Additional data for task generation like final list of privates etc *virtual void emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPExecutableDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data)
static std::string getName(const CallEvent &Call)
OffloadEntryInfoTargetRegion(unsigned Order, llvm::Constant *Addr, llvm::Constant *ID, OMPTargetRegionEntryKind Flags)
virtual bool emitTargetGlobal(GlobalDecl GD)
Emit the global GD if it is meaningful for the target.
virtual void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc, const Expr *IfCond, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancel' construct.
A basic class for pre|post-action for advanced codegen sequence for OpenMP region.
LValue getSharedLValue(unsigned N) const
Returns LValue for the reduction item.
unsigned getOrder() const
llvm::PointerIntPair< llvm::Value *, 1, bool > Priority
void emitUDMapperArrayInitOrDel(CodeGenFunction &MapperCGF, llvm::Value *Handle, llvm::Value *BasePtr, llvm::Value *Ptr, llvm::Value *Size, llvm::Value *MapType, CharUnits ElementSize, llvm::BasicBlock *ExitBB, bool IsInit)
Emit the array initialization or deletion portion for user-defined mapper code generation.
virtual void emitTargetOutlinedFunction(const OMPExecutableDirective &D, StringRef ParentName, llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID, bool IsOffloadEntry, const RegionCodeGenTy &CodeGen)
Emit outilined function for 'target' directive.
virtual bool isDefaultLocationConstant() const
Check if the default location must be constant.
OffloadEntriesInfoManagerTy OffloadEntriesInfoManager
llvm::DenseSet< CanonicalDeclPtr< const Decl > > AlreadyEmittedTargetDecls
List of the emitted declarations.
CGOpenMPSIMDRuntime(CodeGenModule &CGM)
virtual bool emitDeclareTargetVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Addr, bool PerformInit)
Emit a code for initialization of declare target variable.
virtual void emitTeamsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value *> CapturedVars)
Emits code for teams call of the OutlinedFn with variables captured in a record which address is stor...
static bool classof(const OffloadEntryInfo *Info)
virtual void emitDistributeStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDistScheduleClauseKind SchedKind, const StaticRTInput &Values)
virtual StringRef getOutlinedHelperName() const
Get the function name of an outlined region.
bool HasEmittedDeclareTargetRegion
Flag for keeping track of weather a device routine has been emitted.
virtual void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads)
Emit an ordered region.
virtual void checkAndEmitLastprivateConditional(CodeGenFunction &CGF, const Expr *LHS)
Checks if the provided LVal is lastprivate conditional and emits the code to update the value of the ...
virtual void emitInlinedDirective(CodeGenFunction &CGF, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen, bool HasCancel=false)
Emit code for the directive that does not require outlining.
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Entity that registers the offloading constants that were emitted so far.
llvm::Constant * getOrCreateInternalVariable(llvm::Type *Ty, const llvm::Twine &Name, unsigned AddressSpace=0)
Gets (if variable with the given name already exist) or creates internal global variable with the spe...
llvm::function_ref< void(StringRef, const OffloadEntryInfoDeviceGlobalVar &)> OffloadDeviceGlobalVarEntryInfoActTy
Applies action Action on all registered entries.
llvm::Constant * registerTargetFirstprivateCopy(CodeGenFunction &CGF, const VarDecl *VD)
Registers provided target firstprivate variable as global on the target.
virtual void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc)
Emit a taskgroup region.
virtual void adjustTargetSpecificDataForLambdas(CodeGenFunction &CGF, const OMPExecutableDirective &D) const
Adjust some parameters for the target-based directives, like addresses of the variables captured by r...
virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc, ArrayRef< const Expr *> Privates, ArrayRef< const Expr *> LHSExprs, ArrayRef< const Expr *> RHSExprs, ArrayRef< const Expr *> ReductionOps, ReductionOptionsTy Options)
Emit a code for reduction clause.
Defines the clang::SourceLocation class and associated facilities.
llvm::PointerIntPair< llvm::Value *, 1, bool > Schedule
void setID(llvm::Constant *V)
Privates[]
Gets the list of initial values for linear variables.
virtual llvm::Function * emitTeamsOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen)
Emits outlined function for the specified OpenMP teams directive D.
ASTImporterLookupTable & LT
This represents '#pragma omp declare mapper ...' directive.
virtual void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false)
Emit an implicit/explicit barrier for OpenMP threads.
llvm::Constant * getAddress() const
virtual void emitForDispatchInit(CodeGenFunction &CGF, SourceLocation Loc, const OpenMPScheduleTy &ScheduleKind, unsigned IVSize, bool IVSigned, bool Ordered, const DispatchRTInput &DispatchValues)
Call the appropriate runtime routine to initialize it before start of loop.
CharUnits getVarSize() const
llvm::MapVector< CanonicalDeclPtr< const FunctionDecl >, std::pair< GlobalDecl, GlobalDecl > > DeferredVariantFunction
Mapping of the original functions to their variants and original global decl.
A reference to a declared variable, function, enum, etc.
virtual void emitForStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind DKind, const OpenMPScheduleTy &ScheduleKind, const StaticRTInput &Values)
Call the appropriate runtime routine to initialize it before start of loop.
bool HasRequiresUnifiedSharedMemory
Flag for keeping track of weather a requires unified_shared_memory directive is present.
QualType KmpDimTy
struct kmp_dim { // loop bounds info casted to kmp_int64 kmp_int64 lo; // lower kmp_int64 up; // uppe...
void setLinkage(llvm::GlobalValue::LinkageTypes LT)
LValue - This represents an lvalue references.
virtual unsigned getDefaultLocationReserved2Flags() const
Returns additional flags that can be stored in reserved_2 field of the default location.
virtual void getDefaultDistScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind, llvm::Value *&Chunk) const
Choose default schedule type and chunk value for the dist_schedule clause.
QualType SavedKmpTaskTQTy
Saved kmp_task_t for task directive.
virtual Address getTaskReductionItem(CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *ReductionsPtr, LValue SharedLVal)
Get the address of void * type of the privatue copy of the reduction item specified by the SharedLVal...
virtual void getDefaultScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind, const Expr *&ChunkExpr) const
Choose default schedule type and chunk value for the schedule clause.
llvm::StringSet DeclareTargetWithDefinition
Set of declare target variables with the generated initializer.
OffloadEntryInfoDeviceGlobalVar()
virtual llvm::Function * emitTaskOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, const VarDecl *PartIDVar, const VarDecl *TaskTVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen, bool Tied, unsigned &NumberOfParts)
Emits outlined function for the OpenMP task directive D.
virtual void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc)
Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_threads)...
SmallVector< const Expr *, 4 > FirstprivateInits
llvm::Constant * getOrCreateThreadPrivateCache(const VarDecl *VD)
If the specified mangled name is not in the module, create and return threadprivate cache object...
virtual void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc)
Emit code for 'taskwait' directive.