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