14#ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMEGPU_H
15#define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMEGPU_H
51 struct EntryFunctionState {
60 void syncCTAThreads(CodeGenFunction &CGF);
64 EntryFunctionState &EST,
bool IsSPMD);
67 void emitKernelDeinit(CodeGenFunction &CGF, EntryFunctionState &EST,
74 void emitGenericVarsEpilog(CodeGenFunction &CGF);
90 llvm::Function *&OutlinedFn,
91 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
92 const RegionCodeGenTy &CodeGen);
106 llvm::Function *&OutlinedFn,
107 llvm::Constant *&OutlinedFnID,
bool IsOffloadEntry,
108 const RegionCodeGenTy &CodeGen);
120 StringRef ParentName,
121 llvm::Function *&OutlinedFn,
122 llvm::Constant *&OutlinedFnID,
124 const RegionCodeGenTy &CodeGen)
override;
134 bool isGPU()
const override {
return true; };
142 const VarDecl *VD)
const override;
145 std::pair<llvm::Value *, llvm::Value *>
151 const std::pair<llvm::Value *, llvm::Value *> &AddrSizePair)
override;
162 llvm::omp::ProcBindKind ProcBind,
235 llvm::Function *OutlinedFn,
237 const Expr *IfCond, llvm::Value *NumThreads)
override;
249 bool ForceSimpleCall =
false)
override;
259 const Expr *Hint =
nullptr)
override;
279 ReductionOptionsTy Options)
override;
286 const VarDecl *NativeParam)
const override;
293 const VarDecl *TargetParam)
const override;
299 llvm::FunctionCallee OutlinedFn,
317 llvm::Value *&Chunk)
const override;
322 const Expr *&ChunkExpr)
const override;
351 bool IsInTTDRegion =
false;
354 llvm::DenseMap<llvm::Function *, llvm::Function *> WrapperFunctionsMap;
360 llvm::Function *createParallelDataSharingWrapper(
364 struct MappedVarData {
366 llvm::Value *GlobalizedVal =
nullptr;
371 using DeclToAddrMapTy = llvm::MapVector<const Decl *, MappedVarData>;
374 struct FunctionData {
375 DeclToAddrMapTy LocalVarData;
376 EscapedParamsTy EscapedParameters;
380 EscapedVariableLengthDeclsAddrs;
381 std::unique_ptr<CodeGenFunction::OMPMapVars> MappedParams;
385 llvm::SmallDenseMap<llvm::Function *, FunctionData> FunctionGlobalizedDecls;
393 std::pair<const Decl *, llvm::SmallVector<const ValueDecl *, 4>>
This file defines OpenMP AST classes for executable directives and clauses.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
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 * emitTeamsOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits inlined function for the specified OpenMP teams.
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...
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.
DataSharingMode
Target codegen is specialized based on two data-sharing modes: CUDA, in which the local variables are...
@ DS_CUDA
CUDA data sharing mode.
@ DS_Generic
Generic data-sharing mode.
void getDefaultDistScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind, llvm::Value *&Chunk) const override
Choose a default value for the dist_schedule clause.
Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) override
Gets the OpenMP-specific address of the local variable.
void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) override
Emits OpenMP-specific function prolog.
bool isDefaultLocationConstant() const override
Check if the default location must be constant.
void getDefaultScheduleAndChunk(CodeGenFunction &CGF, const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind, const Expr *&ChunkExpr) const override
Choose a default value for the schedule clause.
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.
void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr) override
Emits a critical region.
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...
bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS) override
Checks if the variable has associated OMPAllocateDeclAttr attribute with the predefined allocator and...
void getKmpcFreeShared(CodeGenFunction &CGF, const std::pair< llvm::Value *, llvm::Value * > &AddrSizePair) override
Get call to __kmpc_free_shared.
llvm::Function * emitParallelOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits inlined function for the specified OpenMP parallel.
void functionFinished(CodeGenFunction &CGF) override
Cleans up references to the objects in finished function.
llvm::Value * getGPUThreadID(CodeGenFunction &CGF)
Get the id of the current thread on the GPU.
void processRequiresDirective(const OMPRequiresDecl *D) override
Perform check on requires decl to ensure that target architecture supports unified addressing.
bool isDelayedVariableLengthDecl(CodeGenFunction &CGF, const VarDecl *VD) const override
Declare generalized virtual functions which need to be defined by all specializations of OpenMPGPURun...
void emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::FunctionCallee OutlinedFn, ArrayRef< llvm::Value * > Args={}) const override
Emits call of the outlined function with the provided arguments, translating these arguments to corre...
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.
ExecutionMode
Defines the execution mode.
@ EM_NonSPMD
Non-SPMD execution mode (1 master thread, others are workers).
@ EM_Unknown
Unknown execution mode (orphaned directive).
@ EM_SPMD
SPMD execution mode (all threads are worker threads).
void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false) override
Emit an implicit/explicit barrier for OpenMP threads.
llvm::Value * getGPUNumThreads(CodeGenFunction &CGF)
Get the maximum number of threads in a block of the GPU.
const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const override
Translates the native parameter of outlined function if this is required for target.
std::pair< llvm::Value *, llvm::Value * > getKmpcAllocShared(CodeGenFunction &CGF, const VarDecl *VD) override
Get call to __kmpc_alloc_shared.
bool isGPU() const override
Returns true if the current target is a GPU.
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 adjustTargetSpecificDataForLambdas(CodeGenFunction &CGF, const OMPExecutableDirective &D) const override
Adjust some parameters for the target-based directives, like addresses of the variables captured by r...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a member of a struct/union/class.
This is a basic class for representing single OpenMP executable directive.
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
This represents '#pragma omp requires...' directive.
Encodes a location in the source.
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
LangAS
Defines the address space values used by the address space qualifier of QualType.
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.