23bool checkValidAfterDeviceType(
127 S.
Diag(NewClause.
getBeginLoc(), diag::err_acc_clause_after_device_type)
131 diag::note_acc_active_applies_clause_here)
132 << diag::ACCDeviceTypeApp::Active << DeviceTypeClause.
getClauseKind();
146class SemaOpenACCClauseVisitor {
147 SemaOpenACC &SemaRef;
149 ArrayRef<const OpenACCClause *> ExistingClauses;
155 DiagGangWorkerVectorSeqConflict(SemaOpenACC::OpenACCParsedClause &Clause) {
163 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCSeqClause>);
165 if (Itr != ExistingClauses.end()) {
166 SemaRef.Diag(Clause.
getBeginLoc(), diag::err_acc_clause_cannot_combine)
169 SemaRef.Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
170 << (*Itr)->getClauseKind();
178 CheckModifierList(SemaOpenACC::OpenACCParsedClause &Clause,
187 SemaRef.Diag(Clause.
getLParenLoc(), diag::err_acc_invalid_modifier)
190 return CurMods ^ Bit;
193 if ((Mods | ValidKinds) == ValidKinds)
196 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Always);
197 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::AlwaysIn);
198 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::AlwaysOut);
199 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Readonly);
200 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Zero);
201 Mods = CheckSingle(Mods, ValidKinds, OpenACCModifierKind::Capture);
207 bool IsStructuredDataOrCompute =
214 llvm_unreachable(
"Only for copy, copyin, copyout, create");
215 case OpenACCClauseKind::Copy:
216 case OpenACCClauseKind::PCopy:
217 case OpenACCClauseKind::PresentOrCopy:
219 return Check(OpenACCModifierKind::Always | OpenACCModifierKind::AlwaysIn |
220 OpenACCModifierKind::AlwaysOut |
221 OpenACCModifierKind::Capture);
222 case OpenACCClauseKind::CopyIn:
223 case OpenACCClauseKind::PCopyIn:
224 case OpenACCClauseKind::PresentOrCopyIn:
226 return Check(OpenACCModifierKind::Always | OpenACCModifierKind::AlwaysIn |
227 OpenACCModifierKind::Readonly |
228 (IsStructuredDataOrCompute ? OpenACCModifierKind::Capture
229 : OpenACCModifierKind::Invalid));
230 case OpenACCClauseKind::CopyOut:
231 case OpenACCClauseKind::PCopyOut:
232 case OpenACCClauseKind::PresentOrCopyOut:
234 return Check(OpenACCModifierKind::Always |
235 OpenACCModifierKind::AlwaysOut | OpenACCModifierKind::Zero |
236 (IsStructuredDataOrCompute ? OpenACCModifierKind::Capture
237 : OpenACCModifierKind::Invalid));
238 case OpenACCClauseKind::Create:
239 case OpenACCClauseKind::PCreate:
240 case OpenACCClauseKind::PresentOrCreate:
242 return Check(OpenACCModifierKind::Zero |
243 (IsStructuredDataOrCompute ? OpenACCModifierKind::Capture
244 : OpenACCModifierKind::Invalid));
246 llvm_unreachable(
"didn't return from switch above?");
251 template <
typename Pred>
253 CheckValidRoutineNewClauseHelper(Pred HasPredicate,
254 SemaOpenACC::OpenACCParsedClause &Clause) {
258 auto *FirstDeviceType =
259 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCDeviceTypeClause>);
261 if (FirstDeviceType == ExistingClauses.end()) {
264 auto *ExistingProhibitedClause =
265 llvm::find_if(ExistingClauses, HasPredicate);
267 if (ExistingProhibitedClause == ExistingClauses.end())
270 SemaRef.Diag(Clause.
getBeginLoc(), diag::err_acc_clause_cannot_combine)
272 << (*ExistingProhibitedClause)->getClauseKind()
274 SemaRef.Diag((*ExistingProhibitedClause)->getBeginLoc(),
275 diag::note_acc_previous_clause_here)
276 << (*ExistingProhibitedClause)->getClauseKind();
284 auto *BeforeDeviceType =
285 std::find_if(ExistingClauses.begin(), FirstDeviceType, HasPredicate);
288 if (BeforeDeviceType != FirstDeviceType) {
291 diag::err_acc_clause_routine_cannot_combine_before_device_type)
292 << Clause.
getClauseKind() << (*BeforeDeviceType)->getClauseKind();
293 SemaRef.Diag((*BeforeDeviceType)->getBeginLoc(),
294 diag::note_acc_previous_clause_here)
295 << (*BeforeDeviceType)->getClauseKind();
296 SemaRef.Diag((*FirstDeviceType)->getBeginLoc(),
297 diag::note_acc_active_applies_clause_here)
298 << diag::ACCDeviceTypeApp::Active
299 << (*FirstDeviceType)->getClauseKind();
303 auto LastDeviceTypeItr =
304 std::find_if(ExistingClauses.rbegin(), ExistingClauses.rend(),
305 llvm::IsaPred<OpenACCDeviceTypeClause>);
309 assert(LastDeviceTypeItr != ExistingClauses.rend());
313 auto *LastDeviceType = LastDeviceTypeItr.base() - 1;
315 auto *ExistingProhibitedSinceLastDevice =
316 std::find_if(LastDeviceType, ExistingClauses.end(), HasPredicate);
319 if (ExistingProhibitedSinceLastDevice == ExistingClauses.end())
323 diag::err_acc_clause_routine_cannot_combine_same_device_type)
325 << (*ExistingProhibitedSinceLastDevice)->getClauseKind();
326 SemaRef.Diag((*ExistingProhibitedSinceLastDevice)->getBeginLoc(),
327 diag::note_acc_previous_clause_here)
328 << (*ExistingProhibitedSinceLastDevice)->getClauseKind();
329 SemaRef.Diag((*LastDeviceType)->getBeginLoc(),
330 diag::note_acc_active_applies_clause_here)
331 << diag::ACCDeviceTypeApp::Active << (*LastDeviceType)->getClauseKind();
337 bool CheckValidRoutineGangWorkerVectorSeqNewClause(
338 SemaOpenACC::OpenACCParsedClause &Clause) {
345 auto ProhibitedPred = llvm::IsaPred<OpenACCGangClause, OpenACCWorkerClause,
346 OpenACCVectorClause, OpenACCSeqClause>;
348 return CheckValidRoutineNewClauseHelper(ProhibitedPred, Clause);
355 CheckValidRoutineBindNewClause(SemaOpenACC::OpenACCParsedClause &Clause) {
360 auto HasBindPred = llvm::IsaPred<OpenACCBindClause>;
361 return CheckValidRoutineNewClauseHelper(HasBindPred, Clause);
368 template <
typename TheClauseTy>
369 bool DisallowSinceLastDeviceType(SemaOpenACC::OpenACCParsedClause &Clause) {
370 auto LastDeviceTypeItr =
371 std::find_if(ExistingClauses.rbegin(), ExistingClauses.rend(),
372 llvm::IsaPred<OpenACCDeviceTypeClause>);
374 auto LastSinceDevTy =
375 std::find_if(ExistingClauses.rbegin(), LastDeviceTypeItr,
376 llvm::IsaPred<TheClauseTy>);
380 if (LastSinceDevTy != LastDeviceTypeItr) {
382 diag::err_acc_clause_since_last_device_type)
384 << (LastDeviceTypeItr != ExistingClauses.rend());
386 SemaRef.Diag((*LastSinceDevTy)->getBeginLoc(),
387 diag::note_acc_previous_clause_here)
388 << (*LastSinceDevTy)->getClauseKind();
391 if (LastDeviceTypeItr != ExistingClauses.rend())
392 SemaRef.Diag((*LastDeviceTypeItr)->getBeginLoc(),
393 diag::note_acc_active_applies_clause_here)
394 << diag::ACCDeviceTypeApp::Active
395 << (*LastDeviceTypeItr)->getClauseKind();
402 if (LastDeviceTypeItr == ExistingClauses.rend())
407 const auto &ActiveDeviceTypeClause =
410 auto PrevDeviceTypeItr = LastDeviceTypeItr;
411 auto CurDevTypeItr = LastDeviceTypeItr;
413 while ((CurDevTypeItr = std::find_if(
414 std::next(PrevDeviceTypeItr), ExistingClauses.rend(),
415 llvm::IsaPred<OpenACCDeviceTypeClause>)) !=
416 ExistingClauses.rend()) {
420 auto CurClauseKindItr = std::find_if(PrevDeviceTypeItr, CurDevTypeItr,
421 llvm::IsaPred<TheClauseTy>);
425 if (CurClauseKindItr == CurDevTypeItr) {
426 PrevDeviceTypeItr = CurDevTypeItr;
433 const auto &CurDeviceTypeClause =
437 ActiveDeviceTypeClause.getArchitectures()) {
439 CurDeviceTypeClause.getArchitectures()) {
443 if (
arg.getIdentifierInfo() == prevArg.getIdentifierInfo() ||
444 (
arg.getIdentifierInfo() && prevArg.getIdentifierInfo() &&
445 StringRef{arg.getIdentifierInfo()->getName()}.equals_insensitive(
446 prevArg.getIdentifierInfo()->getName()))) {
448 diag::err_acc_clause_conflicts_prev_dev_type)
450 << (
arg.getIdentifierInfo() ?
arg.getIdentifierInfo()->getName()
453 SemaRef.Diag(ActiveDeviceTypeClause.getBeginLoc(),
454 diag::note_acc_active_applies_clause_here)
455 << diag::ACCDeviceTypeApp::Active
456 << ActiveDeviceTypeClause.getClauseKind();
458 SemaRef.Diag((*CurClauseKindItr)->getBeginLoc(),
459 diag::note_acc_previous_clause_here)
460 << (*CurClauseKindItr)->getClauseKind();
462 SemaRef.Diag(CurDeviceTypeClause.getBeginLoc(),
463 diag::note_acc_active_applies_clause_here)
464 << diag::ACCDeviceTypeApp::Applies
465 << CurDeviceTypeClause.getClauseKind();
471 PrevDeviceTypeItr = CurDevTypeItr;
477 SemaOpenACCClauseVisitor(SemaOpenACC &S,
478 ArrayRef<const OpenACCClause *> ExistingClauses)
479 : SemaRef(S), Ctx(S.getASTContext()), ExistingClauses(ExistingClauses) {}
481 OpenACCClause *Visit(SemaOpenACC::OpenACCParsedClause &Clause) {
483 if (SemaRef.DiagnoseAllowedOnceClauses(
490 if (CheckValidRoutineGangWorkerVectorSeqNewClause(Clause) ||
491 CheckValidRoutineBindNewClause(Clause))
495 case OpenACCClauseKind::Shortloop:
496 llvm_unreachable(
"Shortloop shouldn't be generated in clang");
497 case OpenACCClauseKind::Invalid:
499#define VISIT_CLAUSE(CLAUSE_NAME) \
500 case OpenACCClauseKind::CLAUSE_NAME: \
501 return Visit##CLAUSE_NAME##Clause(Clause);
502#define CLAUSE_ALIAS(ALIAS, CLAUSE_NAME, DEPRECATED) \
503 case OpenACCClauseKind::ALIAS: \
505 SemaRef.Diag(Clause.getBeginLoc(), diag::warn_acc_deprecated_alias_name) \
506 << Clause.getClauseKind() << OpenACCClauseKind::CLAUSE_NAME; \
507 return Visit##CLAUSE_NAME##Clause(Clause);
508#include "clang/Basic/OpenACCClauses.def"
510 llvm_unreachable(
"Invalid clause kind");
513#define VISIT_CLAUSE(CLAUSE_NAME) \
514 OpenACCClause *Visit##CLAUSE_NAME##Clause( \
515 SemaOpenACC::OpenACCParsedClause &Clause);
516#include "clang/Basic/OpenACCClauses.def"
530OpenACCClause *SemaOpenACCClauseVisitor::VisitTileClause(
531 SemaOpenACC::OpenACCParsedClause &Clause) {
533 if (DisallowSinceLastDeviceType<OpenACCTileClause>(Clause))
536 llvm::SmallVector<Expr *> NewSizeExprs;
545 NewSizeExprs.push_back(Res.
get());
553OpenACCClause *SemaOpenACCClauseVisitor::VisitIfClause(
554 SemaOpenACC::OpenACCParsedClause &Clause) {
563 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCSelfClause>);
564 if (Itr != ExistingClauses.end()) {
566 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
567 << (*Itr)->getClauseKind();
576OpenACCClause *SemaOpenACCClauseVisitor::VisitSelfClause(
577 SemaOpenACC::OpenACCParsedClause &Clause) {
587 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCIfClause>);
588 if (Itr != ExistingClauses.end()) {
590 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
591 << (*Itr)->getClauseKind();
598OpenACCClause *SemaOpenACCClauseVisitor::VisitNumGangsClause(
599 SemaOpenACC::OpenACCParsedClause &Clause) {
601 if (DisallowSinceLastDeviceType<OpenACCNumGangsClause>(Clause))
628 auto *GangClauseItr =
629 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
630 auto *ReductionClauseItr =
631 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
633 if (GangClauseItr != ExistingClauses.end() &&
634 ReductionClauseItr != ExistingClauses.end()) {
636 diag::err_acc_gang_reduction_numgangs_conflict)
637 << OpenACCClauseKind::Reduction << OpenACCClauseKind::Gang
639 SemaRef.
Diag((*ReductionClauseItr)->getBeginLoc(),
640 diag::note_acc_previous_clause_here)
641 << (*ReductionClauseItr)->getClauseKind();
642 SemaRef.
Diag((*GangClauseItr)->getBeginLoc(),
643 diag::note_acc_previous_clause_here)
644 << (*GangClauseItr)->getClauseKind();
656 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
658 if (
Parallel != ExistingClauses.end()) {
660 diag::err_acc_reduction_num_gangs_conflict)
663 SemaRef.
Diag((*Parallel)->getBeginLoc(),
664 diag::note_acc_previous_clause_here)
665 << (*Parallel)->getClauseKind();
674 auto GangClauses = llvm::make_filter_range(
675 ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
677 for (
auto *GC : GangClauses) {
680 diag::err_acc_num_arg_conflict_reverse)
681 << OpenACCClauseKind::NumGangs << OpenACCClauseKind::Gang
683 SemaRef.
Diag(GC->getBeginLoc(), diag::note_acc_previous_clause_here)
684 << GC->getClauseKind();
695OpenACCClause *SemaOpenACCClauseVisitor::VisitNumWorkersClause(
696 SemaOpenACC::OpenACCParsedClause &Clause) {
698 if (DisallowSinceLastDeviceType<OpenACCNumWorkersClause>(Clause))
705 auto WorkerClauses = llvm::make_filter_range(
706 ExistingClauses, llvm::IsaPred<OpenACCWorkerClause>);
708 for (
auto *WC : WorkerClauses) {
711 diag::err_acc_num_arg_conflict_reverse)
712 << OpenACCClauseKind::NumWorkers << OpenACCClauseKind::Worker
714 SemaRef.
Diag(WC->getBeginLoc(), diag::note_acc_previous_clause_here)
715 << WC->getClauseKind();
722 "Invalid number of expressions for NumWorkers");
728OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause(
729 SemaOpenACC::OpenACCParsedClause &Clause) {
731 if (DisallowSinceLastDeviceType<OpenACCVectorLengthClause>(Clause))
738 auto VectorClauses = llvm::make_filter_range(
739 ExistingClauses, llvm::IsaPred<OpenACCVectorClause>);
741 for (
auto *VC : VectorClauses) {
744 diag::err_acc_num_arg_conflict_reverse)
745 << OpenACCClauseKind::VectorLength << OpenACCClauseKind::Vector
747 SemaRef.
Diag(VC->getBeginLoc(), diag::note_acc_previous_clause_here)
748 << VC->getClauseKind();
755 "Invalid number of expressions for NumWorkers");
761OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause(
762 SemaOpenACC::OpenACCParsedClause &Clause) {
763 if (DisallowSinceLastDeviceType<OpenACCAsyncClause>(Clause))
767 "Invalid number of expressions for Async");
774OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceNumClause(
775 SemaOpenACC::OpenACCParsedClause &Clause) {
777 "Invalid number of expressions for device_num");
783OpenACCClause *SemaOpenACCClauseVisitor::VisitDefaultAsyncClause(
784 SemaOpenACC::OpenACCParsedClause &Clause) {
786 "Invalid number of expressions for default_async");
792OpenACCClause *SemaOpenACCClauseVisitor::VisitPrivateClause(
793 SemaOpenACC::OpenACCParsedClause &Clause) {
798 llvm::SmallVector<OpenACCPrivateRecipe> InitRecipes;
801 for (
const Expr *VarExpr : Clause.
getVarList())
809OpenACCClause *SemaOpenACCClauseVisitor::VisitFirstPrivateClause(
810 SemaOpenACC::OpenACCParsedClause &Clause) {
815 llvm::SmallVector<OpenACCFirstPrivateRecipe> InitRecipes;
818 for (
const Expr *VarExpr : Clause.
getVarList())
826OpenACCClause *SemaOpenACCClauseVisitor::VisitNoCreateClause(
827 SemaOpenACC::OpenACCParsedClause &Clause) {
837OpenACCClause *SemaOpenACCClauseVisitor::VisitPresentClause(
838 SemaOpenACC::OpenACCParsedClause &Clause) {
853OpenACCClause *SemaOpenACCClauseVisitor::VisitHostClause(
854 SemaOpenACC::OpenACCParsedClause &Clause) {
864OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceClause(
865 SemaOpenACC::OpenACCParsedClause &Clause) {
875OpenACCClause *SemaOpenACCClauseVisitor::VisitCopyClause(
876 SemaOpenACC::OpenACCParsedClause &Clause) {
894OpenACCClause *SemaOpenACCClauseVisitor::VisitLinkClause(
895 SemaOpenACC::OpenACCParsedClause &Clause) {
902 OpenACCModifierKind::Invalid);
909OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceResidentClause(
910 SemaOpenACC::OpenACCParsedClause &Clause) {
921OpenACCClause *SemaOpenACCClauseVisitor::VisitCopyInClause(
922 SemaOpenACC::OpenACCParsedClause &Clause) {
940OpenACCClause *SemaOpenACCClauseVisitor::VisitCopyOutClause(
941 SemaOpenACC::OpenACCParsedClause &Clause) {
959OpenACCClause *SemaOpenACCClauseVisitor::VisitCreateClause(
960 SemaOpenACC::OpenACCParsedClause &Clause) {
978OpenACCClause *SemaOpenACCClauseVisitor::VisitAttachClause(
979 SemaOpenACC::OpenACCParsedClause &Clause) {
982 llvm::SmallVector<Expr *> VarList{Clause.
getVarList()};
983 llvm::erase_if(VarList, [&](Expr *E) {
992OpenACCClause *SemaOpenACCClauseVisitor::VisitDetachClause(
993 SemaOpenACC::OpenACCParsedClause &Clause) {
996 llvm::SmallVector<Expr *> VarList{Clause.
getVarList()};
997 llvm::erase_if(VarList, [&](Expr *E) {
1006OpenACCClause *SemaOpenACCClauseVisitor::VisitDeleteClause(
1007 SemaOpenACC::OpenACCParsedClause &Clause) {
1016OpenACCClause *SemaOpenACCClauseVisitor::VisitUseDeviceClause(
1017 SemaOpenACC::OpenACCParsedClause &Clause) {
1025OpenACCClause *SemaOpenACCClauseVisitor::VisitDevicePtrClause(
1026 SemaOpenACC::OpenACCParsedClause &Clause) {
1029 llvm::SmallVector<Expr *> VarList{Clause.
getVarList()};
1030 llvm::erase_if(VarList, [&](Expr *E) {
1045OpenACCClause *SemaOpenACCClauseVisitor::VisitWaitClause(
1046 SemaOpenACC::OpenACCParsedClause &Clause) {
1052OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceTypeClause(
1053 SemaOpenACC::OpenACCParsedClause &Clause) {
1064 diag::err_acc_device_type_multiple_archs)
1073 const std::array<llvm::StringLiteral, 6> ValidValues{
1074 "default",
"nvidia",
"acc_device_nvidia",
"radeon",
"host",
"multicore"};
1078 std::string ValidValuesString =
1079 "'default', 'nvidia', 'acc_device_nvidia', 'radeon', 'host', 'multicore'";
1081 llvm::SmallVector<DeviceTypeArgument> Architectures{
1087 bool Diagnosed =
false;
1090 if (!
Arch.getIdentifierInfo())
1092 return llvm::find_if(ValidValues, [&](StringRef RHS) {
1093 return Arch.getIdentifierInfo()->getName().equals_insensitive(RHS);
1094 }) == ValidValues.end();
1098 Diagnosed = SemaRef.
Diag(
Arch.getLoc(), diag::err_acc_invalid_default_type)
1100 << ValidValuesString;
1107 llvm::for_each(llvm::make_filter_range(Architectures, FilterPred), Diagnose);
1109 llvm::erase_if(Architectures, FilterPred);
1116OpenACCClause *SemaOpenACCClauseVisitor::VisitAutoClause(
1117 SemaOpenACC::OpenACCParsedClause &Clause) {
1123OpenACCClause *SemaOpenACCClauseVisitor::VisitNoHostClause(
1124 SemaOpenACC::OpenACCParsedClause &Clause) {
1129OpenACCClause *SemaOpenACCClauseVisitor::VisitIndependentClause(
1130 SemaOpenACC::OpenACCParsedClause &Clause) {
1136ExprResult CheckGangStaticExpr(SemaOpenACC &S, Expr *E) {
1139 return S.
ActOnIntExpr(OpenACCDirectiveKind::Invalid, OpenACCClauseKind::Gang,
1144 return DK == OpenACCDirectiveKind::Loop &&
1145 AssocKind == OpenACCDirectiveKind::Invalid;
1149 return DK == OpenACCDirectiveKind::Loop &&
1150 AssocKind != OpenACCDirectiveKind::Invalid;
1157 << GK << CK << IsOrphanLoop(DK, AssocKind) << DK
1158 << HasAssocKind(DK, AssocKind) << AssocKind;
1161ExprResult DiagIntArgInvalid(SemaOpenACC &S, Expr *E, StringRef TagKind,
1165 << TagKind << CK << IsOrphanLoop(DK, AssocKind) << DK
1166 << HasAssocKind(DK, AssocKind) << AssocKind;
1170ExprResult CheckGangDimExpr(SemaOpenACC &S, Expr *E) {
1189 std::optional<llvm::APSInt> ICE =
1192 if (!ICE || *ICE <= 0 || ICE > 3) {
1194 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
1206 case OpenACCGangKind::Static:
1207 return CheckGangStaticExpr(S, E);
1208 case OpenACCGangKind::Num:
1212 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1213 case OpenACCGangKind::Dim:
1214 return CheckGangDimExpr(S, E);
1216 llvm_unreachable(
"Unknown gang kind in gang parallel check");
1219ExprResult CheckGangKernelsExpr(SemaOpenACC &S,
1220 ArrayRef<const OpenACCClause *> ExistingClauses,
1228 case OpenACCGangKind::Dim:
1229 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1230 case OpenACCGangKind::Num: {
1245 llvm::find_if(Collection, llvm::IsaPred<OpenACCNumGangsClause>);
1247 if (Itr != Collection.end()) {
1249 <<
"num" << OpenACCClauseKind::Gang << DK
1250 << HasAssocKind(DK, AssocKind) << AssocKind
1251 << OpenACCClauseKind::NumGangs;
1253 S.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1254 << (*Itr)->getClauseKind();
1259 case OpenACCGangKind::Static:
1260 return CheckGangStaticExpr(S, E);
1262 llvm_unreachable(
"Unknown gang kind in gang kernels check");
1271 case OpenACCGangKind::Dim:
1272 case OpenACCGangKind::Num:
1273 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1274 case OpenACCGangKind::Static:
1275 return CheckGangStaticExpr(S, E);
1277 llvm_unreachable(
"Unknown gang kind in gang serial check");
1285 case OpenACCGangKind::Num:
1286 case OpenACCGangKind::Static:
1287 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1288 case OpenACCGangKind::Dim:
1289 return CheckGangDimExpr(S, E);
1291 llvm_unreachable(
"Unknown gang kind in gang serial check");
1294OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorClause(
1295 SemaOpenACC::OpenACCParsedClause &Clause) {
1296 if (DiagGangWorkerVectorSeqConflict(Clause))
1304 llvm_unreachable(
"Invalid directive kind for this clause");
1305 case OpenACCDirectiveKind::Loop:
1307 case OpenACCDirectiveKind::Invalid:
1308 case OpenACCDirectiveKind::Parallel:
1309 case OpenACCDirectiveKind::ParallelLoop:
1312 case OpenACCDirectiveKind::Serial:
1313 case OpenACCDirectiveKind::SerialLoop:
1316 DiagIntArgInvalid(SemaRef, IntExpr,
"length", OpenACCClauseKind::Vector,
1321 case OpenACCDirectiveKind::Kernels:
1322 case OpenACCDirectiveKind::KernelsLoop: {
1325 llvm::IsaPred<OpenACCVectorLengthClause>);
1328 <<
"length" << OpenACCClauseKind::Vector
1333 << OpenACCClauseKind::VectorLength;
1334 SemaRef.
Diag((*Itr)->getBeginLoc(),
1335 diag::note_acc_previous_clause_here)
1336 << (*Itr)->getClauseKind();
1343 llvm_unreachable(
"Non compute construct in active compute construct");
1346 case OpenACCDirectiveKind::KernelsLoop: {
1347 const auto *Itr = llvm::find_if(ExistingClauses,
1348 llvm::IsaPred<OpenACCVectorLengthClause>);
1349 if (Itr != ExistingClauses.end()) {
1351 <<
"length" << OpenACCClauseKind::Vector
1356 << OpenACCClauseKind::VectorLength;
1357 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1358 << (*Itr)->getClauseKind();
1364 case OpenACCDirectiveKind::SerialLoop:
1365 case OpenACCDirectiveKind::Routine:
1366 DiagIntArgInvalid(SemaRef, IntExpr,
"length", OpenACCClauseKind::Vector,
1371 case OpenACCDirectiveKind::ParallelLoop:
1373 case OpenACCDirectiveKind::Invalid:
1389 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1390 << OpenACCClauseKind::Vector << OpenACCClauseKind::Vector
1393 diag::note_acc_previous_clause_here)
1404OpenACCClause *SemaOpenACCClauseVisitor::VisitWorkerClause(
1405 SemaOpenACC::OpenACCParsedClause &Clause) {
1406 if (DiagGangWorkerVectorSeqConflict(Clause))
1415 llvm_unreachable(
"Invalid directive kind for this clause");
1416 case OpenACCDirectiveKind::Invalid:
1424 case OpenACCDirectiveKind::Loop:
1426 case OpenACCDirectiveKind::Invalid:
1427 case OpenACCDirectiveKind::ParallelLoop:
1428 case OpenACCDirectiveKind::SerialLoop:
1429 case OpenACCDirectiveKind::Parallel:
1430 case OpenACCDirectiveKind::Serial:
1431 DiagIntArgInvalid(SemaRef, IntExpr, OpenACCGangKind::Num,
1436 case OpenACCDirectiveKind::KernelsLoop:
1437 case OpenACCDirectiveKind::Kernels: {
1440 llvm::IsaPred<OpenACCNumWorkersClause>);
1447 << OpenACCClauseKind::NumWorkers;
1448 SemaRef.
Diag((*Itr)->getBeginLoc(),
1449 diag::note_acc_previous_clause_here)
1450 << (*Itr)->getClauseKind();
1457 llvm_unreachable(
"Non compute construct in active compute construct");
1460 case OpenACCDirectiveKind::ParallelLoop:
1461 case OpenACCDirectiveKind::SerialLoop:
1462 case OpenACCDirectiveKind::Routine:
1463 DiagIntArgInvalid(SemaRef, IntExpr, OpenACCGangKind::Num,
1468 case OpenACCDirectiveKind::KernelsLoop: {
1469 const auto *Itr = llvm::find_if(ExistingClauses,
1470 llvm::IsaPred<OpenACCNumWorkersClause>);
1471 if (Itr != ExistingClauses.end()) {
1477 << OpenACCClauseKind::NumWorkers;
1478 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1479 << (*Itr)->getClauseKind();
1494 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1495 << OpenACCClauseKind::Worker << OpenACCClauseKind::Worker
1498 diag::note_acc_previous_clause_here)
1509 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1510 << OpenACCClauseKind::Worker << OpenACCClauseKind::Vector
1513 diag::note_acc_previous_clause_here)
1524OpenACCClause *SemaOpenACCClauseVisitor::VisitGangClause(
1525 SemaOpenACC::OpenACCParsedClause &Clause) {
1527 if (DiagGangWorkerVectorSeqConflict(Clause))
1535 OpenACCDirectiveKind::Invalid) ||
1538 auto ActiveComputeConstructContainer =
1542 auto *NumGangsClauseItr = llvm::find_if(
1543 ActiveComputeConstructContainer, llvm::IsaPred<OpenACCNumGangsClause>);
1545 if (NumGangsClauseItr != ActiveComputeConstructContainer.end() &&
1548 auto *ReductionClauseItr =
1549 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
1551 if (ReductionClauseItr != ExistingClauses.end()) {
1553 diag::err_acc_gang_reduction_numgangs_conflict)
1554 << OpenACCClauseKind::Gang << OpenACCClauseKind::Reduction
1557 SemaRef.
Diag((*ReductionClauseItr)->getBeginLoc(),
1558 diag::note_acc_previous_clause_here)
1559 << (*ReductionClauseItr)->getClauseKind();
1560 SemaRef.
Diag((*NumGangsClauseItr)->getBeginLoc(),
1561 diag::note_acc_previous_clause_here)
1562 << (*NumGangsClauseItr)->getClauseKind();
1568 llvm::SmallVector<OpenACCGangKind> GangKinds;
1569 llvm::SmallVector<Expr *> IntExprs;
1573 SourceLocation ExistingElemLoc[3];
1575 for (
unsigned I = 0; I < Clause.
getIntExprs().size(); ++I) {
1586 if (ExistingElemLoc[
static_cast<unsigned>(GK)].isValid()) {
1588 <<
static_cast<unsigned>(GK);
1589 SemaRef.
Diag(ExistingElemLoc[
static_cast<unsigned>(GK)],
1590 diag::note_acc_previous_expr_here);
1594 ExistingElemLoc[
static_cast<unsigned>(GK)] = ER.
get()->
getBeginLoc();
1595 GangKinds.push_back(GK);
1596 IntExprs.push_back(ER.
get());
1607 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1608 << OpenACCClauseKind::Gang << OpenACCClauseKind::Gang
1612 diag::note_acc_previous_clause_here)
1623 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1624 << OpenACCClauseKind::Gang << OpenACCClauseKind::Worker
1627 diag::note_acc_previous_clause_here)
1638 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1639 << OpenACCClauseKind::Gang << OpenACCClauseKind::Vector
1642 diag::note_acc_previous_clause_here)
1650 GangKinds, IntExprs, Clause.
getEndLoc());
1653OpenACCClause *SemaOpenACCClauseVisitor::VisitFinalizeClause(
1654 SemaOpenACC::OpenACCParsedClause &Clause) {
1661OpenACCClause *SemaOpenACCClauseVisitor::VisitIfPresentClause(
1662 SemaOpenACC::OpenACCParsedClause &Clause) {
1669OpenACCClause *SemaOpenACCClauseVisitor::VisitSeqClause(
1670 SemaOpenACC::OpenACCParsedClause &Clause) {
1676 const auto *Itr = llvm::find_if(
1677 ExistingClauses, llvm::IsaPred<OpenACCGangClause, OpenACCVectorClause,
1678 OpenACCWorkerClause>);
1679 if (Itr != ExistingClauses.end()) {
1680 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_cannot_combine)
1683 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1684 << (*Itr)->getClauseKind();
1693OpenACCClause *SemaOpenACCClauseVisitor::VisitReductionClause(
1694 SemaOpenACC::OpenACCParsedClause &Clause) {
1700 OpenACCDirectiveKind::Invalid) ||
1703 auto ActiveComputeConstructContainer =
1707 auto *NumGangsClauseItr = llvm::find_if(
1708 ActiveComputeConstructContainer, llvm::IsaPred<OpenACCNumGangsClause>);
1710 if (NumGangsClauseItr != ActiveComputeConstructContainer.end() &&
1713 auto *GangClauseItr =
1714 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
1716 if (GangClauseItr != ExistingClauses.end()) {
1718 diag::err_acc_gang_reduction_numgangs_conflict)
1719 << OpenACCClauseKind::Reduction << OpenACCClauseKind::Gang
1722 SemaRef.
Diag((*GangClauseItr)->getBeginLoc(),
1723 diag::note_acc_previous_clause_here)
1724 << (*GangClauseItr)->getClauseKind();
1725 SemaRef.
Diag((*NumGangsClauseItr)->getBeginLoc(),
1726 diag::note_acc_previous_clause_here)
1727 << (*NumGangsClauseItr)->getClauseKind();
1755 auto NumGangsClauses = llvm::make_filter_range(
1756 ExistingClauses, llvm::IsaPred<OpenACCNumGangsClause>);
1758 for (
auto *NGC : NumGangsClauses) {
1764 diag::err_acc_reduction_num_gangs_conflict)
1767 SemaRef.
Diag(NGC->getBeginLoc(), diag::note_acc_previous_clause_here)
1768 << NGC->getClauseKind();
1774 SmallVector<Expr *> ValidVars;
1775 SmallVector<OpenACCReductionRecipe> Recipes;
1782 ValidVars.push_back(Res.
get());
1796OpenACCClause *SemaOpenACCClauseVisitor::VisitCollapseClause(
1797 SemaOpenACC::OpenACCParsedClause &Clause) {
1799 if (DisallowSinceLastDeviceType<OpenACCCollapseClause>(Clause))
1812OpenACCClause *SemaOpenACCClauseVisitor::VisitBindClause(
1813 SemaOpenACC::OpenACCParsedClause &Clause) {
1815 if (std::holds_alternative<StringLiteral *>(Clause.
getBindDetails()))
1826bool areVarsEqual(Expr *VarExpr1, Expr *VarExpr2) {
1839 auto *Expr2AS = dyn_cast<ArraySectionExpr>(VarExpr2);
1845 if (!areVarsEqual(Expr1AS->getBase(), Expr2AS->getBase()))
1854 auto *Expr2AS = dyn_cast<ArraySubscriptExpr>(VarExpr2);
1860 if (!areVarsEqual(Expr1AS->getBase(), Expr2AS->getBase()))
1871 auto *Expr2DRE = dyn_cast<DeclRefExpr>(VarExpr2);
1877 return Expr1DRE->getDecl()->getMostRecentDecl() ==
1878 Expr2DRE->getDecl()->getMostRecentDecl();
1881 llvm_unreachable(
"Unknown variable type encountered");
1891 if (DiagnoseAllowedClauses(Clause.getDirectiveKind(), Clause.getClauseKind(),
1892 Clause.getBeginLoc()))
1902 if (
const auto *DevTypeClause = llvm::find_if(
1903 ExistingClauses, llvm::IsaPred<OpenACCDeviceTypeClause>);
1904 DevTypeClause != ExistingClauses.end()) {
1905 if (checkValidAfterDeviceType(
1910 SemaOpenACCClauseVisitor Visitor{*
this, ExistingClauses};
1912 assert((!
Result ||
Result->getClauseKind() == Clause.getClauseKind()) &&
1913 "Created wrong clause?");
1940 if (
auto *ASE = dyn_cast<ArraySectionExpr>(VarExpr)) {
1944 << diag::OACCReductionArray::Section << BaseType;
1945 Notes.push_back({ASE->getBeginLoc(), PD});
1948 }
else if (
auto *SubExpr = dyn_cast<ArraySubscriptExpr>(VarExpr)) {
1952 PDiag(diag::note_acc_reduction_array)
1953 << diag::OACCReductionArray::Subscript
1954 << SubExpr->getBase()->IgnoreParenImpCasts()->getType();
1955 Notes.push_back({SubExpr->getBeginLoc(), PD});
1956 }
else if (
auto *AT =
getASTContext().getAsArrayType(CurType)) {
1961 << diag::OACCReductionArray::ArrayTy << CurType;
1962 Notes.push_back({VarLoc, PD});
1965 auto IsValidMemberOfComposite = [](
QualType Ty) {
1966 return !Ty->isAnyComplexType() &&
1967 (Ty->isDependentType() ||
1968 (Ty->isScalarType() && !Ty->isPointerType()));
1974 for (
auto [Loc, PD] : Notes)
1977 Diag(VarLoc, diag::note_acc_reduction_type_summary);
1981 if (IsValidMemberOfComposite(CurType)) {
1984 if (!RD->isStruct() && !RD->isClass()) {
1985 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1986 << RD << diag::OACCReductionTy::NotClassStruct);
1990 if (!RD->isCompleteDefinition()) {
1991 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1992 << RD << diag::OACCReductionTy::NotComplete);
1996 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
1997 CXXRD && !CXXRD->isAggregate()) {
1998 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1999 << CXXRD << diag::OACCReductionTy::NotAgg);
2004 if (!IsValidMemberOfComposite(FD->getType())) {
2006 PDiag(diag::note_acc_reduction_member_of_composite)
2007 << FD->getName() << RD->getName();
2008 Notes.push_back({FD->getBeginLoc(), PD});
2010 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
2012 << diag::OACCReductionTy::MemberNotScalar);
2017 EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
2018 << CurType << diag::OACCReductionTy::NotScalar);
2026 if (RClause->getReductionOp() == ReductionOp)
2029 for (
Expr *OldVarExpr : RClause->getVarList()) {
2030 if (OldVarExpr->isInstantiationDependent())
2033 if (areVarsEqual(VarExpr, OldVarExpr)) {
2035 << ReductionOp << RClause->getReductionOp();
2036 Diag(OldVarExpr->getExprLoc(), diag::note_acc_previous_clause_here)
2037 << RClause->getClauseKind();
2053 "size argument non integer?");
2060 std::optional<llvm::APSInt> ICE =
2065 if (!ICE || *ICE <= 0) {
2067 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
2081 "Loop argument non integer?");
2087 std::optional<llvm::APSInt> ICE =
2093 if (!ICE || *ICE <= 0) {
2095 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
2113 return CheckGangParallelExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2116 return CheckGangSerialExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2119 return CheckGangKernelsExpr(*
this, ExistingClauses, DK,
2120 ActiveComputeConstructInfo.Kind, GK, E);
2122 return CheckGangRoutineExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2125 switch (ActiveComputeConstructInfo.Kind) {
2129 return CheckGangParallelExpr(*
this, DK, ActiveComputeConstructInfo.Kind,
2133 return CheckGangSerialExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2137 return CheckGangKernelsExpr(*
this, ExistingClauses, DK,
2138 ActiveComputeConstructInfo.Kind, GK, E);
2140 llvm_unreachable(
"Non compute construct in active compute construct?");
2149 llvm_unreachable(
"Invalid directive kind for a Gang clause");
2151 llvm_unreachable(
"Compute construct directive not handled?");
2165 const auto *ReductionItr =
2166 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
2168 if (ReductionItr != ExistingClauses.end()) {
2169 const auto GangZip = llvm::zip_equal(GangKinds, IntExprs);
2170 const auto GangItr = llvm::find_if(GangZip, [](
const auto &Tuple) {
2174 if (GangItr != GangZip.end()) {
2175 const Expr *DimExpr = std::get<1>(*GangItr);
2179 "Improperly formed gang argument");
2180 if (
const auto *DimVal = dyn_cast<ConstantExpr>(DimExpr);
2181 DimVal && DimVal->getResultAsAPSInt() > 1) {
2182 Diag(DimVal->getBeginLoc(), diag::err_acc_gang_reduction_conflict)
2184 Diag((*ReductionItr)->getBeginLoc(),
2185 diag::note_acc_previous_clause_here)
2186 << (*ReductionItr)->getClauseKind();
2194 GangKinds, IntExprs, EndLoc);
2208 const auto GangClauses = llvm::make_filter_range(
2209 ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
2211 for (
auto *GC : GangClauses) {
2213 for (
unsigned I = 0; I < GangClause->getNumExprs(); ++I) {
2214 std::pair<OpenACCGangKind, const Expr *> EPair = GangClause->getExpr(I);
2218 if (
const auto *DimVal = dyn_cast<ConstantExpr>(EPair.second);
2219 DimVal && DimVal->getResultAsAPSInt() > 1) {
2220 Diag(BeginLoc, diag::err_acc_gang_reduction_conflict)
2221 << 1 << DirectiveKind;
2222 Diag(GangClause->getBeginLoc(), diag::note_acc_previous_clause_here)
2223 << GangClause->getClauseKind();
2231 getASTContext(), BeginLoc, LParenLoc, ReductionOp, Vars, Recipes, EndLoc);
2246 for (
Expr *VarExpr : VarExprs) {
2248 NewVarList.push_back(VarExpr);
2257 NewVarList.push_back(VarExpr);
2262 const VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl());
2265 Diag(VarExpr->getBeginLoc(), diag::err_acc_link_not_extern);
2267 NewVarList.push_back(VarExpr);
2282 bool IsSpecialClause =
2294 return Diag(Clause.getBeginLoc(), diag::err_acc_declare_clause_at_global)
2295 << Clause.getClauseKind();
2300 for (
Expr *VarExpr : Clause.getVarList()) {
2304 }
else if (
const auto *MemExpr = dyn_cast<MemberExpr>(VarExpr)) {
2309 if (removeLinkageSpecDC(
2311 Diag(MemExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2312 << Clause.getClauseKind();
2317 const Expr *VarExprTemp = VarExpr;
2319 while (
const auto *ASE = dyn_cast<ArraySectionExpr>(VarExprTemp))
2323 if (
const auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
2333 if (removeLinkageSpecDC(
2334 Var->getLexicalDeclContext()->getPrimaryContext()) != DC) {
2335 Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2336 << Clause.getClauseKind();
2343 if (!IsSpecialClause && Var->hasExternalStorage()) {
2344 Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_extern)
2345 << Clause.getClauseKind();
2355 auto [Itr, Inserted] = DeclareVarReferences.try_emplace(CurDecl);
2357 Diag(VarExpr->getBeginLoc(), diag::err_acc_multiple_references)
2358 << Clause.getClauseKind();
2359 Diag(Itr->second, diag::note_acc_previous_reference);
2362 Itr->second = VarExpr->getBeginLoc();
2366 FilteredVarList.push_back(VarExpr);
2369 Clause.setVarListDetails(FilteredVarList, Mods);
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Defines some OpenACC-specific enums and functions.
This file declares semantic analysis for OpenACC constructs and clauses.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Represents a ValueDecl that came out of a declarator.
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCBindClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, const IdentifierInfo *ID, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
OpenACCClauseKind getClauseKind() const
SourceLocation getBeginLoc() const
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCModifierKind Mods, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceResidentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCFirstPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCGangClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< OpenACCGangKind > GangKinds, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCLinkClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNoHostClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, ArrayRef< OpenACCPrivateRecipe > InitRecipes, SourceLocation EndLoc)
static OpenACCReductionClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCReductionOperator Operator, ArrayRef< Expr * > VarList, ArrayRef< OpenACCReductionRecipe > Recipes, SourceLocation EndLoc)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A (possibly-)qualified type.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ASTContext & getASTContext() const
DeclContext * getCurContext() const
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void setVarListDetails(ArrayRef< Expr * > VarList, OpenACCModifierKind ModKind)
ArrayRef< Expr * > getIntExprs()
ArrayRef< Expr * > getQueueIdExprs() const
OpenACCDirectiveKind getDirectiveKind() const
ArrayRef< OpenACCGangKind > getGangKinds() const
OpenACCReductionOperator getReductionOp() const
SourceLocation getEndLoc() const
OpenACCClauseKind getClauseKind() const
const Expr * getConditionExpr() const
SourceLocation getLParenLoc() const
ArrayRef< DeviceTypeArgument > getDeviceTypeArchitectures() const
std::variant< std::monostate, clang::StringLiteral *, IdentifierInfo * > getBindDetails() const
SourceLocation getBeginLoc() const
SourceLocation getQueuesLoc() const
OpenACCModifierKind getModifierList() const
Expr * getDevNumExpr() const
ArrayRef< Expr * > getVarList()
unsigned getNumIntExprs() const
Expr * getLoopCount() const
OpenACCDefaultClauseKind getDefaultClauseKind() const
bool CheckDeclareClause(SemaOpenACC::OpenACCParsedClause &Clause, OpenACCModifierKind Mods)
OpenACCPrivateRecipe CreatePrivateInitRecipe(const Expr *VarExpr)
ComputeConstructInfo & getActiveComputeConstructInfo()
OpenACCReductionRecipe CreateReductionInitRecipe(OpenACCReductionOperator ReductionOperator, const Expr *VarExpr)
ExprResult ActOnIntExpr(OpenACCDirectiveKind DK, OpenACCClauseKind CK, SourceLocation Loc, Expr *IntExpr)
Called when encountering an 'int-expr' for OpenACC, and manages conversions and diagnostics to 'int'.
OpenACCClause * CheckReductionClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCDirectiveKind DirectiveKind, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCReductionOperator ReductionOp, ArrayRef< Expr * > Vars, ArrayRef< OpenACCReductionRecipe > Recipes, SourceLocation EndLoc)
SourceLocation LoopWorkerClauseLoc
If there is a current 'active' loop construct with a 'worker' clause on it (on any sort of construct)...
OpenACCClause * ActOnClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCParsedClause &Clause)
Called after parsing an OpenACC Clause so that it can be checked.
bool CheckVarIsPointerType(OpenACCClauseKind ClauseKind, Expr *VarExpr)
Called to check the 'var' type is a variable of pointer type, necessary for 'deviceptr' and 'attach' ...
struct clang::SemaOpenACC::LoopGangOnKernelTy LoopGangClauseOnKernel
ExprResult CheckReductionVar(OpenACCDirectiveKind DirectiveKind, OpenACCReductionOperator ReductionOp, Expr *VarExpr)
Called while semantically analyzing the reduction clause, ensuring the var is the correct kind of ref...
llvm::SmallVector< Expr * > CheckLinkClauseVarList(ArrayRef< Expr * > VarExpr)
ExprResult CheckCollapseLoopCount(Expr *LoopCount)
Checks the loop depth value for a collapse clause.
SourceLocation LoopVectorClauseLoc
If there is a current 'active' loop construct with a 'vector' clause on it (on any sort of construct)...
ExprResult CheckGangExpr(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCDirectiveKind DK, OpenACCGangKind GK, Expr *E)
OpenACCFirstPrivateRecipe CreateFirstPrivateInitRecipe(const Expr *VarExpr)
OpenACCClause * CheckGangClause(OpenACCDirectiveKind DirKind, ArrayRef< const OpenACCClause * > ExistingClauses, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< OpenACCGangKind > GangKinds, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
ExprResult CheckTileSizeExpr(Expr *SizeExpr)
Checks a single size expr for a tile clause.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getBeginLoc() const LLVM_READONLY
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Represents a variable declaration or definition.
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K)
bool isOpenACCCombinedDirectiveKind(OpenACCDirectiveKind K)
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Bind
'bind' clause, allowed on routine constructs.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ Link
'link' clause, allowed on 'declare' construct.
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ DType
'dtype' clause, an alias for 'device_type', stored separately for diagnostic purposes.
@ CopyIn
'copyin' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
IdentifierLoc DeviceTypeArgument
@ Result
The result type of a method or function.
bool isOpenACCModifierBitSet(OpenACCModifierKind List, OpenACCModifierKind Bit)
U cast(CodeGen::Address addr)
ActionResult< Expr * > ExprResult
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
OpenACCDirectiveKind DirKind