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()) {
68 case OMPC_dist_schedule:
70 case OMPC_firstprivate:
72 case OMPC_lastprivate:
76 case OMPC_task_reduction:
78 case OMPC_in_reduction:
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:
124 case OMPC_copyprivate:
130 case OMPC_threadprivate:
131 case OMPC_groupprivate:
151 case OMPC_defaultmap:
156 case OMPC_use_device_ptr:
157 case OMPC_use_device_addr:
158 case OMPC_is_device_ptr:
159 case OMPC_has_device_addr:
160 case OMPC_unified_address:
161 case OMPC_unified_shared_memory:
162 case OMPC_reverse_offload:
163 case OMPC_dynamic_allocators:
164 case OMPC_atomic_default_mem_order:
168 case OMPC_device_type:
170 case OMPC_nontemporal:
176 case OMPC_uses_allocators:
195 switch (
C->getClauseKind()) {
196 case OMPC_lastprivate:
200 case OMPC_task_reduction:
202 case OMPC_in_reduction:
207 case OMPC_dist_schedule:
208 case OMPC_firstprivate:
213 case OMPC_num_threads:
224 case OMPC_copyprivate:
229 case OMPC_threadprivate:
230 case OMPC_groupprivate:
250 case OMPC_thread_limit:
256 case OMPC_defaultmap:
261 case OMPC_use_device_ptr:
262 case OMPC_use_device_addr:
263 case OMPC_is_device_ptr:
264 case OMPC_has_device_addr:
265 case OMPC_unified_address:
266 case OMPC_unified_shared_memory:
267 case OMPC_reverse_offload:
268 case OMPC_dynamic_allocators:
269 case OMPC_atomic_default_mem_order:
274 case OMPC_device_type:
276 case OMPC_nontemporal:
279 case OMPC_novariants:
284 case OMPC_uses_allocators:
301 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
302 assert(DS->isSingleDecl() &&
"Only single expression must be captured.");
303 if (
auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
304 return OED->getInitAddress();
362 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
364 new (Mem) OMPOrderedClause(
Num, NumLoops, StartLoc, LParenLoc, EndLoc);
365 for (
unsigned I = 0; I < NumLoops; ++I) {
366 Clause->setLoopNumIterations(I,
nullptr);
367 Clause->setLoopCounter(I,
nullptr);
374 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
375 auto *Clause =
new (Mem) OMPOrderedClause(NumLoops);
376 for (
unsigned I = 0; I < NumLoops; ++I) {
377 Clause->setLoopNumIterations(I,
nullptr);
378 Clause->setLoopCounter(I,
nullptr);
384 Expr *NumIterations) {
385 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
386 getTrailingObjects()[NumLoop] = NumIterations;
390 return getTrailingObjects(NumberOfLoops);
394 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
395 getTrailingObjects()[NumberOfLoops + NumLoop] = Counter;
399 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
400 return getTrailingObjects()[NumberOfLoops + NumLoop];
404 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
405 return getTrailingObjects()[NumberOfLoops + NumLoop];
411 return new (
C) OMPUpdateClause(StartLoc, EndLoc,
false);
419 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
420 alignof(OMPUpdateClause));
422 new (Mem) OMPUpdateClause(StartLoc, EndLoc,
true);
423 Clause->setLParenLoc(LParenLoc);
424 Clause->setArgumentLoc(ArgumentLoc);
425 Clause->setDependencyKind(DK);
432 return new (
C) OMPUpdateClause(
false);
434 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
435 alignof(OMPUpdateClause));
436 auto *Clause =
new (Mem) OMPUpdateClause(
true);
437 Clause->IsExtended =
true;
443 "Number of private copies is not the same as the preallocated buffer");
452 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
453 OMPPrivateClause *Clause =
454 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
455 Clause->setVarRefs(VL);
456 Clause->setPrivateCopies(PrivateVL);
462 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
463 return new (Mem) OMPPrivateClause(N);
468 "Number of private copies is not the same as the preallocated buffer");
474 "Number of inits is not the same as the preallocated buffer");
475 llvm::copy(VL, getPrivateCopies().end());
483 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
484 OMPFirstprivateClause *Clause =
485 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
486 Clause->setVarRefs(VL);
487 Clause->setPrivateCopies(PrivateVL);
488 Clause->setInits(InitVL);
489 Clause->setPreInitStmt(PreInit);
495 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
496 return new (Mem) OMPFirstprivateClause(N);
501 "Number of private copies is not the same as the preallocated buffer");
506 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
507 "not the same as the "
508 "preallocated buffer");
509 llvm::copy(SrcExprs, getPrivateCopies().end());
513 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
514 "expressions is not the same as "
515 "the preallocated buffer");
516 llvm::copy(DstExprs, getSourceExprs().end());
519void OMPLastprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
521 "Number of assignment expressions is not the same as the preallocated "
523 llvm::copy(AssignmentOps, getDestinationExprs().end());
532 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
533 OMPLastprivateClause *Clause =
new (Mem) OMPLastprivateClause(
534 StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
535 Clause->setVarRefs(VL);
536 Clause->setSourceExprs(SrcExprs);
537 Clause->setDestinationExprs(DstExprs);
538 Clause->setAssignmentOps(AssignmentOps);
539 Clause->setPreInitStmt(PreInit);
540 Clause->setPostUpdateExpr(PostUpdate);
546 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
547 return new (Mem) OMPLastprivateClause(N);
555 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
556 OMPSharedClause *Clause =
557 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
558 Clause->setVarRefs(VL);
563 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
564 return new (Mem) OMPSharedClause(N);
569 "Number of privates is not the same as the preallocated buffer");
575 "Number of inits is not the same as the preallocated buffer");
576 llvm::copy(IL, getPrivates().end());
581 "Number of updates is not the same as the preallocated buffer");
582 llvm::copy(UL, getInits().end());
587 "Number of final updates is not the same as the preallocated buffer");
588 llvm::copy(FL, getUpdates().end());
594 "Number of used expressions is not the same as the preallocated buffer");
595 llvm::copy(UE, getFinals().end() + 2);
608 C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
609 OMPLinearClause *Clause =
610 new (Mem) OMPLinearClause(StartLoc, LParenLoc, Modifier, ModifierLoc,
611 ColonLoc, StepModifierLoc, EndLoc, VL.size());
612 Clause->setVarRefs(VL);
613 Clause->setPrivates(PL);
614 Clause->setInits(IL);
617 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
619 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
621 std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
623 Clause->setStep(Step);
624 Clause->setCalcStep(CalcStep);
625 Clause->setPreInitStmt(PreInit);
626 Clause->setPostUpdateExpr(PostUpdate);
634 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
635 return new (Mem) OMPLinearClause(NumVars);
641 reinterpret_cast<Stmt **
>(getUsedExprs().begin()),
642 reinterpret_cast<Stmt **
>(llvm::find(getUsedExprs(),
nullptr)));
649 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
650 OMPAlignedClause *Clause =
new (Mem)
651 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
652 Clause->setVarRefs(VL);
653 Clause->setAlignment(A);
659 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
660 return new (Mem) OMPAlignedClause(NumVars);
667 return new (
C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc);
671 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
672 "not the same as the "
673 "preallocated buffer");
678 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
679 "expressions is not the same as "
680 "the preallocated buffer");
681 llvm::copy(DstExprs, getSourceExprs().end());
686 "Number of assignment expressions is not the same as the preallocated "
688 llvm::copy(AssignmentOps, getDestinationExprs().end());
695 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
696 OMPCopyinClause *Clause =
697 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
698 Clause->setVarRefs(VL);
699 Clause->setSourceExprs(SrcExprs);
700 Clause->setDestinationExprs(DstExprs);
701 Clause->setAssignmentOps(AssignmentOps);
706 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
707 return new (Mem) OMPCopyinClause(N);
711 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
712 "not the same as the "
713 "preallocated buffer");
718 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
719 "expressions is not the same as "
720 "the preallocated buffer");
721 llvm::copy(DstExprs, getSourceExprs().end());
724void OMPCopyprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
726 "Number of assignment expressions is not the same as the preallocated "
728 llvm::copy(AssignmentOps, getDestinationExprs().end());
735 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
736 OMPCopyprivateClause *Clause =
737 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
738 Clause->setVarRefs(VL);
739 Clause->setSourceExprs(SrcExprs);
740 Clause->setDestinationExprs(DstExprs);
741 Clause->setAssignmentOps(AssignmentOps);
747 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
748 return new (Mem) OMPCopyprivateClause(N);
753 "Number of private copies is not the same as the preallocated buffer");
760 "Number of LHS expressions is not the same as the preallocated buffer");
761 llvm::copy(LHSExprs, getPrivates().end());
767 "Number of RHS expressions is not the same as the preallocated buffer");
768 llvm::copy(RHSExprs, getLHSExprs().end());
772 assert(ReductionOps.size() ==
varlist_size() &&
"Number of reduction "
773 "expressions is not the same "
774 "as the preallocated buffer");
775 llvm::copy(ReductionOps, getRHSExprs().end());
779 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
780 assert(Ops.size() ==
varlist_size() &&
"Number of copy "
781 "expressions is not the same "
782 "as the preallocated buffer");
783 llvm::copy(Ops, getReductionOps().end());
786void OMPReductionClause::setInscanCopyArrayTemps(
788 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
790 "Number of copy temp expressions is not the same as the preallocated "
792 llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
795void OMPReductionClause::setInscanCopyArrayElems(
797 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
799 "Number of copy temp expressions is not the same as the preallocated "
801 llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
815 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
816 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size(), VL.size()));
817 auto *Clause =
new (Mem) OMPReductionClause(
818 StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc, Modifier,
819 OrignalSharingModifier, VL.size(), QualifierLoc, NameInfo);
820 Clause->setVarRefs(VL);
821 Clause->setPrivates(Privates);
822 Clause->setLHSExprs(LHSExprs);
823 Clause->setRHSExprs(RHSExprs);
824 Clause->setReductionOps(ReductionOps);
825 Clause->setPreInitStmt(PreInit);
826 Clause->setPostUpdateExpr(PostUpdate);
827 Clause->setPrivateVariableReductionFlags(IsPrivateVarReduction);
828 if (Modifier == OMPC_REDUCTION_inscan) {
829 Clause->setInscanCopyOps(CopyOps);
830 Clause->setInscanCopyArrayTemps(CopyArrayTemps);
831 Clause->setInscanCopyArrayElems(CopyArrayElems);
833 assert(CopyOps.empty() &&
834 "copy operations are expected in inscan reductions only.");
835 assert(CopyArrayTemps.empty() &&
836 "copy array temps are expected in inscan reductions only.");
837 assert(CopyArrayElems.empty() &&
838 "copy array temps are expected in inscan reductions only.");
846 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
847 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N, N));
848 auto *Clause =
new (Mem) OMPReductionClause(N);
849 Clause->setModifier(Modifier);
855 "Number of private copies is not the same as the preallocated buffer");
862 "Number of LHS expressions is not the same as the preallocated buffer");
863 llvm::copy(LHSExprs, getPrivates().end());
869 "Number of RHS expressions is not the same as the preallocated buffer");
870 llvm::copy(RHSExprs, getLHSExprs().end());
873void OMPTaskReductionClause::setReductionOps(
ArrayRef<Expr *> ReductionOps) {
874 assert(ReductionOps.size() ==
varlist_size() &&
"Number of task reduction "
875 "expressions is not the same "
876 "as the preallocated buffer");
877 llvm::copy(ReductionOps, getRHSExprs().end());
887 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
888 OMPTaskReductionClause *Clause =
new (Mem) OMPTaskReductionClause(
889 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
890 Clause->setVarRefs(VL);
891 Clause->setPrivates(Privates);
892 Clause->setLHSExprs(LHSExprs);
893 Clause->setRHSExprs(RHSExprs);
894 Clause->setReductionOps(ReductionOps);
895 Clause->setPreInitStmt(PreInit);
896 Clause->setPostUpdateExpr(PostUpdate);
902 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
903 return new (Mem) OMPTaskReductionClause(N);
908 "Number of private copies is not the same as the preallocated buffer");
915 "Number of LHS expressions is not the same as the preallocated buffer");
916 llvm::copy(LHSExprs, getPrivates().end());
922 "Number of RHS expressions is not the same as the preallocated buffer");
923 llvm::copy(RHSExprs, getLHSExprs().end());
927 assert(ReductionOps.size() ==
varlist_size() &&
"Number of in reduction "
928 "expressions is not the same "
929 "as the preallocated buffer");
930 llvm::copy(ReductionOps, getRHSExprs().end());
933void OMPInReductionClause::setTaskgroupDescriptors(
936 "Number of in reduction descriptors is not the same as the "
937 "preallocated buffer");
938 llvm::copy(TaskgroupDescriptors, getReductionOps().end());
948 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
949 OMPInReductionClause *Clause =
new (Mem) OMPInReductionClause(
950 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
951 Clause->setVarRefs(VL);
952 Clause->setPrivates(Privates);
953 Clause->setLHSExprs(LHSExprs);
954 Clause->setRHSExprs(RHSExprs);
955 Clause->setReductionOps(ReductionOps);
956 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
957 Clause->setPreInitStmt(PreInit);
958 Clause->setPostUpdateExpr(PostUpdate);
964 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
965 return new (Mem) OMPInReductionClause(N);
974 Clause->setLocStart(StartLoc);
975 Clause->setLParenLoc(LParenLoc);
976 Clause->setLocEnd(EndLoc);
977 Clause->setSizesRefs(Sizes);
983 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
984 return new (Mem) OMPSizesClause(NumSizes);
992 OMPPermutationClause *Clause =
CreateEmpty(
C, Args.size());
993 Clause->setLocStart(StartLoc);
994 Clause->setLParenLoc(LParenLoc);
995 Clause->setLocEnd(EndLoc);
996 Clause->setArgRefs(Args);
1001 unsigned NumLoops) {
1002 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumLoops));
1003 return new (Mem) OMPPermutationClause(NumLoops);
1010 Clause->setLocStart(StartLoc);
1011 Clause->setLocEnd(EndLoc);
1016 return new (
C) OMPFullClause();
1025 Clause->setLocStart(StartLoc);
1026 Clause->setLParenLoc(LParenLoc);
1027 Clause->setLocEnd(EndLoc);
1028 Clause->setFactor(Factor);
1033 return new (
C) OMPPartialClause();
1042 Clause->setLocStart(StartLoc);
1043 Clause->setLParenLoc(LParenLoc);
1044 Clause->setFirstLoc(FirstLoc);
1045 Clause->setCountLoc(CountLoc);
1046 Clause->setLocEnd(EndLoc);
1047 Clause->setFirst(
First);
1048 Clause->setCount(Count);
1053 return new (
C) OMPLoopRangeClause();
1064 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1065 auto *Clause =
new (Mem) OMPAllocateClause(
1066 StartLoc, LParenLoc, Allocator, Alignment, ColonLoc, Modifier1,
1067 Modifier1Loc, Modifier2, Modifier2Loc, EndLoc, VL.size());
1069 Clause->setVarRefs(VL);
1075 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1076 return new (Mem) OMPAllocateClause(N);
1084 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
1085 OMPFlushClause *Clause =
1086 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1087 Clause->setVarRefs(VL);
1092 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1093 return new (Mem) OMPFlushClause(N);
1101 auto *Clause =
new (
C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
1102 Clause->setDepobj(Depobj);
1107 return new (
C) OMPDepobjClause();
1115 void *Mem =
C.Allocate(
1116 totalSizeToAlloc<Expr *>(VL.size() + 1 + NumLoops),
1117 alignof(OMPDependClause));
1118 OMPDependClause *Clause =
new (Mem)
1119 OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1120 Clause->setDependencyKind(Data.DepKind);
1121 Clause->setDependencyLoc(Data.DepLoc);
1122 Clause->setColonLoc(Data.ColonLoc);
1123 Clause->setOmpAllMemoryLoc(Data.OmpAllMemoryLoc);
1124 Clause->setModifier(DepModifier);
1125 Clause->setVarRefs(VL);
1126 for (
unsigned I = 0 ; I < NumLoops; ++I)
1127 Clause->setLoopData(I,
nullptr);
1132 unsigned NumLoops) {
1134 C.Allocate(totalSizeToAlloc<Expr *>(N + 1 + NumLoops),
1135 alignof(OMPDependClause));
1136 return new (Mem) OMPDependClause(N, NumLoops);
1142 NumLoop < NumLoops &&
1143 "Expected sink or source depend + loop index must be less number of "
1145 auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1152 NumLoop < NumLoops &&
1153 "Expected sink or source depend + loop index must be less number of "
1155 auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1162 NumLoop < NumLoops &&
1163 "Expected sink or source depend + loop index must be less number of "
1165 const auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1169void OMPDependClause::setModifier(
Expr *DepModifier) {
1176 unsigned TotalNum = 0u;
1177 for (
auto &
C : ComponentLists)
1178 TotalNum +=
C.size();
1185 for (
const ValueDecl *D : Declarations) {
1187 UniqueDecls.insert(VD);
1189 return UniqueDecls.size();
1195 "Cannot get element-type from array-shaping expr.");
1209 if (
const auto *ATy = BaseType->getAsArrayTypeUnsafe())
1210 ElemTy = ATy->getElementType();
1218std::pair<const Expr *, std::optional<size_t>>
1224 if (Components.size() < 2)
1225 return {
nullptr, std::nullopt};
1230 if (Components.back().isNonContiguous() && CurDirKind == OMPD_target_update)
1231 return {
nullptr, std::nullopt};
1237 for (
auto [I, Component] : llvm::enumerate(Components)) {
1242 const Expr *CurExpr = Component.getAssociatedExpression();
1257 return {CurExpr, Components.size() - I};
1260 return {
nullptr, std::nullopt};
1287 void *Mem =
C.Allocate(
1293 OMPMapClause *Clause =
new (Mem)
1294 OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1297 Clause->setVarRefs(Vars);
1298 Clause->setUDMapperRefs(UDMapperRefs);
1299 Clause->setIteratorModifier(IteratorModifier);
1300 Clause->setClauseInfo(Declarations, ComponentLists);
1301 Clause->setMapType(
Type);
1309 void *Mem =
C.Allocate(
1315 OMPMapClause *Clause =
new (Mem) OMPMapClause(Sizes);
1316 Clause->setIteratorModifier(
nullptr);
1343 void *Mem =
C.Allocate(
1350 auto *Clause =
new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc,
1351 UDMQualifierLoc, MapperId, Locs, Sizes);
1353 Clause->setVarRefs(Vars);
1354 Clause->setUDMapperRefs(UDMapperRefs);
1355 Clause->setClauseInfo(Declarations, ComponentLists);
1361 void *Mem =
C.Allocate(
1367 return new (Mem) OMPToClause(Sizes);
1393 void *Mem =
C.Allocate(
1401 new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc,
1402 UDMQualifierLoc, MapperId, Locs, Sizes);
1404 Clause->setVarRefs(Vars);
1405 Clause->setUDMapperRefs(UDMapperRefs);
1406 Clause->setClauseInfo(Declarations, ComponentLists);
1413 void *Mem =
C.Allocate(
1419 return new (Mem) OMPFromClause(Sizes);
1424 "Number of private copies is not the same as the preallocated buffer");
1430 "Number of inits is not the same as the preallocated buffer");
1431 llvm::copy(VL, getPrivateCopies().end());
1455 void *Mem =
C.Allocate(
1462 OMPUseDevicePtrClause *Clause =
new (Mem) OMPUseDevicePtrClause(Locs, Sizes);
1464 Clause->setVarRefs(Vars);
1465 Clause->setPrivateCopies(PrivateVars);
1466 Clause->setInits(Inits);
1467 Clause->setClauseInfo(Declarations, ComponentLists);
1474 void *Mem =
C.Allocate(
1480 return new (Mem) OMPUseDevicePtrClause(Sizes);
1504 void *Mem =
C.Allocate(
1511 auto *Clause =
new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
1513 Clause->setVarRefs(Vars);
1514 Clause->setClauseInfo(Declarations, ComponentLists);
1521 void *Mem =
C.Allocate(
1527 return new (Mem) OMPUseDeviceAddrClause(Sizes);
1551 void *Mem =
C.Allocate(
1558 OMPIsDevicePtrClause *Clause =
new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1560 Clause->setVarRefs(Vars);
1561 Clause->setClauseInfo(Declarations, ComponentLists);
1568 void *Mem =
C.Allocate(
1574 return new (Mem) OMPIsDevicePtrClause(Sizes);
1598 void *Mem =
C.Allocate(
1605 auto *Clause =
new (Mem) OMPHasDeviceAddrClause(Locs, Sizes);
1607 Clause->setVarRefs(Vars);
1608 Clause->setClauseInfo(Declarations, ComponentLists);
1615 void *Mem =
C.Allocate(
1621 return new (Mem) OMPHasDeviceAddrClause(Sizes);
1630 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1632 new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
1633 Clause->setVarRefs(VL);
1639 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1640 return new (Mem) OMPNontemporalClause(N);
1644 assert(VL.size() ==
varlist_size() &&
"Number of private references is not "
1645 "the same as the preallocated buffer");
1654 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1656 new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1657 Clause->setVarRefs(VL);
1663 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1664 return new (Mem) OMPInclusiveClause(N);
1672 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1674 new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1675 Clause->setVarRefs(VL);
1681 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1682 return new (Mem) OMPExclusiveClause(N);
1685void OMPUsesAllocatorsClause::setAllocatorsData(
1687 assert(
Data.size() == NumOfAllocators &&
1688 "Size of allocators data is not the same as the preallocated buffer.");
1689 for (
unsigned I = 0, E =
Data.size(); I < E; ++I) {
1691 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1692 static_cast<int>(ExprOffsets::Allocator)] =
1694 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1696 ExprOffsets::AllocatorTraits)] =
1699 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1700 static_cast<int>(ParenLocsOffsets::LParen)] =
1703 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1704 static_cast<int>(ParenLocsOffsets::RParen)] =
1713 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1714 static_cast<int>(ExprOffsets::Allocator)];
1716 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1718 ExprOffsets::AllocatorTraits)];
1720 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1721 static_cast<int>(ParenLocsOffsets::LParen)];
1723 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1724 static_cast<int>(ParenLocsOffsets::RParen)];
1732 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1733 static_cast<int>(ExprOffsets::Total) *
Data.size(),
1734 static_cast<int>(ParenLocsOffsets::Total) *
Data.size()));
1735 auto *Clause =
new (Mem)
1736 OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc,
Data.size());
1737 Clause->setAllocatorsData(
Data);
1743 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1744 static_cast<int>(ExprOffsets::Total) * N,
1745 static_cast<int>(ParenLocsOffsets::Total) * N));
1746 return new (Mem) OMPUsesAllocatorsClause(N);
1754 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1755 auto *Clause =
new (Mem)
1756 OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
1757 Clause->setModifier(Modifier);
1758 Clause->setVarRefs(Locators);
1764 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1765 return new (Mem) OMPAffinityClause(N);
1776 C.Allocate(totalSizeToAlloc<Expr *>(InteropInfo.
PreferTypes.size() + 1));
1777 auto *Clause =
new (Mem) OMPInitClause(
1779 VarLoc, EndLoc, InteropInfo.
PreferTypes.size() + 1);
1780 Clause->setInteropVar(InteropVar);
1781 llvm::copy(InteropInfo.
PreferTypes, Clause->getTrailingObjects() + 1);
1786 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1787 return new (Mem) OMPInitClause(N);
1794 return new (
C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
1798 return new (
C) OMPBindClause();
1807 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops),
1808 alignof(OMPDoacrossClause));
1809 OMPDoacrossClause *Clause =
new (Mem)
1810 OMPDoacrossClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1811 Clause->setDependenceType(DepType);
1812 Clause->setDependenceLoc(DepLoc);
1813 Clause->setColonLoc(ColonLoc);
1814 Clause->setVarRefs(VL);
1815 for (
unsigned I = 0; I < NumLoops; ++I)
1816 Clause->setLoopData(I,
nullptr);
1822 unsigned NumLoops) {
1823 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops),
1824 alignof(OMPDoacrossClause));
1825 return new (Mem) OMPDoacrossClause(N, NumLoops);
1829 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1830 auto *It = std::next(
getVarRefs().end(), NumLoop);
1835 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1836 auto *It = std::next(
getVarRefs().end(), NumLoop);
1841 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1842 const auto *It = std::next(
getVarRefs().end(), NumLoop);
1851 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1852 alignof(OMPAbsentClause));
1853 auto *AC =
new (Mem) OMPAbsentClause(Loc, LLoc, RLoc, DKVec.size());
1854 AC->setDirectiveKinds(DKVec);
1859 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1860 alignof(OMPAbsentClause));
1861 return new (Mem) OMPAbsentClause(K);
1867 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1868 alignof(OMPContainsClause));
1869 auto *CC =
new (Mem) OMPContainsClause(Loc, LLoc, RLoc, DKVec.size());
1870 CC->setDirectiveKinds(DKVec);
1876 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1877 alignof(OMPContainsClause));
1878 return new (Mem) OMPContainsClause(K);
1885 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1886 OMPNumTeamsClause *Clause =
1887 new (Mem) OMPNumTeamsClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1888 Clause->setVarRefs(VL);
1889 Clause->setPreInitStmt(PreInit, CaptureRegion);
1895 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1896 return new (Mem) OMPNumTeamsClause(N);
1903 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1904 OMPThreadLimitClause *Clause =
1905 new (Mem) OMPThreadLimitClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1906 Clause->setVarRefs(VL);
1907 Clause->setPreInitStmt(PreInit, CaptureRegion);
1913 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1914 return new (Mem) OMPThreadLimitClause(N);
1921void OMPClausePrinter::VisitOMPIfClause(
OMPIfClause *Node) {
1924 OS << getOpenMPDirectiveName(Node->
getNameModifier(), Version) <<
": ";
1929void OMPClausePrinter::VisitOMPFinalClause(
OMPFinalClause *Node) {
1936 OS <<
"num_threads(";
1946void OMPClausePrinter::VisitOMPAlignClause(
OMPAlignClause *Node) {
1964void OMPClausePrinter::VisitOMPSizesClause(
OMPSizesClause *Node) {
1970 Size->printPretty(OS,
nullptr, Policy, 0);
1977 OS <<
"permutation(";
1978 llvm::interleaveComma(Node->
getArgsRefs(), OS, [&](
const Expr *E) {
1979 E->printPretty(OS, nullptr, Policy, 0);
1984void OMPClausePrinter::VisitOMPFullClause(
OMPFullClause *Node) { OS <<
"full"; }
1991 Factor->printPretty(OS,
nullptr, Policy, 0);
2002 if (
First && Count) {
2004 First->printPretty(OS,
nullptr, Policy, 0);
2033 if (Version >= 60 && Node->
getDefaultVC() != OMPC_DEFAULT_VC_all) {
2056 OS <<
"unified_address";
2059void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
2061 OS <<
"unified_shared_memory";
2065 OS <<
"reverse_offload";
2068void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
2070 OS <<
"dynamic_allocators";
2073void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
2075 OS <<
"atomic_default_mem_order("
2085void OMPClausePrinter::VisitOMPAtClause(
OMPAtClause *Node) {
2099 E->printPretty(OS,
nullptr, Policy);
2118 E->printPretty(OS,
nullptr, Policy);
2127 Num->printPretty(OS,
nullptr, Policy, 0);
2153void OMPClausePrinter::VisitOMPReadClause(
OMPReadClause *) { OS <<
"read"; }
2155void OMPClausePrinter::VisitOMPWriteClause(
OMPWriteClause *) { OS <<
"write"; }
2175void OMPClausePrinter::VisitOMPFailClause(
OMPFailClause *Node) {
2191 OS << getOpenMPDirectiveName(D, Version);
2197void OMPClausePrinter::VisitOMPHoldsClause(
OMPHoldsClause *Node) {
2209 OS << getOpenMPDirectiveName(D, Version);
2219void OMPClausePrinter::VisitOMPNoOpenMPRoutinesClause(
2221 OS <<
"no_openmp_routines";
2224void OMPClausePrinter::VisitOMPNoOpenMPConstructsClause(
2226 OS <<
"no_openmp_constructs";
2230 OS <<
"no_parallelism";
2253void OMPClausePrinter::VisitOMPWeakClause(
OMPWeakClause *) { OS <<
"weak"; }
2259void OMPClausePrinter::VisitOMPSIMDClause(
OMPSIMDClause *) { OS <<
"simd"; }
2275 VisitOMPClauseList(Node,
'(');
2282 OS <<
"thread_limit";
2283 VisitOMPClauseList(Node,
'(');
2316void OMPClausePrinter::VisitOMPHintClause(
OMPHintClause *Node) {
2322void OMPClausePrinter::VisitOMPInitClause(
OMPInitClause *Node) {
2325 for (
const Expr *E : Node->
prefs()) {
2327 OS <<
"prefer_type(";
2330 E->printPretty(OS,
nullptr, Policy);
2347void OMPClausePrinter::VisitOMPUseClause(
OMPUseClause *Node) {
2357 E->printPretty(OS,
nullptr, Policy);
2366 E->printPretty(OS,
nullptr, Policy, 0);
2375 E->printPretty(OS,
nullptr, Policy, 0);
2381void OMPClausePrinter::VisitOMPClauseList(
T *Node,
char StartSym) {
2382 for (
typename T::varlist_iterator I = Node->varlist_begin(),
2383 E = Node->varlist_end();
2385 assert(*I &&
"Expected non-null Stmt");
2386 OS << (I == Node->varlist_begin() ? StartSym :
',');
2387 if (
auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
2389 DRE->printPretty(OS,
nullptr, Policy, 0);
2391 DRE->getDecl()->printQualifiedName(OS);
2393 (*I)->printPretty(OS,
nullptr, Policy, 0);
2401 Expr *FirstModifier =
nullptr;
2402 Expr *SecondModifier =
nullptr;
2407 if (FirstAllocMod == OMPC_ALLOCATE_allocator ||
2418 if (FirstModifier) {
2420 if (!FirstUnknown) {
2424 FirstModifier->
printPretty(OS,
nullptr, Policy, 0);
2427 if (SecondModifier) {
2429 if (!SecondUnknown) {
2434 SecondModifier->
printPretty(OS,
nullptr, Policy, 0);
2439 VisitOMPClauseList(Node,
' ');
2442 VisitOMPClauseList(Node,
'(');
2450 VisitOMPClauseList(Node,
'(');
2457 OS <<
"firstprivate";
2458 VisitOMPClauseList(Node,
'(');
2465 OS <<
"lastprivate";
2480 VisitOMPClauseList(Node,
'(');
2495 if (!Qualifier && OOK !=
OO_None) {
2504 VisitOMPClauseList(Node,
' ');
2509void OMPClausePrinter::VisitOMPTaskReductionClause(
2512 OS <<
"task_reduction(";
2517 if (!Qualifier && OOK !=
OO_None) {
2526 VisitOMPClauseList(Node,
' ');
2533 OS <<
"in_reduction(";
2538 if (!Qualifier && OOK !=
OO_None) {
2547 VisitOMPClauseList(Node,
' ');
2555 VisitOMPClauseList(Node,
'(');
2562 if (Node->
getStep() !=
nullptr) {
2577 VisitOMPClauseList(Node,
'(');
2589 VisitOMPClauseList(Node,
'(');
2596 OS <<
"copyprivate";
2597 VisitOMPClauseList(Node,
'(');
2602void OMPClausePrinter::VisitOMPFlushClause(
OMPFlushClause *Node) {
2604 VisitOMPClauseList(Node,
'(');
2623 bool IsOmpAllMemory =
false;
2624 if (PrintKind == OMPC_DEPEND_outallmemory) {
2625 PrintKind = OMPC_DEPEND_out;
2626 IsOmpAllMemory =
true;
2627 }
else if (PrintKind == OMPC_DEPEND_inoutallmemory) {
2628 PrintKind = OMPC_DEPEND_inout;
2629 IsOmpAllMemory =
true;
2634 VisitOMPClauseList(Node,
' ');
2635 if (IsOmpAllMemory) {
2637 OS <<
"omp_all_memory";
2642template <
typename T>
2647 Node->getMapperQualifierLoc().getNestedNameSpecifier();
2648 MapperNNS.
print(OS, Policy);
2649 OS << Node->getMapperIdInfo() <<
')';
2652template <
typename T>
2655 if (
Expr *IteratorModifier = Node->getIteratorModifier())
2656 IteratorModifier->printPretty(OS,
nullptr, Policy);
2659void OMPClausePrinter::VisitOMPMapClause(
OMPMapClause *Node) {
2679 VisitOMPClauseList(Node,
' ');
2684template <
typename T>
void OMPClausePrinter::VisitOMPMotionClause(
T *Node) {
2685 if (Node->varlist_empty())
2687 OS << getOpenMPClauseName(Node->getClauseKind());
2688 unsigned ModifierCount = 0;
2693 if (ModifierCount) {
2698 Node->getMotionModifier(I));
2699 if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2701 if (I < ModifierCount - 1)
2706 VisitOMPClauseList(Node,
' ');
2708 VisitOMPClauseList(Node,
'(');
2713void OMPClausePrinter::VisitOMPToClause(
OMPToClause *Node) {
2714 VisitOMPMotionClause(Node);
2717void OMPClausePrinter::VisitOMPFromClause(
OMPFromClause *Node) {
2718 VisitOMPMotionClause(Node);
2726 E->printPretty(OS,
nullptr, Policy);
2732 OS <<
"defaultmap(";
2745 OS <<
"use_device_ptr";
2746 VisitOMPClauseList(Node,
'(');
2751void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2754 OS <<
"use_device_addr";
2755 VisitOMPClauseList(Node,
'(');
2762 OS <<
"is_device_ptr";
2763 VisitOMPClauseList(Node,
'(');
2770 OS <<
"has_device_addr";
2771 VisitOMPClauseList(Node,
'(');
2778 OS <<
"nontemporal";
2779 VisitOMPClauseList(Node,
'(');
2784void OMPClausePrinter::VisitOMPOrderClause(
OMPOrderClause *Node) {
2796 VisitOMPClauseList(Node,
'(');
2804 VisitOMPClauseList(Node,
'(');
2809void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2813 OS <<
"uses_allocators(";
2817 if (
Data.AllocatorTraits) {
2819 Data.AllocatorTraits->printPretty(OS,
nullptr, Policy);
2832 char StartSym =
'(';
2835 Modifier->printPretty(OS,
nullptr, Policy);
2839 VisitOMPClauseList(Node, StartSym);
2849void OMPClausePrinter::VisitOMPBindClause(
OMPBindClause *Node) {
2855void OMPClausePrinter::VisitOMPXDynCGroupMemClause(
2857 OS <<
"ompx_dyn_cgroup_mem(";
2862void OMPClausePrinter::VisitOMPDynGroupprivateClause(
2864 OS <<
"dyn_groupprivate(";
2885 case OMPC_DOACROSS_source:
2888 case OMPC_DOACROSS_sink:
2891 case OMPC_DOACROSS_source_omp_cur_iteration:
2892 OS <<
"source: omp_cur_iteration";
2894 case OMPC_DOACROSS_sink_omp_cur_iteration:
2895 OS <<
"sink: omp_cur_iteration - 1";
2898 llvm_unreachable(
"unknown docaross modifier");
2900 VisitOMPClauseList(Node,
' ');
2905 OS <<
"ompx_attribute(";
2907 for (
auto &Attr : Node->
getAttrs()) {
2910 Attr->printPretty(OS, Policy);
2916void OMPClausePrinter::VisitOMPXBareClause(
OMPXBareClause *Node) {
2921 VariantMatchInfo &VMI)
const {
2926 if (
Selector.Kind == TraitSelector::user_condition) {
2927 assert(
Selector.ScoreOrCondition &&
2928 "Ill-formed user condition, expected condition expression!");
2929 assert(
Selector.Properties.size() == 1 &&
2930 Selector.Properties.front().Kind ==
2931 TraitProperty::user_condition_unknown &&
2932 "Ill-formed user condition, expected unknown trait property!");
2934 if (std::optional<APSInt> CondVal =
2935 Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2936 VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
2937 : TraitProperty::user_condition_true,
2940 VMI.addTrait(TraitProperty::user_condition_false,
"<condition>");
2944 std::optional<llvm::APSInt> Score;
2945 llvm::APInt *ScorePtr =
nullptr;
2947 if ((Score =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
2950 VMI.addTrait(TraitProperty::user_condition_false,
2951 "<non-constant-score>");
2957 if (
Set.Kind != TraitSet::construct)
2961 assert(
Selector.Properties.size() == 1 &&
2962 Selector.Properties.front().Kind ==
2963 getOpenMPContextTraitPropertyForSelector(
2965 "Ill-formed construct selector!");
2972 bool FirstSet =
true;
2977 OS << getOpenMPContextTraitSetName(
Set.Kind) <<
"={";
2979 bool FirstSelector =
true;
2983 FirstSelector =
false;
2984 OS << getOpenMPContextTraitSelectorName(
Selector.Kind);
2986 bool AllowsTraitScore =
false;
2987 bool RequiresProperty =
false;
2988 isValidTraitSelectorForTraitSet(
2989 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
2991 if (!RequiresProperty)
2995 if (
Selector.Kind == TraitSelector::user_condition) {
2997 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
3004 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
3008 bool FirstProperty =
true;
3012 FirstProperty =
false;
3013 OS << getOpenMPContextTraitPropertyName(
Property.Kind,
3024 std::string MangledName;
3025 llvm::raw_string_ostream OS(MangledName);
3030 bool AllowsTraitScore =
false;
3031 bool RequiresProperty =
false;
3032 isValidTraitSelectorForTraitSet(
3033 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
3036 if (!RequiresProperty ||
3037 Selector.Kind == TraitSelector::user_condition)
3042 << getOpenMPContextTraitPropertyName(
Property.Kind,
3049OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
3052 if (!MangledName.consume_front(
"$S"))
3054 if (MangledName.consumeInteger(10,
U))
3058 Set.Kind = TraitSet(
U);
3060 if (!MangledName.consume_front(
"$s"))
3062 if (MangledName.consumeInteger(10,
U))
3068 if (!MangledName.consume_front(
"$P"))
3072 std::pair<StringRef, StringRef> PropRestPair = MangledName.split(
'$');
3073 Property.RawString = PropRestPair.first;
3074 Property.Kind = getOpenMPContextTraitPropertyKind(
3076 MangledName = MangledName.drop_front(PropRestPair.first.size());
3086 TI.
print(OS, Policy);
3091 return TI ? OS << *TI : OS;
3098 : OMPContext(ASTCtx.getLangOpts().OpenMPIsTargetDevice,
3099 ASTCtx.getTargetInfo().getTriple(),
3100 ASTCtx.getLangOpts().OMPTargetTriples.empty()
3102 : ASTCtx.getLangOpts().OMPTargetTriples[0],
3104 FeatureValidityCheck([&](StringRef FeatureName) {
3105 return ASTCtx.
getTargetInfo().isValidFeatureName(FeatureName);
3107 DiagUnknownTrait(std::move(DiagUnknownTrait)) {
3110 for (llvm::omp::TraitProperty
Property : ConstructTraits)
3115 auto It = FeatureMap.find(RawString);
3116 if (It != FeatureMap.end())
3118 if (!FeatureValidityCheck(RawString))
3119 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.
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.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
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.
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
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 'absent' clause in the 'pragma omp assume' directive.
static OMPAbsentClause * CreateEmpty(const ASTContext &C, unsigned NumKinds)
static OMPAbsentClause * Create(const ASTContext &C, ArrayRef< OpenMPDirectiveKind > DKVec, SourceLocation Loc, SourceLocation LLoc, SourceLocation RLoc)
This represents 'acq_rel' clause in the 'pragma omp atomic|flush' directives.
This represents 'acquire' clause in the 'pragma omp atomic|flush' directives.
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.
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 'aligned' in the 'pragma omp ...' directives.
Expr * getAlignment()
Returns alignment.
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.
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.
This represents 'at' clause in the 'pragma omp error' directive.
OpenMPAtClauseKind getAtKind() const
Returns kind of the clause.
This represents 'atomic_default_mem_order' clause in the 'pragma omp requires' directive.
OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const
Returns kind of the clause.
This represents 'bind' clause in the 'pragma omp ...' directives.
OpenMPBindClauseKind getBindKind() const
Returns kind of the clause.
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.
This represents 'capture' clause in the 'pragma omp atomic' directive.
Class that represents a component of a mappable expression.
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl * > Declarations)
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
ArrayRef< MappableComponent > MappableExprComponentListRef
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.
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 'compare' clause in the 'pragma omp atomic' directive.
This represents the 'contains' clause in the 'pragma omp assume' directive.
static OMPContainsClause * CreateEmpty(const ASTContext &C, unsigned NumKinds)
static OMPContainsClause * Create(const ASTContext &C, ArrayRef< OpenMPDirectiveKind > DKVec, SourceLocation Loc, SourceLocation LLoc, SourceLocation RLoc)
This represents clause 'copyin' in the 'pragma omp ...' directives.
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.
This represents clause 'copyprivate' in the 'pragma omp ...' directives.
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.
This represents 'default' clause in the 'pragma omp ...' directive.
llvm::omp::DefaultKind getDefaultKind() const
Returns kind of the clause.
OpenMPDefaultClauseVariableCategory getDefaultVC() const
This represents 'defaultmap' clause in the 'pragma omp ...' directive.
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind 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.
This represents implicit clause 'depobj' for the 'pragma omp depobj' directive.
static OMPDepobjClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Depobj)
Creates clause.
static OMPDepobjClause * CreateEmpty(const ASTContext &C)
Creates an empty clause.
Expr * getDepobj()
Returns depobj expression associated with the clause.
This represents 'destroy' clause in the 'pragma omp depobj' directive or the 'pragma omp interop' dir...
Expr * getInteropVar() const
Returns the interop variable.
This represents 'detach' clause in the 'pragma omp task' directive.
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.
MutableArrayRef< OpenMPDirectiveKind > getDirectiveKinds()
This represents 'dist_schedule' clause in the 'pragma omp ...' directive.
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
Expr * getChunkSize()
Get chunk size.
This represents the 'doacross' clause for the 'pragma omp ordered' directive.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data.
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.
OpenMPDoacrossClauseModifier getDependenceType() const
Get dependence type.
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.
This represents 'dynamic_allocators' clause in the 'pragma omp requires' directive.
This represents clause 'exclusive' in the 'pragma omp scan' directive.
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 'fail' clause in the 'pragma omp atomic' directive.
OpenMPClauseKind getFailParameter() const
Gets the parameter (type memory-order-clause) in Fail clause.
This represents 'filter' clause in the 'pragma omp ...' directive.
Expr * getThreadID() const
Return thread identifier.
This represents 'final' clause in the 'pragma omp ...' directive.
child_range used_children()
Expr * getCondition() const
Returns condition.
This represents clause 'firstprivate' in the 'pragma omp ...' directives.
static OMPFirstprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL, ArrayRef< Expr * > InitVL, Stmt *PreInit)
Creates clause with a list of variables VL.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents implicit clause 'flush' for the 'pragma omp flush' directive.
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 * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPFromClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
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 'grainsize' clause in the 'pragma omp ...' directive.
Expr * getGrainsize() const
Return safe iteration space distance.
child_range used_children()
OpenMPGrainsizeClauseModifier getModifier() const
Gets modifier.
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.
This represents 'hint' clause in the 'pragma omp ...' directive.
Expr * getHint() const
Returns number of threads.
This represents the 'holds' clause in the 'pragma omp assume' directive.
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 represents clause 'in_reduction' in the 'pragma omp task' directives.
static OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
static OMPInReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, ArrayRef< Expr * > TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents clause 'inclusive' in the 'pragma omp scan' directive.
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.
This represents the 'init' clause in 'pragma omp ...' directives.
bool getIsTarget() const
Returns true is interop-type 'target' is used.
bool getIsTargetSync() const
Returns true is interop-type 'targetsync' is used.
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.
Expr * getInteropVar()
Returns the interop variable.
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 'lastprivate' in the 'pragma omp ...' directives.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
OpenMPLastprivateModifier getKind() const
Lastprivate kind.
This represents clause 'linear' in the 'pragma omp ...' directives.
child_range used_children()
SourceLocation getModifierLoc() const
Return modifier location.
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Expr * getStep()
Returns linear step.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
void setUsedExprs(ArrayRef< Expr * > UE)
Sets the list of used expressions for the linear clause.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
OpenMPLinearClauseKind getModifier() const
Return modifier.
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 clause 'map' in the 'pragma omp ...' directives.
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
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...
OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
This represents 'mergeable' clause in the 'pragma omp ...' directive.
This represents the 'message' clause in the 'pragma omp error' and the 'pragma omp parallel' directiv...
Expr * getMessageString() const
Returns message string of the clause.
This represents the 'no_openmp' clause in the 'pragma omp assume' directive.
This represents the 'no_openmp_constructs' clause in the.
This represents the 'no_openmp_routines' clause in the 'pragma omp assume' directive.
This represents the 'no_parallelism' clause in the 'pragma omp assume' directive.
This represents 'nocontext' clause in the 'pragma omp ...' directive.
Expr * getCondition() const
Returns condition.
child_range used_children()
This represents 'nogroup' clause in the 'pragma omp ...' directive.
This represents clause 'nontemporal' in the 'pragma omp ...' directives.
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.
child_range used_children()
Expr * getCondition() const
Returns condition.
This represents 'nowait' 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.
Expr * getNumTasks() const
Return safe iteration space distance.
child_range used_children()
OpenMPNumTasksClauseModifier getModifier() const
Gets modifier.
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.
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
This represents 'order' clause in the 'pragma omp ...' directive.
OpenMPOrderClauseKind getKind() const
Returns kind of the clause.
OpenMPOrderClauseModifier getModifier() const
Returns Modifier of the clause.
This represents 'ordered' clause in the 'pragma omp ...' directive.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
Expr * getNumForLoops() const
Return the number of associated for-loops.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
static OMPOrderedClause * Create(const ASTContext &C, Expr *Num, unsigned NumLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ordered' clause.
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
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 'priority' clause in the 'pragma omp ...' directive.
child_range used_children()
Expr * getPriority()
Return Priority number.
This represents clause 'private' in the 'pragma omp ...' directives.
static OMPPrivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL)
Creates clause with a list of variables VL.
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'proc_bind' clause in the 'pragma omp ...' directive.
llvm::omp::ProcBindKind getProcBindKind() const
Returns kind of the clause.
This represents 'read' clause in the 'pragma omp atomic' directive.
This represents clause 'reduction' in the 'pragma omp ...' directives.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N, OpenMPReductionClauseModifier Modifier)
Creates an empty clause with the place for N variables.
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, ArrayRef< Expr * > CopyOps, ArrayRef< Expr * > CopyArrayTemps, ArrayRef< Expr * > CopyArrayElems, Stmt *PreInit, Expr *PostUpdate, ArrayRef< bool > IsPrivateVarReduction, OpenMPOriginalSharingModifier OriginalSharingModifier)
Creates clause with a list of variables VL.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
OpenMPReductionClauseModifier getModifier() const
Returns modifier.
SourceLocation getModifierLoc() const
Returns modifier location.
This represents 'relaxed' clause in the 'pragma omp atomic' directives.
This represents 'release' clause in the 'pragma omp atomic|flush' directives.
This represents 'reverse_offload' clause in the 'pragma omp requires' directive.
This represents 'simd' clause in the 'pragma omp ...' directive.
This represents 'safelen' clause in the 'pragma omp ...' directive.
Expr * getSafelen() const
Return safe iteration space distance.
This represents 'schedule' clause in the 'pragma omp ...' directive.
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
Expr * getChunkSize()
Get chunk size.
This represents 'self_maps' clause in the 'pragma omp requires' directive.
This represents 'seq_cst' clause in the 'pragma omp atomic|flush' directives.
This represents the 'severity' clause in the 'pragma omp error' and the 'pragma omp parallel' directi...
OpenMPSeverityClauseKind getSeverityKind() const
Returns kind of the clause.
This represents clause 'shared' in the 'pragma omp ...' directives.
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
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 clause 'task_reduction' in the 'pragma omp taskgroup' directives.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
static OMPTaskReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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.
This represents 'threads' clause in the 'pragma omp ...' directive.
This represents 'threadset' clause in the 'pragma omp task ...' directive.
OpenMPThreadsetKind getThreadsetKind() const
Returns kind of the clause.
This represents clause 'to' in the 'pragma omp ...' directives.
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, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
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.
This represents 'unified_address' clause in the 'pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the 'pragma omp requires' directive.
This represents 'untied' clause in the 'pragma omp ...' directive.
This represents 'update' clause in the 'pragma omp atomic' directive.
OpenMPDependClauseKind getDependencyKind() const
Gets the dependence kind in clause for 'depobj' directive.
static OMPUpdateClause * CreateEmpty(const ASTContext &C, bool IsExtended)
Creates an empty clause with the place for N variables.
static OMPUpdateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Creates clause for 'atomic' directive.
bool isExtended() const
Checks if the clause is the extended clauses for 'depobj' directive.
This represents the 'use' clause in 'pragma omp ...' directives.
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)
Creates clause with a list of variables Vars.
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.
unsigned getNumberOfAllocators() const
Returns number of allocators associated with the clause.
static OMPUsesAllocatorsClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< OMPUsesAllocatorsClause::Data > Data)
Creates clause with a list of allocators Data.
MutableArrayRef< Expr * > getVarRefs()
varlist_iterator varlist_end()
bool varlist_empty() const
unsigned varlist_size() const
This represents 'weak' clause in the 'pragma omp atomic' directives.
This represents 'write' clause in the 'pragma omp atomic' directive.
This represents 'ompx_attribute' clause in a directive that might generate an outlined function.
ArrayRef< const Attr * > getAttrs() const
Returned the attributes parsed from this clause.
This represents 'ompx_bare' clause in the 'pragma omp target teams ...' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the 'pragma omp target ...' directive.
Expr * getSize()
Return the size expression.
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.
bool isValid() const
Return true if this is a valid SourceLocation object.
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.
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.
bool isa(CodeGen::Address addr)
@ OMPC_ORDER_MODIFIER_unknown
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
@ Property
The type of a property.
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
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
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
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
llvm::SmallVector< Expr *, 4 > PreferTypes
This structure contains all sizes needed for by an OMPMappableExprListClause.
unsigned NumComponentLists
Number of component lists.
unsigned NumVars
Number of expressions listed.
unsigned NumUniqueDeclarations
Number of unique base declarations.
unsigned NumComponents
Total number of expression components.
Data for list of allocators.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
Expr * AllocatorTraits
Allocator traits.
Expr * Allocator
Allocator.
This structure contains most locations needed for by an OMPVarListClause.
Describes how types, statements, expressions, and declarations should be printed.
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.