21#include "llvm/ADT/SmallPtrSet.h"
22#include "llvm/Support/ErrorHandling.h"
35#define GEN_CLANG_CLAUSE_CLASS
36#define CLAUSE_CLASS(Enum, Str, Class) \
38 return static_cast<Class *>(this)->children();
39#include "llvm/Frontend/OpenMP/OMP.inc"
41 llvm_unreachable(
"unknown OMPClause");
46#define GEN_CLANG_CLAUSE_CLASS
47#define CLAUSE_CLASS(Enum, Str, Class) \
49 return static_cast<Class *>(this)->used_children();
50#define CLAUSE_NO_CLASS(Enum, Str) \
53#include "llvm/Frontend/OpenMP/OMP.inc"
55 llvm_unreachable(
"unknown OMPClause");
64 switch (
C->getClauseKind()) {
67 case OMPC_dist_schedule:
69 case OMPC_firstprivate:
71 case OMPC_lastprivate:
75 case OMPC_task_reduction:
77 case OMPC_in_reduction:
83 case OMPC_num_threads:
87 case OMPC_thread_limit:
105 case OMPC_ompx_dyn_cgroup_mem:
121 case OMPC_copyprivate:
126 case OMPC_threadprivate:
127 case OMPC_groupprivate:
147 case OMPC_defaultmap:
152 case OMPC_use_device_ptr:
153 case OMPC_use_device_addr:
154 case OMPC_is_device_ptr:
155 case OMPC_has_device_addr:
156 case OMPC_unified_address:
157 case OMPC_unified_shared_memory:
158 case OMPC_reverse_offload:
159 case OMPC_dynamic_allocators:
160 case OMPC_atomic_default_mem_order:
164 case OMPC_device_type:
166 case OMPC_nontemporal:
172 case OMPC_uses_allocators:
191 switch (
C->getClauseKind()) {
192 case OMPC_lastprivate:
196 case OMPC_task_reduction:
198 case OMPC_in_reduction:
203 case OMPC_dist_schedule:
204 case OMPC_firstprivate:
209 case OMPC_num_threads:
220 case OMPC_copyprivate:
225 case OMPC_threadprivate:
226 case OMPC_groupprivate:
246 case OMPC_thread_limit:
252 case OMPC_defaultmap:
257 case OMPC_use_device_ptr:
258 case OMPC_use_device_addr:
259 case OMPC_is_device_ptr:
260 case OMPC_has_device_addr:
261 case OMPC_unified_address:
262 case OMPC_unified_shared_memory:
263 case OMPC_reverse_offload:
264 case OMPC_dynamic_allocators:
265 case OMPC_atomic_default_mem_order:
270 case OMPC_device_type:
272 case OMPC_nontemporal:
275 case OMPC_novariants:
280 case OMPC_uses_allocators:
297 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
298 assert(DS->isSingleDecl() &&
"Only single expression must be captured.");
299 if (
auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
300 return OED->getInitAddress();
352 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
354 new (Mem) OMPOrderedClause(
Num, NumLoops, StartLoc, LParenLoc, EndLoc);
355 for (
unsigned I = 0; I < NumLoops; ++I) {
356 Clause->setLoopNumIterations(I,
nullptr);
357 Clause->setLoopCounter(I,
nullptr);
364 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
365 auto *Clause =
new (Mem) OMPOrderedClause(NumLoops);
366 for (
unsigned I = 0; I < NumLoops; ++I) {
367 Clause->setLoopNumIterations(I,
nullptr);
368 Clause->setLoopCounter(I,
nullptr);
374 Expr *NumIterations) {
375 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
376 getTrailingObjects()[NumLoop] = NumIterations;
380 return getTrailingObjects(NumberOfLoops);
384 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
385 getTrailingObjects()[NumberOfLoops + NumLoop] = Counter;
389 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
390 return getTrailingObjects()[NumberOfLoops + NumLoop];
394 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
395 return getTrailingObjects()[NumberOfLoops + NumLoop];
401 return new (
C) OMPUpdateClause(StartLoc, EndLoc,
false);
409 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
410 alignof(OMPUpdateClause));
412 new (Mem) OMPUpdateClause(StartLoc, EndLoc,
true);
413 Clause->setLParenLoc(LParenLoc);
414 Clause->setArgumentLoc(ArgumentLoc);
415 Clause->setDependencyKind(DK);
422 return new (
C) OMPUpdateClause(
false);
424 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
425 alignof(OMPUpdateClause));
426 auto *Clause =
new (Mem) OMPUpdateClause(
true);
427 Clause->IsExtended =
true;
433 "Number of private copies is not the same as the preallocated buffer");
442 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
443 OMPPrivateClause *Clause =
444 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
445 Clause->setVarRefs(VL);
446 Clause->setPrivateCopies(PrivateVL);
452 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
453 return new (Mem) OMPPrivateClause(N);
458 "Number of private copies is not the same as the preallocated buffer");
464 "Number of inits is not the same as the preallocated buffer");
465 llvm::copy(VL, getPrivateCopies().end());
473 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
474 OMPFirstprivateClause *Clause =
475 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
476 Clause->setVarRefs(VL);
477 Clause->setPrivateCopies(PrivateVL);
478 Clause->setInits(InitVL);
479 Clause->setPreInitStmt(PreInit);
485 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
486 return new (Mem) OMPFirstprivateClause(N);
491 "Number of private copies is not the same as the preallocated buffer");
496 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
497 "not the same as the "
498 "preallocated buffer");
499 llvm::copy(SrcExprs, getPrivateCopies().end());
503 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
504 "expressions is not the same as "
505 "the preallocated buffer");
506 llvm::copy(DstExprs, getSourceExprs().end());
509void OMPLastprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
511 "Number of assignment expressions is not the same as the preallocated "
513 llvm::copy(AssignmentOps, getDestinationExprs().end());
522 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
523 OMPLastprivateClause *Clause =
new (Mem) OMPLastprivateClause(
524 StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
525 Clause->setVarRefs(VL);
526 Clause->setSourceExprs(SrcExprs);
527 Clause->setDestinationExprs(DstExprs);
528 Clause->setAssignmentOps(AssignmentOps);
529 Clause->setPreInitStmt(PreInit);
530 Clause->setPostUpdateExpr(PostUpdate);
536 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
537 return new (Mem) OMPLastprivateClause(N);
545 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
546 OMPSharedClause *Clause =
547 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
548 Clause->setVarRefs(VL);
553 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
554 return new (Mem) OMPSharedClause(N);
559 "Number of privates is not the same as the preallocated buffer");
565 "Number of inits is not the same as the preallocated buffer");
566 llvm::copy(IL, getPrivates().end());
571 "Number of updates is not the same as the preallocated buffer");
572 llvm::copy(UL, getInits().end());
577 "Number of final updates is not the same as the preallocated buffer");
578 llvm::copy(FL, getUpdates().end());
584 "Number of used expressions is not the same as the preallocated buffer");
585 llvm::copy(UE, getFinals().end() + 2);
598 C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
599 OMPLinearClause *Clause =
600 new (Mem) OMPLinearClause(StartLoc, LParenLoc, Modifier, ModifierLoc,
601 ColonLoc, StepModifierLoc, EndLoc, VL.size());
602 Clause->setVarRefs(VL);
603 Clause->setPrivates(PL);
604 Clause->setInits(IL);
607 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
609 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
611 std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
613 Clause->setStep(Step);
614 Clause->setCalcStep(CalcStep);
615 Clause->setPreInitStmt(PreInit);
616 Clause->setPostUpdateExpr(PostUpdate);
624 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
625 return new (Mem) OMPLinearClause(NumVars);
631 reinterpret_cast<Stmt **
>(getUsedExprs().begin()),
632 reinterpret_cast<Stmt **
>(llvm::find(getUsedExprs(),
nullptr)));
639 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
640 OMPAlignedClause *Clause =
new (Mem)
641 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
642 Clause->setVarRefs(VL);
643 Clause->setAlignment(A);
649 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
650 return new (Mem) OMPAlignedClause(NumVars);
657 return new (
C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc);
661 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
662 "not the same as the "
663 "preallocated buffer");
668 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
669 "expressions is not the same as "
670 "the preallocated buffer");
671 llvm::copy(DstExprs, getSourceExprs().end());
676 "Number of assignment expressions is not the same as the preallocated "
678 llvm::copy(AssignmentOps, getDestinationExprs().end());
685 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
686 OMPCopyinClause *Clause =
687 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
688 Clause->setVarRefs(VL);
689 Clause->setSourceExprs(SrcExprs);
690 Clause->setDestinationExprs(DstExprs);
691 Clause->setAssignmentOps(AssignmentOps);
696 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
697 return new (Mem) OMPCopyinClause(N);
701 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
702 "not the same as the "
703 "preallocated buffer");
708 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
709 "expressions is not the same as "
710 "the preallocated buffer");
711 llvm::copy(DstExprs, getSourceExprs().end());
714void OMPCopyprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
716 "Number of assignment expressions is not the same as the preallocated "
718 llvm::copy(AssignmentOps, getDestinationExprs().end());
725 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
726 OMPCopyprivateClause *Clause =
727 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
728 Clause->setVarRefs(VL);
729 Clause->setSourceExprs(SrcExprs);
730 Clause->setDestinationExprs(DstExprs);
731 Clause->setAssignmentOps(AssignmentOps);
737 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
738 return new (Mem) OMPCopyprivateClause(N);
743 "Number of private copies is not the same as the preallocated buffer");
750 "Number of LHS expressions is not the same as the preallocated buffer");
751 llvm::copy(LHSExprs, getPrivates().end());
757 "Number of RHS expressions is not the same as the preallocated buffer");
758 llvm::copy(RHSExprs, getLHSExprs().end());
762 assert(ReductionOps.size() ==
varlist_size() &&
"Number of reduction "
763 "expressions is not the same "
764 "as the preallocated buffer");
765 llvm::copy(ReductionOps, getRHSExprs().end());
769 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
770 assert(Ops.size() ==
varlist_size() &&
"Number of copy "
771 "expressions is not the same "
772 "as the preallocated buffer");
773 llvm::copy(Ops, getReductionOps().end());
776void OMPReductionClause::setInscanCopyArrayTemps(
778 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
780 "Number of copy temp expressions is not the same as the preallocated "
782 llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
785void OMPReductionClause::setInscanCopyArrayElems(
787 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
789 "Number of copy temp expressions is not the same as the preallocated "
791 llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
805 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
806 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size(), VL.size()));
807 auto *Clause =
new (Mem) OMPReductionClause(
808 StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc, Modifier,
809 OrignalSharingModifier, VL.size(), QualifierLoc, NameInfo);
810 Clause->setVarRefs(VL);
811 Clause->setPrivates(Privates);
812 Clause->setLHSExprs(LHSExprs);
813 Clause->setRHSExprs(RHSExprs);
814 Clause->setReductionOps(ReductionOps);
815 Clause->setPreInitStmt(PreInit);
816 Clause->setPostUpdateExpr(PostUpdate);
817 Clause->setPrivateVariableReductionFlags(IsPrivateVarReduction);
818 if (Modifier == OMPC_REDUCTION_inscan) {
819 Clause->setInscanCopyOps(CopyOps);
820 Clause->setInscanCopyArrayTemps(CopyArrayTemps);
821 Clause->setInscanCopyArrayElems(CopyArrayElems);
823 assert(CopyOps.empty() &&
824 "copy operations are expected in inscan reductions only.");
825 assert(CopyArrayTemps.empty() &&
826 "copy array temps are expected in inscan reductions only.");
827 assert(CopyArrayElems.empty() &&
828 "copy array temps are expected in inscan reductions only.");
836 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
837 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N, N));
838 auto *Clause =
new (Mem) OMPReductionClause(N);
839 Clause->setModifier(Modifier);
845 "Number of private copies is not the same as the preallocated buffer");
852 "Number of LHS expressions is not the same as the preallocated buffer");
853 llvm::copy(LHSExprs, getPrivates().end());
859 "Number of RHS expressions is not the same as the preallocated buffer");
860 llvm::copy(RHSExprs, getLHSExprs().end());
863void OMPTaskReductionClause::setReductionOps(
ArrayRef<Expr *> ReductionOps) {
864 assert(ReductionOps.size() ==
varlist_size() &&
"Number of task reduction "
865 "expressions is not the same "
866 "as the preallocated buffer");
867 llvm::copy(ReductionOps, getRHSExprs().end());
877 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
878 OMPTaskReductionClause *Clause =
new (Mem) OMPTaskReductionClause(
879 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
880 Clause->setVarRefs(VL);
881 Clause->setPrivates(Privates);
882 Clause->setLHSExprs(LHSExprs);
883 Clause->setRHSExprs(RHSExprs);
884 Clause->setReductionOps(ReductionOps);
885 Clause->setPreInitStmt(PreInit);
886 Clause->setPostUpdateExpr(PostUpdate);
892 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
893 return new (Mem) OMPTaskReductionClause(N);
898 "Number of private copies is not the same as the preallocated buffer");
905 "Number of LHS expressions is not the same as the preallocated buffer");
906 llvm::copy(LHSExprs, getPrivates().end());
912 "Number of RHS expressions is not the same as the preallocated buffer");
913 llvm::copy(RHSExprs, getLHSExprs().end());
917 assert(ReductionOps.size() ==
varlist_size() &&
"Number of in reduction "
918 "expressions is not the same "
919 "as the preallocated buffer");
920 llvm::copy(ReductionOps, getRHSExprs().end());
923void OMPInReductionClause::setTaskgroupDescriptors(
926 "Number of in reduction descriptors is not the same as the "
927 "preallocated buffer");
928 llvm::copy(TaskgroupDescriptors, getReductionOps().end());
938 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
939 OMPInReductionClause *Clause =
new (Mem) OMPInReductionClause(
940 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
941 Clause->setVarRefs(VL);
942 Clause->setPrivates(Privates);
943 Clause->setLHSExprs(LHSExprs);
944 Clause->setRHSExprs(RHSExprs);
945 Clause->setReductionOps(ReductionOps);
946 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
947 Clause->setPreInitStmt(PreInit);
948 Clause->setPostUpdateExpr(PostUpdate);
954 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
955 return new (Mem) OMPInReductionClause(N);
964 Clause->setLocStart(StartLoc);
965 Clause->setLParenLoc(LParenLoc);
966 Clause->setLocEnd(EndLoc);
967 Clause->setSizesRefs(Sizes);
973 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
974 return new (Mem) OMPSizesClause(NumSizes);
982 OMPPermutationClause *Clause =
CreateEmpty(
C, Args.size());
983 Clause->setLocStart(StartLoc);
984 Clause->setLParenLoc(LParenLoc);
985 Clause->setLocEnd(EndLoc);
986 Clause->setArgRefs(Args);
992 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumLoops));
993 return new (Mem) OMPPermutationClause(NumLoops);
1000 Clause->setLocStart(StartLoc);
1001 Clause->setLocEnd(EndLoc);
1006 return new (
C) OMPFullClause();
1015 Clause->setLocStart(StartLoc);
1016 Clause->setLParenLoc(LParenLoc);
1017 Clause->setLocEnd(EndLoc);
1018 Clause->setFactor(Factor);
1023 return new (
C) OMPPartialClause();
1034 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1035 auto *Clause =
new (Mem) OMPAllocateClause(
1036 StartLoc, LParenLoc, Allocator, Alignment, ColonLoc, Modifier1,
1037 Modifier1Loc, Modifier2, Modifier2Loc, EndLoc, VL.size());
1039 Clause->setVarRefs(VL);
1045 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1046 return new (Mem) OMPAllocateClause(N);
1054 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
1055 OMPFlushClause *Clause =
1056 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1057 Clause->setVarRefs(VL);
1062 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1063 return new (Mem) OMPFlushClause(N);
1071 auto *Clause =
new (
C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
1072 Clause->setDepobj(Depobj);
1077 return new (
C) OMPDepobjClause();
1085 void *Mem =
C.Allocate(
1086 totalSizeToAlloc<Expr *>(VL.size() + 1 + NumLoops),
1087 alignof(OMPDependClause));
1088 OMPDependClause *Clause =
new (Mem)
1089 OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1090 Clause->setDependencyKind(Data.DepKind);
1091 Clause->setDependencyLoc(Data.DepLoc);
1092 Clause->setColonLoc(Data.ColonLoc);
1093 Clause->setOmpAllMemoryLoc(Data.OmpAllMemoryLoc);
1094 Clause->setModifier(DepModifier);
1095 Clause->setVarRefs(VL);
1096 for (
unsigned I = 0 ; I < NumLoops; ++I)
1097 Clause->setLoopData(I,
nullptr);
1102 unsigned NumLoops) {
1104 C.Allocate(totalSizeToAlloc<Expr *>(N + 1 + NumLoops),
1105 alignof(OMPDependClause));
1106 return new (Mem) OMPDependClause(N, NumLoops);
1112 NumLoop < NumLoops &&
1113 "Expected sink or source depend + loop index must be less number of "
1115 auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1122 NumLoop < NumLoops &&
1123 "Expected sink or source depend + loop index must be less number of "
1125 auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1132 NumLoop < NumLoops &&
1133 "Expected sink or source depend + loop index must be less number of "
1135 const auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1139void OMPDependClause::setModifier(
Expr *DepModifier) {
1146 unsigned TotalNum = 0u;
1147 for (
auto &
C : ComponentLists)
1148 TotalNum +=
C.size();
1155 for (
const ValueDecl *D : Declarations) {
1157 UniqueDecls.insert(VD);
1159 return UniqueDecls.size();
1186 void *Mem =
C.Allocate(
1192 OMPMapClause *Clause =
new (Mem)
1193 OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1196 Clause->setVarRefs(Vars);
1197 Clause->setUDMapperRefs(UDMapperRefs);
1198 Clause->setIteratorModifier(IteratorModifier);
1199 Clause->setClauseInfo(Declarations, ComponentLists);
1200 Clause->setMapType(
Type);
1208 void *Mem =
C.Allocate(
1214 OMPMapClause *Clause =
new (Mem) OMPMapClause(Sizes);
1215 Clause->setIteratorModifier(
nullptr);
1242 void *Mem =
C.Allocate(
1249 auto *Clause =
new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc,
1250 UDMQualifierLoc, MapperId, Locs, Sizes);
1252 Clause->setVarRefs(Vars);
1253 Clause->setUDMapperRefs(UDMapperRefs);
1254 Clause->setClauseInfo(Declarations, ComponentLists);
1260 void *Mem =
C.Allocate(
1266 return new (Mem) OMPToClause(Sizes);
1292 void *Mem =
C.Allocate(
1300 new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc,
1301 UDMQualifierLoc, MapperId, Locs, Sizes);
1303 Clause->setVarRefs(Vars);
1304 Clause->setUDMapperRefs(UDMapperRefs);
1305 Clause->setClauseInfo(Declarations, ComponentLists);
1312 void *Mem =
C.Allocate(
1318 return new (Mem) OMPFromClause(Sizes);
1323 "Number of private copies is not the same as the preallocated buffer");
1329 "Number of inits is not the same as the preallocated buffer");
1330 llvm::copy(VL, getPrivateCopies().end());
1354 void *Mem =
C.Allocate(
1361 OMPUseDevicePtrClause *Clause =
new (Mem) OMPUseDevicePtrClause(Locs, Sizes);
1363 Clause->setVarRefs(Vars);
1364 Clause->setPrivateCopies(PrivateVars);
1365 Clause->setInits(Inits);
1366 Clause->setClauseInfo(Declarations, ComponentLists);
1373 void *Mem =
C.Allocate(
1379 return new (Mem) OMPUseDevicePtrClause(Sizes);
1403 void *Mem =
C.Allocate(
1410 auto *Clause =
new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
1412 Clause->setVarRefs(Vars);
1413 Clause->setClauseInfo(Declarations, ComponentLists);
1420 void *Mem =
C.Allocate(
1426 return new (Mem) OMPUseDeviceAddrClause(Sizes);
1450 void *Mem =
C.Allocate(
1457 OMPIsDevicePtrClause *Clause =
new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1459 Clause->setVarRefs(Vars);
1460 Clause->setClauseInfo(Declarations, ComponentLists);
1467 void *Mem =
C.Allocate(
1473 return new (Mem) OMPIsDevicePtrClause(Sizes);
1497 void *Mem =
C.Allocate(
1504 auto *Clause =
new (Mem) OMPHasDeviceAddrClause(Locs, Sizes);
1506 Clause->setVarRefs(Vars);
1507 Clause->setClauseInfo(Declarations, ComponentLists);
1514 void *Mem =
C.Allocate(
1520 return new (Mem) OMPHasDeviceAddrClause(Sizes);
1529 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1531 new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
1532 Clause->setVarRefs(VL);
1538 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1539 return new (Mem) OMPNontemporalClause(N);
1543 assert(VL.size() ==
varlist_size() &&
"Number of private references is not "
1544 "the same as the preallocated buffer");
1553 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1555 new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1556 Clause->setVarRefs(VL);
1562 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1563 return new (Mem) OMPInclusiveClause(N);
1571 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1573 new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1574 Clause->setVarRefs(VL);
1580 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1581 return new (Mem) OMPExclusiveClause(N);
1584void OMPUsesAllocatorsClause::setAllocatorsData(
1586 assert(
Data.size() == NumOfAllocators &&
1587 "Size of allocators data is not the same as the preallocated buffer.");
1588 for (
unsigned I = 0, E =
Data.size(); I < E; ++I) {
1590 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1591 static_cast<int>(ExprOffsets::Allocator)] =
1593 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1595 ExprOffsets::AllocatorTraits)] =
1598 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1599 static_cast<int>(ParenLocsOffsets::LParen)] =
1602 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1603 static_cast<int>(ParenLocsOffsets::RParen)] =
1612 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1613 static_cast<int>(ExprOffsets::Allocator)];
1615 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1617 ExprOffsets::AllocatorTraits)];
1619 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1620 static_cast<int>(ParenLocsOffsets::LParen)];
1622 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1623 static_cast<int>(ParenLocsOffsets::RParen)];
1631 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1632 static_cast<int>(ExprOffsets::Total) *
Data.size(),
1633 static_cast<int>(ParenLocsOffsets::Total) *
Data.size()));
1634 auto *Clause =
new (Mem)
1635 OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc,
Data.size());
1636 Clause->setAllocatorsData(
Data);
1642 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1643 static_cast<int>(ExprOffsets::Total) * N,
1644 static_cast<int>(ParenLocsOffsets::Total) * N));
1645 return new (Mem) OMPUsesAllocatorsClause(N);
1653 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1654 auto *Clause =
new (Mem)
1655 OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
1656 Clause->setModifier(Modifier);
1657 Clause->setVarRefs(Locators);
1663 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1664 return new (Mem) OMPAffinityClause(N);
1675 C.Allocate(totalSizeToAlloc<Expr *>(InteropInfo.
PreferTypes.size() + 1));
1676 auto *Clause =
new (Mem) OMPInitClause(
1678 VarLoc, EndLoc, InteropInfo.
PreferTypes.size() + 1);
1679 Clause->setInteropVar(InteropVar);
1680 llvm::copy(InteropInfo.
PreferTypes, Clause->getTrailingObjects() + 1);
1685 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1686 return new (Mem) OMPInitClause(N);
1693 return new (
C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
1697 return new (
C) OMPBindClause();
1706 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops),
1707 alignof(OMPDoacrossClause));
1708 OMPDoacrossClause *Clause =
new (Mem)
1709 OMPDoacrossClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1710 Clause->setDependenceType(DepType);
1711 Clause->setDependenceLoc(DepLoc);
1712 Clause->setColonLoc(ColonLoc);
1713 Clause->setVarRefs(VL);
1714 for (
unsigned I = 0; I < NumLoops; ++I)
1715 Clause->setLoopData(I,
nullptr);
1721 unsigned NumLoops) {
1722 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops),
1723 alignof(OMPDoacrossClause));
1724 return new (Mem) OMPDoacrossClause(N, NumLoops);
1728 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1729 auto *It = std::next(
getVarRefs().end(), NumLoop);
1734 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1735 auto *It = std::next(
getVarRefs().end(), NumLoop);
1740 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1741 const auto *It = std::next(
getVarRefs().end(), NumLoop);
1750 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1751 alignof(OMPAbsentClause));
1752 auto *AC =
new (Mem) OMPAbsentClause(Loc, LLoc, RLoc, DKVec.size());
1753 AC->setDirectiveKinds(DKVec);
1758 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1759 alignof(OMPAbsentClause));
1760 return new (Mem) OMPAbsentClause(K);
1766 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1767 alignof(OMPContainsClause));
1768 auto *CC =
new (Mem) OMPContainsClause(Loc, LLoc, RLoc, DKVec.size());
1769 CC->setDirectiveKinds(DKVec);
1775 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1776 alignof(OMPContainsClause));
1777 return new (Mem) OMPContainsClause(K);
1784 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1785 OMPNumTeamsClause *Clause =
1786 new (Mem) OMPNumTeamsClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1787 Clause->setVarRefs(VL);
1788 Clause->setPreInitStmt(PreInit, CaptureRegion);
1794 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1795 return new (Mem) OMPNumTeamsClause(N);
1802 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1803 OMPThreadLimitClause *Clause =
1804 new (Mem) OMPThreadLimitClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1805 Clause->setVarRefs(VL);
1806 Clause->setPreInitStmt(PreInit, CaptureRegion);
1812 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1813 return new (Mem) OMPThreadLimitClause(N);
1820void OMPClausePrinter::VisitOMPIfClause(
OMPIfClause *Node) {
1823 OS << getOpenMPDirectiveName(Node->
getNameModifier(), Version) <<
": ";
1828void OMPClausePrinter::VisitOMPFinalClause(
OMPFinalClause *Node) {
1835 OS <<
"num_threads(";
1845void OMPClausePrinter::VisitOMPAlignClause(
OMPAlignClause *Node) {
1863void OMPClausePrinter::VisitOMPSizesClause(
OMPSizesClause *Node) {
1869 Size->printPretty(OS,
nullptr, Policy, 0);
1876 OS <<
"permutation(";
1877 llvm::interleaveComma(Node->
getArgsRefs(), OS, [&](
const Expr *E) {
1878 E->printPretty(OS, nullptr, Policy, 0);
1883void OMPClausePrinter::VisitOMPFullClause(
OMPFullClause *Node) { OS <<
"full"; }
1890 Factor->printPretty(OS,
nullptr, Policy, 0);
1917 if (Version >= 60 && Node->
getDefaultVC() != OMPC_DEFAULT_VC_all) {
1933 OS <<
"unified_address";
1936void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1938 OS <<
"unified_shared_memory";
1942 OS <<
"reverse_offload";
1945void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1947 OS <<
"dynamic_allocators";
1950void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1952 OS <<
"atomic_default_mem_order("
1962void OMPClausePrinter::VisitOMPAtClause(
OMPAtClause *Node) {
1976 E->printPretty(OS,
nullptr, Policy);
1995 E->printPretty(OS,
nullptr, Policy);
2004 Num->printPretty(OS,
nullptr, Policy, 0);
2025void OMPClausePrinter::VisitOMPReadClause(
OMPReadClause *) { OS <<
"read"; }
2027void OMPClausePrinter::VisitOMPWriteClause(
OMPWriteClause *) { OS <<
"write"; }
2047void OMPClausePrinter::VisitOMPFailClause(
OMPFailClause *Node) {
2063 OS << getOpenMPDirectiveName(D, Version);
2069void OMPClausePrinter::VisitOMPHoldsClause(
OMPHoldsClause *Node) {
2081 OS << getOpenMPDirectiveName(D, Version);
2091void OMPClausePrinter::VisitOMPNoOpenMPRoutinesClause(
2093 OS <<
"no_openmp_routines";
2096void OMPClausePrinter::VisitOMPNoOpenMPConstructsClause(
2098 OS <<
"no_openmp_constructs";
2102 OS <<
"no_parallelism";
2125void OMPClausePrinter::VisitOMPWeakClause(
OMPWeakClause *) { OS <<
"weak"; }
2131void OMPClausePrinter::VisitOMPSIMDClause(
OMPSIMDClause *) { OS <<
"simd"; }
2147 VisitOMPClauseList(Node,
'(');
2154 OS <<
"thread_limit";
2155 VisitOMPClauseList(Node,
'(');
2188void OMPClausePrinter::VisitOMPHintClause(
OMPHintClause *Node) {
2194void OMPClausePrinter::VisitOMPInitClause(
OMPInitClause *Node) {
2197 for (
const Expr *E : Node->
prefs()) {
2199 OS <<
"prefer_type(";
2202 E->printPretty(OS,
nullptr, Policy);
2219void OMPClausePrinter::VisitOMPUseClause(
OMPUseClause *Node) {
2229 E->printPretty(OS,
nullptr, Policy);
2238 E->printPretty(OS,
nullptr, Policy, 0);
2247 E->printPretty(OS,
nullptr, Policy, 0);
2253void OMPClausePrinter::VisitOMPClauseList(
T *Node,
char StartSym) {
2254 for (
typename T::varlist_iterator I = Node->varlist_begin(),
2255 E = Node->varlist_end();
2257 assert(*I &&
"Expected non-null Stmt");
2258 OS << (I == Node->varlist_begin() ? StartSym :
',');
2259 if (
auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
2261 DRE->printPretty(OS,
nullptr, Policy, 0);
2263 DRE->getDecl()->printQualifiedName(OS);
2265 (*I)->printPretty(OS,
nullptr, Policy, 0);
2273 Expr *FirstModifier =
nullptr;
2274 Expr *SecondModifier =
nullptr;
2279 if (FirstAllocMod == OMPC_ALLOCATE_allocator ||
2290 if (FirstModifier) {
2292 if (!FirstUnknown) {
2296 FirstModifier->
printPretty(OS,
nullptr, Policy, 0);
2299 if (SecondModifier) {
2301 if (!SecondUnknown) {
2306 SecondModifier->
printPretty(OS,
nullptr, Policy, 0);
2311 VisitOMPClauseList(Node,
' ');
2314 VisitOMPClauseList(Node,
'(');
2322 VisitOMPClauseList(Node,
'(');
2329 OS <<
"firstprivate";
2330 VisitOMPClauseList(Node,
'(');
2337 OS <<
"lastprivate";
2352 VisitOMPClauseList(Node,
'(');
2367 if (!Qualifier && OOK !=
OO_None) {
2376 VisitOMPClauseList(Node,
' ');
2381void OMPClausePrinter::VisitOMPTaskReductionClause(
2384 OS <<
"task_reduction(";
2389 if (!Qualifier && OOK !=
OO_None) {
2398 VisitOMPClauseList(Node,
' ');
2405 OS <<
"in_reduction(";
2410 if (!Qualifier && OOK !=
OO_None) {
2419 VisitOMPClauseList(Node,
' ');
2427 VisitOMPClauseList(Node,
'(');
2434 if (Node->
getStep() !=
nullptr) {
2449 VisitOMPClauseList(Node,
'(');
2461 VisitOMPClauseList(Node,
'(');
2468 OS <<
"copyprivate";
2469 VisitOMPClauseList(Node,
'(');
2474void OMPClausePrinter::VisitOMPFlushClause(
OMPFlushClause *Node) {
2476 VisitOMPClauseList(Node,
'(');
2495 bool IsOmpAllMemory =
false;
2496 if (PrintKind == OMPC_DEPEND_outallmemory) {
2497 PrintKind = OMPC_DEPEND_out;
2498 IsOmpAllMemory =
true;
2499 }
else if (PrintKind == OMPC_DEPEND_inoutallmemory) {
2500 PrintKind = OMPC_DEPEND_inout;
2501 IsOmpAllMemory =
true;
2506 VisitOMPClauseList(Node,
' ');
2507 if (IsOmpAllMemory) {
2509 OS <<
"omp_all_memory";
2514template <
typename T>
2519 Node->getMapperQualifierLoc().getNestedNameSpecifier();
2520 MapperNNS.
print(OS, Policy);
2521 OS << Node->getMapperIdInfo() <<
')';
2524template <
typename T>
2527 if (
Expr *IteratorModifier = Node->getIteratorModifier())
2528 IteratorModifier->printPretty(OS,
nullptr, Policy);
2531void OMPClausePrinter::VisitOMPMapClause(
OMPMapClause *Node) {
2551 VisitOMPClauseList(Node,
' ');
2556template <
typename T>
void OMPClausePrinter::VisitOMPMotionClause(
T *Node) {
2557 if (Node->varlist_empty())
2559 OS << getOpenMPClauseName(Node->getClauseKind());
2560 unsigned ModifierCount = 0;
2565 if (ModifierCount) {
2570 Node->getMotionModifier(I));
2571 if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2573 if (I < ModifierCount - 1)
2578 VisitOMPClauseList(Node,
' ');
2580 VisitOMPClauseList(Node,
'(');
2585void OMPClausePrinter::VisitOMPToClause(
OMPToClause *Node) {
2586 VisitOMPMotionClause(Node);
2589void OMPClausePrinter::VisitOMPFromClause(
OMPFromClause *Node) {
2590 VisitOMPMotionClause(Node);
2598 E->printPretty(OS,
nullptr, Policy);
2604 OS <<
"defaultmap(";
2617 OS <<
"use_device_ptr";
2618 VisitOMPClauseList(Node,
'(');
2623void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2626 OS <<
"use_device_addr";
2627 VisitOMPClauseList(Node,
'(');
2634 OS <<
"is_device_ptr";
2635 VisitOMPClauseList(Node,
'(');
2642 OS <<
"has_device_addr";
2643 VisitOMPClauseList(Node,
'(');
2650 OS <<
"nontemporal";
2651 VisitOMPClauseList(Node,
'(');
2656void OMPClausePrinter::VisitOMPOrderClause(
OMPOrderClause *Node) {
2668 VisitOMPClauseList(Node,
'(');
2676 VisitOMPClauseList(Node,
'(');
2681void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2685 OS <<
"uses_allocators(";
2689 if (
Data.AllocatorTraits) {
2691 Data.AllocatorTraits->printPretty(OS,
nullptr, Policy);
2704 char StartSym =
'(';
2707 Modifier->printPretty(OS,
nullptr, Policy);
2711 VisitOMPClauseList(Node, StartSym);
2721void OMPClausePrinter::VisitOMPBindClause(
OMPBindClause *Node) {
2727void OMPClausePrinter::VisitOMPXDynCGroupMemClause(
2729 OS <<
"ompx_dyn_cgroup_mem(";
2739 case OMPC_DOACROSS_source:
2742 case OMPC_DOACROSS_sink:
2745 case OMPC_DOACROSS_source_omp_cur_iteration:
2746 OS <<
"source: omp_cur_iteration";
2748 case OMPC_DOACROSS_sink_omp_cur_iteration:
2749 OS <<
"sink: omp_cur_iteration - 1";
2752 llvm_unreachable(
"unknown docaross modifier");
2754 VisitOMPClauseList(Node,
' ');
2759 OS <<
"ompx_attribute(";
2761 for (
auto &Attr : Node->
getAttrs()) {
2764 Attr->printPretty(OS, Policy);
2770void OMPClausePrinter::VisitOMPXBareClause(
OMPXBareClause *Node) {
2775 VariantMatchInfo &VMI)
const {
2780 if (
Selector.Kind == TraitSelector::user_condition) {
2781 assert(
Selector.ScoreOrCondition &&
2782 "Ill-formed user condition, expected condition expression!");
2783 assert(
Selector.Properties.size() == 1 &&
2784 Selector.Properties.front().Kind ==
2785 TraitProperty::user_condition_unknown &&
2786 "Ill-formed user condition, expected unknown trait property!");
2788 if (std::optional<APSInt> CondVal =
2789 Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2790 VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
2791 : TraitProperty::user_condition_true,
2794 VMI.addTrait(TraitProperty::user_condition_false,
"<condition>");
2798 std::optional<llvm::APSInt> Score;
2799 llvm::APInt *ScorePtr =
nullptr;
2801 if ((Score =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
2804 VMI.addTrait(TraitProperty::user_condition_false,
2805 "<non-constant-score>");
2811 if (
Set.Kind != TraitSet::construct)
2815 assert(
Selector.Properties.size() == 1 &&
2816 Selector.Properties.front().Kind ==
2817 getOpenMPContextTraitPropertyForSelector(
2819 "Ill-formed construct selector!");
2826 bool FirstSet =
true;
2831 OS << getOpenMPContextTraitSetName(
Set.Kind) <<
"={";
2833 bool FirstSelector =
true;
2837 FirstSelector =
false;
2838 OS << getOpenMPContextTraitSelectorName(
Selector.Kind);
2840 bool AllowsTraitScore =
false;
2841 bool RequiresProperty =
false;
2842 isValidTraitSelectorForTraitSet(
2843 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
2845 if (!RequiresProperty)
2849 if (
Selector.Kind == TraitSelector::user_condition) {
2851 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
2858 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
2862 bool FirstProperty =
true;
2866 FirstProperty =
false;
2867 OS << getOpenMPContextTraitPropertyName(
Property.Kind,
2878 std::string MangledName;
2879 llvm::raw_string_ostream OS(MangledName);
2884 bool AllowsTraitScore =
false;
2885 bool RequiresProperty =
false;
2886 isValidTraitSelectorForTraitSet(
2887 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
2890 if (!RequiresProperty ||
2891 Selector.Kind == TraitSelector::user_condition)
2896 << getOpenMPContextTraitPropertyName(
Property.Kind,
2903OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
2906 if (!MangledName.consume_front(
"$S"))
2908 if (MangledName.consumeInteger(10,
U))
2912 Set.Kind = TraitSet(
U);
2914 if (!MangledName.consume_front(
"$s"))
2916 if (MangledName.consumeInteger(10,
U))
2922 if (!MangledName.consume_front(
"$P"))
2926 std::pair<StringRef, StringRef> PropRestPair = MangledName.split(
'$');
2927 Property.RawString = PropRestPair.first;
2928 Property.Kind = getOpenMPContextTraitPropertyKind(
2930 MangledName = MangledName.drop_front(PropRestPair.first.size());
2940 TI.
print(OS, Policy);
2945 return TI ? OS << *TI : OS;
2952 : OMPContext(ASTCtx.getLangOpts().OpenMPIsTargetDevice,
2953 ASTCtx.getTargetInfo().getTriple(),
2954 ASTCtx.getLangOpts().OMPTargetTriples.empty()
2956 : ASTCtx.getLangOpts().OMPTargetTriples[0],
2958 FeatureValidityCheck([&](StringRef FeatureName) {
2959 return ASTCtx.
getTargetInfo().isValidFeatureName(FeatureName);
2961 DiagUnknownTrait(std::move(DiagUnknownTrait)) {
2964 for (llvm::omp::TraitProperty
Property : ConstructTraits)
2969 auto It = FeatureMap.find(RawString);
2970 if (It != FeatureMap.end())
2972 if (!FeatureValidityCheck(RawString))
2973 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
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)
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 '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 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.
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 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.
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.
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.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
@ 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.
OpenMPNumThreadsClauseModifier
@ OMPC_NUMTHREADS_unknown
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.