clang 20.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"
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
33namespace llvm {
34class ArrayType;
35class Constant;
36class FunctionType;
37class GlobalVariable;
38class Type;
39class Value;
40class OpenMPIRBuilder;
41} // namespace llvm
42
43namespace clang {
44class Expr;
45class OMPDependClause;
46class OMPExecutableDirective;
47class OMPLoopDirective;
48class VarDecl;
49class OMPDeclareReductionDecl;
50
51namespace CodeGen {
52class Address;
53class CodeGenFunction;
54class CodeGenModule;
55
56/// A basic class for pre|post-action for advanced codegen sequence for OpenMP
57/// region.
59public:
60 explicit PrePostActionTy() {}
61 virtual void Enter(CodeGenFunction &CGF) {}
62 virtual void Exit(CodeGenFunction &CGF) {}
63 virtual ~PrePostActionTy() {}
64};
65
66/// Class provides a way to call simple version of codegen for OpenMP region, or
67/// an advanced with possible pre|post-actions in codegen.
68class RegionCodeGenTy final {
69 intptr_t CodeGen;
70 typedef void (*CodeGenTy)(intptr_t, CodeGenFunction &, PrePostActionTy &);
71 CodeGenTy Callback;
72 mutable PrePostActionTy *PrePostAction;
73 RegionCodeGenTy() = delete;
74 template <typename Callable>
75 static void CallbackFn(intptr_t CodeGen, CodeGenFunction &CGF,
76 PrePostActionTy &Action) {
77 return (*reinterpret_cast<Callable *>(CodeGen))(CGF, Action);
78 }
79
80public:
81 template <typename Callable>
83 Callable &&CodeGen,
84 std::enable_if_t<!std::is_same<std::remove_reference_t<Callable>,
85 RegionCodeGenTy>::value> * = nullptr)
86 : CodeGen(reinterpret_cast<intptr_t>(&CodeGen)),
87 Callback(CallbackFn<std::remove_reference_t<Callable>>),
88 PrePostAction(nullptr) {}
89 void setAction(PrePostActionTy &Action) const { PrePostAction = &Action; }
90 void operator()(CodeGenFunction &CGF) const;
91};
92
93struct OMPTaskDataTy final {
106 struct DependData {
108 const Expr *IteratorExpr = nullptr;
110 explicit DependData() = default;
113 };
115 llvm::PointerIntPair<llvm::Value *, 1, bool> Final;
116 llvm::PointerIntPair<llvm::Value *, 1, bool> Schedule;
117 llvm::PointerIntPair<llvm::Value *, 1, bool> Priority;
118 llvm::Value *Reductions = nullptr;
119 unsigned NumberOfParts = 0;
120 bool Tied = true;
121 bool Nogroup = false;
124 bool HasNowaitClause = false;
125 bool HasModifier = false;
126};
127
128/// Class intended to support codegen of all kind of the reduction clauses.
130private:
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.
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.
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 SharedAddr 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, Address SharedAddr,
169 const OMPDeclareReductionDecl *DRD);
170
171public:
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 SharedAddr Address of the original shared variable.
191 void
192 emitInitialization(CodeGenFunction &CGF, unsigned N, Address PrivateAddr,
193 Address SharedAddr,
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 /// Return the type of the private item.
224 QualType getPrivateType(unsigned N) const {
225 return cast<VarDecl>(cast<DeclRefExpr>(ClausesData[N].Private)->getDecl())
226 ->getType();
227 }
228};
229
231public:
232 /// Allows to disable automatic handling of functions used in target regions
233 /// as those marked as `omp declare target`.
235 CodeGenModule &CGM;
236 bool SavedShouldMarkAsGlobal = false;
237
238 public:
241 };
242
243 /// Manages list of nontemporal decls for the specified directive.
245 CodeGenModule &CGM;
246 const bool NeedToPush;
247
248 public:
251 };
252
253 /// Manages list of nontemporal decls for the specified directive.
255 CodeGenModule &CGM;
256 const bool NeedToPush;
257
258 public:
260 CodeGenFunction &CGF,
261 const llvm::MapVector<CanonicalDeclPtr<const VarDecl>,
262 std::pair<Address, Address>> &LocalVars);
264 };
265
266 /// Maps the expression for the lastprivate variable to the global copy used
267 /// to store new value because original variables are not mapped in inner
268 /// parallel regions. Only private copies are captured but we need also to
269 /// store private copy in shared address.
270 /// Also, stores the expression for the private loop counter and it
271 /// threaprivate name.
273 llvm::MapVector<CanonicalDeclPtr<const Decl>, SmallString<16>>
276 llvm::Function *Fn = nullptr;
277 bool Disabled = false;
278 };
279 /// Manages list of lastprivate conditional decls for the specified directive.
281 enum class ActionToDo {
282 DoNotPush,
283 PushAsLastprivateConditional,
284 DisableLastprivateConditional,
285 };
286 CodeGenModule &CGM;
287 ActionToDo Action = ActionToDo::DoNotPush;
288
289 /// Check and try to disable analysis of inner regions for changes in
290 /// lastprivate conditional.
291 void tryToDisableInnerAnalysis(const OMPExecutableDirective &S,
292 llvm::DenseSet<CanonicalDeclPtr<const Decl>>
293 &NeedToAddForLPCsAsDisabled) const;
294
296 const OMPExecutableDirective &S);
297
298 public:
300 const OMPExecutableDirective &S,
301 LValue IVLVal);
303 const OMPExecutableDirective &S);
305 };
306
307 llvm::OpenMPIRBuilder &getOMPBuilder() { return OMPBuilder; }
308
309protected:
311
312 /// An OpenMP-IR-Builder instance.
313 llvm::OpenMPIRBuilder OMPBuilder;
314
315 /// Helper to determine the min/max number of threads/teams for \p D.
317 CodeGenFunction &CGF,
318 int32_t &MinThreadsVal,
319 int32_t &MaxThreadsVal,
320 int32_t &MinTeamsVal,
321 int32_t &MaxTeamsVal);
322
323 /// Helper to emit outlined function for 'target' directive.
324 /// \param D Directive to emit.
325 /// \param ParentName Name of the function that encloses the target region.
326 /// \param OutlinedFn Outlined function value to be defined by this call.
327 /// \param OutlinedFnID Outlined function ID value to be defined by this call.
328 /// \param IsOffloadEntry True if the outlined function is an offload entry.
329 /// \param CodeGen Lambda codegen specific to an accelerator device.
330 /// An outlined function may not be an entry if, e.g. the if clause always
331 /// evaluates to false.
333 StringRef ParentName,
334 llvm::Function *&OutlinedFn,
335 llvm::Constant *&OutlinedFnID,
336 bool IsOffloadEntry,
337 const RegionCodeGenTy &CodeGen);
338
339 /// Returns pointer to ident_t type.
340 llvm::Type *getIdentTyPointerTy();
341
342 /// Gets thread id value for the current thread.
343 ///
344 llvm::Value *getThreadID(CodeGenFunction &CGF, SourceLocation Loc);
345
346 /// Get the function name of an outlined region.
347 std::string getOutlinedHelperName(StringRef Name) const;
348 std::string getOutlinedHelperName(CodeGenFunction &CGF) const;
349
350 /// Get the function name of a reduction function.
351 std::string getReductionFuncName(StringRef Name) const;
352
353 /// Emits \p Callee function call with arguments \p Args with location \p Loc.
355 llvm::FunctionCallee Callee,
356 ArrayRef<llvm::Value *> Args = {}) const;
357
358 /// Emits address of the word in a memory where current thread id is
359 /// stored.
361
363 bool AtCurrentPoint = false);
365
366 /// Check if the default location must be constant.
367 /// Default is false to support OMPT/OMPD.
368 virtual bool isDefaultLocationConstant() const { return false; }
369
370 /// Returns additional flags that can be stored in reserved_2 field of the
371 /// default location.
372 virtual unsigned getDefaultLocationReserved2Flags() const { return 0; }
373
374 /// Returns default flags for the barriers depending on the directive, for
375 /// which this barier is going to be emitted.
377
378 /// Get the LLVM type for the critical name.
379 llvm::ArrayType *getKmpCriticalNameTy() const {return KmpCriticalNameTy;}
380
381 /// Returns corresponding lock object for the specified critical region
382 /// name. If the lock object does not exist it is created, otherwise the
383 /// reference to the existing copy is returned.
384 /// \param CriticalName Name of the critical region.
385 ///
386 llvm::Value *getCriticalRegionLock(StringRef CriticalName);
387
388protected:
389 /// Map for SourceLocation and OpenMP runtime library debug locations.
390 typedef llvm::DenseMap<SourceLocation, llvm::Value *> OpenMPDebugLocMapTy;
392 /// The type for a microtask which gets passed to __kmpc_fork_call().
393 /// Original representation is:
394 /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...);
395 llvm::FunctionType *Kmpc_MicroTy = nullptr;
396 /// Stores debug location and ThreadID for the function.
398 llvm::Value *DebugLoc;
399 llvm::Value *ThreadID;
400 /// Insert point for the service instructions.
401 llvm::AssertingVH<llvm::Instruction> ServiceInsertPt = nullptr;
402 };
403 /// Map of local debug location, ThreadId and functions.
404 typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy>
407 /// Map of UDRs and corresponding combiner/initializer.
408 typedef llvm::DenseMap<const OMPDeclareReductionDecl *,
409 std::pair<llvm::Function *, llvm::Function *>>
412 /// Map of functions and locally defined UDRs.
413 typedef llvm::DenseMap<llvm::Function *,
417 /// Map from the user-defined mapper declaration to its corresponding
418 /// functions.
419 llvm::DenseMap<const OMPDeclareMapperDecl *, llvm::Function *> UDMMap;
420 /// Map of functions and their local user-defined mappers.
422 llvm::DenseMap<llvm::Function *,
425 /// Maps local variables marked as lastprivate conditional to their internal
426 /// types.
427 llvm::DenseMap<llvm::Function *,
428 llvm::DenseMap<CanonicalDeclPtr<const Decl>,
429 std::tuple<QualType, const FieldDecl *,
430 const FieldDecl *, LValue>>>
432 /// Maps function to the position of the untied task locals stack.
433 llvm::DenseMap<llvm::Function *, unsigned> FunctionToUntiedTaskStackMap;
434 /// Type kmp_critical_name, originally defined as typedef kmp_int32
435 /// kmp_critical_name[8];
436 llvm::ArrayType *KmpCriticalNameTy;
437 /// An ordered map of auto-generated variables to their unique names.
438 /// It stores variables with the following names: 1) ".gomp_critical_user_" +
439 /// <critical_section_name> + ".var" for "omp critical" directives; 2)
440 /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
441 /// variables.
442 llvm::StringMap<llvm::AssertingVH<llvm::GlobalVariable>,
443 llvm::BumpPtrAllocator> InternalVars;
444 /// Type typedef kmp_int32 (* kmp_routine_entry_t)(kmp_int32, void *);
445 llvm::Type *KmpRoutineEntryPtrTy = nullptr;
447 /// Type typedef struct kmp_task {
448 /// void * shareds; /**< pointer to block of pointers to
449 /// shared vars */
450 /// kmp_routine_entry_t routine; /**< pointer to routine to call for
451 /// executing task */
452 /// kmp_int32 part_id; /**< part id for the task */
453 /// kmp_routine_entry_t destructors; /* pointer to function to invoke
454 /// deconstructors of firstprivate C++ objects */
455 /// } kmp_task_t;
457 /// Saved kmp_task_t for task directive.
459 /// Saved kmp_task_t for taskloop-based directive.
461 /// Type typedef struct kmp_depend_info {
462 /// kmp_intptr_t base_addr;
463 /// size_t len;
464 /// struct {
465 /// bool in:1;
466 /// bool out:1;
467 /// } flags;
468 /// } kmp_depend_info_t;
470 /// Type typedef struct kmp_task_affinity_info {
471 /// kmp_intptr_t base_addr;
472 /// size_t len;
473 /// struct {
474 /// bool flag1 : 1;
475 /// bool flag2 : 1;
476 /// kmp_int32 reserved : 30;
477 /// } flags;
478 /// } kmp_task_affinity_info_t;
480 /// struct kmp_dim { // loop bounds info casted to kmp_int64
481 /// kmp_int64 lo; // lower
482 /// kmp_int64 up; // upper
483 /// kmp_int64 st; // stride
484 /// };
486
488 /// List of the emitted declarations.
489 llvm::DenseSet<CanonicalDeclPtr<const Decl>> AlreadyEmittedTargetDecls;
490 /// List of the global variables with their addresses that should not be
491 /// emitted for the target.
492 llvm::StringMap<llvm::WeakTrackingVH> EmittedNonTargetVariables;
493
494 /// List of variables that can become declare target implicitly and, thus,
495 /// must be emitted.
496 llvm::SmallDenseSet<const VarDecl *> DeferredGlobalVariables;
497
498 using NontemporalDeclsSet = llvm::SmallDenseSet<CanonicalDeclPtr<const Decl>>;
499 /// Stack for list of declarations in current context marked as nontemporal.
500 /// The set is the union of all current stack elements.
502
504 llvm::MapVector<CanonicalDeclPtr<const VarDecl>,
505 std::pair<Address, Address>>;
507
508 /// Stack for list of addresses of declarations in current context marked as
509 /// lastprivate conditional. The set is the union of all current stack
510 /// elements.
512
513 /// Flag for keeping track of weather a requires unified_shared_memory
514 /// directive is present.
516
517 /// Atomic ordering from the omp requires directive.
518 llvm::AtomicOrdering RequiresAtomicOrdering = llvm::AtomicOrdering::Monotonic;
519
520 /// Flag for keeping track of weather a target region has been emitted.
522
523 /// Flag for keeping track of weather a device routine has been emitted.
524 /// Device routines are specific to the
526
527 /// Start scanning from statement \a S and emit all target regions
528 /// found along the way.
529 /// \param S Starting statement.
530 /// \param ParentName Name of the function declaration that is being scanned.
531 void scanForTargetRegionsFunctions(const Stmt *S, StringRef ParentName);
532
533 /// Build type kmp_routine_entry_t (if not built yet).
534 void emitKmpRoutineEntryT(QualType KmpInt32Ty);
535
536 /// Returns pointer to kmpc_micro type.
537 llvm::Type *getKmpc_MicroPointerTy();
538
539 /// If the specified mangled name is not in the module, create and
540 /// return threadprivate cache object. This object is a pointer's worth of
541 /// storage that's reserved for use by the OpenMP runtime.
542 /// \param VD Threadprivate variable.
543 /// \return Cache variable for the specified threadprivate.
544 llvm::Constant *getOrCreateThreadPrivateCache(const VarDecl *VD);
545
546 /// Set of threadprivate variables with the generated initializer.
548
549 /// Set of declare target variables with the generated initializer.
551
552 /// Emits initialization code for the threadprivate variables.
553 /// \param VDAddr Address of the global variable \a VD.
554 /// \param Ctor Pointer to a global init function for \a VD.
555 /// \param CopyCtor Pointer to a global copy function for \a VD.
556 /// \param Dtor Pointer to a global destructor function for \a VD.
557 /// \param Loc Location of threadprivate declaration.
559 llvm::Value *Ctor, llvm::Value *CopyCtor,
560 llvm::Value *Dtor, SourceLocation Loc);
561
563 llvm::Value *NewTask = nullptr;
564 llvm::Function *TaskEntry = nullptr;
565 llvm::Value *NewTaskNewTaskTTy = nullptr;
567 const RecordDecl *KmpTaskTQTyRD = nullptr;
568 llvm::Value *TaskDupFn = nullptr;
569 };
570 /// Emit task region for the task directive. The task region is emitted in
571 /// several steps:
572 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
573 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
574 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
575 /// function:
576 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
577 /// TaskFunction(gtid, tt->part_id, tt->shareds);
578 /// return 0;
579 /// }
580 /// 2. Copy a list of shared variables to field shareds of the resulting
581 /// structure kmp_task_t returned by the previous call (if any).
582 /// 3. Copy a pointer to destructions function to field destructions of the
583 /// resulting structure kmp_task_t.
584 /// \param D Current task directive.
585 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
586 /// /*part_id*/, captured_struct */*__context*/);
587 /// \param SharedsTy A type which contains references the shared variables.
588 /// \param Shareds Context with the list of shared variables from the \p
589 /// TaskFunction.
590 /// \param Data Additional data for task generation like tiednsee, final
591 /// state, list of privates etc.
594 llvm::Function *TaskFunction, QualType SharedsTy,
595 Address Shareds, const OMPTaskDataTy &Data);
596
597 /// Emit update for lastprivate conditional data.
599 StringRef UniqueDeclName, LValue LVal,
601
602 /// Returns the number of the elements and the address of the depobj
603 /// dependency array.
604 /// \return Number of elements in depobj array and the pointer to the array of
605 /// dependencies.
606 std::pair<llvm::Value *, LValue> getDepobjElements(CodeGenFunction &CGF,
607 LValue DepobjLVal,
609
613
615 LValue PosLVal, const OMPTaskDataTy::DependData &Data,
616 Address DependenciesArray);
617
618public:
620 virtual ~CGOpenMPRuntime() {}
621 virtual void clear();
622
623 /// Emits object of ident_t type with info for source location.
624 /// \param Flags Flags for OpenMP location.
625 /// \param EmitLoc emit source location with debug-info is off.
626 ///
628 unsigned Flags = 0, bool EmitLoc = false);
629
630 /// Emit the number of teams for a target directive. Inspect the num_teams
631 /// clause associated with a teams construct combined or closely nested
632 /// with the target directive.
633 ///
634 /// Emit a team of size one for directives such as 'target parallel' that
635 /// have no associated teams construct.
636 ///
637 /// Otherwise, return nullptr.
640 int32_t &MinTeamsVal,
641 int32_t &MaxTeamsVal);
644
645 /// Check for a number of threads upper bound constant value (stored in \p
646 /// UpperBound), or expression (returned). If the value is conditional (via an
647 /// if-clause), store the condition in \p CondExpr. Similarly, a potential
648 /// thread limit expression is stored in \p ThreadLimitExpr. If \p
649 /// UpperBoundOnly is true, no expression evaluation is perfomed.
652 int32_t &UpperBound, bool UpperBoundOnly,
653 llvm::Value **CondExpr = nullptr, const Expr **ThreadLimitExpr = nullptr);
654
655 /// Emit an expression that denotes the number of threads a target region
656 /// shall use. Will generate "i32 0" to allow the runtime to choose.
657 llvm::Value *
660
661 /// Return the trip count of loops associated with constructs / 'target teams
662 /// distribute' and 'teams distribute parallel for'. \param SizeEmitter Emits
663 /// the int64 value for the number of iterations of the associated loop.
664 llvm::Value *emitTargetNumIterationsCall(
666 llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
667 const OMPLoopDirective &D)>
668 SizeEmitter);
669
670 /// Returns true if the current target is a GPU.
671 virtual bool isGPU() const { return false; }
672
673 /// Check if the variable length declaration is delayed:
675 const VarDecl *VD) const {
676 return false;
677 };
678
679 /// Get call to __kmpc_alloc_shared
680 virtual std::pair<llvm::Value *, llvm::Value *>
682 llvm_unreachable("not implemented");
683 }
684
685 /// Get call to __kmpc_free_shared
686 virtual void getKmpcFreeShared(
687 CodeGenFunction &CGF,
688 const std::pair<llvm::Value *, llvm::Value *> &AddrSizePair) {
689 llvm_unreachable("not implemented");
690 }
691
692 /// Emits code for OpenMP 'if' clause using specified \a CodeGen
693 /// function. Here is the logic:
694 /// if (Cond) {
695 /// ThenGen();
696 /// } else {
697 /// ElseGen();
698 /// }
699 void emitIfClause(CodeGenFunction &CGF, const Expr *Cond,
700 const RegionCodeGenTy &ThenGen,
701 const RegionCodeGenTy &ElseGen);
702
703 /// Checks if the \p Body is the \a CompoundStmt and returns its child
704 /// statement iff there is only one that is not evaluatable at the compile
705 /// time.
706 static const Stmt *getSingleCompoundChild(ASTContext &Ctx, const Stmt *Body);
707
708 /// Get the platform-specific name separator.
709 std::string getName(ArrayRef<StringRef> Parts) const;
710
711 /// Emit code for the specified user defined reduction construct.
714 /// Get combiner/initializer for the specified user-defined reduction, if any.
715 virtual std::pair<llvm::Function *, llvm::Function *>
717
718 /// Emit the function for the user defined mapper construct.
720 CodeGenFunction *CGF = nullptr);
721 /// Get the function for the specified user-defined mapper. If it does not
722 /// exist, create one.
723 llvm::Function *
725
726 /// Emits outlined function for the specified OpenMP parallel directive
727 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
728 /// kmp_int32 BoundID, struct context_vars*).
729 /// \param CGF Reference to current CodeGenFunction.
730 /// \param D OpenMP directive.
731 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
732 /// \param InnermostKind Kind of innermost directive (for simple directives it
733 /// is a directive itself, for combined - its innermost directive).
734 /// \param CodeGen Code generation sequence for the \a D directive.
735 virtual llvm::Function *emitParallelOutlinedFunction(
737 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
738 const RegionCodeGenTy &CodeGen);
739
740 /// Emits outlined function for the specified OpenMP teams directive
741 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
742 /// kmp_int32 BoundID, struct context_vars*).
743 /// \param CGF Reference to current CodeGenFunction.
744 /// \param D OpenMP directive.
745 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
746 /// \param InnermostKind Kind of innermost directive (for simple directives it
747 /// is a directive itself, for combined - its innermost directive).
748 /// \param CodeGen Code generation sequence for the \a D directive.
749 virtual llvm::Function *emitTeamsOutlinedFunction(
751 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
752 const RegionCodeGenTy &CodeGen);
753
754 /// Emits outlined function for the OpenMP task directive \a D. This
755 /// outlined function has type void(*)(kmp_int32 ThreadID, struct task_t*
756 /// TaskT).
757 /// \param D OpenMP directive.
758 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
759 /// \param PartIDVar Variable for partition id in the current OpenMP untied
760 /// task region.
761 /// \param TaskTVar Variable for task_t argument.
762 /// \param InnermostKind Kind of innermost directive (for simple directives it
763 /// is a directive itself, for combined - its innermost directive).
764 /// \param CodeGen Code generation sequence for the \a D directive.
765 /// \param Tied true if task is generated for tied task, false otherwise.
766 /// \param NumberOfParts Number of parts in untied task. Ignored for tied
767 /// tasks.
768 ///
769 virtual llvm::Function *emitTaskOutlinedFunction(
770 const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
771 const VarDecl *PartIDVar, const VarDecl *TaskTVar,
772 OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen,
773 bool Tied, unsigned &NumberOfParts);
774
775 /// Cleans up references to the objects in finished function.
776 ///
777 virtual void functionFinished(CodeGenFunction &CGF);
778
779 /// Emits code for parallel or serial call of the \a OutlinedFn with
780 /// variables captured in a record which address is stored in \a
781 /// CapturedStruct.
782 /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
783 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
784 /// \param CapturedVars A pointer to the record with the references to
785 /// variables used in \a OutlinedFn function.
786 /// \param IfCond Condition in the associated 'if' clause, if it was
787 /// specified, nullptr otherwise.
788 /// \param NumThreads The value corresponding to the num_threads clause, if
789 /// any, or nullptr.
790 ///
792 llvm::Function *OutlinedFn,
793 ArrayRef<llvm::Value *> CapturedVars,
794 const Expr *IfCond, llvm::Value *NumThreads);
795
796 /// Emits a critical region.
797 /// \param CriticalName Name of the critical region.
798 /// \param CriticalOpGen Generator for the statement associated with the given
799 /// critical region.
800 /// \param Hint Value of the 'hint' clause (optional).
801 virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
802 const RegionCodeGenTy &CriticalOpGen,
804 const Expr *Hint = nullptr);
805
806 /// Emits a master region.
807 /// \param MasterOpGen Generator for the statement associated with the given
808 /// master region.
809 virtual void emitMasterRegion(CodeGenFunction &CGF,
810 const RegionCodeGenTy &MasterOpGen,
812
813 /// Emits a masked region.
814 /// \param MaskedOpGen Generator for the statement associated with the given
815 /// masked region.
816 virtual void emitMaskedRegion(CodeGenFunction &CGF,
817 const RegionCodeGenTy &MaskedOpGen,
819 const Expr *Filter = nullptr);
820
821 /// Emits code for a taskyield directive.
823
824 /// Emit __kmpc_error call for error directive
825 /// extern void __kmpc_error(ident_t *loc, int severity, const char *message);
826 virtual void emitErrorCall(CodeGenFunction &CGF, SourceLocation Loc, Expr *ME,
827 bool IsFatal);
828
829 /// Emit a taskgroup region.
830 /// \param TaskgroupOpGen Generator for the statement associated with the
831 /// given taskgroup region.
832 virtual void emitTaskgroupRegion(CodeGenFunction &CGF,
833 const RegionCodeGenTy &TaskgroupOpGen,
835
836 /// Emits a single region.
837 /// \param SingleOpGen Generator for the statement associated with the given
838 /// single region.
839 virtual void emitSingleRegion(CodeGenFunction &CGF,
840 const RegionCodeGenTy &SingleOpGen,
842 ArrayRef<const Expr *> CopyprivateVars,
843 ArrayRef<const Expr *> DestExprs,
844 ArrayRef<const Expr *> SrcExprs,
845 ArrayRef<const Expr *> AssignmentOps);
846
847 /// Emit an ordered region.
848 /// \param OrderedOpGen Generator for the statement associated with the given
849 /// ordered region.
850 virtual void emitOrderedRegion(CodeGenFunction &CGF,
851 const RegionCodeGenTy &OrderedOpGen,
852 SourceLocation Loc, bool IsThreads);
853
854 /// Emit an implicit/explicit barrier for OpenMP threads.
855 /// \param Kind Directive for which this implicit barrier call must be
856 /// generated. Must be OMPD_barrier for explicit barrier generation.
857 /// \param EmitChecks true if need to emit checks for cancellation barriers.
858 /// \param ForceSimpleCall true simple barrier call must be emitted, false if
859 /// runtime class decides which one to emit (simple or with cancellation
860 /// checks).
861 ///
864 bool EmitChecks = true,
865 bool ForceSimpleCall = false);
866
867 /// Check if the specified \a ScheduleKind is static non-chunked.
868 /// This kind of worksharing directive is emitted without outer loop.
869 /// \param ScheduleKind Schedule kind specified in the 'schedule' clause.
870 /// \param Chunked True if chunk is specified in the clause.
871 ///
872 virtual bool isStaticNonchunked(OpenMPScheduleClauseKind ScheduleKind,
873 bool Chunked) const;
874
875 /// Check if the specified \a ScheduleKind is static non-chunked.
876 /// This kind of distribute directive is emitted without outer loop.
877 /// \param ScheduleKind Schedule kind specified in the 'dist_schedule' clause.
878 /// \param Chunked True if chunk is specified in the clause.
879 ///
880 virtual bool isStaticNonchunked(OpenMPDistScheduleClauseKind ScheduleKind,
881 bool Chunked) const;
882
883 /// Check if the specified \a ScheduleKind is static chunked.
884 /// \param ScheduleKind Schedule kind specified in the 'schedule' clause.
885 /// \param Chunked True if chunk is specified in the clause.
886 ///
887 virtual bool isStaticChunked(OpenMPScheduleClauseKind ScheduleKind,
888 bool Chunked) const;
889
890 /// Check if the specified \a ScheduleKind is static non-chunked.
891 /// \param ScheduleKind Schedule kind specified in the 'dist_schedule' clause.
892 /// \param Chunked True if chunk is specified in the clause.
893 ///
894 virtual bool isStaticChunked(OpenMPDistScheduleClauseKind ScheduleKind,
895 bool Chunked) const;
896
897 /// Check if the specified \a ScheduleKind is dynamic.
898 /// This kind of worksharing directive is emitted without outer loop.
899 /// \param ScheduleKind Schedule Kind specified in the 'schedule' clause.
900 ///
901 virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const;
902
903 /// struct with the values to be passed to the dispatch runtime function
905 /// Loop lower bound
906 llvm::Value *LB = nullptr;
907 /// Loop upper bound
908 llvm::Value *UB = nullptr;
909 /// Chunk size specified using 'schedule' clause (nullptr if chunk
910 /// was not specified)
911 llvm::Value *Chunk = nullptr;
912 DispatchRTInput() = default;
913 DispatchRTInput(llvm::Value *LB, llvm::Value *UB, llvm::Value *Chunk)
914 : LB(LB), UB(UB), Chunk(Chunk) {}
915 };
916
917 /// Call the appropriate runtime routine to initialize it before start
918 /// of loop.
919
920 /// This is used for non static scheduled types and when the ordered
921 /// clause is present on the loop construct.
922 /// Depending on the loop schedule, it is necessary to call some runtime
923 /// routine before start of the OpenMP loop to get the loop upper / lower
924 /// bounds \a LB and \a UB and stride \a ST.
925 ///
926 /// \param CGF Reference to current CodeGenFunction.
927 /// \param Loc Clang source location.
928 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
929 /// \param IVSize Size of the iteration variable in bits.
930 /// \param IVSigned Sign of the iteration variable.
931 /// \param Ordered true if loop is ordered, false otherwise.
932 /// \param DispatchValues struct containing llvm values for lower bound, upper
933 /// bound, and chunk expression.
934 /// For the default (nullptr) value, the chunk 1 will be used.
935 ///
937 const OpenMPScheduleTy &ScheduleKind,
938 unsigned IVSize, bool IVSigned, bool Ordered,
939 const DispatchRTInput &DispatchValues);
940
941 /// This is used for non static scheduled types and when the ordered
942 /// clause is present on the loop construct.
943 ///
944 /// \param CGF Reference to current CodeGenFunction.
945 /// \param Loc Clang source location.
946 ///
948
949 /// Struct with the values to be passed to the static runtime function
951 /// Size of the iteration variable in bits.
952 unsigned IVSize = 0;
953 /// Sign of the iteration variable.
954 bool IVSigned = false;
955 /// true if loop is ordered, false otherwise.
956 bool Ordered = false;
957 /// Address of the output variable in which the flag of the last iteration
958 /// is returned.
960 /// Address of the output variable in which the lower iteration number is
961 /// returned.
963 /// Address of the output variable in which the upper iteration number is
964 /// returned.
966 /// Address of the output variable in which the stride value is returned
967 /// necessary to generated the static_chunked scheduled loop.
969 /// Value of the chunk for the static_chunked scheduled loop. For the
970 /// default (nullptr) value, the chunk 1 will be used.
971 llvm::Value *Chunk = nullptr;
974 llvm::Value *Chunk = nullptr)
976 UB(UB), ST(ST), Chunk(Chunk) {}
977 };
978 /// Call the appropriate runtime routine to initialize it before start
979 /// of loop.
980 ///
981 /// This is used only in case of static schedule, when the user did not
982 /// specify a ordered clause on the loop construct.
983 /// Depending on the loop schedule, it is necessary to call some runtime
984 /// routine before start of the OpenMP loop to get the loop upper / lower
985 /// bounds LB and UB and stride ST.
986 ///
987 /// \param CGF Reference to current CodeGenFunction.
988 /// \param Loc Clang source location.
989 /// \param DKind Kind of the directive.
990 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
991 /// \param Values Input arguments for the construct.
992 ///
995 const OpenMPScheduleTy &ScheduleKind,
996 const StaticRTInput &Values);
997
998 ///
999 /// \param CGF Reference to current CodeGenFunction.
1000 /// \param Loc Clang source location.
1001 /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
1002 /// \param Values Input arguments for the construct.
1003 ///
1004 virtual void emitDistributeStaticInit(CodeGenFunction &CGF,
1007 const StaticRTInput &Values);
1008
1009 /// Call the appropriate runtime routine to notify that we finished
1010 /// iteration of the ordered loop with the dynamic scheduling.
1011 ///
1012 /// \param CGF Reference to current CodeGenFunction.
1013 /// \param Loc Clang source location.
1014 /// \param IVSize Size of the iteration variable in bits.
1015 /// \param IVSigned Sign of the iteration variable.
1016 ///
1018 SourceLocation Loc, unsigned IVSize,
1019 bool IVSigned);
1020
1021 /// Call the appropriate runtime routine to notify that we finished
1022 /// all the work with current loop.
1023 ///
1024 /// \param CGF Reference to current CodeGenFunction.
1025 /// \param Loc Clang source location.
1026 /// \param DKind Kind of the directive for which the static finish is emitted.
1027 ///
1029 OpenMPDirectiveKind DKind);
1030
1031 /// Call __kmpc_dispatch_next(
1032 /// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter,
1033 /// kmp_int[32|64] *p_lower, kmp_int[32|64] *p_upper,
1034 /// kmp_int[32|64] *p_stride);
1035 /// \param IVSize Size of the iteration variable in bits.
1036 /// \param IVSigned Sign of the iteration variable.
1037 /// \param IL Address of the output variable in which the flag of the
1038 /// last iteration is returned.
1039 /// \param LB Address of the output variable in which the lower iteration
1040 /// number is returned.
1041 /// \param UB Address of the output variable in which the upper iteration
1042 /// number is returned.
1043 /// \param ST Address of the output variable in which the stride value is
1044 /// returned.
1045 virtual llvm::Value *emitForNext(CodeGenFunction &CGF, SourceLocation Loc,
1046 unsigned IVSize, bool IVSigned,
1047 Address IL, Address LB,
1048 Address UB, Address ST);
1049
1050 /// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
1051 /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
1052 /// clause.
1053 /// \param NumThreads An integer value of threads.
1054 virtual void emitNumThreadsClause(CodeGenFunction &CGF,
1055 llvm::Value *NumThreads,
1057
1058 /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
1059 /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
1060 virtual void emitProcBindClause(CodeGenFunction &CGF,
1061 llvm::omp::ProcBindKind ProcBind,
1063
1064 /// Returns address of the threadprivate variable for the current
1065 /// thread.
1066 /// \param VD Threadprivate variable.
1067 /// \param VDAddr Address of the global variable \a VD.
1068 /// \param Loc Location of the reference to threadprivate var.
1069 /// \return Address of the threadprivate variable for the current thread.
1071 const VarDecl *VD, Address VDAddr,
1073
1074 /// Returns the address of the variable marked as declare target with link
1075 /// clause OR as declare target with to clause and unified memory.
1077
1078 /// Emit a code for initialization of threadprivate variable. It emits
1079 /// a call to runtime library which adds initial value to the newly created
1080 /// threadprivate variable (if it is not constant) and registers destructor
1081 /// for the variable (if any).
1082 /// \param VD Threadprivate variable.
1083 /// \param VDAddr Address of the global variable \a VD.
1084 /// \param Loc Location of threadprivate declaration.
1085 /// \param PerformInit true if initialization expression is not constant.
1086 virtual llvm::Function *
1088 SourceLocation Loc, bool PerformInit,
1089 CodeGenFunction *CGF = nullptr);
1090
1091 /// Emit code for handling declare target functions in the runtime.
1092 /// \param FD Declare target function.
1093 /// \param Addr Address of the global \a FD.
1094 /// \param PerformInit true if initialization expression is not constant.
1095 virtual void emitDeclareTargetFunction(const FunctionDecl *FD,
1096 llvm::GlobalValue *GV);
1097
1098 /// Creates artificial threadprivate variable with name \p Name and type \p
1099 /// VarType.
1100 /// \param VarType Type of the artificial threadprivate variable.
1101 /// \param Name Name of the artificial threadprivate variable.
1103 QualType VarType,
1104 StringRef Name);
1105
1106 /// Emit flush of the variables specified in 'omp flush' directive.
1107 /// \param Vars List of variables to flush.
1108 virtual void emitFlush(CodeGenFunction &CGF, ArrayRef<const Expr *> Vars,
1109 SourceLocation Loc, llvm::AtomicOrdering AO);
1110
1111 /// Emit task region for the task directive. The task region is
1112 /// emitted in several steps:
1113 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1114 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1115 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1116 /// function:
1117 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1118 /// TaskFunction(gtid, tt->part_id, tt->shareds);
1119 /// return 0;
1120 /// }
1121 /// 2. Copy a list of shared variables to field shareds of the resulting
1122 /// structure kmp_task_t returned by the previous call (if any).
1123 /// 3. Copy a pointer to destructions function to field destructions of the
1124 /// resulting structure kmp_task_t.
1125 /// 4. Emit a call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid,
1126 /// kmp_task_t *new_task), where new_task is a resulting structure from
1127 /// previous items.
1128 /// \param D Current task directive.
1129 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
1130 /// /*part_id*/, captured_struct */*__context*/);
1131 /// \param SharedsTy A type which contains references the shared variables.
1132 /// \param Shareds Context with the list of shared variables from the \p
1133 /// TaskFunction.
1134 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
1135 /// otherwise.
1136 /// \param Data Additional data for task generation like tiednsee, final
1137 /// state, list of privates etc.
1140 llvm::Function *TaskFunction, QualType SharedsTy,
1141 Address Shareds, const Expr *IfCond,
1142 const OMPTaskDataTy &Data);
1143
1144 /// Emit task region for the taskloop directive. The taskloop region is
1145 /// emitted in several steps:
1146 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1147 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1148 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1149 /// function:
1150 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1151 /// TaskFunction(gtid, tt->part_id, tt->shareds);
1152 /// return 0;
1153 /// }
1154 /// 2. Copy a list of shared variables to field shareds of the resulting
1155 /// structure kmp_task_t returned by the previous call (if any).
1156 /// 3. Copy a pointer to destructions function to field destructions of the
1157 /// resulting structure kmp_task_t.
1158 /// 4. Emit a call to void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t
1159 /// *task, int if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int
1160 /// nogroup, int sched, kmp_uint64 grainsize, void *task_dup ), where new_task
1161 /// is a resulting structure from
1162 /// previous items.
1163 /// \param D Current task directive.
1164 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
1165 /// /*part_id*/, captured_struct */*__context*/);
1166 /// \param SharedsTy A type which contains references the shared variables.
1167 /// \param Shareds Context with the list of shared variables from the \p
1168 /// TaskFunction.
1169 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
1170 /// otherwise.
1171 /// \param Data Additional data for task generation like tiednsee, final
1172 /// state, list of privates etc.
1174 const OMPLoopDirective &D,
1175 llvm::Function *TaskFunction,
1176 QualType SharedsTy, Address Shareds,
1177 const Expr *IfCond, const OMPTaskDataTy &Data);
1178
1179 /// Emit code for the directive that does not require outlining.
1180 ///
1181 /// \param InnermostKind Kind of innermost directive (for simple directives it
1182 /// is a directive itself, for combined - its innermost directive).
1183 /// \param CodeGen Code generation sequence for the \a D directive.
1184 /// \param HasCancel true if region has inner cancel directive, false
1185 /// otherwise.
1186 virtual void emitInlinedDirective(CodeGenFunction &CGF,
1187 OpenMPDirectiveKind InnermostKind,
1188 const RegionCodeGenTy &CodeGen,
1189 bool HasCancel = false);
1190
1191 /// Emits reduction function.
1192 /// \param ReducerName Name of the function calling the reduction.
1193 /// \param ArgsElemType Array type containing pointers to reduction variables.
1194 /// \param Privates List of private copies for original reduction arguments.
1195 /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
1196 /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
1197 /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
1198 /// or 'operator binop(LHS, RHS)'.
1199 llvm::Function *emitReductionFunction(
1200 StringRef ReducerName, SourceLocation Loc, llvm::Type *ArgsElemType,
1202 ArrayRef<const Expr *> RHSExprs, ArrayRef<const Expr *> ReductionOps);
1203
1204 /// Emits single reduction combiner
1206 const Expr *ReductionOp,
1207 const Expr *PrivateRef,
1208 const DeclRefExpr *LHS,
1209 const DeclRefExpr *RHS);
1210
1215 };
1216 /// Emit a code for reduction clause. Next code should be emitted for
1217 /// reduction:
1218 /// \code
1219 ///
1220 /// static kmp_critical_name lock = { 0 };
1221 ///
1222 /// void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
1223 /// ...
1224 /// *(Type<i>*)lhs[i] = RedOp<i>(*(Type<i>*)lhs[i], *(Type<i>*)rhs[i]);
1225 /// ...
1226 /// }
1227 ///
1228 /// ...
1229 /// void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
1230 /// switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList),
1231 /// RedList, reduce_func, &<lock>)) {
1232 /// case 1:
1233 /// ...
1234 /// <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]);
1235 /// ...
1236 /// __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
1237 /// break;
1238 /// case 2:
1239 /// ...
1240 /// Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]));
1241 /// ...
1242 /// break;
1243 /// default:;
1244 /// }
1245 /// \endcode
1246 ///
1247 /// \param Privates List of private copies for original reduction arguments.
1248 /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
1249 /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
1250 /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
1251 /// or 'operator binop(LHS, RHS)'.
1252 /// \param Options List of options for reduction codegen:
1253 /// WithNowait true if parent directive has also nowait clause, false
1254 /// otherwise.
1255 /// SimpleReduction Emit reduction operation only. Used for omp simd
1256 /// directive on the host.
1257 /// ReductionKind The kind of reduction to perform.
1259 ArrayRef<const Expr *> Privates,
1260 ArrayRef<const Expr *> LHSExprs,
1261 ArrayRef<const Expr *> RHSExprs,
1262 ArrayRef<const Expr *> ReductionOps,
1263 ReductionOptionsTy Options);
1264
1265 /// Emit a code for initialization of task reduction clause. Next code
1266 /// should be emitted for reduction:
1267 /// \code
1268 ///
1269 /// _taskred_item_t red_data[n];
1270 /// ...
1271 /// red_data[i].shar = &shareds[i];
1272 /// red_data[i].orig = &origs[i];
1273 /// red_data[i].size = sizeof(origs[i]);
1274 /// red_data[i].f_init = (void*)RedInit<i>;
1275 /// red_data[i].f_fini = (void*)RedDest<i>;
1276 /// red_data[i].f_comb = (void*)RedOp<i>;
1277 /// red_data[i].flags = <Flag_i>;
1278 /// ...
1279 /// void* tg1 = __kmpc_taskred_init(gtid, n, red_data);
1280 /// \endcode
1281 /// For reduction clause with task modifier it emits the next call:
1282 /// \code
1283 ///
1284 /// _taskred_item_t red_data[n];
1285 /// ...
1286 /// red_data[i].shar = &shareds[i];
1287 /// red_data[i].orig = &origs[i];
1288 /// red_data[i].size = sizeof(origs[i]);
1289 /// red_data[i].f_init = (void*)RedInit<i>;
1290 /// red_data[i].f_fini = (void*)RedDest<i>;
1291 /// red_data[i].f_comb = (void*)RedOp<i>;
1292 /// red_data[i].flags = <Flag_i>;
1293 /// ...
1294 /// void* tg1 = __kmpc_taskred_modifier_init(loc, gtid, is_worksharing, n,
1295 /// red_data);
1296 /// \endcode
1297 /// \param LHSExprs List of LHS in \a Data.ReductionOps reduction operations.
1298 /// \param RHSExprs List of RHS in \a Data.ReductionOps reduction operations.
1299 /// \param Data Additional data for task generation like tiedness, final
1300 /// state, list of privates, reductions etc.
1301 virtual llvm::Value *emitTaskReductionInit(CodeGenFunction &CGF,
1303 ArrayRef<const Expr *> LHSExprs,
1304 ArrayRef<const Expr *> RHSExprs,
1305 const OMPTaskDataTy &Data);
1306
1307 /// Emits the following code for reduction clause with task modifier:
1308 /// \code
1309 /// __kmpc_task_reduction_modifier_fini(loc, gtid, is_worksharing);
1310 /// \endcode
1312 bool IsWorksharingReduction);
1313
1314 /// Required to resolve existing problems in the runtime. Emits threadprivate
1315 /// variables to store the size of the VLAs/array sections for
1316 /// initializer/combiner/finalizer functions.
1317 /// \param RCG Allows to reuse an existing data for the reductions.
1318 /// \param N Reduction item for which fixups must be emitted.
1320 ReductionCodeGen &RCG, unsigned N);
1321
1322 /// Get the address of `void *` type of the privatue copy of the reduction
1323 /// item specified by the \p SharedLVal.
1324 /// \param ReductionsPtr Pointer to the reduction data returned by the
1325 /// emitTaskReductionInit function.
1326 /// \param SharedLVal Address of the original reduction item.
1328 llvm::Value *ReductionsPtr,
1329 LValue SharedLVal);
1330
1331 /// Emit code for 'taskwait' directive.
1333 const OMPTaskDataTy &Data);
1334
1335 /// Emit code for 'cancellation point' construct.
1336 /// \param CancelRegion Region kind for which the cancellation point must be
1337 /// emitted.
1338 ///
1341 OpenMPDirectiveKind CancelRegion);
1342
1343 /// Emit code for 'cancel' construct.
1344 /// \param IfCond Condition in the associated 'if' clause, if it was
1345 /// specified, nullptr otherwise.
1346 /// \param CancelRegion Region kind for which the cancel must be emitted.
1347 ///
1349 const Expr *IfCond,
1350 OpenMPDirectiveKind CancelRegion);
1351
1352 /// Emit outilined function for 'target' directive.
1353 /// \param D Directive to emit.
1354 /// \param ParentName Name of the function that encloses the target region.
1355 /// \param OutlinedFn Outlined function value to be defined by this call.
1356 /// \param OutlinedFnID Outlined function ID value to be defined by this call.
1357 /// \param IsOffloadEntry True if the outlined function is an offload entry.
1358 /// \param CodeGen Code generation sequence for the \a D directive.
1359 /// An outlined function may not be an entry if, e.g. the if clause always
1360 /// evaluates to false.
1362 StringRef ParentName,
1363 llvm::Function *&OutlinedFn,
1364 llvm::Constant *&OutlinedFnID,
1365 bool IsOffloadEntry,
1366 const RegionCodeGenTy &CodeGen);
1367
1368 /// Emit the target offloading code associated with \a D. The emitted
1369 /// code attempts offloading the execution to the device, an the event of
1370 /// a failure it executes the host version outlined in \a OutlinedFn.
1371 /// \param D Directive to emit.
1372 /// \param OutlinedFn Host version of the code to be offloaded.
1373 /// \param OutlinedFnID ID of host version of the code to be offloaded.
1374 /// \param IfCond Expression evaluated in if clause associated with the target
1375 /// directive, or null if no if clause is used.
1376 /// \param Device Expression evaluated in device clause associated with the
1377 /// target directive, or null if no device clause is used and device modifier.
1378 /// \param SizeEmitter Callback to emit number of iterations for loop-based
1379 /// directives.
1380 virtual void emitTargetCall(
1382 llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond,
1383 llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
1384 llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
1385 const OMPLoopDirective &D)>
1386 SizeEmitter);
1387
1388 /// Emit the target regions enclosed in \a GD function definition or
1389 /// the function itself in case it is a valid device function. Returns true if
1390 /// \a GD was dealt with successfully.
1391 /// \param GD Function to scan.
1392 virtual bool emitTargetFunctions(GlobalDecl GD);
1393
1394 /// Emit the global variable if it is a valid device global variable.
1395 /// Returns true if \a GD was dealt with successfully.
1396 /// \param GD Variable declaration to emit.
1397 virtual bool emitTargetGlobalVariable(GlobalDecl GD);
1398
1399 /// Checks if the provided global decl \a GD is a declare target variable and
1400 /// registers it when emitting code for the host.
1401 virtual void registerTargetGlobalVariable(const VarDecl *VD,
1402 llvm::Constant *Addr);
1403
1404 /// Emit the global \a GD if it is meaningful for the target. Returns
1405 /// if it was emitted successfully.
1406 /// \param GD Global to scan.
1407 virtual bool emitTargetGlobal(GlobalDecl GD);
1408
1409 /// Creates all the offload entries in the current compilation unit
1410 /// along with the associated metadata.
1412
1413 /// Emits code for teams call of the \a OutlinedFn with
1414 /// variables captured in a record which address is stored in \a
1415 /// CapturedStruct.
1416 /// \param OutlinedFn Outlined function to be run by team masters. Type of
1417 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
1418 /// \param CapturedVars A pointer to the record with the references to
1419 /// variables used in \a OutlinedFn function.
1420 ///
1421 virtual void emitTeamsCall(CodeGenFunction &CGF,
1423 SourceLocation Loc, llvm::Function *OutlinedFn,
1424 ArrayRef<llvm::Value *> CapturedVars);
1425
1426 /// Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32
1427 /// global_tid, kmp_int32 num_teams, kmp_int32 thread_limit) to generate code
1428 /// for num_teams clause.
1429 /// \param NumTeams An integer expression of teams.
1430 /// \param ThreadLimit An integer expression of threads.
1431 virtual void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams,
1432 const Expr *ThreadLimit, SourceLocation Loc);
1433
1434 /// Emits call to void __kmpc_set_thread_limit(ident_t *loc, kmp_int32
1435 /// global_tid, kmp_int32 thread_limit) to generate code for
1436 /// thread_limit clause on target directive
1437 /// \param ThreadLimit An integer expression of threads.
1438 virtual void emitThreadLimitClause(CodeGenFunction &CGF,
1439 const Expr *ThreadLimit,
1441
1442 /// Struct that keeps all the relevant information that should be kept
1443 /// throughout a 'target data' region.
1445 public:
1446 explicit TargetDataInfo() : llvm::OpenMPIRBuilder::TargetDataInfo() {}
1447 explicit TargetDataInfo(bool RequiresDevicePointerInfo,
1448 bool SeparateBeginEndCalls)
1449 : llvm::OpenMPIRBuilder::TargetDataInfo(RequiresDevicePointerInfo,
1450 SeparateBeginEndCalls) {}
1451 /// Map between the a declaration of a capture and the corresponding new
1452 /// llvm address where the runtime returns the device pointers.
1453 llvm::DenseMap<const ValueDecl *, llvm::Value *> CaptureDeviceAddrMap;
1454 };
1455
1456 /// Emit the target data mapping code associated with \a D.
1457 /// \param D Directive to emit.
1458 /// \param IfCond Expression evaluated in if clause associated with the
1459 /// target directive, or null if no device clause is used.
1460 /// \param Device Expression evaluated in device clause associated with the
1461 /// target directive, or null if no device clause is used.
1462 /// \param Info A record used to store information that needs to be preserved
1463 /// until the region is closed.
1464 virtual void emitTargetDataCalls(CodeGenFunction &CGF,
1466 const Expr *IfCond, const Expr *Device,
1467 const RegionCodeGenTy &CodeGen,
1469
1470 /// Emit the data mapping/movement code associated with the directive
1471 /// \a D that should be of the form 'target [{enter|exit} data | update]'.
1472 /// \param D Directive to emit.
1473 /// \param IfCond Expression evaluated in if clause associated with the target
1474 /// directive, or null if no if clause is used.
1475 /// \param Device Expression evaluated in device clause associated with the
1476 /// target directive, or null if no device clause is used.
1479 const Expr *IfCond,
1480 const Expr *Device);
1481
1482 /// Marks function \a Fn with properly mangled versions of vector functions.
1483 /// \param FD Function marked as 'declare simd'.
1484 /// \param Fn LLVM function that must be marked with 'declare simd'
1485 /// attributes.
1486 virtual void emitDeclareSimdFunction(const FunctionDecl *FD,
1487 llvm::Function *Fn);
1488
1489 /// Emit initialization for doacross loop nesting support.
1490 /// \param D Loop-based construct used in doacross nesting construct.
1491 virtual void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D,
1492 ArrayRef<Expr *> NumIterations);
1493
1494 /// Emit code for doacross ordered directive with 'depend' clause.
1495 /// \param C 'depend' clause with 'sink|source' dependency kind.
1496 virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
1497 const OMPDependClause *C);
1498
1499 /// Emit code for doacross ordered directive with 'doacross' clause.
1500 /// \param C 'doacross' clause with 'sink|source' dependence type.
1501 virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
1502 const OMPDoacrossClause *C);
1503
1504 /// Translates the native parameter of outlined function if this is required
1505 /// for target.
1506 /// \param FD Field decl from captured record for the parameter.
1507 /// \param NativeParam Parameter itself.
1508 virtual const VarDecl *translateParameter(const FieldDecl *FD,
1509 const VarDecl *NativeParam) const {
1510 return NativeParam;
1511 }
1512
1513 /// Gets the address of the native argument basing on the address of the
1514 /// target-specific parameter.
1515 /// \param NativeParam Parameter itself.
1516 /// \param TargetParam Corresponding target-specific parameter.
1518 const VarDecl *NativeParam,
1519 const VarDecl *TargetParam) const;
1520
1521 /// Choose default schedule type and chunk value for the
1522 /// dist_schedule clause.
1524 const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind,
1525 llvm::Value *&Chunk) const {}
1526
1527 /// Choose default schedule type and chunk value for the
1528 /// schedule clause.
1530 const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind,
1531 const Expr *&ChunkExpr) const;
1532
1533 /// Emits call of the outlined function with the provided arguments,
1534 /// translating these arguments to correct target-specific arguments.
1535 virtual void
1537 llvm::FunctionCallee OutlinedFn,
1538 ArrayRef<llvm::Value *> Args = {}) const;
1539
1540 /// Emits OpenMP-specific function prolog.
1541 /// Required for device constructs.
1542 virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D);
1543
1544 /// Gets the OpenMP-specific address of the local variable.
1545 virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF,
1546 const VarDecl *VD);
1547
1548 /// Marks the declaration as already emitted for the device code and returns
1549 /// true, if it was marked already, and false, otherwise.
1551
1552 /// Emit deferred declare target variables marked for deferred emission.
1553 void emitDeferredTargetDecls() const;
1554
1555 /// Adjust some parameters for the target-based directives, like addresses of
1556 /// the variables captured by reference in lambdas.
1557 virtual void
1558 adjustTargetSpecificDataForLambdas(CodeGenFunction &CGF,
1559 const OMPExecutableDirective &D) const;
1560
1561 /// Perform check on requires decl to ensure that target architecture
1562 /// supports unified addressing
1563 virtual void processRequiresDirective(const OMPRequiresDecl *D);
1564
1565 /// Gets default memory ordering as specified in requires directive.
1566 llvm::AtomicOrdering getDefaultMemoryOrdering() const;
1567
1568 /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
1569 /// the predefined allocator and translates it into the corresponding address
1570 /// space.
1571 virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS);
1572
1573 /// Return whether the unified_shared_memory has been specified.
1574 bool hasRequiresUnifiedSharedMemory() const;
1575
1576 /// Checks if the \p VD variable is marked as nontemporal declaration in
1577 /// current context.
1578 bool isNontemporalDecl(const ValueDecl *VD) const;
1579
1580 /// Create specialized alloca to handle lastprivate conditionals.
1581 Address emitLastprivateConditionalInit(CodeGenFunction &CGF,
1582 const VarDecl *VD);
1583
1584 /// Checks if the provided \p LVal is lastprivate conditional and emits the
1585 /// code to update the value of the original variable.
1586 /// \code
1587 /// lastprivate(conditional: a)
1588 /// ...
1589 /// <type> a;
1590 /// lp_a = ...;
1591 /// #pragma omp critical(a)
1592 /// if (last_iv_a <= iv) {
1593 /// last_iv_a = iv;
1594 /// global_a = lp_a;
1595 /// }
1596 /// \endcode
1597 virtual void checkAndEmitLastprivateConditional(CodeGenFunction &CGF,
1598 const Expr *LHS);
1599
1600 /// Checks if the lastprivate conditional was updated in inner region and
1601 /// writes the value.
1602 /// \code
1603 /// lastprivate(conditional: a)
1604 /// ...
1605 /// <type> a;bool Fired = false;
1606 /// #pragma omp ... shared(a)
1607 /// {
1608 /// lp_a = ...;
1609 /// Fired = true;
1610 /// }
1611 /// if (Fired) {
1612 /// #pragma omp critical(a)
1613 /// if (last_iv_a <= iv) {
1614 /// last_iv_a = iv;
1615 /// global_a = lp_a;
1616 /// }
1617 /// Fired = false;
1618 /// }
1619 /// \endcode
1621 CodeGenFunction &CGF, const OMPExecutableDirective &D,
1622 const llvm::DenseSet<CanonicalDeclPtr<const VarDecl>> &IgnoredDecls);
1623
1624 /// Gets the address of the global copy used for lastprivate conditional
1625 /// update, if any.
1626 /// \param PrivLVal LValue for the private copy.
1627 /// \param VD Original lastprivate declaration.
1628 virtual void emitLastprivateConditionalFinalUpdate(CodeGenFunction &CGF,
1629 LValue PrivLVal,
1630 const VarDecl *VD,
1632
1633 /// Emits list of dependecies based on the provided data (array of
1634 /// dependence/expression pairs).
1635 /// \returns Pointer to the first element of the array casted to VoidPtr type.
1636 std::pair<llvm::Value *, Address>
1637 emitDependClause(CodeGenFunction &CGF,
1640
1641 /// Emits list of dependecies based on the provided data (array of
1642 /// dependence/expression pairs) for depobj construct. In this case, the
1643 /// variable is allocated in dynamically. \returns Pointer to the first
1644 /// element of the array casted to VoidPtr type.
1645 Address emitDepobjDependClause(CodeGenFunction &CGF,
1646 const OMPTaskDataTy::DependData &Dependencies,
1648
1649 /// Emits the code to destroy the dependency object provided in depobj
1650 /// directive.
1651 void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
1653
1654 /// Updates the dependency kind in the specified depobj object.
1655 /// \param DepobjLVal LValue for the main depobj object.
1656 /// \param NewDepKind New dependency kind.
1657 void emitUpdateClause(CodeGenFunction &CGF, LValue DepobjLVal,
1659
1660 /// Initializes user defined allocators specified in the uses_allocators
1661 /// clauses.
1662 void emitUsesAllocatorsInit(CodeGenFunction &CGF, const Expr *Allocator,
1663 const Expr *AllocatorTraits);
1664
1665 /// Destroys user defined allocators specified in the uses_allocators clause.
1666 void emitUsesAllocatorsFini(CodeGenFunction &CGF, const Expr *Allocator);
1667
1668 /// Returns true if the variable is a local variable in untied task.
1669 bool isLocalVarInUntiedTask(CodeGenFunction &CGF, const VarDecl *VD) const;
1670};
1671
1672/// Class supports emissionof SIMD-only code.
1674public:
1677
1678 /// Emits outlined function for the specified OpenMP parallel directive
1679 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
1680 /// kmp_int32 BoundID, struct context_vars*).
1681 /// \param CGF Reference to current CodeGenFunction.
1682 /// \param D OpenMP directive.
1683 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1684 /// \param InnermostKind Kind of innermost directive (for simple directives it
1685 /// is a directive itself, for combined - its innermost directive).
1686 /// \param CodeGen Code generation sequence for the \a D directive.
1687 llvm::Function *emitParallelOutlinedFunction(
1689 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
1690 const RegionCodeGenTy &CodeGen) override;
1691
1692 /// Emits outlined function for the specified OpenMP teams directive
1693 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
1694 /// kmp_int32 BoundID, struct context_vars*).
1695 /// \param CGF Reference to current CodeGenFunction.
1696 /// \param D OpenMP directive.
1697 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1698 /// \param InnermostKind Kind of innermost directive (for simple directives it
1699 /// is a directive itself, for combined - its innermost directive).
1700 /// \param CodeGen Code generation sequence for the \a D directive.
1701 llvm::Function *emitTeamsOutlinedFunction(
1703 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
1704 const RegionCodeGenTy &CodeGen) override;
1705
1706 /// Emits outlined function for the OpenMP task directive \a D. This
1707 /// outlined function has type void(*)(kmp_int32 ThreadID, struct task_t*
1708 /// TaskT).
1709 /// \param D OpenMP directive.
1710 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1711 /// \param PartIDVar Variable for partition id in the current OpenMP untied
1712 /// task region.
1713 /// \param TaskTVar Variable for task_t argument.
1714 /// \param InnermostKind Kind of innermost directive (for simple directives it
1715 /// is a directive itself, for combined - its innermost directive).
1716 /// \param CodeGen Code generation sequence for the \a D directive.
1717 /// \param Tied true if task is generated for tied task, false otherwise.
1718 /// \param NumberOfParts Number of parts in untied task. Ignored for tied
1719 /// tasks.
1720 ///
1721 llvm::Function *emitTaskOutlinedFunction(
1722 const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
1723 const VarDecl *PartIDVar, const VarDecl *TaskTVar,
1724 OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen,
1725 bool Tied, unsigned &NumberOfParts) override;
1726
1727 /// Emits code for parallel or serial call of the \a OutlinedFn with
1728 /// variables captured in a record which address is stored in \a
1729 /// CapturedStruct.
1730 /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
1731 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
1732 /// \param CapturedVars A pointer to the record with the references to
1733 /// variables used in \a OutlinedFn function.
1734 /// \param IfCond Condition in the associated 'if' clause, if it was
1735 /// specified, nullptr otherwise.
1736 /// \param NumThreads The value corresponding to the num_threads clause, if
1737 /// any, or nullptr.
1738 ///
1740 llvm::Function *OutlinedFn,
1741 ArrayRef<llvm::Value *> CapturedVars,
1742 const Expr *IfCond, llvm::Value *NumThreads) override;
1743
1744 /// Emits a critical region.
1745 /// \param CriticalName Name of the critical region.
1746 /// \param CriticalOpGen Generator for the statement associated with the given
1747 /// critical region.
1748 /// \param Hint Value of the 'hint' clause (optional).
1749 void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
1750 const RegionCodeGenTy &CriticalOpGen,
1752 const Expr *Hint = nullptr) override;
1753
1754 /// Emits a master region.
1755 /// \param MasterOpGen Generator for the statement associated with the given
1756 /// master region.
1758 const RegionCodeGenTy &MasterOpGen,
1759 SourceLocation Loc) override;
1760
1761 /// Emits a masked region.
1762 /// \param MaskedOpGen Generator for the statement associated with the given
1763 /// masked region.
1765 const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc,
1766 const Expr *Filter = nullptr) override;
1767
1768 /// Emits a masked region.
1769 /// \param MaskedOpGen Generator for the statement associated with the given
1770 /// masked region.
1771
1772 /// Emits code for a taskyield directive.
1774
1775 /// Emit a taskgroup region.
1776 /// \param TaskgroupOpGen Generator for the statement associated with the
1777 /// given taskgroup region.
1779 const RegionCodeGenTy &TaskgroupOpGen,
1780 SourceLocation Loc) override;
1781
1782 /// Emits a single region.
1783 /// \param SingleOpGen Generator for the statement associated with the given
1784 /// single region.
1786 const RegionCodeGenTy &SingleOpGen, SourceLocation Loc,
1787 ArrayRef<const Expr *> CopyprivateVars,
1788 ArrayRef<const Expr *> DestExprs,
1789 ArrayRef<const Expr *> SrcExprs,
1790 ArrayRef<const Expr *> AssignmentOps) override;
1791
1792 /// Emit an ordered region.
1793 /// \param OrderedOpGen Generator for the statement associated with the given
1794 /// ordered region.
1796 const RegionCodeGenTy &OrderedOpGen,
1797 SourceLocation Loc, bool IsThreads) override;
1798
1799 /// Emit an implicit/explicit barrier for OpenMP threads.
1800 /// \param Kind Directive for which this implicit barrier call must be
1801 /// generated. Must be OMPD_barrier for explicit barrier generation.
1802 /// \param EmitChecks true if need to emit checks for cancellation barriers.
1803 /// \param ForceSimpleCall true simple barrier call must be emitted, false if
1804 /// runtime class decides which one to emit (simple or with cancellation
1805 /// checks).
1806 ///
1808 OpenMPDirectiveKind Kind, bool EmitChecks = true,
1809 bool ForceSimpleCall = false) override;
1810
1811 /// This is used for non static scheduled types and when the ordered
1812 /// clause is present on the loop construct.
1813 /// Depending on the loop schedule, it is necessary to call some runtime
1814 /// routine before start of the OpenMP loop to get the loop upper / lower
1815 /// bounds \a LB and \a UB and stride \a ST.
1816 ///
1817 /// \param CGF Reference to current CodeGenFunction.
1818 /// \param Loc Clang source location.
1819 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
1820 /// \param IVSize Size of the iteration variable in bits.
1821 /// \param IVSigned Sign of the iteration variable.
1822 /// \param Ordered true if loop is ordered, false otherwise.
1823 /// \param DispatchValues struct containing llvm values for lower bound, upper
1824 /// bound, and chunk expression.
1825 /// For the default (nullptr) value, the chunk 1 will be used.
1826 ///
1828 const OpenMPScheduleTy &ScheduleKind,
1829 unsigned IVSize, bool IVSigned, bool Ordered,
1830 const DispatchRTInput &DispatchValues) override;
1831
1832 /// This is used for non static scheduled types and when the ordered
1833 /// clause is present on the loop construct.
1834 ///
1835 /// \param CGF Reference to current CodeGenFunction.
1836 /// \param Loc Clang source location.
1837 ///
1839
1840 /// Call the appropriate runtime routine to initialize it before start
1841 /// of loop.
1842 ///
1843 /// This is used only in case of static schedule, when the user did not
1844 /// specify a ordered clause on the loop construct.
1845 /// Depending on the loop schedule, it is necessary to call some runtime
1846 /// routine before start of the OpenMP loop to get the loop upper / lower
1847 /// bounds LB and UB and stride ST.
1848 ///
1849 /// \param CGF Reference to current CodeGenFunction.
1850 /// \param Loc Clang source location.
1851 /// \param DKind Kind of the directive.
1852 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
1853 /// \param Values Input arguments for the construct.
1854 ///
1856 OpenMPDirectiveKind DKind,
1857 const OpenMPScheduleTy &ScheduleKind,
1858 const StaticRTInput &Values) override;
1859
1860 ///
1861 /// \param CGF Reference to current CodeGenFunction.
1862 /// \param Loc Clang source location.
1863 /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
1864 /// \param Values Input arguments for the construct.
1865 ///
1868 const StaticRTInput &Values) override;
1869
1870 /// Call the appropriate runtime routine to notify that we finished
1871 /// iteration of the ordered loop with the dynamic scheduling.
1872 ///
1873 /// \param CGF Reference to current CodeGenFunction.
1874 /// \param Loc Clang source location.
1875 /// \param IVSize Size of the iteration variable in bits.
1876 /// \param IVSigned Sign of the iteration variable.
1877 ///
1879 unsigned IVSize, bool IVSigned) override;
1880
1881 /// Call the appropriate runtime routine to notify that we finished
1882 /// all the work with current loop.
1883 ///
1884 /// \param CGF Reference to current CodeGenFunction.
1885 /// \param Loc Clang source location.
1886 /// \param DKind Kind of the directive for which the static finish is emitted.
1887 ///
1889 OpenMPDirectiveKind DKind) override;
1890
1891 /// Call __kmpc_dispatch_next(
1892 /// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter,
1893 /// kmp_int[32|64] *p_lower, kmp_int[32|64] *p_upper,
1894 /// kmp_int[32|64] *p_stride);
1895 /// \param IVSize Size of the iteration variable in bits.
1896 /// \param IVSigned Sign of the iteration variable.
1897 /// \param IL Address of the output variable in which the flag of the
1898 /// last iteration is returned.
1899 /// \param LB Address of the output variable in which the lower iteration
1900 /// number is returned.
1901 /// \param UB Address of the output variable in which the upper iteration
1902 /// number is returned.
1903 /// \param ST Address of the output variable in which the stride value is
1904 /// returned.
1905 llvm::Value *emitForNext(CodeGenFunction &CGF, SourceLocation Loc,
1906 unsigned IVSize, bool IVSigned, Address IL,
1907 Address LB, Address UB, Address ST) override;
1908
1909 /// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
1910 /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
1911 /// clause.
1912 /// \param NumThreads An integer value of threads.
1913 void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads,
1914 SourceLocation Loc) override;
1915
1916 /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
1917 /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
1919 llvm::omp::ProcBindKind ProcBind,
1920 SourceLocation Loc) override;
1921
1922 /// Returns address of the threadprivate variable for the current
1923 /// thread.
1924 /// \param VD Threadprivate variable.
1925 /// \param VDAddr Address of the global variable \a VD.
1926 /// \param Loc Location of the reference to threadprivate var.
1927 /// \return Address of the threadprivate variable for the current thread.
1929 Address VDAddr, SourceLocation Loc) override;
1930
1931 /// Emit a code for initialization of threadprivate variable. It emits
1932 /// a call to runtime library which adds initial value to the newly created
1933 /// threadprivate variable (if it is not constant) and registers destructor
1934 /// for the variable (if any).
1935 /// \param VD Threadprivate variable.
1936 /// \param VDAddr Address of the global variable \a VD.
1937 /// \param Loc Location of threadprivate declaration.
1938 /// \param PerformInit true if initialization expression is not constant.
1939 llvm::Function *
1941 SourceLocation Loc, bool PerformInit,
1942 CodeGenFunction *CGF = nullptr) override;
1943
1944 /// Creates artificial threadprivate variable with name \p Name and type \p
1945 /// VarType.
1946 /// \param VarType Type of the artificial threadprivate variable.
1947 /// \param Name Name of the artificial threadprivate variable.
1949 QualType VarType,
1950 StringRef Name) override;
1951
1952 /// Emit flush of the variables specified in 'omp flush' directive.
1953 /// \param Vars List of variables to flush.
1955 SourceLocation Loc, llvm::AtomicOrdering AO) override;
1956
1957 /// Emit task region for the task directive. The task region is
1958 /// emitted in several steps:
1959 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1960 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1961 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1962 /// function:
1963 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1964 /// TaskFunction(gtid, tt->part_id, tt->shareds);
1965 /// return 0;
1966 /// }
1967 /// 2. Copy a list of shared variables to field shareds of the resulting
1968 /// structure kmp_task_t returned by the previous call (if any).
1969 /// 3. Copy a pointer to destructions function to field destructions of the
1970 /// resulting structure kmp_task_t.
1971 /// 4. Emit a call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid,
1972 /// kmp_task_t *new_task), where new_task is a resulting structure from
1973 /// previous items.
1974 /// \param D Current task directive.
1975 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
1976 /// /*part_id*/, captured_struct */*__context*/);
1977 /// \param SharedsTy A type which contains references the shared variables.
1978 /// \param Shareds Context with the list of shared variables from the \p
1979 /// TaskFunction.
1980 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
1981 /// otherwise.
1982 /// \param Data Additional data for task generation like tiednsee, final
1983 /// state, list of privates etc.
1986 llvm::Function *TaskFunction, QualType SharedsTy,
1987 Address Shareds, const Expr *IfCond,
1988 const OMPTaskDataTy &Data) override;
1989
1990 /// Emit task region for the taskloop directive. The taskloop region is
1991 /// emitted in several steps:
1992 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1993 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1994 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1995 /// function:
1996 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1997 /// TaskFunction(gtid, tt->part_id, tt->shareds);
1998 /// return 0;
1999 /// }
2000 /// 2. Copy a list of shared variables to field shareds of the resulting
2001 /// structure kmp_task_t returned by the previous call (if any).
2002 /// 3. Copy a pointer to destructions function to field destructions of the
2003 /// resulting structure kmp_task_t.
2004 /// 4. Emit a call to void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t
2005 /// *task, int if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int
2006 /// nogroup, int sched, kmp_uint64 grainsize, void *task_dup ), where new_task
2007 /// is a resulting structure from
2008 /// previous items.
2009 /// \param D Current task directive.
2010 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
2011 /// /*part_id*/, captured_struct */*__context*/);
2012 /// \param SharedsTy A type which contains references the shared variables.
2013 /// \param Shareds Context with the list of shared variables from the \p
2014 /// TaskFunction.
2015 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
2016 /// otherwise.
2017 /// \param Data Additional data for task generation like tiednsee, final
2018 /// state, list of privates etc.
2020 const OMPLoopDirective &D, llvm::Function *TaskFunction,
2021 QualType SharedsTy, Address Shareds, const Expr *IfCond,
2022 const OMPTaskDataTy &Data) override;
2023
2024 /// Emit a code for reduction clause. Next code should be emitted for
2025 /// reduction:
2026 /// \code
2027 ///
2028 /// static kmp_critical_name lock = { 0 };
2029 ///
2030 /// void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
2031 /// ...
2032 /// *(Type<i>*)lhs[i] = RedOp<i>(*(Type<i>*)lhs[i], *(Type<i>*)rhs[i]);
2033 /// ...
2034 /// }
2035 ///
2036 /// ...
2037 /// void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
2038 /// switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList),
2039 /// RedList, reduce_func, &<lock>)) {
2040 /// case 1:
2041 /// ...
2042 /// <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]);
2043 /// ...
2044 /// __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
2045 /// break;
2046 /// case 2:
2047 /// ...
2048 /// Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]));
2049 /// ...
2050 /// break;
2051 /// default:;
2052 /// }
2053 /// \endcode
2054 ///
2055 /// \param Privates List of private copies for original reduction arguments.
2056 /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
2057 /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
2058 /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
2059 /// or 'operator binop(LHS, RHS)'.
2060 /// \param Options List of options for reduction codegen:
2061 /// WithNowait true if parent directive has also nowait clause, false
2062 /// otherwise.
2063 /// SimpleReduction Emit reduction operation only. Used for omp simd
2064 /// directive on the host.
2065 /// ReductionKind The kind of reduction to perform.
2067 ArrayRef<const Expr *> Privates,
2068 ArrayRef<const Expr *> LHSExprs,
2069 ArrayRef<const Expr *> RHSExprs,
2070 ArrayRef<const Expr *> ReductionOps,
2071 ReductionOptionsTy Options) override;
2072
2073 /// Emit a code for initialization of task reduction clause. Next code
2074 /// should be emitted for reduction:
2075 /// \code
2076 ///
2077 /// _taskred_item_t red_data[n];
2078 /// ...
2079 /// red_data[i].shar = &shareds[i];
2080 /// red_data[i].orig = &origs[i];
2081 /// red_data[i].size = sizeof(origs[i]);
2082 /// red_data[i].f_init = (void*)RedInit<i>;
2083 /// red_data[i].f_fini = (void*)RedDest<i>;
2084 /// red_data[i].f_comb = (void*)RedOp<i>;
2085 /// red_data[i].flags = <Flag_i>;
2086 /// ...
2087 /// void* tg1 = __kmpc_taskred_init(gtid, n, red_data);
2088 /// \endcode
2089 /// For reduction clause with task modifier it emits the next call:
2090 /// \code
2091 ///
2092 /// _taskred_item_t red_data[n];
2093 /// ...
2094 /// red_data[i].shar = &shareds[i];
2095 /// red_data[i].orig = &origs[i];
2096 /// red_data[i].size = sizeof(origs[i]);
2097 /// red_data[i].f_init = (void*)RedInit<i>;
2098 /// red_data[i].f_fini = (void*)RedDest<i>;
2099 /// red_data[i].f_comb = (void*)RedOp<i>;
2100 /// red_data[i].flags = <Flag_i>;
2101 /// ...
2102 /// void* tg1 = __kmpc_taskred_modifier_init(loc, gtid, is_worksharing, n,
2103 /// red_data);
2104 /// \endcode
2105 /// \param LHSExprs List of LHS in \a Data.ReductionOps reduction operations.
2106 /// \param RHSExprs List of RHS in \a Data.ReductionOps reduction operations.
2107 /// \param Data Additional data for task generation like tiedness, final
2108 /// state, list of privates, reductions etc.
2110 ArrayRef<const Expr *> LHSExprs,
2111 ArrayRef<const Expr *> RHSExprs,
2112 const OMPTaskDataTy &Data) override;
2113
2114 /// Emits the following code for reduction clause with task modifier:
2115 /// \code
2116 /// __kmpc_task_reduction_modifier_fini(loc, gtid, is_worksharing);
2117 /// \endcode
2119 bool IsWorksharingReduction) override;
2120
2121 /// Required to resolve existing problems in the runtime. Emits threadprivate
2122 /// variables to store the size of the VLAs/array sections for
2123 /// initializer/combiner/finalizer functions + emits threadprivate variable to
2124 /// store the pointer to the original reduction item for the custom
2125 /// initializer defined by declare reduction construct.
2126 /// \param RCG Allows to reuse an existing data for the reductions.
2127 /// \param N Reduction item for which fixups must be emitted.
2129 ReductionCodeGen &RCG, unsigned N) override;
2130
2131 /// Get the address of `void *` type of the privatue copy of the reduction
2132 /// item specified by the \p SharedLVal.
2133 /// \param ReductionsPtr Pointer to the reduction data returned by the
2134 /// emitTaskReductionInit function.
2135 /// \param SharedLVal Address of the original reduction item.
2137 llvm::Value *ReductionsPtr,
2138 LValue SharedLVal) override;
2139
2140 /// Emit code for 'taskwait' directive.
2142 const OMPTaskDataTy &Data) override;
2143
2144 /// Emit code for 'cancellation point' construct.
2145 /// \param CancelRegion Region kind for which the cancellation point must be
2146 /// emitted.
2147 ///
2149 OpenMPDirectiveKind CancelRegion) override;
2150
2151 /// Emit code for 'cancel' construct.
2152 /// \param IfCond Condition in the associated 'if' clause, if it was
2153 /// specified, nullptr otherwise.
2154 /// \param CancelRegion Region kind for which the cancel must be emitted.
2155 ///
2157 const Expr *IfCond,
2158 OpenMPDirectiveKind CancelRegion) override;
2159
2160 /// Emit outilined function for 'target' directive.
2161 /// \param D Directive to emit.
2162 /// \param ParentName Name of the function that encloses the target region.
2163 /// \param OutlinedFn Outlined function value to be defined by this call.
2164 /// \param OutlinedFnID Outlined function ID value to be defined by this call.
2165 /// \param IsOffloadEntry True if the outlined function is an offload entry.
2166 /// \param CodeGen Code generation sequence for the \a D directive.
2167 /// An outlined function may not be an entry if, e.g. the if clause always
2168 /// evaluates to false.
2170 StringRef ParentName,
2171 llvm::Function *&OutlinedFn,
2172 llvm::Constant *&OutlinedFnID,
2173 bool IsOffloadEntry,
2174 const RegionCodeGenTy &CodeGen) override;
2175
2176 /// Emit the target offloading code associated with \a D. The emitted
2177 /// code attempts offloading the execution to the device, an the event of
2178 /// a failure it executes the host version outlined in \a OutlinedFn.
2179 /// \param D Directive to emit.
2180 /// \param OutlinedFn Host version of the code to be offloaded.
2181 /// \param OutlinedFnID ID of host version of the code to be offloaded.
2182 /// \param IfCond Expression evaluated in if clause associated with the target
2183 /// directive, or null if no if clause is used.
2184 /// \param Device Expression evaluated in device clause associated with the
2185 /// target directive, or null if no device clause is used and device modifier.
2186 void emitTargetCall(
2188 llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond,
2189 llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
2190 llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
2191 const OMPLoopDirective &D)>
2192 SizeEmitter) override;
2193
2194 /// Emit the target regions enclosed in \a GD function definition or
2195 /// the function itself in case it is a valid device function. Returns true if
2196 /// \a GD was dealt with successfully.
2197 /// \param GD Function to scan.
2198 bool emitTargetFunctions(GlobalDecl GD) override;
2199
2200 /// Emit the global variable if it is a valid device global variable.
2201 /// Returns true if \a GD was dealt with successfully.
2202 /// \param GD Variable declaration to emit.
2203 bool emitTargetGlobalVariable(GlobalDecl GD) override;
2204
2205 /// Emit the global \a GD if it is meaningful for the target. Returns
2206 /// if it was emitted successfully.
2207 /// \param GD Global to scan.
2208 bool emitTargetGlobal(GlobalDecl GD) override;
2209
2210 /// Emits code for teams call of the \a OutlinedFn with
2211 /// variables captured in a record which address is stored in \a
2212 /// CapturedStruct.
2213 /// \param OutlinedFn Outlined function to be run by team masters. Type of
2214 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
2215 /// \param CapturedVars A pointer to the record with the references to
2216 /// variables used in \a OutlinedFn function.
2217 ///
2219 SourceLocation Loc, llvm::Function *OutlinedFn,
2220 ArrayRef<llvm::Value *> CapturedVars) override;
2221
2222 /// Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32
2223 /// global_tid, kmp_int32 num_teams, kmp_int32 thread_limit) to generate code
2224 /// for num_teams clause.
2225 /// \param NumTeams An integer expression of teams.
2226 /// \param ThreadLimit An integer expression of threads.
2227 void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams,
2228 const Expr *ThreadLimit, SourceLocation Loc) override;
2229
2230 /// Emit the target data mapping code associated with \a D.
2231 /// \param D Directive to emit.
2232 /// \param IfCond Expression evaluated in if clause associated with the
2233 /// target directive, or null if no device clause is used.
2234 /// \param Device Expression evaluated in device clause associated with the
2235 /// target directive, or null if no device clause is used.
2236 /// \param Info A record used to store information that needs to be preserved
2237 /// until the region is closed.
2239 const OMPExecutableDirective &D, const Expr *IfCond,
2240 const Expr *Device, const RegionCodeGenTy &CodeGen,
2241 CGOpenMPRuntime::TargetDataInfo &Info) override;
2242
2243 /// Emit the data mapping/movement code associated with the directive
2244 /// \a D that should be of the form 'target [{enter|exit} data | update]'.
2245 /// \param D Directive to emit.
2246 /// \param IfCond Expression evaluated in if clause associated with the target
2247 /// directive, or null if no if clause is used.
2248 /// \param Device Expression evaluated in device clause associated with the
2249 /// target directive, or null if no device clause is used.
2252 const Expr *IfCond,
2253 const Expr *Device) override;
2254
2255 /// Emit initialization for doacross loop nesting support.
2256 /// \param D Loop-based construct used in doacross nesting construct.
2258 ArrayRef<Expr *> NumIterations) override;
2259
2260 /// Emit code for doacross ordered directive with 'depend' clause.
2261 /// \param C 'depend' clause with 'sink|source' dependency kind.
2263 const OMPDependClause *C) override;
2264
2265 /// Emit code for doacross ordered directive with 'doacross' clause.
2266 /// \param C 'doacross' clause with 'sink|source' dependence type.
2268 const OMPDoacrossClause *C) override;
2269
2270 /// Translates the native parameter of outlined function if this is required
2271 /// for target.
2272 /// \param FD Field decl from captured record for the parameter.
2273 /// \param NativeParam Parameter itself.
2274 const VarDecl *translateParameter(const FieldDecl *FD,
2275 const VarDecl *NativeParam) const override;
2276
2277 /// Gets the address of the native argument basing on the address of the
2278 /// target-specific parameter.
2279 /// \param NativeParam Parameter itself.
2280 /// \param TargetParam Corresponding target-specific parameter.
2281 Address getParameterAddress(CodeGenFunction &CGF, const VarDecl *NativeParam,
2282 const VarDecl *TargetParam) const override;
2283
2284 /// Gets the OpenMP-specific address of the local variable.
2286 const VarDecl *VD) override {
2287 return Address::invalid();
2288 }
2289};
2290
2291} // namespace CodeGen
2292// Utility for openmp doacross clause kind
2293namespace {
2294template <typename T> class OMPDoacrossKind {
2295public:
2296 bool isSink(const T *) { return false; }
2297 bool isSource(const T *) { return false; }
2298};
2299template <> class OMPDoacrossKind<OMPDependClause> {
2300public:
2301 bool isSink(const OMPDependClause *C) {
2302 return C->getDependencyKind() == OMPC_DEPEND_sink;
2303 }
2304 bool isSource(const OMPDependClause *C) {
2305 return C->getDependencyKind() == OMPC_DEPEND_source;
2306 }
2307};
2308template <> class OMPDoacrossKind<OMPDoacrossClause> {
2309public:
2310 bool isSource(const OMPDoacrossClause *C) {
2311 return C->getDependenceType() == OMPC_DOACROSS_source ||
2312 C->getDependenceType() == OMPC_DOACROSS_source_omp_cur_iteration;
2313 }
2314 bool isSink(const OMPDoacrossClause *C) {
2315 return C->getDependenceType() == OMPC_DOACROSS_sink ||
2316 C->getDependenceType() == OMPC_DOACROSS_sink_omp_cur_iteration;
2317 }
2318};
2319} // namespace
2320} // namespace clang
2321
2322#endif
MatchType Type
const Decl * D
Expr * E
enum clang::sema::@1712::IndirectLocalPathEntry::EntryKind Kind
This file defines OpenMP nodes for declarative directives.
Defines some OpenMP-specific enums and functions.
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
A wrapper class around a pointer that always points to its canonical declaration.
Definition: Redeclarable.h:348
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition: Address.h:128
static Address invalid()
Definition: Address.h:176
Allows to disable automatic handling of functions used in target regions as those marked as omp decla...
Manages list of lastprivate conditional decls for the specified directive.
static LastprivateConditionalRAII disable(CodeGenFunction &CGF, const OMPExecutableDirective &S)
Manages list of nontemporal decls for the specified directive.
Struct that keeps all the relevant information that should be kept throughout a 'target data' region.
llvm::DenseMap< const ValueDecl *, llvm::Value * > CaptureDeviceAddrMap
Map between the a declaration of a capture and the corresponding new llvm address where the runtime r...
TargetDataInfo(bool RequiresDevicePointerInfo, bool SeparateBeginEndCalls)
Manages list of nontemporal decls for the specified directive.
virtual Address emitThreadIDAddress(CodeGenFunction &CGF, SourceLocation Loc)
Emits address of the word in a memory where current thread id is stored.
llvm::FunctionType * Kmpc_MicroTy
The type for a microtask which gets passed to __kmpc_fork_call().
llvm::StringSet ThreadPrivateWithDefinition
Set of threadprivate variables with the generated initializer.
virtual void getKmpcFreeShared(CodeGenFunction &CGF, const std::pair< llvm::Value *, llvm::Value * > &AddrSizePair)
Get call to __kmpc_free_shared.
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.
void createOffloadEntriesAndInfoMetadata()
Creates all the offload entries in the current compilation unit along with the associated metadata.
const Expr * getNumTeamsExprForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D, int32_t &MinTeamsVal, int32_t &MaxTeamsVal)
Emit the number of teams for a target directive.
virtual Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc)
Returns address of the threadprivate variable for the current thread.
void emitDeferredTargetDecls() const
Emit deferred declare target variables marked for deferred emission.
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...
bool markAsGlobalTarget(GlobalDecl GD)
Marks the declaration as already emitted for the device code and returns true, if it was marked alrea...
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...
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)...
QualType SavedKmpTaskloopTQTy
Saved kmp_task_t for taskloop-based directive.
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.
virtual bool emitTargetGlobal(GlobalDecl GD)
Emit the global GD if it is meaningful for the target.
void setLocThreadIdInsertPt(CodeGenFunction &CGF, bool AtCurrentPoint=false)
std::string getOutlinedHelperName(StringRef Name) const
Get the function name of an outlined region.
bool HasEmittedDeclareTargetRegion
Flag for keeping track of weather a device routine has been emitted.
llvm::Constant * getOrCreateThreadPrivateCache(const VarDecl *VD)
If the specified mangled name is not in the module, create and return threadprivate cache object.
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...
virtual void emitForDispatchDeinit(CodeGenFunction &CGF, SourceLocation Loc)
This is used for non static scheduled types and when the ordered clause is present on the loop constr...
void emitCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::FunctionCallee Callee, ArrayRef< llvm::Value * > Args={}) const
Emits Callee function call with arguments Args with location Loc.
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.
virtual std::pair< llvm::Function *, llvm::Function * > getUserDefinedReduction(const OMPDeclareReductionDecl *D)
Get combiner/initializer for the specified user-defined reduction, if any.
virtual bool isGPU() const
Returns true if the current target is a GPU.
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 ...
virtual void emitDeclareTargetFunction(const FunctionDecl *FD, llvm::GlobalValue *GV)
Emit code for handling declare target functions in the runtime.
llvm::Type * getKmpc_MicroPointerTy()
Returns pointer to kmpc_micro type.
bool HasRequiresUnifiedSharedMemory
Flag for keeping track of weather a requires unified_shared_memory directive is present.
llvm::Value * emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc, unsigned Flags=0, bool EmitLoc=false)
Emits object of ident_t type with info for source location.
bool isLocalVarInUntiedTask(CodeGenFunction &CGF, const VarDecl *VD) const
Returns true if the variable is a local variable in untied task.
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...
virtual void emitCancellationPointCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancellation point' construct.
virtual const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const
Translates the native parameter of outlined function if this is required for target.
llvm::DenseMap< llvm::Function *, SmallVector< const OMPDeclareReductionDecl *, 4 > > FunctionUDRMapTy
Map of functions and locally defined UDRs.
virtual llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr)
Emit a code for initialization of threadprivate variable.
virtual bool isDefaultLocationConstant() const
Check if the default location must be constant.
virtual ConstantAddress getAddrOfDeclareTargetVar(const VarDecl *VD)
Returns the address of the variable marked as declare target with link clause OR as declare target wi...
llvm::MapVector< CanonicalDeclPtr< const VarDecl >, std::pair< Address, Address > > UntiedLocalVarsAddressesMap
llvm::Function * getOrCreateUserDefinedMapperFunc(const OMPDeclareMapperDecl *D)
Get the function for the specified user-defined mapper.
OpenMPLocThreadIDMapTy OpenMPLocThreadIDMap
virtual void functionFinished(CodeGenFunction &CGF)
Cleans up references to the objects in finished function.
virtual llvm::Function * emitTeamsOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen)
Emits outlined function for the specified OpenMP teams directive D.
llvm::DenseMap< llvm::Function *, DebugLocThreadIdTy > OpenMPLocThreadIDMapTy
Map of local debug location, ThreadId and functions.
QualType KmpTaskTQTy
Type typedef struct kmp_task { void * shareds; /‍**< pointer to block of pointers to shared vars ‍/ k...
llvm::OpenMPIRBuilder OMPBuilder
An OpenMP-IR-Builder instance.
virtual void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D, ArrayRef< Expr * > NumIterations)
Emit initialization for doacross loop nesting support.
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...
virtual void emitTargetDataCalls(CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond, const Expr *Device, const RegionCodeGenTy &CodeGen, CGOpenMPRuntime::TargetDataInfo &Info)
Emit the target data mapping code associated with D.
virtual unsigned getDefaultLocationReserved2Flags() const
Returns additional flags that can be stored in reserved_2 field of the default location.
void computeMinAndMaxThreadsAndTeams(const OMPExecutableDirective &D, CodeGenFunction &CGF, int32_t &MinThreadsVal, int32_t &MaxThreadsVal, int32_t &MinTeamsVal, int32_t &MaxTeamsVal)
Helper to determine the min/max number of threads/teams for D.
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.
void emitUsesAllocatorsFini(CodeGenFunction &CGF, const Expr *Allocator)
Destroys user defined allocators specified in the uses_allocators clause.
QualType KmpTaskAffinityInfoTy
Type typedef struct kmp_task_affinity_info { kmp_intptr_t base_addr; size_t len; struct { bool flag1 ...
llvm::SmallVector< NontemporalDeclsSet, 4 > NontemporalDeclsStack
Stack for list of declarations in current context marked as nontemporal.
llvm::Value * emitNumTeamsForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D)
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.
void scanForTargetRegionsFunctions(const Stmt *S, StringRef ParentName)
Start scanning from statement S and emit all target regions found along the way.
SmallVector< llvm::Value *, 4 > emitDepobjElementsSizes(CodeGenFunction &CGF, QualType &KmpDependInfoTy, const OMPTaskDataTy::DependData &Data)
virtual void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc)
Emit a taskgroup region.
llvm::DenseMap< llvm::Function *, SmallVector< const OMPDeclareMapperDecl *, 4 > > FunctionUDMMapTy
Map of functions and their local user-defined mappers.
llvm::DenseMap< llvm::Function *, llvm::DenseMap< CanonicalDeclPtr< const Decl >, std::tuple< QualType, const FieldDecl *, const FieldDecl *, LValue > > > LastprivateConditionalToTypes
Maps local variables marked as lastprivate conditional to their internal types.
virtual bool emitTargetGlobalVariable(GlobalDecl GD)
Emit the global variable if it is a valid device global variable.
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,...
bool hasRequiresUnifiedSharedMemory() const
Return whether the unified_shared_memory has been specified.
virtual Address getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name)
Creates artificial threadprivate variable with name Name and type VarType.
void emitUserDefinedMapper(const OMPDeclareMapperDecl *D, CodeGenFunction *CGF=nullptr)
Emit the function for the user defined mapper construct.
llvm::DenseMap< SourceLocation, llvm::Value * > OpenMPDebugLocMapTy
Map for SourceLocation and OpenMP runtime library debug locations.
bool HasEmittedTargetRegion
Flag for keeping track of weather a target region has been emitted.
void emitDepobjElements(CodeGenFunction &CGF, QualType &KmpDependInfoTy, LValue PosLVal, const OMPTaskDataTy::DependData &Data, Address DependenciesArray)
std::string getReductionFuncName(StringRef Name) const
Get the function name of a reduction function.
virtual void processRequiresDirective(const OMPRequiresDecl *D)
Perform check on requires decl to ensure that target architecture supports unified addressing.
llvm::DenseSet< CanonicalDeclPtr< const Decl > > AlreadyEmittedTargetDecls
List of the emitted declarations.
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.
llvm::Value * getThreadID(CodeGenFunction &CGF, SourceLocation Loc)
Gets thread id value for the current thread.
void emitUpdateClause(CodeGenFunction &CGF, LValue DepobjLVal, OpenMPDependClauseKind NewDepKind, SourceLocation Loc)
Updates the dependency kind in the specified depobj object.
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.
virtual void emitErrorCall(CodeGenFunction &CGF, SourceLocation Loc, Expr *ME, bool IsFatal)
Emit __kmpc_error call for error directive extern void __kmpc_error(ident_t *loc, int severity,...
void clearLocThreadIdInsertPt(CodeGenFunction &CGF)
virtual void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc)
Emits code for a taskyield directive.
virtual std::pair< llvm::Value *, llvm::Value * > getKmpcAllocShared(CodeGenFunction &CGF, const VarDecl *VD)
Get call to __kmpc_alloc_shared.
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
virtual void emitFlush(CodeGenFunction &CGF, ArrayRef< const Expr * > Vars, SourceLocation Loc, llvm::AtomicOrdering AO)
Emit flush of the variables specified in 'omp flush' directive.
virtual void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPTaskDataTy &Data)
Emit code for 'taskwait' directive.
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...
void emitLastprivateConditionalUpdate(CodeGenFunction &CGF, LValue IVLVal, StringRef UniqueDeclName, LValue LVal, SourceLocation Loc)
Emit update for lastprivate conditional data.
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.
virtual void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false)
Emit an implicit/explicit barrier for OpenMP threads.
static unsigned getDefaultFlagsForBarriers(OpenMPDirectiveKind Kind)
Returns default flags for the barriers depending on the directive, for which this barier is going to ...
virtual bool isDelayedVariableLengthDecl(CodeGenFunction &CGF, const VarDecl *VD) const
Check if the variable length declaration is delayed:
virtual bool emitTargetFunctions(GlobalDecl GD)
Emit the target regions enclosed in GD function definition or the function itself in case it is a val...
TaskResultTy emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc, const OMPExecutableDirective &D, llvm::Function *TaskFunction, QualType SharedsTy, Address Shareds, const OMPTaskDataTy &Data)
Emit task region for the task directive.
llvm::Value * emitTargetNumIterationsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D, llvm::function_ref< llvm::Value *(CodeGenFunction &CGF, const OMPLoopDirective &D)> SizeEmitter)
Return the trip count of loops associated with constructs / 'target teams distribute' and 'teams dist...
llvm::StringMap< llvm::AssertingVH< llvm::GlobalVariable >, llvm::BumpPtrAllocator > InternalVars
An ordered map of auto-generated variables to their unique names.
virtual void emitDistributeStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDistScheduleClauseKind SchedKind, const StaticRTInput &Values)
llvm::SmallVector< UntiedLocalVarsAddressesMap, 4 > UntiedLocalVarsStack
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.
virtual void emitThreadLimitClause(CodeGenFunction &CGF, const Expr *ThreadLimit, SourceLocation Loc)
Emits call to void __kmpc_set_thread_limit(ident_t *loc, kmp_int32 global_tid, kmp_int32 thread_limit...
void emitIfClause(CodeGenFunction &CGF, const Expr *Cond, const RegionCodeGenTy &ThenGen, const RegionCodeGenTy &ElseGen)
Emits code for OpenMP 'if' clause using specified CodeGen function.
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...
bool isNontemporalDecl(const ValueDecl *VD) const
Checks if the VD variable is marked as nontemporal declaration in current context.
virtual llvm::Function * emitParallelOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen)
Emits outlined function for the specified OpenMP parallel directive D.
const Expr * getNumThreadsExprForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D, int32_t &UpperBound, bool UpperBoundOnly, llvm::Value **CondExpr=nullptr, const Expr **ThreadLimitExpr=nullptr)
Check for a number of threads upper bound constant value (stored in UpperBound), or expression (retur...
llvm::SmallVector< LastprivateConditionalData, 4 > LastprivateConditionalStack
Stack for list of addresses of declarations in current context marked as lastprivate conditional.
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.
virtual void emitDeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn)
Marks function Fn with properly mangled versions of vector functions.
llvm::AtomicOrdering getDefaultMemoryOrdering() const
Gets default memory ordering as specified in requires directive.
llvm::SmallDenseSet< CanonicalDeclPtr< const Decl > > NontemporalDeclsSet
llvm::StringSet DeclareTargetWithDefinition
Set of declare target variables with the generated initializer.
virtual bool isStaticNonchunked(OpenMPScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static non-chunked.
llvm::Value * getCriticalRegionLock(StringRef CriticalName)
Returns corresponding lock object for the specified critical region name.
virtual void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc, const Expr *IfCond, OpenMPDirectiveKind CancelRegion)
Emit code for 'cancel' construct.
QualType SavedKmpTaskTQTy
Saved kmp_task_t for task directive.
virtual void emitMasterRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MasterOpGen, SourceLocation Loc)
Emits a master region.
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.
OpenMPDebugLocMapTy OpenMPDebugLocMap
llvm::DenseMap< llvm::Function *, unsigned > FunctionToUntiedTaskStackMap
Maps function to the position of the untied task locals stack.
void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal, SourceLocation Loc)
Emits the code to destroy the dependency object provided in depobj directive.
virtual void emitTaskReductionFixups(CodeGenFunction &CGF, SourceLocation Loc, ReductionCodeGen &RCG, unsigned N)
Required to resolve existing problems in the runtime.
llvm::ArrayType * KmpCriticalNameTy
Type kmp_critical_name, originally defined as typedef kmp_int32 kmp_critical_name[8];.
virtual void emitDoacrossOrdered(CodeGenFunction &CGF, const OMPDependClause *C)
Emit code for doacross ordered directive with 'depend' clause.
llvm::DenseMap< const OMPDeclareMapperDecl *, llvm::Function * > UDMMap
Map from the user-defined mapper declaration to its corresponding functions.
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 ...
std::pair< llvm::Value *, LValue > getDepobjElements(CodeGenFunction &CGF, LValue DepobjLVal, SourceLocation Loc)
Returns the number of the elements and the address of the depobj dependency array.
llvm::SmallDenseSet< const VarDecl * > DeferredGlobalVariables
List of variables that can become declare target implicitly and, thus, must be emitted.
void emitUsesAllocatorsInit(CodeGenFunction &CGF, const Expr *Allocator, const Expr *AllocatorTraits)
Initializes user defined allocators specified in the uses_allocators clauses.
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.
llvm::DenseMap< const OMPDeclareReductionDecl *, std::pair< llvm::Function *, llvm::Function * > > UDRMapTy
Map of UDRs and corresponding combiner/initializer.
llvm::Type * KmpRoutineEntryPtrTy
Type typedef kmp_int32 (* kmp_routine_entry_t)(kmp_int32, void *);.
llvm::Type * getIdentTyPointerTy()
Returns pointer to ident_t type.
void emitSingleReductionCombiner(CodeGenFunction &CGF, const Expr *ReductionOp, const Expr *PrivateRef, const DeclRefExpr *LHS, const DeclRefExpr *RHS)
Emits single reduction combiner.
llvm::OpenMPIRBuilder & getOMPBuilder()
virtual void emitTargetOutlinedFunction(const OMPExecutableDirective &D, StringRef ParentName, llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID, bool IsOffloadEntry, const RegionCodeGenTy &CodeGen)
Emit outilined function for 'target' directive.
virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr)
Emits a critical region.
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...
virtual void emitOutlinedFunctionCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::FunctionCallee OutlinedFn, ArrayRef< llvm::Value * > Args={}) const
Emits call of the outlined function with the provided arguments, translating these arguments to corre...
llvm::Value * emitNumThreadsForTargetDirective(CodeGenFunction &CGF, const OMPExecutableDirective &D)
Emit an expression that denotes the number of threads a target region shall use.
void emitThreadPrivateVarInit(CodeGenFunction &CGF, Address VDAddr, llvm::Value *Ctor, llvm::Value *CopyCtor, llvm::Value *Dtor, SourceLocation Loc)
Emits initialization code for the threadprivate variables.
virtual void emitUserDefinedReduction(CodeGenFunction *CGF, const OMPDeclareReductionDecl *D)
Emit code for the specified user defined reduction construct.
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.
QualType KmpDimTy
struct kmp_dim { // loop bounds info casted to kmp_int64 kmp_int64 lo; // lower kmp_int64 up; // uppe...
virtual void emitInlinedDirective(CodeGenFunction &CGF, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen, bool HasCancel=false)
Emit code for the directive that does not require outlining.
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...
virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D)
Emits OpenMP-specific function prolog.
virtual void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars, const Expr *IfCond, llvm::Value *NumThreads)
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
void emitKmpRoutineEntryT(QualType KmpInt32Ty)
Build type kmp_routine_entry_t (if not built yet).
virtual bool isStaticChunked(OpenMPScheduleClauseKind ScheduleKind, bool Chunked) const
Check if the specified ScheduleKind is static chunked.
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.
virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS)
Checks if the variable has associated OMPAllocateDeclAttr attribute with the predefined allocator and...
llvm::AtomicOrdering RequiresAtomicOrdering
Atomic ordering from the omp requires directive.
virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > LHSExprs, ArrayRef< const Expr * > RHSExprs, ArrayRef< const Expr * > ReductionOps, ReductionOptionsTy Options)
Emit a code for reduction clause.
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).
llvm::StringMap< llvm::WeakTrackingVH > EmittedNonTargetVariables
List of the global variables with their addresses that should not be emitted for the target.
virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const
Check if the specified ScheduleKind is dynamic.
Address emitLastprivateConditionalInit(CodeGenFunction &CGF, const VarDecl *VD)
Create specialized alloca to handle lastprivate conditionals.
llvm::ArrayType * getKmpCriticalNameTy() const
Get the LLVM type for the critical name.
virtual void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads)
Emit an ordered region.
virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD)
Gets the OpenMP-specific address of the local variable.
virtual void emitTaskReductionFini(CodeGenFunction &CGF, SourceLocation Loc, bool IsWorksharingReduction)
Emits the following code for reduction clause with task modifier:
virtual void emitMaskedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc, const Expr *Filter=nullptr)
Emits a masked region.
QualType KmpDependInfoTy
Type typedef struct kmp_depend_info { kmp_intptr_t base_addr; size_t len; struct { bool in:1; bool ou...
llvm::Function * emitReductionFunction(StringRef ReducerName, SourceLocation Loc, llvm::Type *ArgsElemType, ArrayRef< const Expr * > Privates, ArrayRef< const Expr * > LHSExprs, ArrayRef< const Expr * > RHSExprs, ArrayRef< const Expr * > ReductionOps)
Emits reduction function.
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.
Class supports emissionof SIMD-only code.
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...
void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName, const RegionCodeGenTy &CriticalOpGen, SourceLocation Loc, const Expr *Hint=nullptr) override
Emits a critical region.
void emitDistributeStaticInit(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDistScheduleClauseKind SchedKind, const StaticRTInput &Values) override
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.
bool emitTargetGlobalVariable(GlobalDecl GD) override
Emit the global variable if it is a valid device global variable.
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...
llvm::Function * emitThreadPrivateVarDefinition(const VarDecl *VD, Address VDAddr, SourceLocation Loc, bool PerformInit, CodeGenFunction *CGF=nullptr) override
Emit a code for initialization of threadprivate variable.
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...
llvm::Function * emitTeamsOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits outlined function for the specified OpenMP teams directive D.
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.
void emitFlush(CodeGenFunction &CGF, ArrayRef< const Expr * > Vars, SourceLocation Loc, llvm::AtomicOrdering AO) override
Emit flush of the variables specified in 'omp flush' directive.
void emitDoacrossOrdered(CodeGenFunction &CGF, const OMPDependClause *C) override
Emit code for doacross ordered directive with 'depend' clause.
void emitTaskyieldCall(CodeGenFunction &CGF, SourceLocation Loc) override
Emits a masked region.
Address getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF, QualType VarType, StringRef Name) override
Creates artificial threadprivate variable with name Name and type VarType.
Address getAddrOfThreadPrivate(CodeGenFunction &CGF, const VarDecl *VD, Address VDAddr, SourceLocation Loc) override
Returns address of the threadprivate variable for the current thread.
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.
void emitTaskReductionFixups(CodeGenFunction &CGF, SourceLocation Loc, ReductionCodeGen &RCG, unsigned N) override
Required to resolve existing problems in the runtime.
llvm::Function * emitParallelOutlinedFunction(CodeGenFunction &CGF, const OMPExecutableDirective &D, const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen) override
Emits outlined function for the specified OpenMP parallel directive D.
void emitCancellationPointCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind CancelRegion) override
Emit code for 'cancellation point' construct.
void emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, OpenMPDirectiveKind Kind, bool EmitChecks=true, bool ForceSimpleCall=false) override
Emit an implicit/explicit barrier for OpenMP threads.
Address getAddressOfLocalVariable(CodeGenFunction &CGF, const VarDecl *VD) override
Gets the OpenMP-specific address of the local variable.
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.
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...
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...
bool emitTargetGlobal(GlobalDecl GD) override
Emit the global GD if it is meaningful for the target.
void emitTaskReductionFini(CodeGenFunction &CGF, SourceLocation Loc, bool IsWorksharingReduction) override
Emits the following code for reduction clause with task modifier:
void emitOrderedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &OrderedOpGen, SourceLocation Loc, bool IsThreads) override
Emit an ordered region.
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.
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.
void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars, const Expr *IfCond, llvm::Value *NumThreads) override
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
void emitProcBindClause(CodeGenFunction &CGF, llvm::omp::ProcBindKind ProcBind, SourceLocation Loc) override
Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32 global_tid, int proc_bind) to generat...
void emitTargetOutlinedFunction(const OMPExecutableDirective &D, StringRef ParentName, llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID, bool IsOffloadEntry, const RegionCodeGenTy &CodeGen) override
Emit outilined function for 'target' directive.
void emitMasterRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MasterOpGen, SourceLocation Loc) override
Emits a master region.
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,...
void emitForDispatchDeinit(CodeGenFunction &CGF, SourceLocation Loc) override
This is used for non static scheduled types and when the ordered clause is present on the loop constr...
const VarDecl * translateParameter(const FieldDecl *FD, const VarDecl *NativeParam) const override
Translates the native parameter of outlined function if this is required for target.
void emitMaskedRegion(CodeGenFunction &CGF, const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc, const Expr *Filter=nullptr) override
Emits a masked region.
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.
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.
bool emitTargetFunctions(GlobalDecl GD) override
Emit the target regions enclosed in GD function definition or the function itself in case it is a val...
void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc) override
Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_threads)...
void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D, ArrayRef< Expr * > NumIterations) override
Emit initialization for doacross loop nesting support.
void emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc, const Expr *IfCond, OpenMPDirectiveKind CancelRegion) override
Emit code for 'cancel' construct.
void emitTaskwaitCall(CodeGenFunction &CGF, SourceLocation Loc, const OMPTaskDataTy &Data) override
Emit code for 'taskwait' directive.
void emitTaskgroupRegion(CodeGenFunction &CGF, const RegionCodeGenTy &TaskgroupOpGen, SourceLocation Loc) override
Emit a taskgroup region.
void emitTargetDataCalls(CodeGenFunction &CGF, const OMPExecutableDirective &D, const Expr *IfCond, const Expr *Device, const RegionCodeGenTy &CodeGen, CGOpenMPRuntime::TargetDataInfo &Info) override
Emit the target data mapping code associated with D.
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...
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.
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.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
A specialization of Address that requires the address to be an LLVM Constant.
Definition: Address.h:294
LValue - This represents an lvalue references.
Definition: CGValue.h:182
A basic class for pre|post-action for advanced codegen sequence for OpenMP region.
virtual void Exit(CodeGenFunction &CGF)
virtual void Enter(CodeGenFunction &CGF)
Class intended to support codegen of all kind of the reduction clauses.
LValue getSharedLValue(unsigned N) const
Returns LValue for the reduction item.
const Expr * getRefExpr(unsigned N) const
Returns the base declaration of the reduction item.
LValue getOrigLValue(unsigned N) const
Returns LValue for the original reduction item.
bool needCleanups(unsigned N)
Returns true if the private copy requires cleanups.
void emitAggregateType(CodeGenFunction &CGF, unsigned N)
Emits the code for the variable-modified type, if required.
const VarDecl * getBaseDecl(unsigned N) const
Returns the base declaration of the reduction item.
QualType getPrivateType(unsigned N) const
Return the type of the private item.
bool usesReductionInitializer(unsigned N) const
Returns true if the initialization of the reduction item uses initializer from declare reduction cons...
void emitSharedOrigLValue(CodeGenFunction &CGF, unsigned N)
Emits lvalue for the shared and original reduction item.
void emitInitialization(CodeGenFunction &CGF, unsigned N, Address PrivateAddr, Address SharedAddr, llvm::function_ref< bool(CodeGenFunction &)> DefaultInit)
Performs initialization of the private copy for the reduction item.
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),...
void emitCleanups(CodeGenFunction &CGF, unsigned N, Address PrivateAddr)
Emits cleanup code for the reduction item.
Address adjustPrivateAddress(CodeGenFunction &CGF, unsigned N, Address PrivateAddr)
Adjusts PrivatedAddr for using instead of the original variable address in normal operations.
Class provides a way to call simple version of codegen for OpenMP region, or an advanced with possibl...
RegionCodeGenTy(Callable &&CodeGen, std::enable_if_t<!std::is_same< std::remove_reference_t< Callable >, RegionCodeGenTy >::value > *=nullptr)
void operator()(CodeGenFunction &CGF) const
void setAction(PrePostActionTy &Action) const
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1265
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
This represents one expression.
Definition: Expr.h:110
Represents a member of a struct/union/class.
Definition: Decl.h:3033
Represents a function declaration or definition.
Definition: Decl.h:1935
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:56
This represents '#pragma omp declare mapper ...' directive.
Definition: DeclOpenMP.h:287
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:177
This represents implicit clause 'depend' for the '#pragma omp task' directive.
This represents the 'doacross' clause for the '#pragma omp ordered' directive.
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:266
This is a common base class for loop directives ('omp simd', 'omp for', 'omp for simd' etc....
Definition: StmtOpenMP.h:1004
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:417
A (possibly-)qualified type.
Definition: Type.h:929
Represents a struct/union/class.
Definition: Decl.h:4148
Encodes a location in the source.
Stmt - This represents one statement.
Definition: Stmt.h:84
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
Represents a variable declaration or definition.
Definition: Decl.h:882
The JSON file list parser is used to communicate input to InstallAPI.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:25
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Definition: OpenMPKinds.h:104
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:55
@ OMPC_DEPEND_unknown
Definition: OpenMPKinds.h:59
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
const FunctionProtoType * T
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:31
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type,...
Stores debug location and ThreadID for the function.
llvm::AssertingVH< llvm::Instruction > ServiceInsertPt
Insert point for the service instructions.
struct with the values to be passed to the dispatch runtime function
llvm::Value * Chunk
Chunk size specified using 'schedule' clause (nullptr if chunk was not specified)
DispatchRTInput(llvm::Value *LB, llvm::Value *UB, llvm::Value *Chunk)
Maps the expression for the lastprivate variable to the global copy used to store new value because o...
llvm::MapVector< CanonicalDeclPtr< const Decl >, SmallString< 16 > > DeclToUniqueName
Struct with the values to be passed to the static runtime function.
StaticRTInput(unsigned IVSize, bool IVSigned, bool Ordered, Address IL, Address LB, Address UB, Address ST, llvm::Value *Chunk=nullptr)
bool IVSigned
Sign of the iteration variable.
Address UB
Address of the output variable in which the upper iteration number is returned.
Address IL
Address of the output variable in which the flag of the last iteration is returned.
llvm::Value * Chunk
Value of the chunk for the static_chunked scheduled loop.
unsigned IVSize
Size of the iteration variable in bits.
Address ST
Address of the output variable in which the stride value is returned necessary to generated the stati...
bool Ordered
true if loop is ordered, false otherwise.
Address LB
Address of the output variable in which the lower iteration number is returned.
DependData(OpenMPDependClauseKind DepKind, const Expr *IteratorExpr)
SmallVector< const Expr *, 4 > DepExprs
SmallVector< const Expr *, 4 > FirstprivateVars
SmallVector< CanonicalDeclPtr< const VarDecl >, 4 > PrivateLocals
SmallVector< const Expr *, 4 > LastprivateCopies
SmallVector< const Expr *, 4 > PrivateCopies
SmallVector< const Expr *, 4 > ReductionVars
llvm::PointerIntPair< llvm::Value *, 1, bool > Schedule
SmallVector< const Expr *, 4 > FirstprivateInits
llvm::PointerIntPair< llvm::Value *, 1, bool > Priority
SmallVector< const Expr *, 4 > ReductionOps
SmallVector< DependData, 4 > Dependences
SmallVector< const Expr *, 4 > ReductionCopies
SmallVector< const Expr *, 4 > PrivateVars
llvm::PointerIntPair< llvm::Value *, 1, bool > Final
SmallVector< const Expr *, 4 > FirstprivateCopies
SmallVector< const Expr *, 4 > LastprivateVars
SmallVector< const Expr *, 4 > ReductionOrigs
Scheduling data for loop-based OpenMP directives.
Definition: OpenMPKinds.h:180