22#include "llvm/ADT/SmallPtrSet.h"
23#include "llvm/Support/ErrorHandling.h"
36#define GEN_CLANG_CLAUSE_CLASS
37#define CLAUSE_CLASS(Enum, Str, Class) \
39 return static_cast<Class *>(this)->children();
40#include "llvm/Frontend/OpenMP/OMP.inc"
42 llvm_unreachable(
"unknown OMPClause");
47#define GEN_CLANG_CLAUSE_CLASS
48#define CLAUSE_CLASS(Enum, Str, Class) \
50 return static_cast<Class *>(this)->used_children();
51#define CLAUSE_NO_CLASS(Enum, Str) \
54#include "llvm/Frontend/OpenMP/OMP.inc"
56 llvm_unreachable(
"unknown OMPClause");
65 switch (
C->getClauseKind()) {
67 return static_cast<const OMPScheduleClause *
>(
C);
68 case OMPC_dist_schedule:
70 case OMPC_firstprivate:
71 return static_cast<const OMPFirstprivateClause *
>(
C);
72 case OMPC_lastprivate:
73 return static_cast<const OMPLastprivateClause *
>(
C);
75 return static_cast<const OMPReductionClause *
>(
C);
76 case OMPC_task_reduction:
77 return static_cast<const OMPTaskReductionClause *
>(
C);
78 case OMPC_in_reduction:
79 return static_cast<const OMPInReductionClause *
>(
C);
81 return static_cast<const OMPLinearClause *
>(
C);
84 case OMPC_num_threads:
88 case OMPC_thread_limit:
100 case OMPC_novariants:
106 case OMPC_ompx_dyn_cgroup_mem:
108 case OMPC_dyn_groupprivate:
111 return static_cast<const OMPMessageClause *
>(
C);
124 case OMPC_copyprivate:
130 case OMPC_transparent:
131 case OMPC_threadprivate:
132 case OMPC_groupprivate:
152 case OMPC_defaultmap:
157 case OMPC_use_device_ptr:
158 case OMPC_use_device_addr:
159 case OMPC_is_device_ptr:
160 case OMPC_has_device_addr:
161 case OMPC_unified_address:
162 case OMPC_unified_shared_memory:
163 case OMPC_reverse_offload:
164 case OMPC_dynamic_allocators:
165 case OMPC_atomic_default_mem_order:
169 case OMPC_device_type:
171 case OMPC_nontemporal:
177 case OMPC_uses_allocators:
196 switch (
C->getClauseKind()) {
197 case OMPC_lastprivate:
198 return static_cast<const OMPLastprivateClause *
>(
C);
200 return static_cast<const OMPReductionClause *
>(
C);
201 case OMPC_task_reduction:
202 return static_cast<const OMPTaskReductionClause *
>(
C);
203 case OMPC_in_reduction:
204 return static_cast<const OMPInReductionClause *
>(
C);
206 return static_cast<const OMPLinearClause *
>(
C);
208 case OMPC_dist_schedule:
209 case OMPC_firstprivate:
214 case OMPC_num_threads:
225 case OMPC_copyprivate:
230 case OMPC_threadprivate:
231 case OMPC_groupprivate:
251 case OMPC_thread_limit:
257 case OMPC_defaultmap:
262 case OMPC_use_device_ptr:
263 case OMPC_use_device_addr:
264 case OMPC_is_device_ptr:
265 case OMPC_has_device_addr:
266 case OMPC_unified_address:
267 case OMPC_unified_shared_memory:
268 case OMPC_reverse_offload:
269 case OMPC_dynamic_allocators:
270 case OMPC_atomic_default_mem_order:
275 case OMPC_device_type:
277 case OMPC_nontemporal:
280 case OMPC_novariants:
285 case OMPC_uses_allocators:
302 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
303 assert(DS->isSingleDecl() &&
"Only single expression must be captured.");
304 if (
auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
305 return OED->getInitAddress();
324 return child_range(
C,
C + 1);
325 return child_range(&Grainsize, &Grainsize + 1);
330 return child_range(
C,
C + 1);
331 return child_range(&NumTasks, &NumTasks + 1);
342 return child_range(
C,
C + 1);
343 return child_range(&Priority, &Priority + 1);
348 return child_range(
C,
C + 1);
354 return child_range(
C,
C + 1);
363 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
365 new (Mem) OMPOrderedClause(
Num, NumLoops, StartLoc, LParenLoc, EndLoc);
366 for (
unsigned I = 0; I < NumLoops; ++I) {
367 Clause->setLoopNumIterations(I,
nullptr);
368 Clause->setLoopCounter(I,
nullptr);
373OMPOrderedClause *OMPOrderedClause::CreateEmpty(
const ASTContext &
C,
375 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
376 auto *Clause =
new (Mem) OMPOrderedClause(NumLoops);
377 for (
unsigned I = 0; I < NumLoops; ++I) {
378 Clause->setLoopNumIterations(I,
nullptr);
379 Clause->setLoopCounter(I,
nullptr);
384void OMPOrderedClause::setLoopNumIterations(
unsigned NumLoop,
385 Expr *NumIterations) {
386 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
387 getTrailingObjects()[NumLoop] = NumIterations;
391 return getTrailingObjects(NumberOfLoops);
394void OMPOrderedClause::setLoopCounter(
unsigned NumLoop,
Expr *Counter) {
395 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
396 getTrailingObjects()[NumberOfLoops + NumLoop] = Counter;
399Expr *OMPOrderedClause::getLoopCounter(
unsigned NumLoop) {
400 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
401 return getTrailingObjects()[NumberOfLoops + NumLoop];
404const Expr *OMPOrderedClause::getLoopCounter(
unsigned NumLoop)
const {
405 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
406 return getTrailingObjects()[NumberOfLoops + NumLoop];
409OMPUpdateClause *OMPUpdateClause::Create(
const ASTContext &
C,
412 return new (
C) OMPUpdateClause(StartLoc, EndLoc,
false);
420 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
421 alignof(OMPUpdateClause));
423 new (Mem) OMPUpdateClause(StartLoc, EndLoc,
true);
424 Clause->setLParenLoc(LParenLoc);
425 Clause->setArgumentLoc(ArgumentLoc);
426 Clause->setDependencyKind(DK);
430OMPUpdateClause *OMPUpdateClause::CreateEmpty(
const ASTContext &
C,
433 return new (
C) OMPUpdateClause(
false);
435 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
436 alignof(OMPUpdateClause));
437 auto *Clause =
new (Mem) OMPUpdateClause(
true);
438 Clause->IsExtended =
true;
443 assert(VL.size() == varlist_size() &&
444 "Number of private copies is not the same as the preallocated buffer");
445 llvm::copy(VL, varlist_end());
453 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
454 OMPPrivateClause *Clause =
455 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
456 Clause->setVarRefs(VL);
457 Clause->setPrivateCopies(PrivateVL);
461OMPPrivateClause *OMPPrivateClause::CreateEmpty(
const ASTContext &
C,
463 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
464 return new (Mem) OMPPrivateClause(N);
468 assert(VL.size() == varlist_size() &&
469 "Number of private copies is not the same as the preallocated buffer");
470 llvm::copy(VL, varlist_end());
474 assert(VL.size() == varlist_size() &&
475 "Number of inits is not the same as the preallocated buffer");
476 llvm::copy(VL, getPrivateCopies().end());
479OMPFirstprivateClause *
484 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
485 OMPFirstprivateClause *Clause =
486 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
487 Clause->setVarRefs(VL);
488 Clause->setPrivateCopies(PrivateVL);
489 Clause->setInits(InitVL);
490 Clause->setPreInitStmt(PreInit);
494OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(
const ASTContext &
C,
496 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
497 return new (Mem) OMPFirstprivateClause(N);
500void OMPLastprivateClause::setPrivateCopies(
ArrayRef<Expr *> PrivateCopies) {
501 assert(PrivateCopies.size() == varlist_size() &&
502 "Number of private copies is not the same as the preallocated buffer");
503 llvm::copy(PrivateCopies, varlist_end());
507 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is "
508 "not the same as the "
509 "preallocated buffer");
510 llvm::copy(SrcExprs, getPrivateCopies().end());
514 assert(DstExprs.size() == varlist_size() &&
"Number of destination "
515 "expressions is not the same as "
516 "the preallocated buffer");
517 llvm::copy(DstExprs, getSourceExprs().end());
520void OMPLastprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
521 assert(AssignmentOps.size() == varlist_size() &&
522 "Number of assignment expressions is not the same as the preallocated "
524 llvm::copy(AssignmentOps, getDestinationExprs().end());
527OMPLastprivateClause *OMPLastprivateClause::Create(
533 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
534 OMPLastprivateClause *Clause =
new (Mem) OMPLastprivateClause(
535 StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
536 Clause->setVarRefs(VL);
537 Clause->setSourceExprs(SrcExprs);
538 Clause->setDestinationExprs(DstExprs);
539 Clause->setAssignmentOps(AssignmentOps);
540 Clause->setPreInitStmt(PreInit);
541 Clause->setPostUpdateExpr(PostUpdate);
545OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(
const ASTContext &
C,
547 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
548 return new (Mem) OMPLastprivateClause(N);
551OMPSharedClause *OMPSharedClause::Create(
const ASTContext &
C,
556 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
557 OMPSharedClause *Clause =
558 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
559 Clause->setVarRefs(VL);
563OMPSharedClause *OMPSharedClause::CreateEmpty(
const ASTContext &
C,
unsigned N) {
564 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
565 return new (Mem) OMPSharedClause(N);
569 assert(PL.size() == varlist_size() &&
570 "Number of privates is not the same as the preallocated buffer");
571 llvm::copy(PL, varlist_end());
575 assert(IL.size() == varlist_size() &&
576 "Number of inits is not the same as the preallocated buffer");
581 assert(UL.size() == varlist_size() &&
582 "Number of updates is not the same as the preallocated buffer");
587 assert(FL.size() == varlist_size() &&
588 "Number of final updates is not the same as the preallocated buffer");
594 UE.size() == varlist_size() + 1 &&
595 "Number of used expressions is not the same as the preallocated buffer");
599OMPLinearClause *OMPLinearClause::Create(
609 C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
610 OMPLinearClause *Clause =
611 new (Mem) OMPLinearClause(StartLoc, LParenLoc, Modifier, ModifierLoc,
612 ColonLoc, StepModifierLoc, EndLoc, VL.size());
613 Clause->setVarRefs(VL);
614 Clause->setPrivates(PL);
615 Clause->setInits(IL);
618 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
620 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
622 std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
624 Clause->setStep(Step);
625 Clause->setCalcStep(CalcStep);
626 Clause->setPreInitStmt(PreInit);
627 Clause->setPostUpdateExpr(PostUpdate);
631OMPLinearClause *OMPLinearClause::CreateEmpty(
const ASTContext &
C,
635 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
636 return new (Mem) OMPLinearClause(NumVars);
650 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
651 OMPAlignedClause *Clause =
new (Mem)
652 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
653 Clause->setVarRefs(VL);
654 Clause->setAlignment(A);
660 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
661 return new (Mem) OMPAlignedClause(NumVars);
668 return new (
C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc);
672 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is "
673 "not the same as the "
674 "preallocated buffer");
675 llvm::copy(SrcExprs, varlist_end());
679 assert(DstExprs.size() == varlist_size() &&
"Number of destination "
680 "expressions is not the same as "
681 "the preallocated buffer");
682 llvm::copy(DstExprs, getSourceExprs().end());
686 assert(AssignmentOps.size() == varlist_size() &&
687 "Number of assignment expressions is not the same as the preallocated "
689 llvm::copy(AssignmentOps, getDestinationExprs().end());
696 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
697 OMPCopyinClause *Clause =
698 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
699 Clause->setVarRefs(VL);
700 Clause->setSourceExprs(SrcExprs);
701 Clause->setDestinationExprs(DstExprs);
702 Clause->setAssignmentOps(AssignmentOps);
707 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
708 return new (Mem) OMPCopyinClause(N);
712 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is "
713 "not the same as the "
714 "preallocated buffer");
715 llvm::copy(SrcExprs, varlist_end());
719 assert(DstExprs.size() == varlist_size() &&
"Number of destination "
720 "expressions is not the same as "
721 "the preallocated buffer");
722 llvm::copy(DstExprs, getSourceExprs().end());
725void OMPCopyprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
726 assert(AssignmentOps.size() == varlist_size() &&
727 "Number of assignment expressions is not the same as the preallocated "
729 llvm::copy(AssignmentOps, getDestinationExprs().end());
736 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
737 OMPCopyprivateClause *Clause =
738 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
739 Clause->setVarRefs(VL);
740 Clause->setSourceExprs(SrcExprs);
741 Clause->setDestinationExprs(DstExprs);
742 Clause->setAssignmentOps(AssignmentOps);
748 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
749 return new (Mem) OMPCopyprivateClause(N);
753 assert(
Privates.size() == varlist_size() &&
754 "Number of private copies is not the same as the preallocated buffer");
755 llvm::copy(
Privates, varlist_end());
760 LHSExprs.size() == varlist_size() &&
761 "Number of LHS expressions is not the same as the preallocated buffer");
767 RHSExprs.size() == varlist_size() &&
768 "Number of RHS expressions is not the same as the preallocated buffer");
769 llvm::copy(RHSExprs, getLHSExprs().end());
773 assert(ReductionOps.size() == varlist_size() &&
"Number of reduction "
774 "expressions is not the same "
775 "as the preallocated buffer");
776 llvm::copy(ReductionOps, getRHSExprs().end());
780 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
781 assert(Ops.size() == varlist_size() &&
"Number of copy "
782 "expressions is not the same "
783 "as the preallocated buffer");
784 llvm::copy(Ops, getReductionOps().end());
787void OMPReductionClause::setInscanCopyArrayTemps(
789 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
790 assert(CopyArrayTemps.size() == varlist_size() &&
791 "Number of copy temp expressions is not the same as the preallocated "
793 llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
796void OMPReductionClause::setInscanCopyArrayElems(
798 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
799 assert(CopyArrayElems.size() == varlist_size() &&
800 "Number of copy temp expressions is not the same as the preallocated "
802 llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
805OMPReductionClause *OMPReductionClause::Create(
816 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
817 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size(), VL.size()));
818 auto *Clause =
new (Mem) OMPReductionClause(
819 StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc, Modifier,
820 OrignalSharingModifier, VL.size(), QualifierLoc, NameInfo);
821 Clause->setVarRefs(VL);
823 Clause->setLHSExprs(LHSExprs);
824 Clause->setRHSExprs(RHSExprs);
825 Clause->setReductionOps(ReductionOps);
826 Clause->setPreInitStmt(PreInit);
827 Clause->setPostUpdateExpr(PostUpdate);
828 Clause->setPrivateVariableReductionFlags(IsPrivateVarReduction);
829 if (Modifier == OMPC_REDUCTION_inscan) {
830 Clause->setInscanCopyOps(CopyOps);
831 Clause->setInscanCopyArrayTemps(CopyArrayTemps);
832 Clause->setInscanCopyArrayElems(CopyArrayElems);
834 assert(CopyOps.empty() &&
835 "copy operations are expected in inscan reductions only.");
836 assert(CopyArrayTemps.empty() &&
837 "copy array temps are expected in inscan reductions only.");
838 assert(CopyArrayElems.empty() &&
839 "copy array temps are expected in inscan reductions only.");
845OMPReductionClause::CreateEmpty(
const ASTContext &
C,
unsigned N,
847 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
848 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N, N));
849 auto *Clause =
new (Mem) OMPReductionClause(N);
850 Clause->setModifier(Modifier);
855 assert(
Privates.size() == varlist_size() &&
856 "Number of private copies is not the same as the preallocated buffer");
857 llvm::copy(
Privates, varlist_end());
862 LHSExprs.size() == varlist_size() &&
863 "Number of LHS expressions is not the same as the preallocated buffer");
869 RHSExprs.size() == varlist_size() &&
870 "Number of RHS expressions is not the same as the preallocated buffer");
871 llvm::copy(RHSExprs, getLHSExprs().end());
874void OMPTaskReductionClause::setReductionOps(
ArrayRef<Expr *> ReductionOps) {
875 assert(ReductionOps.size() == varlist_size() &&
"Number of task reduction "
876 "expressions is not the same "
877 "as the preallocated buffer");
878 llvm::copy(ReductionOps, getRHSExprs().end());
881OMPTaskReductionClause *OMPTaskReductionClause::Create(
888 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
889 OMPTaskReductionClause *Clause =
new (Mem) OMPTaskReductionClause(
890 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
891 Clause->setVarRefs(VL);
893 Clause->setLHSExprs(LHSExprs);
894 Clause->setRHSExprs(RHSExprs);
895 Clause->setReductionOps(ReductionOps);
896 Clause->setPreInitStmt(PreInit);
897 Clause->setPostUpdateExpr(PostUpdate);
901OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(
const ASTContext &
C,
903 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
904 return new (Mem) OMPTaskReductionClause(N);
908 assert(
Privates.size() == varlist_size() &&
909 "Number of private copies is not the same as the preallocated buffer");
910 llvm::copy(
Privates, varlist_end());
915 LHSExprs.size() == varlist_size() &&
916 "Number of LHS expressions is not the same as the preallocated buffer");
922 RHSExprs.size() == varlist_size() &&
923 "Number of RHS expressions is not the same as the preallocated buffer");
924 llvm::copy(RHSExprs, getLHSExprs().end());
928 assert(ReductionOps.size() == varlist_size() &&
"Number of in reduction "
929 "expressions is not the same "
930 "as the preallocated buffer");
931 llvm::copy(ReductionOps, getRHSExprs().end());
934void OMPInReductionClause::setTaskgroupDescriptors(
936 assert(TaskgroupDescriptors.size() == varlist_size() &&
937 "Number of in reduction descriptors is not the same as the "
938 "preallocated buffer");
939 llvm::copy(TaskgroupDescriptors, getReductionOps().end());
942OMPInReductionClause *OMPInReductionClause::Create(
949 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
950 OMPInReductionClause *Clause =
new (Mem) OMPInReductionClause(
951 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
952 Clause->setVarRefs(VL);
954 Clause->setLHSExprs(LHSExprs);
955 Clause->setRHSExprs(RHSExprs);
956 Clause->setReductionOps(ReductionOps);
957 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
958 Clause->setPreInitStmt(PreInit);
959 Clause->setPostUpdateExpr(PostUpdate);
963OMPInReductionClause *OMPInReductionClause::CreateEmpty(
const ASTContext &
C,
965 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
966 return new (Mem) OMPInReductionClause(N);
975 Clause->setLocStart(StartLoc);
976 Clause->setLParenLoc(LParenLoc);
977 Clause->setLocEnd(EndLoc);
978 Clause->setSizesRefs(Sizes);
984 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
985 return new (Mem) OMPSizesClause(NumSizes);
993 OMPPermutationClause *Clause =
CreateEmpty(
C, Args.size());
994 Clause->setLocStart(StartLoc);
995 Clause->setLParenLoc(LParenLoc);
996 Clause->setLocEnd(EndLoc);
997 Clause->setArgRefs(Args);
1002 unsigned NumLoops) {
1003 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumLoops));
1004 return new (Mem) OMPPermutationClause(NumLoops);
1011 Clause->setLocStart(StartLoc);
1012 Clause->setLocEnd(EndLoc);
1017 return new (
C) OMPFullClause();
1026 Clause->setLocStart(StartLoc);
1027 Clause->setLParenLoc(LParenLoc);
1028 Clause->setLocEnd(EndLoc);
1029 Clause->setFactor(Factor);
1034 return new (
C) OMPPartialClause();
1043 Clause->setLocStart(StartLoc);
1044 Clause->setLParenLoc(LParenLoc);
1045 Clause->setFirstLoc(FirstLoc);
1046 Clause->setCountLoc(CountLoc);
1047 Clause->setLocEnd(EndLoc);
1048 Clause->setFirst(
First);
1049 Clause->setCount(Count);
1054 return new (
C) OMPLoopRangeClause();
1065 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1066 auto *Clause =
new (Mem) OMPAllocateClause(
1067 StartLoc, LParenLoc, Allocator, Alignment, ColonLoc, Modifier1,
1068 Modifier1Loc, Modifier2, Modifier2Loc, EndLoc, VL.size());
1070 Clause->setVarRefs(VL);
1076 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1077 return new (Mem) OMPAllocateClause(N);
1085 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
1086 OMPFlushClause *Clause =
1087 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1088 Clause->setVarRefs(VL);
1093 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1094 return new (Mem) OMPFlushClause(N);
1102 auto *Clause =
new (
C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
1103 Clause->setDepobj(Depobj);
1108 return new (
C) OMPDepobjClause();
1116 void *Mem =
C.Allocate(
1117 totalSizeToAlloc<Expr *>(VL.size() + 1 + NumLoops),
1118 alignof(OMPDependClause));
1119 OMPDependClause *Clause =
new (Mem)
1120 OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1121 Clause->setDependencyKind(Data.DepKind);
1122 Clause->setDependencyLoc(Data.DepLoc);
1123 Clause->setColonLoc(Data.ColonLoc);
1124 Clause->setOmpAllMemoryLoc(Data.OmpAllMemoryLoc);
1125 Clause->setModifier(DepModifier);
1126 Clause->setVarRefs(VL);
1127 for (
unsigned I = 0 ; I < NumLoops; ++I)
1128 Clause->setLoopData(I,
nullptr);
1133 unsigned NumLoops) {
1135 C.Allocate(totalSizeToAlloc<Expr *>(N + 1 + NumLoops),
1136 alignof(OMPDependClause));
1137 return new (Mem) OMPDependClause(N, NumLoops);
1143 NumLoop < NumLoops &&
1144 "Expected sink or source depend + loop index must be less number of "
1146 auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1153 NumLoop < NumLoops &&
1154 "Expected sink or source depend + loop index must be less number of "
1156 auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1163 NumLoop < NumLoops &&
1164 "Expected sink or source depend + loop index must be less number of "
1166 const auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1170void OMPDependClause::setModifier(
Expr *DepModifier) {
1171 *getVarRefs().end() = DepModifier;
1177 unsigned TotalNum = 0u;
1178 for (
auto &
C : ComponentLists)
1179 TotalNum +=
C.size();
1186 for (
const ValueDecl *D : Declarations) {
1188 UniqueDecls.insert(VD);
1190 return UniqueDecls.size();
1196 "Cannot get element-type from array-shaping expr.");
1210 if (
const auto *ATy = BaseType->getAsArrayTypeUnsafe())
1211 ElemTy = ATy->getElementType();
1219std::pair<const Expr *, std::optional<size_t>>
1225 if (Components.size() < 2)
1226 return {
nullptr, std::nullopt};
1231 if (Components.back().isNonContiguous() && CurDirKind == OMPD_target_update)
1232 return {
nullptr, std::nullopt};
1238 for (
auto [I, Component] : llvm::enumerate(Components)) {
1243 const Expr *CurExpr = Component.getAssociatedExpression();
1258 return {CurExpr, Components.size() - I};
1261 return {
nullptr, std::nullopt};
1288 void *Mem =
C.Allocate(
1294 OMPMapClause *Clause =
new (Mem)
1295 OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1298 Clause->setVarRefs(Vars);
1299 Clause->setUDMapperRefs(UDMapperRefs);
1300 Clause->setIteratorModifier(IteratorModifier);
1301 Clause->setClauseInfo(Declarations, ComponentLists);
1302 Clause->setMapType(
Type);
1310 void *Mem =
C.Allocate(
1316 OMPMapClause *Clause =
new (Mem) OMPMapClause(Sizes);
1317 Clause->setIteratorModifier(
nullptr);
1344 void *Mem =
C.Allocate(
1351 auto *Clause =
new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc,
1352 UDMQualifierLoc, MapperId, Locs, Sizes);
1354 Clause->setVarRefs(Vars);
1355 Clause->setUDMapperRefs(UDMapperRefs);
1356 Clause->setClauseInfo(Declarations, ComponentLists);
1357 Clause->setIteratorModifier(IteratorModifier);
1363 void *Mem =
C.Allocate(
1369 OMPToClause *Clause =
new (Mem) OMPToClause(Sizes);
1370 Clause->setIteratorModifier(
nullptr);
1397 void *Mem =
C.Allocate(
1405 new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc,
1406 UDMQualifierLoc, MapperId, Locs, Sizes);
1408 Clause->setVarRefs(Vars);
1409 Clause->setUDMapperRefs(UDMapperRefs);
1410 Clause->setClauseInfo(Declarations, ComponentLists);
1411 Clause->setIteratorModifier(IteratorModifier);
1418 void *Mem =
C.Allocate(
1424 OMPFromClause *Clause =
new (Mem) OMPFromClause(Sizes);
1425 Clause->setIteratorModifier(
nullptr);
1430 assert(VL.size() == varlist_size() &&
1431 "Number of private copies is not the same as the preallocated buffer");
1432 llvm::copy(VL, varlist_end());
1436 assert(VL.size() == varlist_size() &&
1437 "Number of inits is not the same as the preallocated buffer");
1438 llvm::copy(VL, getPrivateCopies().end());
1464 void *Mem =
C.Allocate(
1471 OMPUseDevicePtrClause *Clause =
new (Mem)
1472 OMPUseDevicePtrClause(Locs, Sizes, FallbackModifier, FallbackModifierLoc);
1474 Clause->setVarRefs(Vars);
1475 Clause->setPrivateCopies(PrivateVars);
1476 Clause->setInits(
Inits);
1477 Clause->setClauseInfo(Declarations, ComponentLists);
1484 void *Mem =
C.Allocate(
1490 return new (Mem) OMPUseDevicePtrClause(Sizes);
1514 void *Mem =
C.Allocate(
1521 auto *Clause =
new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
1523 Clause->setVarRefs(Vars);
1524 Clause->setClauseInfo(Declarations, ComponentLists);
1531 void *Mem =
C.Allocate(
1537 return new (Mem) OMPUseDeviceAddrClause(Sizes);
1561 void *Mem =
C.Allocate(
1568 OMPIsDevicePtrClause *Clause =
new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1570 Clause->setVarRefs(Vars);
1571 Clause->setClauseInfo(Declarations, ComponentLists);
1578 void *Mem =
C.Allocate(
1584 return new (Mem) OMPIsDevicePtrClause(Sizes);
1608 void *Mem =
C.Allocate(
1615 auto *Clause =
new (Mem) OMPHasDeviceAddrClause(Locs, Sizes);
1617 Clause->setVarRefs(Vars);
1618 Clause->setClauseInfo(Declarations, ComponentLists);
1625 void *Mem =
C.Allocate(
1631 return new (Mem) OMPHasDeviceAddrClause(Sizes);
1640 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1642 new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
1643 Clause->setVarRefs(VL);
1649 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1650 return new (Mem) OMPNontemporalClause(N);
1654 assert(VL.size() == varlist_size() &&
"Number of private references is not "
1655 "the same as the preallocated buffer");
1656 llvm::copy(VL, varlist_end());
1664 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1666 new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1667 Clause->setVarRefs(VL);
1673 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1674 return new (Mem) OMPInclusiveClause(N);
1682 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1684 new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1685 Clause->setVarRefs(VL);
1691 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1692 return new (Mem) OMPExclusiveClause(N);
1695void OMPUsesAllocatorsClause::setAllocatorsData(
1697 assert(
Data.size() == NumOfAllocators &&
1698 "Size of allocators data is not the same as the preallocated buffer.");
1699 for (
unsigned I = 0, E =
Data.size(); I < E; ++I) {
1701 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1702 static_cast<int>(ExprOffsets::Allocator)] =
1704 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1706 ExprOffsets::AllocatorTraits)] =
1709 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1710 static_cast<int>(ParenLocsOffsets::LParen)] =
1713 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1714 static_cast<int>(ParenLocsOffsets::RParen)] =
1719OMPUsesAllocatorsClause::Data
1723 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1724 static_cast<int>(ExprOffsets::Allocator)];
1726 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1728 ExprOffsets::AllocatorTraits)];
1730 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1731 static_cast<int>(ParenLocsOffsets::LParen)];
1733 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1734 static_cast<int>(ParenLocsOffsets::RParen)];
1742 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1743 static_cast<int>(ExprOffsets::Total) *
Data.size(),
1744 static_cast<int>(ParenLocsOffsets::Total) *
Data.size()));
1745 auto *Clause =
new (Mem)
1746 OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc,
Data.size());
1747 Clause->setAllocatorsData(
Data);
1753 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1754 static_cast<int>(ExprOffsets::Total) * N,
1755 static_cast<int>(ParenLocsOffsets::Total) * N));
1756 return new (Mem) OMPUsesAllocatorsClause(N);
1764 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1765 auto *Clause =
new (Mem)
1766 OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
1767 Clause->setModifier(Modifier);
1768 Clause->setVarRefs(Locators);
1774 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1775 return new (Mem) OMPAffinityClause(N);
1786 C.Allocate(totalSizeToAlloc<Expr *>(InteropInfo.
PreferTypes.size() + 1));
1787 auto *Clause =
new (Mem) OMPInitClause(
1789 VarLoc, EndLoc, InteropInfo.
PreferTypes.size() + 1);
1790 Clause->setInteropVar(InteropVar);
1791 llvm::copy(InteropInfo.
PreferTypes, Clause->getTrailingObjects() + 1);
1796 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1797 return new (Mem) OMPInitClause(N);
1804 return new (
C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
1808 return new (
C) OMPBindClause();
1817 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops),
1818 alignof(OMPDoacrossClause));
1819 OMPDoacrossClause *Clause =
new (Mem)
1820 OMPDoacrossClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1821 Clause->setDependenceType(DepType);
1822 Clause->setDependenceLoc(DepLoc);
1823 Clause->setColonLoc(ColonLoc);
1824 Clause->setVarRefs(VL);
1825 for (
unsigned I = 0; I < NumLoops; ++I)
1826 Clause->setLoopData(I,
nullptr);
1832 unsigned NumLoops) {
1833 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops),
1834 alignof(OMPDoacrossClause));
1835 return new (Mem) OMPDoacrossClause(N, NumLoops);
1839 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1840 auto *It = std::next(getVarRefs().end(), NumLoop);
1845 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1846 auto *It = std::next(getVarRefs().end(), NumLoop);
1851 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1852 const auto *It = std::next(getVarRefs().end(), NumLoop);
1856OMPAbsentClause *OMPAbsentClause::Create(
const ASTContext &
C,
1861 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1862 alignof(OMPAbsentClause));
1863 auto *AC =
new (Mem) OMPAbsentClause(Loc, LLoc, RLoc, DKVec.size());
1864 AC->setDirectiveKinds(DKVec);
1868OMPAbsentClause *OMPAbsentClause::CreateEmpty(
const ASTContext &
C,
unsigned K) {
1869 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1870 alignof(OMPAbsentClause));
1871 return new (Mem) OMPAbsentClause(K);
1874OMPContainsClause *OMPContainsClause::Create(
1877 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1878 alignof(OMPContainsClause));
1879 auto *CC =
new (Mem) OMPContainsClause(Loc, LLoc, RLoc, DKVec.size());
1880 CC->setDirectiveKinds(DKVec);
1884OMPContainsClause *OMPContainsClause::CreateEmpty(
const ASTContext &
C,
1886 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1887 alignof(OMPContainsClause));
1888 return new (Mem) OMPContainsClause(K);
1895 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1896 OMPNumTeamsClause *Clause =
1897 new (Mem) OMPNumTeamsClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1898 Clause->setVarRefs(VL);
1899 Clause->setPreInitStmt(PreInit, CaptureRegion);
1905 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1906 return new (Mem) OMPNumTeamsClause(N);
1913 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1914 OMPThreadLimitClause *Clause =
1915 new (Mem) OMPThreadLimitClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1916 Clause->setVarRefs(VL);
1917 Clause->setPreInitStmt(PreInit, CaptureRegion);
1923 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1924 return new (Mem) OMPThreadLimitClause(N);
1931void OMPClausePrinter::VisitOMPIfClause(
OMPIfClause *Node) {
1934 OS << getOpenMPDirectiveName(Node->
getNameModifier(), Version) <<
": ";
1939void OMPClausePrinter::VisitOMPFinalClause(
OMPFinalClause *Node) {
1946 OS <<
"num_threads(";
1956void OMPClausePrinter::VisitOMPAlignClause(
OMPAlignClause *Node) {
1974void OMPClausePrinter::VisitOMPSizesClause(
OMPSizesClause *Node) {
1980 Size->printPretty(OS,
nullptr, Policy, 0);
1987 OS <<
"permutation(";
1989 E->printPretty(OS, nullptr, Policy, 0);
1994void OMPClausePrinter::VisitOMPFullClause(
OMPFullClause *Node) {
OS <<
"full"; }
2001 Factor->printPretty(OS,
nullptr, Policy, 0);
2012 if (
First && Count) {
2014 First->printPretty(OS,
nullptr, Policy, 0);
2033void OMPClausePrinter::VisitOMPDetachClause(OMPDetachClause *Node) {
2043 if (Version >= 60 && Node->
getDefaultVC() != OMPC_DEFAULT_VC_all) {
2058void OMPClausePrinter::VisitOMPTransparentClause(OMPTransparentClause *Node) {
2059 OS <<
"transparent(";
2060 Node->getImpexType()->printPretty(OS,
nullptr, Policy, 0);
2064void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
2067 unsigned(Node->getProcBindKind()))
2071void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
2072 OS <<
"unified_address";
2075void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
2076 OMPUnifiedSharedMemoryClause *) {
2077 OS <<
"unified_shared_memory";
2080void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
2081 OS <<
"reverse_offload";
2084void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
2085 OMPDynamicAllocatorsClause *) {
2086 OS <<
"dynamic_allocators";
2089void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
2090 OMPAtomicDefaultMemOrderClause *Node) {
2091 OS <<
"atomic_default_mem_order("
2093 Node->getAtomicDefaultMemOrderKind())
2097void OMPClausePrinter::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {
2101void OMPClausePrinter::VisitOMPAtClause(OMPAtClause *Node) {
2106void OMPClausePrinter::VisitOMPSeverityClause(OMPSeverityClause *Node) {
2112void OMPClausePrinter::VisitOMPMessageClause(OMPMessageClause *Node) {
2114 if (
Expr *E = Node->getMessageString())
2115 E->printPretty(OS,
nullptr, Policy);
2119void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
2123 Node->getFirstScheduleModifier());
2127 Node->getSecondScheduleModifier());
2132 if (
auto *E = Node->getChunkSize()) {
2134 E->printPretty(OS,
nullptr, Policy);
2139void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
2141 if (
auto *
Num = Node->getNumForLoops()) {
2143 Num->printPretty(OS,
nullptr, Policy, 0);
2148void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *Node) {
2150 if (
auto *
Cond = Node->getCondition()) {
2152 Cond->printPretty(OS,
nullptr, Policy, 0);
2157void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
2161void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
2165void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
2169void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) {
OS <<
"read"; }
2171void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) {
OS <<
"write"; }
2173void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *Node) {
2175 if (Node->isExtended()) {
2178 Node->getDependencyKind());
2183void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
2187void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) {
2191void OMPClausePrinter::VisitOMPFailClause(OMPFailClause *Node) {
2196 Node->getClauseKind(),
static_cast<int>(Node->getFailParameter()));
2201void OMPClausePrinter::VisitOMPAbsentClause(OMPAbsentClause *Node) {
2204 for (
auto &D : Node->getDirectiveKinds()) {
2207 OS << getOpenMPDirectiveName(D, Version);
2213void OMPClausePrinter::VisitOMPHoldsClause(OMPHoldsClause *Node) {
2215 Node->getExpr()->printPretty(OS,
nullptr, Policy, 0);
2219void OMPClausePrinter::VisitOMPContainsClause(OMPContainsClause *Node) {
2222 for (
auto &D : Node->getDirectiveKinds()) {
2225 OS << getOpenMPDirectiveName(D, Version);
2231void OMPClausePrinter::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {
2235void OMPClausePrinter::VisitOMPNoOpenMPRoutinesClause(
2236 OMPNoOpenMPRoutinesClause *) {
2237 OS <<
"no_openmp_routines";
2240void OMPClausePrinter::VisitOMPNoOpenMPConstructsClause(
2241 OMPNoOpenMPConstructsClause *) {
2242 OS <<
"no_openmp_constructs";
2245void OMPClausePrinter::VisitOMPNoParallelismClause(OMPNoParallelismClause *) {
2246 OS <<
"no_parallelism";
2249void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
2253void OMPClausePrinter::VisitOMPAcqRelClause(OMPAcqRelClause *) {
2257void OMPClausePrinter::VisitOMPAcquireClause(OMPAcquireClause *) {
2261void OMPClausePrinter::VisitOMPReleaseClause(OMPReleaseClause *) {
2265void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) {
2269void OMPClausePrinter::VisitOMPWeakClause(OMPWeakClause *) {
OS <<
"weak"; }
2271void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
2275void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) {
OS <<
"simd"; }
2277void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
2288void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
2289 if (!Node->varlist_empty()) {
2291 VisitOMPClauseList(Node,
'(');
2296void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
2297 if (!Node->varlist_empty()) {
2298 OS <<
"thread_limit";
2299 VisitOMPClauseList(Node,
'(');
2304void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
2310void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
2321void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
2332void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
2338void OMPClausePrinter::VisitOMPInitClause(OMPInitClause *Node) {
2343 OS <<
"prefer_type(";
2346 E->printPretty(OS,
nullptr, Policy);
2363void OMPClausePrinter::VisitOMPUseClause(OMPUseClause *Node) {
2369void OMPClausePrinter::VisitOMPDestroyClause(OMPDestroyClause *Node) {
2373 E->printPretty(OS,
nullptr, Policy);
2378void OMPClausePrinter::VisitOMPNovariantsClause(OMPNovariantsClause *Node) {
2382 E->printPretty(OS,
nullptr, Policy, 0);
2387void OMPClausePrinter::VisitOMPNocontextClause(OMPNocontextClause *Node) {
2391 E->printPretty(OS,
nullptr, Policy, 0);
2397void OMPClausePrinter::VisitOMPClauseList(
T *Node,
char StartSym) {
2398 for (
typename T::varlist_iterator I = Node->varlist_begin(),
2399 E = Node->varlist_end();
2401 assert(*I &&
"Expected non-null Stmt");
2402 OS << (I == Node->varlist_begin() ? StartSym :
',');
2403 if (
auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
2405 DRE->printPretty(OS,
nullptr, Policy, 0);
2407 DRE->getDecl()->printQualifiedName(OS);
2409 (*I)->printPretty(OS,
nullptr, Policy, 0);
2417 Expr *FirstModifier =
nullptr;
2418 Expr *SecondModifier =
nullptr;
2423 if (FirstAllocMod == OMPC_ALLOCATE_allocator ||
2434 if (FirstModifier) {
2436 if (!FirstUnknown) {
2440 FirstModifier->
printPretty(OS,
nullptr, Policy, 0);
2443 if (SecondModifier) {
2445 if (!SecondUnknown) {
2450 SecondModifier->
printPretty(OS,
nullptr, Policy, 0);
2455 VisitOMPClauseList(Node,
' ');
2458 VisitOMPClauseList(Node,
'(');
2463void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
2464 if (!Node->varlist_empty()) {
2466 VisitOMPClauseList(Node,
'(');
2471void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
2472 if (!Node->varlist_empty()) {
2473 OS <<
"firstprivate";
2474 VisitOMPClauseList(Node,
'(');
2479void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
2480 if (!Node->varlist_empty()) {
2481 OS <<
"lastprivate";
2493void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
2494 if (!Node->varlist_empty()) {
2496 VisitOMPClauseList(Node,
'(');
2501void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
2502 if (!Node->varlist_empty()) {
2504 if (Node->getModifierLoc().isValid())
2508 Node->getQualifierLoc().getNestedNameSpecifier();
2510 Node->getNameInfo().getName().getCXXOverloadedOperator();
2511 if (!Qualifier && OOK !=
OO_None) {
2517 OS << Node->getNameInfo();
2520 VisitOMPClauseList(Node,
' ');
2525void OMPClausePrinter::VisitOMPTaskReductionClause(
2526 OMPTaskReductionClause *Node) {
2527 if (!Node->varlist_empty()) {
2528 OS <<
"task_reduction(";
2530 Node->getQualifierLoc().getNestedNameSpecifier();
2532 Node->getNameInfo().getName().getCXXOverloadedOperator();
2533 if (!Qualifier && OOK !=
OO_None) {
2539 OS << Node->getNameInfo();
2542 VisitOMPClauseList(Node,
' ');
2547void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
2548 if (!Node->varlist_empty()) {
2549 OS <<
"in_reduction(";
2551 Node->getQualifierLoc().getNestedNameSpecifier();
2553 Node->getNameInfo().getName().getCXXOverloadedOperator();
2554 if (!Qualifier && OOK !=
OO_None) {
2560 OS << Node->getNameInfo();
2563 VisitOMPClauseList(Node,
' ');
2568void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
2569 if (!Node->varlist_empty()) {
2571 VisitOMPClauseList(Node,
'(');
2572 if (Node->getModifierLoc().isValid() || Node->getStep() !=
nullptr) {
2575 if (Node->getModifierLoc().isValid()) {
2578 if (Node->getStep() !=
nullptr) {
2579 if (Node->getModifierLoc().isValid()) {
2583 Node->getStep()->printPretty(OS,
nullptr, Policy, 0);
2590void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
2591 if (!Node->varlist_empty()) {
2593 VisitOMPClauseList(Node,
'(');
2602void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
2603 if (!Node->varlist_empty()) {
2605 VisitOMPClauseList(Node,
'(');
2610void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
2611 if (!Node->varlist_empty()) {
2612 OS <<
"copyprivate";
2613 VisitOMPClauseList(Node,
'(');
2618void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
2619 if (!Node->varlist_empty()) {
2620 VisitOMPClauseList(Node,
'(');
2625void OMPClausePrinter::VisitOMPDepobjClause(OMPDepobjClause *Node) {
2631void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
2639 bool IsOmpAllMemory =
false;
2640 if (PrintKind == OMPC_DEPEND_outallmemory) {
2641 PrintKind = OMPC_DEPEND_out;
2642 IsOmpAllMemory =
true;
2643 }
else if (PrintKind == OMPC_DEPEND_inoutallmemory) {
2644 PrintKind = OMPC_DEPEND_inout;
2645 IsOmpAllMemory =
true;
2648 if (!Node->varlist_empty() || IsOmpAllMemory)
2650 VisitOMPClauseList(Node,
' ');
2651 if (IsOmpAllMemory) {
2652 OS << (Node->varlist_empty() ?
" " :
",");
2653 OS <<
"omp_all_memory";
2658template <
typename T>
2663 Node->getMapperQualifierLoc().getNestedNameSpecifier();
2664 MapperNNS.
print(OS, Policy);
2665 OS << Node->getMapperIdInfo() <<
')';
2668template <
typename T>
2671 if (
Expr *IteratorModifier = Node->getIteratorModifier())
2672 IteratorModifier->printPretty(OS,
nullptr, Policy);
2675void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
2676 if (!Node->varlist_empty()) {
2695 VisitOMPClauseList(Node,
' ');
2700template <
typename T>
void OMPClausePrinter::VisitOMPMotionClause(
T *Node) {
2701 if (Node->varlist_empty())
2703 OS << getOpenMPClauseName(Node->getClauseKind());
2704 unsigned ModifierCount = 0;
2709 if (ModifierCount) {
2713 if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator) {
2717 Node->getMotionModifier(I));
2718 if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2720 if (I < ModifierCount - 1)
2726 VisitOMPClauseList(Node,
' ');
2728 VisitOMPClauseList(Node,
'(');
2733void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
2734 VisitOMPMotionClause(Node);
2737void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
2738 VisitOMPMotionClause(Node);
2741void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
2746 E->printPretty(OS,
nullptr, Policy);
2751void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
2752 OS <<
"defaultmap(";
2763void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
2764 if (!Node->varlist_empty()) {
2765 OS <<
"use_device_ptr";
2771 VisitOMPClauseList(Node,
' ');
2773 VisitOMPClauseList(Node,
'(');
2779void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2780 OMPUseDeviceAddrClause *Node) {
2781 if (!Node->varlist_empty()) {
2782 OS <<
"use_device_addr";
2783 VisitOMPClauseList(Node,
'(');
2788void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
2789 if (!Node->varlist_empty()) {
2790 OS <<
"is_device_ptr";
2791 VisitOMPClauseList(Node,
'(');
2796void OMPClausePrinter::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *Node) {
2797 if (!Node->varlist_empty()) {
2798 OS <<
"has_device_addr";
2799 VisitOMPClauseList(Node,
'(');
2804void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) {
2805 if (!Node->varlist_empty()) {
2806 OS <<
"nontemporal";
2807 VisitOMPClauseList(Node,
'(');
2812void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) {
2821void OMPClausePrinter::VisitOMPInclusiveClause(OMPInclusiveClause *Node) {
2822 if (!Node->varlist_empty()) {
2824 VisitOMPClauseList(Node,
'(');
2829void OMPClausePrinter::VisitOMPExclusiveClause(OMPExclusiveClause *Node) {
2830 if (!Node->varlist_empty()) {
2832 VisitOMPClauseList(Node,
'(');
2837void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2838 OMPUsesAllocatorsClause *Node) {
2841 OS <<
"uses_allocators(";
2844 Data.Allocator->printPretty(OS,
nullptr, Policy);
2845 if (
Data.AllocatorTraits) {
2847 Data.AllocatorTraits->printPretty(OS,
nullptr, Policy);
2856void OMPClausePrinter::VisitOMPAffinityClause(OMPAffinityClause *Node) {
2857 if (Node->varlist_empty())
2860 char StartSym =
'(';
2863 Modifier->printPretty(OS,
nullptr, Policy);
2867 VisitOMPClauseList(Node, StartSym);
2871void OMPClausePrinter::VisitOMPFilterClause(OMPFilterClause *Node) {
2877void OMPClausePrinter::VisitOMPBindClause(OMPBindClause *Node) {
2883void OMPClausePrinter::VisitOMPXDynCGroupMemClause(
2884 OMPXDynCGroupMemClause *Node) {
2885 OS <<
"ompx_dyn_cgroup_mem(";
2890void OMPClausePrinter::VisitOMPDynGroupprivateClause(
2891 OMPDynGroupprivateClause *Node) {
2892 OS <<
"dyn_groupprivate(";
2908void OMPClausePrinter::VisitOMPDoacrossClause(OMPDoacrossClause *Node) {
2913 case OMPC_DOACROSS_source:
2916 case OMPC_DOACROSS_sink:
2919 case OMPC_DOACROSS_source_omp_cur_iteration:
2920 OS <<
"source: omp_cur_iteration";
2922 case OMPC_DOACROSS_sink_omp_cur_iteration:
2923 OS <<
"sink: omp_cur_iteration - 1";
2926 llvm_unreachable(
"unknown docaross modifier");
2928 VisitOMPClauseList(Node,
' ');
2932void OMPClausePrinter::VisitOMPXAttributeClause(OMPXAttributeClause *Node) {
2933 OS <<
"ompx_attribute(";
2944void OMPClausePrinter::VisitOMPXBareClause(OMPXBareClause *Node) {
2949 VariantMatchInfo &VMI)
const {
2954 if (
Selector.Kind == TraitSelector::user_condition) {
2955 assert(
Selector.ScoreOrCondition &&
2956 "Ill-formed user condition, expected condition expression!");
2957 assert(
Selector.Properties.size() == 1 &&
2958 Selector.Properties.front().Kind ==
2959 TraitProperty::user_condition_unknown &&
2960 "Ill-formed user condition, expected unknown trait property!");
2962 if (std::optional<APSInt> CondVal =
2963 Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2964 VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
2965 : TraitProperty::user_condition_true,
2968 VMI.addTrait(TraitProperty::user_condition_false,
"<condition>");
2972 std::optional<llvm::APSInt> Score;
2973 llvm::APInt *ScorePtr =
nullptr;
2975 if ((Score =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
2978 VMI.addTrait(TraitProperty::user_condition_false,
2979 "<non-constant-score>");
2983 VMI.addTrait(
Set.Kind, Property.Kind, Property.RawString, ScorePtr);
2985 if (
Set.Kind != TraitSet::construct)
2989 assert(
Selector.Properties.size() == 1 &&
2990 Selector.Properties.front().Kind ==
2991 getOpenMPContextTraitPropertyForSelector(
2993 "Ill-formed construct selector!");
3000 bool FirstSet =
true;
3005 OS << getOpenMPContextTraitSetName(
Set.Kind) <<
"={";
3007 bool FirstSelector =
true;
3011 FirstSelector =
false;
3012 OS << getOpenMPContextTraitSelectorName(
Selector.Kind);
3014 bool AllowsTraitScore =
false;
3015 bool RequiresProperty =
false;
3016 isValidTraitSelectorForTraitSet(
3017 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
3019 if (!RequiresProperty)
3023 if (
Selector.Kind == TraitSelector::user_condition) {
3025 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
3032 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
3036 bool FirstProperty =
true;
3040 FirstProperty =
false;
3041 OS << getOpenMPContextTraitPropertyName(Property.Kind,
3042 Property.RawString);
3052 std::string MangledName;
3053 llvm::raw_string_ostream OS(MangledName);
3058 bool AllowsTraitScore =
false;
3059 bool RequiresProperty =
false;
3060 isValidTraitSelectorForTraitSet(
3061 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
3064 if (!RequiresProperty ||
3065 Selector.Kind == TraitSelector::user_condition)
3070 << getOpenMPContextTraitPropertyName(Property.Kind,
3071 Property.RawString);
3077OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
3080 if (!MangledName.consume_front(
"$S"))
3082 if (MangledName.consumeInteger(10,
U))
3086 Set.Kind = TraitSet(
U);
3088 if (!MangledName.consume_front(
"$s"))
3090 if (MangledName.consumeInteger(10,
U))
3096 if (!MangledName.consume_front(
"$P"))
3100 std::pair<StringRef, StringRef> PropRestPair = MangledName.split(
'$');
3101 Property.RawString = PropRestPair.first;
3102 Property.Kind = getOpenMPContextTraitPropertyKind(
3104 MangledName = MangledName.drop_front(PropRestPair.first.size());
3114 TI.
print(OS, Policy);
3119 return TI ? OS << *TI : OS;
3126 : OMPContext(ASTCtx.getLangOpts().OpenMPIsTargetDevice,
3127 ASTCtx.getTargetInfo().getTriple(),
3128 ASTCtx.getLangOpts().OMPTargetTriples.empty()
3130 : ASTCtx.getLangOpts().OMPTargetTriples[0],
3132 FeatureValidityCheck([&](StringRef FeatureName) {
3133 return ASTCtx.
getTargetInfo().isValidFeatureName(FeatureName);
3135 DiagUnknownTrait(std::move(DiagUnknownTrait)) {
3138 for (llvm::omp::TraitProperty Property : ConstructTraits)
3143 auto It = FeatureMap.find(RawString);
3144 if (It != FeatureMap.end())
3146 if (!FeatureValidityCheck(RawString))
3147 DiagUnknownTrait(RawString);
Defines the clang::ASTContext interface.
This file defines OpenMP nodes for declarative directives.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static Stmt ** getAddrOfExprAsWritten(Stmt *S)
Gets the address of the original, non-captured, expression used in the clause as the preinitializer.
static void PrintIterator(raw_ostream &OS, T *Node, const PrintingPolicy &Policy)
static void PrintMapper(raw_ostream &OS, T *Node, const PrintingPolicy &Policy)
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
This represents clause 'affinity' in the 'pragma omp task'-based directives.
static OMPAffinityClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Creates clause with a modifier a list of locator items.
Expr * getModifier()
Gets affinity modifier.
static OMPAffinityClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N locator items.
static OMPAlignedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Expr *A)
Creates clause with a list of variables VL and alignment A.
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Expr * getAlignment()
Returns alignment.
This represents 'bind' clause in the 'pragma omp ...' directives.
static OMPBindClause * Create(const ASTContext &C, OpenMPBindClauseKind K, SourceLocation KLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'bind' clause with kind K ('teams', 'parallel', or 'thread').
static OMPBindClause * CreateEmpty(const ASTContext &C)
Build an empty 'bind' clause.
OpenMPBindClauseKind getBindKind() const
Returns kind of the clause.
Class that represents a component of a mappable expression. E.g. for an expression S....
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl * > Declarations)
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
static std::pair< const Expr *, std::optional< size_t > > findAttachPtrExpr(MappableExprComponentListRef Components, OpenMPDirectiveKind CurDirKind)
Find the attach pointer expression from a list of mappable expression components.
static QualType getComponentExprElementType(const Expr *Exp)
Get the type of an element of a ComponentList Expr Exp.
ArrayRef< MappableComponent > MappableExprComponentListRef
static OMPCopyinClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPCopyprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
This represents implicit clause 'depend' for the 'pragma omp task' directive.
static OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VL, unsigned NumLoops)
Creates clause with a list of variables VL.
Expr * getModifier()
Return optional depend modifier.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with 'sink|source' kind of dependency.
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
static OMPDepobjClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Depobj)
Creates clause.
Expr * getDepobj()
Returns depobj expression associated with the clause.
static OMPDepobjClause * CreateEmpty(const ASTContext &C)
Creates an empty clause.
Expr * getInteropVar() const
Returns the interop variable.
Expr * getEventHandler() const
Returns event-handler expression.
This represents 'device' clause in the 'pragma omp ...' directive.
OpenMPDeviceClauseModifier getModifier() const
Gets modifier.
Expr * getDevice()
Return device number.
This represents 'dist_schedule' clause in the 'pragma omp ...' directive.
Expr * getChunkSize()
Get chunk size.
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
This represents the 'doacross' clause for the 'pragma omp ordered' directive.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data.
OpenMPDoacrossClauseModifier getDependenceType() const
Get dependence type.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
static OMPDoacrossClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VL, unsigned NumLoops)
Creates clause with a list of expressions VL.
static OMPDoacrossClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N expressions.
This represents 'dyn_groupprivate' clause in 'pragma omp target ...' and 'pragma omp teams ....
Expr * getSize()
Get size.
OpenMPDynGroupprivateClauseFallbackModifier getDynGroupprivateFallbackModifier() const
Get the second modifier of the clause.
OpenMPDynGroupprivateClauseModifier getDynGroupprivateModifier() const
Get the first modifier of the clause.
static OMPExclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPExclusiveClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
This represents 'filter' clause in the 'pragma omp ...' directive.
Expr * getThreadID() const
Return thread identifier.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
This represents clause 'from' in the 'pragma omp ...' directives.
static OMPFromClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, Expr *IteratorExpr, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents 'grainsize' clause in the 'pragma omp ...' directive.
OpenMPGrainsizeClauseModifier getModifier() const
Gets modifier.
Expr * getGrainsize() const
Return safe iteration space distance.
child_range used_children()
This represents clause 'has_device_ptr' in the 'pragma omp ...' directives.
static OMPHasDeviceAddrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPHasDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
Expr * getHint() const
Returns number of threads.
static OMPInclusiveClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
static OMPInclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
bool getIsTarget() const
Returns true is interop-type 'target' is used.
Expr * getInteropVar()
Returns the interop variable.
static OMPInitClause * Create(const ASTContext &C, Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Creates a fully specified clause.
static OMPInitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N expressions.
bool getIsTargetSync() const
Returns true is interop-type 'targetsync' is used.
This represents clause 'is_device_ptr' in the 'pragma omp ...' directives.
static OMPIsDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'map' in the 'pragma omp ...' directives.
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
static OMPMapClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapModifiers, ArrayRef< SourceLocation > MapModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId, OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc)
Creates clause with a list of variables VL.
static OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
This represents 'nocontext' clause in the 'pragma omp ...' directive.
Expr * getCondition() const
Returns condition.
child_range used_children()
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPNontemporalClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
void setPrivateRefs(ArrayRef< Expr * > VL)
Sets the list of references to private copies created in private clauses.
This represents 'novariants' clause in the 'pragma omp ...' directive.
Expr * getCondition() const
Returns condition.
child_range used_children()
This represents 'num_tasks' clause in the 'pragma omp ...' directive.
OpenMPNumTasksClauseModifier getModifier() const
Gets modifier.
child_range used_children()
Expr * getNumTasks() const
Return safe iteration space distance.
This represents 'num_teams' clause in the 'pragma omp ...' directive.
static OMPNumTeamsClause * Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Stmt *PreInit)
Creates clause with a list of variables VL.
static OMPNumTeamsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
OpenMPOrderClauseKind getKind() const
Returns kind of the clause.
OpenMPOrderClauseModifier getModifier() const
Returns Modifier of the clause.
This represents 'priority' clause in the 'pragma omp ...' directive.
child_range used_children()
Expr * getPriority()
Return Priority number.
This represents 'thread_limit' clause in the 'pragma omp ...' directive.
static OMPThreadLimitClause * Create(const ASTContext &C, OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Stmt *PreInit)
Creates clause with a list of variables VL.
static OMPThreadLimitClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPToClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, Expr *IteratorModifier, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
std::string getMangledName() const
Return a string representation identifying this context selector.
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Print a human readable representation into OS.
void getAsVariantMatchInfo(ASTContext &ASTCtx, llvm::omp::VariantMatchInfo &VMI) const
Create a variant match info object from this trait info object.
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
Expr * getInteropVar() const
Returns the interop variable.
This represents clause 'use_device_addr' in the 'pragma omp ...' directives.
static OMPUseDeviceAddrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPUseDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'use_device_ptr' in the 'pragma omp ...' directives.
static OMPUseDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< Expr * > PrivateVars, ArrayRef< Expr * > Inits, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, OpenMPUseDevicePtrFallbackModifier FallbackModifier, SourceLocation FallbackModifierLoc)
Creates clause with a list of variables Vars.
OpenMPUseDevicePtrFallbackModifier getFallbackModifier() const
Get the fallback modifier for the clause.
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'uses_allocators' in the 'pragma omp target'-based directives.
OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const
Returns data for the specified allocator.
static OMPUsesAllocatorsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N allocators.
static OMPUsesAllocatorsClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< OMPUsesAllocatorsClause::Data > Data)
Creates clause with a list of allocators Data.
unsigned getNumberOfAllocators() const
Returns number of allocators associated with the clause.
ArrayRef< const Attr * > getAttrs() const
Returned the attributes parsed from this clause.
This represents 'ompx_dyn_cgroup_mem' clause in the 'pragma omp target ...' directive.
Expr * getSize()
Return the size expression.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const TargetInfo & getTargetInfo() const
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
Attr - This represents one attribute.
void printPretty(raw_ostream &OS, const PrintingPolicy &Policy) const
This represents one expression.
Represents a function declaration or definition.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false, bool PrintFinalScopeResOp=true) const
Print this nested name specifier to the given output stream.
This represents the 'align' clause in the 'pragma omp allocate' directive.
Expr * getAlignment() const
Returns alignment.
static OMPAlignClause * Create(const ASTContext &C, Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'align' clause with the given alignment.
This represents clause 'allocate' in the 'pragma omp ...' directives.
static OMPAllocateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, Expr *Allocator, Expr *Alignment, SourceLocation ColonLoc, OpenMPAllocateClauseModifier Modifier1, SourceLocation Modifier1Loc, OpenMPAllocateClauseModifier Modifier2, SourceLocation Modifier2Loc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
OpenMPAllocateClauseModifier getSecondAllocateModifier() const
Get the second modifier of the clause.
Expr * getAlignment() const
Returns the alignment expression or nullptr, if no alignment specified.
OpenMPAllocateClauseModifier getFirstAllocateModifier() const
Get the first modifier of the clause.
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'allocator' clause in the 'pragma omp ...' directive.
Expr * getAllocator() const
Returns allocator.
static OMPClauseWithPostUpdate * get(OMPClause *C)
OMPClauseWithPostUpdate(const OMPClause *This)
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
OMPClauseWithPreInit(const OMPClause *This)
static OMPClauseWithPreInit * get(OMPClause *C)
This is a basic class for representing single OpenMP clause.
child_range used_children()
Get the iterator range for the expressions used in the clauses.
llvm::iterator_range< child_iterator > child_range
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
This represents 'collapse' clause in the 'pragma omp ...' directive.
Expr * getNumForLoops() const
Return the number of associated for-loops.
This represents 'default' clause in the 'pragma omp ...' directive.
llvm::omp::DefaultKind getDefaultKind() const
Returns kind of the clause.
OpenMPDefaultClauseVariableCategory getDefaultVC() const
This represents 'final' clause in the 'pragma omp ...' directive.
child_range used_children()
Expr * getCondition() const
Returns condition.
Representation of the 'full' clause of the 'pragma omp unroll' directive.
static OMPFullClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Build an AST node for a 'full' clause.
static OMPFullClause * CreateEmpty(const ASTContext &C)
Build an empty 'full' AST node for deserialization.
This represents 'if' clause in the 'pragma omp ...' directive.
child_range used_children()
Expr * getCondition() const
Returns condition.
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
This class represents the 'looprange' clause in the 'pragma omp fuse' directive.
Expr * getFirst() const
Get looprange 'first' expression.
static OMPLoopRangeClause * CreateEmpty(const ASTContext &C)
Build an empty 'looprange' clause node.
static OMPLoopRangeClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation FirstLoc, SourceLocation CountLoc, SourceLocation EndLoc, Expr *First, Expr *Count)
Build a 'looprange' clause AST node.
Expr * getCount() const
Get looprange 'count' expression.
This represents 'num_threads' clause in the 'pragma omp ...' directive.
OpenMPNumThreadsClauseModifier getModifier() const
Gets modifier.
Expr * getNumThreads() const
Returns number of threads.
llvm::iterator_range< child_iterator > child_range
Representation of the 'partial' clause of the 'pragma omp unroll' directive.
static OMPPartialClause * CreateEmpty(const ASTContext &C)
Build an empty 'partial' AST node for deserialization.
static OMPPartialClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Factor)
Build an AST node for a 'partial' clause.
Expr * getFactor() const
Returns the argument of the clause or nullptr if not set.
This class represents the 'permutation' clause in the 'pragma omp interchange' directive.
MutableArrayRef< Expr * > getArgsRefs()
Returns the permutation index expressions.
static OMPPermutationClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty 'permutation' AST node for deserialization.
static OMPPermutationClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Args)
Build a 'permutation' clause AST node.
This represents 'safelen' clause in the 'pragma omp ...' directive.
Expr * getSafelen() const
Return safe iteration space distance.
This represents 'simdlen' clause in the 'pragma omp ...' directive.
Expr * getSimdlen() const
Return safe iteration space distance.
This represents the 'sizes' clause in the 'pragma omp tile' directive.
static OMPSizesClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Sizes)
Build a 'sizes' AST node.
MutableArrayRef< Expr * > getSizesRefs()
Returns the tile size expressions.
static OMPSizesClause * CreateEmpty(const ASTContext &C, unsigned NumSizes)
Build an empty 'sizes' AST node for deserialization.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
OpenMPThreadsetKind getThreadsetKind() const
Returns kind of the clause.
bool varlist_empty() const
A (possibly-)qualified type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getCanonicalType() const
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
Stmt - This represents one statement.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Base wrapper for a particular "section" of type source info.
The base class of the type hierarchy.
bool isPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Defines the clang::TargetInfo interface.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
The JSON file list parser is used to communicate input to InstallAPI.
OpenMPOriginalSharingModifier
OpenMP 6.0 original sharing modifiers.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
Privates[]
This class represents the 'transparent' clause in the 'pragma omp task' directive.
bool isa(CodeGen::Address addr)
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
@ OMPC_ORDER_MODIFIER_unknown
MutableArrayRef< Expr * > getPrivates()
Finals[]; Step; CalcStep; }.
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ OMPC_SCHEDULE_MODIFIER_unknown
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
@ OMPC_DYN_GROUPPRIVATE_FALLBACK_unknown
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
const FunctionProtoType * T
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
@ OMPC_LASTPRIVATE_unknown
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
OpenMPUseDevicePtrFallbackModifier
OpenMP 6.1 use_device_ptr fallback modifier.
@ OMPC_USE_DEVICE_PTR_FALLBACK_unknown
MutableArrayRef< Expr * > getUsedExprs()
Gets the list of used expressions for linear variables.
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
@ OMPC_MOTION_MODIFIER_unknown
@ OMPC_DEFAULTMAP_unknown
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
@ OMPC_DYN_GROUPPRIVATE_unknown
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
MutableArrayRef< Expr * > getInits()
OpenMPNumThreadsClauseModifier
@ OMPC_NUMTHREADS_unknown
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
U cast(CodeGen::Address addr)
const char * getOpenMPDefaultVariableCategoryName(unsigned VC)
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
@ OMPC_MAP_MODIFIER_unknown
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Diagnostic wrappers for TextAPI types for error reporting.
int const char * function
This structure contains all sizes needed for by an OMPMappableExprListClause.
unsigned NumComponents
Total number of expression components.
unsigned NumUniqueDeclarations
Number of unique base declarations.
unsigned NumVars
Number of expressions listed.
unsigned NumComponentLists
Number of component lists.
Data for list of allocators.
Expr * AllocatorTraits
Allocator traits.
Expr * Allocator
Allocator.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
TargetOMPContext(ASTContext &ASTCtx, std::function< void(StringRef)> &&DiagUnknownTrait, const FunctionDecl *CurrentFunctionDecl, ArrayRef< llvm::omp::TraitProperty > ConstructTraits, int DeviceNum)
bool matchesISATrait(StringRef RawString) const override
See llvm::omp::OMPContext::matchesISATrait.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
llvm::SmallVector< Expr *, 4 > PreferTypes
This structure contains most locations needed for by an OMPVarListClause.
Describes how types, statements, expressions, and declarations should be printed.