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