14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H 15 #define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H 22 #include "llvm/ADT/DenseMap.h" 23 #include "llvm/ADT/StringMap.h" 24 #include "llvm/ADT/StringSet.h" 25 #include "llvm/IR/Function.h" 26 #include "llvm/IR/ValueHandle.h" 42 class OMPExecutableDirective;
43 class OMPLoopDirective;
45 class OMPDeclareReductionDecl;
50 class CodeGenFunction;
72 template <
typename Callable>
73 static void CallbackFn(intptr_t CodeGen, CodeGenFunction &CGF,
75 return (*reinterpret_cast<Callable *>(CodeGen))(CGF, Action);
79 template <
typename Callable>
82 typename std::enable_if<
85 : CodeGen(reinterpret_cast<intptr_t>(&CodeGen)),
86 Callback(CallbackFn<typename
std::remove_reference<Callable>::
type>),
87 PrePostAction(nullptr) {}
89 void operator()(CodeGenFunction &CGF)
const;
104 llvm::PointerIntPair<llvm::Value *, 1, bool>
Final;
105 llvm::PointerIntPair<llvm::Value *, 1, bool>
Schedule;
106 llvm::PointerIntPair<llvm::Value *, 1, bool>
Priority;
108 unsigned NumberOfParts = 0;
110 bool Nogroup =
false;
117 struct ReductionData {
119 const Expr *Ref =
nullptr;
121 const Expr *Private =
nullptr;
123 const Expr *ReductionOp =
nullptr;
124 ReductionData(
const Expr *Ref,
const Expr *Private,
const Expr *ReductionOp)
125 : Ref(Ref), Private(Private), ReductionOp(ReductionOp) {}
175 bool needCleanups(
unsigned N);
190 std::pair<llvm::Value *, llvm::Value *>
getSizes(
unsigned N)
const {
199 bool usesReductionInitializer(
unsigned N)
const;
208 bool SavedShouldMarkAsGlobal;
221 StringRef Separator);
225 virtual void createOffloadEntry(llvm::Constant *
ID, llvm::Constant *Addr,
226 uint64_t Size, int32_t Flags,
227 llvm::GlobalValue::LinkageTypes
Linkage);
239 StringRef ParentName,
240 llvm::Function *&OutlinedFn,
241 llvm::Constant *&OutlinedFnID,
263 llvm::Type *getIdentTyPointerTy();
283 bool AtCurrentPoint =
false);
306 llvm::Value *getCriticalRegionLock(StringRef CriticalName);
311 llvm::Constant *DefaultOpenMPPSource =
nullptr;
312 using FlagsTy = std::pair<unsigned, unsigned>;
314 using OpenMPDefaultLocMapTy = llvm::DenseMap<FlagsTy, llvm::Value *>;
315 OpenMPDefaultLocMapTy OpenMPDefaultLocMap;
316 Address getOrCreateDefaultLocation(
unsigned Flags);
319 llvm::StructType *IdentTy =
nullptr;
321 typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy;
322 OpenMPDebugLocMapTy OpenMPDebugLocMap;
326 llvm::FunctionType *Kmpc_MicroTy =
nullptr;
328 struct DebugLocThreadIdTy {
332 llvm::AssertingVH<llvm::Instruction> ServiceInsertPt =
nullptr;
335 typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy>
336 OpenMPLocThreadIDMapTy;
337 OpenMPLocThreadIDMapTy OpenMPLocThreadIDMap;
340 std::pair<llvm::Function *, llvm::Function *>>
344 typedef llvm::DenseMap<llvm::Function *,
347 FunctionUDRMapTy FunctionUDRMap;
350 llvm::ArrayType *KmpCriticalNameTy;
356 llvm::StringMap<llvm::AssertingVH<llvm::Constant>, llvm::BumpPtrAllocator>
359 llvm::Type *KmpRoutineEntryPtrTy =
nullptr;
424 unsigned OffloadingEntriesNum = 0;
433 OffloadingEntryInfoTargetRegion = 0,
435 OffloadingEntryInfoDeviceGlobalVar = 1,
437 OffloadingEntryInfoInvalid = ~0u
445 : Flags(Flags), Order(Order), Kind(Kind) {}
453 void setFlags(uint32_t NewFlags) { Flags = NewFlags; }
455 return cast_or_null<llvm::Constant>(Addr);
458 assert(!Addr.pointsToAliveValue() &&
"Address has been set before!");
465 llvm::WeakTrackingVH Addr;
471 unsigned Order = ~0u;
479 unsigned size()
const {
return OffloadingEntriesNum; }
489 OMPTargetRegionEntryTargetRegion = 0x0,
491 OMPTargetRegionEntryCtor = 0x02,
493 OMPTargetRegionEntryDtor = 0x04,
499 llvm::Constant *
ID =
nullptr;
505 llvm::Constant *Addr,
515 assert(!ID &&
"ID has been set before!");
519 return Info->
getKind() == OffloadingEntryInfoTargetRegion;
524 void initializeTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
525 StringRef ParentName,
unsigned LineNum,
528 void registerTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
529 StringRef ParentName,
unsigned LineNum,
530 llvm::Constant *Addr, llvm::Constant *
ID,
534 bool hasTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
535 StringRef ParentName,
unsigned LineNum)
const;
537 typedef llvm::function_ref<void(
unsigned,
unsigned, StringRef,
unsigned,
540 void actOnTargetRegionEntriesInfo(
550 OMPTargetGlobalVarEntryTo = 0x0,
552 OMPTargetGlobalVarEntryLink = 0x1,
559 llvm::GlobalValue::LinkageTypes
Linkage;
568 unsigned Order, llvm::Constant *Addr,
CharUnits VarSize,
570 llvm::GlobalValue::LinkageTypes Linkage)
572 VarSize(VarSize), Linkage(Linkage) {
581 return Info->
getKind() == OffloadingEntryInfoDeviceGlobalVar;
586 void initializeDeviceGlobalVarEntryInfo(StringRef Name,
592 registerDeviceGlobalVarEntryInfo(StringRef VarName, llvm::Constant *Addr,
595 llvm::GlobalValue::LinkageTypes
Linkage);
598 return OffloadEntriesDeviceGlobalVar.count(VarName) > 0;
601 typedef llvm::function_ref<void(StringRef,
604 void actOnDeviceGlobalVarEntriesInfo(
610 typedef llvm::DenseMap<unsigned, OffloadEntryInfoTargetRegion>
611 OffloadEntriesTargetRegionPerLine;
612 typedef llvm::StringMap<OffloadEntriesTargetRegionPerLine>
613 OffloadEntriesTargetRegionPerParentName;
614 typedef llvm::DenseMap<unsigned, OffloadEntriesTargetRegionPerParentName>
615 OffloadEntriesTargetRegionPerFile;
616 typedef llvm::DenseMap<unsigned, OffloadEntriesTargetRegionPerFile>
617 OffloadEntriesTargetRegionPerDevice;
618 typedef OffloadEntriesTargetRegionPerDevice OffloadEntriesTargetRegionTy;
619 OffloadEntriesTargetRegionTy OffloadEntriesTargetRegion;
622 typedef llvm::StringMap<OffloadEntryInfoDeviceGlobalVar>
623 OffloadEntriesDeviceGlobalVarTy;
624 OffloadEntriesDeviceGlobalVarTy OffloadEntriesDeviceGlobalVar;
707 const llvm::Twine &Name);
764 virtual void clear();
771 const OMPDeclareReductionDecl *D);
773 virtual std::pair<llvm::Function *, llvm::Function *>
819 bool Tied,
unsigned &NumberOfParts);
848 const Expr *Hint =
nullptr);
895 bool EmitChecks =
true,
896 bool ForceSimpleCall =
false);
945 : LB(LB), UB(UB), Chunk(Chunk) {}
969 unsigned IVSize,
bool IVSigned,
bool Ordered,
977 bool IVSigned =
false;
979 bool Ordered =
false;
998 : IVSize(IVSize), IVSigned(IVSigned), Ordered(Ordered), IL(IL), LB(LB),
999 UB(UB), ST(ST), Chunk(Chunk) {}
1069 unsigned IVSize,
bool IVSigned,
1110 virtual llvm::Function *
1120 llvm::GlobalVariable *Addr,
1213 bool HasCancel =
false);
1223 llvm::Type *ArgsType,
1231 const Expr *ReductionOp,
1232 const Expr *PrivateRef,
1365 StringRef ParentName,
1366 llvm::Function *&OutlinedFn,
1367 llvm::Constant *&OutlinedFnID,
1368 bool IsOffloadEntry,
1394 const Expr *Device);
1410 llvm::Constant *Addr);
1447 bool RequiresDevicePointerInfo =
false;
1459 unsigned NumberOfPtrs = 0u;
1466 : RequiresDevicePointerInfo(RequiresDevicePointerInfo) {}
1469 BasePointersArray =
nullptr;
1470 PointersArray =
nullptr;
1471 SizesArray =
nullptr;
1472 MapTypesArray =
nullptr;
1477 return BasePointersArray && PointersArray && SizesArray &&
1478 MapTypesArray && NumberOfPtrs;
1493 const Expr *IfCond,
const Expr *Device,
1507 const Expr *Device);
1514 llvm::Function *Fn);
1531 const VarDecl *NativeParam)
const {
1541 const VarDecl *TargetParam)
const;
1553 const Expr *&ChunkExpr)
const {}
1607 const RegionCodeGenTy &CodeGen)
override;
1621 const RegionCodeGenTy &CodeGen)
override;
1642 bool Tied,
unsigned &NumberOfParts)
override;
1657 const Expr *IfCond)
override;
1665 const RegionCodeGenTy &CriticalOpGen,
1667 const Expr *Hint =
nullptr)
override;
1673 const RegionCodeGenTy &MasterOpGen,
1683 const RegionCodeGenTy &TaskgroupOpGen,
1700 const RegionCodeGenTy &OrderedOpGen,
1713 bool ForceSimpleCall =
false)
override;
1733 unsigned IVSize,
bool IVSigned,
bool Ordered,
1734 const DispatchRTInput &DispatchValues)
override;
1754 const StaticRTInput &Values)
override;
1764 const StaticRTInput &Values)
override;
1775 unsigned IVSize,
bool IVSigned)
override;
1802 unsigned IVSize,
bool IVSigned, Address IL,
1803 Address LB, Address UB, Address ST)
override;
1838 CodeGenFunction *CGF =
nullptr)
override;
1846 StringRef Name)
override;
1882 QualType SharedsTy, Address Shareds,
const Expr *IfCond,
1883 const OMPTaskDataTy &Data)
override;
1916 QualType SharedsTy, Address Shareds,
const Expr *IfCond,
1917 const OMPTaskDataTy &Data)
override;
1966 ReductionOptionsTy Options)
override;
1991 const OMPTaskDataTy &Data)
override;
2001 ReductionCodeGen &RCG,
unsigned N)
override;
2010 LValue SharedLVal)
override;
2041 StringRef ParentName,
2042 llvm::Function *&OutlinedFn,
2043 llvm::Constant *&OutlinedFnID,
2044 bool IsOffloadEntry,
2045 const RegionCodeGenTy &CodeGen)
override;
2059 const Expr *IfCond,
const Expr *Device)
override;
2112 const Expr *Device,
const RegionCodeGenTy &CodeGen,
2113 TargetDataInfo &Info)
override;
2125 const Expr *Device)
override;
2142 const VarDecl *NativeParam)
const override;
2149 const VarDecl *TargetParam)
const override;
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.
void setAddress(llvm::Constant *V)
virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable.
QualType TgtDeviceImageQTy
struct __tgt_device_image{ void *ImageStart; // Pointer to the target code start. ...
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::Constant * getID() const
void emitSingleReductionCombiner(CodeGenFunction &CGF, const Expr *ReductionOp, const Expr *PrivateRef, const DeclRefExpr *LHS, const DeclRefExpr *RHS)
Emits single reduction combiner.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
QualType getTgtBinaryDescriptorQTy()
Returns __tgt_bin_desc type.
SmallVector< std::pair< OpenMPDependClauseKind, const Expr * >, 4 > Dependences
SmallVector< const Expr *, 4 > LastprivateCopies
Decl - This represents one declaration (or definition), e.g.
llvm::Constant * getOrCreateInternalVariable(llvm::Type *Ty, const llvm::Twine &Name)
Gets (if variable with the given name already exist) or creates internal global variable with the spe...
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...
OffloadEntryInfoDeviceGlobalVar(unsigned Order, OMPTargetGlobalVarEntryKind Flags)
void scanForTargetRegionsFunctions(const Stmt *S, StringRef ParentName)
Start scanning from statement S and and emit all target regions found along the way.
virtual void checkArchForUnifiedAddressing(CodeGenModule &CGM, const OMPRequiresDecl *D) const
Perform check on requires decl to ensure that target architecture supports unified addressing...
SmallVector< const Expr *, 4 > ReductionCopies
Represents a variable declaration or definition.
virtual void emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *OutlinedFn, ArrayRef< llvm::Value *> Args=llvm::None) const
Emits call of the outlined function with the provided arguments, translating these arguments to corre...
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...
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...
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
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...
~CGOpenMPSIMDRuntime() override
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.
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.
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.
virtual void emitTargetCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, llvm::Value *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond, const Expr *Device)
Emit the target offloading code associated with D.
QualType TgtOffloadEntryQTy
Type struct __tgt_offload_entry{ void *addr; // Pointer to the offload entry info.
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.
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::Value *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data)
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
llvm::StringSet AlreadyEmittedTargetFunctions
List of the emitted functions.
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.
virtual void emitTeamsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, SourceLocation Loc, llvm::Value *OutlinedFn, ArrayRef< llvm::Value *> CapturedVars)
Emits code for teams call of the OutlinedFn with variables captured in a record which address is stor...
SmallVector< const Expr *, 4 > FirstprivateCopies
llvm::Value * emitReductionFunction(CodeGenModule &CGM, SourceLocation Loc, llvm::Type *ArgsType, ArrayRef< const Expr *> Privates, ArrayRef< const Expr *> LHSExprs, ArrayRef< const Expr *> RHSExprs, ArrayRef< const Expr *> ReductionOps)
Emits reduction function.
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.
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
virtual llvm::Value * emitTeamsOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen)
Emits outlined function for the specified OpenMP teams directive D.
SmallVector< const Expr *, 4 > ReductionOps
SmallVector< const Expr *, 4 > ReductionVars
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 Address getAddrOfDeclareTargetLink(const VarDecl *VD)
Returns the address of the variable marked as declare target with link clause.
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...
llvm::Constant * createForStaticInitFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_for_static_init_* runtime function for the specified size IVSize and sign IVSigned...
TargetDataInfo(bool RequiresDevicePointerInfo)
Class intended to support codegen of all kind of the reduction clauses.
llvm::Constant * createDispatchFiniFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_dispatch_fini_* runtime function for the specified size IVSize and sign IVSigned...
void setVarSize(CharUnits Size)
This represents '#pragma omp requires...' directive.
QualType getTgtDeviceImageQTy()
Returns __tgt_device_image type.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
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)
This represents one expression.
virtual llvm::Value * emitParallelOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen)
Emits outlined function for the specified OpenMP parallel directive D.
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.
CGOpenMPRuntime(CodeGenModule &CGM)
void clearArrayInfo()
Clear information about the data arrays.
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.
OpenMPProcBindClauseKind
OpenMP attributes for 'proc_bind' clause.
llvm::Constant * createDispatchInitFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_dispatch_init_* runtime function for the specified size IVSize and sign IVSigned...
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...
QualType TgtBinaryDescriptorQTy
struct __tgt_bin_desc{ int32_t NumDevices; // Number of devices supported.
virtual ~PrePostActionTy()
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...
static bool classof(const OffloadEntryInfo *Info)
Encodes a location in the source.
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.
OpenMPDirectiveKind
OpenMP directives.
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 llvm::Value * 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.
unsigned size() const
Return number of entries defined so far.
virtual void Enter(CodeGenFunction &CGF)
OffloadEntryInfo(OffloadingEntryInfoKinds Kind)
virtual void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *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...
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 emitProcBindClause(CodeGenFunction &CGF, OpenMPProcBindClauseKind 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 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.
const Expr * getRefExpr(unsigned N) const
Returns the base declaration of the reduction item.
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::Value *TaskFunction, QualType SharedsTy, Address Shareds, const OMPTaskDataTy &Data)
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...
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
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::Value *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data)
llvm::Function * createOffloadingBinaryDescriptorRegistration()
Creates and registers offloading binary descriptor for the current compilation unit.
llvm::PointerIntPair< llvm::Value *, 1, bool > Priority
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
CGOpenMPSIMDRuntime(CodeGenModule &CGM)
virtual bool emitDeclareTargetVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Addr, bool PerformInit)
Emit a code for initialization of declare target variable.
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.
virtual void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads)
Emit an ordered region.
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::function_ref< void(StringRef, const OffloadEntryInfoDeviceGlobalVar &)> OffloadDeviceGlobalVarEntryInfoActTy
Applies action Action on all registered entries.
llvm::Constant * createDispatchNextFunction(unsigned IVSize, bool IVSigned)
Returns __kmpc_dispatch_next_* runtime function for the specified size IVSize and sign IVSigned...
virtual void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc)
Emit a taskgroup region.
virtual llvm::Function * emitRegistrationFunction()
Creates the offloading descriptor in the event any target region was emitted in the current module an...
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.
ASTImporterLookupTable & LT
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
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.
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::Constant * createRuntimeFunction(unsigned Function)
Returns specified OpenMP runtime function.
llvm::StringSet DeclareTargetWithDefinition
Set of declare target variables with the generated initializer.
OffloadEntryInfoDeviceGlobalVar()
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 emitTargetNumIterationsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *Device, const 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 void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc)
Emit code for 'taskwait' directive.