13 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H 14 #define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H 21 #include "llvm/ADT/DenseMap.h" 22 #include "llvm/ADT/StringMap.h" 23 #include "llvm/ADT/StringSet.h" 24 #include "llvm/IR/Function.h" 25 #include "llvm/IR/ValueHandle.h" 41 class OMPExecutableDirective;
42 class OMPLoopDirective;
44 class OMPDeclareReductionDecl;
49 class CodeGenFunction;
71 template <
typename Callable>
72 static void CallbackFn(intptr_t CodeGen, CodeGenFunction &CGF,
74 return (*reinterpret_cast<Callable *>(CodeGen))(CGF, Action);
78 template <
typename Callable>
81 typename std::enable_if<
84 : CodeGen(reinterpret_cast<intptr_t>(&CodeGen)),
85 Callback(CallbackFn<typename
std::remove_reference<Callable>::
type>),
86 PrePostAction(nullptr) {}
88 void operator()(CodeGenFunction &CGF)
const;
103 llvm::PointerIntPair<llvm::Value *, 1, bool>
Final;
104 llvm::PointerIntPair<llvm::Value *, 1, bool>
Schedule;
105 llvm::PointerIntPair<llvm::Value *, 1, bool>
Priority;
107 unsigned NumberOfParts = 0;
109 bool Nogroup =
false;
116 struct ReductionData {
118 const Expr *Ref =
nullptr;
120 const Expr *Private =
nullptr;
122 const Expr *ReductionOp =
nullptr;
123 ReductionData(
const Expr *Ref,
const Expr *Private,
const Expr *ReductionOp)
124 : Ref(Ref), Private(Private), ReductionOp(ReductionOp) {}
174 bool needCleanups(
unsigned N);
189 std::pair<llvm::Value *, llvm::Value *>
getSizes(
unsigned N)
const {
198 bool usesReductionInitializer(
unsigned N)
const;
207 bool SavedShouldMarkAsGlobal;
220 StringRef Separator);
224 virtual void createOffloadEntry(llvm::Constant *
ID, llvm::Constant *Addr,
225 uint64_t Size, int32_t Flags,
226 llvm::GlobalValue::LinkageTypes
Linkage);
238 StringRef ParentName,
239 llvm::Function *&OutlinedFn,
240 llvm::Constant *&OutlinedFnID,
262 llvm::Type *getIdentTyPointerTy();
275 llvm::FunctionCallee Callee,
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;
722 const llvm::Twine &Name,
723 unsigned AddressSpace = 0);
743 llvm::Function *TaskEntry =
nullptr;
773 llvm::Function *TaskFunction,
QualType SharedsTy,
784 virtual void clear();
796 const OMPDeclareReductionDecl *D);
798 virtual std::pair<llvm::Function *, llvm::Function *>
844 bool Tied,
unsigned &NumberOfParts);
861 llvm::Function *OutlinedFn,
873 const Expr *Hint =
nullptr);
920 bool EmitChecks =
true,
921 bool ForceSimpleCall =
false);
970 : LB(LB), UB(UB), Chunk(Chunk) {}
994 unsigned IVSize,
bool IVSigned,
bool Ordered,
1000 unsigned IVSize = 0;
1002 bool IVSigned =
false;
1004 bool Ordered =
false;
1023 : IVSize(IVSize), IVSigned(IVSigned), Ordered(Ordered), IL(IL), LB(LB),
1024 UB(UB), ST(ST), Chunk(Chunk) {}
1094 unsigned IVSize,
bool IVSigned,
1135 virtual llvm::Function *
1145 llvm::GlobalVariable *Addr,
1190 llvm::Function *TaskFunction,
QualType SharedsTy,
1225 llvm::Function *TaskFunction,
1239 bool HasCancel =
false);
1249 llvm::Type *ArgsType,
1257 const Expr *ReductionOp,
1258 const Expr *PrivateRef,
1391 StringRef ParentName,
1392 llvm::Function *&OutlinedFn,
1393 llvm::Constant *&OutlinedFnID,
1394 bool IsOffloadEntry,
1418 llvm::Function *OutlinedFn,
1420 const Expr *Device);
1436 llvm::Constant *Addr);
1482 bool RequiresDevicePointerInfo =
false;
1494 unsigned NumberOfPtrs = 0u;
1501 : RequiresDevicePointerInfo(RequiresDevicePointerInfo) {}
1504 BasePointersArray =
nullptr;
1505 PointersArray =
nullptr;
1506 SizesArray =
nullptr;
1507 MapTypesArray =
nullptr;
1512 return BasePointersArray && PointersArray && SizesArray &&
1513 MapTypesArray && NumberOfPtrs;
1528 const Expr *IfCond,
const Expr *Device,
1542 const Expr *Device);
1549 llvm::Function *Fn);
1566 const VarDecl *NativeParam)
const {
1576 const VarDecl *TargetParam)
const;
1588 const Expr *&ChunkExpr)
const;
1594 llvm::FunctionCallee OutlinedFn,
1649 const RegionCodeGenTy &CodeGen)
override;
1663 const RegionCodeGenTy &CodeGen)
override;
1684 bool Tied,
unsigned &NumberOfParts)
override;
1697 llvm::Function *OutlinedFn,
1699 const Expr *IfCond)
override;
1707 const RegionCodeGenTy &CriticalOpGen,
1709 const Expr *Hint =
nullptr)
override;
1715 const RegionCodeGenTy &MasterOpGen,
1725 const RegionCodeGenTy &TaskgroupOpGen,
1742 const RegionCodeGenTy &OrderedOpGen,
1755 bool ForceSimpleCall =
false)
override;
1775 unsigned IVSize,
bool IVSigned,
bool Ordered,
1776 const DispatchRTInput &DispatchValues)
override;
1796 const StaticRTInput &Values)
override;
1806 const StaticRTInput &Values)
override;
1817 unsigned IVSize,
bool IVSigned)
override;
1844 unsigned IVSize,
bool IVSigned, Address IL,
1845 Address LB, Address UB, Address ST)
override;
1880 CodeGenFunction *CGF =
nullptr)
override;
1888 StringRef Name)
override;
1924 llvm::Function *TaskFunction,
QualType SharedsTy,
1925 Address Shareds,
const Expr *IfCond,
1926 const OMPTaskDataTy &Data)
override;
1959 QualType SharedsTy, Address Shareds,
const Expr *IfCond,
1960 const OMPTaskDataTy &Data)
override;
2009 ReductionOptionsTy Options)
override;
2034 const OMPTaskDataTy &Data)
override;
2044 ReductionCodeGen &RCG,
unsigned N)
override;
2053 LValue SharedLVal)
override;
2084 StringRef ParentName,
2085 llvm::Function *&OutlinedFn,
2086 llvm::Constant *&OutlinedFnID,
2087 bool IsOffloadEntry,
2088 const RegionCodeGenTy &CodeGen)
override;
2101 llvm::Function *OutlinedFn,
llvm::Value *OutlinedFnID,
2102 const Expr *IfCond,
const Expr *Device)
override;
2155 const Expr *Device,
const RegionCodeGenTy &CodeGen,
2156 TargetDataInfo &Info)
override;
2168 const Expr *Device)
override;
2185 const VarDecl *NativeParam)
const override;
2192 const VarDecl *TargetParam)
const override;
2197 return Address::invalid();
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.
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)
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::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...
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.
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)
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.
virtual void emitTargetCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond, const Expr *Device)
Emit the target offloading code associated with D.
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 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.
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.
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.
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
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 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.
QualType getTgtDeviceImageQTy()
Returns __tgt_device_image type.
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)
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.
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.
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 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.
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 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...
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 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.
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::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.
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 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 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.
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
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.
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 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.