clang  8.0.0svn
CGOpenMPRuntimeNVPTX.h
Go to the documentation of this file.
1 //===----- CGOpenMPRuntimeNVPTX.h - Interface to OpenMP NVPTX Runtimes ----===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This provides a class for OpenMP runtime code generation specialized to NVPTX
11 // targets.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
16 #define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
17 
18 #include "CGOpenMPRuntime.h"
19 #include "CodeGenFunction.h"
20 #include "clang/AST/StmtOpenMP.h"
21 #include "llvm/IR/CallSite.h"
22 
23 namespace clang {
24 namespace CodeGen {
25 
27 public:
28  /// Defines the execution mode.
30  /// SPMD execution mode (all threads are worker threads).
32  /// Non-SPMD execution mode (1 master thread, others are workers).
34  /// Unknown execution mode (orphaned directive).
36  };
37 private:
38  /// Parallel outlined function work for workers to execute.
40 
41  struct EntryFunctionState {
42  llvm::BasicBlock *ExitBB = nullptr;
43  };
44 
45  class WorkerFunctionState {
46  public:
47  llvm::Function *WorkerFn;
48  const CGFunctionInfo &CGFI;
49  SourceLocation Loc;
50 
51  WorkerFunctionState(CodeGenModule &CGM, SourceLocation Loc);
52 
53  private:
54  void createWorkerFunction(CodeGenModule &CGM);
55  };
56 
57  ExecutionMode getExecutionMode() const;
58 
59  bool requiresFullRuntime() const { return RequiresFullRuntime; }
60 
61  /// Emit the worker function for the current target region.
62  void emitWorkerFunction(WorkerFunctionState &WST);
63 
64  /// Helper for worker function. Emit body of worker loop.
65  void emitWorkerLoop(CodeGenFunction &CGF, WorkerFunctionState &WST);
66 
67  /// Helper for non-SPMD target entry function. Guide the master and
68  /// worker threads to their respective locations.
69  void emitNonSPMDEntryHeader(CodeGenFunction &CGF, EntryFunctionState &EST,
70  WorkerFunctionState &WST);
71 
72  /// Signal termination of OMP execution for non-SPMD target entry
73  /// function.
74  void emitNonSPMDEntryFooter(CodeGenFunction &CGF, EntryFunctionState &EST);
75 
76  /// Helper for generic variables globalization prolog.
77  void emitGenericVarsProlog(CodeGenFunction &CGF, SourceLocation Loc,
78  bool WithSPMDCheck = false);
79 
80  /// Helper for generic variables globalization epilog.
81  void emitGenericVarsEpilog(CodeGenFunction &CGF, bool WithSPMDCheck = false);
82 
83  /// Helper for SPMD mode target directive's entry function.
84  void emitSPMDEntryHeader(CodeGenFunction &CGF, EntryFunctionState &EST,
85  const OMPExecutableDirective &D);
86 
87  /// Signal termination of SPMD mode execution.
88  void emitSPMDEntryFooter(CodeGenFunction &CGF, EntryFunctionState &EST);
89 
90  //
91  // Base class overrides.
92  //
93 
94  /// Creates offloading entry for the provided entry ID \a ID,
95  /// address \a Addr, size \a Size, and flags \a Flags.
96  void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
97  uint64_t Size, int32_t Flags,
98  llvm::GlobalValue::LinkageTypes Linkage) override;
99 
100  /// Emit outlined function specialized for the Fork-Join
101  /// programming model for applicable target directives on the NVPTX device.
102  /// \param D Directive to emit.
103  /// \param ParentName Name of the function that encloses the target region.
104  /// \param OutlinedFn Outlined function value to be defined by this call.
105  /// \param OutlinedFnID Outlined function ID value to be defined by this call.
106  /// \param IsOffloadEntry True if the outlined function is an offload entry.
107  /// An outlined function may not be an entry if, e.g. the if clause always
108  /// evaluates to false.
109  void emitNonSPMDKernel(const OMPExecutableDirective &D, StringRef ParentName,
110  llvm::Function *&OutlinedFn,
111  llvm::Constant *&OutlinedFnID, bool IsOffloadEntry,
112  const RegionCodeGenTy &CodeGen);
113 
114  /// Emit outlined function specialized for the Single Program
115  /// Multiple Data programming model for applicable target directives on the
116  /// NVPTX device.
117  /// \param D Directive to emit.
118  /// \param ParentName Name of the function that encloses the target region.
119  /// \param OutlinedFn Outlined function value to be defined by this call.
120  /// \param OutlinedFnID Outlined function ID value to be defined by this call.
121  /// \param IsOffloadEntry True if the outlined function is an offload entry.
122  /// \param CodeGen Object containing the target statements.
123  /// An outlined function may not be an entry if, e.g. the if clause always
124  /// evaluates to false.
125  void emitSPMDKernel(const OMPExecutableDirective &D, StringRef ParentName,
126  llvm::Function *&OutlinedFn,
127  llvm::Constant *&OutlinedFnID, bool IsOffloadEntry,
128  const RegionCodeGenTy &CodeGen);
129 
130  /// Emit outlined function for 'target' directive on the NVPTX
131  /// device.
132  /// \param D Directive to emit.
133  /// \param ParentName Name of the function that encloses the target region.
134  /// \param OutlinedFn Outlined function value to be defined by this call.
135  /// \param OutlinedFnID Outlined function ID value to be defined by this call.
136  /// \param IsOffloadEntry True if the outlined function is an offload entry.
137  /// An outlined function may not be an entry if, e.g. the if clause always
138  /// evaluates to false.
140  StringRef ParentName,
141  llvm::Function *&OutlinedFn,
142  llvm::Constant *&OutlinedFnID,
143  bool IsOffloadEntry,
144  const RegionCodeGenTy &CodeGen) override;
145 
146  /// Emits code for parallel or serial call of the \a OutlinedFn with
147  /// variables captured in a record which address is stored in \a
148  /// CapturedStruct.
149  /// This call is for the Non-SPMD Execution Mode.
150  /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
151  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
152  /// \param CapturedVars A pointer to the record with the references to
153  /// variables used in \a OutlinedFn function.
154  /// \param IfCond Condition in the associated 'if' clause, if it was
155  /// specified, nullptr otherwise.
156  void emitNonSPMDParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
157  llvm::Value *OutlinedFn,
158  ArrayRef<llvm::Value *> CapturedVars,
159  const Expr *IfCond);
160 
161  /// Emits code for parallel or serial call of the \a OutlinedFn with
162  /// variables captured in a record which address is stored in \a
163  /// CapturedStruct.
164  /// This call is for a parallel directive within an SPMD target directive.
165  /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
166  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
167  /// \param CapturedVars A pointer to the record with the references to
168  /// variables used in \a OutlinedFn function.
169  /// \param IfCond Condition in the associated 'if' clause, if it was
170  /// specified, nullptr otherwise.
171  ///
172  void emitSPMDParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
173  llvm::Value *OutlinedFn,
174  ArrayRef<llvm::Value *> CapturedVars,
175  const Expr *IfCond);
176 
177 protected:
178  /// Get the function name of an outlined region.
179  // The name can be customized depending on the target.
180  //
181  StringRef getOutlinedHelperName() const override {
182  return "__omp_outlined__";
183  }
184 
185  /// Check if the default location must be constant.
186  /// Constant for NVPTX for better optimization.
187  bool isDefaultLocationConstant() const override { return true; }
188 
189  /// Returns additional flags that can be stored in reserved_2 field of the
190  /// default location.
191  /// For NVPTX target contains data about SPMD/Non-SPMD execution mode +
192  /// Full/Lightweight runtime mode. Used for better optimization.
193  unsigned getDefaultLocationReserved2Flags() const override;
194 
195 public:
197  void clear() override;
198 
199  /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
200  /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
201  virtual void emitProcBindClause(CodeGenFunction &CGF,
202  OpenMPProcBindClauseKind ProcBind,
203  SourceLocation Loc) override;
204 
205  /// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
206  /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
207  /// clause.
208  /// \param NumThreads An integer value of threads.
209  virtual void emitNumThreadsClause(CodeGenFunction &CGF,
210  llvm::Value *NumThreads,
211  SourceLocation Loc) override;
212 
213  /// This function ought to emit, in the general case, a call to
214  // the openmp runtime kmpc_push_num_teams. In NVPTX backend it is not needed
215  // as these numbers are obtained through the PTX grid and block configuration.
216  /// \param NumTeams An integer expression of teams.
217  /// \param ThreadLimit An integer expression of threads.
218  void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams,
219  const Expr *ThreadLimit, SourceLocation Loc) override;
220 
221  /// Emits inlined function for the specified OpenMP parallel
222  // directive.
223  /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
224  /// kmp_int32 BoundID, struct context_vars*).
225  /// \param D OpenMP directive.
226  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
227  /// \param InnermostKind Kind of innermost directive (for simple directives it
228  /// is a directive itself, for combined - its innermost directive).
229  /// \param CodeGen Code generation sequence for the \a D directive.
230  llvm::Value *
232  const VarDecl *ThreadIDVar,
233  OpenMPDirectiveKind InnermostKind,
234  const RegionCodeGenTy &CodeGen) override;
235 
236  /// Emits inlined function for the specified OpenMP teams
237  // directive.
238  /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
239  /// kmp_int32 BoundID, struct context_vars*).
240  /// \param D OpenMP directive.
241  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
242  /// \param InnermostKind Kind of innermost directive (for simple directives it
243  /// is a directive itself, for combined - its innermost directive).
244  /// \param CodeGen Code generation sequence for the \a D directive.
245  llvm::Value *
247  const VarDecl *ThreadIDVar,
248  OpenMPDirectiveKind InnermostKind,
249  const RegionCodeGenTy &CodeGen) override;
250 
251  /// Emits code for teams call of the \a OutlinedFn with
252  /// variables captured in a record which address is stored in \a
253  /// CapturedStruct.
254  /// \param OutlinedFn Outlined function to be run by team masters. Type of
255  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
256  /// \param CapturedVars A pointer to the record with the references to
257  /// variables used in \a OutlinedFn function.
258  ///
260  SourceLocation Loc, llvm::Value *OutlinedFn,
261  ArrayRef<llvm::Value *> CapturedVars) override;
262 
263  /// Emits code for parallel or serial call of the \a OutlinedFn with
264  /// variables captured in a record which address is stored in \a
265  /// CapturedStruct.
266  /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
267  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
268  /// \param CapturedVars A pointer to the record with the references to
269  /// variables used in \a OutlinedFn function.
270  /// \param IfCond Condition in the associated 'if' clause, if it was
271  /// specified, nullptr otherwise.
273  llvm::Value *OutlinedFn,
274  ArrayRef<llvm::Value *> CapturedVars,
275  const Expr *IfCond) override;
276 
277  /// Emit an implicit/explicit barrier for OpenMP threads.
278  /// \param Kind Directive for which this implicit barrier call must be
279  /// generated. Must be OMPD_barrier for explicit barrier generation.
280  /// \param EmitChecks true if need to emit checks for cancellation barriers.
281  /// \param ForceSimpleCall true simple barrier call must be emitted, false if
282  /// runtime class decides which one to emit (simple or with cancellation
283  /// checks).
284  ///
286  OpenMPDirectiveKind Kind, bool EmitChecks = true,
287  bool ForceSimpleCall = false) override;
288 
289  /// Emits a critical region.
290  /// \param CriticalName Name of the critical region.
291  /// \param CriticalOpGen Generator for the statement associated with the given
292  /// critical region.
293  /// \param Hint Value of the 'hint' clause (optional).
294  void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
295  const RegionCodeGenTy &CriticalOpGen,
296  SourceLocation Loc,
297  const Expr *Hint = nullptr) override;
298 
299  /// Emit a code for reduction clause.
300  ///
301  /// \param Privates List of private copies for original reduction arguments.
302  /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
303  /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
304  /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
305  /// or 'operator binop(LHS, RHS)'.
306  /// \param Options List of options for reduction codegen:
307  /// WithNowait true if parent directive has also nowait clause, false
308  /// otherwise.
309  /// SimpleReduction Emit reduction operation only. Used for omp simd
310  /// directive on the host.
311  /// ReductionKind The kind of reduction to perform.
312  virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
314  ArrayRef<const Expr *> LHSExprs,
315  ArrayRef<const Expr *> RHSExprs,
316  ArrayRef<const Expr *> ReductionOps,
317  ReductionOptionsTy Options) override;
318 
319  /// Returns specified OpenMP runtime function for the current OpenMP
320  /// implementation. Specialized for the NVPTX device.
321  /// \param Function OpenMP runtime function.
322  /// \return Specified function.
323  llvm::Constant *createNVPTXRuntimeFunction(unsigned Function);
324 
325  /// Translates the native parameter of outlined function if this is required
326  /// for target.
327  /// \param FD Field decl from captured record for the parameter.
328  /// \param NativeParam Parameter itself.
329  const VarDecl *translateParameter(const FieldDecl *FD,
330  const VarDecl *NativeParam) const override;
331 
332  /// Gets the address of the native argument basing on the address of the
333  /// target-specific parameter.
334  /// \param NativeParam Parameter itself.
335  /// \param TargetParam Corresponding target-specific parameter.
336  Address getParameterAddress(CodeGenFunction &CGF, const VarDecl *NativeParam,
337  const VarDecl *TargetParam) const override;
338 
339  /// Emits call of the outlined function with the provided arguments,
340  /// translating these arguments to correct target-specific arguments.
342  CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *OutlinedFn,
343  ArrayRef<llvm::Value *> Args = llvm::None) const override;
344 
345  /// Emits OpenMP-specific function prolog.
346  /// Required for device constructs.
347  void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) override;
348 
349  /// Gets the OpenMP-specific address of the local variable.
351  const VarDecl *VD) override;
352 
353  /// Target codegen is specialized based on two data-sharing modes: CUDA, in
354  /// which the local variables are actually global threadlocal, and Generic, in
355  /// which the local variables are placed in global memory if they may escape
356  /// their declaration context.
358  /// CUDA data sharing mode.
360  /// Generic data-sharing mode.
362  };
363 
364  /// Cleans up references to the objects in finished function.
365  ///
366  void functionFinished(CodeGenFunction &CGF) override;
367 
368  /// Choose a default value for the dist_schedule clause.
370  const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind,
371  llvm::Value *&Chunk) const override;
372 
373  /// Choose a default value for the schedule clause.
375  const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind,
376  const Expr *&ChunkExpr) const override;
377 
378  /// Adjust some parameters for the target-based directives, like addresses of
379  /// the variables captured by reference in lambdas.
381  CodeGenFunction &CGF, const OMPExecutableDirective &D) const override;
382 
383  /// Perform check on requires decl to ensure that target architecture
384  /// supports unified addressing
386  const OMPRequiresDecl *D) const override;
387 
388 private:
389  /// Track the execution mode when codegening directives within a target
390  /// region. The appropriate mode (SPMD/NON-SPMD) is set on entry to the
391  /// target region and used by containing directives such as 'parallel'
392  /// to emit optimized code.
393  ExecutionMode CurrentExecutionMode = EM_Unknown;
394 
395  /// Check if the full runtime is required (default - yes).
396  bool RequiresFullRuntime = true;
397 
398  /// true if we're emitting the code for the target region and next parallel
399  /// region is L0 for sure.
400  bool IsInTargetMasterThreadRegion = false;
401  /// true if currently emitting code for target/teams/distribute region, false
402  /// - otherwise.
403  bool IsInTTDRegion = false;
404  /// true if we're definitely in the parallel region.
405  bool IsInParallelRegion = false;
406 
407  /// Map between an outlined function and its wrapper.
408  llvm::DenseMap<llvm::Function *, llvm::Function *> WrapperFunctionsMap;
409 
410  /// Emit function which wraps the outline parallel region
411  /// and controls the parameters which are passed to this function.
412  /// The wrapper ensures that the outlined function is called
413  /// with the correct arguments when data is shared.
414  llvm::Function *createParallelDataSharingWrapper(
415  llvm::Function *OutlinedParallelFn, const OMPExecutableDirective &D);
416 
417  /// The data for the single globalized variable.
418  struct MappedVarData {
419  /// Corresponding field in the global record.
420  const FieldDecl *FD = nullptr;
421  /// Corresponding address.
422  Address PrivateAddr = Address::invalid();
423  /// true, if only one element is required (for latprivates in SPMD mode),
424  /// false, if need to create based on the warp-size.
425  bool IsOnePerTeam = false;
426  MappedVarData() = delete;
427  MappedVarData(const FieldDecl *FD, bool IsOnePerTeam = false)
428  : FD(FD), IsOnePerTeam(IsOnePerTeam) {}
429  };
430  /// The map of local variables to their addresses in the global memory.
431  using DeclToAddrMapTy = llvm::MapVector<const Decl *, MappedVarData>;
432  /// Set of the parameters passed by value escaping OpenMP context.
433  using EscapedParamsTy = llvm::SmallPtrSet<const Decl *, 4>;
434  struct FunctionData {
435  DeclToAddrMapTy LocalVarData;
436  llvm::Optional<DeclToAddrMapTy> SecondaryLocalVarData = llvm::None;
437  EscapedParamsTy EscapedParameters;
438  llvm::SmallVector<const ValueDecl*, 4> EscapedVariableLengthDecls;
439  llvm::SmallVector<llvm::Value *, 4> EscapedVariableLengthDeclsAddrs;
440  const RecordDecl *GlobalRecord = nullptr;
441  llvm::Optional<const RecordDecl *> SecondaryGlobalRecord = llvm::None;
442  llvm::Value *GlobalRecordAddr = nullptr;
443  llvm::Value *IsInSPMDModeFlag = nullptr;
444  std::unique_ptr<CodeGenFunction::OMPMapVars> MappedParams;
445  };
446  /// Maps the function to the list of the globalized variables with their
447  /// addresses.
448  llvm::SmallDenseMap<llvm::Function *, FunctionData> FunctionGlobalizedDecls;
449  /// List of records for the globalized variables in target/teams/distribute
450  /// contexts. Inner records are going to be joined into the single record,
451  /// while those resulting records are going to be joined into the single
452  /// union. This resulting union (one per CU) is the entry point for the static
453  /// memory management runtime functions.
454  struct GlobalPtrSizeRecsTy {
455  llvm::GlobalVariable *UseSharedMemory = nullptr;
456  llvm::GlobalVariable *RecSize = nullptr;
457  llvm::GlobalVariable *Buffer = nullptr;
458  SourceLocation Loc;
460  unsigned RegionCounter = 0;
461  };
463  /// Shared pointer for the global memory in the global memory buffer used for
464  /// the given kernel.
465  llvm::GlobalVariable *KernelStaticGlobalized = nullptr;
466  /// Pair of the Non-SPMD team and all reductions variables in this team
467  /// region.
468  std::pair<const Decl *, llvm::SmallVector<const ValueDecl *, 4>>
469  TeamAndReductions;
470 };
471 
472 } // CodeGen namespace.
473 } // clang namespace.
474 
475 #endif // LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIMENVPTX_H
bool isDefaultLocationConstant() const override
Check if the default location must be constant.
llvm::Value * emitParallelOutlinedFunction(const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits inlined function for the specified OpenMP parallel.
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.
Definition: DeclBase.h:87
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...
Represents a variable declaration or definition.
Definition: Decl.h:812
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Definition: Linkage.h:24
SPMD execution mode (all threads are worker threads).
Represents a struct/union/class.
Definition: Decl.h:3602
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.
Definition: Decl.h:2588
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.
This is a common base class for loop directives (&#39;omp simd&#39;, &#39;omp for&#39;, &#39;omp for simd&#39; etc...
Definition: StmtOpenMP.h:338
OpenMPDistScheduleClauseKind
OpenMP attributes for &#39;dist_schedule&#39; clause.
Definition: OpenMPKinds.h:100
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.
void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *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...
Unknown execution mode (orphaned directive).
This represents &#39;#pragma omp requires...&#39; directive.
Definition: DeclOpenMP.h:250
This represents one expression.
Definition: Expr.h:106
static Address invalid()
Definition: Address.h:35
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.
OpenMPProcBindClauseKind
OpenMP attributes for &#39;proc_bind&#39; clause.
Definition: OpenMPKinds.h:51
Non-SPMD execution mode (1 master thread, others are workers).
llvm::Value * 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::Value *OutlinedFn, ArrayRef< llvm::Value *> Args=llvm::None) const override
Emits call of the outlined function with the provided arguments, translating these arguments to corre...
Kind
void emitTeamsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, SourceLocation Loc, llvm::Value *OutlinedFn, ArrayRef< llvm::Value *> CapturedVars) override
Emits code for teams call of the OutlinedFn with variables captured in a record which address is stor...
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.
Definition: StmtOpenMP.h:33
StringRef getOutlinedHelperName() const override
Get the function name of an outlined region.
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
An aligned address.
Definition: Address.h:25
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 &#39;target&#39; directive.
void checkArchForUnifiedAddressing(CodeGenModule &CGM, const OMPRequiresDecl *D) const override
Perform check on requires decl to ensure that target architecture supports unified addressing...
llvm::Constant * createNVPTXRuntimeFunction(unsigned Function)
Returns specified OpenMP runtime function for the current OpenMP implementation.
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 &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:59
ExecutionMode
Defines the execution mode.
void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D) override
Emits OpenMP-specific function prolog.
Privates[]
Gets the list of initial values for linear variables.
Definition: OpenMPClause.h:151
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.
void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false) override
Emit an implicit/explicit barrier for OpenMP threads.