14 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H 15 #define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H 39 struct EntryFunctionState {
40 llvm::BasicBlock *ExitBB =
nullptr;
43 class WorkerFunctionState {
45 llvm::Function *WorkerFn;
57 bool requiresFullRuntime()
const {
return RequiresFullRuntime; }
63 void emitWorkerFunction(WorkerFunctionState &WST);
70 void emitNonSPMDEntryHeader(
CodeGenFunction &CGF, EntryFunctionState &EST,
71 WorkerFunctionState &WST);
75 void emitNonSPMDEntryFooter(
CodeGenFunction &CGF, EntryFunctionState &EST);
79 bool WithSPMDCheck =
false);
82 void emitGenericVarsEpilog(
CodeGenFunction &CGF,
bool WithSPMDCheck =
false);
89 void emitSPMDEntryFooter(
CodeGenFunction &CGF, EntryFunctionState &EST);
97 void createOffloadEntry(llvm::Constant *
ID, llvm::Constant *Addr,
98 uint64_t Size, int32_t Flags,
99 llvm::GlobalValue::LinkageTypes
Linkage)
override;
111 llvm::Function *&OutlinedFn,
112 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
127 llvm::Function *&OutlinedFn,
128 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
141 StringRef ParentName,
142 llvm::Function *&OutlinedFn,
143 llvm::Constant *&OutlinedFnID,
174 llvm::Function *OutlinedFn,
183 return "__omp_outlined__";
198 void clear()
override;
274 llvm::Function *OutlinedFn,
276 const Expr *IfCond)
override;
288 bool ForceSimpleCall =
false)
override;
298 const Expr *Hint =
nullptr)
override;
331 const VarDecl *NativeParam)
const override;
338 const VarDecl *TargetParam)
const override;
377 const Expr *&ChunkExpr)
const override;
405 bool RequiresFullRuntime =
true;
409 bool IsInTargetMasterThreadRegion =
false;
412 bool IsInTTDRegion =
false;
414 bool IsInParallelRegion =
false;
417 llvm::DenseMap<llvm::Function *, llvm::Function *> WrapperFunctionsMap;
423 llvm::Function *createParallelDataSharingWrapper(
427 struct MappedVarData {
434 bool IsOnePerTeam =
false;
435 MappedVarData() =
delete;
436 MappedVarData(
const FieldDecl *FD,
bool IsOnePerTeam =
false)
437 : FD(FD), IsOnePerTeam(IsOnePerTeam) {}
440 using DeclToAddrMapTy = llvm::MapVector<const Decl *, MappedVarData>;
442 using EscapedParamsTy = llvm::SmallPtrSet<const Decl *, 4>;
443 struct FunctionData {
444 DeclToAddrMapTy LocalVarData;
446 EscapedParamsTy EscapedParameters;
453 std::unique_ptr<CodeGenFunction::OMPMapVars> MappedParams;
457 llvm::SmallDenseMap<llvm::Function *, FunctionData> FunctionGlobalizedDecls;
463 struct GlobalPtrSizeRecsTy {
464 llvm::GlobalVariable *UseSharedMemory =
nullptr;
465 llvm::GlobalVariable *RecSize =
nullptr;
466 llvm::GlobalVariable *Buffer =
nullptr;
469 unsigned RegionCounter = 0;
472 llvm::GlobalVariable *KernelTeamsReductionPtr =
nullptr;
480 llvm::GlobalVariable *KernelStaticGlobalized =
nullptr;
483 std::pair<const Decl *, llvm::SmallVector<const ValueDecl *, 4>>
490 #endif // LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
bool isDefaultLocationConstant() const override
Check if the default location must be constant.
void checkArchForUnifiedAddressing(const OMPRequiresDecl *D) override
Perform check on requires decl to ensure that target architecture supports unified addressing...
void adjustTargetSpecificDataForLambdas(CodeGenFunction &CGF, const OMPExecutableDirective &D) const override
Adjust some parameters for the target-based directives, like addresses of the variables captured by r...
Decl - This represents one declaration (or definition), e.g.
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...
llvm::FunctionCallee createNVPTXRuntimeFunction(unsigned Function)
Returns specified OpenMP runtime function for the current OpenMP implementation.
Represents a variable declaration or definition.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
SPMD execution mode (all threads are worker threads).
Represents a struct/union/class.
DataSharingMode
Target codegen is specialized based on two data-sharing modes: CUDA, in which the local variables are...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Represents a member of a struct/union/class.
unsigned getDefaultLocationReserved2Flags() const override
Returns additional flags that can be stored in reserved_2 field of the default location.
void functionFinished(CodeGenFunction &CGF) override
Cleans up references to the objects in finished function.
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...
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc...
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
virtual 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)...
void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams, const Expr *ThreadLimit, SourceLocation Loc) override
This function ought to emit, in the general case, a call to.
unsigned getDefaultFirstprivateAddressSpace() const override
Returns default address space for the constant firstprivates, constant address space by default...
bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS) override
Checks if the variable has associated OMPAllocateDeclAttr attribute with the predefined allocator and...
Unknown execution mode (orphaned directive).
llvm::Function * emitParallelOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits inlined function for the specified OpenMP parallel.
This represents '#pragma omp requires...' directive.
This represents one expression.
Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) override
Gets the OpenMP-specific address of the local variable.
void getDefaultScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind, const Expr *&ChunkExpr) const override
Choose a default value for the schedule clause.
void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value *> CapturedVars, const Expr *IfCond) override
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
OpenMPProcBindClauseKind
OpenMP attributes for 'proc_bind' clause.
Non-SPMD execution mode (1 master thread, others are workers).
Encodes a location in the source.
void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr) override
Emits a critical region.
This is a basic class for representing single OpenMP executable directive.
StringRef getOutlinedHelperName() const override
Get the function name of an outlined region.
OpenMPDirectiveKind
OpenMP directives.
llvm::Function * emitTeamsOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits inlined function for the specified OpenMP teams.
void emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::FunctionCallee OutlinedFn, ArrayRef< llvm::Value *> Args=llvm::None) const override
Emits call of the outlined function with the provided arguments, translating these arguments to corre...
const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const override
Translates the native parameter of outlined function if this is required for target.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
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 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.
This file defines OpenMP AST classes for executable directives and clauses.
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
ExecutionMode
Defines the execution mode.
void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) override
Emits OpenMP-specific function prolog.
Generic data-sharing mode.
Privates[]
Gets the list of initial values for linear variables.
virtual void emitProcBindClause(CodeGenFunction &CGF, OpenMPProcBindClauseKind ProcBind, SourceLocation Loc) override
Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32 global_tid, int proc_bind) to generat...
void getDefaultDistScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind, llvm::Value *&Chunk) const override
Choose a default value for the dist_schedule clause.
CGOpenMPRuntimeNVPTX(CodeGenModule &CGM)
void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false) override
Emit an implicit/explicit barrier for OpenMP threads.