21#include "llvm/ADT/SmallPtrSet.h"
22#include "llvm/Support/Casting.h"
23#include "llvm/Support/ErrorHandling.h"
36#define GEN_CLANG_CLAUSE_CLASS
37#define CLAUSE_CLASS(Enum, Str, Class) \
39 return static_cast<Class *>(this)->children();
40#include "llvm/Frontend/OpenMP/OMP.inc"
42 llvm_unreachable(
"unknown OMPClause");
47#define GEN_CLANG_CLAUSE_CLASS
48#define CLAUSE_CLASS(Enum, Str, Class) \
50 return static_cast<Class *>(this)->used_children();
51#define CLAUSE_NO_CLASS(Enum, Str) \
54#include "llvm/Frontend/OpenMP/OMP.inc"
56 llvm_unreachable(
"unknown OMPClause");
65 switch (
C->getClauseKind()) {
68 case OMPC_dist_schedule:
70 case OMPC_firstprivate:
72 case OMPC_lastprivate:
76 case OMPC_task_reduction:
78 case OMPC_in_reduction:
84 case OMPC_num_threads:
88 case OMPC_thread_limit:
100 case OMPC_novariants:
106 case OMPC_ompx_dyn_cgroup_mem:
120 case OMPC_copyprivate:
125 case OMPC_threadprivate:
144 case OMPC_defaultmap:
149 case OMPC_use_device_ptr:
150 case OMPC_use_device_addr:
151 case OMPC_is_device_ptr:
152 case OMPC_has_device_addr:
153 case OMPC_unified_address:
154 case OMPC_unified_shared_memory:
155 case OMPC_reverse_offload:
156 case OMPC_dynamic_allocators:
157 case OMPC_atomic_default_mem_order:
161 case OMPC_device_type:
163 case OMPC_nontemporal:
169 case OMPC_uses_allocators:
187 switch (
C->getClauseKind()) {
188 case OMPC_lastprivate:
192 case OMPC_task_reduction:
194 case OMPC_in_reduction:
199 case OMPC_dist_schedule:
200 case OMPC_firstprivate:
205 case OMPC_num_threads:
216 case OMPC_copyprivate:
221 case OMPC_threadprivate:
240 case OMPC_thread_limit:
246 case OMPC_defaultmap:
251 case OMPC_use_device_ptr:
252 case OMPC_use_device_addr:
253 case OMPC_is_device_ptr:
254 case OMPC_has_device_addr:
255 case OMPC_unified_address:
256 case OMPC_unified_shared_memory:
257 case OMPC_reverse_offload:
258 case OMPC_dynamic_allocators:
259 case OMPC_atomic_default_mem_order:
263 case OMPC_device_type:
265 case OMPC_nontemporal:
268 case OMPC_novariants:
273 case OMPC_uses_allocators:
290 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
291 assert(DS->isSingleDecl() &&
"Only single expression must be captured.");
292 if (
auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
293 return OED->getInitAddress();
345 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
348 for (
unsigned I = 0; I < NumLoops; ++I) {
350 Clause->setLoopCounter(I,
nullptr);
357 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
359 for (
unsigned I = 0; I < NumLoops; ++I) {
361 Clause->setLoopCounter(I,
nullptr);
367 Expr *NumIterations) {
368 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
369 getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
373 return llvm::ArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
377 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
378 getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
382 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
383 return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
387 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
388 return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
402 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
406 Clause->setLParenLoc(LParenLoc);
407 Clause->setArgumentLoc(ArgumentLoc);
408 Clause->setDependencyKind(DK);
417 C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
420 Clause->IsExtended =
true;
426 "Number of private copies is not the same as the preallocated buffer");
435 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
439 Clause->setPrivateCopies(PrivateVL);
445 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
451 "Number of private copies is not the same as the preallocated buffer");
457 "Number of inits is not the same as the preallocated buffer");
458 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
466 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
470 Clause->setPrivateCopies(PrivateVL);
471 Clause->setInits(InitVL);
478 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
484 "Number of private copies is not the same as the preallocated buffer");
485 std::copy(PrivateCopies.begin(), PrivateCopies.end(),
varlist_end());
489 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
490 "not the same as the "
491 "preallocated buffer");
492 std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
496 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
497 "expressions is not the same as "
498 "the preallocated buffer");
499 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
502void OMPLastprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
504 "Number of assignment expressions is not the same as the preallocated "
506 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
507 getDestinationExprs().end());
516 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
518 StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
520 Clause->setSourceExprs(SrcExprs);
521 Clause->setDestinationExprs(DstExprs);
522 Clause->setAssignmentOps(AssignmentOps);
530 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
539 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
547 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
553 "Number of privates is not the same as the preallocated buffer");
559 "Number of inits is not the same as the preallocated buffer");
560 std::copy(IL.begin(), IL.end(), getPrivates().end());
565 "Number of updates is not the same as the preallocated buffer");
566 std::copy(UL.begin(), UL.end(), getInits().end());
571 "Number of final updates is not the same as the preallocated buffer");
572 std::copy(FL.begin(), FL.end(), getUpdates().end());
578 "Number of used expressions is not the same as the preallocated buffer");
579 std::copy(UE.begin(), UE.end(), getFinals().end() + 2);
591 C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
593 StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
595 Clause->setPrivates(PL);
596 Clause->setInits(IL);
599 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
601 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
603 std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
605 Clause->setStep(Step);
606 Clause->setCalcStep(CalcStep);
616 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
623 reinterpret_cast<Stmt **
>(getUsedExprs().begin()),
624 reinterpret_cast<Stmt **
>(llvm::find(getUsedExprs(),
nullptr)));
631 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
635 Clause->setAlignment(A);
641 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
653 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
654 "not the same as the "
655 "preallocated buffer");
656 std::copy(SrcExprs.begin(), SrcExprs.end(),
varlist_end());
660 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
661 "expressions is not the same as "
662 "the preallocated buffer");
663 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
668 "Number of assignment expressions is not the same as the preallocated "
670 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
671 getDestinationExprs().end());
678 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
682 Clause->setSourceExprs(SrcExprs);
683 Clause->setDestinationExprs(DstExprs);
684 Clause->setAssignmentOps(AssignmentOps);
689 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
694 assert(SrcExprs.size() ==
varlist_size() &&
"Number of source expressions is "
695 "not the same as the "
696 "preallocated buffer");
697 std::copy(SrcExprs.begin(), SrcExprs.end(),
varlist_end());
701 assert(DstExprs.size() ==
varlist_size() &&
"Number of destination "
702 "expressions is not the same as "
703 "the preallocated buffer");
704 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
707void OMPCopyprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
709 "Number of assignment expressions is not the same as the preallocated "
711 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
712 getDestinationExprs().end());
719 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
723 Clause->setSourceExprs(SrcExprs);
724 Clause->setDestinationExprs(DstExprs);
725 Clause->setAssignmentOps(AssignmentOps);
731 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
737 "Number of private copies is not the same as the preallocated buffer");
738 std::copy(Privates.begin(), Privates.end(),
varlist_end());
744 "Number of LHS expressions is not the same as the preallocated buffer");
745 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
751 "Number of RHS expressions is not the same as the preallocated buffer");
752 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
756 assert(ReductionOps.size() ==
varlist_size() &&
"Number of reduction "
757 "expressions is not the same "
758 "as the preallocated buffer");
759 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
763 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
764 assert(Ops.size() ==
varlist_size() &&
"Number of copy "
765 "expressions is not the same "
766 "as the preallocated buffer");
767 llvm::copy(Ops, getReductionOps().end());
770void OMPReductionClause::setInscanCopyArrayTemps(
772 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
774 "Number of copy temp expressions is not the same as the preallocated "
776 llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
779void OMPReductionClause::setInscanCopyArrayElems(
781 assert(Modifier == OMPC_REDUCTION_inscan &&
"Expected inscan reduction.");
783 "Number of copy temp expressions is not the same as the preallocated "
785 llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
797 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(
798 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size()));
799 auto *Clause =
new (Mem)
801 Modifier, VL.size(), QualifierLoc, NameInfo);
803 Clause->setPrivates(Privates);
804 Clause->setLHSExprs(LHSExprs);
805 Clause->setRHSExprs(RHSExprs);
806 Clause->setReductionOps(ReductionOps);
807 Clause->setPreInitStmt(PreInit);
808 Clause->setPostUpdateExpr(PostUpdate);
809 if (Modifier == OMPC_REDUCTION_inscan) {
810 Clause->setInscanCopyOps(CopyOps);
811 Clause->setInscanCopyArrayTemps(CopyArrayTemps);
812 Clause->setInscanCopyArrayElems(CopyArrayElems);
814 assert(CopyOps.empty() &&
815 "copy operations are expected in inscan reductions only.");
816 assert(CopyArrayTemps.empty() &&
817 "copy array temps are expected in inscan reductions only.");
818 assert(CopyArrayElems.empty() &&
819 "copy array temps are expected in inscan reductions only.");
827 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(
828 (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N));
830 Clause->setModifier(Modifier);
836 "Number of private copies is not the same as the preallocated buffer");
837 std::copy(Privates.begin(), Privates.end(),
varlist_end());
843 "Number of LHS expressions is not the same as the preallocated buffer");
844 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
850 "Number of RHS expressions is not the same as the preallocated buffer");
851 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
854void OMPTaskReductionClause::setReductionOps(
ArrayRef<Expr *> ReductionOps) {
855 assert(ReductionOps.size() ==
varlist_size() &&
"Number of task reduction "
856 "expressions is not the same "
857 "as the preallocated buffer");
858 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
868 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
870 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
872 Clause->setPrivates(Privates);
873 Clause->setLHSExprs(LHSExprs);
874 Clause->setRHSExprs(RHSExprs);
875 Clause->setReductionOps(ReductionOps);
883 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
889 "Number of private copies is not the same as the preallocated buffer");
890 std::copy(Privates.begin(), Privates.end(),
varlist_end());
896 "Number of LHS expressions is not the same as the preallocated buffer");
897 std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
903 "Number of RHS expressions is not the same as the preallocated buffer");
904 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
908 assert(ReductionOps.size() ==
varlist_size() &&
"Number of in reduction "
909 "expressions is not the same "
910 "as the preallocated buffer");
911 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
914void OMPInReductionClause::setTaskgroupDescriptors(
917 "Number of in reduction descriptors is not the same as the "
918 "preallocated buffer");
919 std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
920 getReductionOps().end());
930 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
932 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
934 Clause->setPrivates(Privates);
935 Clause->setLHSExprs(LHSExprs);
936 Clause->setRHSExprs(RHSExprs);
937 Clause->setReductionOps(ReductionOps);
938 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
946 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
965 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumSizes));
989 Clause->setLParenLoc(LParenLoc);
991 Clause->setFactor(Factor);
1005 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1007 ColonLoc, EndLoc, VL.size());
1014 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1023 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
1025 new (Mem)
OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
1031 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1041 Clause->setDepobj(Depobj);
1054 void *Mem =
C.Allocate(
1055 totalSizeToAlloc<Expr *>(VL.size() + 1 + NumLoops),
1059 Clause->setDependencyKind(
Data.DepKind);
1060 Clause->setDependencyLoc(
Data.DepLoc);
1061 Clause->setColonLoc(
Data.ColonLoc);
1062 Clause->setOmpAllMemoryLoc(
Data.OmpAllMemoryLoc);
1063 Clause->setModifier(DepModifier);
1065 for (
unsigned I = 0 ; I < NumLoops; ++I)
1071 unsigned NumLoops) {
1073 C.Allocate(totalSizeToAlloc<Expr *>(N + 1 + NumLoops),
1081 NumLoop < NumLoops &&
1082 "Expected sink or source depend + loop index must be less number of "
1084 auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1091 NumLoop < NumLoops &&
1092 "Expected sink or source depend + loop index must be less number of "
1094 auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1101 NumLoop < NumLoops &&
1102 "Expected sink or source depend + loop index must be less number of "
1104 const auto *It = std::next(
getVarRefs().end(), NumLoop + 1);
1108void OMPDependClause::setModifier(
Expr *DepModifier) {
1115 unsigned TotalNum = 0u;
1116 for (
auto &
C : ComponentLists)
1117 TotalNum +=
C.size();
1123 unsigned TotalNum = 0u;
1125 for (
const ValueDecl *D : Declarations) {
1126 const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) :
nullptr;
1127 if (
Cache.count(VD))
1159 void *Mem =
C.Allocate(
1166 OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1171 Clause->setIteratorModifier(IteratorModifier);
1173 Clause->setMapType(
Type);
1181 void *Mem =
C.Allocate(
1188 Clause->setIteratorModifier(
nullptr);
1215 void *Mem =
C.Allocate(
1222 auto *Clause =
new (Mem)
OMPToClause(MotionModifiers, MotionModifiersLoc,
1223 UDMQualifierLoc, MapperId, Locs, Sizes);
1226 Clause->setUDMapperRefs(UDMapperRefs);
1227 Clause->setClauseInfo(Declarations, ComponentLists);
1233 void *Mem =
C.Allocate(
1265 void *Mem =
C.Allocate(
1273 new (Mem)
OMPFromClause(MotionModifiers, MotionModifiersLoc,
1274 UDMQualifierLoc, MapperId, Locs, Sizes);
1277 Clause->setUDMapperRefs(UDMapperRefs);
1278 Clause->setClauseInfo(Declarations, ComponentLists);
1285 void *Mem =
C.Allocate(
1296 "Number of private copies is not the same as the preallocated buffer");
1302 "Number of inits is not the same as the preallocated buffer");
1303 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
1327 void *Mem =
C.Allocate(
1337 Clause->setPrivateCopies(PrivateVars);
1338 Clause->setInits(Inits);
1346 void *Mem =
C.Allocate(
1376 void *Mem =
C.Allocate(
1386 Clause->setClauseInfo(Declarations, ComponentLists);
1393 void *Mem =
C.Allocate(
1423 void *Mem =
C.Allocate(
1440 void *Mem =
C.Allocate(
1470 void *Mem =
C.Allocate(
1480 Clause->setClauseInfo(Declarations, ComponentLists);
1487 void *Mem =
C.Allocate(
1502 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1511 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1516 assert(VL.size() ==
varlist_size() &&
"Number of private references is not "
1517 "the same as the preallocated buffer");
1526 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1535 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1544 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1553 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1557void OMPUsesAllocatorsClause::setAllocatorsData(
1559 assert(
Data.size() == NumOfAllocators &&
1560 "Size of allocators data is not the same as the preallocated buffer.");
1561 for (
unsigned I = 0, E =
Data.size(); I < E; ++I) {
1563 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1564 static_cast<int>(ExprOffsets::Allocator)] =
1566 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1568 ExprOffsets::AllocatorTraits)] =
1571 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1572 static_cast<int>(ParenLocsOffsets::LParen)] =
1575 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1576 static_cast<int>(ParenLocsOffsets::RParen)] =
1585 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1586 static_cast<int>(ExprOffsets::Allocator)];
1588 getTrailingObjects<Expr *>()[I *
static_cast<int>(ExprOffsets::Total) +
1590 ExprOffsets::AllocatorTraits)];
1592 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1593 static_cast<int>(ParenLocsOffsets::LParen)];
1595 SourceLocation>()[I *
static_cast<int>(ParenLocsOffsets::Total) +
1596 static_cast<int>(ParenLocsOffsets::RParen)];
1604 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1605 static_cast<int>(ExprOffsets::Total) *
Data.size(),
1606 static_cast<int>(ParenLocsOffsets::Total) *
Data.size()));
1607 auto *Clause =
new (Mem)
1609 Clause->setAllocatorsData(
Data);
1615 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1616 static_cast<int>(ExprOffsets::Total) * N,
1617 static_cast<int>(ParenLocsOffsets::Total) * N));
1626 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1627 auto *Clause =
new (Mem)
1629 Clause->setModifier(Modifier);
1630 Clause->setVarRefs(Locators);
1636 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1648 C.Allocate(totalSizeToAlloc<Expr *>(InteropInfo.
PreferTypes.size() + 1));
1651 VarLoc, EndLoc, InteropInfo.
PreferTypes.size() + 1);
1652 Clause->setInteropVar(InteropVar);
1653 llvm::copy(InteropInfo.
PreferTypes, Clause->getTrailingObjects<
Expr *>() + 1);
1658 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(N));
1666 return new (
C)
OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc);
1678 if (
Node->getNameModifier() != OMPD_unknown)
1679 OS << getOpenMPDirectiveName(
Node->getNameModifier()) <<
": ";
1680 Node->getCondition()->printPretty(OS,
nullptr, Policy, 0);
1686 Node->getCondition()->printPretty(OS,
nullptr, Policy, 0);
1691 OS <<
"num_threads(";
1692 Node->getNumThreads()->printPretty(OS,
nullptr, Policy, 0);
1698 Node->getAlignment()->printPretty(OS,
nullptr, Policy, 0);
1704 Node->getSafelen()->printPretty(OS,
nullptr, Policy, 0);
1710 Node->getSimdlen()->printPretty(OS,
nullptr, Policy, 0);
1717 for (
auto *Size :
Node->getSizesRefs()) {
1720 Size->printPretty(OS,
nullptr, Policy, 0);
1731 if (
Expr *Factor =
Node->getFactor()) {
1733 Factor->printPretty(OS,
nullptr, Policy, 0);
1740 Node->getAllocator()->printPretty(OS,
nullptr, Policy, 0);
1746 Node->getNumForLoops()->printPretty(OS,
nullptr, Policy, 0);
1752 Node->getEventHandler()->printPretty(OS,
nullptr, Policy, 0);
1759 unsigned(
Node->getDefaultKind()))
1766 unsigned(
Node->getProcBindKind()))
1771 OS <<
"unified_address";
1774void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1776 OS <<
"unified_shared_memory";
1780 OS <<
"reverse_offload";
1783void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1785 OS <<
"dynamic_allocators";
1788void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1790 OS <<
"atomic_default_mem_order("
1792 Node->getAtomicDefaultMemOrderKind())
1809 << cast<StringLiteral>(
Node->getMessageString())->getString() <<
"\")";
1816 Node->getFirstScheduleModifier());
1820 Node->getSecondScheduleModifier());
1825 if (
auto *E =
Node->getChunkSize()) {
1827 E->printPretty(OS,
nullptr, Policy);
1834 if (
auto *Num =
Node->getNumForLoops()) {
1836 Num->printPretty(OS,
nullptr, Policy, 0);
1857void OMPClausePrinter::VisitOMPReadClause(
OMPReadClause *) { OS <<
"read"; }
1859void OMPClausePrinter::VisitOMPWriteClause(
OMPWriteClause *) { OS <<
"write"; }
1863 if (
Node->isExtended()) {
1866 Node->getDependencyKind());
1903void OMPClausePrinter::VisitOMPSIMDClause(
OMPSIMDClause *) { OS <<
"simd"; }
1912 Node->getDevice()->printPretty(OS,
nullptr, Policy, 0);
1918 Node->getNumTeams()->printPretty(OS,
nullptr, Policy, 0);
1923 OS <<
"thread_limit(";
1924 Node->getThreadLimit()->printPretty(OS,
nullptr, Policy, 0);
1930 Node->getPriority()->printPretty(OS,
nullptr, Policy, 0);
1941 Node->getGrainsize()->printPretty(OS,
nullptr, Policy, 0);
1952 Node->getNumTasks()->printPretty(OS,
nullptr, Policy, 0);
1958 Node->getHint()->printPretty(OS,
nullptr, Policy, 0);
1965 for (
const Expr *E :
Node->prefs()) {
1967 OS <<
"prefer_type(";
1970 E->printPretty(OS,
nullptr, Policy);
1975 if (
Node->getIsTarget())
1977 if (
Node->getIsTargetSync()) {
1978 if (
Node->getIsTarget())
1983 Node->getInteropVar()->printPretty(OS,
nullptr, Policy);
1989 Node->getInteropVar()->printPretty(OS,
nullptr, Policy);
1995 if (
Expr *E =
Node->getInteropVar()) {
1997 E->printPretty(OS,
nullptr, Policy);
2004 if (
Expr *E =
Node->getCondition()) {
2006 E->printPretty(OS,
nullptr, Policy, 0);
2013 if (
Expr *E =
Node->getCondition()) {
2015 E->printPretty(OS,
nullptr, Policy, 0);
2021void OMPClausePrinter::VisitOMPClauseList(T *
Node,
char StartSym) {
2022 for (
typename T::varlist_iterator I =
Node->varlist_begin(),
2023 E =
Node->varlist_end();
2025 assert(*I &&
"Expected non-null Stmt");
2026 OS << (I ==
Node->varlist_begin() ? StartSym :
',');
2027 if (
auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
2028 if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
2029 DRE->printPretty(OS,
nullptr, Policy, 0);
2031 DRE->getDecl()->printQualifiedName(OS);
2033 (*I)->printPretty(OS,
nullptr, Policy, 0);
2038 if (
Node->varlist_empty())
2041 if (
Expr *Allocator =
Node->getAllocator()) {
2043 Allocator->printPretty(OS,
nullptr, Policy, 0);
2045 VisitOMPClauseList(
Node,
' ');
2047 VisitOMPClauseList(
Node,
'(');
2053 if (!
Node->varlist_empty()) {
2055 VisitOMPClauseList(
Node,
'(');
2061 if (!
Node->varlist_empty()) {
2062 OS <<
"firstprivate";
2063 VisitOMPClauseList(
Node,
'(');
2069 if (!
Node->varlist_empty()) {
2070 OS <<
"lastprivate";
2083 if (!
Node->varlist_empty()) {
2085 VisitOMPClauseList(
Node,
'(');
2091 if (!
Node->varlist_empty()) {
2093 if (
Node->getModifierLoc().isValid())
2097 Node->getQualifierLoc().getNestedNameSpecifier();
2099 Node->getNameInfo().getName().getCXXOverloadedOperator();
2100 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
2105 if (QualifierLoc !=
nullptr)
2106 QualifierLoc->
print(OS, Policy);
2107 OS <<
Node->getNameInfo();
2110 VisitOMPClauseList(
Node,
' ');
2115void OMPClausePrinter::VisitOMPTaskReductionClause(
2117 if (!
Node->varlist_empty()) {
2118 OS <<
"task_reduction(";
2120 Node->getQualifierLoc().getNestedNameSpecifier();
2122 Node->getNameInfo().getName().getCXXOverloadedOperator();
2123 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
2128 if (QualifierLoc !=
nullptr)
2129 QualifierLoc->
print(OS, Policy);
2130 OS <<
Node->getNameInfo();
2133 VisitOMPClauseList(
Node,
' ');
2139 if (!
Node->varlist_empty()) {
2140 OS <<
"in_reduction(";
2142 Node->getQualifierLoc().getNestedNameSpecifier();
2144 Node->getNameInfo().getName().getCXXOverloadedOperator();
2145 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
2150 if (QualifierLoc !=
nullptr)
2151 QualifierLoc->
print(OS, Policy);
2152 OS <<
Node->getNameInfo();
2155 VisitOMPClauseList(
Node,
' ');
2161 if (!
Node->varlist_empty()) {
2163 if (
Node->getModifierLoc().isValid()) {
2167 VisitOMPClauseList(
Node,
'(');
2168 if (
Node->getModifierLoc().isValid())
2170 if (
Node->getStep() !=
nullptr) {
2172 Node->getStep()->printPretty(OS,
nullptr, Policy, 0);
2179 if (!
Node->varlist_empty()) {
2181 VisitOMPClauseList(
Node,
'(');
2182 if (
Node->getAlignment() !=
nullptr) {
2184 Node->getAlignment()->printPretty(OS,
nullptr, Policy, 0);
2191 if (!
Node->varlist_empty()) {
2193 VisitOMPClauseList(
Node,
'(');
2199 if (!
Node->varlist_empty()) {
2200 OS <<
"copyprivate";
2201 VisitOMPClauseList(
Node,
'(');
2207 if (!
Node->varlist_empty()) {
2208 VisitOMPClauseList(
Node,
'(');
2215 Node->getDepobj()->printPretty(OS,
nullptr, Policy, 0);
2221 if (
Expr *DepModifier =
Node->getModifier()) {
2227 bool IsOmpAllMemory =
false;
2228 if (PrintKind == OMPC_DEPEND_outallmemory) {
2229 PrintKind = OMPC_DEPEND_out;
2230 IsOmpAllMemory =
true;
2231 }
else if (PrintKind == OMPC_DEPEND_inoutallmemory) {
2232 PrintKind = OMPC_DEPEND_inout;
2233 IsOmpAllMemory =
true;
2236 if (!
Node->varlist_empty() || IsOmpAllMemory)
2238 VisitOMPClauseList(
Node,
' ');
2239 if (IsOmpAllMemory) {
2240 OS << (
Node->varlist_empty() ?
" " :
",");
2241 OS <<
"omp_all_memory";
2246template <
typename T>
2251 Node->getMapperQualifierLoc().getNestedNameSpecifier();
2254 OS <<
Node->getMapperIdInfo() <<
')';
2257template <
typename T>
2260 if (
Expr *IteratorModifier =
Node->getIteratorModifier())
2261 IteratorModifier->printPretty(
OS,
nullptr, Policy);
2265 if (!
Node->varlist_empty()) {
2270 if (
Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator) {
2274 Node->getMapTypeModifier(I));
2275 if (
Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper)
2284 VisitOMPClauseList(
Node,
' ');
2289template <
typename T>
void OMPClausePrinter::VisitOMPMotionClause(T *
Node) {
2290 if (
Node->varlist_empty())
2292 OS << getOpenMPClauseName(
Node->getClauseKind());
2293 unsigned ModifierCount = 0;
2298 if (ModifierCount) {
2303 Node->getMotionModifier(I));
2304 if (
Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper)
2306 if (I < ModifierCount - 1)
2311 VisitOMPClauseList(
Node,
' ');
2313 VisitOMPClauseList(
Node,
'(');
2319 VisitOMPMotionClause(
Node);
2323 VisitOMPMotionClause(
Node);
2328 OMPC_dist_schedule,
Node->getDistScheduleKind());
2329 if (
auto *E =
Node->getChunkSize()) {
2331 E->printPretty(OS,
nullptr, Policy);
2337 OS <<
"defaultmap(";
2339 Node->getDefaultmapModifier());
2343 Node->getDefaultmapKind());
2349 if (!
Node->varlist_empty()) {
2350 OS <<
"use_device_ptr";
2351 VisitOMPClauseList(
Node,
'(');
2356void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2358 if (!
Node->varlist_empty()) {
2359 OS <<
"use_device_addr";
2360 VisitOMPClauseList(
Node,
'(');
2366 if (!
Node->varlist_empty()) {
2367 OS <<
"is_device_ptr";
2368 VisitOMPClauseList(
Node,
'(');
2374 if (!
Node->varlist_empty()) {
2375 OS <<
"has_device_addr";
2376 VisitOMPClauseList(
Node,
'(');
2382 if (!
Node->varlist_empty()) {
2383 OS <<
"nontemporal";
2384 VisitOMPClauseList(
Node,
'(');
2399 if (!
Node->varlist_empty()) {
2401 VisitOMPClauseList(
Node,
'(');
2407 if (!
Node->varlist_empty()) {
2409 VisitOMPClauseList(
Node,
'(');
2414void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2416 if (
Node->getNumberOfAllocators() == 0)
2418 OS <<
"uses_allocators(";
2419 for (
unsigned I = 0, E =
Node->getNumberOfAllocators(); I < E; ++I) {
2421 Data.Allocator->printPretty(OS,
nullptr, Policy);
2422 if (
Data.AllocatorTraits) {
2424 Data.AllocatorTraits->printPretty(OS,
nullptr, Policy);
2434 if (
Node->varlist_empty())
2437 char StartSym =
'(';
2438 if (
Expr *Modifier =
Node->getModifier()) {
2440 Modifier->printPretty(OS,
nullptr, Policy);
2444 VisitOMPClauseList(
Node, StartSym);
2450 Node->getThreadID()->printPretty(OS,
nullptr, Policy, 0);
2460void OMPClausePrinter::VisitOMPXDynCGroupMemClause(
2462 OS <<
"ompx_dyn_cgroup_mem(";
2463 Node->getSize()->printPretty(OS,
nullptr, Policy, 0);
2468 VariantMatchInfo &VMI)
const {
2473 if (
Selector.Kind == TraitSelector::user_condition) {
2474 assert(
Selector.ScoreOrCondition &&
2475 "Ill-formed user condition, expected condition expression!");
2476 assert(
Selector.Properties.size() == 1 &&
2477 Selector.Properties.front().Kind ==
2478 TraitProperty::user_condition_unknown &&
2479 "Ill-formed user condition, expected unknown trait property!");
2481 if (std::optional<APSInt> CondVal =
2482 Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))
2483 VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false
2484 : TraitProperty::user_condition_true,
2487 VMI.addTrait(TraitProperty::user_condition_false,
"<condition>");
2491 std::optional<llvm::APSInt> Score;
2492 llvm::APInt *ScorePtr =
nullptr;
2494 if ((Score =
Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)))
2497 VMI.addTrait(TraitProperty::user_condition_false,
2498 "<non-constant-score>");
2504 if (Set.Kind != TraitSet::construct)
2508 assert(
Selector.Properties.size() == 1 &&
2509 Selector.Properties.front().Kind ==
2510 getOpenMPContextTraitPropertyForSelector(
2512 "Ill-formed construct selector!");
2519 bool FirstSet =
true;
2524 OS << getOpenMPContextTraitSetName(Set.Kind) <<
"={";
2526 bool FirstSelector =
true;
2530 FirstSelector =
false;
2531 OS << getOpenMPContextTraitSelectorName(
Selector.Kind);
2533 bool AllowsTraitScore =
false;
2534 bool RequiresProperty =
false;
2535 isValidTraitSelectorForTraitSet(
2536 Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2538 if (!RequiresProperty)
2542 if (
Selector.Kind == TraitSelector::user_condition) {
2544 Selector.ScoreOrCondition->printPretty(
OS,
nullptr, Policy);
2551 Selector.ScoreOrCondition->printPretty(
OS,
nullptr, Policy);
2555 bool FirstProperty =
true;
2559 FirstProperty =
false;
2560 OS << getOpenMPContextTraitPropertyName(
Property.Kind,
2571 std::string MangledName;
2572 llvm::raw_string_ostream
OS(MangledName);
2577 bool AllowsTraitScore =
false;
2578 bool RequiresProperty =
false;
2579 isValidTraitSelectorForTraitSet(
2580 Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2583 if (!RequiresProperty ||
2584 Selector.Kind == TraitSelector::user_condition)
2589 << getOpenMPContextTraitPropertyName(
Property.Kind,
2596OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
2599 if (!MangledName.consume_front(
"$S"))
2601 if (MangledName.consumeInteger(10,
U))
2605 Set.
Kind = TraitSet(
U);
2607 if (!MangledName.consume_front(
"$s"))
2609 if (MangledName.consumeInteger(10,
U))
2615 if (!MangledName.consume_front(
"$P"))
2619 std::pair<StringRef, StringRef> PropRestPair = MangledName.split(
'$');
2620 Property.RawString = PropRestPair.first;
2621 Property.Kind = getOpenMPContextTraitPropertyKind(
2623 MangledName = MangledName.drop_front(PropRestPair.first.size());
2638 return TI ?
OS << *TI :
OS;
2642 ASTContext &ASTCtx, std::function<
void(StringRef)> &&DiagUnknownTrait,
2645 : OMPContext(ASTCtx.getLangOpts().OpenMPIsDevice,
2646 ASTCtx.getTargetInfo().getTriple()),
2647 FeatureValidityCheck([&](StringRef FeatureName) {
2650 DiagUnknownTrait(std::move(DiagUnknownTrait)) {
2653 for (llvm::omp::TraitProperty
Property : ConstructTraits)
2658 auto It = FeatureMap.find(RawString);
2659 if (It != FeatureMap.end())
2661 if (!FeatureValidityCheck(RawString))
2662 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.
TypePropertyCache< Private > Cache
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
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) const
Print this nested name specifier to the given output stream.
This represents 'acq_rel' clause in the '#pragma omp atomic|flush' directives.
This represents 'acquire' clause in the '#pragma omp atomic|flush' directives.
This represents clause 'affinity' in the '#pragma omp task'-based directives.
static OMPAffinityClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Creates clause with a modifier a list of locator items.
static OMPAffinityClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N locator items.
This represents the 'align' clause in the '#pragma omp allocate' directive.
static OMPAlignClause * Create(const ASTContext &C, Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'align' clause with the given alignment.
This represents clause 'aligned' in the '#pragma omp ...' directives.
static OMPAlignedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Expr *A)
Creates clause with a list of variables VL and alignment A.
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
This represents clause 'allocate' in the '#pragma omp ...' directives.
static OMPAllocateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, Expr *Allocator, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
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.
This represents 'at' clause in the '#pragma omp error' directive.
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
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.
This represents 'capture' clause in the '#pragma omp atomic' directive.
Class that represents a component of a mappable expression.
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl * > Declarations)
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc.
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
static OMPClauseWithPostUpdate * get(OMPClause *C)
Class that handles pre-initialization statement for some clauses, like 'shedule', 'firstprivate' etc.
const Stmt * getPreInitStmt() const
Get pre-initialization statement for the clause.
static OMPClauseWithPreInit * get(OMPClause *C)
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=llvm::omp::OMPD_unknown)
Set pre-initialization statement for the clause.
This is a basic class for representing single OpenMP clause.
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
child_range used_children()
Get the iterator range for the expressions used in the clauses.
llvm::iterator_range< child_iterator > child_range
void setLocEnd(SourceLocation Loc)
Sets the ending location of the clause.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents 'compare' clause in the '#pragma omp atomic' directive.
This represents clause 'copyin' in the '#pragma omp ...' directives.
static OMPCopyinClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
static OMPCopyprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'default' clause in the '#pragma omp ...' directive.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
static OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VL, unsigned NumLoops)
Creates clause with a list of variables VL.
Expr * getModifier()
Return optional depend modifier.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with 'sink|source' kind of dependency.
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
This represents implicit clause 'depobj' for the '#pragma omp depobj' directive.
static OMPDepobjClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Depobj)
Creates clause.
static OMPDepobjClause * CreateEmpty(const ASTContext &C)
Creates an empty clause.
This represents 'destroy' clause in the '#pragma omp depobj' directive or the '#pragma omp interop' d...
This represents 'detach' clause in the '#pragma omp task' directive.
This represents 'device' clause in the '#pragma omp ...' directive.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
This represents clause 'exclusive' in the '#pragma omp scan' directive.
static OMPExclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPExclusiveClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
This represents 'filter' clause in the '#pragma omp ...' directive.
This represents 'final' clause in the '#pragma omp ...' directive.
child_range used_children()
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
static OMPFirstprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL, ArrayRef< Expr * > InitVL, Stmt *PreInit)
Creates clause with a list of variables VL.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
This represents clause 'from' in the '#pragma omp ...' directives.
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPFromClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
Representation of the 'full' clause of the '#pragma omp unroll' directive.
static OMPFullClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Build an AST node for a 'full' clause.
static OMPFullClause * CreateEmpty(const ASTContext &C)
Build an empty 'full' AST node for deserialization.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
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.
This represents 'hint' clause in the '#pragma omp ...' directive.
This represents 'if' clause in the '#pragma omp ...' directive.
child_range used_children()
This represents clause 'in_reduction' in the '#pragma omp task' directives.
static OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPInReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, ArrayRef< Expr * > TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents clause 'inclusive' in the '#pragma omp scan' directive.
static OMPInclusiveClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
static OMPInclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents the 'init' clause in '#pragma omp ...' directives.
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.
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
static OMPIsDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents clause 'linear' in the '#pragma omp ...' directives.
child_range used_children()
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
void setUsedExprs(ArrayRef< Expr * > UE)
Sets the list of used expressions for the linear clause.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
This represents clause 'map' in the '#pragma omp ...' directives.
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...
void setUDMapperRefs(ArrayRef< Expr * > DMDs)
Set the user-defined mappers that are in the trailing objects of the class.
void setClauseInfo(ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
This represents 'message' clause in the '#pragma omp error' directive.
This represents 'nocontext' clause in the '#pragma omp ...' directive.
child_range used_children()
This represents 'nogroup' clause in the '#pragma omp ...' directive.
This represents clause 'nontemporal' in the '#pragma omp ...' directives.
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPNontemporalClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
void setPrivateRefs(ArrayRef< Expr * > VL)
Sets the list of references to private copies created in private clauses.
This represents 'novariants' clause in the '#pragma omp ...' directive.
child_range used_children()
This represents 'nowait' clause in the '#pragma omp ...' directive.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
child_range used_children()
This represents 'num_teams' clause in the '#pragma omp ...' directive.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
llvm::iterator_range< child_iterator > child_range
This represents 'order' clause in the '#pragma omp ...' directive.
This represents 'ordered' clause in the '#pragma omp ...' directive.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
static OMPOrderedClause * Create(const ASTContext &C, Expr *Num, unsigned NumLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ordered' clause.
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
Representation of the 'partial' clause of the '#pragma omp unroll' directive.
static OMPPartialClause * CreateEmpty(const ASTContext &C)
Build an empty 'partial' AST node for deserialization.
static OMPPartialClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Factor)
Build an AST node for a 'partial' clause.
This represents 'priority' clause in the '#pragma omp ...' directive.
child_range used_children()
This represents clause 'private' in the '#pragma omp ...' directives.
static OMPPrivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL)
Creates clause with a list of variables VL.
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'read' clause in the '#pragma omp atomic' directive.
This represents clause 'reduction' in the '#pragma omp ...' directives.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N, OpenMPReductionClauseModifier Modifier)
Creates an empty clause with the place for N variables.
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, ArrayRef< Expr * > CopyOps, ArrayRef< Expr * > CopyArrayTemps, ArrayRef< Expr * > CopyArrayElems, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents 'relaxed' clause in the '#pragma omp atomic' directives.
This represents 'release' clause in the '#pragma omp atomic|flush' directives.
This represents 'reverse_offload' clause in the '#pragma omp requires' directive.
This represents 'simd' clause in the '#pragma omp ...' directive.
This represents 'safelen' clause in the '#pragma omp ...' directive.
This represents 'schedule' clause in the '#pragma omp ...' directive.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
This represents 'severity' clause in the '#pragma omp error' directive.
This represents clause 'shared' in the '#pragma omp ...' directives.
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents 'simdlen' clause in the '#pragma omp ...' directive.
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.
void setLParenLoc(SourceLocation Loc)
Sets the location of '('.
void setSizesRefs(ArrayRef< Expr * > VL)
Sets the tile size expressions.
static OMPSizesClause * CreateEmpty(const ASTContext &C, unsigned NumSizes)
Build an empty 'sizes' AST node for deserialization.
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
static OMPTaskReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
This represents 'threads' clause in the '#pragma omp ...' directive.
This represents clause 'to' in the '#pragma omp ...' directives.
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
static OMPToClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr * > UDMapperRefs, ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
std::string getMangledName() const
Return a string representation identifying this context selector.
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Print a human readable representation into OS.
void getAsVariantMatchInfo(ASTContext &ASTCtx, llvm::omp::VariantMatchInfo &VMI) const
Create a variant match info object from this trait info object.
llvm::SmallVector< OMPTraitSet, 2 > Sets
The outermost level of selector sets.
This represents 'unified_address' clause in the '#pragma omp requires' directive.
This represents 'unified_shared_memory' clause in the '#pragma omp requires' directive.
This represents 'untied' clause in the '#pragma omp ...' directive.
This represents 'update' clause in the '#pragma omp atomic' directive.
static OMPUpdateClause * CreateEmpty(const ASTContext &C, bool IsExtended)
Creates an empty clause with the place for N variables.
static OMPUpdateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Creates clause for 'atomic' directive.
This represents the 'use' clause in '#pragma omp ...' directives.
This represents clause 'use_device_addr' in the '#pragma omp ...' directives.
static OMPUseDeviceAddrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPUseDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.
static OMPUseDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr * > Vars, ArrayRef< Expr * > PrivateVars, ArrayRef< Expr * > Inits, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents clause 'uses_allocators' in the '#pragma omp target'-based directives.
OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const
Returns data for the specified allocator.
static OMPUsesAllocatorsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N allocators.
static OMPUsesAllocatorsClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< OMPUsesAllocatorsClause::Data > Data)
Creates clause with a list of allocators Data.
MutableArrayRef< Expr * > getVarRefs()
Fetches list of variables associated with this clause.
varlist_iterator varlist_end()
unsigned varlist_size() const
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
This represents 'write' clause in the '#pragma omp atomic' directive.
This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...' directive.
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
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
Base wrapper for a particular "section" of type source info.
The base class of the type hierarchy.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Defines the clang::TargetInfo interface.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ OMPC_ORDER_MODIFIER_unknown
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
@ OMPC_SCHEDULE_MODIFIER_unknown
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
@ C
Languages that the frontend can parse and compile.
@ Property
The type of a property.
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
@ OMPC_LASTPRIVATE_unknown
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
OpenMPGrainsizeClauseModifier
OpenMPNumTasksClauseModifier
static constexpr unsigned NumberOfOMPMotionModifiers
Number of allowed motion-modifiers.
@ OMPC_MOTION_MODIFIER_unknown
@ OMPC_DEFAULTMAP_unknown
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
@ OMPC_MAP_MODIFIER_unknown
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
YAML serialization mapping.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
llvm::SmallVector< Expr *, 4 > PreferTypes
This structure contains all sizes needed for by an OMPMappableExprListClause.
unsigned NumComponentLists
Number of component lists.
unsigned NumVars
Number of expressions listed.
unsigned NumUniqueDeclarations
Number of unique base declarations.
unsigned NumComponents
Total number of expression components.
llvm::SmallVector< OMPTraitSelector, 2 > Selectors
Data for list of allocators.
SourceLocation LParenLoc
Locations of '(' and ')' symbols.
Expr * AllocatorTraits
Allocator traits.
Expr * Allocator
Allocator.
This structure contains most locations needed for by an OMPVarListClause.
Describes how types, statements, expressions, and declarations should be printed.
bool matchesISATrait(StringRef RawString) const override
See llvm::omp::OMPContext::matchesISATrait.
TargetOMPContext(ASTContext &ASTCtx, std::function< void(StringRef)> &&DiagUnknownTrait, const FunctionDecl *CurrentFunctionDecl, ArrayRef< llvm::omp::TraitProperty > ConstructTraits)