clang  15.0.0git
CGOpenMPRuntime.h
Go to the documentation of this file.
1 //===----- CGOpenMPRuntime.h - Interface to OpenMP Runtimes -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This provides a class for OpenMP runtime code generation.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H
14 #define LLVM_CLANG_LIB_CODEGEN_CGOPENMPRUNTIME_H
15 
16 #include "CGValue.h"
17 #include "clang/AST/DeclOpenMP.h"
18 #include "clang/AST/GlobalDecl.h"
19 #include "clang/AST/Type.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"
32 
33 namespace llvm {
34 class ArrayType;
35 class Constant;
36 class FunctionType;
37 class GlobalVariable;
38 class Type;
39 class Value;
40 class OpenMPIRBuilder;
41 } // namespace llvm
42 
43 namespace clang {
44 class Expr;
45 class OMPDependClause;
46 class OMPExecutableDirective;
47 class OMPLoopDirective;
48 class VarDecl;
49 class OMPDeclareReductionDecl;
50 
51 namespace CodeGen {
52 class Address;
53 class CodeGenFunction;
54 class CodeGenModule;
55 
56 /// A basic class for pre|post-action for advanced codegen sequence for OpenMP
57 /// region.
59 public:
60  explicit PrePostActionTy() {}
61  virtual void Enter(CodeGenFunction &CGF) {}
62  virtual void Exit(CodeGenFunction &CGF) {}
63  virtual ~PrePostActionTy() {}
64 };
65 
66 /// Class provides a way to call simple version of codegen for OpenMP region, or
67 /// an advanced with possible pre|post-actions in codegen.
68 class RegionCodeGenTy final {
69  intptr_t CodeGen;
70  typedef void (*CodeGenTy)(intptr_t, CodeGenFunction &, PrePostActionTy &);
71  CodeGenTy Callback;
72  mutable PrePostActionTy *PrePostAction;
73  RegionCodeGenTy() = delete;
74  template <typename Callable>
75  static void CallbackFn(intptr_t CodeGen, CodeGenFunction &CGF,
76  PrePostActionTy &Action) {
77  return (*reinterpret_cast<Callable *>(CodeGen))(CGF, Action);
78  }
79 
80 public:
81  template <typename Callable>
83  Callable &&CodeGen,
84  std::enable_if_t<!std::is_same<std::remove_reference_t<Callable>,
85  RegionCodeGenTy>::value> * = nullptr)
86  : CodeGen(reinterpret_cast<intptr_t>(&CodeGen)),
87  Callback(CallbackFn<std::remove_reference_t<Callable>>),
88  PrePostAction(nullptr) {}
89  void setAction(PrePostActionTy &Action) const { PrePostAction = &Action; }
90  void operator()(CodeGenFunction &CGF) const;
91 };
92 
93 struct OMPTaskDataTy final {
106  struct DependData {
108  const Expr *IteratorExpr = nullptr;
110  explicit DependData() = default;
113  };
115  llvm::PointerIntPair<llvm::Value *, 1, bool> Final;
116  llvm::PointerIntPair<llvm::Value *, 1, bool> Schedule;
117  llvm::PointerIntPair<llvm::Value *, 1, bool> Priority;
118  llvm::Value *Reductions = nullptr;
119  unsigned NumberOfParts = 0;
120  bool Tied = true;
121  bool Nogroup = false;
124 };
125 
126 /// Class intended to support codegen of all kind of the reduction clauses.
128 private:
129  /// Data required for codegen of reduction clauses.
130  struct ReductionData {
131  /// Reference to the item shared between tasks to reduce into.
132  const Expr *Shared = nullptr;
133  /// Reference to the original item.
134  const Expr *Ref = nullptr;
135  /// Helper expression for generation of private copy.
136  const Expr *Private = nullptr;
137  /// Helper expression for generation reduction operation.
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) {
142  }
143  };
144  /// List of reduction-based clauses.
145  SmallVector<ReductionData, 4> ClausesData;
146 
147  /// List of addresses of shared variables/expressions.
148  SmallVector<std::pair<LValue, LValue>, 4> SharedAddresses;
149  /// List of addresses of original variables/expressions.
150  SmallVector<std::pair<LValue, LValue>, 4> OrigAddresses;
151  /// Sizes of the reduction items in chars.
153  /// Base declarations for the reduction items.
155 
156  /// Emits lvalue for shared expression.
157  LValue emitSharedLValue(CodeGenFunction &CGF, const Expr *E);
158  /// Emits upper bound for shared expression (if array section).
159  LValue emitSharedLValueUB(CodeGenFunction &CGF, const Expr *E);
160  /// Performs aggregate initialization.
161  /// \param N Number of reduction item in the common list.
162  /// \param PrivateAddr Address of the corresponding private item.
163  /// \param SharedAddr Address of the original shared variable.
164  /// \param DRD Declare reduction construct used for reduction item.
165  void emitAggregateInitialization(CodeGenFunction &CGF, unsigned N,
166  Address PrivateAddr, Address SharedAddr,
167  const OMPDeclareReductionDecl *DRD);
168 
169 public:
171  ArrayRef<const Expr *> Privates,
172  ArrayRef<const Expr *> ReductionOps);
173  /// Emits lvalue for the shared and original reduction item.
174  /// \param N Number of the reduction item.
175  void emitSharedOrigLValue(CodeGenFunction &CGF, unsigned N);
176  /// Emits the code for the variable-modified type, if required.
177  /// \param N Number of the reduction item.
178  void emitAggregateType(CodeGenFunction &CGF, unsigned N);
179  /// Emits the code for the variable-modified type, if required.
180  /// \param N Number of the reduction item.
181  /// \param Size Size of the type in chars.
182  void emitAggregateType(CodeGenFunction &CGF, unsigned N, llvm::Value *Size);
183  /// Performs initialization of the private copy for the reduction item.
184  /// \param N Number of the reduction item.
185  /// \param PrivateAddr Address of the corresponding private item.
186  /// \param DefaultInit Default initialization sequence that should be
187  /// performed if no reduction specific initialization is found.
188  /// \param SharedAddr Address of the original shared variable.
189  void
190  emitInitialization(CodeGenFunction &CGF, unsigned N, Address PrivateAddr,
191  Address SharedAddr,
192  llvm::function_ref<bool(CodeGenFunction &)> DefaultInit);
193  /// Returns true if the private copy requires cleanups.
194  bool needCleanups(unsigned N);
195  /// Emits cleanup code for the reduction item.
196  /// \param N Number of the reduction item.
197  /// \param PrivateAddr Address of the corresponding private item.
198  void emitCleanups(CodeGenFunction &CGF, unsigned N, Address PrivateAddr);
199  /// Adjusts \p PrivatedAddr for using instead of the original variable
200  /// address in normal operations.
201  /// \param N Number of the reduction item.
202  /// \param PrivateAddr Address of the corresponding private item.
204  Address PrivateAddr);
205  /// Returns LValue for the reduction item.
206  LValue getSharedLValue(unsigned N) const { return SharedAddresses[N].first; }
207  /// Returns LValue for the original reduction item.
208  LValue getOrigLValue(unsigned N) const { return OrigAddresses[N].first; }
209  /// Returns the size of the reduction item (in chars and total number of
210  /// elements in the item), or nullptr, if the size is a constant.
211  std::pair<llvm::Value *, llvm::Value *> getSizes(unsigned N) const {
212  return Sizes[N];
213  }
214  /// Returns the base declaration of the reduction item.
215  const VarDecl *getBaseDecl(unsigned N) const { return BaseDecls[N]; }
216  /// Returns the base declaration of the reduction item.
217  const Expr *getRefExpr(unsigned N) const { return ClausesData[N].Ref; }
218  /// Returns true if the initialization of the reduction item uses initializer
219  /// from declare reduction construct.
220  bool usesReductionInitializer(unsigned N) const;
221  /// Return the type of the private item.
222  QualType getPrivateType(unsigned N) const {
223  return cast<VarDecl>(cast<DeclRefExpr>(ClausesData[N].Private)->getDecl())
224  ->getType();
225  }
226 };
227 
229 public:
230  /// Allows to disable automatic handling of functions used in target regions
231  /// as those marked as `omp declare target`.
233  CodeGenModule &CGM;
234  bool SavedShouldMarkAsGlobal;
235 
236  public:
239  };
240 
241  /// Manages list of nontemporal decls for the specified directive.
243  CodeGenModule &CGM;
244  const bool NeedToPush;
245 
246  public:
249  };
250 
251  /// Manages list of nontemporal decls for the specified directive.
253  CodeGenModule &CGM;
254  const bool NeedToPush;
255 
256  public:
258  CodeGenFunction &CGF,
259  const llvm::MapVector<CanonicalDeclPtr<const VarDecl>,
260  std::pair<Address, Address>> &LocalVars);
262  };
263 
264  /// Maps the expression for the lastprivate variable to the global copy used
265  /// to store new value because original variables are not mapped in inner
266  /// parallel regions. Only private copies are captured but we need also to
267  /// store private copy in shared address.
268  /// Also, stores the expression for the private loop counter and it
269  /// threaprivate name.
271  llvm::MapVector<CanonicalDeclPtr<const Decl>, SmallString<16>>
274  llvm::Function *Fn = nullptr;
275  bool Disabled = false;
276  };
277  /// Manages list of lastprivate conditional decls for the specified directive.
279  enum class ActionToDo {
280  DoNotPush,
281  PushAsLastprivateConditional,
282  DisableLastprivateConditional,
283  };
284  CodeGenModule &CGM;
285  ActionToDo Action = ActionToDo::DoNotPush;
286 
287  /// Check and try to disable analysis of inner regions for changes in
288  /// lastprivate conditional.
289  void tryToDisableInnerAnalysis(const OMPExecutableDirective &S,
291  &NeedToAddForLPCsAsDisabled) const;
292 
294  const OMPExecutableDirective &S);
295 
296  public:
298  const OMPExecutableDirective &S,
299  LValue IVLVal);
301  const OMPExecutableDirective &S);
303  };
304 
305  llvm::OpenMPIRBuilder &getOMPBuilder() { return OMPBuilder; }
306 
307 protected:
310 
311  /// An OpenMP-IR-Builder instance.
312  llvm::OpenMPIRBuilder OMPBuilder;
313 
314  /// Constructor allowing to redefine the name separator for the variables.
315  explicit CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator,
316  StringRef Separator);
317 
318  /// Creates offloading entry for the provided entry ID \a ID,
319  /// address \a Addr, size \a Size, and flags \a Flags.
320  virtual void createOffloadEntry(llvm::Constant *ID, llvm::Constant *Addr,
321  uint64_t Size, int32_t Flags,
322  llvm::GlobalValue::LinkageTypes Linkage);
323 
324  /// Helper to emit outlined function for 'target' directive.
325  /// \param D Directive to emit.
326  /// \param ParentName Name of the function that encloses the target region.
327  /// \param OutlinedFn Outlined function value to be defined by this call.
328  /// \param OutlinedFnID Outlined function ID value to be defined by this call.
329  /// \param IsOffloadEntry True if the outlined function is an offload entry.
330  /// \param CodeGen Lambda codegen specific to an accelerator device.
331  /// An outlined function may not be an entry if, e.g. the if clause always
332  /// evaluates to false.
334  StringRef ParentName,
335  llvm::Function *&OutlinedFn,
336  llvm::Constant *&OutlinedFnID,
337  bool IsOffloadEntry,
338  const RegionCodeGenTy &CodeGen);
339 
340  /// Emits object of ident_t type with info for source location.
341  /// \param Flags Flags for OpenMP location.
342  ///
343  llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
344  unsigned Flags = 0);
345 
346  /// Emit the number of teams for a target directive. Inspect the num_teams
347  /// clause associated with a teams construct combined or closely nested
348  /// with the target directive.
349  ///
350  /// Emit a team of size one for directives such as 'target parallel' that
351  /// have no associated teams construct.
352  ///
353  /// Otherwise, return nullptr.
355  const OMPExecutableDirective &D,
356  int32_t &DefaultVal);
358  const OMPExecutableDirective &D);
359  /// Emit the number of threads for a target directive. Inspect the
360  /// thread_limit clause associated with a teams construct combined or closely
361  /// nested with the target directive.
362  ///
363  /// Emit the num_threads clause for directives such as 'target parallel' that
364  /// have no associated teams construct.
365  ///
366  /// Otherwise, return nullptr.
367  const Expr *
369  const OMPExecutableDirective &D,
370  int32_t &DefaultVal);
371  llvm::Value *
373  const OMPExecutableDirective &D);
374 
375  /// Returns pointer to ident_t type.
376  llvm::Type *getIdentTyPointerTy();
377 
378  /// Gets thread id value for the current thread.
379  ///
380  llvm::Value *getThreadID(CodeGenFunction &CGF, SourceLocation Loc);
381 
382  /// Get the function name of an outlined region.
383  // The name can be customized depending on the target.
384  //
385  virtual StringRef getOutlinedHelperName() const { return ".omp_outlined."; }
386 
387  /// Emits \p Callee function call with arguments \p Args with location \p Loc.
388  void emitCall(CodeGenFunction &CGF, SourceLocation Loc,
389  llvm::FunctionCallee Callee,
390  ArrayRef<llvm::Value *> Args = llvm::None) const;
391 
392  /// Emits address of the word in a memory where current thread id is
393  /// stored.
395 
397  bool AtCurrentPoint = false);
399 
400  /// Check if the default location must be constant.
401  /// Default is false to support OMPT/OMPD.
402  virtual bool isDefaultLocationConstant() const { return false; }
403 
404  /// Returns additional flags that can be stored in reserved_2 field of the
405  /// default location.
406  virtual unsigned getDefaultLocationReserved2Flags() const { return 0; }
407 
408  /// Returns default flags for the barriers depending on the directive, for
409  /// which this barier is going to be emitted.
411 
412  /// Get the LLVM type for the critical name.
413  llvm::ArrayType *getKmpCriticalNameTy() const {return KmpCriticalNameTy;}
414 
415  /// Returns corresponding lock object for the specified critical region
416  /// name. If the lock object does not exist it is created, otherwise the
417  /// reference to the existing copy is returned.
418  /// \param CriticalName Name of the critical region.
419  ///
420  llvm::Value *getCriticalRegionLock(StringRef CriticalName);
421 
422 private:
423 
424  /// Map for SourceLocation and OpenMP runtime library debug locations.
425  typedef llvm::DenseMap<SourceLocation, llvm::Value *> OpenMPDebugLocMapTy;
426  OpenMPDebugLocMapTy OpenMPDebugLocMap;
427  /// The type for a microtask which gets passed to __kmpc_fork_call().
428  /// Original representation is:
429  /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...);
430  llvm::FunctionType *Kmpc_MicroTy = nullptr;
431  /// Stores debug location and ThreadID for the function.
432  struct DebugLocThreadIdTy {
433  llvm::Value *DebugLoc;
434  llvm::Value *ThreadID;
435  /// Insert point for the service instructions.
436  llvm::AssertingVH<llvm::Instruction> ServiceInsertPt = nullptr;
437  };
438  /// Map of local debug location, ThreadId and functions.
439  typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy>
440  OpenMPLocThreadIDMapTy;
441  OpenMPLocThreadIDMapTy OpenMPLocThreadIDMap;
442  /// Map of UDRs and corresponding combiner/initializer.
443  typedef llvm::DenseMap<const OMPDeclareReductionDecl *,
444  std::pair<llvm::Function *, llvm::Function *>>
445  UDRMapTy;
446  UDRMapTy UDRMap;
447  /// Map of functions and locally defined UDRs.
448  typedef llvm::DenseMap<llvm::Function *,
450  FunctionUDRMapTy;
451  FunctionUDRMapTy FunctionUDRMap;
452  /// Map from the user-defined mapper declaration to its corresponding
453  /// functions.
454  llvm::DenseMap<const OMPDeclareMapperDecl *, llvm::Function *> UDMMap;
455  /// Map of functions and their local user-defined mappers.
456  using FunctionUDMMapTy =
457  llvm::DenseMap<llvm::Function *,
459  FunctionUDMMapTy FunctionUDMMap;
460  /// Maps local variables marked as lastprivate conditional to their internal
461  /// types.
462  llvm::DenseMap<llvm::Function *,
463  llvm::DenseMap<CanonicalDeclPtr<const Decl>,
464  std::tuple<QualType, const FieldDecl *,
465  const FieldDecl *, LValue>>>
466  LastprivateConditionalToTypes;
467  /// Maps function to the position of the untied task locals stack.
468  llvm::DenseMap<llvm::Function *, unsigned> FunctionToUntiedTaskStackMap;
469  /// Type kmp_critical_name, originally defined as typedef kmp_int32
470  /// kmp_critical_name[8];
471  llvm::ArrayType *KmpCriticalNameTy;
472  /// An ordered map of auto-generated variables to their unique names.
473  /// It stores variables with the following names: 1) ".gomp_critical_user_" +
474  /// <critical_section_name> + ".var" for "omp critical" directives; 2)
475  /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
476  /// variables.
477  llvm::StringMap<llvm::AssertingVH<llvm::GlobalVariable>,
478  llvm::BumpPtrAllocator> InternalVars;
479  /// Type typedef kmp_int32 (* kmp_routine_entry_t)(kmp_int32, void *);
480  llvm::Type *KmpRoutineEntryPtrTy = nullptr;
481  QualType KmpRoutineEntryPtrQTy;
482  /// Type typedef struct kmp_task {
483  /// void * shareds; /**< pointer to block of pointers to
484  /// shared vars */
485  /// kmp_routine_entry_t routine; /**< pointer to routine to call for
486  /// executing task */
487  /// kmp_int32 part_id; /**< part id for the task */
488  /// kmp_routine_entry_t destructors; /* pointer to function to invoke
489  /// deconstructors of firstprivate C++ objects */
490  /// } kmp_task_t;
491  QualType KmpTaskTQTy;
492  /// Saved kmp_task_t for task directive.
493  QualType SavedKmpTaskTQTy;
494  /// Saved kmp_task_t for taskloop-based directive.
495  QualType SavedKmpTaskloopTQTy;
496  /// Type typedef struct kmp_depend_info {
497  /// kmp_intptr_t base_addr;
498  /// size_t len;
499  /// struct {
500  /// bool in:1;
501  /// bool out:1;
502  /// } flags;
503  /// } kmp_depend_info_t;
504  QualType KmpDependInfoTy;
505  /// Type typedef struct kmp_task_affinity_info {
506  /// kmp_intptr_t base_addr;
507  /// size_t len;
508  /// struct {
509  /// bool flag1 : 1;
510  /// bool flag2 : 1;
511  /// kmp_int32 reserved : 30;
512  /// } flags;
513  /// } kmp_task_affinity_info_t;
514  QualType KmpTaskAffinityInfoTy;
515  /// struct kmp_dim { // loop bounds info casted to kmp_int64
516  /// kmp_int64 lo; // lower
517  /// kmp_int64 up; // upper
518  /// kmp_int64 st; // stride
519  /// };
520  QualType KmpDimTy;
521  /// Entity that registers the offloading constants that were emitted so
522  /// far.
523  class OffloadEntriesInfoManagerTy {
524  CodeGenModule &CGM;
525 
526  /// Number of entries registered so far.
527  unsigned OffloadingEntriesNum = 0;
528 
529  public:
530  /// Base class of the entries info.
532  public:
533  /// Kind of a given entry.
534  enum OffloadingEntryInfoKinds : unsigned {
535  /// Entry is a target region.
537  /// Entry is a declare target variable.
539  /// Invalid entry info.
541  };
542 
543  protected:
544  OffloadEntryInfo() = delete;
545  explicit OffloadEntryInfo(OffloadingEntryInfoKinds Kind) : Kind(Kind) {}
546  explicit OffloadEntryInfo(OffloadingEntryInfoKinds Kind, unsigned Order,
547  uint32_t Flags)
548  : Flags(Flags), Order(Order), Kind(Kind) {}
549  ~OffloadEntryInfo() = default;
550 
551  public:
552  bool isValid() const { return Order != ~0u; }
553  unsigned getOrder() const { return Order; }
554  OffloadingEntryInfoKinds getKind() const { return Kind; }
555  uint32_t getFlags() const { return Flags; }
556  void setFlags(uint32_t NewFlags) { Flags = NewFlags; }
557  llvm::Constant *getAddress() const {
558  return cast_or_null<llvm::Constant>(Addr);
559  }
560  void setAddress(llvm::Constant *V) {
561  assert(!Addr.pointsToAliveValue() && "Address has been set before!");
562  Addr = V;
563  }
564  static bool classof(const OffloadEntryInfo *Info) { return true; }
565 
566  private:
567  /// Address of the entity that has to be mapped for offloading.
568  llvm::WeakTrackingVH Addr;
569 
570  /// Flags associated with the device global.
571  uint32_t Flags = 0u;
572 
573  /// Order this entry was emitted.
574  unsigned Order = ~0u;
575 
577  };
578 
579  /// Return true if a there are no entries defined.
580  bool empty() const;
581  /// Return number of entries defined so far.
582  unsigned size() const { return OffloadingEntriesNum; }
583  OffloadEntriesInfoManagerTy(CodeGenModule &CGM) : CGM(CGM) {}
584 
585  //
586  // Target region entries related.
587  //
588 
589  /// Kind of the target registry entry.
590  enum OMPTargetRegionEntryKind : uint32_t {
591  /// Mark the entry as target region.
592  OMPTargetRegionEntryTargetRegion = 0x0,
593  /// Mark the entry as a global constructor.
594  OMPTargetRegionEntryCtor = 0x02,
595  /// Mark the entry as a global destructor.
596  OMPTargetRegionEntryDtor = 0x04,
597  };
598 
599  /// Target region entries info.
601  /// Address that can be used as the ID of the entry.
602  llvm::Constant *ID = nullptr;
603 
604  public:
607  explicit OffloadEntryInfoTargetRegion(unsigned Order,
608  llvm::Constant *Addr,
609  llvm::Constant *ID,
610  OMPTargetRegionEntryKind Flags)
612  ID(ID) {
613  setAddress(Addr);
614  }
615 
616  llvm::Constant *getID() const { return ID; }
617  void setID(llvm::Constant *V) {
618  assert(!ID && "ID has been set before!");
619  ID = V;
620  }
621  static bool classof(const OffloadEntryInfo *Info) {
622  return Info->getKind() == OffloadingEntryInfoTargetRegion;
623  }
624  };
625 
626  /// Initialize target region entry.
627  void initializeTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
628  StringRef ParentName, unsigned LineNum,
629  unsigned Order);
630  /// Register target region entry.
631  void registerTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
632  StringRef ParentName, unsigned LineNum,
633  llvm::Constant *Addr, llvm::Constant *ID,
634  OMPTargetRegionEntryKind Flags);
635  /// Return true if a target region entry with the provided information
636  /// exists.
637  bool hasTargetRegionEntryInfo(unsigned DeviceID, unsigned FileID,
638  StringRef ParentName, unsigned LineNum,
639  bool IgnoreAddressId = false) const;
640  /// brief Applies action \a Action on all registered entries.
641  typedef llvm::function_ref<void(unsigned, unsigned, StringRef, unsigned,
642  const OffloadEntryInfoTargetRegion &)>
643  OffloadTargetRegionEntryInfoActTy;
644  void actOnTargetRegionEntriesInfo(
645  const OffloadTargetRegionEntryInfoActTy &Action);
646 
647  //
648  // Device global variable entries related.
649  //
650 
651  /// Kind of the global variable entry..
652  enum OMPTargetGlobalVarEntryKind : uint32_t {
653  /// Mark the entry as a to declare target.
654  OMPTargetGlobalVarEntryTo = 0x0,
655  /// Mark the entry as a to declare target link.
656  OMPTargetGlobalVarEntryLink = 0x1,
657  };
658 
659  /// Device global variable entries info.
661  /// Type of the global variable.
662  CharUnits VarSize;
663  llvm::GlobalValue::LinkageTypes Linkage;
664 
665  public:
668  explicit OffloadEntryInfoDeviceGlobalVar(unsigned Order,
669  OMPTargetGlobalVarEntryKind Flags)
672  unsigned Order, llvm::Constant *Addr, CharUnits VarSize,
673  OMPTargetGlobalVarEntryKind Flags,
674  llvm::GlobalValue::LinkageTypes Linkage)
676  VarSize(VarSize), Linkage(Linkage) {
677  setAddress(Addr);
678  }
679 
680  CharUnits getVarSize() const { return VarSize; }
681  void setVarSize(CharUnits Size) { VarSize = Size; }
682  llvm::GlobalValue::LinkageTypes getLinkage() const { return Linkage; }
683  void setLinkage(llvm::GlobalValue::LinkageTypes LT) { Linkage = LT; }
684  static bool classof(const OffloadEntryInfo *Info) {
686  }
687  };
688 
689  /// Initialize device global variable entry.
690  void initializeDeviceGlobalVarEntryInfo(StringRef Name,
691  OMPTargetGlobalVarEntryKind Flags,
692  unsigned Order);
693 
694  /// Register device global variable entry.
695  void
696  registerDeviceGlobalVarEntryInfo(StringRef VarName, llvm::Constant *Addr,
697  CharUnits VarSize,
698  OMPTargetGlobalVarEntryKind Flags,
699  llvm::GlobalValue::LinkageTypes Linkage);
700  /// Checks if the variable with the given name has been registered already.
701  bool hasDeviceGlobalVarEntryInfo(StringRef VarName) const {
702  return OffloadEntriesDeviceGlobalVar.count(VarName) > 0;
703  }
704  /// Applies action \a Action on all registered entries.
705  typedef llvm::function_ref<void(StringRef,
706  const OffloadEntryInfoDeviceGlobalVar &)>
707  OffloadDeviceGlobalVarEntryInfoActTy;
708  void actOnDeviceGlobalVarEntriesInfo(
709  const OffloadDeviceGlobalVarEntryInfoActTy &Action);
710 
711  private:
712  // Storage for target region entries kind. The storage is to be indexed by
713  // file ID, device ID, parent function name and line number.
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;
724  /// Storage for device global variable entries kind. The storage is to be
725  /// indexed by mangled name.
726  typedef llvm::StringMap<OffloadEntryInfoDeviceGlobalVar>
727  OffloadEntriesDeviceGlobalVarTy;
728  OffloadEntriesDeviceGlobalVarTy OffloadEntriesDeviceGlobalVar;
729  };
730  OffloadEntriesInfoManagerTy OffloadEntriesInfoManager;
731 
732  bool ShouldMarkAsGlobal = true;
733  /// List of the emitted declarations.
734  llvm::DenseSet<CanonicalDeclPtr<const Decl>> AlreadyEmittedTargetDecls;
735  /// List of the global variables with their addresses that should not be
736  /// emitted for the target.
737  llvm::StringMap<llvm::WeakTrackingVH> EmittedNonTargetVariables;
738 
739  /// List of variables that can become declare target implicitly and, thus,
740  /// must be emitted.
741  llvm::SmallDenseSet<const VarDecl *> DeferredGlobalVariables;
742 
743  using NontemporalDeclsSet = llvm::SmallDenseSet<CanonicalDeclPtr<const Decl>>;
744  /// Stack for list of declarations in current context marked as nontemporal.
745  /// The set is the union of all current stack elements.
746  llvm::SmallVector<NontemporalDeclsSet, 4> NontemporalDeclsStack;
747 
748  using UntiedLocalVarsAddressesMap =
749  llvm::MapVector<CanonicalDeclPtr<const VarDecl>,
750  std::pair<Address, Address>>;
752 
753  /// Stack for list of addresses of declarations in current context marked as
754  /// lastprivate conditional. The set is the union of all current stack
755  /// elements.
756  llvm::SmallVector<LastprivateConditionalData, 4> LastprivateConditionalStack;
757 
758  /// Flag for keeping track of weather a requires unified_shared_memory
759  /// directive is present.
760  bool HasRequiresUnifiedSharedMemory = false;
761 
762  /// Atomic ordering from the omp requires directive.
763  llvm::AtomicOrdering RequiresAtomicOrdering = llvm::AtomicOrdering::Monotonic;
764 
765  /// Flag for keeping track of weather a target region has been emitted.
766  bool HasEmittedTargetRegion = false;
767 
768  /// Flag for keeping track of weather a device routine has been emitted.
769  /// Device routines are specific to the
770  bool HasEmittedDeclareTargetRegion = false;
771 
772  /// Loads all the offload entries information from the host IR
773  /// metadata.
774  void loadOffloadInfoMetadata();
775 
776  /// Start scanning from statement \a S and and emit all target regions
777  /// found along the way.
778  /// \param S Starting statement.
779  /// \param ParentName Name of the function declaration that is being scanned.
780  void scanForTargetRegionsFunctions(const Stmt *S, StringRef ParentName);
781 
782  /// Build type kmp_routine_entry_t (if not built yet).
783  void emitKmpRoutineEntryT(QualType KmpInt32Ty);
784 
785  /// Returns pointer to kmpc_micro type.
786  llvm::Type *getKmpc_MicroPointerTy();
787 
788  /// Returns __kmpc_for_static_init_* runtime function for the specified
789  /// size \a IVSize and sign \a IVSigned. Will create a distribute call
790  /// __kmpc_distribute_static_init* if \a IsGPUDistribute is set.
791  llvm::FunctionCallee createForStaticInitFunction(unsigned IVSize,
792  bool IVSigned,
793  bool IsGPUDistribute);
794 
795  /// Returns __kmpc_dispatch_init_* runtime function for the specified
796  /// size \a IVSize and sign \a IVSigned.
797  llvm::FunctionCallee createDispatchInitFunction(unsigned IVSize,
798  bool IVSigned);
799 
800  /// Returns __kmpc_dispatch_next_* runtime function for the specified
801  /// size \a IVSize and sign \a IVSigned.
802  llvm::FunctionCallee createDispatchNextFunction(unsigned IVSize,
803  bool IVSigned);
804 
805  /// Returns __kmpc_dispatch_fini_* runtime function for the specified
806  /// size \a IVSize and sign \a IVSigned.
807  llvm::FunctionCallee createDispatchFiniFunction(unsigned IVSize,
808  bool IVSigned);
809 
810  /// If the specified mangled name is not in the module, create and
811  /// return threadprivate cache object. This object is a pointer's worth of
812  /// storage that's reserved for use by the OpenMP runtime.
813  /// \param VD Threadprivate variable.
814  /// \return Cache variable for the specified threadprivate.
815  llvm::Constant *getOrCreateThreadPrivateCache(const VarDecl *VD);
816 
817  /// Gets (if variable with the given name already exist) or creates
818  /// internal global variable with the specified Name. The created variable has
819  /// linkage CommonLinkage by default and is initialized by null value.
820  /// \param Ty Type of the global variable. If it is exist already the type
821  /// must be the same.
822  /// \param Name Name of the variable.
823  llvm::GlobalVariable *getOrCreateInternalVariable(llvm::Type *Ty,
824  const llvm::Twine &Name,
825  unsigned AddressSpace = 0);
826 
827  /// Set of threadprivate variables with the generated initializer.
828  llvm::StringSet<> ThreadPrivateWithDefinition;
829 
830  /// Set of declare target variables with the generated initializer.
831  llvm::StringSet<> DeclareTargetWithDefinition;
832 
833  /// Emits initialization code for the threadprivate variables.
834  /// \param VDAddr Address of the global variable \a VD.
835  /// \param Ctor Pointer to a global init function for \a VD.
836  /// \param CopyCtor Pointer to a global copy function for \a VD.
837  /// \param Dtor Pointer to a global destructor function for \a VD.
838  /// \param Loc Location of threadprivate declaration.
839  void emitThreadPrivateVarInit(CodeGenFunction &CGF, Address VDAddr,
840  llvm::Value *Ctor, llvm::Value *CopyCtor,
841  llvm::Value *Dtor, SourceLocation Loc);
842 
843  /// Emit the array initialization or deletion portion for user-defined mapper
844  /// code generation.
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,
849  CharUnits ElementSize,
850  llvm::BasicBlock *ExitBB, bool IsInit);
851 
852  struct TaskResultTy {
853  llvm::Value *NewTask = nullptr;
854  llvm::Function *TaskEntry = nullptr;
855  llvm::Value *NewTaskNewTaskTTy = nullptr;
856  LValue TDBase;
857  const RecordDecl *KmpTaskTQTyRD = nullptr;
858  llvm::Value *TaskDupFn = nullptr;
859  };
860  /// Emit task region for the task directive. The task region is emitted in
861  /// several steps:
862  /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
863  /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
864  /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
865  /// function:
866  /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
867  /// TaskFunction(gtid, tt->part_id, tt->shareds);
868  /// return 0;
869  /// }
870  /// 2. Copy a list of shared variables to field shareds of the resulting
871  /// structure kmp_task_t returned by the previous call (if any).
872  /// 3. Copy a pointer to destructions function to field destructions of the
873  /// resulting structure kmp_task_t.
874  /// \param D Current task directive.
875  /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
876  /// /*part_id*/, captured_struct */*__context*/);
877  /// \param SharedsTy A type which contains references the shared variables.
878  /// \param Shareds Context with the list of shared variables from the \p
879  /// TaskFunction.
880  /// \param Data Additional data for task generation like tiednsee, final
881  /// state, list of privates etc.
882  TaskResultTy emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
883  const OMPExecutableDirective &D,
884  llvm::Function *TaskFunction, QualType SharedsTy,
885  Address Shareds, const OMPTaskDataTy &Data);
886 
887  /// Emit code that pushes the trip count of loops associated with constructs
888  /// 'target teams distribute' and 'teams distribute parallel for'.
889  /// \param SizeEmitter Emits the int64 value for the number of iterations of
890  /// the associated loop.
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)>
896  SizeEmitter);
897 
898  /// Emit update for lastprivate conditional data.
899  void emitLastprivateConditionalUpdate(CodeGenFunction &CGF, LValue IVLVal,
900  StringRef UniqueDeclName, LValue LVal,
901  SourceLocation Loc);
902 
903  /// Returns the number of the elements and the address of the depobj
904  /// dependency array.
905  /// \return Number of elements in depobj array and the pointer to the array of
906  /// dependencies.
907  std::pair<llvm::Value *, LValue> getDepobjElements(CodeGenFunction &CGF,
908  LValue DepobjLVal,
909  SourceLocation Loc);
910 
911  SmallVector<llvm::Value *, 4>
912  emitDepobjElementsSizes(CodeGenFunction &CGF, QualType &KmpDependInfoTy,
913  const OMPTaskDataTy::DependData &Data);
914 
915  void emitDepobjElements(CodeGenFunction &CGF, QualType &KmpDependInfoTy,
916  LValue PosLVal, const OMPTaskDataTy::DependData &Data,
917  Address DependenciesArray);
918 
919 public:
921  : CGOpenMPRuntime(CGM, ".", ".") {}
922  virtual ~CGOpenMPRuntime() {}
923  virtual void clear();
924 
925  /// Emits code for OpenMP 'if' clause using specified \a CodeGen
926  /// function. Here is the logic:
927  /// if (Cond) {
928  /// ThenGen();
929  /// } else {
930  /// ElseGen();
931  /// }
932  void emitIfClause(CodeGenFunction &CGF, const Expr *Cond,
933  const RegionCodeGenTy &ThenGen,
934  const RegionCodeGenTy &ElseGen);
935 
936  /// Checks if the \p Body is the \a CompoundStmt and returns its child
937  /// statement iff there is only one that is not evaluatable at the compile
938  /// time.
939  static const Stmt *getSingleCompoundChild(ASTContext &Ctx, const Stmt *Body);
940 
941  /// Get the platform-specific name separator.
943 
944  /// Emit code for the specified user defined reduction construct.
945  virtual void emitUserDefinedReduction(CodeGenFunction *CGF,
946  const OMPDeclareReductionDecl *D);
947  /// Get combiner/initializer for the specified user-defined reduction, if any.
948  virtual std::pair<llvm::Function *, llvm::Function *>
950 
951  /// Emit the function for the user defined mapper construct.
953  CodeGenFunction *CGF = nullptr);
954  /// Get the function for the specified user-defined mapper. If it does not
955  /// exist, create one.
956  llvm::Function *
958 
959  /// Emits outlined function for the specified OpenMP parallel directive
960  /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
961  /// kmp_int32 BoundID, struct context_vars*).
962  /// \param D OpenMP directive.
963  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
964  /// \param InnermostKind Kind of innermost directive (for simple directives it
965  /// is a directive itself, for combined - its innermost directive).
966  /// \param CodeGen Code generation sequence for the \a D directive.
967  virtual llvm::Function *emitParallelOutlinedFunction(
968  const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
969  OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen);
970 
971  /// Emits outlined function for the specified OpenMP teams directive
972  /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
973  /// kmp_int32 BoundID, struct context_vars*).
974  /// \param D OpenMP directive.
975  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
976  /// \param InnermostKind Kind of innermost directive (for simple directives it
977  /// is a directive itself, for combined - its innermost directive).
978  /// \param CodeGen Code generation sequence for the \a D directive.
979  virtual llvm::Function *emitTeamsOutlinedFunction(
980  const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
981  OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen);
982 
983  /// Emits outlined function for the OpenMP task directive \a D. This
984  /// outlined function has type void(*)(kmp_int32 ThreadID, struct task_t*
985  /// TaskT).
986  /// \param D OpenMP directive.
987  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
988  /// \param PartIDVar Variable for partition id in the current OpenMP untied
989  /// task region.
990  /// \param TaskTVar Variable for task_t argument.
991  /// \param InnermostKind Kind of innermost directive (for simple directives it
992  /// is a directive itself, for combined - its innermost directive).
993  /// \param CodeGen Code generation sequence for the \a D directive.
994  /// \param Tied true if task is generated for tied task, false otherwise.
995  /// \param NumberOfParts Number of parts in untied task. Ignored for tied
996  /// tasks.
997  ///
998  virtual llvm::Function *emitTaskOutlinedFunction(
999  const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
1000  const VarDecl *PartIDVar, const VarDecl *TaskTVar,
1001  OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen,
1002  bool Tied, unsigned &NumberOfParts);
1003 
1004  /// Cleans up references to the objects in finished function.
1005  ///
1006  virtual void functionFinished(CodeGenFunction &CGF);
1007 
1008  /// Emits code for parallel or serial call of the \a OutlinedFn with
1009  /// variables captured in a record which address is stored in \a
1010  /// CapturedStruct.
1011  /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
1012  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
1013  /// \param CapturedVars A pointer to the record with the references to
1014  /// variables used in \a OutlinedFn function.
1015  /// \param IfCond Condition in the associated 'if' clause, if it was
1016  /// specified, nullptr otherwise.
1017  /// \param NumThreads The value corresponding to the num_threads clause, if
1018  /// any, or nullptr.
1019  ///
1020  virtual void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
1021  llvm::Function *OutlinedFn,
1022  ArrayRef<llvm::Value *> CapturedVars,
1023  const Expr *IfCond, llvm::Value *NumThreads);
1024 
1025  /// Emits a critical region.
1026  /// \param CriticalName Name of the critical region.
1027  /// \param CriticalOpGen Generator for the statement associated with the given
1028  /// critical region.
1029  /// \param Hint Value of the 'hint' clause (optional).
1030  virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
1031  const RegionCodeGenTy &CriticalOpGen,
1032  SourceLocation Loc,
1033  const Expr *Hint = nullptr);
1034 
1035  /// Emits a master region.
1036  /// \param MasterOpGen Generator for the statement associated with the given
1037  /// master region.
1038  virtual void emitMasterRegion(CodeGenFunction &CGF,
1039  const RegionCodeGenTy &MasterOpGen,
1040  SourceLocation Loc);
1041 
1042  /// Emits a masked region.
1043  /// \param MaskedOpGen Generator for the statement associated with the given
1044  /// masked region.
1045  virtual void emitMaskedRegion(CodeGenFunction &CGF,
1046  const RegionCodeGenTy &MaskedOpGen,
1047  SourceLocation Loc,
1048  const Expr *Filter = nullptr);
1049 
1050  /// Emits code for a taskyield directive.
1051  virtual void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc);
1052 
1053  /// Emit a taskgroup region.
1054  /// \param TaskgroupOpGen Generator for the statement associated with the
1055  /// given taskgroup region.
1056  virtual void emitTaskgroupRegion(CodeGenFunction &CGF,
1057  const RegionCodeGenTy &TaskgroupOpGen,
1058  SourceLocation Loc);
1059 
1060  /// Emits a single region.
1061  /// \param SingleOpGen Generator for the statement associated with the given
1062  /// single region.
1063  virtual void emitSingleRegion(CodeGenFunction &CGF,
1064  const RegionCodeGenTy &SingleOpGen,
1065  SourceLocation Loc,
1066  ArrayRef<const Expr *> CopyprivateVars,
1067  ArrayRef<const Expr *> DestExprs,
1068  ArrayRef<const Expr *> SrcExprs,
1069  ArrayRef<const Expr *> AssignmentOps);
1070 
1071  /// Emit an ordered region.
1072  /// \param OrderedOpGen Generator for the statement associated with the given
1073  /// ordered region.
1074  virtual void emitOrderedRegion(CodeGenFunction &CGF,
1075  const RegionCodeGenTy &OrderedOpGen,
1076  SourceLocation Loc, bool IsThreads);
1077 
1078  /// Emit an implicit/explicit barrier for OpenMP threads.
1079  /// \param Kind Directive for which this implicit barrier call must be
1080  /// generated. Must be OMPD_barrier for explicit barrier generation.
1081  /// \param EmitChecks true if need to emit checks for cancellation barriers.
1082  /// \param ForceSimpleCall true simple barrier call must be emitted, false if
1083  /// runtime class decides which one to emit (simple or with cancellation
1084  /// checks).
1085  ///
1086  virtual void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc,
1088  bool EmitChecks = true,
1089  bool ForceSimpleCall = false);
1090 
1091  /// Check if the specified \a ScheduleKind is static non-chunked.
1092  /// This kind of worksharing directive is emitted without outer loop.
1093  /// \param ScheduleKind Schedule kind specified in the 'schedule' clause.
1094  /// \param Chunked True if chunk is specified in the clause.
1095  ///
1096  virtual bool isStaticNonchunked(OpenMPScheduleClauseKind ScheduleKind,
1097  bool Chunked) const;
1098 
1099  /// Check if the specified \a ScheduleKind is static non-chunked.
1100  /// This kind of distribute directive is emitted without outer loop.
1101  /// \param ScheduleKind Schedule kind specified in the 'dist_schedule' clause.
1102  /// \param Chunked True if chunk is specified in the clause.
1103  ///
1104  virtual bool isStaticNonchunked(OpenMPDistScheduleClauseKind ScheduleKind,
1105  bool Chunked) const;
1106 
1107  /// Check if the specified \a ScheduleKind is static chunked.
1108  /// \param ScheduleKind Schedule kind specified in the 'schedule' clause.
1109  /// \param Chunked True if chunk is specified in the clause.
1110  ///
1111  virtual bool isStaticChunked(OpenMPScheduleClauseKind ScheduleKind,
1112  bool Chunked) const;
1113 
1114  /// Check if the specified \a ScheduleKind is static non-chunked.
1115  /// \param ScheduleKind Schedule kind specified in the 'dist_schedule' clause.
1116  /// \param Chunked True if chunk is specified in the clause.
1117  ///
1118  virtual bool isStaticChunked(OpenMPDistScheduleClauseKind ScheduleKind,
1119  bool Chunked) const;
1120 
1121  /// Check if the specified \a ScheduleKind is dynamic.
1122  /// This kind of worksharing directive is emitted without outer loop.
1123  /// \param ScheduleKind Schedule Kind specified in the 'schedule' clause.
1124  ///
1125  virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const;
1126 
1127  /// struct with the values to be passed to the dispatch runtime function
1129  /// Loop lower bound
1130  llvm::Value *LB = nullptr;
1131  /// Loop upper bound
1132  llvm::Value *UB = nullptr;
1133  /// Chunk size specified using 'schedule' clause (nullptr if chunk
1134  /// was not specified)
1135  llvm::Value *Chunk = nullptr;
1136  DispatchRTInput() = default;
1137  DispatchRTInput(llvm::Value *LB, llvm::Value *UB, llvm::Value *Chunk)
1138  : LB(LB), UB(UB), Chunk(Chunk) {}
1139  };
1140 
1141  /// Call the appropriate runtime routine to initialize it before start
1142  /// of loop.
1143 
1144  /// This is used for non static scheduled types and when the ordered
1145  /// clause is present on the loop construct.
1146  /// Depending on the loop schedule, it is necessary to call some runtime
1147  /// routine before start of the OpenMP loop to get the loop upper / lower
1148  /// bounds \a LB and \a UB and stride \a ST.
1149  ///
1150  /// \param CGF Reference to current CodeGenFunction.
1151  /// \param Loc Clang source location.
1152  /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
1153  /// \param IVSize Size of the iteration variable in bits.
1154  /// \param IVSigned Sign of the iteration variable.
1155  /// \param Ordered true if loop is ordered, false otherwise.
1156  /// \param DispatchValues struct containing llvm values for lower bound, upper
1157  /// bound, and chunk expression.
1158  /// For the default (nullptr) value, the chunk 1 will be used.
1159  ///
1160  virtual void emitForDispatchInit(CodeGenFunction &CGF, SourceLocation Loc,
1161  const OpenMPScheduleTy &ScheduleKind,
1162  unsigned IVSize, bool IVSigned, bool Ordered,
1163  const DispatchRTInput &DispatchValues);
1164 
1165  /// Struct with the values to be passed to the static runtime function
1166  struct StaticRTInput {
1167  /// Size of the iteration variable in bits.
1168  unsigned IVSize = 0;
1169  /// Sign of the iteration variable.
1170  bool IVSigned = false;
1171  /// true if loop is ordered, false otherwise.
1172  bool Ordered = false;
1173  /// Address of the output variable in which the flag of the last iteration
1174  /// is returned.
1176  /// Address of the output variable in which the lower iteration number is
1177  /// returned.
1179  /// Address of the output variable in which the upper iteration number is
1180  /// returned.
1182  /// Address of the output variable in which the stride value is returned
1183  /// necessary to generated the static_chunked scheduled loop.
1185  /// Value of the chunk for the static_chunked scheduled loop. For the
1186  /// default (nullptr) value, the chunk 1 will be used.
1187  llvm::Value *Chunk = nullptr;
1190  llvm::Value *Chunk = nullptr)
1192  UB(UB), ST(ST), Chunk(Chunk) {}
1193  };
1194  /// Call the appropriate runtime routine to initialize it before start
1195  /// of loop.
1196  ///
1197  /// This is used only in case of static schedule, when the user did not
1198  /// specify a ordered clause on the loop construct.
1199  /// Depending on the loop schedule, it is necessary to call some runtime
1200  /// routine before start of the OpenMP loop to get the loop upper / lower
1201  /// bounds LB and UB and stride ST.
1202  ///
1203  /// \param CGF Reference to current CodeGenFunction.
1204  /// \param Loc Clang source location.
1205  /// \param DKind Kind of the directive.
1206  /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
1207  /// \param Values Input arguments for the construct.
1208  ///
1209  virtual void emitForStaticInit(CodeGenFunction &CGF, SourceLocation Loc,
1210  OpenMPDirectiveKind DKind,
1211  const OpenMPScheduleTy &ScheduleKind,
1212  const StaticRTInput &Values);
1213 
1214  ///
1215  /// \param CGF Reference to current CodeGenFunction.
1216  /// \param Loc Clang source location.
1217  /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
1218  /// \param Values Input arguments for the construct.
1219  ///
1220  virtual void emitDistributeStaticInit(CodeGenFunction &CGF,
1221  SourceLocation Loc,
1222  OpenMPDistScheduleClauseKind SchedKind,
1223  const StaticRTInput &Values);
1224 
1225  /// Call the appropriate runtime routine to notify that we finished
1226  /// iteration of the ordered loop with the dynamic scheduling.
1227  ///
1228  /// \param CGF Reference to current CodeGenFunction.
1229  /// \param Loc Clang source location.
1230  /// \param IVSize Size of the iteration variable in bits.
1231  /// \param IVSigned Sign of the iteration variable.
1232  ///
1233  virtual void emitForOrderedIterationEnd(CodeGenFunction &CGF,
1234  SourceLocation Loc, unsigned IVSize,
1235  bool IVSigned);
1236 
1237  /// Call the appropriate runtime routine to notify that we finished
1238  /// all the work with current loop.
1239  ///
1240  /// \param CGF Reference to current CodeGenFunction.
1241  /// \param Loc Clang source location.
1242  /// \param DKind Kind of the directive for which the static finish is emitted.
1243  ///
1244  virtual void emitForStaticFinish(CodeGenFunction &CGF, SourceLocation Loc,
1245  OpenMPDirectiveKind DKind);
1246 
1247  /// Call __kmpc_dispatch_next(
1248  /// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter,
1249  /// kmp_int[32|64] *p_lower, kmp_int[32|64] *p_upper,
1250  /// kmp_int[32|64] *p_stride);
1251  /// \param IVSize Size of the iteration variable in bits.
1252  /// \param IVSigned Sign of the iteration variable.
1253  /// \param IL Address of the output variable in which the flag of the
1254  /// last iteration is returned.
1255  /// \param LB Address of the output variable in which the lower iteration
1256  /// number is returned.
1257  /// \param UB Address of the output variable in which the upper iteration
1258  /// number is returned.
1259  /// \param ST Address of the output variable in which the stride value is
1260  /// returned.
1261  virtual llvm::Value *emitForNext(CodeGenFunction &CGF, SourceLocation Loc,
1262  unsigned IVSize, bool IVSigned,
1263  Address IL, Address LB,
1264  Address UB, Address ST);
1265 
1266  /// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
1267  /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
1268  /// clause.
1269  /// \param NumThreads An integer value of threads.
1270  virtual void emitNumThreadsClause(CodeGenFunction &CGF,
1271  llvm::Value *NumThreads,
1272  SourceLocation Loc);
1273 
1274  /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
1275  /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
1276  virtual void emitProcBindClause(CodeGenFunction &CGF,
1277  llvm::omp::ProcBindKind ProcBind,
1278  SourceLocation Loc);
1279 
1280  /// Returns address of the threadprivate variable for the current
1281  /// thread.
1282  /// \param VD Threadprivate variable.
1283  /// \param VDAddr Address of the global variable \a VD.
1284  /// \param Loc Location of the reference to threadprivate var.
1285  /// \return Address of the threadprivate variable for the current thread.
1287  const VarDecl *VD,
1288  Address VDAddr,
1289  SourceLocation Loc);
1290 
1291  /// Returns the address of the variable marked as declare target with link
1292  /// clause OR as declare target with to clause and unified memory.
1293  virtual Address getAddrOfDeclareTargetVar(const VarDecl *VD);
1294 
1295  /// Emit a code for initialization of threadprivate variable. It emits
1296  /// a call to runtime library which adds initial value to the newly created
1297  /// threadprivate variable (if it is not constant) and registers destructor
1298  /// for the variable (if any).
1299  /// \param VD Threadprivate variable.
1300  /// \param VDAddr Address of the global variable \a VD.
1301  /// \param Loc Location of threadprivate declaration.
1302  /// \param PerformInit true if initialization expression is not constant.
1303  virtual llvm::Function *
1305  SourceLocation Loc, bool PerformInit,
1306  CodeGenFunction *CGF = nullptr);
1307 
1308  /// Emit a code for initialization of declare target variable.
1309  /// \param VD Declare target variable.
1310  /// \param Addr Address of the global variable \a VD.
1311  /// \param PerformInit true if initialization expression is not constant.
1312  virtual bool emitDeclareTargetVarDefinition(const VarDecl *VD,
1313  llvm::GlobalVariable *Addr,
1314  bool PerformInit);
1315 
1316  /// Creates artificial threadprivate variable with name \p Name and type \p
1317  /// VarType.
1318  /// \param VarType Type of the artificial threadprivate variable.
1319  /// \param Name Name of the artificial threadprivate variable.
1321  QualType VarType,
1322  StringRef Name);
1323 
1324  /// Emit flush of the variables specified in 'omp flush' directive.
1325  /// \param Vars List of variables to flush.
1326  virtual void emitFlush(CodeGenFunction &CGF, ArrayRef<const Expr *> Vars,
1327  SourceLocation Loc, llvm::AtomicOrdering AO);
1328 
1329  /// Emit task region for the task directive. The task region is
1330  /// emitted in several steps:
1331  /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1332  /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1333  /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1334  /// function:
1335  /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1336  /// TaskFunction(gtid, tt->part_id, tt->shareds);
1337  /// return 0;
1338  /// }
1339  /// 2. Copy a list of shared variables to field shareds of the resulting
1340  /// structure kmp_task_t returned by the previous call (if any).
1341  /// 3. Copy a pointer to destructions function to field destructions of the
1342  /// resulting structure kmp_task_t.
1343  /// 4. Emit a call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid,
1344  /// kmp_task_t *new_task), where new_task is a resulting structure from
1345  /// previous items.
1346  /// \param D Current task directive.
1347  /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
1348  /// /*part_id*/, captured_struct */*__context*/);
1349  /// \param SharedsTy A type which contains references the shared variables.
1350  /// \param Shareds Context with the list of shared variables from the \p
1351  /// TaskFunction.
1352  /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
1353  /// otherwise.
1354  /// \param Data Additional data for task generation like tiednsee, final
1355  /// state, list of privates etc.
1356  virtual void emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
1357  const OMPExecutableDirective &D,
1358  llvm::Function *TaskFunction, QualType SharedsTy,
1359  Address Shareds, const Expr *IfCond,
1360  const OMPTaskDataTy &Data);
1361 
1362  /// Emit task region for the taskloop directive. The taskloop region is
1363  /// emitted in several steps:
1364  /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1365  /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1366  /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1367  /// function:
1368  /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1369  /// TaskFunction(gtid, tt->part_id, tt->shareds);
1370  /// return 0;
1371  /// }
1372  /// 2. Copy a list of shared variables to field shareds of the resulting
1373  /// structure kmp_task_t returned by the previous call (if any).
1374  /// 3. Copy a pointer to destructions function to field destructions of the
1375  /// resulting structure kmp_task_t.
1376  /// 4. Emit a call to void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t
1377  /// *task, int if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int
1378  /// nogroup, int sched, kmp_uint64 grainsize, void *task_dup ), where new_task
1379  /// is a resulting structure from
1380  /// previous items.
1381  /// \param D Current task directive.
1382  /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
1383  /// /*part_id*/, captured_struct */*__context*/);
1384  /// \param SharedsTy A type which contains references the shared variables.
1385  /// \param Shareds Context with the list of shared variables from the \p
1386  /// TaskFunction.
1387  /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
1388  /// otherwise.
1389  /// \param Data Additional data for task generation like tiednsee, final
1390  /// state, list of privates etc.
1391  virtual void emitTaskLoopCall(CodeGenFunction &CGF, SourceLocation Loc,
1392  const OMPLoopDirective &D,
1393  llvm::Function *TaskFunction,
1394  QualType SharedsTy, Address Shareds,
1395  const Expr *IfCond, const OMPTaskDataTy &Data);
1396 
1397  /// Emit code for the directive that does not require outlining.
1398  ///
1399  /// \param InnermostKind Kind of innermost directive (for simple directives it
1400  /// is a directive itself, for combined - its innermost directive).
1401  /// \param CodeGen Code generation sequence for the \a D directive.
1402  /// \param HasCancel true if region has inner cancel directive, false
1403  /// otherwise.
1404  virtual void emitInlinedDirective(CodeGenFunction &CGF,
1405  OpenMPDirectiveKind InnermostKind,
1406  const RegionCodeGenTy &CodeGen,
1407  bool HasCancel = false);
1408 
1409  /// Emits reduction function.
1410  /// \param ArgsElemType Array type containing pointers to reduction variables.
1411  /// \param Privates List of private copies for original reduction arguments.
1412  /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
1413  /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
1414  /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
1415  /// or 'operator binop(LHS, RHS)'.
1416  llvm::Function *emitReductionFunction(SourceLocation Loc,
1417  llvm::Type *ArgsElemType,
1418  ArrayRef<const Expr *> Privates,
1419  ArrayRef<const Expr *> LHSExprs,
1420  ArrayRef<const Expr *> RHSExprs,
1421  ArrayRef<const Expr *> ReductionOps);
1422 
1423  /// Emits single reduction combiner
1425  const Expr *ReductionOp,
1426  const Expr *PrivateRef,
1427  const DeclRefExpr *LHS,
1428  const DeclRefExpr *RHS);
1429 
1434  };
1435  /// Emit a code for reduction clause. Next code should be emitted for
1436  /// reduction:
1437  /// \code
1438  ///
1439  /// static kmp_critical_name lock = { 0 };
1440  ///
1441  /// void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
1442  /// ...
1443  /// *(Type<i>*)lhs[i] = RedOp<i>(*(Type<i>*)lhs[i], *(Type<i>*)rhs[i]);
1444  /// ...
1445  /// }
1446  ///
1447  /// ...
1448  /// void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
1449  /// switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList),
1450  /// RedList, reduce_func, &<lock>)) {
1451  /// case 1:
1452  /// ...
1453  /// <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]);
1454  /// ...
1455  /// __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
1456  /// break;
1457  /// case 2:
1458  /// ...
1459  /// Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]));
1460  /// ...
1461  /// break;
1462  /// default:;
1463  /// }
1464  /// \endcode
1465  ///
1466  /// \param Privates List of private copies for original reduction arguments.
1467  /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
1468  /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
1469  /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
1470  /// or 'operator binop(LHS, RHS)'.
1471  /// \param Options List of options for reduction codegen:
1472  /// WithNowait true if parent directive has also nowait clause, false
1473  /// otherwise.
1474  /// SimpleReduction Emit reduction operation only. Used for omp simd
1475  /// directive on the host.
1476  /// ReductionKind The kind of reduction to perform.
1477  virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
1478  ArrayRef<const Expr *> Privates,
1479  ArrayRef<const Expr *> LHSExprs,
1480  ArrayRef<const Expr *> RHSExprs,
1481  ArrayRef<const Expr *> ReductionOps,
1482  ReductionOptionsTy Options);
1483 
1484  /// Emit a code for initialization of task reduction clause. Next code
1485  /// should be emitted for reduction:
1486  /// \code
1487  ///
1488  /// _taskred_item_t red_data[n];
1489  /// ...
1490  /// red_data[i].shar = &shareds[i];
1491  /// red_data[i].orig = &origs[i];
1492  /// red_data[i].size = sizeof(origs[i]);
1493  /// red_data[i].f_init = (void*)RedInit<i>;
1494  /// red_data[i].f_fini = (void*)RedDest<i>;
1495  /// red_data[i].f_comb = (void*)RedOp<i>;
1496  /// red_data[i].flags = <Flag_i>;
1497  /// ...
1498  /// void* tg1 = __kmpc_taskred_init(gtid, n, red_data);
1499  /// \endcode
1500  /// For reduction clause with task modifier it emits the next call:
1501  /// \code
1502  ///
1503  /// _taskred_item_t red_data[n];
1504  /// ...
1505  /// red_data[i].shar = &shareds[i];
1506  /// red_data[i].orig = &origs[i];
1507  /// red_data[i].size = sizeof(origs[i]);
1508  /// red_data[i].f_init = (void*)RedInit<i>;
1509  /// red_data[i].f_fini = (void*)RedDest<i>;
1510  /// red_data[i].f_comb = (void*)RedOp<i>;
1511  /// red_data[i].flags = <Flag_i>;
1512  /// ...
1513  /// void* tg1 = __kmpc_taskred_modifier_init(loc, gtid, is_worksharing, n,
1514  /// red_data);
1515  /// \endcode
1516  /// \param LHSExprs List of LHS in \a Data.ReductionOps reduction operations.
1517  /// \param RHSExprs List of RHS in \a Data.ReductionOps reduction operations.
1518  /// \param Data Additional data for task generation like tiedness, final
1519  /// state, list of privates, reductions etc.
1520  virtual llvm::Value *emitTaskReductionInit(CodeGenFunction &CGF,
1521  SourceLocation Loc,
1522  ArrayRef<const Expr *> LHSExprs,
1523  ArrayRef<const Expr *> RHSExprs,
1524  const OMPTaskDataTy &Data);
1525 
1526  /// Emits the following code for reduction clause with task modifier:
1527  /// \code
1528  /// __kmpc_task_reduction_modifier_fini(loc, gtid, is_worksharing);
1529  /// \endcode
1530  virtual void emitTaskReductionFini(CodeGenFunction &CGF, SourceLocation Loc,
1531  bool IsWorksharingReduction);
1532 
1533  /// Required to resolve existing problems in the runtime. Emits threadprivate
1534  /// variables to store the size of the VLAs/array sections for
1535  /// initializer/combiner/finalizer functions.
1536  /// \param RCG Allows to reuse an existing data for the reductions.
1537  /// \param N Reduction item for which fixups must be emitted.
1539  ReductionCodeGen &RCG, unsigned N);
1540 
1541  /// Get the address of `void *` type of the privatue copy of the reduction
1542  /// item specified by the \p SharedLVal.
1543  /// \param ReductionsPtr Pointer to the reduction data returned by the
1544  /// emitTaskReductionInit function.
1545  /// \param SharedLVal Address of the original reduction item.
1547  llvm::Value *ReductionsPtr,
1548  LValue SharedLVal);
1549 
1550  /// Emit code for 'taskwait' directive.
1551  virtual void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc,
1552  const OMPTaskDataTy &Data);
1553 
1554  /// Emit code for 'cancellation point' construct.
1555  /// \param CancelRegion Region kind for which the cancellation point must be
1556  /// emitted.
1557  ///
1558  virtual void emitCancellationPointCall(CodeGenFunction &CGF,
1559  SourceLocation Loc,
1560  OpenMPDirectiveKind CancelRegion);
1561 
1562  /// Emit code for 'cancel' construct.
1563  /// \param IfCond Condition in the associated 'if' clause, if it was
1564  /// specified, nullptr otherwise.
1565  /// \param CancelRegion Region kind for which the cancel must be emitted.
1566  ///
1567  virtual void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc,
1568  const Expr *IfCond,
1569  OpenMPDirectiveKind CancelRegion);
1570 
1571  /// Emit outilined function for 'target' directive.
1572  /// \param D Directive to emit.
1573  /// \param ParentName Name of the function that encloses the target region.
1574  /// \param OutlinedFn Outlined function value to be defined by this call.
1575  /// \param OutlinedFnID Outlined function ID value to be defined by this call.
1576  /// \param IsOffloadEntry True if the outlined function is an offload entry.
1577  /// \param CodeGen Code generation sequence for the \a D directive.
1578  /// An outlined function may not be an entry if, e.g. the if clause always
1579  /// evaluates to false.
1580  virtual void emitTargetOutlinedFunction(const OMPExecutableDirective &D,
1581  StringRef ParentName,
1582  llvm::Function *&OutlinedFn,
1583  llvm::Constant *&OutlinedFnID,
1584  bool IsOffloadEntry,
1585  const RegionCodeGenTy &CodeGen);
1586 
1587  /// Emit the target offloading code associated with \a D. The emitted
1588  /// code attempts offloading the execution to the device, an the event of
1589  /// a failure it executes the host version outlined in \a OutlinedFn.
1590  /// \param D Directive to emit.
1591  /// \param OutlinedFn Host version of the code to be offloaded.
1592  /// \param OutlinedFnID ID of host version of the code to be offloaded.
1593  /// \param IfCond Expression evaluated in if clause associated with the target
1594  /// directive, or null if no if clause is used.
1595  /// \param Device Expression evaluated in device clause associated with the
1596  /// target directive, or null if no device clause is used and device modifier.
1597  /// \param SizeEmitter Callback to emit number of iterations for loop-based
1598  /// directives.
1599  virtual void emitTargetCall(
1600  CodeGenFunction &CGF, const OMPExecutableDirective &D,
1601  llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond,
1602  llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
1603  llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
1604  const OMPLoopDirective &D)>
1605  SizeEmitter);
1606 
1607  /// Emit the target regions enclosed in \a GD function definition or
1608  /// the function itself in case it is a valid device function. Returns true if
1609  /// \a GD was dealt with successfully.
1610  /// \param GD Function to scan.
1611  virtual bool emitTargetFunctions(GlobalDecl GD);
1612 
1613  /// Emit the global variable if it is a valid device global variable.
1614  /// Returns true if \a GD was dealt with successfully.
1615  /// \param GD Variable declaration to emit.
1616  virtual bool emitTargetGlobalVariable(GlobalDecl GD);
1617 
1618  /// Checks if the provided global decl \a GD is a declare target variable and
1619  /// registers it when emitting code for the host.
1620  virtual void registerTargetGlobalVariable(const VarDecl *VD,
1621  llvm::Constant *Addr);
1622 
1623  /// Emit the global \a GD if it is meaningful for the target. Returns
1624  /// if it was emitted successfully.
1625  /// \param GD Global to scan.
1626  virtual bool emitTargetGlobal(GlobalDecl GD);
1627 
1628  /// Creates and returns a registration function for when at least one
1629  /// requires directives was used in the current module.
1630  llvm::Function *emitRequiresDirectiveRegFun();
1631 
1632  /// Creates all the offload entries in the current compilation unit
1633  /// along with the associated metadata.
1635 
1636  /// Emits code for teams call of the \a OutlinedFn with
1637  /// variables captured in a record which address is stored in \a
1638  /// CapturedStruct.
1639  /// \param OutlinedFn Outlined function to be run by team masters. Type of
1640  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
1641  /// \param CapturedVars A pointer to the record with the references to
1642  /// variables used in \a OutlinedFn function.
1643  ///
1644  virtual void emitTeamsCall(CodeGenFunction &CGF,
1645  const OMPExecutableDirective &D,
1646  SourceLocation Loc, llvm::Function *OutlinedFn,
1647  ArrayRef<llvm::Value *> CapturedVars);
1648 
1649  /// Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32
1650  /// global_tid, kmp_int32 num_teams, kmp_int32 thread_limit) to generate code
1651  /// for num_teams clause.
1652  /// \param NumTeams An integer expression of teams.
1653  /// \param ThreadLimit An integer expression of threads.
1654  virtual void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams,
1655  const Expr *ThreadLimit, SourceLocation Loc);
1656 
1657  /// Struct that keeps all the relevant information that should be kept
1658  /// throughout a 'target data' region.
1660  /// Set to true if device pointer information have to be obtained.
1661  bool RequiresDevicePointerInfo = false;
1662  /// Set to true if Clang emits separate runtime calls for the beginning and
1663  /// end of the region. These calls might have separate map type arrays.
1664  bool SeparateBeginEndCalls = false;
1665 
1666  public:
1667  /// The array of base pointer passed to the runtime library.
1668  llvm::Value *BasePointersArray = nullptr;
1669  /// The array of section pointers passed to the runtime library.
1670  llvm::Value *PointersArray = nullptr;
1671  /// The array of sizes passed to the runtime library.
1672  llvm::Value *SizesArray = nullptr;
1673  /// The array of map types passed to the runtime library for the beginning
1674  /// of the region or for the entire region if there are no separate map
1675  /// types for the region end.
1676  llvm::Value *MapTypesArray = nullptr;
1677  /// The array of map types passed to the runtime library for the end of the
1678  /// region, or nullptr if there are no separate map types for the region
1679  /// end.
1680  llvm::Value *MapTypesArrayEnd = nullptr;
1681  /// The array of user-defined mappers passed to the runtime library.
1682  llvm::Value *MappersArray = nullptr;
1683  /// The array of original declaration names of mapped pointers sent to the
1684  /// runtime library for debugging
1685  llvm::Value *MapNamesArray = nullptr;
1686  /// Indicate whether any user-defined mapper exists.
1687  bool HasMapper = false;
1688  /// The total number of pointers passed to the runtime library.
1689  unsigned NumberOfPtrs = 0u;
1690  /// Map between the a declaration of a capture and the corresponding base
1691  /// pointer address where the runtime returns the device pointers.
1692  llvm::DenseMap<const ValueDecl *, Address> CaptureDeviceAddrMap;
1693 
1694  explicit TargetDataInfo() {}
1695  explicit TargetDataInfo(bool RequiresDevicePointerInfo,
1696  bool SeparateBeginEndCalls)
1697  : RequiresDevicePointerInfo(RequiresDevicePointerInfo),
1698  SeparateBeginEndCalls(SeparateBeginEndCalls) {}
1699  /// Clear information about the data arrays.
1701  BasePointersArray = nullptr;
1702  PointersArray = nullptr;
1703  SizesArray = nullptr;
1704  MapTypesArray = nullptr;
1705  MapTypesArrayEnd = nullptr;
1706  MapNamesArray = nullptr;
1707  MappersArray = nullptr;
1708  HasMapper = false;
1709  NumberOfPtrs = 0u;
1710  }
1711  /// Return true if the current target data information has valid arrays.
1712  bool isValid() {
1715  }
1716  bool requiresDevicePointerInfo() { return RequiresDevicePointerInfo; }
1717  bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
1718  };
1719 
1720  /// Emit the target data mapping code associated with \a D.
1721  /// \param D Directive to emit.
1722  /// \param IfCond Expression evaluated in if clause associated with the
1723  /// target directive, or null if no device clause is used.
1724  /// \param Device Expression evaluated in device clause associated with the
1725  /// target directive, or null if no device clause is used.
1726  /// \param Info A record used to store information that needs to be preserved
1727  /// until the region is closed.
1728  virtual void emitTargetDataCalls(CodeGenFunction &CGF,
1729  const OMPExecutableDirective &D,
1730  const Expr *IfCond, const Expr *Device,
1731  const RegionCodeGenTy &CodeGen,
1732  TargetDataInfo &Info);
1733 
1734  /// Emit the data mapping/movement code associated with the directive
1735  /// \a D that should be of the form 'target [{enter|exit} data | update]'.
1736  /// \param D Directive to emit.
1737  /// \param IfCond Expression evaluated in if clause associated with the target
1738  /// directive, or null if no if clause is used.
1739  /// \param Device Expression evaluated in device clause associated with the
1740  /// target directive, or null if no device clause is used.
1742  const OMPExecutableDirective &D,
1743  const Expr *IfCond,
1744  const Expr *Device);
1745 
1746  /// Marks function \a Fn with properly mangled versions of vector functions.
1747  /// \param FD Function marked as 'declare simd'.
1748  /// \param Fn LLVM function that must be marked with 'declare simd'
1749  /// attributes.
1750  virtual void emitDeclareSimdFunction(const FunctionDecl *FD,
1751  llvm::Function *Fn);
1752 
1753  /// Emit initialization for doacross loop nesting support.
1754  /// \param D Loop-based construct used in doacross nesting construct.
1755  virtual void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D,
1756  ArrayRef<Expr *> NumIterations);
1757 
1758  /// Emit code for doacross ordered directive with 'depend' clause.
1759  /// \param C 'depend' clause with 'sink|source' dependency kind.
1760  virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
1761  const OMPDependClause *C);
1762 
1763  /// Translates the native parameter of outlined function if this is required
1764  /// for target.
1765  /// \param FD Field decl from captured record for the parameter.
1766  /// \param NativeParam Parameter itself.
1767  virtual const VarDecl *translateParameter(const FieldDecl *FD,
1768  const VarDecl *NativeParam) const {
1769  return NativeParam;
1770  }
1771 
1772  /// Gets the address of the native argument basing on the address of the
1773  /// target-specific parameter.
1774  /// \param NativeParam Parameter itself.
1775  /// \param TargetParam Corresponding target-specific parameter.
1777  const VarDecl *NativeParam,
1778  const VarDecl *TargetParam) const;
1779 
1780  /// Choose default schedule type and chunk value for the
1781  /// dist_schedule clause.
1783  const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind,
1784  llvm::Value *&Chunk) const {}
1785 
1786  /// Choose default schedule type and chunk value for the
1787  /// schedule clause.
1788  virtual void getDefaultScheduleAndChunk(CodeGenFunction &CGF,
1789  const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind,
1790  const Expr *&ChunkExpr) const;
1791 
1792  /// Emits call of the outlined function with the provided arguments,
1793  /// translating these arguments to correct target-specific arguments.
1794  virtual void
1796  llvm::FunctionCallee OutlinedFn,
1797  ArrayRef<llvm::Value *> Args = llvm::None) const;
1798 
1799  /// Emits OpenMP-specific function prolog.
1800  /// Required for device constructs.
1801  virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D);
1802 
1803  /// Gets the OpenMP-specific address of the local variable.
1805  const VarDecl *VD);
1806 
1807  /// Marks the declaration as already emitted for the device code and returns
1808  /// true, if it was marked already, and false, otherwise.
1809  bool markAsGlobalTarget(GlobalDecl GD);
1810 
1811  /// Emit deferred declare target variables marked for deferred emission.
1812  void emitDeferredTargetDecls() const;
1813 
1814  /// Adjust some parameters for the target-based directives, like addresses of
1815  /// the variables captured by reference in lambdas.
1816  virtual void
1818  const OMPExecutableDirective &D) const;
1819 
1820  /// Perform check on requires decl to ensure that target architecture
1821  /// supports unified addressing
1822  virtual void processRequiresDirective(const OMPRequiresDecl *D);
1823 
1824  /// Gets default memory ordering as specified in requires directive.
1825  llvm::AtomicOrdering getDefaultMemoryOrdering() const;
1826 
1827  /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
1828  /// the predefined allocator and translates it into the corresponding address
1829  /// space.
1830  virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS);
1831 
1832  /// Return whether the unified_shared_memory has been specified.
1833  bool hasRequiresUnifiedSharedMemory() const;
1834 
1835  /// Checks if the \p VD variable is marked as nontemporal declaration in
1836  /// current context.
1837  bool isNontemporalDecl(const ValueDecl *VD) const;
1838 
1839  /// Create specialized alloca to handle lastprivate conditionals.
1841  const VarDecl *VD);
1842 
1843  /// Checks if the provided \p LVal is lastprivate conditional and emits the
1844  /// code to update the value of the original variable.
1845  /// \code
1846  /// lastprivate(conditional: a)
1847  /// ...
1848  /// <type> a;
1849  /// lp_a = ...;
1850  /// #pragma omp critical(a)
1851  /// if (last_iv_a <= iv) {
1852  /// last_iv_a = iv;
1853  /// global_a = lp_a;
1854  /// }
1855  /// \endcode
1857  const Expr *LHS);
1858 
1859  /// Checks if the lastprivate conditional was updated in inner region and
1860  /// writes the value.
1861  /// \code
1862  /// lastprivate(conditional: a)
1863  /// ...
1864  /// <type> a;bool Fired = false;
1865  /// #pragma omp ... shared(a)
1866  /// {
1867  /// lp_a = ...;
1868  /// Fired = true;
1869  /// }
1870  /// if (Fired) {
1871  /// #pragma omp critical(a)
1872  /// if (last_iv_a <= iv) {
1873  /// last_iv_a = iv;
1874  /// global_a = lp_a;
1875  /// }
1876  /// Fired = false;
1877  /// }
1878  /// \endcode
1880  CodeGenFunction &CGF, const OMPExecutableDirective &D,
1881  const llvm::DenseSet<CanonicalDeclPtr<const VarDecl>> &IgnoredDecls);
1882 
1883  /// Gets the address of the global copy used for lastprivate conditional
1884  /// update, if any.
1885  /// \param PrivLVal LValue for the private copy.
1886  /// \param VD Original lastprivate declaration.
1888  LValue PrivLVal,
1889  const VarDecl *VD,
1890  SourceLocation Loc);
1891 
1892  /// Emits list of dependecies based on the provided data (array of
1893  /// dependence/expression pairs).
1894  /// \returns Pointer to the first element of the array casted to VoidPtr type.
1895  std::pair<llvm::Value *, Address>
1898  SourceLocation Loc);
1899 
1900  /// Emits list of dependecies based on the provided data (array of
1901  /// dependence/expression pairs) for depobj construct. In this case, the
1902  /// variable is allocated in dynamically. \returns Pointer to the first
1903  /// element of the array casted to VoidPtr type.
1905  const OMPTaskDataTy::DependData &Dependencies,
1906  SourceLocation Loc);
1907 
1908  /// Emits the code to destroy the dependency object provided in depobj
1909  /// directive.
1910  void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
1911  SourceLocation Loc);
1912 
1913  /// Updates the dependency kind in the specified depobj object.
1914  /// \param DepobjLVal LValue for the main depobj object.
1915  /// \param NewDepKind New dependency kind.
1916  void emitUpdateClause(CodeGenFunction &CGF, LValue DepobjLVal,
1917  OpenMPDependClauseKind NewDepKind, SourceLocation Loc);
1918 
1919  /// Initializes user defined allocators specified in the uses_allocators
1920  /// clauses.
1921  void emitUsesAllocatorsInit(CodeGenFunction &CGF, const Expr *Allocator,
1922  const Expr *AllocatorTraits);
1923 
1924  /// Destroys user defined allocators specified in the uses_allocators clause.
1925  void emitUsesAllocatorsFini(CodeGenFunction &CGF, const Expr *Allocator);
1926 
1927  /// Returns true if the variable is a local variable in untied task.
1928  bool isLocalVarInUntiedTask(CodeGenFunction &CGF, const VarDecl *VD) const;
1929 };
1930 
1931 /// Class supports emissionof SIMD-only code.
1932 class CGOpenMPSIMDRuntime final : public CGOpenMPRuntime {
1933 public:
1935  ~CGOpenMPSIMDRuntime() override {}
1936 
1937  /// Emits outlined function for the specified OpenMP parallel directive
1938  /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
1939  /// kmp_int32 BoundID, struct context_vars*).
1940  /// \param D OpenMP directive.
1941  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1942  /// \param InnermostKind Kind of innermost directive (for simple directives it
1943  /// is a directive itself, for combined - its innermost directive).
1944  /// \param CodeGen Code generation sequence for the \a D directive.
1945  llvm::Function *
1947  const VarDecl *ThreadIDVar,
1948  OpenMPDirectiveKind InnermostKind,
1949  const RegionCodeGenTy &CodeGen) override;
1950 
1951  /// Emits outlined function for the specified OpenMP teams directive
1952  /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
1953  /// kmp_int32 BoundID, struct context_vars*).
1954  /// \param D OpenMP directive.
1955  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1956  /// \param InnermostKind Kind of innermost directive (for simple directives it
1957  /// is a directive itself, for combined - its innermost directive).
1958  /// \param CodeGen Code generation sequence for the \a D directive.
1959  llvm::Function *
1961  const VarDecl *ThreadIDVar,
1962  OpenMPDirectiveKind InnermostKind,
1963  const RegionCodeGenTy &CodeGen) override;
1964 
1965  /// Emits outlined function for the OpenMP task directive \a D. This
1966  /// outlined function has type void(*)(kmp_int32 ThreadID, struct task_t*
1967  /// TaskT).
1968  /// \param D OpenMP directive.
1969  /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1970  /// \param PartIDVar Variable for partition id in the current OpenMP untied
1971  /// task region.
1972  /// \param TaskTVar Variable for task_t argument.
1973  /// \param InnermostKind Kind of innermost directive (for simple directives it
1974  /// is a directive itself, for combined - its innermost directive).
1975  /// \param CodeGen Code generation sequence for the \a D directive.
1976  /// \param Tied true if task is generated for tied task, false otherwise.
1977  /// \param NumberOfParts Number of parts in untied task. Ignored for tied
1978  /// tasks.
1979  ///
1980  llvm::Function *emitTaskOutlinedFunction(
1981  const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
1982  const VarDecl *PartIDVar, const VarDecl *TaskTVar,
1983  OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen,
1984  bool Tied, unsigned &NumberOfParts) override;
1985 
1986  /// Emits code for parallel or serial call of the \a OutlinedFn with
1987  /// variables captured in a record which address is stored in \a
1988  /// CapturedStruct.
1989  /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
1990  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
1991  /// \param CapturedVars A pointer to the record with the references to
1992  /// variables used in \a OutlinedFn function.
1993  /// \param IfCond Condition in the associated 'if' clause, if it was
1994  /// specified, nullptr otherwise.
1995  /// \param NumThreads The value corresponding to the num_threads clause, if
1996  /// any, or nullptr.
1997  ///
1999  llvm::Function *OutlinedFn,
2000  ArrayRef<llvm::Value *> CapturedVars,
2001  const Expr *IfCond, llvm::Value *NumThreads) override;
2002 
2003  /// Emits a critical region.
2004  /// \param CriticalName Name of the critical region.
2005  /// \param CriticalOpGen Generator for the statement associated with the given
2006  /// critical region.
2007  /// \param Hint Value of the 'hint' clause (optional).
2008  void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
2009  const RegionCodeGenTy &CriticalOpGen,
2010  SourceLocation Loc,
2011  const Expr *Hint = nullptr) override;
2012 
2013  /// Emits a master region.
2014  /// \param MasterOpGen Generator for the statement associated with the given
2015  /// master region.
2017  const RegionCodeGenTy &MasterOpGen,
2018  SourceLocation Loc) override;
2019 
2020  /// Emits a masked region.
2021  /// \param MaskedOpGen Generator for the statement associated with the given
2022  /// masked region.
2024  const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc,
2025  const Expr *Filter = nullptr) override;
2026 
2027  /// Emits a masked region.
2028  /// \param MaskedOpGen Generator for the statement associated with the given
2029  /// masked region.
2030 
2031  /// Emits code for a taskyield directive.
2032  void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc) override;
2033 
2034  /// Emit a taskgroup region.
2035  /// \param TaskgroupOpGen Generator for the statement associated with the
2036  /// given taskgroup region.
2038  const RegionCodeGenTy &TaskgroupOpGen,
2039  SourceLocation Loc) override;
2040 
2041  /// Emits a single region.
2042  /// \param SingleOpGen Generator for the statement associated with the given
2043  /// single region.
2045  const RegionCodeGenTy &SingleOpGen, SourceLocation Loc,
2046  ArrayRef<const Expr *> CopyprivateVars,
2047  ArrayRef<const Expr *> DestExprs,
2048  ArrayRef<const Expr *> SrcExprs,
2049  ArrayRef<const Expr *> AssignmentOps) override;
2050 
2051  /// Emit an ordered region.
2052  /// \param OrderedOpGen Generator for the statement associated with the given
2053  /// ordered region.
2055  const RegionCodeGenTy &OrderedOpGen,
2056  SourceLocation Loc, bool IsThreads) override;
2057 
2058  /// Emit an implicit/explicit barrier for OpenMP threads.
2059  /// \param Kind Directive for which this implicit barrier call must be
2060  /// generated. Must be OMPD_barrier for explicit barrier generation.
2061  /// \param EmitChecks true if need to emit checks for cancellation barriers.
2062  /// \param ForceSimpleCall true simple barrier call must be emitted, false if
2063  /// runtime class decides which one to emit (simple or with cancellation
2064  /// checks).
2065  ///
2067  OpenMPDirectiveKind Kind, bool EmitChecks = true,
2068  bool ForceSimpleCall = false) override;
2069 
2070  /// This is used for non static scheduled types and when the ordered
2071  /// clause is present on the loop construct.
2072  /// Depending on the loop schedule, it is necessary to call some runtime
2073  /// routine before start of the OpenMP loop to get the loop upper / lower
2074  /// bounds \a LB and \a UB and stride \a ST.
2075  ///
2076  /// \param CGF Reference to current CodeGenFunction.
2077  /// \param Loc Clang source location.
2078  /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
2079  /// \param IVSize Size of the iteration variable in bits.
2080  /// \param IVSigned Sign of the iteration variable.
2081  /// \param Ordered true if loop is ordered, false otherwise.
2082  /// \param DispatchValues struct containing llvm values for lower bound, upper
2083  /// bound, and chunk expression.
2084  /// For the default (nullptr) value, the chunk 1 will be used.
2085  ///
2087  const OpenMPScheduleTy &ScheduleKind,
2088  unsigned IVSize, bool IVSigned, bool Ordered,
2089  const DispatchRTInput &DispatchValues) override;
2090 
2091  /// Call the appropriate runtime routine to initialize it before start
2092  /// of loop.
2093  ///
2094  /// This is used only in case of static schedule, when the user did not
2095  /// specify a ordered clause on the loop construct.
2096  /// Depending on the loop schedule, it is necessary to call some runtime
2097  /// routine before start of the OpenMP loop to get the loop upper / lower
2098  /// bounds LB and UB and stride ST.
2099  ///
2100  /// \param CGF Reference to current CodeGenFunction.
2101  /// \param Loc Clang source location.
2102  /// \param DKind Kind of the directive.
2103  /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
2104  /// \param Values Input arguments for the construct.
2105  ///
2107  OpenMPDirectiveKind DKind,
2108  const OpenMPScheduleTy &ScheduleKind,
2109  const StaticRTInput &Values) override;
2110 
2111  ///
2112  /// \param CGF Reference to current CodeGenFunction.
2113  /// \param Loc Clang source location.
2114  /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
2115  /// \param Values Input arguments for the construct.
2116  ///
2118  OpenMPDistScheduleClauseKind SchedKind,
2119  const StaticRTInput &Values) override;
2120 
2121  /// Call the appropriate runtime routine to notify that we finished
2122  /// iteration of the ordered loop with the dynamic scheduling.
2123  ///
2124  /// \param CGF Reference to current CodeGenFunction.
2125  /// \param Loc Clang source location.
2126  /// \param IVSize Size of the iteration variable in bits.
2127  /// \param IVSigned Sign of the iteration variable.
2128  ///
2130  unsigned IVSize, bool IVSigned) override;
2131 
2132  /// Call the appropriate runtime routine to notify that we finished
2133  /// all the work with current loop.
2134  ///
2135  /// \param CGF Reference to current CodeGenFunction.
2136  /// \param Loc Clang source location.
2137  /// \param DKind Kind of the directive for which the static finish is emitted.
2138  ///
2140  OpenMPDirectiveKind DKind) override;
2141 
2142  /// Call __kmpc_dispatch_next(
2143  /// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter,
2144  /// kmp_int[32|64] *p_lower, kmp_int[32|64] *p_upper,
2145  /// kmp_int[32|64] *p_stride);
2146  /// \param IVSize Size of the iteration variable in bits.
2147  /// \param IVSigned Sign of the iteration variable.
2148  /// \param IL Address of the output variable in which the flag of the
2149  /// last iteration is returned.
2150  /// \param LB Address of the output variable in which the lower iteration
2151  /// number is returned.
2152  /// \param UB Address of the output variable in which the upper iteration
2153  /// number is returned.
2154  /// \param ST Address of the output variable in which the stride value is
2155  /// returned.
2156  llvm::Value *emitForNext(CodeGenFunction &CGF, SourceLocation Loc,
2157  unsigned IVSize, bool IVSigned, Address IL,
2158  Address LB, Address UB, Address ST) override;
2159 
2160  /// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
2161  /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
2162  /// clause.
2163  /// \param NumThreads An integer value of threads.
2164  void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads,
2165  SourceLocation Loc) override;
2166 
2167  /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
2168  /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
2170  llvm::omp::ProcBindKind ProcBind,
2171  SourceLocation Loc) override;
2172 
2173  /// Returns address of the threadprivate variable for the current
2174  /// thread.
2175  /// \param VD Threadprivate variable.
2176  /// \param VDAddr Address of the global variable \a VD.
2177  /// \param Loc Location of the reference to threadprivate var.
2178  /// \return Address of the threadprivate variable for the current thread.
2180  Address VDAddr, SourceLocation Loc) override;
2181 
2182  /// Emit a code for initialization of threadprivate variable. It emits
2183  /// a call to runtime library which adds initial value to the newly created
2184  /// threadprivate variable (if it is not constant) and registers destructor
2185  /// for the variable (if any).
2186  /// \param VD Threadprivate variable.
2187  /// \param VDAddr Address of the global variable \a VD.
2188  /// \param Loc Location of threadprivate declaration.
2189  /// \param PerformInit true if initialization expression is not constant.
2190  llvm::Function *
2192  SourceLocation Loc, bool PerformInit,
2193  CodeGenFunction *CGF = nullptr) override;
2194 
2195  /// Creates artificial threadprivate variable with name \p Name and type \p
2196  /// VarType.
2197  /// \param VarType Type of the artificial threadprivate variable.
2198  /// \param Name Name of the artificial threadprivate variable.
2200  QualType VarType,
2201  StringRef Name) override;
2202 
2203  /// Emit flush of the variables specified in 'omp flush' directive.
2204  /// \param Vars List of variables to flush.
2206  SourceLocation Loc, llvm::AtomicOrdering AO) override;
2207 
2208  /// Emit task region for the task directive. The task region is
2209  /// emitted in several steps:
2210  /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
2211  /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
2212  /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
2213  /// function:
2214  /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
2215  /// TaskFunction(gtid, tt->part_id, tt->shareds);
2216  /// return 0;
2217  /// }
2218  /// 2. Copy a list of shared variables to field shareds of the resulting
2219  /// structure kmp_task_t returned by the previous call (if any).
2220  /// 3. Copy a pointer to destructions function to field destructions of the
2221  /// resulting structure kmp_task_t.
2222  /// 4. Emit a call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid,
2223  /// kmp_task_t *new_task), where new_task is a resulting structure from
2224  /// previous items.
2225  /// \param D Current task directive.
2226  /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
2227  /// /*part_id*/, captured_struct */*__context*/);
2228  /// \param SharedsTy A type which contains references the shared variables.
2229  /// \param Shareds Context with the list of shared variables from the \p
2230  /// TaskFunction.
2231  /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
2232  /// otherwise.
2233  /// \param Data Additional data for task generation like tiednsee, final
2234  /// state, list of privates etc.
2236  const OMPExecutableDirective &D,
2237  llvm::Function *TaskFunction, QualType SharedsTy,
2238  Address Shareds, const Expr *IfCond,
2239  const OMPTaskDataTy &Data) override;
2240 
2241  /// Emit task region for the taskloop directive. The taskloop region is
2242  /// emitted in several steps:
2243  /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
2244  /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
2245  /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
2246  /// function:
2247  /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
2248  /// TaskFunction(gtid, tt->part_id, tt->shareds);
2249  /// return 0;
2250  /// }
2251  /// 2. Copy a list of shared variables to field shareds of the resulting
2252  /// structure kmp_task_t returned by the previous call (if any).
2253  /// 3. Copy a pointer to destructions function to field destructions of the
2254  /// resulting structure kmp_task_t.
2255  /// 4. Emit a call to void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t
2256  /// *task, int if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int
2257  /// nogroup, int sched, kmp_uint64 grainsize, void *task_dup ), where new_task
2258  /// is a resulting structure from
2259  /// previous items.
2260  /// \param D Current task directive.
2261  /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
2262  /// /*part_id*/, captured_struct */*__context*/);
2263  /// \param SharedsTy A type which contains references the shared variables.
2264  /// \param Shareds Context with the list of shared variables from the \p
2265  /// TaskFunction.
2266  /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
2267  /// otherwise.
2268  /// \param Data Additional data for task generation like tiednsee, final
2269  /// state, list of privates etc.
2271  const OMPLoopDirective &D, llvm::Function *TaskFunction,
2272  QualType SharedsTy, Address Shareds, const Expr *IfCond,
2273  const OMPTaskDataTy &Data) override;
2274 
2275  /// Emit a code for reduction clause. Next code should be emitted for
2276  /// reduction:
2277  /// \code
2278  ///
2279  /// static kmp_critical_name lock = { 0 };
2280  ///
2281  /// void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
2282  /// ...
2283  /// *(Type<i>*)lhs[i] = RedOp<i>(*(Type<i>*)lhs[i], *(Type<i>*)rhs[i]);
2284  /// ...
2285  /// }
2286  ///
2287  /// ...
2288  /// void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
2289  /// switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList),
2290  /// RedList, reduce_func, &<lock>)) {
2291  /// case 1:
2292  /// ...
2293  /// <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]);
2294  /// ...
2295  /// __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
2296  /// break;
2297  /// case 2:
2298  /// ...
2299  /// Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]));
2300  /// ...
2301  /// break;
2302  /// default:;
2303  /// }
2304  /// \endcode
2305  ///
2306  /// \param Privates List of private copies for original reduction arguments.
2307  /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
2308  /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
2309  /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
2310  /// or 'operator binop(LHS, RHS)'.
2311  /// \param Options List of options for reduction codegen:
2312  /// WithNowait true if parent directive has also nowait clause, false
2313  /// otherwise.
2314  /// SimpleReduction Emit reduction operation only. Used for omp simd
2315  /// directive on the host.
2316  /// ReductionKind The kind of reduction to perform.
2318  ArrayRef<const Expr *> Privates,
2319  ArrayRef<const Expr *> LHSExprs,
2320  ArrayRef<const Expr *> RHSExprs,
2321  ArrayRef<const Expr *> ReductionOps,
2322  ReductionOptionsTy Options) override;
2323 
2324  /// Emit a code for initialization of task reduction clause. Next code
2325  /// should be emitted for reduction:
2326  /// \code
2327  ///
2328  /// _taskred_item_t red_data[n];
2329  /// ...
2330  /// red_data[i].shar = &shareds[i];
2331  /// red_data[i].orig = &origs[i];
2332  /// red_data[i].size = sizeof(origs[i]);
2333  /// red_data[i].f_init = (void*)RedInit<i>;
2334  /// red_data[i].f_fini = (void*)RedDest<i>;
2335  /// red_data[i].f_comb = (void*)RedOp<i>;
2336  /// red_data[i].flags = <Flag_i>;
2337  /// ...
2338  /// void* tg1 = __kmpc_taskred_init(gtid, n, red_data);
2339  /// \endcode
2340  /// For reduction clause with task modifier it emits the next call:
2341  /// \code
2342  ///
2343  /// _taskred_item_t red_data[n];
2344  /// ...
2345  /// red_data[i].shar = &shareds[i];
2346  /// red_data[i].orig = &origs[i];
2347  /// red_data[i].size = sizeof(origs[i]);
2348  /// red_data[i].f_init = (void*)RedInit<i>;
2349  /// red_data[i].f_fini = (void*)RedDest<i>;
2350  /// red_data[i].f_comb = (void*)RedOp<i>;
2351  /// red_data[i].flags = <Flag_i>;
2352  /// ...
2353  /// void* tg1 = __kmpc_taskred_modifier_init(loc, gtid, is_worksharing, n,
2354  /// red_data);
2355  /// \endcode
2356  /// \param LHSExprs List of LHS in \a Data.ReductionOps reduction operations.
2357  /// \param RHSExprs List of RHS in \a Data.ReductionOps reduction operations.
2358  /// \param Data Additional data for task generation like tiedness, final
2359  /// state, list of privates, reductions etc.
2360  llvm::Value *emitTaskReductionInit(CodeGenFunction &CGF, SourceLocation Loc,
2361  ArrayRef<const Expr *> LHSExprs,
2362  ArrayRef<const Expr *> RHSExprs,
2363  const OMPTaskDataTy &Data) override;
2364 
2365  /// Emits the following code for reduction clause with task modifier:
2366  /// \code
2367  /// __kmpc_task_reduction_modifier_fini(loc, gtid, is_worksharing);
2368  /// \endcode
2370  bool IsWorksharingReduction) override;
2371 
2372  /// Required to resolve existing problems in the runtime. Emits threadprivate
2373  /// variables to store the size of the VLAs/array sections for
2374  /// initializer/combiner/finalizer functions + emits threadprivate variable to
2375  /// store the pointer to the original reduction item for the custom
2376  /// initializer defined by declare reduction construct.
2377  /// \param RCG Allows to reuse an existing data for the reductions.
2378  /// \param N Reduction item for which fixups must be emitted.
2380  ReductionCodeGen &RCG, unsigned N) override;
2381 
2382  /// Get the address of `void *` type of the privatue copy of the reduction
2383  /// item specified by the \p SharedLVal.
2384  /// \param ReductionsPtr Pointer to the reduction data returned by the
2385  /// emitTaskReductionInit function.
2386  /// \param SharedLVal Address of the original reduction item.
2388  llvm::Value *ReductionsPtr,
2389  LValue SharedLVal) override;
2390 
2391  /// Emit code for 'taskwait' directive.
2393  const OMPTaskDataTy &Data) override;
2394 
2395  /// Emit code for 'cancellation point' construct.
2396  /// \param CancelRegion Region kind for which the cancellation point must be
2397  /// emitted.
2398  ///
2400  OpenMPDirectiveKind CancelRegion) override;
2401 
2402  /// Emit code for 'cancel' construct.
2403  /// \param IfCond Condition in the associated 'if' clause, if it was
2404  /// specified, nullptr otherwise.
2405  /// \param CancelRegion Region kind for which the cancel must be emitted.
2406  ///
2408  const Expr *IfCond,
2409  OpenMPDirectiveKind CancelRegion) override;
2410 
2411  /// Emit outilined function for 'target' directive.
2412  /// \param D Directive to emit.
2413  /// \param ParentName Name of the function that encloses the target region.
2414  /// \param OutlinedFn Outlined function value to be defined by this call.
2415  /// \param OutlinedFnID Outlined function ID value to be defined by this call.
2416  /// \param IsOffloadEntry True if the outlined function is an offload entry.
2417  /// \param CodeGen Code generation sequence for the \a D directive.
2418  /// An outlined function may not be an entry if, e.g. the if clause always
2419  /// evaluates to false.
2421  StringRef ParentName,
2422  llvm::Function *&OutlinedFn,
2423  llvm::Constant *&OutlinedFnID,
2424  bool IsOffloadEntry,
2425  const RegionCodeGenTy &CodeGen) override;
2426 
2427  /// Emit the target offloading code associated with \a D. The emitted
2428  /// code attempts offloading the execution to the device, an the event of
2429  /// a failure it executes the host version outlined in \a OutlinedFn.
2430  /// \param D Directive to emit.
2431  /// \param OutlinedFn Host version of the code to be offloaded.
2432  /// \param OutlinedFnID ID of host version of the code to be offloaded.
2433  /// \param IfCond Expression evaluated in if clause associated with the target
2434  /// directive, or null if no if clause is used.
2435  /// \param Device Expression evaluated in device clause associated with the
2436  /// target directive, or null if no device clause is used and device modifier.
2437  void emitTargetCall(
2438  CodeGenFunction &CGF, const OMPExecutableDirective &D,
2439  llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond,
2440  llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
2441  llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
2442  const OMPLoopDirective &D)>
2443  SizeEmitter) override;
2444 
2445  /// Emit the target regions enclosed in \a GD function definition or
2446  /// the function itself in case it is a valid device function. Returns true if
2447  /// \a GD was dealt with successfully.
2448  /// \param GD Function to scan.
2449  bool emitTargetFunctions(GlobalDecl GD) override;
2450 
2451  /// Emit the global variable if it is a valid device global variable.
2452  /// Returns true if \a GD was dealt with successfully.
2453  /// \param GD Variable declaration to emit.
2454  bool emitTargetGlobalVariable(GlobalDecl GD) override;
2455 
2456  /// Emit the global \a GD if it is meaningful for the target. Returns
2457  /// if it was emitted successfully.
2458  /// \param GD Global to scan.
2459  bool emitTargetGlobal(GlobalDecl GD) override;
2460 
2461  /// Emits code for teams call of the \a OutlinedFn with
2462  /// variables captured in a record which address is stored in \a
2463  /// CapturedStruct.
2464  /// \param OutlinedFn Outlined function to be run by team masters. Type of
2465  /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
2466  /// \param CapturedVars A pointer to the record with the references to
2467  /// variables used in \a OutlinedFn function.
2468  ///
2470  SourceLocation Loc, llvm::Function *OutlinedFn,
2471  ArrayRef<llvm::Value *> CapturedVars) override;
2472 
2473  /// Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32
2474  /// global_tid, kmp_int32 num_teams, kmp_int32 thread_limit) to generate code
2475  /// for num_teams clause.
2476  /// \param NumTeams An integer expression of teams.
2477  /// \param ThreadLimit An integer expression of threads.
2478  void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams,
2479  const Expr *ThreadLimit, SourceLocation Loc) override;
2480 
2481  /// Emit the target data mapping code associated with \a D.
2482  /// \param D Directive to emit.
2483  /// \param IfCond Expression evaluated in if clause associated with the
2484  /// target directive, or null if no device clause is used.
2485  /// \param Device Expression evaluated in device clause associated with the
2486  /// target directive, or null if no device clause is used.
2487  /// \param Info A record used to store information that needs to be preserved
2488  /// until the region is closed.
2490  const OMPExecutableDirective &D, const Expr *IfCond,
2491  const Expr *Device, const RegionCodeGenTy &CodeGen,
2492  TargetDataInfo &Info) override;
2493 
2494  /// Emit the data mapping/movement code associated with the directive
2495  /// \a D that should be of the form 'target [{enter|exit} data | update]'.
2496  /// \param D Directive to emit.
2497  /// \param IfCond Expression evaluated in if clause associated with the target
2498  /// directive, or null if no if clause is used.
2499  /// \param Device Expression evaluated in device clause associated with the
2500  /// target directive, or null if no device clause is used.
2502  const OMPExecutableDirective &D,
2503  const Expr *IfCond,
2504  const Expr *Device) override;
2505 
2506  /// Emit initialization for doacross loop nesting support.
2507  /// \param D Loop-based construct used in doacross nesting construct.
2509  ArrayRef<Expr *> NumIterations) override;
2510 
2511  /// Emit code for doacross ordered directive with 'depend' clause.
2512  /// \param C 'depend' clause with 'sink|source' dependency kind.
2514  const OMPDependClause *C) override;
2515 
2516  /// Translates the native parameter of outlined function if this is required
2517  /// for target.
2518  /// \param FD Field decl from captured record for the parameter.
2519  /// \param NativeParam Parameter itself.
2520  const VarDecl *translateParameter(const FieldDecl *FD,
2521  const VarDecl *NativeParam) const override;
2522 
2523  /// Gets the address of the native argument basing on the address of the
2524  /// target-specific parameter.
2525  /// \param NativeParam Parameter itself.
2526  /// \param TargetParam Corresponding target-specific parameter.
2527  Address getParameterAddress(CodeGenFunction &CGF, const VarDecl *NativeParam,
2528  const VarDecl *TargetParam) const override;
2529 
2530  /// Gets the OpenMP-specific address of the local variable.
2532  const VarDecl *VD) override {
2533  return Address::invalid();
2534  }
2535 };
2536 
2537 } // namespace CodeGen
2538 } // namespace clang
2539 
2540 #endif
clang::CodeGen::OMPTaskDataTy::ReductionOps
SmallVector< const Expr *, 4 > ReductionOps
Definition: CGOpenMPRuntime.h:104
clang::CodeGen::OMPTaskDataTy::Reductions
llvm::Value * Reductions
Definition: CGOpenMPRuntime.h:118
clang::CodeGen::CGOpenMPRuntime::emitTaskLoopCall
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.
Definition: CGOpenMPRuntime.cpp:5130
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::OffloadEntryInfoDeviceGlobalVar
OffloadEntryInfoDeviceGlobalVar()
Definition: CGOpenMPRuntime.h:666
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::getLinkage
llvm::GlobalValue::LinkageTypes getLinkage() const
Definition: CGOpenMPRuntime.h:682
clang::CodeGen::CGOpenMPSIMDRuntime::emitCancelCall
void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc, const Expr *IfCond, OpenMPDirectiveKind CancelRegion) override
Emit code for 'cancel' construct.
Definition: CGOpenMPRuntime.cpp:13045
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::BasePointersArray
llvm::Value * BasePointersArray
The array of base pointer passed to the runtime library.
Definition: CGOpenMPRuntime.h:1668
clang::CodeGen::CGOpenMPRuntime::emitTaskReductionFini
virtual void emitTaskReductionFini(CodeGenFunction &CGF, SourceLocation Loc, bool IsWorksharingReduction)
Emits the following code for reduction clause with task modifier:
Definition: CGOpenMPRuntime.cpp:6074
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::ST
Address ST
Address of the output variable in which the stride value is returned necessary to generated the stati...
Definition: CGOpenMPRuntime.h:1184
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskwaitCall
void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPTaskDataTy &Data) override
Emit code for 'taskwait' directive.
Definition: CGOpenMPRuntime.cpp:13033
clang::CodeGen::CGOpenMPRuntime::getThreadID
llvm::Value * getThreadID(CodeGenFunction &CGF, SourceLocation Loc)
Gets thread id value for the current thread.
Definition: CGOpenMPRuntime.cpp:1394
clang::CodeGen::CGOpenMPRuntime::getAddressOfLocalVariable
virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable.
Definition: CGOpenMPRuntime.cpp:12198
LT
ASTImporterLookupTable & LT
Definition: ASTImporterLookupTable.cpp:24
clang::CodeGen::OMPTaskDataTy::IsReductionWithTaskMod
bool IsReductionWithTaskMod
Definition: CGOpenMPRuntime.h:122
clang::CodeGen::CGOpenMPRuntime::emitLastprivateConditionalFinalUpdate
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.
Definition: CGOpenMPRuntime.cpp:12802
clang::CodeGen::CGOpenMPSIMDRuntime::translateParameter
const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const override
Translates the native parameter of outlined function if this is required for target.
Definition: CGOpenMPRuntime.cpp:13119
clang::CodeGen::CGOpenMPRuntime
Definition: CGOpenMPRuntime.h:228
clang::CodeGen::CGOpenMPSIMDRuntime::CGOpenMPSIMDRuntime
CGOpenMPSIMDRuntime(CodeGenModule &CGM)
Definition: CGOpenMPRuntime.h:1934
clang::CodeGen::CGOpenMPRuntime::checkAndEmitSharedLastprivateConditional
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.
Definition: CGOpenMPRuntime.cpp:12752
clang::CodeGen::OMPTaskDataTy::DependData::IteratorExpr
const Expr * IteratorExpr
Definition: CGOpenMPRuntime.h:108
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskCall
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.
Definition: CGOpenMPRuntime.cpp:12982
clang::CodeGen::OMPTaskDataTy::LastprivateVars
SmallVector< const Expr *, 4 > LastprivateVars
Definition: CGOpenMPRuntime.h:99
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::PointersArray
llvm::Value * PointersArray
The array of section pointers passed to the runtime library.
Definition: CGOpenMPRuntime.h:1670
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalData
Maps the expression for the lastprivate variable to the global copy used to store new value because o...
Definition: CGOpenMPRuntime.h:270
clang::CodeGen::CGOpenMPRuntime::registerTargetGlobalVariable
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...
Definition: CGOpenMPRuntime.cpp:10782
clang::CodeGen::CGOpenMPRuntime::emitSingleReductionCombiner
void emitSingleReductionCombiner(CodeGenFunction &CGF, const Expr *ReductionOp, const Expr *PrivateRef, const DeclRefExpr *LHS, const DeclRefExpr *RHS)
Emits single reduction combiner.
Definition: CGOpenMPRuntime.cpp:5410
clang::CodeGen::ReductionCodeGen::adjustPrivateAddress
Address adjustPrivateAddress(CodeGenFunction &CGF, unsigned N, Address PrivateAddr)
Adjusts PrivatedAddr for using instead of the original variable address in normal operations.
Definition: CGOpenMPRuntime.cpp:988
clang::CodeGen::CGOpenMPRuntime::emitForStaticFinish
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.
Definition: CGOpenMPRuntime.cpp:2823
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskLoopCall
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.
Definition: CGOpenMPRuntime.cpp:12991
clang::CodeGen::CGOpenMPRuntime::Separator
StringRef Separator
Definition: CGOpenMPRuntime.h:309
clang::CodeGen::OMPTaskDataTy::DependData
Definition: CGOpenMPRuntime.h:106
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::MappersArray
llvm::Value * MappersArray
The array of user-defined mappers passed to the runtime library.
Definition: CGOpenMPRuntime.h:1682
clang::CodeGen::CGOpenMPRuntime::getName
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
Definition: CGOpenMPRuntime.cpp:1086
clang::CodeGen::CGOpenMPSIMDRuntime::emitForNext
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...
Definition: CGOpenMPRuntime.cpp:12937
clang::CodeGen::CGOpenMPRuntime::emitParallelOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:1269
clang::CodeGen::CGOpenMPRuntime::emitProcBindClause
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...
Definition: CGOpenMPRuntime.cpp:2899
clang::CodeGen::CGOpenMPSIMDRuntime::emitTargetDataStandAloneCall
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...
Definition: CGOpenMPRuntime.cpp:13101
clang::CodeGen::CGOpenMPSIMDRuntime::emitDoacrossInit
void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D, ArrayRef< Expr * > NumIterations) override
Emit initialization for doacross loop nesting support.
Definition: CGOpenMPRuntime.cpp:13107
clang::CodeGen::CGOpenMPRuntime::StaticRTInput
Struct with the values to be passed to the static runtime function.
Definition: CGOpenMPRuntime.h:1166
clang::CodeGen::CGOpenMPRuntime::clearLocThreadIdInsertPt
void clearLocThreadIdInsertPt(CodeGenFunction &CGF)
Definition: CGOpenMPRuntime.cpp:1348
clang::CodeGen::ReductionCodeGen
Class intended to support codegen of all kind of the reduction clauses.
Definition: CGOpenMPRuntime.h:127
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::isValid
bool isValid() const
Definition: CGOpenMPRuntime.h:552
llvm::SmallVector
Definition: LLVM.h:38
clang::CodeGen::CGOpenMPRuntime::getNumThreadsExprForTargetDirective
const Expr * getNumThreadsExprForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D, int32_t &DefaultVal)
Emit the number of threads for a target directive.
Definition: CGOpenMPRuntime.cpp:6819
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskReductionFixups
void emitTaskReductionFixups(CodeGenFunction &CGF, SourceLocation Loc, ReductionCodeGen &RCG, unsigned N) override
Required to resolve existing problems in the runtime.
Definition: CGOpenMPRuntime.cpp:13019
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::~OffloadEntryInfo
~OffloadEntryInfo()=default
clang::CodeGen::CGOpenMPRuntime::CGOpenMPRuntime
CGOpenMPRuntime(CodeGenModule &CGM)
Definition: CGOpenMPRuntime.h:920
clang::CodeGen::CGOpenMPRuntime::emitParallelCall
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...
Definition: CGOpenMPRuntime.cpp:2039
clang::OMPC_DEPEND_unknown
@ OMPC_DEPEND_unknown
Definition: OpenMPKinds.h:58
clang::CodeGen::CGOpenMPRuntime::setLocThreadIdInsertPt
void setLocThreadIdInsertPt(CodeGenFunction &CGF, bool AtCurrentPoint=false)
Definition: CGOpenMPRuntime.cpp:1332
clang::CodeGen::CGOpenMPRuntime::emitCancellationPointCall
virtual void emitCancellationPointCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancellation point' construct.
Definition: CGOpenMPRuntime.cpp:6218
clang::CodeGen::CGOpenMPRuntime::getNumTeamsExprForTargetDirective
const Expr * getNumTeamsExprForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D, int32_t &DefaultVal)
Emit the number of teams for a target directive.
Definition: CGOpenMPRuntime.cpp:6556
clang::CodeGen::CGOpenMPRuntime::getCriticalRegionLock
llvm::Value * getCriticalRegionLock(StringRef CriticalName)
Returns corresponding lock object for the specified critical region name.
Definition: CGOpenMPRuntime.cpp:2154
clang::CodeGen::CGOpenMPSIMDRuntime::emitForDispatchInit
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...
Definition: CGOpenMPRuntime.cpp:12905
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:731
clang::CodeGen::CGOpenMPRuntime::ReductionOptionsTy::ReductionKind
OpenMPDirectiveKind ReductionKind
Definition: CGOpenMPRuntime.h:1433
clang::CodeGen::CGOpenMPRuntime::emitTaskyieldCall
virtual void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc)
Emits code for a taskyield directive.
Definition: CGOpenMPRuntime.cpp:2281
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::separateBeginEndCalls
bool separateBeginEndCalls()
Definition: CGOpenMPRuntime.h:1717
clang::CodeGen::CGOpenMPSIMDRuntime::emitProcBindClause
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...
Definition: CGOpenMPRuntime.cpp:12951
clang::tooling::Filter
llvm::cl::opt< std::string > Filter
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2862
clang::CodeGen::CGOpenMPRuntime::OMPBuilder
llvm::OpenMPIRBuilder OMPBuilder
An OpenMP-IR-Builder instance.
Definition: CGOpenMPRuntime.h:312
clang::CodeGen::PrePostActionTy::Exit
virtual void Exit(CodeGenFunction &CGF)
Definition: CGOpenMPRuntime.h:62
clang::CodeGen::CGOpenMPRuntime::hasAllocateAttributeForGlobalVar
virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS)
Checks if the variable has associated OMPAllocateDeclAttr attribute with the predefined allocator and...
Definition: CGOpenMPRuntime.cpp:10924
clang::CodeGen::CGOpenMPRuntime::emitCriticalRegion
virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr)
Emits a critical region.
Definition: CGOpenMPRuntime.cpp:2199
clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:6332
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::UB
Address UB
Address of the output variable in which the upper iteration number is returned.
Definition: CGOpenMPRuntime.h:1181
clang::CodeGen::CGOpenMPRuntime::emitDepobjDependClause
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...
Definition: CGOpenMPRuntime.cpp:4853
clang::CodeGen::CGOpenMPRuntime::NontemporalDeclsRAII::NontemporalDeclsRAII
NontemporalDeclsRAII(CodeGenModule &CGM, const OMPLoopDirective &S)
Definition: CGOpenMPRuntime.cpp:12306
clang::CodeGen::CGOpenMPSIMDRuntime::emitTargetOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:13051
DeclOpenMP.h
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalData::DeclToUniqueName
llvm::MapVector< CanonicalDeclPtr< const Decl >, SmallString< 16 > > DeclToUniqueName
Definition: CGOpenMPRuntime.h:272
clang::CodeGen::CGOpenMPRuntime::UntiedTaskLocalDeclsRAII::~UntiedTaskLocalDeclsRAII
~UntiedTaskLocalDeclsRAII()
Definition: CGOpenMPRuntime.cpp:12350
clang::CodeGen::CGOpenMPRuntime::emitRequiresDirectiveRegFun
llvm::Function * emitRequiresDirectiveRegFun()
Creates and returns a registration function for when at least one requires directives was used in the...
Definition: CGOpenMPRuntime.cpp:10987
clang::CodeGen::CGOpenMPRuntime::emitTaskReductionFixups
virtual void emitTaskReductionFixups(CodeGenFunction &CGF, SourceLocation Loc, ReductionCodeGen &RCG, unsigned N)
Required to resolve existing problems in the runtime.
Definition: CGOpenMPRuntime.cpp:6092
clang::CodeGen::CGOpenMPRuntime::emitThreadIDAddress
virtual Address emitThreadIDAddress(CodeGenFunction &CGF, SourceLocation Loc)
Emits address of the word in a memory where current thread id is stored.
Definition: CGOpenMPRuntime.cpp:2117
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion::setID
void setID(llvm::Constant *V)
Definition: CGOpenMPRuntime.h:617
clang::CodeGen::OMPTaskDataTy::Schedule
llvm::PointerIntPair< llvm::Value *, 1, bool > Schedule
Definition: CGOpenMPRuntime.h:116
clang::CodeGen::RegionCodeGenTy::operator()
void operator()(CodeGenFunction &CGF) const
Definition: CGOpenMPRuntime.cpp:596
clang::CodeGen::CGOpenMPRuntime::emitTargetFunctions
virtual bool emitTargetFunctions(GlobalDecl GD)
Emit the target regions enclosed in GD function definition or the function itself in case it is a val...
Definition: CGOpenMPRuntime.cpp:10718
clang::CodeGen::CGOpenMPSIMDRuntime::emitThreadPrivateVarDefinition
llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr) override
Emit a code for initialization of threadprivate variable.
Definition: CGOpenMPRuntime.cpp:12964
clang::CodeGen::CGOpenMPSIMDRuntime::emitCancellationPointCall
void emitCancellationPointCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind CancelRegion) override
Emit code for 'cancellation point' construct.
Definition: CGOpenMPRuntime.cpp:13039
clang::CodeGen::CGOpenMPRuntime::emitBarrierCall
virtual void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false)
Emit an implicit/explicit barrier for OpenMP threads.
Definition: CGOpenMPRuntime.cpp:2536
clang::CodeGen::CGOpenMPRuntime::isDynamic
virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const
Check if the specified ScheduleKind is dynamic.
Definition: CGOpenMPRuntime.cpp:2641
clang::CodeGen::CGOpenMPSIMDRuntime::~CGOpenMPSIMDRuntime
~CGOpenMPSIMDRuntime() override
Definition: CGOpenMPRuntime.h:1935
clang::CodeGen::OMPTaskDataTy::Final
llvm::PointerIntPair< llvm::Value *, 1, bool > Final
Definition: CGOpenMPRuntime.h:115
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalRAII::disable
static LastprivateConditionalRAII disable(CodeGenFunction &CGF, const OMPExecutableDirective &S)
Definition: CGOpenMPRuntime.cpp:12495
clang::CodeGen::CGOpenMPRuntime::getDefaultMemoryOrdering
llvm::AtomicOrdering getDefaultMemoryOrdering() const
Gets default memory ordering as specified in requires directive.
Definition: CGOpenMPRuntime.cpp:10920
clang::CodeGen::CGOpenMPRuntime::emitFlush
virtual void emitFlush(CodeGenFunction &CGF, ArrayRef< const Expr * > Vars, SourceLocation Loc, llvm::AtomicOrdering AO)
Emit flush of the variables specified in 'omp flush' directive.
Definition: CGOpenMPRuntime.cpp:2914
clang::CodeGen::CGOpenMPRuntime::~CGOpenMPRuntime
virtual ~CGOpenMPRuntime()
Definition: CGOpenMPRuntime.h:922
clang::CodeGen::CGOpenMPRuntime::emitForNext
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...
Definition: CGOpenMPRuntime.cpp:2861
clang::CodeGen::CGOpenMPSIMDRuntime::emitTargetGlobalVariable
bool emitTargetGlobalVariable(GlobalDecl GD) override
Emit the global variable if it is a valid device global variable.
Definition: CGOpenMPRuntime.cpp:13072
clang::CodeGen::CGOpenMPSIMDRuntime::getAddrOfThreadPrivate
Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc) override
Returns address of the threadprivate variable for the current thread.
Definition: CGOpenMPRuntime.cpp:12957
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::MapTypesArrayEnd
llvm::Value * MapTypesArrayEnd
The array of map types passed to the runtime library for the end of the region, or nullptr if there a...
Definition: CGOpenMPRuntime.h:1680
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::OffloadingEntryInfoKinds
OffloadingEntryInfoKinds
Kind of a given entry.
Definition: CGOpenMPRuntime.h:534
clang::CodeGen::CGOpenMPRuntime::emitCall
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.
Definition: CGOpenMPRuntime.cpp:12135
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::setAddress
void setAddress(llvm::Constant *V)
Definition: CGOpenMPRuntime.h:560
clang::CodeGen::ReductionCodeGen::getSizes
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),...
Definition: CGOpenMPRuntime.h:211
clang::GlobalDecl
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:56
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::OffloadEntryInfoDeviceGlobalVar
OffloadEntryInfoDeviceGlobalVar(unsigned Order, OMPTargetGlobalVarEntryKind Flags)
Definition: CGOpenMPRuntime.h:668
uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:24
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo
Struct that keeps all the relevant information that should be kept throughout a 'target data' region.
Definition: CGOpenMPRuntime.h:1659
clang::CodeGen::CGOpenMPRuntime::emitFunctionProlog
virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D)
Emits OpenMP-specific function prolog.
Definition: CGOpenMPRuntime.cpp:12156
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::NumberOfPtrs
unsigned NumberOfPtrs
The total number of pointers passed to the runtime library.
Definition: CGOpenMPRuntime.h:1689
clang::CodeGen::OMPTaskDataTy::DependData::DependData
DependData()=default
clang::CodeGen::OMPTaskDataTy::Priority
llvm::PointerIntPair< llvm::Value *, 1, bool > Priority
Definition: CGOpenMPRuntime.h:117
clang::CodeGen::CGOpenMPRuntime::emitForDispatchInit
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.
Definition: CGOpenMPRuntime.cpp:2699
V
#define V(N, I)
Definition: ASTContext.h:3176
clang::CodeGen::CGOpenMPRuntime::emitForOrderedIterationEnd
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...
Definition: CGOpenMPRuntime.cpp:2850
clang::CodeGen::CGOpenMPRuntime::isStaticNonchunked
virtual bool isStaticNonchunked(OpenMPScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static non-chunked.
Definition: CGOpenMPRuntime.cpp:2615
clang::CodeGen::CGOpenMPRuntime::getOMPBuilder
llvm::OpenMPIRBuilder & getOMPBuilder()
Definition: CGOpenMPRuntime.h:305
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalData::Fn
llvm::Function * Fn
Definition: CGOpenMPRuntime.h:274
clang::CodeGen::CGOpenMPRuntime::emitTaskReductionInit
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.
Definition: CGOpenMPRuntime.cpp:5945
clang::CodeGen::OMPTaskDataTy::DependData::DependData
DependData(OpenMPDependClauseKind DepKind, const Expr *IteratorExpr)
Definition: CGOpenMPRuntime.h:111
clang::CodeGen::CGOpenMPRuntime::emitDestroyClause
void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal, SourceLocation Loc)
Emits the code to destroy the dependency object provided in depobj directive.
Definition: CGOpenMPRuntime.cpp:4938
clang::CodeGen::CGOpenMPSIMDRuntime::emitNumThreadsClause
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)...
Definition: CGOpenMPRuntime.cpp:12945
clang::CodeGen::CGOpenMPRuntime::emitTeamsCall
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...
Definition: CGOpenMPRuntime.cpp:11029
clang::CodeGen::CGOpenMPSIMDRuntime::emitTargetDataCalls
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.
Definition: CGOpenMPRuntime.cpp:13095
clang::OMPDeclareReductionDecl
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:171
clang::CodeGen::CGOpenMPRuntime::DispatchRTInput
struct with the values to be passed to the dispatch runtime function
Definition: CGOpenMPRuntime.h:1128
clang::CodeGen::ReductionCodeGen::getBaseDecl
const VarDecl * getBaseDecl(unsigned N) const
Returns the base declaration of the reduction item.
Definition: CGOpenMPRuntime.h:215
clang::Linkage
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:23
clang::CodeGen::OMPTaskDataTy::Tied
bool Tied
Definition: CGOpenMPRuntime.h:120
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::TargetDataInfo
TargetDataInfo()
Definition: CGOpenMPRuntime.h:1694
clang::CodeGen::OMPTaskDataTy::Dependences
SmallVector< DependData, 4 > Dependences
Definition: CGOpenMPRuntime.h:114
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::getKind
OffloadingEntryInfoKinds getKind() const
Definition: CGOpenMPRuntime.h:554
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo
Base class of the entries info.
Definition: CGOpenMPRuntime.h:531
clang::CodeGen::CGOpenMPRuntime::emitDependClause
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).
Definition: CGOpenMPRuntime.cpp:4729
CGValue.h
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::OffloadingEntryInfoDeviceGlobalVar
@ OffloadingEntryInfoDeviceGlobalVar
Entry is a declare target variable.
Definition: CGOpenMPRuntime.h:538
clang::CodeGen::CGOpenMPRuntime::emitMaskedRegion
virtual void emitMaskedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc, const Expr *Filter=nullptr)
Emits a masked region.
Definition: CGOpenMPRuntime.cpp:2252
clang::OMPLoopDirective
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
Definition: StmtOpenMP.h:1002
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::OffloadEntryInfo
OffloadEntryInfo(OffloadingEntryInfoKinds Kind, unsigned Order, uint32_t Flags)
Definition: CGOpenMPRuntime.h:546
clang::CodeGen::CGOpenMPSIMDRuntime::emitSingleRegion
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.
Definition: CGOpenMPRuntime.cpp:12882
clang::CodeGen::CGOpenMPSIMDRuntime::emitNumTeamsClause
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,...
Definition: CGOpenMPRuntime.cpp:13088
clang::CodeGen::OMPTaskDataTy::Nogroup
bool Nogroup
Definition: CGOpenMPRuntime.h:121
clang::CodeGen::CGOpenMPRuntime::hasRequiresUnifiedSharedMemory
bool hasRequiresUnifiedSharedMemory() const
Return whether the unified_shared_memory has been specified.
Definition: CGOpenMPRuntime.cpp:10949
clang::CodeGen::OMPTaskDataTy::PrivateLocals
SmallVector< CanonicalDeclPtr< const VarDecl >, 4 > PrivateLocals
Definition: CGOpenMPRuntime.h:105
clang::CodeGen::ReductionCodeGen::emitInitialization
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.
Definition: CGOpenMPRuntime.cpp:877
clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunctionHelper
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.
Definition: CGOpenMPRuntime.cpp:6404
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:208
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::getOrder
unsigned getOrder() const
Definition: CGOpenMPRuntime.h:553
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar
Device global variable entries info.
Definition: CGOpenMPRuntime.h:660
clang::CodeGen::CGOpenMPRuntime::getDefaultLocationReserved2Flags
virtual unsigned getDefaultLocationReserved2Flags() const
Returns additional flags that can be stored in reserved_2 field of the default location.
Definition: CGOpenMPRuntime.h:406
clang::CodeGen::CGOpenMPRuntime::emitForStaticInit
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.
Definition: CGOpenMPRuntime.cpp:2781
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalData::Disabled
bool Disabled
Definition: CGOpenMPRuntime.h:275
clang::CodeGen::CGOpenMPSIMDRuntime::getAddrOfArtificialThreadPrivate
Address getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name) override
Creates artificial threadprivate variable with name Name and type VarType.
Definition: CGOpenMPRuntime.cpp:12970
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::TargetDataInfo
TargetDataInfo(bool RequiresDevicePointerInfo, bool SeparateBeginEndCalls)
Definition: CGOpenMPRuntime.h:1695
clang::CodeGen::CGOpenMPRuntime::FirstSeparator
StringRef FirstSeparator
Definition: CGOpenMPRuntime.h:309
clang::CodeGen::CGOpenMPSIMDRuntime::emitTargetFunctions
bool emitTargetFunctions(GlobalDecl GD) override
Emit the target regions enclosed in GD function definition or the function itself in case it is a val...
Definition: CGOpenMPRuntime.cpp:13068
intptr_t
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
Definition: opencl-c-base.h:133
clang::CodeGen::CGOpenMPRuntime::emitDoacrossInit
virtual void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D, ArrayRef< Expr * > NumIterations)
Emit initialization for doacross loop nesting support.
Definition: CGOpenMPRuntime.cpp:12031
OpenMPKinds.h
clang::CodeGen::ReductionCodeGen::ReductionCodeGen
ReductionCodeGen(ArrayRef< const Expr * > Shareds, ArrayRef< const Expr * > Origs, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > ReductionOps)
Definition: CGOpenMPRuntime.cpp:792
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::HasMapper
bool HasMapper
Indicate whether any user-defined mapper exists.
Definition: CGOpenMPRuntime.h:1687
clang::CodeGen::OMPTaskDataTy::DependData::DepExprs
SmallVector< const Expr *, 4 > DepExprs
Definition: CGOpenMPRuntime.h:109
clang::CodeGen::CGOpenMPRuntime::DispatchRTInput::DispatchRTInput
DispatchRTInput(llvm::Value *LB, llvm::Value *UB, llvm::Value *Chunk)
Definition: CGOpenMPRuntime.h:1137
clang::CodeGen::CGOpenMPSIMDRuntime::emitFlush
void emitFlush(CodeGenFunction &CGF, ArrayRef< const Expr * > Vars, SourceLocation Loc, llvm::AtomicOrdering AO) override
Emit flush of the variables specified in 'omp flush' directive.
Definition: CGOpenMPRuntime.cpp:12975
clang::CodeGen::ReductionCodeGen::emitAggregateType
void emitAggregateType(CodeGenFunction &CGF, unsigned N)
Emits the code for the variable-modified type, if required.
Definition: CGOpenMPRuntime.cpp:826
Type.h
clang::CodeGen::CGOpenMPSIMDRuntime::emitOrderedRegion
void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads) override
Emit an ordered region.
Definition: CGOpenMPRuntime.cpp:12890
clang::CodeGen::OMPTaskDataTy::FirstprivateInits
SmallVector< const Expr *, 4 > FirstprivateInits
Definition: CGOpenMPRuntime.h:98
clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective
virtual void emitInlinedDirective(CodeGenFunction &CGF, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen, bool HasCancel=false)
Emit code for the directive that does not require outlining.
Definition: CGOpenMPRuntime.cpp:6180
clang::CodeGen::CGOpenMPRuntime::getDefaultFlagsForBarriers
static unsigned getDefaultFlagsForBarriers(OpenMPDirectiveKind Kind)
Returns default flags for the barriers depending on the directive, for which this barier is going to ...
Definition: CGOpenMPRuntime.cpp:2503
clang::CodeGen::CGOpenMPRuntime::isStaticChunked
virtual bool isStaticChunked(OpenMPScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static chunked.
Definition: CGOpenMPRuntime.cpp:2628
llvm::SmallString< 16 >
clang::CodeGen::OMPTaskDataTy::IsWorksharingReduction
bool IsWorksharingReduction
Definition: CGOpenMPRuntime.h:123
clang::CodeGen::CGOpenMPSIMDRuntime::emitCriticalRegion
void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr) override
Emits a critical region.
Definition: CGOpenMPRuntime.cpp:12851
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:874
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::OffloadEntryInfoDeviceGlobalVar
OffloadEntryInfoDeviceGlobalVar(unsigned Order, llvm::Constant *Addr, CharUnits VarSize, OMPTargetGlobalVarEntryKind Flags, llvm::GlobalValue::LinkageTypes Linkage)
Definition: CGOpenMPRuntime.h:671
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::CaptureDeviceAddrMap
llvm::DenseMap< const ValueDecl *, Address > CaptureDeviceAddrMap
Map between the a declaration of a capture and the corresponding base pointer address where the runti...
Definition: CGOpenMPRuntime.h:1692
clang::CodeGen::CGOpenMPSIMDRuntime::emitMasterRegion
void emitMasterRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MasterOpGen, SourceLocation Loc) override
Emits a master region.
Definition: CGOpenMPRuntime.cpp:12858
clang::OMPDeclareMapperDecl
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:286
clang::CodeGen::CGOpenMPSIMDRuntime::emitMaskedRegion
void emitMaskedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc, const Expr *Filter=nullptr) override
Emits a masked region.
Definition: CGOpenMPRuntime.cpp:12864
llvm::DenseSet
Definition: Sema.h:77
clang::CodeGen::ReductionCodeGen::getOrigLValue
LValue getOrigLValue(unsigned N) const
Returns LValue for the original reduction item.
Definition: CGOpenMPRuntime.h:208
clang::CodeGen::CGOpenMPRuntime::emitLastprivateConditionalInit
Address emitLastprivateConditionalInit(CodeGenFunction &CGF, const VarDecl *VD)
Create specialized alloca to handle lastprivate conditionals.
Definition: CGOpenMPRuntime.cpp:12516
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalRAII
Manages list of lastprivate conditional decls for the specified directive.
Definition: CGOpenMPRuntime.h:278
clang::CodeGen::CGOpenMPRuntime::emitMasterRegion
virtual void emitMasterRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MasterOpGen, SourceLocation Loc)
Emits a master region.
Definition: CGOpenMPRuntime.cpp:2229
clang::CodeGen::CGOpenMPRuntime::getDefaultDistScheduleAndChunk
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.
Definition: CGOpenMPRuntime.h:1782
clang::CodeGen::CGOpenMPRuntime::getIdentTyPointerTy
llvm::Type * getIdentTyPointerTy()
Returns pointer to ident_t type.
Definition: CGOpenMPRuntime.cpp:1484
clang::CodeGen::CGOpenMPRuntime::emitNumThreadsForTargetDirective
llvm::Value * emitNumThreadsForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D)
Definition: CGOpenMPRuntime.cpp:6941
clang::CodeGen::CGOpenMPRuntime::ReductionOptionsTy
Definition: CGOpenMPRuntime.h:1430
clang::CodeGen::CGOpenMPRuntime::isNontemporalDecl
bool isNontemporalDecl(const ValueDecl *VD) const
Checks if the VD variable is marked as nontemporal declaration in current context.
Definition: CGOpenMPRuntime.cpp:12356
clang::CodeGen::CGOpenMPRuntime::getSingleCompoundChild
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 ...
Definition: CGOpenMPRuntime.cpp:6514
clang::CodeGen::CGOpenMPSIMDRuntime::emitForStaticFinish
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.
Definition: CGOpenMPRuntime.cpp:12931
clang::CodeGen::Address
An aligned address.
Definition: Address.h:74
clang::CodeGen::CGOpenMPRuntime::DisableAutoDeclareTargetRAII::DisableAutoDeclareTargetRAII
DisableAutoDeclareTargetRAII(CodeGenModule &CGM)
Definition: CGOpenMPRuntime.cpp:10953
clang::CodeGen::OMPTaskDataTy::ReductionCopies
SmallVector< const Expr *, 4 > ReductionCopies
Definition: CGOpenMPRuntime.h:103
clang::CodeGen::CGOpenMPSIMDRuntime::getTaskReductionItem
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...
Definition: CGOpenMPRuntime.cpp:13026
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskReductionInit
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.
Definition: CGOpenMPRuntime.cpp:13007
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::StaticRTInput
StaticRTInput(unsigned IVSize, bool IVSigned, bool Ordered, Address IL, Address LB, Address UB, Address ST, llvm::Value *Chunk=nullptr)
Definition: CGOpenMPRuntime.h:1188
clang::CodeGen::ReductionCodeGen::getSharedLValue
LValue getSharedLValue(unsigned N) const
Returns LValue for the reduction item.
Definition: CGOpenMPRuntime.h:206
clang::CodeGen::CGOpenMPRuntime::DispatchRTInput::DispatchRTInput
DispatchRTInput()=default
clang::OpenMPDependClauseKind
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:54
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskgroupRegion
void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc) override
Emit a taskgroup region.
Definition: CGOpenMPRuntime.cpp:12876
clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata
void createOffloadEntriesAndInfoMetadata()
Creates all the offload entries in the current compilation unit along with the associated metadata.
Definition: CGOpenMPRuntime.cpp:3097
clang::CodeGen::CGOpenMPRuntime::emitDistributeStaticInit
virtual void emitDistributeStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDistScheduleClauseKind SchedKind, const StaticRTInput &Values)
Definition: CGOpenMPRuntime.cpp:2802
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::OffloadEntryInfo
OffloadEntryInfo()=delete
clang::CodeGen::OMPTaskDataTy::NumberOfParts
unsigned NumberOfParts
Definition: CGOpenMPRuntime.h:119
clang::CodeGen::CGOpenMPRuntime::emitUpdateLocation
llvm::Value * emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc, unsigned Flags=0)
Emits object of ident_t type with info for source location.
Definition: CGOpenMPRuntime.cpp:1370
clang::CodeGen::CGOpenMPRuntime::emitUpdateClause
void emitUpdateClause(CodeGenFunction &CGF, LValue DepobjLVal, OpenMPDependClauseKind NewDepKind, SourceLocation Loc)
Updates the dependency kind in the specified depobj object.
Definition: CGOpenMPRuntime.cpp:4965
clang::CodeGen::CGOpenMPRuntime::DispatchRTInput::UB
llvm::Value * UB
Loop upper bound.
Definition: CGOpenMPRuntime.h:1132
clang::CodeGen::CGOpenMPRuntime::emitDeclareTargetVarDefinition
virtual bool emitDeclareTargetVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Addr, bool PerformInit)
Emit a code for initialization of declare target variable.
Definition: CGOpenMPRuntime.cpp:1837
clang::CodeGen::CGOpenMPRuntime::getAddrOfDeclareTargetVar
virtual Address getAddrOfDeclareTargetVar(const VarDecl *VD)
Returns the address of the variable marked as declare target with link clause OR as declare target wi...
Definition: CGOpenMPRuntime.cpp:1625
clang::CodeGen::CGOpenMPRuntime::DispatchRTInput::LB
llvm::Value * LB
Loop lower bound.
Definition: CGOpenMPRuntime.h:1130
clang::CodeGen::CGOpenMPRuntime::getOutlinedHelperName
virtual StringRef getOutlinedHelperName() const
Get the function name of an outlined region.
Definition: CGOpenMPRuntime.h:385
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::clearArrayInfo
void clearArrayInfo()
Clear information about the data arrays.
Definition: CGOpenMPRuntime.h:1700
clang::LangAS
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
clang::CodeGen::CGOpenMPSIMDRuntime
Class supports emissionof SIMD-only code.
Definition: CGOpenMPRuntime.h:1932
clang::CodeGen::CGOpenMPRuntime::getAddrOfThreadPrivate
virtual Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc)
Returns address of the threadprivate variable for the current thread.
Definition: CGOpenMPRuntime.cpp:1674
clang::CodeGen::RegionCodeGenTy
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
Definition: CGOpenMPRuntime.h:68
clang::CodeGen::CGOpenMPRuntime::isDefaultLocationConstant
virtual bool isDefaultLocationConstant() const
Check if the default location must be constant.
Definition: CGOpenMPRuntime.h:402
clang::CodeGen::CGOpenMPRuntime::getTaskReductionItem
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...
Definition: CGOpenMPRuntime.cpp:6109
clang::CodeGen::PrePostActionTy::~PrePostActionTy
virtual ~PrePostActionTy()
Definition: CGOpenMPRuntime.h:63
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::Ordered
bool Ordered
true if loop is ordered, false otherwise.
Definition: CGOpenMPRuntime.h:1172
clang::CodeGen::LValue
LValue - This represents an lvalue references.
Definition: CGValue.h:171
SourceLocation.h
clang::OMPDependClause
This represents implicit clause 'depend' for the '#pragma omp task' directive.
Definition: OpenMPClause.h:4742
clang::CodeGen::ReductionCodeGen::emitSharedOrigLValue
void emitSharedOrigLValue(CodeGenFunction &CGF, unsigned N)
Emits lvalue for the shared and original reduction item.
Definition: CGOpenMPRuntime.cpp:811
clang::CodeGen::PrePostActionTy::PrePostActionTy
PrePostActionTy()
Definition: CGOpenMPRuntime.h:60
clang::CodeGen::CGOpenMPRuntime::emitNumTeamsClause
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,...
Definition: CGOpenMPRuntime.cpp:11054
clang::CodeGen::CGOpenMPRuntime::NontemporalDeclsRAII::~NontemporalDeclsRAII
~NontemporalDeclsRAII()
Definition: CGOpenMPRuntime.cpp:12332
clang::CodeGen::CGOpenMPRuntime::translateParameter
virtual const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const
Translates the native parameter of outlined function if this is required for target.
Definition: CGOpenMPRuntime.h:1767
clang::CodeGen::CGOpenMPRuntime::emitDeferredTargetDecls
void emitDeferredTargetDecls() const
Emit deferred declare target variables marked for deferred emission.
Definition: CGOpenMPRuntime.cpp:10872
clang::CodeGen::CGOpenMPRuntime::checkAndEmitLastprivateConditional
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 ...
Definition: CGOpenMPRuntime.cpp:12708
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion::getID
llvm::Constant * getID() const
Definition: CGOpenMPRuntime.h:616
clang::CodeGen::CGOpenMPRuntime::DispatchRTInput::Chunk
llvm::Value * Chunk
Chunk size specified using 'schedule' clause (nullptr if chunk was not specified)
Definition: CGOpenMPRuntime.h:1135
clang::CodeGen::PrePostActionTy::Enter
virtual void Enter(CodeGenFunction &CGF)
Definition: CGOpenMPRuntime.h:61
clang::CodeGen::CodeGenFunction
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Definition: CodeGenFunction.h:231
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:674
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::MapTypesArray
llvm::Value * MapTypesArray
The array of map types passed to the runtime library for the beginning of the region or for the entir...
Definition: CGOpenMPRuntime.h:1676
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::OffloadEntryInfo
OffloadEntryInfo(OffloadingEntryInfoKinds Kind)
Definition: CGOpenMPRuntime.h:545
clang::CodeGen::CGOpenMPSIMDRuntime::emitTeamsCall
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...
Definition: CGOpenMPRuntime.cpp:13080
clang::CodeGen::OMPTaskDataTy::LastprivateCopies
SmallVector< const Expr *, 4 > LastprivateCopies
Definition: CGOpenMPRuntime.h:100
clang::CodeGen::CGOpenMPRuntime::processRequiresDirective
virtual void processRequiresDirective(const OMPRequiresDecl *D)
Perform check on requires decl to ensure that target architecture supports unified addressing.
Definition: CGOpenMPRuntime.cpp:10897
clang::CodeGen::OMPTaskDataTy::DependData::DepKind
OpenMPDependClauseKind DepKind
Definition: CGOpenMPRuntime.h:107
clang::CodeGen::CGOpenMPSIMDRuntime::emitTargetCall
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.
Definition: CGOpenMPRuntime.cpp:13058
clang::CodeGen::CGOpenMPRuntime::CGOpenMPRuntime
CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator, StringRef Separator)
Constructor allowing to redefine the name separator for the variables.
Definition: CGOpenMPRuntime.cpp:1060
clang::CodeGen::CGOpenMPRuntime::DisableAutoDeclareTargetRAII::~DisableAutoDeclareTargetRAII
~DisableAutoDeclareTargetRAII()
Definition: CGOpenMPRuntime.cpp:10962
clang::CodeGen::CodeGenModule
This class organizes the cross-function state that is used while generating LLVM code.
Definition: CodeGenModule.h:275
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion::OffloadEntryInfoTargetRegion
OffloadEntryInfoTargetRegion(unsigned Order, llvm::Constant *Addr, llvm::Constant *ID, OMPTargetRegionEntryKind Flags)
Definition: CGOpenMPRuntime.h:607
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::IL
Address IL
Address of the output variable in which the flag of the last iteration is returned.
Definition: CGOpenMPRuntime.h:1175
clang::CodeGen::CGOpenMPSIMDRuntime::emitTeamsOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:12828
llvm::ArrayRef
Definition: LLVM.h:34
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::setLinkage
void setLinkage(llvm::GlobalValue::LinkageTypes LT)
Definition: CGOpenMPRuntime.h:683
Value
Value
Definition: UninitializedValues.cpp:102
clang::CodeGen::OMPTaskDataTy::ReductionOrigs
SmallVector< const Expr *, 4 > ReductionOrigs
Definition: CGOpenMPRuntime.h:102
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
clang::CodeGen::CGOpenMPRuntime::emitNumThreadsClause
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)...
Definition: CGOpenMPRuntime.cpp:2885
clang::CodeGen::CGOpenMPRuntime::getKmpCriticalNameTy
llvm::ArrayType * getKmpCriticalNameTy() const
Get the LLVM type for the critical name.
Definition: CGOpenMPRuntime.h:413
clang::CodeGen::Address::invalid
static Address invalid()
Definition: Address.h:90
clang::CodeGen::OMPTaskDataTy
Definition: CGOpenMPRuntime.h:93
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion
Target region entries info.
Definition: CGOpenMPRuntime.h:600
clang::CodeGen::CGOpenMPRuntime::ReductionOptionsTy::WithNowait
bool WithNowait
Definition: CGOpenMPRuntime.h:1431
clang::CodeGen::CGOpenMPRuntime::adjustTargetSpecificDataForLambdas
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...
Definition: CGOpenMPRuntime.cpp:10891
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskyieldCall
void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc) override
Emits a masked region.
Definition: CGOpenMPRuntime.cpp:12871
clang::CodeGen::CGOpenMPRuntime::emitTargetDataCalls
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.
Definition: CGOpenMPRuntime.cpp:11083
clang::CodeGen::OMPTaskDataTy::PrivateCopies
SmallVector< const Expr *, 4 > PrivateCopies
Definition: CGOpenMPRuntime.h:95
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::Chunk
llvm::Value * Chunk
Value of the chunk for the static_chunked scheduled loop.
Definition: CGOpenMPRuntime.h:1187
clang::CodeGen::ReductionCodeGen::getPrivateType
QualType getPrivateType(unsigned N) const
Return the type of the private item.
Definition: CGOpenMPRuntime.h:222
clang::CodeGen::CGOpenMPSIMDRuntime::emitBarrierCall
void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false) override
Emit an implicit/explicit barrier for OpenMP threads.
Definition: CGOpenMPRuntime.cpp:12897
clang::CodeGen::CGOpenMPRuntime::markAsGlobalTarget
bool markAsGlobalTarget(GlobalDecl GD)
Marks the declaration as already emitted for the device code and returns true, if it was marked alrea...
Definition: CGOpenMPRuntime.cpp:10967
clang::CodeGen::OMPTaskDataTy::FirstprivateCopies
SmallVector< const Expr *, 4 > FirstprivateCopies
Definition: CGOpenMPRuntime.h:97
clang::CodeGen::CGOpenMPRuntime::emitOutlinedFunctionCall
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...
Definition: CGOpenMPRuntime.cpp:12150
clang::CodeGen::CGOpenMPSIMDRuntime::emitDistributeStaticInit
void emitDistributeStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDistScheduleClauseKind SchedKind, const StaticRTInput &Values) override
Definition: CGOpenMPRuntime.cpp:12918
clang::CodeGen::CGOpenMPRuntime::emitReductionFunction
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.
Definition: CGOpenMPRuntime.cpp:5320
clang::CodeGen::CGOpenMPRuntime::emitSingleRegion
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.
Definition: CGOpenMPRuntime.cpp:2392
clang::OMPExecutableDirective
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:266
clang::CodeGen::CGOpenMPRuntime::getDefaultScheduleAndChunk
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.
Definition: CGOpenMPRuntime.cpp:2518
clang::CodeGen::CGOpenMPSIMDRuntime::emitForOrderedIterationEnd
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...
Definition: CGOpenMPRuntime.cpp:12924
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion::classof
static bool classof(const OffloadEntryInfo *Info)
Definition: CGOpenMPRuntime.h:621
clang::CodeGen::CGOpenMPRuntime::ReductionOptionsTy::SimpleReduction
bool SimpleReduction
Definition: CGOpenMPRuntime.h:1432
clang::CodeGen::CGOpenMPRuntime::emitTaskOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:1285
clang::CodeGen::CGOpenMPRuntime::UntiedTaskLocalDeclsRAII
Manages list of nontemporal decls for the specified directive.
Definition: CGOpenMPRuntime.h:252
clang::CodeGen::CGOpenMPRuntime::emitOrderedRegion
virtual void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads)
Emit an ordered region.
Definition: CGOpenMPRuntime.cpp:2479
std
Definition: Format.h:4303
clang::CodeGen::CGOpenMPSIMDRuntime::emitDoacrossOrdered
void emitDoacrossOrdered(CodeGenFunction &CGF, const OMPDependClause *C) override
Emit code for doacross ordered directive with 'depend' clause.
Definition: CGOpenMPRuntime.cpp:13113
clang::CodeGen::CGOpenMPSIMDRuntime::emitParallelCall
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...
Definition: CGOpenMPRuntime.cpp:12842
clang::CodeGen::CGOpenMPRuntime::getOrCreateUserDefinedMapperFunc
llvm::Function * getOrCreateUserDefinedMapperFunc(const OMPDeclareMapperDecl *D)
Get the function for the specified user-defined mapper.
Definition: CGOpenMPRuntime.cpp:10183
clang::CodeGen::CGOpenMPSIMDRuntime::getParameterAddress
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.
Definition: CGOpenMPRuntime.cpp:13125
clang::CodeGen::CGOpenMPRuntime::emitUserDefinedReduction
virtual void emitUserDefinedReduction(CodeGenFunction *CGF, const OMPDeclareReductionDecl *D)
Emit code for the specified user defined reduction construct.
Definition: CGOpenMPRuntime.cpp:1152
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::isValid
bool isValid()
Return true if the current target data information has valid arrays.
Definition: CGOpenMPRuntime.h:1712
clang::CodeGen::CGOpenMPRuntime::emitCancelCall
virtual void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc, const Expr *IfCond, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancel' construct.
Definition: CGOpenMPRuntime.cpp:6258
clang
Definition: CalledOnceCheck.h:17
clang::CodeGen::ReductionCodeGen::emitCleanups
void emitCleanups(CodeGenFunction &CGF, unsigned N, Address PrivateAddr)
Emits cleanup code for the reduction item.
Definition: CGOpenMPRuntime.cpp:908
clang::CodeGen::CGOpenMPRuntime::emitIfClause
void emitIfClause(CodeGenFunction &CGF, const Expr *Cond, const RegionCodeGenTy &ThenGen, const RegionCodeGenTy &ElseGen)
Emits code for OpenMP 'if' clause using specified CodeGen function.
Definition: CGOpenMPRuntime.cpp:2000
clang::OpenMPDistScheduleClauseKind
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Definition: OpenMPKinds.h:103
clang::CodeGen::CGOpenMPRuntime::emitTargetGlobal
virtual bool emitTargetGlobal(GlobalDecl GD)
Emit the global GD if it is meaningful for the target.
Definition: CGOpenMPRuntime.cpp:10864
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskReductionFini
void emitTaskReductionFini(CodeGenFunction &CGF, SourceLocation Loc, bool IsWorksharingReduction) override
Emits the following code for reduction clause with task modifier:
Definition: CGOpenMPRuntime.cpp:13013
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:69
clang::CodeGen::ReductionCodeGen::needCleanups
bool needCleanups(unsigned N)
Returns true if the private copy requires cleanups.
Definition: CGOpenMPRuntime.cpp:902
clang::CodeGen::CGOpenMPRuntime::emitUserDefinedMapper
void emitUserDefinedMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit the function for the user defined mapper construct.
Definition: CGOpenMPRuntime.cpp:9867
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::setVarSize
void setVarSize(CharUnits Size)
Definition: CGOpenMPRuntime.h:681
clang::CodeGen::CGOpenMPRuntime::clear
virtual void clear()
Definition: CGOpenMPRuntime.cpp:1071
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::getVarSize
CharUnits getVarSize() const
Definition: CGOpenMPRuntime.h:680
clang::CodeGen::CGOpenMPSIMDRuntime::emitParallelOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:12822
clang::CodeGen::CGOpenMPRuntime::emitDoacrossOrdered
virtual void emitDoacrossOrdered(CodeGenFunction &CGF, const OMPDependClause *C)
Emit code for doacross ordered directive with 'depend' clause.
Definition: CGOpenMPRuntime.cpp:12102
clang::CodeGen::CGOpenMPRuntime::emitNumTeamsForTargetDirective
llvm::Value * emitNumTeamsForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D)
Definition: CGOpenMPRuntime.cpp:6685
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalRAII::~LastprivateConditionalRAII
~LastprivateConditionalRAII()
Definition: CGOpenMPRuntime.cpp:12500
clang::CodeGen::CGOpenMPRuntime::emitTeamsOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:1277
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::getAddress
llvm::Constant * getAddress() const
Definition: CGOpenMPRuntime.h:557
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang::CodeGen::RegionCodeGenTy::setAction
void setAction(PrePostActionTy &Action) const
Definition: CGOpenMPRuntime.h:89
clang::OMPRequiresDecl
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:416
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoTargetRegion::OffloadEntryInfoTargetRegion
OffloadEntryInfoTargetRegion()
Definition: CGOpenMPRuntime.h:605
clang::CodeGen::OMPTaskDataTy::PrivateVars
SmallVector< const Expr *, 4 > PrivateVars
Definition: CGOpenMPRuntime.h:94
clang::CodeGen::CGOpenMPRuntime::emitTargetDataStandAloneCall
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...
Definition: CGOpenMPRuntime.cpp:11237
clang::CodeGen::CGOpenMPRuntime::getAddrOfArtificialThreadPrivate
virtual Address getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name)
Creates artificial threadprivate variable with name Name and type VarType.
Definition: CGOpenMPRuntime.cpp:1968
clang::CodeGen::RegionCodeGenTy::RegionCodeGenTy
RegionCodeGenTy(Callable &&CodeGen, std::enable_if_t<!std::is_same< std::remove_reference_t< Callable >, RegionCodeGenTy >::value > *=nullptr)
Definition: CGOpenMPRuntime.h:82
clang::CodeGen::CGOpenMPSIMDRuntime::emitForStaticInit
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.
Definition: CGOpenMPRuntime.cpp:12912
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::MapNamesArray
llvm::Value * MapNamesArray
The array of original declaration names of mapped pointers sent to the runtime library for debugging.
Definition: CGOpenMPRuntime.h:1685
GlobalDecl.h
clang::CodeGen::CGOpenMPRuntime::NontemporalDeclsRAII
Manages list of nontemporal decls for the specified directive.
Definition: CGOpenMPRuntime.h:242
clang::CodeGen::CGOpenMPRuntime::emitTargetGlobalVariable
virtual bool emitTargetGlobalVariable(GlobalDecl GD)
Emit the global variable if it is a valid device global variable.
Definition: CGOpenMPRuntime.cpp:10744
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::OffloadingEntryInfoInvalid
@ OffloadingEntryInfoInvalid
Invalid entry info.
Definition: CGOpenMPRuntime.h:540
clang::CodeGen::CGOpenMPRuntime::UntiedTaskLocalDeclsRAII::UntiedTaskLocalDeclsRAII
UntiedTaskLocalDeclsRAII(CodeGenFunction &CGF, const llvm::MapVector< CanonicalDeclPtr< const VarDecl >, std::pair< Address, Address >> &LocalVars)
Definition: CGOpenMPRuntime.cpp:12338
clang::OpenMPDirectiveKind
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:24
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::getFlags
uint32_t getFlags() const
Definition: CGOpenMPRuntime.h:555
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::OffloadingEntryInfoTargetRegion
@ OffloadingEntryInfoTargetRegion
Entry is a target region.
Definition: CGOpenMPRuntime.h:536
clang::CanonicalDeclPtr
A wrapper class around a pointer that always points to its canonical declaration.
Definition: Redeclarable.h:349
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::SizesArray
llvm::Value * SizesArray
The array of sizes passed to the runtime library.
Definition: CGOpenMPRuntime.h:1672
clang::CharUnits
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
clang::CodeGen::CGOpenMPRuntime::isLocalVarInUntiedTask
bool isLocalVarInUntiedTask(CodeGenFunction &CGF, const VarDecl *VD) const
Returns true if the variable is a local variable in untied task.
Definition: CGOpenMPRuntime.cpp:12298
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::LB
Address LB
Address of the output variable in which the lower iteration number is returned.
Definition: CGOpenMPRuntime.h:1178
clang::CodeGen::OMPTaskDataTy::FirstprivateVars
SmallVector< const Expr *, 4 > FirstprivateVars
Definition: CGOpenMPRuntime.h:96
clang::CodeGen::CGOpenMPRuntime::emitThreadPrivateVarDefinition
virtual llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr)
Emit a code for initialization of threadprivate variable.
Definition: CGOpenMPRuntime.cpp:1716
clang::CodeGen::CGOpenMPSIMDRuntime::getAddressOfLocalVariable
Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) override
Gets the OpenMP-specific address of the local variable.
Definition: CGOpenMPRuntime.h:2531
clang::CodeGen::CGOpenMPRuntime::DisableAutoDeclareTargetRAII
Allows to disable automatic handling of functions used in target regions as those marked as omp decla...
Definition: CGOpenMPRuntime.h:232
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::IVSigned
bool IVSigned
Sign of the iteration variable.
Definition: CGOpenMPRuntime.h:1170
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::CodeGen::CGOpenMPRuntime::emitTaskgroupRegion
virtual void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc)
Emit a taskgroup region.
Definition: CGOpenMPRuntime.cpp:2301
clang::OpenMPScheduleClauseKind
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:30
clang::CodeGen::CGOpenMPRuntime::CGM
CodeGenModule & CGM
Definition: CGOpenMPRuntime.h:308
clang::CodeGen::OMPTaskDataTy::ReductionVars
SmallVector< const Expr *, 4 > ReductionVars
Definition: CGOpenMPRuntime.h:101
clang::CodeGen::CGOpenMPRuntime::emitUsesAllocatorsFini
void emitUsesAllocatorsFini(CodeGenFunction &CGF, const Expr *Allocator)
Destroys user defined allocators specified in the uses_allocators clause.
Definition: CGOpenMPRuntime.cpp:6388
clang::CodeGen::CGOpenMPRuntime::emitTaskCall
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.
Definition: CGOpenMPRuntime.cpp:5012
clang::CodeGen::CGOpenMPRuntime::emitDeclareSimdFunction
virtual void emitDeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn)
Marks function Fn with properly mangled versions of vector functions.
Definition: CGOpenMPRuntime.cpp:11853
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::classof
static bool classof(const OffloadEntryInfo *Info)
Definition: CGOpenMPRuntime.h:564
clang::DeclRefExpr
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1233
clang::CodeGen::CGOpenMPRuntime::emitUsesAllocatorsInit
void emitUsesAllocatorsInit(CodeGenFunction &CGF, const Expr *Allocator, const Expr *AllocatorTraits)
Initializes user defined allocators specified in the uses_allocators clauses.
Definition: CGOpenMPRuntime.cpp:6353
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1872
clang::RecordDecl
Represents a struct/union/class.
Definition: Decl.h:3908
clang::CodeGen::CGOpenMPRuntime::emitReduction
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.
Definition: CGOpenMPRuntime.cpp:5430
clang::CodeGen::CGOpenMPSIMDRuntime::emitTargetGlobal
bool emitTargetGlobal(GlobalDecl GD) override
Emit the global GD if it is meaningful for the target.
Definition: CGOpenMPRuntime.cpp:13076
clang::CodeGen::ReductionCodeGen::getRefExpr
const Expr * getRefExpr(unsigned N) const
Returns the base declaration of the reduction item.
Definition: CGOpenMPRuntime.h:217
clang::CodeGen::CGOpenMPRuntime::createOffloadEntry
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.
Definition: CGOpenMPRuntime.cpp:3091
clang::CodeGen::CGOpenMPRuntime::LastprivateConditionalData::IVLVal
LValue IVLVal
Definition: CGOpenMPRuntime.h:273
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfoDeviceGlobalVar::classof
static bool classof(const OffloadEntryInfo *Info)
Definition: CGOpenMPRuntime.h:684
clang::CodeGen::CGOpenMPRuntime::OffloadEntriesInfoManagerTy::OffloadEntryInfo::setFlags
void setFlags(uint32_t NewFlags)
Definition: CGOpenMPRuntime.h:556
clang::CodeGen::CGOpenMPRuntime::emitTargetCall
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.
Definition: CGOpenMPRuntime.cpp:10220
clang::ShaderStage::Callable
@ Callable
clang::CodeGen::PrePostActionTy
A basic class for pre|post-action for advanced codegen sequence for OpenMP region.
Definition: CGOpenMPRuntime.h:58
clang::OpenMPScheduleTy
Scheduling data for loop-based OpenMP directives.
Definition: OpenMPKinds.h:157
clang::CodeGen::CGOpenMPRuntime::StaticRTInput::IVSize
unsigned IVSize
Size of the iteration variable in bits.
Definition: CGOpenMPRuntime.h:1168
clang::CodeGen::CGOpenMPRuntime::TargetDataInfo::requiresDevicePointerInfo
bool requiresDevicePointerInfo()
Definition: CGOpenMPRuntime.h:1716
clang::CodeGen::CGOpenMPSIMDRuntime::emitTaskOutlinedFunction
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.
Definition: CGOpenMPRuntime.cpp:12834
clang::CodeGen::CGOpenMPRuntime::functionFinished
virtual void functionFinished(CodeGenFunction &CGF)
Cleans up references to the objects in finished function.
Definition: CGOpenMPRuntime.cpp:1463
clang::CodeGen::CGOpenMPRuntime::getUserDefinedReduction
virtual std::pair< llvm::Function *, llvm::Function * > getUserDefinedReduction(const OMPDeclareReductionDecl *D)
Get combiner/initializer for the specified user-defined reduction, if any.
Definition: CGOpenMPRuntime.cpp:1179
clang::CodeGen::CGOpenMPSIMDRuntime::emitReduction
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.
Definition: CGOpenMPRuntime.cpp:12998
Type
MatchType Type
Definition: ASTMatchFinder.cpp:71
clang::CodeGen::CGOpenMPRuntime::getParameterAddress
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.
Definition: CGOpenMPRuntime.cpp:12162
clang::CodeGen::CGOpenMPRuntime::emitTaskwaitCall
virtual void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPTaskDataTy &Data)
Emit code for 'taskwait' directive.
Definition: CGOpenMPRuntime.cpp:6129
clang::CodeGen::ReductionCodeGen::usesReductionInitializer
bool usesReductionInitializer(unsigned N) const
Returns true if the initialization of the reduction item uses initializer from declare reduction cons...
Definition: CGOpenMPRuntime.cpp:1015