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);
112 case OMPC_transparent:
113 return static_cast<const OMPTransparentClause *
>(
C);
126 case OMPC_copyprivate:
132 case OMPC_threadprivate:
133 case OMPC_groupprivate:
153 case OMPC_defaultmap:
158 case OMPC_use_device_ptr:
159 case OMPC_use_device_addr:
160 case OMPC_is_device_ptr:
161 case OMPC_has_device_addr:
162 case OMPC_unified_address:
163 case OMPC_unified_shared_memory:
164 case OMPC_reverse_offload:
165 case OMPC_dynamic_allocators:
166 case OMPC_atomic_default_mem_order:
170 case OMPC_device_type:
172 case OMPC_nontemporal:
178 case OMPC_uses_allocators:
197 switch (
C->getClauseKind()) {
198 case OMPC_lastprivate:
199 return static_cast<const OMPLastprivateClause *
>(
C);
201 return static_cast<const OMPReductionClause *
>(
C);
202 case OMPC_task_reduction:
203 return static_cast<const OMPTaskReductionClause *
>(
C);
204 case OMPC_in_reduction:
205 return static_cast<const OMPInReductionClause *
>(
C);
207 return static_cast<const OMPLinearClause *
>(
C);
209 case OMPC_dist_schedule:
210 case OMPC_firstprivate:
215 case OMPC_num_threads:
226 case OMPC_copyprivate:
231 case OMPC_threadprivate:
232 case OMPC_groupprivate:
252 case OMPC_thread_limit:
258 case OMPC_defaultmap:
263 case OMPC_use_device_ptr:
264 case OMPC_use_device_addr:
265 case OMPC_is_device_ptr:
266 case OMPC_has_device_addr:
267 case OMPC_unified_address:
268 case OMPC_unified_shared_memory:
269 case OMPC_reverse_offload:
270 case OMPC_dynamic_allocators:
271 case OMPC_atomic_default_mem_order:
276 case OMPC_device_type:
278 case OMPC_nontemporal:
281 case OMPC_novariants:
286 case OMPC_uses_allocators:
303 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
304 assert(DS->isSingleDecl() &&
"Only single expression must be captured.");
305 if (
auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
306 return OED->getInitAddress();
325 return child_range(
C,
C + 1);
326 return child_range(&Grainsize, &Grainsize + 1);
331 return child_range(
C,
C + 1);
332 return child_range(&NumTasks, &NumTasks + 1);
343 return child_range(
C,
C + 1);
344 return child_range(&Priority, &Priority + 1);
349 return child_range(
C,
C + 1);
355 return child_range(
C,
C + 1);
364 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
366 new (Mem) OMPOrderedClause(
Num, NumLoops, StartLoc, LParenLoc, EndLoc);
367 for (
unsigned I = 0; I < NumLoops; ++I) {
368 Clause->setLoopNumIterations(I,
nullptr);
369 Clause->setLoopCounter(I,
nullptr);
374OMPOrderedClause *OMPOrderedClause::CreateEmpty(
const ASTContext &
C,
376 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
377 auto *Clause =
new (Mem) OMPOrderedClause(NumLoops);
378 for (
unsigned I = 0; I < NumLoops; ++I) {
379 Clause->setLoopNumIterations(I,
nullptr);
380 Clause->setLoopCounter(I,
nullptr);
385void OMPOrderedClause::setLoopNumIterations(
unsigned NumLoop,
386 Expr *NumIterations) {
387 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
388 getTrailingObjects()[NumLoop] = NumIterations;
392 return getTrailingObjects(NumberOfLoops);
395void OMPOrderedClause::setLoopCounter(
unsigned NumLoop,
Expr *Counter) {
396 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
397 getTrailingObjects()[NumberOfLoops + NumLoop] = Counter;
400Expr *OMPOrderedClause::getLoopCounter(
unsigned NumLoop) {
401 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
402 return getTrailingObjects()[NumberOfLoops + NumLoop];
405const Expr *OMPOrderedClause::getLoopCounter(
unsigned NumLoop)
const {
406 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
407 return getTrailingObjects()[NumberOfLoops + NumLoop];
410OMPUpdateClause *OMPUpdateClause::Create(
const ASTContext &
C,
413 return new (
C) OMPUpdateClause(StartLoc, EndLoc,
false);
421 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
422 alignof(OMPUpdateClause));
424 new (Mem) OMPUpdateClause(StartLoc, EndLoc,
true);
425 Clause->setLParenLoc(LParenLoc);
426 Clause->setArgumentLoc(ArgumentLoc);
427 Clause->setDependencyKind(DK);
431OMPUpdateClause *OMPUpdateClause::CreateEmpty(
const ASTContext &
C,
434 return new (
C) OMPUpdateClause(
false);
436 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
437 alignof(OMPUpdateClause));
438 auto *Clause =
new (Mem) OMPUpdateClause(
true);
439 Clause->IsExtended =
true;
444 assert(VL.size() == varlist_size() &&
445 "Number of private copies is not the same as the preallocated buffer");
446 llvm::copy(VL, varlist_end());
454 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
455 OMPPrivateClause *Clause =
456 new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
457 Clause->setVarRefs(VL);
458 Clause->setPrivateCopies(PrivateVL);
462OMPPrivateClause *OMPPrivateClause::CreateEmpty(
const ASTContext &
C,
464 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
465 return new (Mem) OMPPrivateClause(N);
469 assert(VL.size() == varlist_size() &&
470 "Number of private copies is not the same as the preallocated buffer");
471 llvm::copy(VL, varlist_end());
475 assert(VL.size() == varlist_size() &&
476 "Number of inits is not the same as the preallocated buffer");
477 llvm::copy(VL, getPrivateCopies().end());
480OMPFirstprivateClause *
485 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
486 OMPFirstprivateClause *Clause =
487 new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
488 Clause->setVarRefs(VL);
489 Clause->setPrivateCopies(PrivateVL);
490 Clause->setInits(InitVL);
491 Clause->setPreInitStmt(PreInit);
495OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(
const ASTContext &
C,
497 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
498 return new (Mem) OMPFirstprivateClause(N);
501void OMPLastprivateClause::setPrivateCopies(
ArrayRef<Expr *> PrivateCopies) {
502 assert(PrivateCopies.size() == varlist_size() &&
503 "Number of private copies is not the same as the preallocated buffer");
504 llvm::copy(PrivateCopies, varlist_end());
508 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is "
509 "not the same as the "
510 "preallocated buffer");
511 llvm::copy(SrcExprs, getPrivateCopies().end());
515 assert(DstExprs.size() == varlist_size() &&
"Number of destination "
516 "expressions is not the same as "
517 "the preallocated buffer");
518 llvm::copy(DstExprs, getSourceExprs().end());
521void OMPLastprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
522 assert(AssignmentOps.size() == varlist_size() &&
523 "Number of assignment expressions is not the same as the preallocated "
525 llvm::copy(AssignmentOps, getDestinationExprs().end());
528OMPLastprivateClause *OMPLastprivateClause::Create(
534 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
535 OMPLastprivateClause *Clause =
new (Mem) OMPLastprivateClause(
536 StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
537 Clause->setVarRefs(VL);
538 Clause->setSourceExprs(SrcExprs);
539 Clause->setDestinationExprs(DstExprs);
540 Clause->setAssignmentOps(AssignmentOps);
541 Clause->setPreInitStmt(PreInit);
542 Clause->setPostUpdateExpr(PostUpdate);
546OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(
const ASTContext &
C,
548 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
549 return new (Mem) OMPLastprivateClause(N);
552OMPSharedClause *OMPSharedClause::Create(
const ASTContext &
C,
557 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
558 OMPSharedClause *Clause =
559 new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
560 Clause->setVarRefs(VL);
564OMPSharedClause *OMPSharedClause::CreateEmpty(
const ASTContext &
C,
unsigned N) {
565 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
566 return new (Mem) OMPSharedClause(N);
570 assert(PL.size() == varlist_size() &&
571 "Number of privates is not the same as the preallocated buffer");
572 llvm::copy(PL, varlist_end());
576 assert(IL.size() == varlist_size() &&
577 "Number of inits is not the same as the preallocated buffer");
582 assert(UL.size() == varlist_size() &&
583 "Number of updates is not the same as the preallocated buffer");
588 assert(FL.size() == varlist_size() &&
589 "Number of final updates is not the same as the preallocated buffer");
595 UE.size() == varlist_size() + 1 &&
596 "Number of used expressions is not the same as the preallocated buffer");
600OMPLinearClause *OMPLinearClause::Create(
610 C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
611 OMPLinearClause *Clause =
612 new (Mem) OMPLinearClause(StartLoc, LParenLoc, Modifier, ModifierLoc,
613 ColonLoc, StepModifierLoc, EndLoc, VL.size());
614 Clause->setVarRefs(VL);
615 Clause->setPrivates(PL);
616 Clause->setInits(IL);
619 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
621 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
623 std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
625 Clause->setStep(Step);
626 Clause->setCalcStep(CalcStep);
627 Clause->setPreInitStmt(PreInit);
628 Clause->setPostUpdateExpr(PostUpdate);
632OMPLinearClause *OMPLinearClause::CreateEmpty(
const ASTContext &
C,
636 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
637 return new (Mem) OMPLinearClause(NumVars);
651 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
652 OMPAlignedClause *Clause =
new (Mem)
653 OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
654 Clause->setVarRefs(VL);
655 Clause->setAlignment(A);
661 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
662 return new (Mem) OMPAlignedClause(NumVars);
669 return new (
C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc);
673 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is "
674 "not the same as the "
675 "preallocated buffer");
676 llvm::copy(SrcExprs, varlist_end());
680 assert(DstExprs.size() == varlist_size() &&
"Number of destination "
681 "expressions is not the same as "
682 "the preallocated buffer");
683 llvm::copy(DstExprs, getSourceExprs().end());
687 assert(AssignmentOps.size() == varlist_size() &&
688 "Number of assignment expressions is not the same as the preallocated "
690 llvm::copy(AssignmentOps, getDestinationExprs().end());
697 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
698 OMPCopyinClause *Clause =
699 new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
700 Clause->setVarRefs(VL);
701 Clause->setSourceExprs(SrcExprs);
702 Clause->setDestinationExprs(DstExprs);
703 Clause->setAssignmentOps(AssignmentOps);
708 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
709 return new (Mem) OMPCopyinClause(N);
713 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is "
714 "not the same as the "
715 "preallocated buffer");
716 llvm::copy(SrcExprs, varlist_end());
720 assert(DstExprs.size() == varlist_size() &&
"Number of destination "
721 "expressions is not the same as "
722 "the preallocated buffer");
723 llvm::copy(DstExprs, getSourceExprs().end());
726void OMPCopyprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
727 assert(AssignmentOps.size() == varlist_size() &&
728 "Number of assignment expressions is not the same as the preallocated "
730 llvm::copy(AssignmentOps, getDestinationExprs().end());
737 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
738 OMPCopyprivateClause *Clause =
739 new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
740 Clause->setVarRefs(VL);
741 Clause->setSourceExprs(SrcExprs);
742 Clause->setDestinationExprs(DstExprs);
743 Clause->setAssignmentOps(AssignmentOps);
749 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
750 return new (Mem) OMPCopyprivateClause(N);
754 assert(
Privates.size() == varlist_size() &&
755 "Number of private copies is not the same as the preallocated buffer");
756 llvm::copy(
Privates, varlist_end());
761 LHSExprs.size() == varlist_size() &&
762 "Number of LHS expressions is not the same as the preallocated buffer");
768 RHSExprs.size() == varlist_size() &&
769 "Number of RHS expressions is not the same as the preallocated buffer");
770 llvm::copy(RHSExprs, getLHSExprs().end());
774 assert(ReductionOps.size() == varlist_size() &&
"Number of reduction "
775 "expressions is not the same "
776 "as the preallocated buffer");
777 llvm::copy(ReductionOps, getRHSExprs().end());
781 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
782 assert(Ops.size() == varlist_size() &&
"Number of copy "
783 "expressions is not the same "
784 "as the preallocated buffer");
785 llvm::copy(Ops, getReductionOps().end());
788void OMPReductionClause::setInscanCopyArrayTemps(
790 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
791 assert(CopyArrayTemps.size() == varlist_size() &&
792 "Number of copy temp expressions is not the same as the preallocated "
794 llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
797void OMPReductionClause::setInscanCopyArrayElems(
799 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
800 assert(CopyArrayElems.size() == varlist_size() &&
801 "Number of copy temp expressions is not the same as the preallocated "
803 llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
806OMPReductionClause *OMPReductionClause::Create(
817 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
818 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size(), VL.size()));
819 auto *Clause =
new (Mem) OMPReductionClause(
820 StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc, Modifier,
821 OrignalSharingModifier, VL.size(), QualifierLoc, NameInfo);
822 Clause->setVarRefs(VL);
824 Clause->setLHSExprs(LHSExprs);
825 Clause->setRHSExprs(RHSExprs);
826 Clause->setReductionOps(ReductionOps);
827 Clause->setPreInitStmt(PreInit);
828 Clause->setPostUpdateExpr(PostUpdate);
829 Clause->setPrivateVariableReductionFlags(IsPrivateVarReduction);
830 if (Modifier == OMPC_REDUCTION_inscan) {
831 Clause->setInscanCopyOps(CopyOps);
832 Clause->setInscanCopyArrayTemps(CopyArrayTemps);
833 Clause->setInscanCopyArrayElems(CopyArrayElems);
835 assert(CopyOps.empty() &&
836 "copy operations are expected in inscan reductions only.");
837 assert(CopyArrayTemps.empty() &&
838 "copy array temps are expected in inscan reductions only.");
839 assert(CopyArrayElems.empty() &&
840 "copy array temps are expected in inscan reductions only.");
846OMPReductionClause::CreateEmpty(
const ASTContext &
C,
unsigned N,
848 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, bool>(
849 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N, N));
850 auto *Clause =
new (Mem) OMPReductionClause(N);
851 Clause->setModifier(Modifier);
856 assert(
Privates.size() == varlist_size() &&
857 "Number of private copies is not the same as the preallocated buffer");
858 llvm::copy(
Privates, varlist_end());
863 LHSExprs.size() == varlist_size() &&
864 "Number of LHS expressions is not the same as the preallocated buffer");
870 RHSExprs.size() == varlist_size() &&
871 "Number of RHS expressions is not the same as the preallocated buffer");
872 llvm::copy(RHSExprs, getLHSExprs().end());
875void OMPTaskReductionClause::setReductionOps(
ArrayRef<Expr *> ReductionOps) {
876 assert(ReductionOps.size() == varlist_size() &&
"Number of task reduction "
877 "expressions is not the same "
878 "as the preallocated buffer");
879 llvm::copy(ReductionOps, getRHSExprs().end());
882OMPTaskReductionClause *OMPTaskReductionClause::Create(
889 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
890 OMPTaskReductionClause *Clause =
new (Mem) OMPTaskReductionClause(
891 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
892 Clause->setVarRefs(VL);
894 Clause->setLHSExprs(LHSExprs);
895 Clause->setRHSExprs(RHSExprs);
896 Clause->setReductionOps(ReductionOps);
897 Clause->setPreInitStmt(PreInit);
898 Clause->setPostUpdateExpr(PostUpdate);
902OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(
const ASTContext &
C,
904 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
905 return new (Mem) OMPTaskReductionClause(N);
909 assert(
Privates.size() == varlist_size() &&
910 "Number of private copies is not the same as the preallocated buffer");
911 llvm::copy(
Privates, varlist_end());
916 LHSExprs.size() == varlist_size() &&
917 "Number of LHS expressions is not the same as the preallocated buffer");
923 RHSExprs.size() == varlist_size() &&
924 "Number of RHS expressions is not the same as the preallocated buffer");
925 llvm::copy(RHSExprs, getLHSExprs().end());
929 assert(ReductionOps.size() == varlist_size() &&
"Number of in reduction "
930 "expressions is not the same "
931 "as the preallocated buffer");
932 llvm::copy(ReductionOps, getRHSExprs().end());
935void OMPInReductionClause::setTaskgroupDescriptors(
937 assert(TaskgroupDescriptors.size() == varlist_size() &&
938 "Number of in reduction descriptors is not the same as the "
939 "preallocated buffer");
940 llvm::copy(TaskgroupDescriptors, getReductionOps().end());
943OMPInReductionClause *OMPInReductionClause::Create(
950 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
951 OMPInReductionClause *Clause =
new (Mem) OMPInReductionClause(
952 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
953 Clause->setVarRefs(VL);
955 Clause->setLHSExprs(LHSExprs);
956 Clause->setRHSExprs(RHSExprs);
957 Clause->setReductionOps(ReductionOps);
958 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
959 Clause->setPreInitStmt(PreInit);
960 Clause->setPostUpdateExpr(PostUpdate);
964OMPInReductionClause *OMPInReductionClause::CreateEmpty(
const ASTContext &
C,
966 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
967 return new (Mem) OMPInReductionClause(N);
976 Clause->setLocStart(StartLoc);
977 Clause->setLParenLoc(LParenLoc);
978 Clause->setLocEnd(EndLoc);
979 Clause->setSizesRefs(Sizes);
985 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
986 return new (Mem) OMPSizesClause(NumSizes);
994 OMPPermutationClause *Clause =
CreateEmpty(
C, Args.size());
995 Clause->setLocStart(StartLoc);
996 Clause->setLParenLoc(LParenLoc);
997 Clause->setLocEnd(EndLoc);
998 Clause->setArgRefs(Args);
1003 unsigned NumLoops) {
1004 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumLoops));
1005 return new (Mem) OMPPermutationClause(NumLoops);
1012 Clause->setLocStart(StartLoc);
1013 Clause->setLocEnd(EndLoc);
1018 return new (
C) OMPFullClause();
1027 Clause->setLocStart(StartLoc);
1028 Clause->setLParenLoc(LParenLoc);
1029 Clause->setLocEnd(EndLoc);
1030 Clause->setFactor(Factor);
1035 return new (
C) OMPPartialClause();
1044 Clause->setLocStart(StartLoc);
1045 Clause->setLParenLoc(LParenLoc);
1046 Clause->setFirstLoc(FirstLoc);
1047 Clause->setCountLoc(CountLoc);
1048 Clause->setLocEnd(EndLoc);
1049 Clause->setFirst(
First);
1050 Clause->setCount(Count);
1055 return new (
C) OMPLoopRangeClause();
1066 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1067 auto *Clause =
new (Mem) OMPAllocateClause(
1068 StartLoc, LParenLoc, Allocator, Alignment, ColonLoc, Modifier1,
1069 Modifier1Loc, Modifier2, Modifier2Loc, EndLoc, VL.size());
1071 Clause->setVarRefs(VL);
1077 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1078 return new (Mem) OMPAllocateClause(N);
1086 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
1087 OMPFlushClause *Clause =
1088 new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1089 Clause->setVarRefs(VL);
1094 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1095 return new (Mem) OMPFlushClause(N);
1103 auto *Clause =
new (
C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
1104 Clause->setDepobj(Depobj);
1109 return new (
C) OMPDepobjClause();
1117 void *Mem =
C.Allocate(
1118 totalSizeToAlloc<Expr *>(VL.size() + 1 + NumLoops),
1119 alignof(OMPDependClause));
1120 OMPDependClause *Clause =
new (Mem)
1121 OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1122 Clause->setDependencyKind(Data.DepKind);
1123 Clause->setDependencyLoc(Data.DepLoc);
1124 Clause->setColonLoc(Data.ColonLoc);
1125 Clause->setOmpAllMemoryLoc(Data.OmpAllMemoryLoc);
1126 Clause->setModifier(DepModifier);
1127 Clause->setVarRefs(VL);
1128 for (
unsigned I = 0 ; I < NumLoops; ++I)
1129 Clause->setLoopData(I,
nullptr);
1134 unsigned NumLoops) {
1136 C.Allocate(totalSizeToAlloc<Expr *>(N + 1 + NumLoops),
1137 alignof(OMPDependClause));
1138 return new (Mem) OMPDependClause(N, NumLoops);
1144 NumLoop < NumLoops &&
1145 "Expected sink or source depend + loop index must be less number of "
1147 auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1154 NumLoop < NumLoops &&
1155 "Expected sink or source depend + loop index must be less number of "
1157 auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1164 NumLoop < NumLoops &&
1165 "Expected sink or source depend + loop index must be less number of "
1167 const auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1171void OMPDependClause::setModifier(
Expr *DepModifier) {
1172 *getVarRefs().end() = DepModifier;
1178 unsigned TotalNum = 0u;
1179 for (
auto &
C : ComponentLists)
1180 TotalNum +=
C.size();
1187 for (
const ValueDecl *D : Declarations) {
1189 UniqueDecls.insert(VD);
1191 return UniqueDecls.size();
1197 "Cannot get element-type from array-shaping expr.");
1211 if (
const auto *ATy = BaseType->getAsArrayTypeUnsafe())
1212 ElemTy = ATy->getElementType();
1220std::pair<const Expr *, std::optional<size_t>>
1226 if (Components.size() < 2)
1227 return {
nullptr, std::nullopt};
1232 if (Components.back().isNonContiguous() && CurDirKind == OMPD_target_update)
1233 return {
nullptr, std::nullopt};
1239 for (
auto [I, Component] : llvm::enumerate(Components)) {
1244 const Expr *CurExpr = Component.getAssociatedExpression();
1259 return {CurExpr, Components.size() - I};
1262 return {
nullptr, std::nullopt};
1289 void *Mem =
C.Allocate(
1295 OMPMapClause *Clause =
new (Mem)
1296 OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1299 Clause->setVarRefs(Vars);
1300 Clause->setUDMapperRefs(UDMapperRefs);
1301 Clause->setIteratorModifier(IteratorModifier);
1302 Clause->setClauseInfo(Declarations, ComponentLists);
1303 Clause->setMapType(
Type);
1311 void *Mem =
C.Allocate(
1317 OMPMapClause *Clause =
new (Mem) OMPMapClause(Sizes);
1318 Clause->setIteratorModifier(
nullptr);
1345 void *Mem =
C.Allocate(
1352 auto *Clause =
new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc,
1353 UDMQualifierLoc, MapperId, Locs, Sizes);
1355 Clause->setVarRefs(Vars);
1356 Clause->setUDMapperRefs(UDMapperRefs);
1357 Clause->setClauseInfo(Declarations, ComponentLists);
1358 Clause->setIteratorModifier(IteratorModifier);
1364 void *Mem =
C.Allocate(
1370 OMPToClause *Clause =
new (Mem) OMPToClause(Sizes);
1371 Clause->setIteratorModifier(
nullptr);
1398 void *Mem =
C.Allocate(
1406 new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc,
1407 UDMQualifierLoc, MapperId, Locs, Sizes);
1409 Clause->setVarRefs(Vars);
1410 Clause->setUDMapperRefs(UDMapperRefs);
1411 Clause->setClauseInfo(Declarations, ComponentLists);
1412 Clause->setIteratorModifier(IteratorModifier);
1419 void *Mem =
C.Allocate(
1425 OMPFromClause *Clause =
new (Mem) OMPFromClause(Sizes);
1426 Clause->setIteratorModifier(
nullptr);
1431 assert(VL.size() == varlist_size() &&
1432 "Number of private copies is not the same as the preallocated buffer");
1433 llvm::copy(VL, varlist_end());
1437 assert(VL.size() == varlist_size() &&
1438 "Number of inits is not the same as the preallocated buffer");
1439 llvm::copy(VL, getPrivateCopies().end());
1465 void *Mem =
C.Allocate(
1472 OMPUseDevicePtrClause *Clause =
new (Mem)
1473 OMPUseDevicePtrClause(Locs, Sizes, FallbackModifier, FallbackModifierLoc);
1475 Clause->setVarRefs(Vars);
1476 Clause->setPrivateCopies(PrivateVars);
1477 Clause->setInits(
Inits);
1478 Clause->setClauseInfo(Declarations, ComponentLists);
1485 void *Mem =
C.Allocate(
1491 return new (Mem) OMPUseDevicePtrClause(Sizes);
1515 void *Mem =
C.Allocate(
1522 auto *Clause =
new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
1524 Clause->setVarRefs(Vars);
1525 Clause->setClauseInfo(Declarations, ComponentLists);
1532 void *Mem =
C.Allocate(
1538 return new (Mem) OMPUseDeviceAddrClause(Sizes);
1562 void *Mem =
C.Allocate(
1569 OMPIsDevicePtrClause *Clause =
new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1571 Clause->setVarRefs(Vars);
1572 Clause->setClauseInfo(Declarations, ComponentLists);
1579 void *Mem =
C.Allocate(
1585 return new (Mem) OMPIsDevicePtrClause(Sizes);
1609 void *Mem =
C.Allocate(
1616 auto *Clause =
new (Mem) OMPHasDeviceAddrClause(Locs, Sizes);
1618 Clause->setVarRefs(Vars);
1619 Clause->setClauseInfo(Declarations, ComponentLists);
1626 void *Mem =
C.Allocate(
1632 return new (Mem) OMPHasDeviceAddrClause(Sizes);
1641 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1643 new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
1644 Clause->setVarRefs(VL);
1650 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1651 return new (Mem) OMPNontemporalClause(N);
1655 assert(VL.size() == varlist_size() &&
"Number of private references is not "
1656 "the same as the preallocated buffer");
1657 llvm::copy(VL, varlist_end());
1665 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1667 new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1668 Clause->setVarRefs(VL);
1674 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1675 return new (Mem) OMPInclusiveClause(N);
1683 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1685 new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1686 Clause->setVarRefs(VL);
1692 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1693 return new (Mem) OMPExclusiveClause(N);
1696void OMPUsesAllocatorsClause::setAllocatorsData(
1698 assert(
Data.size() == NumOfAllocators &&
1699 "Size of allocators data is not the same as the preallocated buffer.");
1700 for (
unsigned I = 0, E =
Data.size(); I < E; ++I) {
1702 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1703 static_cast<int>(ExprOffsets::Allocator)] =
1705 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1707 ExprOffsets::AllocatorTraits)] =
1710 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1711 static_cast<int>(ParenLocsOffsets::LParen)] =
1714 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1715 static_cast<int>(ParenLocsOffsets::RParen)] =
1720OMPUsesAllocatorsClause::Data
1724 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1725 static_cast<int>(ExprOffsets::Allocator)];
1727 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1729 ExprOffsets::AllocatorTraits)];
1731 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1732 static_cast<int>(ParenLocsOffsets::LParen)];
1734 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1735 static_cast<int>(ParenLocsOffsets::RParen)];
1743 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1744 static_cast<int>(ExprOffsets::Total) *
Data.size(),
1745 static_cast<int>(ParenLocsOffsets::Total) *
Data.size()));
1746 auto *Clause =
new (Mem)
1747 OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc,
Data.size());
1748 Clause->setAllocatorsData(
Data);
1754 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1755 static_cast<int>(ExprOffsets::Total) * N,
1756 static_cast<int>(ParenLocsOffsets::Total) * N));
1757 return new (Mem) OMPUsesAllocatorsClause(N);
1765 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1766 auto *Clause =
new (Mem)
1767 OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
1768 Clause->setModifier(Modifier);
1769 Clause->setVarRefs(Locators);
1775 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1776 return new (Mem) OMPAffinityClause(N);
1787 C.Allocate(totalSizeToAlloc<Expr *>(InteropInfo.
PreferTypes.size() + 1));
1788 auto *Clause =
new (Mem) OMPInitClause(
1790 VarLoc, EndLoc, InteropInfo.
PreferTypes.size() + 1);
1791 Clause->setInteropVar(InteropVar);
1792 llvm::copy(InteropInfo.
PreferTypes, Clause->getTrailingObjects() + 1);
1797 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1798 return new (Mem) OMPInitClause(N);
1805 return new (
C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
1809 return new (
C) OMPBindClause();
1818 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops),
1819 alignof(OMPDoacrossClause));
1820 OMPDoacrossClause *Clause =
new (Mem)
1821 OMPDoacrossClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
1822 Clause->setDependenceType(DepType);
1823 Clause->setDependenceLoc(DepLoc);
1824 Clause->setColonLoc(ColonLoc);
1825 Clause->setVarRefs(VL);
1826 for (
unsigned I = 0; I < NumLoops; ++I)
1827 Clause->setLoopData(I,
nullptr);
1833 unsigned NumLoops) {
1834 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops),
1835 alignof(OMPDoacrossClause));
1836 return new (Mem) OMPDoacrossClause(N, NumLoops);
1840 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1841 auto *It = std::next(getVarRefs().end(), NumLoop);
1846 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1847 auto *It = std::next(getVarRefs().end(), NumLoop);
1852 assert(NumLoop < NumLoops &&
"Loop index must be less number of loops.");
1853 const auto *It = std::next(getVarRefs().end(), NumLoop);
1857OMPAbsentClause *OMPAbsentClause::Create(
const ASTContext &
C,
1862 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1863 alignof(OMPAbsentClause));
1864 auto *AC =
new (Mem) OMPAbsentClause(Loc, LLoc, RLoc, DKVec.size());
1865 AC->setDirectiveKinds(DKVec);
1869OMPAbsentClause *OMPAbsentClause::CreateEmpty(
const ASTContext &
C,
unsigned K) {
1870 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1871 alignof(OMPAbsentClause));
1872 return new (Mem) OMPAbsentClause(K);
1875OMPContainsClause *OMPContainsClause::Create(
1878 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(DKVec.size()),
1879 alignof(OMPContainsClause));
1880 auto *CC =
new (Mem) OMPContainsClause(Loc, LLoc, RLoc, DKVec.size());
1881 CC->setDirectiveKinds(DKVec);
1885OMPContainsClause *OMPContainsClause::CreateEmpty(
const ASTContext &
C,
1887 void *Mem =
C.Allocate(totalSizeToAlloc<OpenMPDirectiveKind>(K),
1888 alignof(OMPContainsClause));
1889 return new (Mem) OMPContainsClause(K);
1896 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1897 OMPNumTeamsClause *Clause =
1898 new (Mem) OMPNumTeamsClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1899 Clause->setVarRefs(VL);
1900 Clause->setPreInitStmt(PreInit, CaptureRegion);
1906 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1907 return new (Mem) OMPNumTeamsClause(N);
1914 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1915 OMPThreadLimitClause *Clause =
1916 new (Mem) OMPThreadLimitClause(
C, StartLoc, LParenLoc, EndLoc, VL.size());
1917 Clause->setVarRefs(VL);
1918 Clause->setPreInitStmt(PreInit, CaptureRegion);
1924 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1925 return new (Mem) OMPThreadLimitClause(N);
1932void OMPClausePrinter::VisitOMPIfClause(
OMPIfClause *Node) {
1935 OS << getOpenMPDirectiveName(Node->
getNameModifier(), Version) <<
": ";
1940void OMPClausePrinter::VisitOMPFinalClause(
OMPFinalClause *Node) {
1947 OS <<
"num_threads(";
1957void OMPClausePrinter::VisitOMPAlignClause(
OMPAlignClause *Node) {
1975void OMPClausePrinter::VisitOMPSizesClause(
OMPSizesClause *Node) {
1981 Size->printPretty(OS,
nullptr, Policy, 0);
1988 OS <<
"permutation(";
1990 E->printPretty(OS, nullptr, Policy, 0);
1995void OMPClausePrinter::VisitOMPFullClause(
OMPFullClause *Node) {
OS <<
"full"; }
2002 Factor->printPretty(OS,
nullptr, Policy, 0);
2013 if (
First && Count) {
2015 First->printPretty(OS,
nullptr, Policy, 0);
2034void OMPClausePrinter::VisitOMPDetachClause(OMPDetachClause *Node) {
2044 if (Version >= 60 && Node->
getDefaultVC() != OMPC_DEFAULT_VC_all) {
2059void OMPClausePrinter::VisitOMPTransparentClause(OMPTransparentClause *Node) {
2060 OS <<
"transparent(";
2061 if (Node->getImpexType())
2062 Node->getImpexType()->printPretty(OS,
nullptr, Policy, 0);
2068void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
2071 unsigned(Node->getProcBindKind()))
2075void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
2076 OS <<
"unified_address";
2079void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
2080 OMPUnifiedSharedMemoryClause *) {
2081 OS <<
"unified_shared_memory";
2084void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
2085 OS <<
"reverse_offload";
2088void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
2089 OMPDynamicAllocatorsClause *) {
2090 OS <<
"dynamic_allocators";
2093void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
2094 OMPAtomicDefaultMemOrderClause *Node) {
2095 OS <<
"atomic_default_mem_order("
2097 Node->getAtomicDefaultMemOrderKind())
2101void OMPClausePrinter::VisitOMPSelfMapsClause(OMPSelfMapsClause *) {
2105void OMPClausePrinter::VisitOMPAtClause(OMPAtClause *Node) {
2110void OMPClausePrinter::VisitOMPSeverityClause(OMPSeverityClause *Node) {
2116void OMPClausePrinter::VisitOMPMessageClause(OMPMessageClause *Node) {
2118 if (
Expr *E = Node->getMessageString())
2119 E->printPretty(OS,
nullptr, Policy);
2123void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
2127 Node->getFirstScheduleModifier());
2131 Node->getSecondScheduleModifier());
2136 if (
auto *E = Node->getChunkSize()) {
2138 E->printPretty(OS,
nullptr, Policy);
2143void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
2145 if (
auto *
Num = Node->getNumForLoops()) {
2147 Num->printPretty(OS,
nullptr, Policy, 0);
2152void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *Node) {
2154 if (
auto *
Cond = Node->getCondition()) {
2156 Cond->printPretty(OS,
nullptr, Policy, 0);
2161void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
2165void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
2169void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
2173void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) {
OS <<
"read"; }
2175void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) {
OS <<
"write"; }
2177void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *Node) {
2179 if (Node->isExtended()) {
2182 Node->getDependencyKind());
2187void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
2191void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) {
2195void OMPClausePrinter::VisitOMPFailClause(OMPFailClause *Node) {
2200 Node->getClauseKind(),
static_cast<int>(Node->getFailParameter()));
2205void OMPClausePrinter::VisitOMPAbsentClause(OMPAbsentClause *Node) {
2208 for (
auto &D : Node->getDirectiveKinds()) {
2211 OS << getOpenMPDirectiveName(D, Version);
2217void OMPClausePrinter::VisitOMPHoldsClause(OMPHoldsClause *Node) {
2219 Node->getExpr()->printPretty(OS,
nullptr, Policy, 0);
2223void OMPClausePrinter::VisitOMPContainsClause(OMPContainsClause *Node) {
2226 for (
auto &D : Node->getDirectiveKinds()) {
2229 OS << getOpenMPDirectiveName(D, Version);
2235void OMPClausePrinter::VisitOMPNoOpenMPClause(OMPNoOpenMPClause *) {
2239void OMPClausePrinter::VisitOMPNoOpenMPRoutinesClause(
2240 OMPNoOpenMPRoutinesClause *) {
2241 OS <<
"no_openmp_routines";
2244void OMPClausePrinter::VisitOMPNoOpenMPConstructsClause(
2245 OMPNoOpenMPConstructsClause *) {
2246 OS <<
"no_openmp_constructs";
2249void OMPClausePrinter::VisitOMPNoParallelismClause(OMPNoParallelismClause *) {
2250 OS <<
"no_parallelism";
2253void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
2257void OMPClausePrinter::VisitOMPAcqRelClause(OMPAcqRelClause *) {
2261void OMPClausePrinter::VisitOMPAcquireClause(OMPAcquireClause *) {
2265void OMPClausePrinter::VisitOMPReleaseClause(OMPReleaseClause *) {
2269void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) {
2273void OMPClausePrinter::VisitOMPWeakClause(OMPWeakClause *) {
OS <<
"weak"; }
2275void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
2279void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) {
OS <<
"simd"; }
2281void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
2292void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
2293 if (!Node->varlist_empty()) {
2297 if (Node->varlist_size() == 2) {
2299 Node->varlist(), OS,
2300 [&](
const auto *
Expr) { Expr->printPretty(OS, nullptr, Policy, 0); },
2304 llvm::interleaveComma(Node->varlist(), OS, [&](
const auto *
Expr) {
2305 Expr->printPretty(OS, nullptr, Policy, 0);
2312void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
2313 if (!Node->varlist_empty()) {
2314 OS <<
"thread_limit";
2315 VisitOMPClauseList(Node,
'(');
2320void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
2326void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
2337void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
2348void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
2354void OMPClausePrinter::VisitOMPInitClause(OMPInitClause *Node) {
2359 OS <<
"prefer_type(";
2362 E->printPretty(OS,
nullptr, Policy);
2379void OMPClausePrinter::VisitOMPUseClause(OMPUseClause *Node) {
2385void OMPClausePrinter::VisitOMPDestroyClause(OMPDestroyClause *Node) {
2389 E->printPretty(OS,
nullptr, Policy);
2394void OMPClausePrinter::VisitOMPNovariantsClause(OMPNovariantsClause *Node) {
2398 E->printPretty(OS,
nullptr, Policy, 0);
2403void OMPClausePrinter::VisitOMPNocontextClause(OMPNocontextClause *Node) {
2407 E->printPretty(OS,
nullptr, Policy, 0);
2413void OMPClausePrinter::VisitOMPClauseList(T *Node,
char StartSym) {
2414 for (
typename T::varlist_iterator I = Node->varlist_begin(),
2415 E = Node->varlist_end();
2417 assert(*I &&
"Expected non-null Stmt");
2418 OS << (I == Node->varlist_begin() ? StartSym :
',');
2419 if (
auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
2421 DRE->printPretty(OS,
nullptr, Policy, 0);
2423 DRE->getDecl()->printQualifiedName(OS);
2425 (*I)->printPretty(OS,
nullptr, Policy, 0);
2433 Expr *FirstModifier =
nullptr;
2434 Expr *SecondModifier =
nullptr;
2439 if (FirstAllocMod == OMPC_ALLOCATE_allocator ||
2450 if (FirstModifier) {
2452 if (!FirstUnknown) {
2456 FirstModifier->
printPretty(OS,
nullptr, Policy, 0);
2459 if (SecondModifier) {
2461 if (!SecondUnknown) {
2466 SecondModifier->
printPretty(OS,
nullptr, Policy, 0);
2471 VisitOMPClauseList(Node,
' ');
2474 VisitOMPClauseList(Node,
'(');
2479void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
2480 if (!Node->varlist_empty()) {
2482 VisitOMPClauseList(Node,
'(');
2487void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
2488 if (!Node->varlist_empty()) {
2489 OS <<
"firstprivate";
2490 VisitOMPClauseList(Node,
'(');
2495void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
2496 if (!Node->varlist_empty()) {
2497 OS <<
"lastprivate";
2509void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
2510 if (!Node->varlist_empty()) {
2512 VisitOMPClauseList(Node,
'(');
2517void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
2518 if (!Node->varlist_empty()) {
2520 if (Node->getModifierLoc().isValid())
2524 Node->getQualifierLoc().getNestedNameSpecifier();
2526 Node->getNameInfo().getName().getCXXOverloadedOperator();
2527 if (!Qualifier && OOK !=
OO_None) {
2533 OS << Node->getNameInfo();
2536 VisitOMPClauseList(Node,
' ');
2541void OMPClausePrinter::VisitOMPTaskReductionClause(
2542 OMPTaskReductionClause *Node) {
2543 if (!Node->varlist_empty()) {
2544 OS <<
"task_reduction(";
2546 Node->getQualifierLoc().getNestedNameSpecifier();
2548 Node->getNameInfo().getName().getCXXOverloadedOperator();
2549 if (!Qualifier && OOK !=
OO_None) {
2555 OS << Node->getNameInfo();
2558 VisitOMPClauseList(Node,
' ');
2563void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
2564 if (!Node->varlist_empty()) {
2565 OS <<
"in_reduction(";
2567 Node->getQualifierLoc().getNestedNameSpecifier();
2569 Node->getNameInfo().getName().getCXXOverloadedOperator();
2570 if (!Qualifier && OOK !=
OO_None) {
2576 OS << Node->getNameInfo();
2579 VisitOMPClauseList(Node,
' ');
2584void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
2585 if (!Node->varlist_empty()) {
2587 VisitOMPClauseList(Node,
'(');
2588 if (Node->getModifierLoc().isValid() || Node->getStep() !=
nullptr) {
2591 if (Node->getModifierLoc().isValid()) {
2594 if (Node->getStep() !=
nullptr) {
2595 if (Node->getModifierLoc().isValid()) {
2599 Node->getStep()->printPretty(OS,
nullptr, Policy, 0);
2606void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
2607 if (!Node->varlist_empty()) {
2609 VisitOMPClauseList(Node,
'(');
2618void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
2619 if (!Node->varlist_empty()) {
2621 VisitOMPClauseList(Node,
'(');
2626void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
2627 if (!Node->varlist_empty()) {
2628 OS <<
"copyprivate";
2629 VisitOMPClauseList(Node,
'(');
2634void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
2635 if (!Node->varlist_empty()) {
2636 VisitOMPClauseList(Node,
'(');
2641void OMPClausePrinter::VisitOMPDepobjClause(OMPDepobjClause *Node) {
2647void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
2655 bool IsOmpAllMemory =
false;
2656 if (PrintKind == OMPC_DEPEND_outallmemory) {
2657 PrintKind = OMPC_DEPEND_out;
2658 IsOmpAllMemory =
true;
2659 }
else if (PrintKind == OMPC_DEPEND_inoutallmemory) {
2660 PrintKind = OMPC_DEPEND_inout;
2661 IsOmpAllMemory =
true;
2664 if (!Node->varlist_empty() || IsOmpAllMemory)
2666 VisitOMPClauseList(Node,
' ');
2667 if (IsOmpAllMemory) {
2668 OS << (Node->varlist_empty() ?
" " :
",");
2669 OS <<
"omp_all_memory";
2674template <
typename T>
2679 Node->getMapperQualifierLoc().getNestedNameSpecifier();
2680 MapperNNS.
print(OS, Policy);
2681 OS << Node->getMapperIdInfo() <<
')';
2684template <
typename T>
2687 if (
Expr *IteratorModifier = Node->getIteratorModifier())
2688 IteratorModifier->printPretty(OS,
nullptr, Policy);
2691void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
2692 if (!Node->varlist_empty()) {
2711 VisitOMPClauseList(Node,
' ');
2716template <
typename T>
void OMPClausePrinter::VisitOMPMotionClause(T *Node) {
2717 if (Node->varlist_empty())
2719 OS << getOpenMPClauseName(Node->getClauseKind());
2720 unsigned ModifierCount = 0;
2725 if (ModifierCount) {
2729 if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_iterator) {
2733 Node->getMotionModifier(I));
2734 if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2736 if (I < ModifierCount - 1)
2742 VisitOMPClauseList(Node,
' ');
2744 VisitOMPClauseList(Node,
'(');
2749void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
2750 VisitOMPMotionClause(Node);
2753void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
2754 VisitOMPMotionClause(Node);
2757void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
2762 E->printPretty(OS,
nullptr, Policy);
2767void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
2768 OS <<
"defaultmap(";
2779void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
2780 if (!Node->varlist_empty()) {
2781 OS <<
"use_device_ptr";
2787 VisitOMPClauseList(Node,
' ');
2789 VisitOMPClauseList(Node,
'(');
2795void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2796 OMPUseDeviceAddrClause *Node) {
2797 if (!Node->varlist_empty()) {
2798 OS <<
"use_device_addr";
2799 VisitOMPClauseList(Node,
'(');
2804void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
2805 if (!Node->varlist_empty()) {
2806 OS <<
"is_device_ptr";
2807 VisitOMPClauseList(Node,
'(');
2812void OMPClausePrinter::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *Node) {
2813 if (!Node->varlist_empty()) {
2814 OS <<
"has_device_addr";
2815 VisitOMPClauseList(Node,
'(');
2820void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) {
2821 if (!Node->varlist_empty()) {
2822 OS <<
"nontemporal";
2823 VisitOMPClauseList(Node,
'(');
2828void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) {
2837void OMPClausePrinter::VisitOMPInclusiveClause(OMPInclusiveClause *Node) {
2838 if (!Node->varlist_empty()) {
2840 VisitOMPClauseList(Node,
'(');
2845void OMPClausePrinter::VisitOMPExclusiveClause(OMPExclusiveClause *Node) {
2846 if (!Node->varlist_empty()) {
2848 VisitOMPClauseList(Node,
'(');
2853void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2854 OMPUsesAllocatorsClause *Node) {
2857 OS <<
"uses_allocators(";
2860 Data.Allocator->printPretty(OS,
nullptr, Policy);
2861 if (
Data.AllocatorTraits) {
2863 Data.AllocatorTraits->printPretty(OS,
nullptr, Policy);
2872void OMPClausePrinter::VisitOMPAffinityClause(OMPAffinityClause *Node) {
2873 if (Node->varlist_empty())
2876 char StartSym =
'(';
2879 Modifier->printPretty(OS,
nullptr, Policy);
2883 VisitOMPClauseList(Node, StartSym);
2887void OMPClausePrinter::VisitOMPFilterClause(OMPFilterClause *Node) {
2893void OMPClausePrinter::VisitOMPBindClause(OMPBindClause *Node) {
2899void OMPClausePrinter::VisitOMPXDynCGroupMemClause(
2900 OMPXDynCGroupMemClause *Node) {
2901 OS <<
"ompx_dyn_cgroup_mem(";
2906void OMPClausePrinter::VisitOMPDynGroupprivateClause(
2907 OMPDynGroupprivateClause *Node) {
2908 OS <<
"dyn_groupprivate(";
2924void OMPClausePrinter::VisitOMPDoacrossClause(OMPDoacrossClause *Node) {
2929 case OMPC_DOACROSS_source:
2932 case OMPC_DOACROSS_sink:
2935 case OMPC_DOACROSS_source_omp_cur_iteration:
2936 OS <<
"source: omp_cur_iteration";
2938 case OMPC_DOACROSS_sink_omp_cur_iteration:
2939 OS <<
"sink: omp_cur_iteration - 1";
2942 llvm_unreachable(
"unknown docaross modifier");
2944 VisitOMPClauseList(Node,
' ');
2948void OMPClausePrinter::VisitOMPXAttributeClause(OMPXAttributeClause *Node) {
2949 OS <<
"ompx_attribute(";
2960void OMPClausePrinter::VisitOMPXBareClause(OMPXBareClause *Node) {
2965 VariantMatchInfo &VMI)
const {
2970 if (
Selector.Kind == TraitSelector::user_condition) {
2971 assert(
Selector.ScoreOrCondition &&
2972 "Ill-formed user condition, expected condition expression!");
2973 assert(
Selector.Properties.size() == 1 &&
2974 Selector.Properties.front().Kind ==
2975 TraitProperty::user_condition_unknown &&
2976 "Ill-formed user condition, expected unknown trait property!");
2978 if (std::optional<APSInt> CondVal =
2979 Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2980 VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
2981 : TraitProperty::user_condition_true,
2984 VMI.addTrait(TraitProperty::user_condition_false,
"<condition>");
2988 std::optional<llvm::APSInt> Score;
2989 llvm::APInt *ScorePtr =
nullptr;
2991 if ((Score =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
2994 VMI.addTrait(TraitProperty::user_condition_false,
2995 "<non-constant-score>");
2999 VMI.addTrait(
Set.Kind, Property.Kind, Property.RawString, ScorePtr);
3001 if (
Set.Kind != TraitSet::construct)
3005 assert(
Selector.Properties.size() == 1 &&
3006 Selector.Properties.front().Kind ==
3007 getOpenMPContextTraitPropertyForSelector(
3009 "Ill-formed construct selector!");
3016 bool FirstSet =
true;
3021 OS << getOpenMPContextTraitSetName(
Set.Kind) <<
"={";
3023 bool FirstSelector =
true;
3027 FirstSelector =
false;
3028 OS << getOpenMPContextTraitSelectorName(
Selector.Kind);
3030 bool AllowsTraitScore =
false;
3031 bool RequiresProperty =
false;
3032 isValidTraitSelectorForTraitSet(
3033 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
3035 if (!RequiresProperty)
3039 if (
Selector.Kind == TraitSelector::user_condition) {
3041 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
3048 Selector.ScoreOrCondition->printPretty(OS,
nullptr, Policy);
3052 bool FirstProperty =
true;
3056 FirstProperty =
false;
3057 OS << getOpenMPContextTraitPropertyName(Property.Kind,
3058 Property.RawString);
3068 std::string MangledName;
3069 llvm::raw_string_ostream OS(MangledName);
3074 bool AllowsTraitScore =
false;
3075 bool RequiresProperty =
false;
3076 isValidTraitSelectorForTraitSet(
3077 Selector.Kind,
Set.Kind, AllowsTraitScore, RequiresProperty);
3080 if (!RequiresProperty ||
3081 Selector.Kind == TraitSelector::user_condition)
3086 << getOpenMPContextTraitPropertyName(Property.Kind,
3087 Property.RawString);
3093OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
3096 if (!MangledName.consume_front(
"$S"))
3098 if (MangledName.consumeInteger(10,
U))
3102 Set.Kind = TraitSet(
U);
3104 if (!MangledName.consume_front(
"$s"))
3106 if (MangledName.consumeInteger(10,
U))
3112 if (!MangledName.consume_front(
"$P"))
3116 std::pair<StringRef, StringRef> PropRestPair = MangledName.split(
'$');
3117 Property.RawString = PropRestPair.first;
3118 Property.Kind = getOpenMPContextTraitPropertyKind(
3120 MangledName = MangledName.drop_front(PropRestPair.first.size());
3130 TI.
print(OS, Policy);
3135 return TI ? OS << *TI : OS;
3142 : OMPContext(ASTCtx.getLangOpts().OpenMPIsTargetDevice,
3144 ASTCtx.getLangOpts().OMPTargetTriples.empty()
3146 : ASTCtx.getLangOpts().OMPTargetTriples[0],
3148 FeatureValidityCheck([&](StringRef FeatureName) {
3149 return ASTCtx.
getTargetInfo().isValidFeatureName(FeatureName);
3151 DiagUnknownTrait(std::move(DiagUnknownTrait)) {
3154 for (llvm::omp::TraitProperty Property : ConstructTraits)
3159 auto It = FeatureMap.find(RawString);
3160 if (It != FeatureMap.end())
3162 if (!FeatureValidityCheck(RawString))
3163 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 StringRef getTriple(const Command &Job)
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.