Go to the documentation of this file.
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/PointerIntPair.h"
24 #include "llvm/ADT/SmallPtrSet.h"
25 #include "llvm/ADT/StringMap.h"
26 #include "llvm/ADT/StringSet.h"
27 #include "llvm/Frontend/OpenMP/OMPConstants.h"
28 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
29 #include "llvm/IR/Function.h"
30 #include "llvm/IR/ValueHandle.h"
31 #include "llvm/Support/AtomicOrdering.h"
40 class OpenMPIRBuilder;
45 class OMPDependClause;
46 class OMPExecutableDirective;
47 class OMPLoopDirective;
49 class OMPDeclareReductionDecl;
53 class CodeGenFunction;
74 template <
typename Callable>
77 return (*
reinterpret_cast<Callable *
>(CodeGen))(CGF, Action);
81 template <
typename Callable>
84 std::enable_if_t<!std::is_same<std::remove_reference_t<Callable>,
86 : CodeGen(reinterpret_cast<
intptr_t>(&CodeGen)),
87 Callback(CallbackFn<
std::remove_reference_t<
Callable>>),
88 PrePostAction(nullptr) {}
115 llvm::PointerIntPair<llvm::Value *, 1, bool>
Final;
116 llvm::PointerIntPair<llvm::Value *, 1, bool>
Schedule;
117 llvm::PointerIntPair<llvm::Value *, 1, bool>
Priority;
130 struct ReductionData {
132 const Expr *Shared =
nullptr;
134 const Expr *Ref =
nullptr;
136 const Expr *Private =
nullptr;
138 const Expr *ReductionOp =
nullptr;
139 ReductionData(
const Expr *Shared,
const Expr *Ref,
const Expr *Private,
140 const Expr *ReductionOp)
141 : Shared(Shared), Ref(Ref), Private(Private), ReductionOp(ReductionOp) {
211 std::pair<llvm::Value *, llvm::Value *>
getSizes(
unsigned N)
const {
223 return cast<VarDecl>(cast<DeclRefExpr>(ClausesData[N].Private)->getDecl())
234 bool SavedShouldMarkAsGlobal;
244 const bool NeedToPush;
254 const bool NeedToPush;
260 std::pair<Address, Address>> &LocalVars);
274 llvm::Function *
Fn =
nullptr;
279 enum class ActionToDo {
281 PushAsLastprivateConditional,
282 DisableLastprivateConditional,
285 ActionToDo Action = ActionToDo::DoNotPush;
291 &NeedToAddForLPCsAsDisabled)
const;
322 llvm::GlobalValue::LinkageTypes
Linkage);
334 StringRef ParentName,
335 llvm::Function *&OutlinedFn,
336 llvm::Constant *&OutlinedFnID,
356 int32_t &DefaultVal);
370 int32_t &DefaultVal);
389 llvm::FunctionCallee Callee,
397 bool AtCurrentPoint =
false);
425 typedef llvm::DenseMap<SourceLocation, llvm::Value *> OpenMPDebugLocMapTy;
426 OpenMPDebugLocMapTy OpenMPDebugLocMap;
430 llvm::FunctionType *Kmpc_MicroTy =
nullptr;
432 struct DebugLocThreadIdTy {
433 llvm::Value *DebugLoc;
434 llvm::Value *ThreadID;
436 llvm::AssertingVH<llvm::Instruction> ServiceInsertPt =
nullptr;
439 typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy>
440 OpenMPLocThreadIDMapTy;
441 OpenMPLocThreadIDMapTy OpenMPLocThreadIDMap;
444 std::pair<llvm::Function *, llvm::Function *>>
448 typedef llvm::DenseMap<llvm::Function *,
451 FunctionUDRMapTy FunctionUDRMap;
454 llvm::DenseMap<const OMPDeclareMapperDecl *, llvm::Function *> UDMMap;
456 using FunctionUDMMapTy =
457 llvm::DenseMap<llvm::Function *,
459 FunctionUDMMapTy FunctionUDMMap;
462 llvm::DenseMap<llvm::Function *,
463 llvm::DenseMap<CanonicalDeclPtr<const Decl>,
466 LastprivateConditionalToTypes;
468 llvm::DenseMap<llvm::Function *, unsigned> FunctionToUntiedTaskStackMap;
471 llvm::ArrayType *KmpCriticalNameTy;
477 llvm::StringMap<llvm::AssertingVH<llvm::GlobalVariable>,
478 llvm::BumpPtrAllocator> InternalVars;
480 llvm::Type *KmpRoutineEntryPtrTy =
nullptr;
523 class OffloadEntriesInfoManagerTy {
527 unsigned OffloadingEntriesNum = 0;
548 : Flags(Flags), Order(Order), Kind(Kind) {}
556 void setFlags(uint32_t NewFlags) { Flags = NewFlags; }
558 return cast_or_null<llvm::Constant>(Addr);
561 assert(!Addr.pointsToAliveValue() &&
"Address has been set before!");
568 llvm::WeakTrackingVH Addr;
574 unsigned Order = ~0u;
582 unsigned size()
const {
return OffloadingEntriesNum; }
590 enum OMPTargetRegionEntryKind : uint32_t {
592 OMPTargetRegionEntryTargetRegion = 0x0,
594 OMPTargetRegionEntryCtor = 0x02,
596 OMPTargetRegionEntryDtor = 0x04,
602 llvm::Constant *ID =
nullptr;
608 llvm::Constant *Addr,
610 OMPTargetRegionEntryKind Flags)
616 llvm::Constant *
getID()
const {
return ID; }
618 assert(!ID &&
"ID has been set before!");
627 void initializeTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
628 StringRef ParentName,
unsigned LineNum,
631 void registerTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
632 StringRef ParentName,
unsigned LineNum,
633 llvm::Constant *Addr, llvm::Constant *
ID,
634 OMPTargetRegionEntryKind Flags);
637 bool hasTargetRegionEntryInfo(
unsigned DeviceID,
unsigned FileID,
638 StringRef ParentName,
unsigned LineNum,
639 bool IgnoreAddressId =
false)
const;
641 typedef llvm::function_ref<void(
unsigned,
unsigned, StringRef,
unsigned,
642 const OffloadEntryInfoTargetRegion &)>
643 OffloadTargetRegionEntryInfoActTy;
644 void actOnTargetRegionEntriesInfo(
645 const OffloadTargetRegionEntryInfoActTy &Action);
652 enum OMPTargetGlobalVarEntryKind : uint32_t {
654 OMPTargetGlobalVarEntryTo = 0x0,
656 OMPTargetGlobalVarEntryLink = 0x1,
663 llvm::GlobalValue::LinkageTypes
Linkage;
669 OMPTargetGlobalVarEntryKind Flags)
672 unsigned Order, llvm::Constant *Addr,
CharUnits VarSize,
673 OMPTargetGlobalVarEntryKind Flags,
674 llvm::GlobalValue::LinkageTypes
Linkage)
690 void initializeDeviceGlobalVarEntryInfo(StringRef Name,
691 OMPTargetGlobalVarEntryKind Flags,
696 registerDeviceGlobalVarEntryInfo(StringRef VarName, llvm::Constant *Addr,
698 OMPTargetGlobalVarEntryKind Flags,
699 llvm::GlobalValue::LinkageTypes
Linkage);
701 bool hasDeviceGlobalVarEntryInfo(StringRef VarName)
const {
702 return OffloadEntriesDeviceGlobalVar.count(VarName) > 0;
705 typedef llvm::function_ref<void(StringRef,
706 const OffloadEntryInfoDeviceGlobalVar &)>
707 OffloadDeviceGlobalVarEntryInfoActTy;
708 void actOnDeviceGlobalVarEntriesInfo(
709 const OffloadDeviceGlobalVarEntryInfoActTy &Action);
714 typedef llvm::DenseMap<unsigned, OffloadEntryInfoTargetRegion>
715 OffloadEntriesTargetRegionPerLine;
716 typedef llvm::StringMap<OffloadEntriesTargetRegionPerLine>
717 OffloadEntriesTargetRegionPerParentName;
718 typedef llvm::DenseMap<unsigned, OffloadEntriesTargetRegionPerParentName>
719 OffloadEntriesTargetRegionPerFile;
720 typedef llvm::DenseMap<unsigned, OffloadEntriesTargetRegionPerFile>
721 OffloadEntriesTargetRegionPerDevice;
722 typedef OffloadEntriesTargetRegionPerDevice OffloadEntriesTargetRegionTy;
723 OffloadEntriesTargetRegionTy OffloadEntriesTargetRegion;
726 typedef llvm::StringMap<OffloadEntryInfoDeviceGlobalVar>
727 OffloadEntriesDeviceGlobalVarTy;
728 OffloadEntriesDeviceGlobalVarTy OffloadEntriesDeviceGlobalVar;
730 OffloadEntriesInfoManagerTy OffloadEntriesInfoManager;
732 bool ShouldMarkAsGlobal =
true;
737 llvm::StringMap<llvm::WeakTrackingVH> EmittedNonTargetVariables;
741 llvm::SmallDenseSet<const VarDecl *> DeferredGlobalVariables;
743 using NontemporalDeclsSet = llvm::SmallDenseSet<CanonicalDeclPtr<const Decl>>;
748 using UntiedLocalVarsAddressesMap =
749 llvm::MapVector<CanonicalDeclPtr<const VarDecl>,
750 std::pair<Address, Address>>;
760 bool HasRequiresUnifiedSharedMemory =
false;
763 llvm::AtomicOrdering RequiresAtomicOrdering = llvm::AtomicOrdering::Monotonic;
766 bool HasEmittedTargetRegion =
false;
770 bool HasEmittedDeclareTargetRegion =
false;
774 void loadOffloadInfoMetadata();
780 void scanForTargetRegionsFunctions(
const Stmt *S, StringRef ParentName);
783 void emitKmpRoutineEntryT(
QualType KmpInt32Ty);
786 llvm::Type *getKmpc_MicroPointerTy();
791 llvm::FunctionCallee createForStaticInitFunction(
unsigned IVSize,
793 bool IsGPUDistribute);
797 llvm::FunctionCallee createDispatchInitFunction(
unsigned IVSize,
802 llvm::FunctionCallee createDispatchNextFunction(
unsigned IVSize,
807 llvm::FunctionCallee createDispatchFiniFunction(
unsigned IVSize,
815 llvm::Constant *getOrCreateThreadPrivateCache(
const VarDecl *VD);
823 llvm::GlobalVariable *getOrCreateInternalVariable(llvm::Type *Ty,
824 const llvm::Twine &Name,
825 unsigned AddressSpace = 0);
828 llvm::StringSet<> ThreadPrivateWithDefinition;
831 llvm::StringSet<> DeclareTargetWithDefinition;
839 void emitThreadPrivateVarInit(CodeGenFunction &CGF, Address VDAddr,
840 llvm::Value *Ctor, llvm::Value *CopyCtor,
845 void emitUDMapperArrayInitOrDel(CodeGenFunction &MapperCGF,
846 llvm::Value *Handle, llvm::Value *BasePtr,
847 llvm::Value *Ptr, llvm::Value *Size,
848 llvm::Value *MapType, llvm::Value *MapName,
850 llvm::BasicBlock *ExitBB,
bool IsInit);
852 struct TaskResultTy {
853 llvm::Value *NewTask =
nullptr;
854 llvm::Function *TaskEntry =
nullptr;
855 llvm::Value *NewTaskNewTaskTTy =
nullptr;
858 llvm::Value *TaskDupFn =
nullptr;
882 TaskResultTy emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
883 const OMPExecutableDirective &D,
884 llvm::Function *TaskFunction, QualType SharedsTy,
885 Address Shareds,
const OMPTaskDataTy &Data);
891 void emitTargetNumIterationsCall(
892 CodeGenFunction &CGF,
const OMPExecutableDirective &D,
893 llvm::Value *DeviceID,
894 llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
895 const OMPLoopDirective &D)>
899 void emitLastprivateConditionalUpdate(CodeGenFunction &CGF, LValue IVLVal,
900 StringRef UniqueDeclName, LValue LVal,
907 std::pair<llvm::Value *, LValue> getDepobjElements(CodeGenFunction &CGF,
911 SmallVector<llvm::Value *, 4>
912 emitDepobjElementsSizes(CodeGenFunction &CGF, QualType &KmpDependInfoTy,
913 const OMPTaskDataTy::DependData &Data);
915 void emitDepobjElements(CodeGenFunction &CGF, QualType &KmpDependInfoTy,
916 LValue PosLVal,
const OMPTaskDataTy::DependData &Data,
917 Address DependenciesArray);
923 virtual void clear();
948 virtual std::pair<llvm::Function *, llvm::Function *>
1002 bool Tied,
unsigned &NumberOfParts);
1021 llvm::Function *OutlinedFn,
1023 const Expr *IfCond, llvm::Value *NumThreads);
1033 const Expr *Hint =
nullptr);
1088 bool EmitChecks =
true,
1089 bool ForceSimpleCall =
false);
1097 bool Chunked)
const;
1105 bool Chunked)
const;
1112 bool Chunked)
const;
1119 bool Chunked)
const;
1130 llvm::Value *
LB =
nullptr;
1132 llvm::Value *
UB =
nullptr;
1162 unsigned IVSize,
bool IVSigned,
bool Ordered,
1163 const DispatchRTInput &DispatchValues);
1190 llvm::Value *
Chunk =
nullptr)
1212 const StaticRTInput &Values);
1223 const StaticRTInput &Values);
1262 unsigned IVSize,
bool IVSigned,
1271 llvm::Value *NumThreads,
1277 llvm::omp::ProcBindKind ProcBind,
1303 virtual llvm::Function *
1313 llvm::GlobalVariable *Addr,
1358 llvm::Function *TaskFunction,
QualType SharedsTy,
1393 llvm::Function *TaskFunction,
1407 bool HasCancel =
false);
1417 llvm::Type *ArgsElemType,
1425 const Expr *ReductionOp,
1426 const Expr *PrivateRef,
1531 bool IsWorksharingReduction);
1547 llvm::Value *ReductionsPtr,
1581 StringRef ParentName,
1582 llvm::Function *&OutlinedFn,
1583 llvm::Constant *&OutlinedFnID,
1584 bool IsOffloadEntry,
1601 llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID,
const Expr *IfCond,
1602 llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
1621 llvm::Constant *Addr);
1661 bool RequiresDevicePointerInfo =
false;
1664 bool SeparateBeginEndCalls =
false;
1696 bool SeparateBeginEndCalls)
1697 : RequiresDevicePointerInfo(RequiresDevicePointerInfo),
1698 SeparateBeginEndCalls(SeparateBeginEndCalls) {}
1730 const Expr *IfCond,
const Expr *Device,
1732 TargetDataInfo &Info);
1744 const Expr *Device);
1751 llvm::Function *Fn);
1768 const VarDecl *NativeParam)
const {
1778 const VarDecl *TargetParam)
const;
1784 llvm::Value *&Chunk)
const {}
1790 const Expr *&ChunkExpr)
const;
1796 llvm::FunctionCallee OutlinedFn,
1895 std::pair<llvm::Value *, Address>
1922 const Expr *AllocatorTraits);
1984 bool Tied,
unsigned &NumberOfParts)
override;
1999 llvm::Function *OutlinedFn,
2001 const Expr *IfCond, llvm::Value *NumThreads)
override;
2011 const Expr *Hint =
nullptr)
override;
2068 bool ForceSimpleCall =
false)
override;
2088 unsigned IVSize,
bool IVSigned,
bool Ordered,
2089 const DispatchRTInput &DispatchValues)
override;
2109 const StaticRTInput &Values)
override;
2119 const StaticRTInput &Values)
override;
2130 unsigned IVSize,
bool IVSigned)
override;
2157 unsigned IVSize,
bool IVSigned,
Address IL,
2170 llvm::omp::ProcBindKind ProcBind,
2201 StringRef Name)
override;
2237 llvm::Function *TaskFunction,
QualType SharedsTy,
2322 ReductionOptionsTy Options)
override;
2370 bool IsWorksharingReduction)
override;
2388 llvm::Value *ReductionsPtr,
2389 LValue SharedLVal)
override;
2421 StringRef ParentName,
2422 llvm::Function *&OutlinedFn,
2423 llvm::Constant *&OutlinedFnID,
2424 bool IsOffloadEntry,
2439 llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID,
const Expr *IfCond,
2440 llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
2443 SizeEmitter)
override;
2492 TargetDataInfo &Info)
override;
2504 const Expr *Device)
override;
2521 const VarDecl *NativeParam)
const override;
2528 const VarDecl *TargetParam)
const override;
SmallVector< const Expr *, 4 > ReductionOps
virtual void emitTaskLoopCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPLoopDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data)
Emit task region for the taskloop directive.
OffloadEntryInfoDeviceGlobalVar()
llvm::GlobalValue::LinkageTypes getLinkage() const
void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc, const Expr *IfCond, OpenMPDirectiveKind CancelRegion) override
Emit code for 'cancel' construct.
llvm::Value * BasePointersArray
The array of base pointer passed to the runtime library.
virtual void emitTaskReductionFini(CodeGenFunction &CGF, SourceLocation Loc, bool IsWorksharingReduction)
Emits the following code for reduction clause with task modifier:
YAML serialization mapping.
void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPTaskDataTy &Data) override
Emit code for 'taskwait' directive.
llvm::Value * getThreadID(CodeGenFunction &CGF, SourceLocation Loc)
Gets thread id value for the current thread.
virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable.
ASTImporterLookupTable & LT
bool IsReductionWithTaskMod
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.
const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const override
Translates the native parameter of outlined function if this is required for target.
CGOpenMPSIMDRuntime(CodeGenModule &CGM)
virtual void checkAndEmitSharedLastprivateConditional(CodeGenFunction &CGF, const OMPExecutableDirective &D, const llvm::DenseSet< CanonicalDeclPtr< const VarDecl >> &IgnoredDecls)
Checks if the lastprivate conditional was updated in inner region and writes the value.
const Expr * IteratorExpr
void emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPExecutableDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data) override
Emit task region for the task directive.
SmallVector< const Expr *, 4 > LastprivateVars
llvm::Value * PointersArray
The array of section pointers passed to the runtime library.
Maps the expression for the lastprivate variable to the global copy used to store new value because o...
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...
void emitSingleReductionCombiner(CodeGenFunction &CGF, const Expr *ReductionOp, const Expr *PrivateRef, const DeclRefExpr *LHS, const DeclRefExpr *RHS)
Emits single reduction combiner.
Address adjustPrivateAddress(CodeGenFunction &CGF, unsigned N, Address PrivateAddr)
Adjusts PrivatedAddr for using instead of the original variable address in normal operations.
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.
void emitTaskLoopCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPLoopDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data) override
Emit task region for the taskloop directive.
llvm::Value * MappersArray
The array of user-defined mappers passed to the runtime library.
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
llvm::Value * emitForNext(CodeGenFunction &CGF, SourceLocation Loc, unsigned IVSize, bool IVSigned, Address IL, Address LB, Address UB, Address ST) override
Call __kmpc_dispatch_next( ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter, kmp_int[32|64] *p_lowe...
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.
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...
void emitTargetDataStandAloneCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond, const Expr *Device) override
Emit the data mapping/movement code associated with the directive D that should be of the form 'targe...
void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D, ArrayRef< Expr * > NumIterations) override
Emit initialization for doacross loop nesting support.
void clearLocThreadIdInsertPt(CodeGenFunction &CGF)
Class intended to support codegen of all kind of the reduction clauses.
const Expr * getNumThreadsExprForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D, int32_t &DefaultVal)
Emit the number of threads for a target directive.
void emitTaskReductionFixups(CodeGenFunction &CGF, SourceLocation Loc, ReductionCodeGen &RCG, unsigned N) override
Required to resolve existing problems in the runtime.
Encodes a location in the source.
~OffloadEntryInfo()=default
CGOpenMPRuntime(CodeGenModule &CGM)
virtual void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars, const Expr *IfCond, llvm::Value *NumThreads)
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
void setLocThreadIdInsertPt(CodeGenFunction &CGF, bool AtCurrentPoint=false)
virtual void emitCancellationPointCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancellation point' construct.
const Expr * getNumTeamsExprForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D, int32_t &DefaultVal)
Emit the number of teams for a target directive.
llvm::Value * getCriticalRegionLock(StringRef CriticalName)
Returns corresponding lock object for the specified critical region name.
void emitForDispatchInit(CodeGenFunction &CGF, SourceLocation Loc, const OpenMPScheduleTy &ScheduleKind, unsigned IVSize, bool IVSigned, bool Ordered, const DispatchRTInput &DispatchValues) override
This is used for non static scheduled types and when the ordered clause is present on the loop constr...
A (possibly-)qualified type.
OpenMPDirectiveKind ReductionKind
virtual void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc)
Emits code for a taskyield directive.
bool separateBeginEndCalls()
void emitProcBindClause(CodeGenFunction &CGF, llvm::omp::ProcBindKind ProcBind, SourceLocation Loc) override
Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32 global_tid, int proc_bind) to generat...
Represents a member of a struct/union/class.
llvm::OpenMPIRBuilder OMPBuilder
An OpenMP-IR-Builder instance.
virtual void Exit(CodeGenFunction &CGF)
virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS)
Checks if the variable has associated OMPAllocateDeclAttr attribute with the predefined allocator and...
virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr)
Emits a critical region.
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.
Address emitDepobjDependClause(CodeGenFunction &CGF, const OMPTaskDataTy::DependData &Dependencies, SourceLocation Loc)
Emits list of dependecies based on the provided data (array of dependence/expression pairs) for depob...
NontemporalDeclsRAII(CodeGenModule &CGM, const OMPLoopDirective &S)
void emitTargetOutlinedFunction(const OMPExecutableDirective &D, StringRef ParentName, llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID, bool IsOffloadEntry, const RegionCodeGenTy &CodeGen) override
Emit outilined function for 'target' directive.
llvm::MapVector< CanonicalDeclPtr< const Decl >, SmallString< 16 > > DeclToUniqueName
~UntiedTaskLocalDeclsRAII()
llvm::Function * emitRequiresDirectiveRegFun()
Creates and returns a registration function for when at least one requires directives was used in the...
virtual void emitTaskReductionFixups(CodeGenFunction &CGF, SourceLocation Loc, ReductionCodeGen &RCG, unsigned N)
Required to resolve existing problems in the runtime.
virtual Address emitThreadIDAddress(CodeGenFunction &CGF, SourceLocation Loc)
Emits address of the word in a memory where current thread id is stored.
void setID(llvm::Constant *V)
llvm::PointerIntPair< llvm::Value *, 1, bool > Schedule
void operator()(CodeGenFunction &CGF) const
virtual bool emitTargetFunctions(GlobalDecl GD)
Emit the target regions enclosed in GD function definition or the function itself in case it is a val...
llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr) override
Emit a code for initialization of threadprivate variable.
void emitCancellationPointCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind CancelRegion) override
Emit code for 'cancellation point' construct.
virtual void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false)
Emit an implicit/explicit barrier for OpenMP threads.
virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const
Check if the specified ScheduleKind is dynamic.
~CGOpenMPSIMDRuntime() override
llvm::PointerIntPair< llvm::Value *, 1, bool > Final
static LastprivateConditionalRAII disable(CodeGenFunction &CGF, const OMPExecutableDirective &S)
llvm::AtomicOrdering getDefaultMemoryOrdering() const
Gets default memory ordering as specified in requires directive.
virtual void emitFlush(CodeGenFunction &CGF, ArrayRef< const Expr * > Vars, SourceLocation Loc, llvm::AtomicOrdering AO)
Emit flush of the variables specified in 'omp flush' directive.
virtual ~CGOpenMPRuntime()
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...
bool emitTargetGlobalVariable(GlobalDecl GD) override
Emit the global variable if it is a valid device global variable.
Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc) override
Returns address of the threadprivate variable for the current thread.
llvm::Value * MapTypesArrayEnd
The array of map types passed to the runtime library for the end of the region, or nullptr if there a...
OffloadingEntryInfoKinds
Kind of a given entry.
void emitCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::FunctionCallee Callee, ArrayRef< llvm::Value * > Args=llvm::None) const
Emits Callee function call with arguments Args with location Loc.
void setAddress(llvm::Constant *V)
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),...
GlobalDecl - represents a global declaration.
OffloadEntryInfoDeviceGlobalVar(unsigned Order, OMPTargetGlobalVarEntryKind Flags)
Struct that keeps all the relevant information that should be kept throughout a 'target data' region.
virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D)
Emits OpenMP-specific function prolog.
unsigned NumberOfPtrs
The total number of pointers passed to the runtime library.
llvm::PointerIntPair< llvm::Value *, 1, bool > Priority
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.
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...
virtual bool isStaticNonchunked(OpenMPScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static non-chunked.
llvm::OpenMPIRBuilder & getOMPBuilder()
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.
DependData(OpenMPDependClauseKind DepKind, const Expr *IteratorExpr)
void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal, SourceLocation Loc)
Emits the code to destroy the dependency object provided in depobj directive.
void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc) override
Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_threads)...
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...
void emitTargetDataCalls(CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond, const Expr *Device, const RegionCodeGenTy &CodeGen, TargetDataInfo &Info) override
Emit the target data mapping code associated with D.
This represents '#pragma omp declare reduction ...' directive.
const VarDecl * getBaseDecl(unsigned N) const
Returns the base declaration of the reduction item.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
SmallVector< DependData, 4 > Dependences
OffloadingEntryInfoKinds getKind() const
Base class of the entries info.
std::pair< llvm::Value *, Address > emitDependClause(CodeGenFunction &CGF, ArrayRef< OMPTaskDataTy::DependData > Dependencies, SourceLocation Loc)
Emits list of dependecies based on the provided data (array of dependence/expression pairs).
@ OffloadingEntryInfoDeviceGlobalVar
Entry is a declare target variable.
virtual void emitMaskedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc, const Expr *Filter=nullptr)
Emits a masked region.
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
OffloadEntryInfo(OffloadingEntryInfoKinds Kind, unsigned Order, uint32_t Flags)
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) override
Emits a single region.
void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams, const Expr *ThreadLimit, SourceLocation Loc) override
Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_teams,...
bool hasRequiresUnifiedSharedMemory() const
Return whether the unified_shared_memory has been specified.
SmallVector< CanonicalDeclPtr< const VarDecl >, 4 > PrivateLocals
void emitInitialization(CodeGenFunction &CGF, unsigned N, Address PrivateAddr, Address SharedAddr, llvm::function_ref< bool(CodeGenFunction &)> DefaultInit)
Performs initialization of the private copy for the reduction item.
virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective &D, StringRef ParentName, llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID, bool IsOffloadEntry, const RegionCodeGenTy &CodeGen)
Helper to emit outlined function for 'target' directive.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
unsigned getOrder() const
Device global variable entries info.
virtual unsigned getDefaultLocationReserved2Flags() const
Returns additional flags that can be stored in reserved_2 field of the default location.
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.
Address getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name) override
Creates artificial threadprivate variable with name Name and type VarType.
TargetDataInfo(bool RequiresDevicePointerInfo, bool SeparateBeginEndCalls)
bool emitTargetFunctions(GlobalDecl GD) override
Emit the target regions enclosed in GD function definition or the function itself in case it is a val...
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
virtual void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D, ArrayRef< Expr * > NumIterations)
Emit initialization for doacross loop nesting support.
ReductionCodeGen(ArrayRef< const Expr * > Shareds, ArrayRef< const Expr * > Origs, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > ReductionOps)
bool HasMapper
Indicate whether any user-defined mapper exists.
SmallVector< const Expr *, 4 > DepExprs
void emitFlush(CodeGenFunction &CGF, ArrayRef< const Expr * > Vars, SourceLocation Loc, llvm::AtomicOrdering AO) override
Emit flush of the variables specified in 'omp flush' directive.
void emitAggregateType(CodeGenFunction &CGF, unsigned N)
Emits the code for the variable-modified type, if required.
void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads) override
Emit an ordered region.
SmallVector< const Expr *, 4 > FirstprivateInits
virtual void emitInlinedDirective(CodeGenFunction &CGF, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen, bool HasCancel=false)
Emit code for the directive that does not require outlining.
static unsigned getDefaultFlagsForBarriers(OpenMPDirectiveKind Kind)
Returns default flags for the barriers depending on the directive, for which this barier is going to ...
virtual bool isStaticChunked(OpenMPScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static chunked.
bool IsWorksharingReduction
void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr) override
Emits a critical region.
Represents a variable declaration or definition.
OffloadEntryInfoDeviceGlobalVar(unsigned Order, llvm::Constant *Addr, CharUnits VarSize, OMPTargetGlobalVarEntryKind Flags, llvm::GlobalValue::LinkageTypes Linkage)
llvm::DenseMap< const ValueDecl *, Address > CaptureDeviceAddrMap
Map between the a declaration of a capture and the corresponding base pointer address where the runti...
void emitMasterRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MasterOpGen, SourceLocation Loc) override
Emits a master region.
This represents '#pragma omp declare mapper ...' directive.
void emitMaskedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc, const Expr *Filter=nullptr) override
Emits a masked region.
LValue getOrigLValue(unsigned N) const
Returns LValue for the original reduction item.
Address emitLastprivateConditionalInit(CodeGenFunction &CGF, const VarDecl *VD)
Create specialized alloca to handle lastprivate conditionals.
Manages list of lastprivate conditional decls for the specified directive.
virtual void emitMasterRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MasterOpGen, SourceLocation Loc)
Emits a master region.
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.
llvm::Type * getIdentTyPointerTy()
Returns pointer to ident_t type.
llvm::Value * emitNumThreadsForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D)
bool isNontemporalDecl(const ValueDecl *VD) const
Checks if the VD variable is marked as nontemporal declaration in current context.
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 ...
void emitForStaticFinish(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind DKind) override
Call the appropriate runtime routine to notify that we finished all the work with current loop.
DisableAutoDeclareTargetRAII(CodeGenModule &CGM)
SmallVector< const Expr *, 4 > ReductionCopies
Address getTaskReductionItem(CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *ReductionsPtr, LValue SharedLVal) override
Get the address of void * type of the privatue copy of the reduction item specified by the SharedLVal...
llvm::Value * emitTaskReductionInit(CodeGenFunction &CGF, SourceLocation Loc, ArrayRef< const Expr * > LHSExprs, ArrayRef< const Expr * > RHSExprs, const OMPTaskDataTy &Data) override
Emit a code for initialization of task reduction clause.
LValue getSharedLValue(unsigned N) const
Returns LValue for the reduction item.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc) override
Emit a taskgroup region.
void createOffloadEntriesAndInfoMetadata()
Creates all the offload entries in the current compilation unit along with the associated metadata.
virtual void emitDistributeStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDistScheduleClauseKind SchedKind, const StaticRTInput &Values)
OffloadEntryInfo()=delete
llvm::Value * emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc, unsigned Flags=0)
Emits object of ident_t type with info for source location.
void emitUpdateClause(CodeGenFunction &CGF, LValue DepobjLVal, OpenMPDependClauseKind NewDepKind, SourceLocation Loc)
Updates the dependency kind in the specified depobj object.
virtual bool emitDeclareTargetVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Addr, bool PerformInit)
Emit a code for initialization of declare target variable.
virtual Address getAddrOfDeclareTargetVar(const VarDecl *VD)
Returns the address of the variable marked as declare target with link clause OR as declare target wi...
virtual StringRef getOutlinedHelperName() const
Get the function name of an outlined region.
void clearArrayInfo()
Clear information about the data arrays.
LangAS
Defines the address space values used by the address space qualifier of QualType.
Class supports emissionof SIMD-only code.
virtual Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc)
Returns address of the threadprivate variable for the current thread.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
virtual bool isDefaultLocationConstant() const
Check if the default location must be constant.
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 ~PrePostActionTy()
LValue - This represents an lvalue references.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
void emitSharedOrigLValue(CodeGenFunction &CGF, unsigned N)
Emits lvalue for the shared and original reduction item.
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,...
virtual const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const
Translates the native parameter of outlined function if this is required for target.
void emitDeferredTargetDecls() const
Emit deferred declare target variables marked for deferred emission.
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 ...
llvm::Constant * getID() const
virtual void Enter(CodeGenFunction &CGF)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
llvm::Value * MapTypesArray
The array of map types passed to the runtime library for the beginning of the region or for the entir...
OffloadEntryInfo(OffloadingEntryInfoKinds Kind)
void emitTeamsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars) override
Emits code for teams call of the OutlinedFn with variables captured in a record which address is stor...
SmallVector< const Expr *, 4 > LastprivateCopies
virtual void processRequiresDirective(const OMPRequiresDecl *D)
Perform check on requires decl to ensure that target architecture supports unified addressing.
OpenMPDependClauseKind DepKind
void emitTargetCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond, llvm::PointerIntPair< const Expr *, 2, OpenMPDeviceClauseModifier > Device, llvm::function_ref< llvm::Value *(CodeGenFunction &CGF, const OMPLoopDirective &D)> SizeEmitter) override
Emit the target offloading code associated with D.
CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator, StringRef Separator)
Constructor allowing to redefine the name separator for the variables.
~DisableAutoDeclareTargetRAII()
This class organizes the cross-function state that is used while generating LLVM code.
OffloadEntryInfoTargetRegion(unsigned Order, llvm::Constant *Addr, llvm::Constant *ID, OMPTargetRegionEntryKind Flags)
llvm::Function * emitTeamsOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits outlined function for the specified OpenMP teams directive D.
void setLinkage(llvm::GlobalValue::LinkageTypes LT)
SmallVector< const Expr *, 4 > ReductionOrigs
Decl - This represents one declaration (or definition), e.g.
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)...
llvm::ArrayType * getKmpCriticalNameTy() const
Get the LLVM type for the critical name.
Target region entries info.
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...
void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc) override
Emits a masked region.
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.
SmallVector< const Expr *, 4 > PrivateCopies
QualType getPrivateType(unsigned N) const
Return the type of the private item.
void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false) override
Emit an implicit/explicit barrier for OpenMP threads.
bool markAsGlobalTarget(GlobalDecl GD)
Marks the declaration as already emitted for the device code and returns true, if it was marked alrea...
SmallVector< const Expr *, 4 > FirstprivateCopies
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...
void emitDistributeStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDistScheduleClauseKind SchedKind, const StaticRTInput &Values) override
llvm::Function * emitReductionFunction(SourceLocation Loc, llvm::Type *ArgsElemType, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > LHSExprs, ArrayRef< const Expr * > RHSExprs, ArrayRef< const Expr * > ReductionOps)
Emits reduction function.
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.
This is a basic class for representing single OpenMP executable directive.
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.
void emitForOrderedIterationEnd(CodeGenFunction &CGF, SourceLocation Loc, unsigned IVSize, bool IVSigned) override
Call the appropriate runtime routine to notify that we finished iteration of the ordered loop with th...
static bool classof(const OffloadEntryInfo *Info)
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.
Manages list of nontemporal decls for the specified directive.
virtual void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads)
Emit an ordered region.
void emitDoacrossOrdered(CodeGenFunction &CGF, const OMPDependClause *C) override
Emit code for doacross ordered directive with 'depend' clause.
void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars, const Expr *IfCond, llvm::Value *NumThreads) override
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
llvm::Function * getOrCreateUserDefinedMapperFunc(const OMPDeclareMapperDecl *D)
Get the function for the specified user-defined mapper.
Address getParameterAddress(CodeGenFunction &CGF, const VarDecl *NativeParam, const VarDecl *TargetParam) const override
Gets the address of the native argument basing on the address of the target-specific parameter.
virtual void emitUserDefinedReduction(CodeGenFunction *CGF, const OMPDeclareReductionDecl *D)
Emit code for the specified user defined reduction construct.
bool isValid()
Return true if the current target data information has valid arrays.
virtual void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc, const Expr *IfCond, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancel' construct.
void emitCleanups(CodeGenFunction &CGF, unsigned N, Address PrivateAddr)
Emits cleanup code for the reduction item.
void emitIfClause(CodeGenFunction &CGF, const Expr *Cond, const RegionCodeGenTy &ThenGen, const RegionCodeGenTy &ElseGen)
Emits code for OpenMP 'if' clause using specified CodeGen function.
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
virtual bool emitTargetGlobal(GlobalDecl GD)
Emit the global GD if it is meaningful for the target.
void emitTaskReductionFini(CodeGenFunction &CGF, SourceLocation Loc, bool IsWorksharingReduction) override
Emits the following code for reduction clause with task modifier:
Stmt - This represents one statement.
bool needCleanups(unsigned N)
Returns true if the private copy requires cleanups.
void emitUserDefinedMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit the function for the user defined mapper construct.
void setVarSize(CharUnits Size)
CharUnits getVarSize() const
llvm::Function * emitParallelOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits outlined function for the specified OpenMP parallel directive D.
virtual void emitDoacrossOrdered(CodeGenFunction &CGF, const OMPDependClause *C)
Emit code for doacross ordered directive with 'depend' clause.
llvm::Value * emitNumTeamsForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D)
~LastprivateConditionalRAII()
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.
llvm::Constant * getAddress() const
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
void setAction(PrePostActionTy &Action) const
This represents '#pragma omp requires...' directive.
OffloadEntryInfoTargetRegion()
SmallVector< const Expr *, 4 > PrivateVars
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...
virtual Address getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name)
Creates artificial threadprivate variable with name Name and type VarType.
RegionCodeGenTy(Callable &&CodeGen, std::enable_if_t<!std::is_same< std::remove_reference_t< Callable >, RegionCodeGenTy >::value > *=nullptr)
void emitForStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind DKind, const OpenMPScheduleTy &ScheduleKind, const StaticRTInput &Values) override
Call the appropriate runtime routine to initialize it before start of loop.
llvm::Value * MapNamesArray
The array of original declaration names of mapped pointers sent to the runtime library for debugging.
Manages list of nontemporal decls for the specified directive.
virtual bool emitTargetGlobalVariable(GlobalDecl GD)
Emit the global variable if it is a valid device global variable.
@ OffloadingEntryInfoInvalid
Invalid entry info.
UntiedTaskLocalDeclsRAII(CodeGenFunction &CGF, const llvm::MapVector< CanonicalDeclPtr< const VarDecl >, std::pair< Address, Address >> &LocalVars)
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
uint32_t getFlags() const
@ OffloadingEntryInfoTargetRegion
Entry is a target region.
A wrapper class around a pointer that always points to its canonical declaration.
llvm::Value * SizesArray
The array of sizes passed to the runtime library.
CharUnits - This is an opaque type for sizes expressed in character units.
bool isLocalVarInUntiedTask(CodeGenFunction &CGF, const VarDecl *VD) const
Returns true if the variable is a local variable in untied task.
SmallVector< const Expr *, 4 > FirstprivateVars
virtual llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr)
Emit a code for initialization of threadprivate variable.
Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) override
Gets the OpenMP-specific address of the local variable.
Allows to disable automatic handling of functions used in target regions as those marked as omp decla...
This represents one expression.
virtual void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc)
Emit a taskgroup region.
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
SmallVector< const Expr *, 4 > ReductionVars
void emitUsesAllocatorsFini(CodeGenFunction &CGF, const Expr *Allocator)
Destroys user defined allocators specified in the uses_allocators clause.
virtual void emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPExecutableDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const Expr *IfCond, const OMPTaskDataTy &Data)
Emit task region for the task directive.
virtual void emitDeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn)
Marks function Fn with properly mangled versions of vector functions.
static bool classof(const OffloadEntryInfo *Info)
A reference to a declared variable, function, enum, etc.
void emitUsesAllocatorsInit(CodeGenFunction &CGF, const Expr *Allocator, const Expr *AllocatorTraits)
Initializes user defined allocators specified in the uses_allocators clauses.
Represents a function declaration or definition.
Represents a struct/union/class.
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.
bool emitTargetGlobal(GlobalDecl GD) override
Emit the global GD if it is meaningful for the target.
const Expr * getRefExpr(unsigned N) const
Returns the base declaration of the reduction item.
virtual void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr, uint64_t Size, int32_t Flags, llvm::GlobalValue::LinkageTypes Linkage)
Creates offloading entry for the provided entry ID ID, address Addr, size Size, and flags Flags.
static bool classof(const OffloadEntryInfo *Info)
void setFlags(uint32_t NewFlags)
virtual void emitTargetCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond, llvm::PointerIntPair< const Expr *, 2, OpenMPDeviceClauseModifier > Device, llvm::function_ref< llvm::Value *(CodeGenFunction &CGF, const OMPLoopDirective &D)> SizeEmitter)
Emit the target offloading code associated with D.
A basic class for pre|post-action for advanced codegen sequence for OpenMP region.
Scheduling data for loop-based OpenMP directives.
bool requiresDevicePointerInfo()
llvm::Function * emitTaskOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, const VarDecl *PartIDVar, const VarDecl *TaskTVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen, bool Tied, unsigned &NumberOfParts) override
Emits outlined function for the OpenMP task directive D.
virtual void functionFinished(CodeGenFunction &CGF)
Cleans up references to the objects in finished function.
virtual std::pair< llvm::Function *, llvm::Function * > getUserDefinedReduction(const OMPDeclareReductionDecl *D)
Get combiner/initializer for the specified user-defined reduction, if any.
void emitReduction(CodeGenFunction &CGF, SourceLocation Loc, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > LHSExprs, ArrayRef< const Expr * > RHSExprs, ArrayRef< const Expr * > ReductionOps, ReductionOptionsTy Options) override
Emit a code for reduction 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.
virtual void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPTaskDataTy &Data)
Emit code for 'taskwait' directive.
bool usesReductionInitializer(unsigned N) const
Returns true if the initialization of the reduction item uses initializer from declare reduction cons...