clang 22.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.
318 llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs &Attrs);
319
320 /// Helper to emit outlined function for 'target' directive.
321 /// \param D Directive to emit.
322 /// \param ParentName Name of the function that encloses the target region.
323 /// \param OutlinedFn Outlined function value to be defined by this call.
324 /// \param OutlinedFnID Outlined function ID value to be defined by this call.
325 /// \param IsOffloadEntry True if the outlined function is an offload entry.
326 /// \param CodeGen Lambda codegen specific to an accelerator device.
327 /// An outlined function may not be an entry if, e.g. the if clause always
328 /// evaluates to false.
330 StringRef ParentName,
331 llvm::Function *&OutlinedFn,
332 llvm::Constant *&OutlinedFnID,
333 bool IsOffloadEntry,
334 const RegionCodeGenTy &CodeGen);
335
336 /// Returns pointer to ident_t type.
337 llvm::Type *getIdentTyPointerTy();
338
339 /// Gets thread id value for the current thread.
340 ///
341 llvm::Value *getThreadID(CodeGenFunction &CGF, SourceLocation Loc);
342
343 /// Get the function name of an outlined region.
344 std::string getOutlinedHelperName(StringRef Name) const;
345 std::string getOutlinedHelperName(CodeGenFunction &CGF) const;
346
347 /// Get the function name of a reduction function.
348 std::string getReductionFuncName(StringRef Name) const;
349
350 /// Emits \p Callee function call with arguments \p Args with location \p Loc.
352 llvm::FunctionCallee Callee,
353 ArrayRef<llvm::Value *> Args = {}) const;
354
355 /// Emits address of the word in a memory where current thread id is
356 /// stored.
358
360 bool AtCurrentPoint = false);
362
363 /// Check if the default location must be constant.
364 /// Default is false to support OMPT/OMPD.
365 virtual bool isDefaultLocationConstant() const { return false; }
366
367 /// Returns additional flags that can be stored in reserved_2 field of the
368 /// default location.
369 virtual unsigned getDefaultLocationReserved2Flags() const { return 0; }
370
371 /// Returns default flags for the barriers depending on the directive, for
372 /// which this barier is going to be emitted.
374
375 /// Get the LLVM type for the critical name.
376 llvm::ArrayType *getKmpCriticalNameTy() const {return KmpCriticalNameTy;}
377
378 /// Returns corresponding lock object for the specified critical region
379 /// name. If the lock object does not exist it is created, otherwise the
380 /// reference to the existing copy is returned.
381 /// \param CriticalName Name of the critical region.
382 ///
383 llvm::Value *getCriticalRegionLock(StringRef CriticalName);
384
385protected:
386 /// Map for SourceLocation and OpenMP runtime library debug locations.
387 typedef llvm::DenseMap<SourceLocation, llvm::Value *> OpenMPDebugLocMapTy;
389 /// Stores debug location and ThreadID for the function.
391 llvm::Value *DebugLoc;
392 llvm::Value *ThreadID;
393 /// Insert point for the service instructions.
394 llvm::AssertingVH<llvm::Instruction> ServiceInsertPt = nullptr;
395 };
396 /// Map of local debug location, ThreadId and functions.
397 typedef llvm::DenseMap<llvm::Function *, DebugLocThreadIdTy>
400 /// Map of UDRs and corresponding combiner/initializer.
401 typedef llvm::DenseMap<const OMPDeclareReductionDecl *,
402 std::pair<llvm::Function *, llvm::Function *>>
405 /// Map of functions and locally defined UDRs.
406 typedef llvm::DenseMap<llvm::Function *,
410 /// Map from the user-defined mapper declaration to its corresponding
411 /// functions.
412 llvm::DenseMap<const OMPDeclareMapperDecl *, llvm::Function *> UDMMap;
413 /// Map of functions and their local user-defined mappers.
415 llvm::DenseMap<llvm::Function *,
418 /// Maps local variables marked as lastprivate conditional to their internal
419 /// types.
420 llvm::DenseMap<llvm::Function *,
421 llvm::DenseMap<CanonicalDeclPtr<const Decl>,
422 std::tuple<QualType, const FieldDecl *,
423 const FieldDecl *, LValue>>>
425 /// Maps function to the position of the untied task locals stack.
426 llvm::DenseMap<llvm::Function *, unsigned> FunctionToUntiedTaskStackMap;
427 /// Type kmp_critical_name, originally defined as typedef kmp_int32
428 /// kmp_critical_name[8];
429 llvm::ArrayType *KmpCriticalNameTy;
430 /// An ordered map of auto-generated variables to their unique names.
431 /// It stores variables with the following names: 1) ".gomp_critical_user_" +
432 /// <critical_section_name> + ".var" for "omp critical" directives; 2)
433 /// <mangled_name_for_global_var> + ".cache." for cache for threadprivate
434 /// variables.
435 llvm::StringMap<llvm::AssertingVH<llvm::GlobalVariable>,
436 llvm::BumpPtrAllocator> InternalVars;
437 /// Type typedef kmp_int32 (* kmp_routine_entry_t)(kmp_int32, void *);
438 llvm::Type *KmpRoutineEntryPtrTy = nullptr;
440 /// Type typedef struct kmp_task {
441 /// void * shareds; /**< pointer to block of pointers to
442 /// shared vars */
443 /// kmp_routine_entry_t routine; /**< pointer to routine to call for
444 /// executing task */
445 /// kmp_int32 part_id; /**< part id for the task */
446 /// kmp_routine_entry_t destructors; /* pointer to function to invoke
447 /// deconstructors of firstprivate C++ objects */
448 /// } kmp_task_t;
450 /// Saved kmp_task_t for task directive.
452 /// Saved kmp_task_t for taskloop-based directive.
454 /// Type typedef struct kmp_depend_info {
455 /// kmp_intptr_t base_addr;
456 /// size_t len;
457 /// struct {
458 /// bool in:1;
459 /// bool out:1;
460 /// } flags;
461 /// } kmp_depend_info_t;
463 /// Type typedef struct kmp_task_affinity_info {
464 /// kmp_intptr_t base_addr;
465 /// size_t len;
466 /// struct {
467 /// bool flag1 : 1;
468 /// bool flag2 : 1;
469 /// kmp_int32 reserved : 30;
470 /// } flags;
471 /// } kmp_task_affinity_info_t;
473 /// struct kmp_dim { // loop bounds info casted to kmp_int64
474 /// kmp_int64 lo; // lower
475 /// kmp_int64 up; // upper
476 /// kmp_int64 st; // stride
477 /// };
479
481 /// List of the emitted declarations.
482 llvm::DenseSet<CanonicalDeclPtr<const Decl>> AlreadyEmittedTargetDecls;
483 /// List of the global variables with their addresses that should not be
484 /// emitted for the target.
485 llvm::StringMap<llvm::WeakTrackingVH> EmittedNonTargetVariables;
486
487 /// List of variables that can become declare target implicitly and, thus,
488 /// must be emitted.
489 llvm::SmallDenseSet<const VarDecl *> DeferredGlobalVariables;
490
491 using NontemporalDeclsSet = llvm::SmallDenseSet<CanonicalDeclPtr<const Decl>>;
492 /// Stack for list of declarations in current context marked as nontemporal.
493 /// The set is the union of all current stack elements.
495
497 llvm::MapVector<CanonicalDeclPtr<const VarDecl>,
498 std::pair<Address, Address>>;
500
501 /// Stack for list of addresses of declarations in current context marked as
502 /// lastprivate conditional. The set is the union of all current stack
503 /// elements.
505
506 /// Flag for keeping track of weather a requires unified_shared_memory
507 /// directive is present.
509
510 /// Atomic ordering from the omp requires directive.
511 llvm::AtomicOrdering RequiresAtomicOrdering = llvm::AtomicOrdering::Monotonic;
512
513 /// Flag for keeping track of weather a target region has been emitted.
515
516 /// Flag for keeping track of weather a device routine has been emitted.
517 /// Device routines are specific to the
519
520 /// Start scanning from statement \a S and emit all target regions
521 /// found along the way.
522 /// \param S Starting statement.
523 /// \param ParentName Name of the function declaration that is being scanned.
524 void scanForTargetRegionsFunctions(const Stmt *S, StringRef ParentName);
525
526 /// Build type kmp_routine_entry_t (if not built yet).
527 void emitKmpRoutineEntryT(QualType KmpInt32Ty);
528
529 /// If the specified mangled name is not in the module, create and
530 /// return threadprivate cache object. This object is a pointer's worth of
531 /// storage that's reserved for use by the OpenMP runtime.
532 /// \param VD Threadprivate variable.
533 /// \return Cache variable for the specified threadprivate.
534 llvm::Constant *getOrCreateThreadPrivateCache(const VarDecl *VD);
535
536 /// Set of threadprivate variables with the generated initializer.
538
539 /// Set of declare target variables with the generated initializer.
541
542 /// Emits initialization code for the threadprivate variables.
543 /// \param VDAddr Address of the global variable \a VD.
544 /// \param Ctor Pointer to a global init function for \a VD.
545 /// \param CopyCtor Pointer to a global copy function for \a VD.
546 /// \param Dtor Pointer to a global destructor function for \a VD.
547 /// \param Loc Location of threadprivate declaration.
549 llvm::Value *Ctor, llvm::Value *CopyCtor,
550 llvm::Value *Dtor, SourceLocation Loc);
551
553 llvm::Value *NewTask = nullptr;
554 llvm::Function *TaskEntry = nullptr;
555 llvm::Value *NewTaskNewTaskTTy = nullptr;
557 const RecordDecl *KmpTaskTQTyRD = nullptr;
558 llvm::Value *TaskDupFn = nullptr;
559 };
560 /// Emit task region for the task directive. The task region is emitted in
561 /// several steps:
562 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
563 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
564 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
565 /// function:
566 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
567 /// TaskFunction(gtid, tt->part_id, tt->shareds);
568 /// return 0;
569 /// }
570 /// 2. Copy a list of shared variables to field shareds of the resulting
571 /// structure kmp_task_t returned by the previous call (if any).
572 /// 3. Copy a pointer to destructions function to field destructions of the
573 /// resulting structure kmp_task_t.
574 /// \param D Current task directive.
575 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
576 /// /*part_id*/, captured_struct */*__context*/);
577 /// \param SharedsTy A type which contains references the shared variables.
578 /// \param Shareds Context with the list of shared variables from the \p
579 /// TaskFunction.
580 /// \param Data Additional data for task generation like tiednsee, final
581 /// state, list of privates etc.
584 llvm::Function *TaskFunction, QualType SharedsTy,
585 Address Shareds, const OMPTaskDataTy &Data);
586
587 /// Emit update for lastprivate conditional data.
589 StringRef UniqueDeclName, LValue LVal,
591
592 /// Returns the number of the elements and the address of the depobj
593 /// dependency array.
594 /// \return Number of elements in depobj array and the pointer to the array of
595 /// dependencies.
596 std::pair<llvm::Value *, LValue> getDepobjElements(CodeGenFunction &CGF,
597 LValue DepobjLVal,
599
603
605 LValue PosLVal, const OMPTaskDataTy::DependData &Data,
606 Address DependenciesArray);
607
608public:
610 virtual ~CGOpenMPRuntime() {}
611 virtual void clear();
612
613 /// Emits object of ident_t type with info for source location.
614 /// \param Flags Flags for OpenMP location.
615 /// \param EmitLoc emit source location with debug-info is off.
616 ///
618 unsigned Flags = 0, bool EmitLoc = false);
619
620 /// Emit the number of teams for a target directive. Inspect the num_teams
621 /// clause associated with a teams construct combined or closely nested
622 /// with the target directive.
623 ///
624 /// Emit a team of size one for directives such as 'target parallel' that
625 /// have no associated teams construct.
626 ///
627 /// Otherwise, return nullptr.
630 int32_t &MinTeamsVal,
631 int32_t &MaxTeamsVal);
634
635 /// Check for a number of threads upper bound constant value (stored in \p
636 /// UpperBound), or expression (returned). If the value is conditional (via an
637 /// if-clause), store the condition in \p CondExpr. Similarly, a potential
638 /// thread limit expression is stored in \p ThreadLimitExpr. If \p
639 /// UpperBoundOnly is true, no expression evaluation is perfomed.
642 int32_t &UpperBound, bool UpperBoundOnly,
643 llvm::Value **CondExpr = nullptr, const Expr **ThreadLimitExpr = nullptr);
644
645 /// Emit an expression that denotes the number of threads a target region
646 /// shall use. Will generate "i32 0" to allow the runtime to choose.
647 llvm::Value *
650
651 /// Return the trip count of loops associated with constructs / 'target teams
652 /// distribute' and 'teams distribute parallel for'. \param SizeEmitter Emits
653 /// the int64 value for the number of iterations of the associated loop.
654 llvm::Value *emitTargetNumIterationsCall(
656 llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
657 const OMPLoopDirective &D)>
658 SizeEmitter);
659
660 /// Returns true if the current target is a GPU.
661 virtual bool isGPU() const { return false; }
662
663 /// Check if the variable length declaration is delayed:
665 const VarDecl *VD) const {
666 return false;
667 };
668
669 /// Get call to __kmpc_alloc_shared
670 virtual std::pair<llvm::Value *, llvm::Value *>
672 llvm_unreachable("not implemented");
673 }
674
675 /// Get call to __kmpc_free_shared
676 virtual void getKmpcFreeShared(
677 CodeGenFunction &CGF,
678 const std::pair<llvm::Value *, llvm::Value *> &AddrSizePair) {
679 llvm_unreachable("not implemented");
680 }
681
682 /// Emits code for OpenMP 'if' clause using specified \a CodeGen
683 /// function. Here is the logic:
684 /// if (Cond) {
685 /// ThenGen();
686 /// } else {
687 /// ElseGen();
688 /// }
689 void emitIfClause(CodeGenFunction &CGF, const Expr *Cond,
690 const RegionCodeGenTy &ThenGen,
691 const RegionCodeGenTy &ElseGen);
692
693 /// Checks if the \p Body is the \a CompoundStmt and returns its child
694 /// statement iff there is only one that is not evaluatable at the compile
695 /// time.
696 static const Stmt *getSingleCompoundChild(ASTContext &Ctx, const Stmt *Body);
697
698 /// Get the platform-specific name separator.
699 std::string getName(ArrayRef<StringRef> Parts) const;
700
701 /// Emit code for the specified user defined reduction construct.
704 /// Get combiner/initializer for the specified user-defined reduction, if any.
705 virtual std::pair<llvm::Function *, llvm::Function *>
707
708 /// Emit the function for the user defined mapper construct.
710 CodeGenFunction *CGF = nullptr);
711 /// Get the function for the specified user-defined mapper. If it does not
712 /// exist, create one.
713 llvm::Function *
715
716 /// Emits outlined function for the specified OpenMP parallel directive
717 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
718 /// kmp_int32 BoundID, struct context_vars*).
719 /// \param CGF Reference to current CodeGenFunction.
720 /// \param D OpenMP directive.
721 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
722 /// \param InnermostKind Kind of innermost directive (for simple directives it
723 /// is a directive itself, for combined - its innermost directive).
724 /// \param CodeGen Code generation sequence for the \a D directive.
725 virtual llvm::Function *emitParallelOutlinedFunction(
727 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
728 const RegionCodeGenTy &CodeGen);
729
730 /// Emits outlined function for the specified OpenMP teams directive
731 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
732 /// kmp_int32 BoundID, struct context_vars*).
733 /// \param CGF Reference to current CodeGenFunction.
734 /// \param D OpenMP directive.
735 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
736 /// \param InnermostKind Kind of innermost directive (for simple directives it
737 /// is a directive itself, for combined - its innermost directive).
738 /// \param CodeGen Code generation sequence for the \a D directive.
739 virtual llvm::Function *emitTeamsOutlinedFunction(
741 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
742 const RegionCodeGenTy &CodeGen);
743
744 /// Emits outlined function for the OpenMP task directive \a D. This
745 /// outlined function has type void(*)(kmp_int32 ThreadID, struct task_t*
746 /// TaskT).
747 /// \param D OpenMP directive.
748 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
749 /// \param PartIDVar Variable for partition id in the current OpenMP untied
750 /// task region.
751 /// \param TaskTVar Variable for task_t argument.
752 /// \param InnermostKind Kind of innermost directive (for simple directives it
753 /// is a directive itself, for combined - its innermost directive).
754 /// \param CodeGen Code generation sequence for the \a D directive.
755 /// \param Tied true if task is generated for tied task, false otherwise.
756 /// \param NumberOfParts Number of parts in untied task. Ignored for tied
757 /// tasks.
758 ///
759 virtual llvm::Function *emitTaskOutlinedFunction(
760 const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
761 const VarDecl *PartIDVar, const VarDecl *TaskTVar,
762 OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen,
763 bool Tied, unsigned &NumberOfParts);
764
765 /// Cleans up references to the objects in finished function.
766 ///
767 virtual void functionFinished(CodeGenFunction &CGF);
768
769 /// Emits code for parallel or serial call of the \a OutlinedFn with
770 /// variables captured in a record which address is stored in \a
771 /// CapturedStruct.
772 /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
773 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
774 /// \param CapturedVars A pointer to the record with the references to
775 /// variables used in \a OutlinedFn function.
776 /// \param IfCond Condition in the associated 'if' clause, if it was
777 /// specified, nullptr otherwise.
778 /// \param NumThreads The value corresponding to the num_threads clause, if
779 /// any, or nullptr.
780 /// \param NumThreadsModifier The modifier of the num_threads clause, if
781 /// any, ignored otherwise.
782 /// \param Severity The severity corresponding to the num_threads clause, if
783 /// any, ignored otherwise.
784 /// \param Message The message string corresponding to the num_threads clause,
785 /// if any, or nullptr.
786 ///
787 virtual void
789 llvm::Function *OutlinedFn,
790 ArrayRef<llvm::Value *> CapturedVars, const Expr *IfCond,
791 llvm::Value *NumThreads,
792 OpenMPNumThreadsClauseModifier NumThreadsModifier =
794 OpenMPSeverityClauseKind Severity = OMPC_SEVERITY_fatal,
795 const Expr *Message = nullptr);
796
797 /// Emits a critical region.
798 /// \param CriticalName Name of the critical region.
799 /// \param CriticalOpGen Generator for the statement associated with the given
800 /// critical region.
801 /// \param Hint Value of the 'hint' clause (optional).
802 virtual void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
803 const RegionCodeGenTy &CriticalOpGen,
805 const Expr *Hint = nullptr);
806
807 /// Emits a master region.
808 /// \param MasterOpGen Generator for the statement associated with the given
809 /// master region.
810 virtual void emitMasterRegion(CodeGenFunction &CGF,
811 const RegionCodeGenTy &MasterOpGen,
813
814 /// Emits a masked region.
815 /// \param MaskedOpGen Generator for the statement associated with the given
816 /// masked region.
817 virtual void emitMaskedRegion(CodeGenFunction &CGF,
818 const RegionCodeGenTy &MaskedOpGen,
820 const Expr *Filter = nullptr);
821
822 /// Emits code for a taskyield directive.
824
825 /// Emit __kmpc_error call for error directive
826 /// extern void __kmpc_error(ident_t *loc, int severity, const char *message);
827 virtual void emitErrorCall(CodeGenFunction &CGF, SourceLocation Loc, Expr *ME,
828 bool IsFatal);
829
830 /// Emit a taskgroup region.
831 /// \param TaskgroupOpGen Generator for the statement associated with the
832 /// given taskgroup region.
833 virtual void emitTaskgroupRegion(CodeGenFunction &CGF,
834 const RegionCodeGenTy &TaskgroupOpGen,
836
837 /// Emits a single region.
838 /// \param SingleOpGen Generator for the statement associated with the given
839 /// single region.
840 virtual void emitSingleRegion(CodeGenFunction &CGF,
841 const RegionCodeGenTy &SingleOpGen,
843 ArrayRef<const Expr *> CopyprivateVars,
844 ArrayRef<const Expr *> DestExprs,
845 ArrayRef<const Expr *> SrcExprs,
846 ArrayRef<const Expr *> AssignmentOps);
847
848 /// Emit an ordered region.
849 /// \param OrderedOpGen Generator for the statement associated with the given
850 /// ordered region.
851 virtual void emitOrderedRegion(CodeGenFunction &CGF,
852 const RegionCodeGenTy &OrderedOpGen,
853 SourceLocation Loc, bool IsThreads);
854
855 /// Emit an implicit/explicit barrier for OpenMP threads.
856 /// \param Kind Directive for which this implicit barrier call must be
857 /// generated. Must be OMPD_barrier for explicit barrier generation.
858 /// \param EmitChecks true if need to emit checks for cancellation barriers.
859 /// \param ForceSimpleCall true simple barrier call must be emitted, false if
860 /// runtime class decides which one to emit (simple or with cancellation
861 /// checks).
862 ///
865 bool EmitChecks = true,
866 bool ForceSimpleCall = false);
867
868 /// Check if the specified \a ScheduleKind is static non-chunked.
869 /// This kind of worksharing directive is emitted without outer loop.
870 /// \param ScheduleKind Schedule kind specified in the 'schedule' clause.
871 /// \param Chunked True if chunk is specified in the clause.
872 ///
873 virtual bool isStaticNonchunked(OpenMPScheduleClauseKind ScheduleKind,
874 bool Chunked) const;
875
876 /// Check if the specified \a ScheduleKind is static non-chunked.
877 /// This kind of distribute directive is emitted without outer loop.
878 /// \param ScheduleKind Schedule kind specified in the 'dist_schedule' clause.
879 /// \param Chunked True if chunk is specified in the clause.
880 ///
881 virtual bool isStaticNonchunked(OpenMPDistScheduleClauseKind ScheduleKind,
882 bool Chunked) const;
883
884 /// Check if the specified \a ScheduleKind is static chunked.
885 /// \param ScheduleKind Schedule kind specified in the 'schedule' clause.
886 /// \param Chunked True if chunk is specified in the clause.
887 ///
888 virtual bool isStaticChunked(OpenMPScheduleClauseKind ScheduleKind,
889 bool Chunked) const;
890
891 /// Check if the specified \a ScheduleKind is static non-chunked.
892 /// \param ScheduleKind Schedule kind specified in the 'dist_schedule' clause.
893 /// \param Chunked True if chunk is specified in the clause.
894 ///
895 virtual bool isStaticChunked(OpenMPDistScheduleClauseKind ScheduleKind,
896 bool Chunked) const;
897
898 /// Check if the specified \a ScheduleKind is dynamic.
899 /// This kind of worksharing directive is emitted without outer loop.
900 /// \param ScheduleKind Schedule Kind specified in the 'schedule' clause.
901 ///
902 virtual bool isDynamic(OpenMPScheduleClauseKind ScheduleKind) const;
903
904 /// struct with the values to be passed to the dispatch runtime function
906 /// Loop lower bound
907 llvm::Value *LB = nullptr;
908 /// Loop upper bound
909 llvm::Value *UB = nullptr;
910 /// Chunk size specified using 'schedule' clause (nullptr if chunk
911 /// was not specified)
912 llvm::Value *Chunk = nullptr;
913 DispatchRTInput() = default;
914 DispatchRTInput(llvm::Value *LB, llvm::Value *UB, llvm::Value *Chunk)
915 : LB(LB), UB(UB), Chunk(Chunk) {}
916 };
917
918 /// Call the appropriate runtime routine to initialize it before start
919 /// of loop.
920
921 /// This is used for non static scheduled types and when the ordered
922 /// clause is present on the loop construct.
923 /// Depending on the loop schedule, it is necessary to call some runtime
924 /// routine before start of the OpenMP loop to get the loop upper / lower
925 /// bounds \a LB and \a UB and stride \a ST.
926 ///
927 /// \param CGF Reference to current CodeGenFunction.
928 /// \param Loc Clang source location.
929 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
930 /// \param IVSize Size of the iteration variable in bits.
931 /// \param IVSigned Sign of the iteration variable.
932 /// \param Ordered true if loop is ordered, false otherwise.
933 /// \param DispatchValues struct containing llvm values for lower bound, upper
934 /// bound, and chunk expression.
935 /// For the default (nullptr) value, the chunk 1 will be used.
936 ///
938 const OpenMPScheduleTy &ScheduleKind,
939 unsigned IVSize, bool IVSigned, bool Ordered,
940 const DispatchRTInput &DispatchValues);
941
942 /// This is used for non static scheduled types and when the ordered
943 /// clause is present on the loop construct.
944 ///
945 /// \param CGF Reference to current CodeGenFunction.
946 /// \param Loc Clang source location.
947 ///
949
950 /// Struct with the values to be passed to the static runtime function
952 /// Size of the iteration variable in bits.
953 unsigned IVSize = 0;
954 /// Sign of the iteration variable.
955 bool IVSigned = false;
956 /// true if loop is ordered, false otherwise.
957 bool Ordered = false;
958 /// Address of the output variable in which the flag of the last iteration
959 /// is returned.
961 /// Address of the output variable in which the lower iteration number is
962 /// returned.
964 /// Address of the output variable in which the upper iteration number is
965 /// returned.
967 /// Address of the output variable in which the stride value is returned
968 /// necessary to generated the static_chunked scheduled loop.
970 /// Value of the chunk for the static_chunked scheduled loop. For the
971 /// default (nullptr) value, the chunk 1 will be used.
972 llvm::Value *Chunk = nullptr;
975 llvm::Value *Chunk = nullptr)
977 UB(UB), ST(ST), Chunk(Chunk) {}
978 };
979 /// Call the appropriate runtime routine to initialize it before start
980 /// of loop.
981 ///
982 /// This is used only in case of static schedule, when the user did not
983 /// specify a ordered clause on the loop construct.
984 /// Depending on the loop schedule, it is necessary to call some runtime
985 /// routine before start of the OpenMP loop to get the loop upper / lower
986 /// bounds LB and UB and stride ST.
987 ///
988 /// \param CGF Reference to current CodeGenFunction.
989 /// \param Loc Clang source location.
990 /// \param DKind Kind of the directive.
991 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
992 /// \param Values Input arguments for the construct.
993 ///
996 const OpenMPScheduleTy &ScheduleKind,
997 const StaticRTInput &Values);
998
999 ///
1000 /// \param CGF Reference to current CodeGenFunction.
1001 /// \param Loc Clang source location.
1002 /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
1003 /// \param Values Input arguments for the construct.
1004 ///
1005 virtual void emitDistributeStaticInit(CodeGenFunction &CGF,
1008 const StaticRTInput &Values);
1009
1010 /// Call the appropriate runtime routine to notify that we finished
1011 /// iteration of the ordered loop with the dynamic scheduling.
1012 ///
1013 /// \param CGF Reference to current CodeGenFunction.
1014 /// \param Loc Clang source location.
1015 /// \param IVSize Size of the iteration variable in bits.
1016 /// \param IVSigned Sign of the iteration variable.
1017 ///
1019 SourceLocation Loc, unsigned IVSize,
1020 bool IVSigned);
1021
1022 /// Call the appropriate runtime routine to notify that we finished
1023 /// all the work with current loop.
1024 ///
1025 /// \param CGF Reference to current CodeGenFunction.
1026 /// \param Loc Clang source location.
1027 /// \param DKind Kind of the directive for which the static finish is emitted.
1028 ///
1030 OpenMPDirectiveKind DKind);
1031
1032 /// Call __kmpc_dispatch_next(
1033 /// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter,
1034 /// kmp_int[32|64] *p_lower, kmp_int[32|64] *p_upper,
1035 /// kmp_int[32|64] *p_stride);
1036 /// \param IVSize Size of the iteration variable in bits.
1037 /// \param IVSigned Sign of the iteration variable.
1038 /// \param IL Address of the output variable in which the flag of the
1039 /// last iteration is returned.
1040 /// \param LB Address of the output variable in which the lower iteration
1041 /// number is returned.
1042 /// \param UB Address of the output variable in which the upper iteration
1043 /// number is returned.
1044 /// \param ST Address of the output variable in which the stride value is
1045 /// returned.
1046 virtual llvm::Value *emitForNext(CodeGenFunction &CGF, SourceLocation Loc,
1047 unsigned IVSize, bool IVSigned,
1048 Address IL, Address LB,
1049 Address UB, Address ST);
1050
1051 virtual llvm::Value *emitMessageClause(CodeGenFunction &CGF,
1052 const Expr *Message);
1053 virtual llvm::Value *emitMessageClause(CodeGenFunction &CGF,
1054 const OMPMessageClause *MessageClause);
1055
1056 virtual llvm::Value *emitSeverityClause(OpenMPSeverityClauseKind Severity);
1057 virtual llvm::Value *
1058 emitSeverityClause(const OMPSeverityClause *SeverityClause);
1059
1060 /// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
1061 /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
1062 /// clause.
1063 /// If the modifier 'strict' is given:
1064 /// Emits call to void __kmpc_push_num_threads_strict(ident_t *loc, kmp_int32
1065 /// global_tid, kmp_int32 num_threads, int severity, const char *message) to
1066 /// generate code for 'num_threads' clause with 'strict' modifier.
1067 /// \param NumThreads An integer value of threads.
1068 virtual void emitNumThreadsClause(
1069 CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc,
1071 OpenMPSeverityClauseKind Severity = OMPC_SEVERITY_fatal,
1072 const Expr *Message = nullptr);
1073
1074 /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
1075 /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
1076 virtual void emitProcBindClause(CodeGenFunction &CGF,
1077 llvm::omp::ProcBindKind ProcBind,
1079
1080 /// Returns address of the threadprivate variable for the current
1081 /// thread.
1082 /// \param VD Threadprivate variable.
1083 /// \param VDAddr Address of the global variable \a VD.
1084 /// \param Loc Location of the reference to threadprivate var.
1085 /// \return Address of the threadprivate variable for the current thread.
1087 const VarDecl *VD, Address VDAddr,
1089
1090 /// Returns the address of the variable marked as declare target with link
1091 /// clause OR as declare target with to clause and unified memory.
1093
1094 /// Emit a code for initialization of threadprivate variable. It emits
1095 /// a call to runtime library which adds initial value to the newly created
1096 /// threadprivate variable (if it is not constant) and registers destructor
1097 /// for the variable (if any).
1098 /// \param VD Threadprivate variable.
1099 /// \param VDAddr Address of the global variable \a VD.
1100 /// \param Loc Location of threadprivate declaration.
1101 /// \param PerformInit true if initialization expression is not constant.
1102 virtual llvm::Function *
1104 SourceLocation Loc, bool PerformInit,
1105 CodeGenFunction *CGF = nullptr);
1106
1107 /// Emit code for handling declare target functions in the runtime.
1108 /// \param FD Declare target function.
1109 /// \param Addr Address of the global \a FD.
1110 /// \param PerformInit true if initialization expression is not constant.
1111 virtual void emitDeclareTargetFunction(const FunctionDecl *FD,
1112 llvm::GlobalValue *GV);
1113
1114 /// Creates artificial threadprivate variable with name \p Name and type \p
1115 /// VarType.
1116 /// \param VarType Type of the artificial threadprivate variable.
1117 /// \param Name Name of the artificial threadprivate variable.
1119 QualType VarType,
1120 StringRef Name);
1121
1122 /// Emit flush of the variables specified in 'omp flush' directive.
1123 /// \param Vars List of variables to flush.
1124 virtual void emitFlush(CodeGenFunction &CGF, ArrayRef<const Expr *> Vars,
1125 SourceLocation Loc, llvm::AtomicOrdering AO);
1126
1127 /// Emit task region for the task directive. The task region is
1128 /// emitted in several steps:
1129 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1130 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1131 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1132 /// function:
1133 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1134 /// TaskFunction(gtid, tt->part_id, tt->shareds);
1135 /// return 0;
1136 /// }
1137 /// 2. Copy a list of shared variables to field shareds of the resulting
1138 /// structure kmp_task_t returned by the previous call (if any).
1139 /// 3. Copy a pointer to destructions function to field destructions of the
1140 /// resulting structure kmp_task_t.
1141 /// 4. Emit a call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid,
1142 /// kmp_task_t *new_task), where new_task is a resulting structure from
1143 /// previous items.
1144 /// \param D Current task directive.
1145 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
1146 /// /*part_id*/, captured_struct */*__context*/);
1147 /// \param SharedsTy A type which contains references the shared variables.
1148 /// \param Shareds Context with the list of shared variables from the \p
1149 /// TaskFunction.
1150 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
1151 /// otherwise.
1152 /// \param Data Additional data for task generation like tiednsee, final
1153 /// state, list of privates etc.
1156 llvm::Function *TaskFunction, QualType SharedsTy,
1157 Address Shareds, const Expr *IfCond,
1158 const OMPTaskDataTy &Data);
1159
1160 /// Emit task region for the taskloop directive. The taskloop region is
1161 /// emitted in several steps:
1162 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
1163 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
1164 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
1165 /// function:
1166 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
1167 /// TaskFunction(gtid, tt->part_id, tt->shareds);
1168 /// return 0;
1169 /// }
1170 /// 2. Copy a list of shared variables to field shareds of the resulting
1171 /// structure kmp_task_t returned by the previous call (if any).
1172 /// 3. Copy a pointer to destructions function to field destructions of the
1173 /// resulting structure kmp_task_t.
1174 /// 4. Emit a call to void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t
1175 /// *task, int if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int
1176 /// nogroup, int sched, kmp_uint64 grainsize, void *task_dup ), where new_task
1177 /// is a resulting structure from
1178 /// previous items.
1179 /// \param D Current task directive.
1180 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
1181 /// /*part_id*/, captured_struct */*__context*/);
1182 /// \param SharedsTy A type which contains references the shared variables.
1183 /// \param Shareds Context with the list of shared variables from the \p
1184 /// TaskFunction.
1185 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
1186 /// otherwise.
1187 /// \param Data Additional data for task generation like tiednsee, final
1188 /// state, list of privates etc.
1190 const OMPLoopDirective &D,
1191 llvm::Function *TaskFunction,
1192 QualType SharedsTy, Address Shareds,
1193 const Expr *IfCond, const OMPTaskDataTy &Data);
1194
1195 /// Emit code for the directive that does not require outlining.
1196 ///
1197 /// \param InnermostKind Kind of innermost directive (for simple directives it
1198 /// is a directive itself, for combined - its innermost directive).
1199 /// \param CodeGen Code generation sequence for the \a D directive.
1200 /// \param HasCancel true if region has inner cancel directive, false
1201 /// otherwise.
1202 virtual void emitInlinedDirective(CodeGenFunction &CGF,
1203 OpenMPDirectiveKind InnermostKind,
1204 const RegionCodeGenTy &CodeGen,
1205 bool HasCancel = false);
1206
1207 /// Emits reduction function.
1208 /// \param ReducerName Name of the function calling the reduction.
1209 /// \param ArgsElemType Array type containing pointers to reduction variables.
1210 /// \param Privates List of private copies for original reduction arguments.
1211 /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
1212 /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
1213 /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
1214 /// or 'operator binop(LHS, RHS)'.
1215 llvm::Function *emitReductionFunction(
1216 StringRef ReducerName, SourceLocation Loc, llvm::Type *ArgsElemType,
1218 ArrayRef<const Expr *> RHSExprs, ArrayRef<const Expr *> ReductionOps);
1219
1220 /// Emits single reduction combiner
1222 const Expr *ReductionOp,
1223 const Expr *PrivateRef,
1224 const DeclRefExpr *LHS,
1225 const DeclRefExpr *RHS);
1226
1232 };
1233
1234 /// Emits code for private variable reduction
1235 /// \param Privates List of private copies for original reduction arguments.
1236 /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
1237 /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
1238 /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
1239 /// or 'operator binop(LHS, RHS)'.
1241 const Expr *Privates, const Expr *LHSExprs,
1242 const Expr *RHSExprs, const Expr *ReductionOps);
1243
1244 /// Emit a code for reduction clause. Next code should be emitted for
1245 /// reduction:
1246 /// \code
1247 ///
1248 /// static kmp_critical_name lock = { 0 };
1249 ///
1250 /// void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
1251 /// ...
1252 /// *(Type<i>*)lhs[i] = RedOp<i>(*(Type<i>*)lhs[i], *(Type<i>*)rhs[i]);
1253 /// ...
1254 /// }
1255 ///
1256 /// ...
1257 /// void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
1258 /// switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList),
1259 /// RedList, reduce_func, &<lock>)) {
1260 /// case 1:
1261 /// ...
1262 /// <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]);
1263 /// ...
1264 /// __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
1265 /// break;
1266 /// case 2:
1267 /// ...
1268 /// Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]));
1269 /// ...
1270 /// break;
1271 /// default:;
1272 /// }
1273 /// \endcode
1274 ///
1275 /// \param Privates List of private copies for original reduction arguments.
1276 /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
1277 /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
1278 /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
1279 /// or 'operator binop(LHS, RHS)'.
1280 /// \param Options List of options for reduction codegen:
1281 /// WithNowait true if parent directive has also nowait clause, false
1282 /// otherwise.
1283 /// SimpleReduction Emit reduction operation only. Used for omp simd
1284 /// directive on the host.
1285 /// ReductionKind The kind of reduction to perform.
1287 ArrayRef<const Expr *> Privates,
1288 ArrayRef<const Expr *> LHSExprs,
1289 ArrayRef<const Expr *> RHSExprs,
1290 ArrayRef<const Expr *> ReductionOps,
1291 ReductionOptionsTy Options);
1292
1293 /// Emit a code for initialization of task reduction clause. Next code
1294 /// should be emitted for reduction:
1295 /// \code
1296 ///
1297 /// _taskred_item_t red_data[n];
1298 /// ...
1299 /// red_data[i].shar = &shareds[i];
1300 /// red_data[i].orig = &origs[i];
1301 /// red_data[i].size = sizeof(origs[i]);
1302 /// red_data[i].f_init = (void*)RedInit<i>;
1303 /// red_data[i].f_fini = (void*)RedDest<i>;
1304 /// red_data[i].f_comb = (void*)RedOp<i>;
1305 /// red_data[i].flags = <Flag_i>;
1306 /// ...
1307 /// void* tg1 = __kmpc_taskred_init(gtid, n, red_data);
1308 /// \endcode
1309 /// For reduction clause with task modifier it emits the next call:
1310 /// \code
1311 ///
1312 /// _taskred_item_t red_data[n];
1313 /// ...
1314 /// red_data[i].shar = &shareds[i];
1315 /// red_data[i].orig = &origs[i];
1316 /// red_data[i].size = sizeof(origs[i]);
1317 /// red_data[i].f_init = (void*)RedInit<i>;
1318 /// red_data[i].f_fini = (void*)RedDest<i>;
1319 /// red_data[i].f_comb = (void*)RedOp<i>;
1320 /// red_data[i].flags = <Flag_i>;
1321 /// ...
1322 /// void* tg1 = __kmpc_taskred_modifier_init(loc, gtid, is_worksharing, n,
1323 /// red_data);
1324 /// \endcode
1325 /// \param LHSExprs List of LHS in \a Data.ReductionOps reduction operations.
1326 /// \param RHSExprs List of RHS in \a Data.ReductionOps reduction operations.
1327 /// \param Data Additional data for task generation like tiedness, final
1328 /// state, list of privates, reductions etc.
1329 virtual llvm::Value *emitTaskReductionInit(CodeGenFunction &CGF,
1331 ArrayRef<const Expr *> LHSExprs,
1332 ArrayRef<const Expr *> RHSExprs,
1333 const OMPTaskDataTy &Data);
1334
1335 /// Emits the following code for reduction clause with task modifier:
1336 /// \code
1337 /// __kmpc_task_reduction_modifier_fini(loc, gtid, is_worksharing);
1338 /// \endcode
1340 bool IsWorksharingReduction);
1341
1342 /// Required to resolve existing problems in the runtime. Emits threadprivate
1343 /// variables to store the size of the VLAs/array sections for
1344 /// initializer/combiner/finalizer functions.
1345 /// \param RCG Allows to reuse an existing data for the reductions.
1346 /// \param N Reduction item for which fixups must be emitted.
1348 ReductionCodeGen &RCG, unsigned N);
1349
1350 /// Get the address of `void *` type of the privatue copy of the reduction
1351 /// item specified by the \p SharedLVal.
1352 /// \param ReductionsPtr Pointer to the reduction data returned by the
1353 /// emitTaskReductionInit function.
1354 /// \param SharedLVal Address of the original reduction item.
1356 llvm::Value *ReductionsPtr,
1357 LValue SharedLVal);
1358
1359 /// Emit code for 'taskwait' directive.
1361 const OMPTaskDataTy &Data);
1362
1363 /// Emit code for 'cancellation point' construct.
1364 /// \param CancelRegion Region kind for which the cancellation point must be
1365 /// emitted.
1366 ///
1369 OpenMPDirectiveKind CancelRegion);
1370
1371 /// Emit code for 'cancel' construct.
1372 /// \param IfCond Condition in the associated 'if' clause, if it was
1373 /// specified, nullptr otherwise.
1374 /// \param CancelRegion Region kind for which the cancel must be emitted.
1375 ///
1377 const Expr *IfCond,
1378 OpenMPDirectiveKind CancelRegion);
1379
1380 /// Emit outilined function for 'target' directive.
1381 /// \param D Directive to emit.
1382 /// \param ParentName Name of the function that encloses the target region.
1383 /// \param OutlinedFn Outlined function value to be defined by this call.
1384 /// \param OutlinedFnID Outlined function ID value to be defined by this call.
1385 /// \param IsOffloadEntry True if the outlined function is an offload entry.
1386 /// \param CodeGen Code generation sequence for the \a D directive.
1387 /// An outlined function may not be an entry if, e.g. the if clause always
1388 /// evaluates to false.
1390 StringRef ParentName,
1391 llvm::Function *&OutlinedFn,
1392 llvm::Constant *&OutlinedFnID,
1393 bool IsOffloadEntry,
1394 const RegionCodeGenTy &CodeGen);
1395
1396 /// Emit the target offloading code associated with \a D. The emitted
1397 /// code attempts offloading the execution to the device, an the event of
1398 /// a failure it executes the host version outlined in \a OutlinedFn.
1399 /// \param D Directive to emit.
1400 /// \param OutlinedFn Host version of the code to be offloaded.
1401 /// \param OutlinedFnID ID of host version of the code to be offloaded.
1402 /// \param IfCond Expression evaluated in if clause associated with the target
1403 /// directive, or null if no if clause is used.
1404 /// \param Device Expression evaluated in device clause associated with the
1405 /// target directive, or null if no device clause is used and device modifier.
1406 /// \param SizeEmitter Callback to emit number of iterations for loop-based
1407 /// directives.
1408 virtual void emitTargetCall(
1410 llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond,
1411 llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
1412 llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
1413 const OMPLoopDirective &D)>
1414 SizeEmitter);
1415
1416 /// Emit the target regions enclosed in \a GD function definition or
1417 /// the function itself in case it is a valid device function. Returns true if
1418 /// \a GD was dealt with successfully.
1419 /// \param GD Function to scan.
1420 virtual bool emitTargetFunctions(GlobalDecl GD);
1421
1422 /// Emit the global variable if it is a valid device global variable.
1423 /// Returns true if \a GD was dealt with successfully.
1424 /// \param GD Variable declaration to emit.
1425 virtual bool emitTargetGlobalVariable(GlobalDecl GD);
1426
1427 /// Checks if the provided global decl \a GD is a declare target variable and
1428 /// registers it when emitting code for the host.
1429 virtual void registerTargetGlobalVariable(const VarDecl *VD,
1430 llvm::Constant *Addr);
1431
1432 /// Emit the global \a GD if it is meaningful for the target. Returns
1433 /// if it was emitted successfully.
1434 /// \param GD Global to scan.
1435 virtual bool emitTargetGlobal(GlobalDecl GD);
1436
1437 /// Creates all the offload entries in the current compilation unit
1438 /// along with the associated metadata.
1440
1441 /// Emits code for teams call of the \a OutlinedFn with
1442 /// variables captured in a record which address is stored in \a
1443 /// CapturedStruct.
1444 /// \param OutlinedFn Outlined function to be run by team masters. Type of
1445 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
1446 /// \param CapturedVars A pointer to the record with the references to
1447 /// variables used in \a OutlinedFn function.
1448 ///
1449 virtual void emitTeamsCall(CodeGenFunction &CGF,
1451 SourceLocation Loc, llvm::Function *OutlinedFn,
1452 ArrayRef<llvm::Value *> CapturedVars);
1453
1454 /// Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32
1455 /// global_tid, kmp_int32 num_teams, kmp_int32 thread_limit) to generate code
1456 /// for num_teams clause.
1457 /// \param NumTeams An integer expression of teams.
1458 /// \param ThreadLimit An integer expression of threads.
1459 virtual void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams,
1460 const Expr *ThreadLimit, SourceLocation Loc);
1461
1462 /// Emits call to void __kmpc_set_thread_limit(ident_t *loc, kmp_int32
1463 /// global_tid, kmp_int32 thread_limit) to generate code for
1464 /// thread_limit clause on target directive
1465 /// \param ThreadLimit An integer expression of threads.
1466 virtual void emitThreadLimitClause(CodeGenFunction &CGF,
1467 const Expr *ThreadLimit,
1469
1470 /// Struct that keeps all the relevant information that should be kept
1471 /// throughout a 'target data' region.
1473 public:
1474 explicit TargetDataInfo() : llvm::OpenMPIRBuilder::TargetDataInfo() {}
1475 explicit TargetDataInfo(bool RequiresDevicePointerInfo,
1476 bool SeparateBeginEndCalls)
1477 : llvm::OpenMPIRBuilder::TargetDataInfo(RequiresDevicePointerInfo,
1478 SeparateBeginEndCalls) {}
1479 /// Map between the a declaration of a capture and the corresponding new
1480 /// llvm address where the runtime returns the device pointers.
1481 llvm::DenseMap<const ValueDecl *, llvm::Value *> CaptureDeviceAddrMap;
1482 };
1483
1484 /// Emit the target data mapping code associated with \a D.
1485 /// \param D Directive to emit.
1486 /// \param IfCond Expression evaluated in if clause associated with the
1487 /// target directive, or null if no device clause is used.
1488 /// \param Device Expression evaluated in device clause associated with the
1489 /// target directive, or null if no device clause is used.
1490 /// \param Info A record used to store information that needs to be preserved
1491 /// until the region is closed.
1492 virtual void emitTargetDataCalls(CodeGenFunction &CGF,
1494 const Expr *IfCond, const Expr *Device,
1495 const RegionCodeGenTy &CodeGen,
1497
1498 /// Emit the data mapping/movement code associated with the directive
1499 /// \a D that should be of the form 'target [{enter|exit} data | update]'.
1500 /// \param D Directive to emit.
1501 /// \param IfCond Expression evaluated in if clause associated with the target
1502 /// directive, or null if no if clause is used.
1503 /// \param Device Expression evaluated in device clause associated with the
1504 /// target directive, or null if no device clause is used.
1507 const Expr *IfCond,
1508 const Expr *Device);
1509
1510 /// Marks function \a Fn with properly mangled versions of vector functions.
1511 /// \param FD Function marked as 'declare simd'.
1512 /// \param Fn LLVM function that must be marked with 'declare simd'
1513 /// attributes.
1514 virtual void emitDeclareSimdFunction(const FunctionDecl *FD,
1515 llvm::Function *Fn);
1516
1517 /// Emit initialization for doacross loop nesting support.
1518 /// \param D Loop-based construct used in doacross nesting construct.
1519 virtual void emitDoacrossInit(CodeGenFunction &CGF, const OMPLoopDirective &D,
1520 ArrayRef<Expr *> NumIterations);
1521
1522 /// Emit code for doacross ordered directive with 'depend' clause.
1523 /// \param C 'depend' clause with 'sink|source' dependency kind.
1524 virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
1525 const OMPDependClause *C);
1526
1527 /// Emit code for doacross ordered directive with 'doacross' clause.
1528 /// \param C 'doacross' clause with 'sink|source' dependence type.
1529 virtual void emitDoacrossOrdered(CodeGenFunction &CGF,
1530 const OMPDoacrossClause *C);
1531
1532 /// Translates the native parameter of outlined function if this is required
1533 /// for target.
1534 /// \param FD Field decl from captured record for the parameter.
1535 /// \param NativeParam Parameter itself.
1536 virtual const VarDecl *translateParameter(const FieldDecl *FD,
1537 const VarDecl *NativeParam) const {
1538 return NativeParam;
1539 }
1540
1541 /// Gets the address of the native argument basing on the address of the
1542 /// target-specific parameter.
1543 /// \param NativeParam Parameter itself.
1544 /// \param TargetParam Corresponding target-specific parameter.
1546 const VarDecl *NativeParam,
1547 const VarDecl *TargetParam) const;
1548
1549 /// Choose default schedule type and chunk value for the
1550 /// dist_schedule clause.
1552 const OMPLoopDirective &S, OpenMPDistScheduleClauseKind &ScheduleKind,
1553 llvm::Value *&Chunk) const {}
1554
1555 /// Choose default schedule type and chunk value for the
1556 /// schedule clause.
1558 const OMPLoopDirective &S, OpenMPScheduleClauseKind &ScheduleKind,
1559 const Expr *&ChunkExpr) const;
1560
1561 /// Emits call of the outlined function with the provided arguments,
1562 /// translating these arguments to correct target-specific arguments.
1563 virtual void
1565 llvm::FunctionCallee OutlinedFn,
1566 ArrayRef<llvm::Value *> Args = {}) const;
1567
1568 /// Emits OpenMP-specific function prolog.
1569 /// Required for device constructs.
1570 virtual void emitFunctionProlog(CodeGenFunction &CGF, const Decl *D);
1571
1572 /// Gets the OpenMP-specific address of the local variable.
1573 virtual Address getAddressOfLocalVariable(CodeGenFunction &CGF,
1574 const VarDecl *VD);
1575
1576 /// Marks the declaration as already emitted for the device code and returns
1577 /// true, if it was marked already, and false, otherwise.
1579
1580 /// Emit deferred declare target variables marked for deferred emission.
1581 void emitDeferredTargetDecls() const;
1582
1583 /// Adjust some parameters for the target-based directives, like addresses of
1584 /// the variables captured by reference in lambdas.
1585 virtual void
1586 adjustTargetSpecificDataForLambdas(CodeGenFunction &CGF,
1587 const OMPExecutableDirective &D) const;
1588
1589 /// Perform check on requires decl to ensure that target architecture
1590 /// supports unified addressing
1591 virtual void processRequiresDirective(const OMPRequiresDecl *D);
1592
1593 /// Gets default memory ordering as specified in requires directive.
1594 llvm::AtomicOrdering getDefaultMemoryOrdering() const;
1595
1596 /// Checks if the variable has associated OMPAllocateDeclAttr attribute with
1597 /// the predefined allocator and translates it into the corresponding address
1598 /// space.
1599 virtual bool hasAllocateAttributeForGlobalVar(const VarDecl *VD, LangAS &AS);
1600
1601 /// Return whether the unified_shared_memory has been specified.
1602 bool hasRequiresUnifiedSharedMemory() const;
1603
1604 /// Checks if the \p VD variable is marked as nontemporal declaration in
1605 /// current context.
1606 bool isNontemporalDecl(const ValueDecl *VD) const;
1607
1608 /// Create specialized alloca to handle lastprivate conditionals.
1609 Address emitLastprivateConditionalInit(CodeGenFunction &CGF,
1610 const VarDecl *VD);
1611
1612 /// Checks if the provided \p LVal is lastprivate conditional and emits the
1613 /// code to update the value of the original variable.
1614 /// \code
1615 /// lastprivate(conditional: a)
1616 /// ...
1617 /// <type> a;
1618 /// lp_a = ...;
1619 /// #pragma omp critical(a)
1620 /// if (last_iv_a <= iv) {
1621 /// last_iv_a = iv;
1622 /// global_a = lp_a;
1623 /// }
1624 /// \endcode
1625 virtual void checkAndEmitLastprivateConditional(CodeGenFunction &CGF,
1626 const Expr *LHS);
1627
1628 /// Checks if the lastprivate conditional was updated in inner region and
1629 /// writes the value.
1630 /// \code
1631 /// lastprivate(conditional: a)
1632 /// ...
1633 /// <type> a;bool Fired = false;
1634 /// #pragma omp ... shared(a)
1635 /// {
1636 /// lp_a = ...;
1637 /// Fired = true;
1638 /// }
1639 /// if (Fired) {
1640 /// #pragma omp critical(a)
1641 /// if (last_iv_a <= iv) {
1642 /// last_iv_a = iv;
1643 /// global_a = lp_a;
1644 /// }
1645 /// Fired = false;
1646 /// }
1647 /// \endcode
1649 CodeGenFunction &CGF, const OMPExecutableDirective &D,
1650 const llvm::DenseSet<CanonicalDeclPtr<const VarDecl>> &IgnoredDecls);
1651
1652 /// Gets the address of the global copy used for lastprivate conditional
1653 /// update, if any.
1654 /// \param PrivLVal LValue for the private copy.
1655 /// \param VD Original lastprivate declaration.
1656 virtual void emitLastprivateConditionalFinalUpdate(CodeGenFunction &CGF,
1657 LValue PrivLVal,
1658 const VarDecl *VD,
1660
1661 /// Emits list of dependecies based on the provided data (array of
1662 /// dependence/expression pairs).
1663 /// \returns Pointer to the first element of the array casted to VoidPtr type.
1664 std::pair<llvm::Value *, Address>
1665 emitDependClause(CodeGenFunction &CGF,
1668
1669 /// Emits list of dependecies based on the provided data (array of
1670 /// dependence/expression pairs) for depobj construct. In this case, the
1671 /// variable is allocated in dynamically. \returns Pointer to the first
1672 /// element of the array casted to VoidPtr type.
1673 Address emitDepobjDependClause(CodeGenFunction &CGF,
1674 const OMPTaskDataTy::DependData &Dependencies,
1676
1677 /// Emits the code to destroy the dependency object provided in depobj
1678 /// directive.
1679 void emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
1681
1682 /// Updates the dependency kind in the specified depobj object.
1683 /// \param DepobjLVal LValue for the main depobj object.
1684 /// \param NewDepKind New dependency kind.
1685 void emitUpdateClause(CodeGenFunction &CGF, LValue DepobjLVal,
1687
1688 /// Initializes user defined allocators specified in the uses_allocators
1689 /// clauses.
1690 void emitUsesAllocatorsInit(CodeGenFunction &CGF, const Expr *Allocator,
1691 const Expr *AllocatorTraits);
1692
1693 /// Destroys user defined allocators specified in the uses_allocators clause.
1694 void emitUsesAllocatorsFini(CodeGenFunction &CGF, const Expr *Allocator);
1695
1696 /// Returns true if the variable is a local variable in untied task.
1697 bool isLocalVarInUntiedTask(CodeGenFunction &CGF, const VarDecl *VD) const;
1698};
1699
1700/// Class supports emissionof SIMD-only code.
1702public:
1705
1706 /// Emits outlined function for the specified OpenMP parallel directive
1707 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
1708 /// kmp_int32 BoundID, struct context_vars*).
1709 /// \param CGF Reference to current CodeGenFunction.
1710 /// \param D OpenMP directive.
1711 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1712 /// \param InnermostKind Kind of innermost directive (for simple directives it
1713 /// is a directive itself, for combined - its innermost directive).
1714 /// \param CodeGen Code generation sequence for the \a D directive.
1715 llvm::Function *emitParallelOutlinedFunction(
1717 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
1718 const RegionCodeGenTy &CodeGen) override;
1719
1720 /// Emits outlined function for the specified OpenMP teams directive
1721 /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
1722 /// kmp_int32 BoundID, struct context_vars*).
1723 /// \param CGF Reference to current CodeGenFunction.
1724 /// \param D OpenMP directive.
1725 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1726 /// \param InnermostKind Kind of innermost directive (for simple directives it
1727 /// is a directive itself, for combined - its innermost directive).
1728 /// \param CodeGen Code generation sequence for the \a D directive.
1729 llvm::Function *emitTeamsOutlinedFunction(
1731 const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
1732 const RegionCodeGenTy &CodeGen) override;
1733
1734 /// Emits outlined function for the OpenMP task directive \a D. This
1735 /// outlined function has type void(*)(kmp_int32 ThreadID, struct task_t*
1736 /// TaskT).
1737 /// \param D OpenMP directive.
1738 /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
1739 /// \param PartIDVar Variable for partition id in the current OpenMP untied
1740 /// task region.
1741 /// \param TaskTVar Variable for task_t argument.
1742 /// \param InnermostKind Kind of innermost directive (for simple directives it
1743 /// is a directive itself, for combined - its innermost directive).
1744 /// \param CodeGen Code generation sequence for the \a D directive.
1745 /// \param Tied true if task is generated for tied task, false otherwise.
1746 /// \param NumberOfParts Number of parts in untied task. Ignored for tied
1747 /// tasks.
1748 ///
1749 llvm::Function *emitTaskOutlinedFunction(
1750 const OMPExecutableDirective &D, const VarDecl *ThreadIDVar,
1751 const VarDecl *PartIDVar, const VarDecl *TaskTVar,
1752 OpenMPDirectiveKind InnermostKind, const RegionCodeGenTy &CodeGen,
1753 bool Tied, unsigned &NumberOfParts) override;
1754
1755 /// Emits code for parallel or serial call of the \a OutlinedFn with
1756 /// variables captured in a record which address is stored in \a
1757 /// CapturedStruct.
1758 /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
1759 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
1760 /// \param CapturedVars A pointer to the record with the references to
1761 /// variables used in \a OutlinedFn function.
1762 /// \param IfCond Condition in the associated 'if' clause, if it was
1763 /// specified, nullptr otherwise.
1764 /// \param NumThreads The value corresponding to the num_threads clause, if
1765 /// any, or nullptr.
1766 /// \param NumThreadsModifier The modifier of the num_threads clause, if
1767 /// any, ignored otherwise.
1768 /// \param Severity The severity corresponding to the num_threads clause, if
1769 /// any, ignored otherwise.
1770 /// \param Message The message string corresponding to the num_threads clause,
1771 /// if any, or nullptr.
1772 ///
1774 llvm::Function *OutlinedFn,
1775 ArrayRef<llvm::Value *> CapturedVars,
1776 const Expr *IfCond, llvm::Value *NumThreads,
1777 OpenMPNumThreadsClauseModifier NumThreadsModifier =
1779 OpenMPSeverityClauseKind Severity = OMPC_SEVERITY_fatal,
1780 const Expr *Message = nullptr) override;
1781
1782 /// Emits a critical region.
1783 /// \param CriticalName Name of the critical region.
1784 /// \param CriticalOpGen Generator for the statement associated with the given
1785 /// critical region.
1786 /// \param Hint Value of the 'hint' clause (optional).
1787 void emitCriticalRegion(CodeGenFunction &CGF, StringRef CriticalName,
1788 const RegionCodeGenTy &CriticalOpGen,
1790 const Expr *Hint = nullptr) override;
1791
1792 /// Emits a master region.
1793 /// \param MasterOpGen Generator for the statement associated with the given
1794 /// master region.
1796 const RegionCodeGenTy &MasterOpGen,
1797 SourceLocation Loc) override;
1798
1799 /// Emits a masked region.
1800 /// \param MaskedOpGen Generator for the statement associated with the given
1801 /// masked region.
1803 const RegionCodeGenTy &MaskedOpGen, SourceLocation Loc,
1804 const Expr *Filter = nullptr) override;
1805
1806 /// Emits a masked region.
1807 /// \param MaskedOpGen Generator for the statement associated with the given
1808 /// masked region.
1809
1810 /// Emits code for a taskyield directive.
1812
1813 /// Emit a taskgroup region.
1814 /// \param TaskgroupOpGen Generator for the statement associated with the
1815 /// given taskgroup region.
1817 const RegionCodeGenTy &TaskgroupOpGen,
1818 SourceLocation Loc) override;
1819
1820 /// Emits a single region.
1821 /// \param SingleOpGen Generator for the statement associated with the given
1822 /// single region.
1824 const RegionCodeGenTy &SingleOpGen, SourceLocation Loc,
1825 ArrayRef<const Expr *> CopyprivateVars,
1826 ArrayRef<const Expr *> DestExprs,
1827 ArrayRef<const Expr *> SrcExprs,
1828 ArrayRef<const Expr *> AssignmentOps) override;
1829
1830 /// Emit an ordered region.
1831 /// \param OrderedOpGen Generator for the statement associated with the given
1832 /// ordered region.
1834 const RegionCodeGenTy &OrderedOpGen,
1835 SourceLocation Loc, bool IsThreads) override;
1836
1837 /// Emit an implicit/explicit barrier for OpenMP threads.
1838 /// \param Kind Directive for which this implicit barrier call must be
1839 /// generated. Must be OMPD_barrier for explicit barrier generation.
1840 /// \param EmitChecks true if need to emit checks for cancellation barriers.
1841 /// \param ForceSimpleCall true simple barrier call must be emitted, false if
1842 /// runtime class decides which one to emit (simple or with cancellation
1843 /// checks).
1844 ///
1846 OpenMPDirectiveKind Kind, bool EmitChecks = true,
1847 bool ForceSimpleCall = false) override;
1848
1849 /// This is used for non static scheduled types and when the ordered
1850 /// clause is present on the loop construct.
1851 /// Depending on the loop schedule, it is necessary to call some runtime
1852 /// routine before start of the OpenMP loop to get the loop upper / lower
1853 /// bounds \a LB and \a UB and stride \a ST.
1854 ///
1855 /// \param CGF Reference to current CodeGenFunction.
1856 /// \param Loc Clang source location.
1857 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
1858 /// \param IVSize Size of the iteration variable in bits.
1859 /// \param IVSigned Sign of the iteration variable.
1860 /// \param Ordered true if loop is ordered, false otherwise.
1861 /// \param DispatchValues struct containing llvm values for lower bound, upper
1862 /// bound, and chunk expression.
1863 /// For the default (nullptr) value, the chunk 1 will be used.
1864 ///
1866 const OpenMPScheduleTy &ScheduleKind,
1867 unsigned IVSize, bool IVSigned, bool Ordered,
1868 const DispatchRTInput &DispatchValues) override;
1869
1870 /// This is used for non static scheduled types and when the ordered
1871 /// clause is present on the loop construct.
1872 ///
1873 /// \param CGF Reference to current CodeGenFunction.
1874 /// \param Loc Clang source location.
1875 ///
1877
1878 /// Call the appropriate runtime routine to initialize it before start
1879 /// of loop.
1880 ///
1881 /// This is used only in case of static schedule, when the user did not
1882 /// specify a ordered clause on the loop construct.
1883 /// Depending on the loop schedule, it is necessary to call some runtime
1884 /// routine before start of the OpenMP loop to get the loop upper / lower
1885 /// bounds LB and UB and stride ST.
1886 ///
1887 /// \param CGF Reference to current CodeGenFunction.
1888 /// \param Loc Clang source location.
1889 /// \param DKind Kind of the directive.
1890 /// \param ScheduleKind Schedule kind, specified by the 'schedule' clause.
1891 /// \param Values Input arguments for the construct.
1892 ///
1894 OpenMPDirectiveKind DKind,
1895 const OpenMPScheduleTy &ScheduleKind,
1896 const StaticRTInput &Values) override;
1897
1898 ///
1899 /// \param CGF Reference to current CodeGenFunction.
1900 /// \param Loc Clang source location.
1901 /// \param SchedKind Schedule kind, specified by the 'dist_schedule' clause.
1902 /// \param Values Input arguments for the construct.
1903 ///
1906 const StaticRTInput &Values) override;
1907
1908 /// Call the appropriate runtime routine to notify that we finished
1909 /// iteration of the ordered loop with the dynamic scheduling.
1910 ///
1911 /// \param CGF Reference to current CodeGenFunction.
1912 /// \param Loc Clang source location.
1913 /// \param IVSize Size of the iteration variable in bits.
1914 /// \param IVSigned Sign of the iteration variable.
1915 ///
1917 unsigned IVSize, bool IVSigned) override;
1918
1919 /// Call the appropriate runtime routine to notify that we finished
1920 /// all the work with current loop.
1921 ///
1922 /// \param CGF Reference to current CodeGenFunction.
1923 /// \param Loc Clang source location.
1924 /// \param DKind Kind of the directive for which the static finish is emitted.
1925 ///
1927 OpenMPDirectiveKind DKind) override;
1928
1929 /// Call __kmpc_dispatch_next(
1930 /// ident_t *loc, kmp_int32 tid, kmp_int32 *p_lastiter,
1931 /// kmp_int[32|64] *p_lower, kmp_int[32|64] *p_upper,
1932 /// kmp_int[32|64] *p_stride);
1933 /// \param IVSize Size of the iteration variable in bits.
1934 /// \param IVSigned Sign of the iteration variable.
1935 /// \param IL Address of the output variable in which the flag of the
1936 /// last iteration is returned.
1937 /// \param LB Address of the output variable in which the lower iteration
1938 /// number is returned.
1939 /// \param UB Address of the output variable in which the upper iteration
1940 /// number is returned.
1941 /// \param ST Address of the output variable in which the stride value is
1942 /// returned.
1943 llvm::Value *emitForNext(CodeGenFunction &CGF, SourceLocation Loc,
1944 unsigned IVSize, bool IVSigned, Address IL,
1945 Address LB, Address UB, Address ST) override;
1946
1947 /// Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32
1948 /// global_tid, kmp_int32 num_threads) to generate code for 'num_threads'
1949 /// clause.
1950 /// If the modifier 'strict' is given:
1951 /// Emits call to void __kmpc_push_num_threads_strict(ident_t *loc, kmp_int32
1952 /// global_tid, kmp_int32 num_threads, int severity, const char *message) to
1953 /// generate code for 'num_threads' clause with 'strict' modifier.
1954 /// \param NumThreads An integer value of threads.
1956 CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc,
1958 OpenMPSeverityClauseKind Severity = OMPC_SEVERITY_fatal,
1959 const Expr *Message = nullptr) override;
1960
1961 /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
1962 /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
1964 llvm::omp::ProcBindKind ProcBind,
1965 SourceLocation Loc) override;
1966
1967 /// Returns address of the threadprivate variable for the current
1968 /// thread.
1969 /// \param VD Threadprivate variable.
1970 /// \param VDAddr Address of the global variable \a VD.
1971 /// \param Loc Location of the reference to threadprivate var.
1972 /// \return Address of the threadprivate variable for the current thread.
1974 Address VDAddr, SourceLocation Loc) override;
1975
1976 /// Emit a code for initialization of threadprivate variable. It emits
1977 /// a call to runtime library which adds initial value to the newly created
1978 /// threadprivate variable (if it is not constant) and registers destructor
1979 /// for the variable (if any).
1980 /// \param VD Threadprivate variable.
1981 /// \param VDAddr Address of the global variable \a VD.
1982 /// \param Loc Location of threadprivate declaration.
1983 /// \param PerformInit true if initialization expression is not constant.
1984 llvm::Function *
1986 SourceLocation Loc, bool PerformInit,
1987 CodeGenFunction *CGF = nullptr) override;
1988
1989 /// Creates artificial threadprivate variable with name \p Name and type \p
1990 /// VarType.
1991 /// \param VarType Type of the artificial threadprivate variable.
1992 /// \param Name Name of the artificial threadprivate variable.
1994 QualType VarType,
1995 StringRef Name) override;
1996
1997 /// Emit flush of the variables specified in 'omp flush' directive.
1998 /// \param Vars List of variables to flush.
2000 SourceLocation Loc, llvm::AtomicOrdering AO) override;
2001
2002 /// Emit task region for the task directive. The task region is
2003 /// emitted in several steps:
2004 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
2005 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
2006 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
2007 /// function:
2008 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
2009 /// TaskFunction(gtid, tt->part_id, tt->shareds);
2010 /// return 0;
2011 /// }
2012 /// 2. Copy a list of shared variables to field shareds of the resulting
2013 /// structure kmp_task_t returned by the previous call (if any).
2014 /// 3. Copy a pointer to destructions function to field destructions of the
2015 /// resulting structure kmp_task_t.
2016 /// 4. Emit a call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid,
2017 /// kmp_task_t *new_task), where new_task is a resulting structure from
2018 /// previous items.
2019 /// \param D Current task directive.
2020 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
2021 /// /*part_id*/, captured_struct */*__context*/);
2022 /// \param SharedsTy A type which contains references the shared variables.
2023 /// \param Shareds Context with the list of shared variables from the \p
2024 /// TaskFunction.
2025 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
2026 /// otherwise.
2027 /// \param Data Additional data for task generation like tiednsee, final
2028 /// state, list of privates etc.
2031 llvm::Function *TaskFunction, QualType SharedsTy,
2032 Address Shareds, const Expr *IfCond,
2033 const OMPTaskDataTy &Data) override;
2034
2035 /// Emit task region for the taskloop directive. The taskloop region is
2036 /// emitted in several steps:
2037 /// 1. Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32
2038 /// gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds,
2039 /// kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the
2040 /// function:
2041 /// kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) {
2042 /// TaskFunction(gtid, tt->part_id, tt->shareds);
2043 /// return 0;
2044 /// }
2045 /// 2. Copy a list of shared variables to field shareds of the resulting
2046 /// structure kmp_task_t returned by the previous call (if any).
2047 /// 3. Copy a pointer to destructions function to field destructions of the
2048 /// resulting structure kmp_task_t.
2049 /// 4. Emit a call to void __kmpc_taskloop(ident_t *loc, int gtid, kmp_task_t
2050 /// *task, int if_val, kmp_uint64 *lb, kmp_uint64 *ub, kmp_int64 st, int
2051 /// nogroup, int sched, kmp_uint64 grainsize, void *task_dup ), where new_task
2052 /// is a resulting structure from
2053 /// previous items.
2054 /// \param D Current task directive.
2055 /// \param TaskFunction An LLVM function with type void (*)(i32 /*gtid*/, i32
2056 /// /*part_id*/, captured_struct */*__context*/);
2057 /// \param SharedsTy A type which contains references the shared variables.
2058 /// \param Shareds Context with the list of shared variables from the \p
2059 /// TaskFunction.
2060 /// \param IfCond Not a nullptr if 'if' clause was specified, nullptr
2061 /// otherwise.
2062 /// \param Data Additional data for task generation like tiednsee, final
2063 /// state, list of privates etc.
2065 const OMPLoopDirective &D, llvm::Function *TaskFunction,
2066 QualType SharedsTy, Address Shareds, const Expr *IfCond,
2067 const OMPTaskDataTy &Data) override;
2068
2069 /// Emit a code for reduction clause. Next code should be emitted for
2070 /// reduction:
2071 /// \code
2072 ///
2073 /// static kmp_critical_name lock = { 0 };
2074 ///
2075 /// void reduce_func(void *lhs[<n>], void *rhs[<n>]) {
2076 /// ...
2077 /// *(Type<i>*)lhs[i] = RedOp<i>(*(Type<i>*)lhs[i], *(Type<i>*)rhs[i]);
2078 /// ...
2079 /// }
2080 ///
2081 /// ...
2082 /// void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]};
2083 /// switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList),
2084 /// RedList, reduce_func, &<lock>)) {
2085 /// case 1:
2086 /// ...
2087 /// <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]);
2088 /// ...
2089 /// __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>);
2090 /// break;
2091 /// case 2:
2092 /// ...
2093 /// Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]));
2094 /// ...
2095 /// break;
2096 /// default:;
2097 /// }
2098 /// \endcode
2099 ///
2100 /// \param Privates List of private copies for original reduction arguments.
2101 /// \param LHSExprs List of LHS in \a ReductionOps reduction operations.
2102 /// \param RHSExprs List of RHS in \a ReductionOps reduction operations.
2103 /// \param ReductionOps List of reduction operations in form 'LHS binop RHS'
2104 /// or 'operator binop(LHS, RHS)'.
2105 /// \param Options List of options for reduction codegen:
2106 /// WithNowait true if parent directive has also nowait clause, false
2107 /// otherwise.
2108 /// SimpleReduction Emit reduction operation only. Used for omp simd
2109 /// directive on the host.
2110 /// ReductionKind The kind of reduction to perform.
2112 ArrayRef<const Expr *> Privates,
2113 ArrayRef<const Expr *> LHSExprs,
2114 ArrayRef<const Expr *> RHSExprs,
2115 ArrayRef<const Expr *> ReductionOps,
2116 ReductionOptionsTy Options) override;
2117
2118 /// Emit a code for initialization of task reduction clause. Next code
2119 /// should be emitted for reduction:
2120 /// \code
2121 ///
2122 /// _taskred_item_t red_data[n];
2123 /// ...
2124 /// red_data[i].shar = &shareds[i];
2125 /// red_data[i].orig = &origs[i];
2126 /// red_data[i].size = sizeof(origs[i]);
2127 /// red_data[i].f_init = (void*)RedInit<i>;
2128 /// red_data[i].f_fini = (void*)RedDest<i>;
2129 /// red_data[i].f_comb = (void*)RedOp<i>;
2130 /// red_data[i].flags = <Flag_i>;
2131 /// ...
2132 /// void* tg1 = __kmpc_taskred_init(gtid, n, red_data);
2133 /// \endcode
2134 /// For reduction clause with task modifier it emits the next call:
2135 /// \code
2136 ///
2137 /// _taskred_item_t red_data[n];
2138 /// ...
2139 /// red_data[i].shar = &shareds[i];
2140 /// red_data[i].orig = &origs[i];
2141 /// red_data[i].size = sizeof(origs[i]);
2142 /// red_data[i].f_init = (void*)RedInit<i>;
2143 /// red_data[i].f_fini = (void*)RedDest<i>;
2144 /// red_data[i].f_comb = (void*)RedOp<i>;
2145 /// red_data[i].flags = <Flag_i>;
2146 /// ...
2147 /// void* tg1 = __kmpc_taskred_modifier_init(loc, gtid, is_worksharing, n,
2148 /// red_data);
2149 /// \endcode
2150 /// \param LHSExprs List of LHS in \a Data.ReductionOps reduction operations.
2151 /// \param RHSExprs List of RHS in \a Data.ReductionOps reduction operations.
2152 /// \param Data Additional data for task generation like tiedness, final
2153 /// state, list of privates, reductions etc.
2155 ArrayRef<const Expr *> LHSExprs,
2156 ArrayRef<const Expr *> RHSExprs,
2157 const OMPTaskDataTy &Data) override;
2158
2159 /// Emits the following code for reduction clause with task modifier:
2160 /// \code
2161 /// __kmpc_task_reduction_modifier_fini(loc, gtid, is_worksharing);
2162 /// \endcode
2164 bool IsWorksharingReduction) override;
2165
2166 /// Required to resolve existing problems in the runtime. Emits threadprivate
2167 /// variables to store the size of the VLAs/array sections for
2168 /// initializer/combiner/finalizer functions + emits threadprivate variable to
2169 /// store the pointer to the original reduction item for the custom
2170 /// initializer defined by declare reduction construct.
2171 /// \param RCG Allows to reuse an existing data for the reductions.
2172 /// \param N Reduction item for which fixups must be emitted.
2174 ReductionCodeGen &RCG, unsigned N) override;
2175
2176 /// Get the address of `void *` type of the privatue copy of the reduction
2177 /// item specified by the \p SharedLVal.
2178 /// \param ReductionsPtr Pointer to the reduction data returned by the
2179 /// emitTaskReductionInit function.
2180 /// \param SharedLVal Address of the original reduction item.
2182 llvm::Value *ReductionsPtr,
2183 LValue SharedLVal) override;
2184
2185 /// Emit code for 'taskwait' directive.
2187 const OMPTaskDataTy &Data) override;
2188
2189 /// Emit code for 'cancellation point' construct.
2190 /// \param CancelRegion Region kind for which the cancellation point must be
2191 /// emitted.
2192 ///
2194 OpenMPDirectiveKind CancelRegion) override;
2195
2196 /// Emit code for 'cancel' construct.
2197 /// \param IfCond Condition in the associated 'if' clause, if it was
2198 /// specified, nullptr otherwise.
2199 /// \param CancelRegion Region kind for which the cancel must be emitted.
2200 ///
2202 const Expr *IfCond,
2203 OpenMPDirectiveKind CancelRegion) override;
2204
2205 /// Emit outilined function for 'target' directive.
2206 /// \param D Directive to emit.
2207 /// \param ParentName Name of the function that encloses the target region.
2208 /// \param OutlinedFn Outlined function value to be defined by this call.
2209 /// \param OutlinedFnID Outlined function ID value to be defined by this call.
2210 /// \param IsOffloadEntry True if the outlined function is an offload entry.
2211 /// \param CodeGen Code generation sequence for the \a D directive.
2212 /// An outlined function may not be an entry if, e.g. the if clause always
2213 /// evaluates to false.
2215 StringRef ParentName,
2216 llvm::Function *&OutlinedFn,
2217 llvm::Constant *&OutlinedFnID,
2218 bool IsOffloadEntry,
2219 const RegionCodeGenTy &CodeGen) override;
2220
2221 /// Emit the target offloading code associated with \a D. The emitted
2222 /// code attempts offloading the execution to the device, an the event of
2223 /// a failure it executes the host version outlined in \a OutlinedFn.
2224 /// \param D Directive to emit.
2225 /// \param OutlinedFn Host version of the code to be offloaded.
2226 /// \param OutlinedFnID ID of host version of the code to be offloaded.
2227 /// \param IfCond Expression evaluated in if clause associated with the target
2228 /// directive, or null if no if clause is used.
2229 /// \param Device Expression evaluated in device clause associated with the
2230 /// target directive, or null if no device clause is used and device modifier.
2231 void emitTargetCall(
2233 llvm::Function *OutlinedFn, llvm::Value *OutlinedFnID, const Expr *IfCond,
2234 llvm::PointerIntPair<const Expr *, 2, OpenMPDeviceClauseModifier> Device,
2235 llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
2236 const OMPLoopDirective &D)>
2237 SizeEmitter) override;
2238
2239 /// Emit the target regions enclosed in \a GD function definition or
2240 /// the function itself in case it is a valid device function. Returns true if
2241 /// \a GD was dealt with successfully.
2242 /// \param GD Function to scan.
2243 bool emitTargetFunctions(GlobalDecl GD) override;
2244
2245 /// Emit the global variable if it is a valid device global variable.
2246 /// Returns true if \a GD was dealt with successfully.
2247 /// \param GD Variable declaration to emit.
2248 bool emitTargetGlobalVariable(GlobalDecl GD) override;
2249
2250 /// Emit the global \a GD if it is meaningful for the target. Returns
2251 /// if it was emitted successfully.
2252 /// \param GD Global to scan.
2253 bool emitTargetGlobal(GlobalDecl GD) override;
2254
2255 /// Emits code for teams call of the \a OutlinedFn with
2256 /// variables captured in a record which address is stored in \a
2257 /// CapturedStruct.
2258 /// \param OutlinedFn Outlined function to be run by team masters. Type of
2259 /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
2260 /// \param CapturedVars A pointer to the record with the references to
2261 /// variables used in \a OutlinedFn function.
2262 ///
2264 SourceLocation Loc, llvm::Function *OutlinedFn,
2265 ArrayRef<llvm::Value *> CapturedVars) override;
2266
2267 /// Emits call to void __kmpc_push_num_teams(ident_t *loc, kmp_int32
2268 /// global_tid, kmp_int32 num_teams, kmp_int32 thread_limit) to generate code
2269 /// for num_teams clause.
2270 /// \param NumTeams An integer expression of teams.
2271 /// \param ThreadLimit An integer expression of threads.
2272 void emitNumTeamsClause(CodeGenFunction &CGF, const Expr *NumTeams,
2273 const Expr *ThreadLimit, SourceLocation Loc) override;
2274
2275 /// Emit the target data mapping code associated with \a D.
2276 /// \param D Directive to emit.
2277 /// \param IfCond Expression evaluated in if clause associated with the
2278 /// target directive, or null if no device clause is used.
2279 /// \param Device Expression evaluated in device clause associated with the
2280 /// target directive, or null if no device clause is used.
2281 /// \param Info A record used to store information that needs to be preserved
2282 /// until the region is closed.
2284 const OMPExecutableDirective &D, const Expr *IfCond,
2285 const Expr *Device, const RegionCodeGenTy &CodeGen,
2286 CGOpenMPRuntime::TargetDataInfo &Info) override;
2287
2288 /// Emit the data mapping/movement code associated with the directive
2289 /// \a D that should be of the form 'target [{enter|exit} data | update]'.
2290 /// \param D Directive to emit.
2291 /// \param IfCond Expression evaluated in if clause associated with the target
2292 /// directive, or null if no if clause is used.
2293 /// \param Device Expression evaluated in device clause associated with the
2294 /// target directive, or null if no device clause is used.
2297 const Expr *IfCond,
2298 const Expr *Device) override;
2299
2300 /// Emit initialization for doacross loop nesting support.
2301 /// \param D Loop-based construct used in doacross nesting construct.
2303 ArrayRef<Expr *> NumIterations) override;
2304
2305 /// Emit code for doacross ordered directive with 'depend' clause.
2306 /// \param C 'depend' clause with 'sink|source' dependency kind.
2308 const OMPDependClause *C) override;
2309
2310 /// Emit code for doacross ordered directive with 'doacross' clause.
2311 /// \param C 'doacross' clause with 'sink|source' dependence type.
2313 const OMPDoacrossClause *C) override;
2314
2315 /// Translates the native parameter of outlined function if this is required
2316 /// for target.
2317 /// \param FD Field decl from captured record for the parameter.
2318 /// \param NativeParam Parameter itself.
2319 const VarDecl *translateParameter(const FieldDecl *FD,
2320 const VarDecl *NativeParam) const override;
2321
2322 /// Gets the address of the native argument basing on the address of the
2323 /// target-specific parameter.
2324 /// \param NativeParam Parameter itself.
2325 /// \param TargetParam Corresponding target-specific parameter.
2326 Address getParameterAddress(CodeGenFunction &CGF, const VarDecl *NativeParam,
2327 const VarDecl *TargetParam) const override;
2328
2329 /// Gets the OpenMP-specific address of the local variable.
2331 const VarDecl *VD) override {
2332 return Address::invalid();
2333 }
2334};
2335
2336} // namespace CodeGen
2337// Utility for openmp doacross clause kind
2338namespace {
2339template <typename T> class OMPDoacrossKind {
2340public:
2341 bool isSink(const T *) { return false; }
2342 bool isSource(const T *) { return false; }
2343};
2344template <> class OMPDoacrossKind<OMPDependClause> {
2345public:
2346 bool isSink(const OMPDependClause *C) {
2347 return C->getDependencyKind() == OMPC_DEPEND_sink;
2348 }
2349 bool isSource(const OMPDependClause *C) {
2350 return C->getDependencyKind() == OMPC_DEPEND_source;
2351 }
2352};
2353template <> class OMPDoacrossKind<OMPDoacrossClause> {
2354public:
2355 bool isSource(const OMPDoacrossClause *C) {
2356 return C->getDependenceType() == OMPC_DOACROSS_source ||
2357 C->getDependenceType() == OMPC_DOACROSS_source_omp_cur_iteration;
2358 }
2359 bool isSink(const OMPDoacrossClause *C) {
2360 return C->getDependenceType() == OMPC_DOACROSS_sink ||
2361 C->getDependenceType() == OMPC_DOACROSS_sink_omp_cur_iteration;
2362 }
2363};
2364} // namespace
2365} // namespace clang
2366
2367#endif
MatchType Type
const Decl * D
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
Expr * E
This file defines OpenMP nodes for declarative directives.
Defines some OpenMP-specific enums and functions.
SourceLocation Loc
Definition: SemaObjC.cpp:754
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:346
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::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 emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars, const Expr *IfCond, llvm::Value *NumThreads, OpenMPNumThreadsClauseModifier NumThreadsModifier=OMPC_NUMTHREADS_unknown, OpenMPSeverityClauseKind Severity=OMPC_SEVERITY_fatal, const Expr *Message=nullptr)
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
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...
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.
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.
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.
void emitPrivateReduction(CodeGenFunction &CGF, SourceLocation Loc, const Expr *Privates, const Expr *LHSExprs, const Expr *RHSExprs, const Expr *ReductionOps)
Emits code for private variable reduction.
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.
virtual llvm::Value * emitMessageClause(CodeGenFunction &CGF, const Expr *Message)
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.
void computeMinAndMaxThreadsAndTeams(const OMPExecutableDirective &D, CodeGenFunction &CGF, llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs &Attrs)
Helper to determine the min/max number of threads/teams for D.
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...
virtual llvm::Value * emitSeverityClause(OpenMPSeverityClauseKind Severity)
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.
virtual void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc, OpenMPNumThreadsClauseModifier Modifier=OMPC_NUMTHREADS_unknown, OpenMPSeverityClauseKind Severity=OMPC_SEVERITY_fatal, const Expr *Message=nullptr)
Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_threads)...
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.
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...
void emitNumThreadsClause(CodeGenFunction &CGF, llvm::Value *NumThreads, SourceLocation Loc, OpenMPNumThreadsClauseModifier Modifier=OMPC_NUMTHREADS_unknown, OpenMPSeverityClauseKind Severity=OMPC_SEVERITY_fatal, const Expr *Message=nullptr) override
Emits call to void __kmpc_push_num_threads(ident_t *loc, kmp_int32 global_tid, kmp_int32 num_threads)...
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 emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc, llvm::Function *OutlinedFn, ArrayRef< llvm::Value * > CapturedVars, const Expr *IfCond, llvm::Value *NumThreads, OpenMPNumThreadsClauseModifier NumThreadsModifier=OMPC_NUMTHREADS_unknown, OpenMPSeverityClauseKind Severity=OMPC_SEVERITY_fatal, const Expr *Message=nullptr) override
Emits code for parallel or serial call of the OutlinedFn with variables captured in a record which ad...
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 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 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:296
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:1272
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
This represents one expression.
Definition: Expr.h:112
Represents a member of a struct/union/class.
Definition: Decl.h:3157
Represents a function declaration or definition.
Definition: Decl.h:1999
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:57
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 the 'message' clause in the '#pragma omp error' and the '#pragma omp parallel' direct...
This represents '#pragma omp requires...' directive.
Definition: DeclOpenMP.h:417
This represents the 'severity' clause in the '#pragma omp error' and the '#pragma omp parallel' direc...
A (possibly-)qualified type.
Definition: TypeBase.h:937
Represents a struct/union/class.
Definition: Decl.h:4309
Encodes a location in the source.
Stmt - This represents one statement.
Definition: Stmt.h:85
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:711
Represents a variable declaration or definition.
Definition: Decl.h:925
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
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
Definition: OpenMPKinds.h:143
LangAS
Defines the address space values used by the address space qualifier of QualType.
Definition: AddressSpaces.h:25
const FunctionProtoType * T
OpenMPNumThreadsClauseModifier
Definition: OpenMPKinds.h:226
@ OMPC_NUMTHREADS_unknown
Definition: OpenMPKinds.h:229
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