18 #include "llvm/ADT/SmallPtrSet.h" 19 #include "llvm/Support/Casting.h" 20 #include "llvm/Support/ErrorHandling.h" 24 using namespace clang;
30 #define OPENMP_CLAUSE(Name, Class) \ 32 return static_cast<Class *>(this)->children(); 33 #include "clang/Basic/OpenMPKinds.def" 35 llvm_unreachable(
"unknown OMPClause");
40 #define OPENMP_CLAUSE(Name, Class) \ 42 return static_cast<Class *>(this)->used_children(); 43 #include "clang/Basic/OpenMPKinds.def" 49 llvm_unreachable(
"unknown OMPClause");
61 case OMPC_dist_schedule:
63 case OMPC_firstprivate:
65 case OMPC_lastprivate:
69 case OMPC_task_reduction:
71 case OMPC_in_reduction:
77 case OMPC_num_threads:
81 case OMPC_thread_limit:
97 case OMPC_copyprivate:
118 case OMPC_defaultmap:
123 case OMPC_use_device_ptr:
124 case OMPC_is_device_ptr:
125 case OMPC_unified_address:
126 case OMPC_unified_shared_memory:
127 case OMPC_reverse_offload:
128 case OMPC_dynamic_allocators:
129 case OMPC_atomic_default_mem_order:
143 case OMPC_lastprivate:
147 case OMPC_task_reduction:
149 case OMPC_in_reduction:
154 case OMPC_dist_schedule:
155 case OMPC_firstprivate:
160 case OMPC_num_threads:
170 case OMPC_copyprivate:
188 case OMPC_thread_limit:
194 case OMPC_defaultmap:
199 case OMPC_use_device_ptr:
200 case OMPC_is_device_ptr:
201 case OMPC_unified_address:
202 case OMPC_unified_shared_memory:
203 case OMPC_reverse_offload:
204 case OMPC_dynamic_allocators:
205 case OMPC_atomic_default_mem_order:
217 if (
auto *DS = dyn_cast<DeclStmt>(S)) {
218 assert(DS->isSingleDecl() &&
"Only single expression must be captured.");
219 if (
auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
220 return OED->getInitAddress();
236 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
239 for (
unsigned I = 0; I < NumLoops; ++I) {
241 Clause->setLoopCounter(I,
nullptr);
248 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
250 for (
unsigned I = 0; I < NumLoops; ++I) {
252 Clause->setLoopCounter(I,
nullptr);
258 Expr *NumIterations) {
259 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
260 getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
264 return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
268 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
269 getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
273 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
274 return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
278 assert(NumLoop < NumberOfLoops &&
"out of loops number.");
279 return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
283 assert(VL.size() == varlist_size() &&
284 "Number of private copies is not the same as the preallocated buffer");
285 std::copy(VL.begin(), VL.end(), varlist_end());
293 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
297 Clause->setPrivateCopies(PrivateVL);
303 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(2 * N));
308 assert(VL.size() == varlist_size() &&
309 "Number of private copies is not the same as the preallocated buffer");
310 std::copy(VL.begin(), VL.end(), varlist_end());
314 assert(VL.size() == varlist_size() &&
315 "Number of inits is not the same as the preallocated buffer");
316 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
324 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
328 Clause->setPrivateCopies(PrivateVL);
329 Clause->setInits(InitVL);
336 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(3 * N));
341 assert(PrivateCopies.size() == varlist_size() &&
342 "Number of private copies is not the same as the preallocated buffer");
343 std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
347 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is " 348 "not the same as the " 349 "preallocated buffer");
350 std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
354 assert(DstExprs.size() == varlist_size() &&
"Number of destination " 355 "expressions is not the same as " 356 "the preallocated buffer");
357 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
360 void OMPLastprivateClause::setAssignmentOps(
ArrayRef<Expr *> AssignmentOps) {
361 assert(AssignmentOps.size() == varlist_size() &&
362 "Number of assignment expressions is not the same as the preallocated " 364 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
365 getDestinationExprs().end());
373 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
377 Clause->setSourceExprs(SrcExprs);
378 Clause->setDestinationExprs(DstExprs);
379 Clause->setAssignmentOps(AssignmentOps);
387 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * N));
396 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(VL.size()));
404 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(N));
409 assert(PL.size() == varlist_size() &&
410 "Number of privates is not the same as the preallocated buffer");
411 std::copy(PL.begin(), PL.end(), varlist_end());
415 assert(IL.size() == varlist_size() &&
416 "Number of inits is not the same as the preallocated buffer");
417 std::copy(IL.begin(), IL.end(),
getPrivates().end());
421 assert(UL.size() == varlist_size() &&
422 "Number of updates is not the same as the preallocated buffer");
423 std::copy(UL.begin(), UL.end(),
getInits().end());
427 assert(FL.size() == varlist_size() &&
428 "Number of final updates is not the same as the preallocated buffer");
429 std::copy(FL.begin(), FL.end(),
getUpdates().end());
440 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
442 StartLoc, LParenLoc,
Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
444 Clause->setPrivates(PL);
445 Clause->setInits(IL);
448 std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
450 std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
452 Clause->setStep(Step);
453 Clause->setCalcStep(CalcStep);
463 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
471 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
474 Clause->setVarRefs(VL);
475 Clause->setAlignment(A);
481 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
486 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is " 487 "not the same as the " 488 "preallocated buffer");
489 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
493 assert(DstExprs.size() == varlist_size() &&
"Number of destination " 494 "expressions is not the same as " 495 "the preallocated buffer");
496 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
500 assert(AssignmentOps.size() == varlist_size() &&
501 "Number of assignment expressions is not the same as the preallocated " 503 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
504 getDestinationExprs().end());
509 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
510 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
511 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
514 Clause->setVarRefs(VL);
515 Clause->setSourceExprs(SrcExprs);
516 Clause->setDestinationExprs(DstExprs);
517 Clause->setAssignmentOps(AssignmentOps);
522 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(4 * N));
526 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
527 assert(SrcExprs.size() == varlist_size() &&
"Number of source expressions is " 528 "not the same as the " 529 "preallocated buffer");
530 std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
533 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
534 assert(DstExprs.size() == varlist_size() &&
"Number of destination " 535 "expressions is not the same as " 536 "the preallocated buffer");
537 std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
540 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
541 assert(AssignmentOps.size() == varlist_size() &&
542 "Number of assignment expressions is not the same as the preallocated " 544 std::copy(AssignmentOps.begin(), AssignmentOps.end(),
545 getDestinationExprs().end());
550 SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
551 ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
552 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
555 Clause->setVarRefs(VL);
556 Clause->setSourceExprs(SrcExprs);
557 Clause->setDestinationExprs(DstExprs);
558 Clause->setAssignmentOps(AssignmentOps);
564 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(4 * N));
568 void OMPReductionClause::setPrivates(ArrayRef<Expr *>
Privates) {
569 assert(Privates.size() == varlist_size() &&
570 "Number of private copies is not the same as the preallocated buffer");
571 std::copy(Privates.begin(), Privates.end(), varlist_end());
574 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
576 LHSExprs.size() == varlist_size() &&
577 "Number of LHS expressions is not the same as the preallocated buffer");
578 std::copy(LHSExprs.begin(), LHSExprs.end(),
getPrivates().end());
581 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
583 RHSExprs.size() == varlist_size() &&
584 "Number of RHS expressions is not the same as the preallocated buffer");
585 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
588 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
589 assert(ReductionOps.size() == varlist_size() &&
"Number of reduction " 590 "expressions is not the same " 591 "as the preallocated buffer");
592 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
602 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
604 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
606 Clause->setPrivates(Privates);
607 Clause->setLHSExprs(LHSExprs);
608 Clause->setRHSExprs(RHSExprs);
609 Clause->setReductionOps(ReductionOps);
617 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * N));
622 assert(Privates.size() == varlist_size() &&
623 "Number of private copies is not the same as the preallocated buffer");
624 std::copy(Privates.begin(), Privates.end(), varlist_end());
629 LHSExprs.size() == varlist_size() &&
630 "Number of LHS expressions is not the same as the preallocated buffer");
631 std::copy(LHSExprs.begin(), LHSExprs.end(),
getPrivates().end());
636 RHSExprs.size() == varlist_size() &&
637 "Number of RHS expressions is not the same as the preallocated buffer");
638 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
641 void OMPTaskReductionClause::setReductionOps(
ArrayRef<Expr *> ReductionOps) {
642 assert(ReductionOps.size() == varlist_size() &&
"Number of task reduction " 643 "expressions is not the same " 644 "as the preallocated buffer");
645 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
655 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
657 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
659 Clause->setPrivates(Privates);
660 Clause->setLHSExprs(LHSExprs);
661 Clause->setRHSExprs(RHSExprs);
662 Clause->setReductionOps(ReductionOps);
670 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(5 * N));
675 assert(Privates.size() == varlist_size() &&
676 "Number of private copies is not the same as the preallocated buffer");
677 std::copy(Privates.begin(), Privates.end(), varlist_end());
682 LHSExprs.size() == varlist_size() &&
683 "Number of LHS expressions is not the same as the preallocated buffer");
684 std::copy(LHSExprs.begin(), LHSExprs.end(),
getPrivates().end());
689 RHSExprs.size() == varlist_size() &&
690 "Number of RHS expressions is not the same as the preallocated buffer");
691 std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
695 assert(ReductionOps.size() == varlist_size() &&
"Number of in reduction " 696 "expressions is not the same " 697 "as the preallocated buffer");
698 std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
701 void OMPInReductionClause::setTaskgroupDescriptors(
703 assert(TaskgroupDescriptors.size() == varlist_size() &&
704 "Number of in reduction descriptors is not the same as the " 705 "preallocated buffer");
706 std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
707 getReductionOps().end());
717 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
719 StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
721 Clause->setPrivates(Privates);
722 Clause->setLHSExprs(LHSExprs);
723 Clause->setRHSExprs(RHSExprs);
724 Clause->setReductionOps(ReductionOps);
725 Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
733 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(6 * N));
743 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(VL.size()));
745 ColonLoc, EndLoc, VL.size());
752 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(N));
761 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
764 Clause->setVarRefs(VL);
769 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(N));
779 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops));
782 Clause->setVarRefs(VL);
783 Clause->setDependencyKind(DepKind);
784 Clause->setDependencyLoc(DepLoc);
785 Clause->setColonLoc(ColonLoc);
786 for (
unsigned I = 0 ; I < NumLoops; ++I)
793 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(N + NumLoops));
798 assert((getDependencyKind() == OMPC_DEPEND_sink ||
799 getDependencyKind() == OMPC_DEPEND_source) &&
800 NumLoop < NumLoops &&
801 "Expected sink or source depend + loop index must be less number of " 803 auto It = std::next(getVarRefs().end(), NumLoop);
808 assert((getDependencyKind() == OMPC_DEPEND_sink ||
809 getDependencyKind() == OMPC_DEPEND_source) &&
810 NumLoop < NumLoops &&
811 "Expected sink or source depend + loop index must be less number of " 813 auto It = std::next(getVarRefs().end(), NumLoop);
818 assert((getDependencyKind() == OMPC_DEPEND_sink ||
819 getDependencyKind() == OMPC_DEPEND_source) &&
820 NumLoop < NumLoops &&
821 "Expected sink or source depend + loop index must be less number of " 823 auto It = std::next(getVarRefs().end(), NumLoop);
829 unsigned TotalNum = 0u;
830 for (
auto &C : ComponentLists)
831 TotalNum += C.size();
836 ArrayRef<const ValueDecl *> Declarations) {
837 unsigned TotalNum = 0u;
838 llvm::SmallPtrSet<const ValueDecl *, 8>
Cache;
839 for (
const ValueDecl *D : Declarations) {
840 const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) :
nullptr;
861 Sizes.
NumComponents = getComponentsTotalNumber(ComponentLists);
880 OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
881 Type, TypeIsImplicit, TypeLoc, Locs, Sizes);
883 Clause->setVarRefs(Vars);
886 Clause->setMapType(Type);
887 Clause->setMapLoc(TypeLoc);
912 Sizes.
NumComponents = getComponentsTotalNumber(ComponentLists);
931 auto *Clause =
new (Mem)
OMPToClause(UDMQualifierLoc, MapperId, Locs, Sizes);
933 Clause->setVarRefs(Vars);
935 Clause->setClauseInfo(Declarations, ComponentLists);
959 Sizes.
NumComponents = getComponentsTotalNumber(ComponentLists);
979 new (Mem)
OMPFromClause(UDMQualifierLoc, MapperId, Locs, Sizes);
981 Clause->setVarRefs(Vars);
983 Clause->setClauseInfo(Declarations, ComponentLists);
1000 assert(VL.size() == varlist_size() &&
1001 "Number of private copies is not the same as the preallocated buffer");
1002 std::copy(VL.begin(), VL.end(), varlist_end());
1006 assert(VL.size() == varlist_size() &&
1007 "Number of inits is not the same as the preallocated buffer");
1008 std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
1013 ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *>
Inits,
1014 ArrayRef<ValueDecl *> Declarations,
1020 Sizes.
NumComponents = getComponentsTotalNumber(ComponentLists);
1041 Clause->setVarRefs(Vars);
1042 Clause->setPrivateCopies(PrivateVars);
1043 Clause->setInits(Inits);
1069 Sizes.
NumComponents = getComponentsTotalNumber(ComponentLists);
1090 Clause->setVarRefs(Vars);
1119 void OMPClausePrinter::VisitOMPFinalClause(
OMPFinalClause *Node) {
1126 OS <<
"num_threads(";
1168 OS <<
"unified_address";
1171 void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1173 OS <<
"unified_shared_memory";
1177 OS <<
"reverse_offload";
1180 void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1182 OS <<
"dynamic_allocators";
1185 void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1187 OS <<
"atomic_default_mem_order(" 1208 E->printPretty(OS,
nullptr, Policy);
1217 Num->printPretty(OS,
nullptr, Policy, 0);
1238 void OMPClausePrinter::VisitOMPReadClause(
OMPReadClause *) { OS <<
"read"; }
1240 void OMPClausePrinter::VisitOMPWriteClause(
OMPWriteClause *) { OS <<
"write"; }
1258 void OMPClausePrinter::VisitOMPSIMDClause(
OMPSIMDClause *) { OS <<
"simd"; }
1273 OS <<
"thread_limit(";
1296 void OMPClausePrinter::VisitOMPHintClause(
OMPHintClause *Node) {
1302 template<
typename T>
1303 void OMPClausePrinter::VisitOMPClauseList(T *Node,
char StartSym) {
1304 for (
typename T::varlist_iterator I = Node->varlist_begin(),
1305 E = Node->varlist_end();
1307 assert(*I &&
"Expected non-null Stmt");
1308 OS << (I == Node->varlist_begin() ? StartSym :
',');
1309 if (
auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1310 if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1311 DRE->printPretty(OS,
nullptr, Policy, 0);
1313 DRE->getDecl()->printQualifiedName(OS);
1315 (*I)->printPretty(OS,
nullptr, Policy, 0);
1325 Allocator->printPretty(OS,
nullptr, Policy, 0);
1327 VisitOMPClauseList(Node,
' ');
1329 VisitOMPClauseList(Node,
'(');
1337 VisitOMPClauseList(Node,
'(');
1344 OS <<
"firstprivate";
1345 VisitOMPClauseList(Node,
'(');
1352 OS <<
"lastprivate";
1353 VisitOMPClauseList(Node,
'(');
1361 VisitOMPClauseList(Node,
'(');
1373 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
1378 if (QualifierLoc !=
nullptr)
1379 QualifierLoc->
print(OS, Policy);
1383 VisitOMPClauseList(Node,
' ');
1388 void OMPClausePrinter::VisitOMPTaskReductionClause(
1391 OS <<
"task_reduction(";
1396 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
1401 if (QualifierLoc !=
nullptr)
1402 QualifierLoc->
print(OS, Policy);
1406 VisitOMPClauseList(Node,
' ');
1413 OS <<
"in_reduction(";
1418 if (QualifierLoc ==
nullptr && OOK !=
OO_None) {
1423 if (QualifierLoc !=
nullptr)
1424 QualifierLoc->
print(OS, Policy);
1428 VisitOMPClauseList(Node,
' ');
1436 if (Node->getModifierLoc().isValid()) {
1440 VisitOMPClauseList(Node,
'(');
1441 if (Node->getModifierLoc().isValid())
1443 if (Node->getStep() !=
nullptr) {
1445 Node->getStep()->printPretty(OS,
nullptr, Policy, 0);
1452 if (!Node->varlist_empty()) {
1454 VisitOMPClauseList(Node,
'(');
1464 if (!Node->varlist_empty()) {
1466 VisitOMPClauseList(Node,
'(');
1472 if (!Node->varlist_empty()) {
1473 OS <<
"copyprivate";
1474 VisitOMPClauseList(Node,
'(');
1479 void OMPClausePrinter::VisitOMPFlushClause(
OMPFlushClause *Node) {
1480 if (!Node->varlist_empty()) {
1481 VisitOMPClauseList(Node,
'(');
1490 if (!Node->varlist_empty()) {
1492 VisitOMPClauseList(Node,
' ');
1497 void OMPClausePrinter::VisitOMPMapClause(
OMPMapClause *Node) {
1498 if (!Node->varlist_empty()) {
1510 MapperNNS->
print(OS, Policy);
1519 VisitOMPClauseList(Node,
' ');
1524 void OMPClausePrinter::VisitOMPToClause(
OMPToClause *Node) {
1525 if (!Node->varlist_empty()) {
1534 MapperNNS->
print(OS, Policy);
1535 OS << MapperId <<
"):";
1536 VisitOMPClauseList(Node,
' ');
1538 VisitOMPClauseList(Node,
'(');
1544 void OMPClausePrinter::VisitOMPFromClause(
OMPFromClause *Node) {
1545 if (!Node->varlist_empty()) {
1554 MapperNNS->
print(OS, Policy);
1555 OS << MapperId <<
"):";
1556 VisitOMPClauseList(Node,
' ');
1558 VisitOMPClauseList(Node,
'(');
1569 E->printPretty(OS,
nullptr, Policy);
1575 OS <<
"defaultmap(";
1585 if (!Node->varlist_empty()) {
1586 OS <<
"use_device_ptr";
1587 VisitOMPClauseList(Node,
'(');
1593 if (!Node->varlist_empty()) {
1594 OS <<
"is_device_ptr";
1595 VisitOMPClauseList(Node,
'(');
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.
Defines the clang::ASTContext interface.
static OMPToClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr *> UDMapperRefs, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents clause 'copyin' in the '#pragma omp ...' directives.
bool varlist_empty() const
This represents 'atomic_default_mem_order' clause in the '#pragma omp requires' directive.
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.
TypePropertyCache< Private > Cache
static OMPClauseWithPreInit * get(OMPClause *C)
Stmt - This represents one statement.
This represents clause 'in_reduction' in the '#pragma omp task' directives.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
Class that handles pre-initialization statement for some clauses, like 'shedule', 'firstprivate' etc...
Expr * getAllocator() const
Returns allocator.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'grainsize' clause in the '#pragma omp ...' directive.
static constexpr unsigned NumberOfModifiers
Number of allowed map-type-modifiers.
This represents 'if' clause in the '#pragma omp ...' directive.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
This represents 'priority' clause in the '#pragma omp ...' directive.
The base class of the type hierarchy.
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
Expr * getCondition() const
Returns condition.
This represents 'update' clause in the '#pragma omp atomic' directive.
bool isEmpty() const
Evaluates true when this declaration name is empty.
Expr * getCondition() const
Returns condition.
Expr * getAlignment()
Returns alignment.
Expr * getNumForLoops() const
Return the number of associated for-loops.
OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier at 'Cnt' index of array of modifiers.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents 'read' clause in the '#pragma omp atomic' directive.
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.
This represents clause 'private' in the '#pragma omp ...' directives.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
This represents 'defaultmap' clause in the '#pragma omp ...' directive.
void setUpdates(ArrayRef< Expr *> UL)
Sets the list of update expressions for linear variables.
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
This represents 'reverse_offload' clause in the '#pragma omp requires' directive. ...
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Expr * getGrainsize() const
Return safe iteration space distance.
This represents 'nogroup' clause in the '#pragma omp ...' directive.
This represents 'allocator' clause in the '#pragma omp ...' directive.
This represents 'safelen' clause in the '#pragma omp ...' directive.
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Base wrapper for a particular "section" of type source info.
static OMPReductionClause * 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 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.
clang::OMPLinearClause OMPVarListClause, OMPClauseWithPostUpdate, llvm::TrailingObjects getPrivates()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'simd' clause in the '#pragma omp ...' directive.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
This represents clause 'allocate' in the '#pragma omp ...' directives.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
Expr * getChunkSize()
Get chunk size.
This represents clause 'map' in the '#pragma omp ...' directives.
This represents clause 'to' in the '#pragma omp ...' directives.
Expr * getSafelen() const
Return safe iteration space distance.
Expr * getNumTeams()
Return NumTeams number.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
static OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> SrcExprs, ArrayRef< Expr *> DstExprs, ArrayRef< Expr *> AssignmentOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc...
This represents 'default' clause in the '#pragma omp ...' directive.
This represents 'final' clause in the '#pragma omp ...' directive.
This represents 'mergeable' clause in the '#pragma omp ...' directive.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
This represents clause 'reduction' in the '#pragma omp ...' directives.
void setPrivates(ArrayRef< Expr *> PL)
Sets the list of the copies of original linear variables.
unsigned NumVars
Number of expressions listed.
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
child_range used_children()
Get the iterator range for the expressions used in the clauses.
static OMPMapClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr *> UDMapperRefs, ArrayRef< OpenMPMapModifierKind > MapModifiers, ArrayRef< SourceLocation > MapModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId, OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc)
Creates clause with a list of variables VL.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
void setFinals(ArrayRef< Expr *> FL)
Sets the list of final update expressions for linear variables.
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 OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr *> VL, unsigned NumLoops)
Creates clause with a list of variables VL.
This represents clause 'from' 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.
This represents 'dynamic_allocators' clause in the '#pragma omp requires' directive.
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, unsigned NumVars)
Build 'linear' clause with given number of variables NumVars.
This represents 'threads' clause in the '#pragma omp ...' directive.
NestedNameSpecifierLoc getMapperQualifierLoc() const
Gets the nested name specifier for associated user-defined mapper.
Expr * getSimdlen() const
Return safe iteration space distance.
This represents clause 'aligned' in the '#pragma omp ...' directives.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
static OMPOrderedClause * Create(const ASTContext &C, Expr *Num, unsigned NumLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build 'ordered' clause.
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
This represents 'proc_bind' clause in the '#pragma omp ...' directive.
This represents 'capture' clause in the '#pragma omp atomic' directive.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
This represents 'simdlen' clause in the '#pragma omp ...' directive.
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
Expr * getNumTasks() const
Return safe iteration space distance.
unsigned NumComponentLists
Number of component lists.
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
static Stmt ** getAddrOfExprAsWritten(Stmt *S)
Gets the address of the original, non-captured, expression used in the clause as the preinitializer...
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
This represents 'ordered' clause in the '#pragma omp ...' directive.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Expr * getDevice()
Return device number.
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents 'collapse' clause in the '#pragma omp ...' directive.
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This file defines OpenMP AST classes for clauses.
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
This represents 'seq_cst' clause in the '#pragma omp atomic' directive.
This represents 'untied' clause in the '#pragma omp ...' directive.
This represents 'unified_address' clause in the '#pragma omp requires' directive. ...
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
This represents 'num_teams' clause in the '#pragma omp ...' directive.
llvm::iterator_range< child_iterator > child_range
Encodes a location in the source.
This represents 'hint' clause in the '#pragma omp ...' directive.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
MutableArrayRef< Expr * > getInits()
This structure contains all sizes needed for by an OMPMappableExprListClause.
DeclarationName getName() const
getName - Returns the embedded declaration name.
This represents 'schedule' clause in the '#pragma omp ...' directive.
This represents clause 'shared' in the '#pragma omp ...' directives.
Expr * getPriority()
Return Priority number.
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
This file defines OpenMP nodes for declarative directives.
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
void setPrivateCopies(ArrayRef< Expr *> PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
This is a basic class for representing single OpenMP clause.
void setVarRefs(ArrayRef< Expr *> VL)
Sets the list of variables for this clause.
Expr * getNumForLoops() const
Return the number of associated for-loops.
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 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.
void * Allocate(size_t Size, unsigned Align=8) const
ast_type_traits::DynTypedNode Node
Dataflow Directional Tag Classes.
This represents 'device' clause in the '#pragma omp ...' directive.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
SourceLocation ModifierLoc
Location of linear modifier if any.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
This represents 'unified_shared_memory' clause in the '#pragma omp requires' directive.
This represents clause 'linear' in the '#pragma omp ...' directives.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
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.
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
unsigned NumUniqueDeclarations
Number of unique base declarations.
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Class that represents a component of a mappable expression.
Not an overloaded operator.
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl *> Declarations)
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
child_range used_children()
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
void setUDMapperRefs(ArrayRef< Expr *> DMDs)
Set the user-defined mappers that are in the trailing objects of the class.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
This represents 'write' clause in the '#pragma omp atomic' directive.
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with 'sink|source' kind of dependency.
void setClauseInfo(ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
This represents 'nowait' clause in the '#pragma omp ...' directive.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
This represents 'num_tasks' clause in the '#pragma omp ...' directive.
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
static OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
Privates[]
Gets the list of initial values for linear variables.
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Expr * getThreadLimit()
Return ThreadLimit number.
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=OMPD_unknown)
Set pre-initialization statement for the clause.
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
Expr * getHint() const
Returns number of threads.
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.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
void setInits(ArrayRef< Expr *> IL)
Sets the list of the initial values for linear variables.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
Expr * getChunkSize()
Get chunk size.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
Expr * getNumThreads() const
Returns number of threads.
This structure contains most locations needed for by an OMPVarListClause.
static OMPClauseWithPostUpdate * get(OMPClause *C)
static OMPFromClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr *> UDMapperRefs, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const
Returns kind of the clause.
const DeclarationNameInfo & getMapperIdInfo() const
Gets the name info for associated user-defined mapper.
SourceLocation ColonLoc
Location of ':'.
unsigned NumComponents
Total number of expression components.
static OMPToClause * 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 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.