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?");
255 template <
typename Pred>
256 bool DisallowSinceLastDeviceType(Pred HasPredicate,
257 SemaOpenACC::OpenACCParsedClause &Clause,
258 bool DTOverrides =
true) {
259 using ItrTy =
decltype(ExistingClauses.begin());
260 llvm::SmallVector<ItrTy> DeviceTypeClauses;
263 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCDeviceTypeClause>);
264 while (DevTypeItr != ExistingClauses.end()) {
265 DeviceTypeClauses.push_back(DevTypeItr);
266 DevTypeItr = std::find_if(std::next(DevTypeItr), ExistingClauses.end(),
267 llvm::IsaPred<OpenACCDeviceTypeClause>);
270 auto SinceLastDevType =
271 std::find_if(DeviceTypeClauses.empty() ? ExistingClauses.begin()
272 : DeviceTypeClauses.back(),
273 ExistingClauses.end(), HasPredicate);
277 if (SinceLastDevType != ExistingClauses.end()) {
279 diag::err_acc_clause_cannot_combine_same_device_type)
281 << (*SinceLastDevType)->getClauseKind() << !DeviceTypeClauses.empty();
283 SemaRef.Diag((*SinceLastDevType)->getBeginLoc(),
284 diag::note_acc_previous_clause_here)
285 << (*SinceLastDevType)->getClauseKind();
287 if (!DeviceTypeClauses.empty()) {
288 SemaRef.Diag((*DeviceTypeClauses.back())->getBeginLoc(),
289 diag::note_acc_active_applies_clause_here)
290 << diag::ACCDeviceTypeApp::Active
291 << (*DeviceTypeClauses.back())->getClauseKind();
300 if (DeviceTypeClauses.empty())
307 auto BeforeFirstDevType = std::find_if(
308 ExistingClauses.begin(), DeviceTypeClauses.front(), HasPredicate);
310 if (BeforeFirstDevType != DeviceTypeClauses.front()) {
312 diag::err_acc_clause_cannot_combine_before_device_type)
314 << (*BeforeFirstDevType)->getClauseKind();
316 SemaRef.Diag((*BeforeFirstDevType)->getBeginLoc(),
317 diag::note_acc_previous_clause_here)
318 << (*BeforeFirstDevType)->getClauseKind();
320 SemaRef.Diag((*DeviceTypeClauses.back())->getBeginLoc(),
321 diag::note_acc_active_applies_clause_here)
322 << diag::ACCDeviceTypeApp::Active
323 << (*DeviceTypeClauses.back())->getClauseKind();
341 StringRef RHSName = RHS.getIdentifierInfo()->getName();
342 if (LHSName.equals_insensitive(RHSName))
347 return (LHSName.equals_insensitive(
"acc_device_nvidia") &&
348 RHSName.equals_insensitive(
"nvidia")) ||
349 (RHSName.equals_insensitive(
"acc_device_nvidia") &&
350 LHSName.equals_insensitive(
"nvidia"));
352 const OpenACCDeviceTypeClause *ActiveDTClause =
357 for (
unsigned Idx = 0; Idx < DeviceTypeClauses.size() - 1; ++Idx) {
358 ItrTy ProhibitedClause = std::find_if(
359 DeviceTypeClauses[Idx], DeviceTypeClauses[Idx + 1], HasPredicate);
363 if (ProhibitedClause == DeviceTypeClauses[Idx + 1])
366 const OpenACCDeviceTypeClause *CurDTClause =
373 if (areSameArch(CurArch, ActiveArch)) {
375 diag::err_acc_clause_conflicts_prev_dev_type)
377 << (ActiveArch.getIdentifierInfo()
378 ? ActiveArch.getIdentifierInfo()->getName()
380 << (*ProhibitedClause)->getClauseKind();
383 diag::note_acc_active_applies_clause_here)
384 << diag::ACCDeviceTypeApp::Active
387 SemaRef.Diag((*ProhibitedClause)->getBeginLoc(),
388 diag::note_acc_previous_clause_here)
389 << (*ProhibitedClause)->getClauseKind();
392 diag::note_acc_active_applies_clause_here)
393 << diag::ACCDeviceTypeApp::Applies
411 bool CheckValidRoutineGangWorkerVectorSeqNewClause(
412 SemaOpenACC::OpenACCParsedClause &Clause) {
420 auto ProhibitedPred = llvm::IsaPred<OpenACCGangClause, OpenACCWorkerClause,
421 OpenACCVectorClause, OpenACCSeqClause>;
423 return DisallowSinceLastDeviceType(ProhibitedPred, Clause,
431 CheckValidRoutineBindNewClause(SemaOpenACC::OpenACCParsedClause &Clause) {
437 auto HasBindPred = llvm::IsaPred<OpenACCBindClause>;
438 return DisallowSinceLastDeviceType(HasBindPred, Clause,
443 SemaOpenACCClauseVisitor(SemaOpenACC &S,
444 ArrayRef<const OpenACCClause *> ExistingClauses)
445 : SemaRef(S), Ctx(S.getASTContext()), ExistingClauses(ExistingClauses) {}
447 OpenACCClause *Visit(SemaOpenACC::OpenACCParsedClause &Clause) {
449 if (SemaRef.DiagnoseAllowedOnceClauses(
456 if (CheckValidRoutineGangWorkerVectorSeqNewClause(Clause) ||
457 CheckValidRoutineBindNewClause(Clause))
461 case OpenACCClauseKind::Shortloop:
462 llvm_unreachable(
"Shortloop shouldn't be generated in clang");
463 case OpenACCClauseKind::Invalid:
465#define VISIT_CLAUSE(CLAUSE_NAME) \
466 case OpenACCClauseKind::CLAUSE_NAME: \
467 return Visit##CLAUSE_NAME##Clause(Clause);
468#define CLAUSE_ALIAS(ALIAS, CLAUSE_NAME, DEPRECATED) \
469 case OpenACCClauseKind::ALIAS: \
471 SemaRef.Diag(Clause.getBeginLoc(), diag::warn_acc_deprecated_alias_name) \
472 << Clause.getClauseKind() << OpenACCClauseKind::CLAUSE_NAME; \
473 return Visit##CLAUSE_NAME##Clause(Clause);
474#include "clang/Basic/OpenACCClauses.def"
476 llvm_unreachable(
"Invalid clause kind");
479#define VISIT_CLAUSE(CLAUSE_NAME) \
480 OpenACCClause *Visit##CLAUSE_NAME##Clause( \
481 SemaOpenACC::OpenACCParsedClause &Clause);
482#include "clang/Basic/OpenACCClauses.def"
496OpenACCClause *SemaOpenACCClauseVisitor::VisitTileClause(
497 SemaOpenACC::OpenACCParsedClause &Clause) {
499 if (DisallowSinceLastDeviceType(llvm::IsaPred<OpenACCTileClause>, Clause))
502 llvm::SmallVector<Expr *> NewSizeExprs;
511 NewSizeExprs.push_back(Res.
get());
519OpenACCClause *SemaOpenACCClauseVisitor::VisitIfClause(
520 SemaOpenACC::OpenACCParsedClause &Clause) {
529 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCSelfClause>);
530 if (Itr != ExistingClauses.end()) {
532 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
533 << (*Itr)->getClauseKind();
542OpenACCClause *SemaOpenACCClauseVisitor::VisitSelfClause(
543 SemaOpenACC::OpenACCParsedClause &Clause) {
553 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCIfClause>);
554 if (Itr != ExistingClauses.end()) {
556 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
557 << (*Itr)->getClauseKind();
564OpenACCClause *SemaOpenACCClauseVisitor::VisitNumGangsClause(
565 SemaOpenACC::OpenACCParsedClause &Clause) {
567 if (DisallowSinceLastDeviceType(llvm::IsaPred<OpenACCNumGangsClause>, Clause))
594 auto *GangClauseItr =
595 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
596 auto *ReductionClauseItr =
597 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
599 if (GangClauseItr != ExistingClauses.end() &&
600 ReductionClauseItr != ExistingClauses.end()) {
602 diag::err_acc_gang_reduction_numgangs_conflict)
603 << OpenACCClauseKind::Reduction << OpenACCClauseKind::Gang
605 SemaRef.
Diag((*ReductionClauseItr)->getBeginLoc(),
606 diag::note_acc_previous_clause_here)
607 << (*ReductionClauseItr)->getClauseKind();
608 SemaRef.
Diag((*GangClauseItr)->getBeginLoc(),
609 diag::note_acc_previous_clause_here)
610 << (*GangClauseItr)->getClauseKind();
622 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
624 if (
Parallel != ExistingClauses.end()) {
626 diag::err_acc_reduction_num_gangs_conflict)
629 SemaRef.
Diag((*Parallel)->getBeginLoc(),
630 diag::note_acc_previous_clause_here)
631 << (*Parallel)->getClauseKind();
640 auto GangClauses = llvm::make_filter_range(
641 ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
643 for (
auto *GC : GangClauses) {
646 diag::err_acc_num_arg_conflict_reverse)
647 << OpenACCClauseKind::NumGangs << OpenACCClauseKind::Gang
649 SemaRef.
Diag(GC->getBeginLoc(), diag::note_acc_previous_clause_here)
650 << GC->getClauseKind();
661OpenACCClause *SemaOpenACCClauseVisitor::VisitNumWorkersClause(
662 SemaOpenACC::OpenACCParsedClause &Clause) {
664 if (DisallowSinceLastDeviceType(llvm::IsaPred<OpenACCNumWorkersClause>,
672 auto WorkerClauses = llvm::make_filter_range(
673 ExistingClauses, llvm::IsaPred<OpenACCWorkerClause>);
675 for (
auto *WC : WorkerClauses) {
678 diag::err_acc_num_arg_conflict_reverse)
679 << OpenACCClauseKind::NumWorkers << OpenACCClauseKind::Worker
681 SemaRef.
Diag(WC->getBeginLoc(), diag::note_acc_previous_clause_here)
682 << WC->getClauseKind();
689 "Invalid number of expressions for NumWorkers");
695OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause(
696 SemaOpenACC::OpenACCParsedClause &Clause) {
698 if (DisallowSinceLastDeviceType(llvm::IsaPred<OpenACCVectorLengthClause>,
706 auto VectorClauses = llvm::make_filter_range(
707 ExistingClauses, llvm::IsaPred<OpenACCVectorClause>);
709 for (
auto *VC : VectorClauses) {
712 diag::err_acc_num_arg_conflict_reverse)
713 << OpenACCClauseKind::VectorLength << OpenACCClauseKind::Vector
715 SemaRef.
Diag(VC->getBeginLoc(), diag::note_acc_previous_clause_here)
716 << VC->getClauseKind();
723 "Invalid number of expressions for NumWorkers");
729OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause(
730 SemaOpenACC::OpenACCParsedClause &Clause) {
731 if (DisallowSinceLastDeviceType(llvm::IsaPred<OpenACCAsyncClause>, Clause))
735 "Invalid number of expressions for Async");
742OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceNumClause(
743 SemaOpenACC::OpenACCParsedClause &Clause) {
745 "Invalid number of expressions for device_num");
751OpenACCClause *SemaOpenACCClauseVisitor::VisitDefaultAsyncClause(
752 SemaOpenACC::OpenACCParsedClause &Clause) {
754 "Invalid number of expressions for default_async");
760OpenACCClause *SemaOpenACCClauseVisitor::VisitPrivateClause(
761 SemaOpenACC::OpenACCParsedClause &Clause) {
766 llvm::SmallVector<OpenACCPrivateRecipe> InitRecipes;
769 for (
const Expr *VarExpr : Clause.
getVarList())
777OpenACCClause *SemaOpenACCClauseVisitor::VisitFirstPrivateClause(
778 SemaOpenACC::OpenACCParsedClause &Clause) {
783 llvm::SmallVector<OpenACCFirstPrivateRecipe> InitRecipes;
786 for (
const Expr *VarExpr : Clause.
getVarList())
794OpenACCClause *SemaOpenACCClauseVisitor::VisitNoCreateClause(
795 SemaOpenACC::OpenACCParsedClause &Clause) {
805OpenACCClause *SemaOpenACCClauseVisitor::VisitPresentClause(
806 SemaOpenACC::OpenACCParsedClause &Clause) {
821OpenACCClause *SemaOpenACCClauseVisitor::VisitHostClause(
822 SemaOpenACC::OpenACCParsedClause &Clause) {
832OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceClause(
833 SemaOpenACC::OpenACCParsedClause &Clause) {
843OpenACCClause *SemaOpenACCClauseVisitor::VisitCopyClause(
844 SemaOpenACC::OpenACCParsedClause &Clause) {
862OpenACCClause *SemaOpenACCClauseVisitor::VisitLinkClause(
863 SemaOpenACC::OpenACCParsedClause &Clause) {
870 OpenACCModifierKind::Invalid);
877OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceResidentClause(
878 SemaOpenACC::OpenACCParsedClause &Clause) {
889OpenACCClause *SemaOpenACCClauseVisitor::VisitCopyInClause(
890 SemaOpenACC::OpenACCParsedClause &Clause) {
908OpenACCClause *SemaOpenACCClauseVisitor::VisitCopyOutClause(
909 SemaOpenACC::OpenACCParsedClause &Clause) {
927OpenACCClause *SemaOpenACCClauseVisitor::VisitCreateClause(
928 SemaOpenACC::OpenACCParsedClause &Clause) {
946OpenACCClause *SemaOpenACCClauseVisitor::VisitAttachClause(
947 SemaOpenACC::OpenACCParsedClause &Clause) {
950 llvm::SmallVector<Expr *> VarList{Clause.
getVarList()};
951 llvm::erase_if(VarList, [&](Expr *E) {
960OpenACCClause *SemaOpenACCClauseVisitor::VisitDetachClause(
961 SemaOpenACC::OpenACCParsedClause &Clause) {
964 llvm::SmallVector<Expr *> VarList{Clause.
getVarList()};
965 llvm::erase_if(VarList, [&](Expr *E) {
974OpenACCClause *SemaOpenACCClauseVisitor::VisitDeleteClause(
975 SemaOpenACC::OpenACCParsedClause &Clause) {
984OpenACCClause *SemaOpenACCClauseVisitor::VisitUseDeviceClause(
985 SemaOpenACC::OpenACCParsedClause &Clause) {
993OpenACCClause *SemaOpenACCClauseVisitor::VisitDevicePtrClause(
994 SemaOpenACC::OpenACCParsedClause &Clause) {
997 llvm::SmallVector<Expr *> VarList{Clause.
getVarList()};
998 llvm::erase_if(VarList, [&](Expr *E) {
1013OpenACCClause *SemaOpenACCClauseVisitor::VisitWaitClause(
1014 SemaOpenACC::OpenACCParsedClause &Clause) {
1020OpenACCClause *SemaOpenACCClauseVisitor::VisitDeviceTypeClause(
1021 SemaOpenACC::OpenACCParsedClause &Clause) {
1032 diag::err_acc_device_type_multiple_archs)
1041 const std::array<llvm::StringLiteral, 6> ValidValues{
1042 "default",
"nvidia",
"acc_device_nvidia",
"radeon",
"host",
"multicore"};
1046 std::string ValidValuesString =
1047 "'default', 'nvidia', 'acc_device_nvidia', 'radeon', 'host', 'multicore'";
1049 llvm::SmallVector<DeviceTypeArgument> Architectures{
1055 bool Diagnosed =
false;
1058 if (!
Arch.getIdentifierInfo())
1060 return llvm::find_if(ValidValues, [&](StringRef RHS) {
1061 return Arch.getIdentifierInfo()->getName().equals_insensitive(RHS);
1062 }) == ValidValues.end();
1066 Diagnosed = SemaRef.
Diag(
Arch.getLoc(), diag::err_acc_invalid_default_type)
1068 << ValidValuesString;
1075 llvm::for_each(llvm::make_filter_range(Architectures, FilterPred), Diagnose);
1077 llvm::erase_if(Architectures, FilterPred);
1084OpenACCClause *SemaOpenACCClauseVisitor::VisitAutoClause(
1085 SemaOpenACC::OpenACCParsedClause &Clause) {
1091OpenACCClause *SemaOpenACCClauseVisitor::VisitNoHostClause(
1092 SemaOpenACC::OpenACCParsedClause &Clause) {
1097OpenACCClause *SemaOpenACCClauseVisitor::VisitIndependentClause(
1098 SemaOpenACC::OpenACCParsedClause &Clause) {
1104ExprResult CheckGangStaticExpr(SemaOpenACC &S, Expr *E) {
1107 return S.
ActOnIntExpr(OpenACCDirectiveKind::Invalid, OpenACCClauseKind::Gang,
1112 return DK == OpenACCDirectiveKind::Loop &&
1113 AssocKind == OpenACCDirectiveKind::Invalid;
1117 return DK == OpenACCDirectiveKind::Loop &&
1118 AssocKind != OpenACCDirectiveKind::Invalid;
1125 << GK << CK << IsOrphanLoop(DK, AssocKind) << DK
1126 << HasAssocKind(DK, AssocKind) << AssocKind;
1129ExprResult DiagIntArgInvalid(SemaOpenACC &S, Expr *E, StringRef TagKind,
1133 << TagKind << CK << IsOrphanLoop(DK, AssocKind) << DK
1134 << HasAssocKind(DK, AssocKind) << AssocKind;
1138ExprResult CheckGangDimExpr(SemaOpenACC &S, Expr *E) {
1157 std::optional<llvm::APSInt> ICE =
1160 if (!ICE || *ICE <= 0 || ICE > 3) {
1162 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
1174 case OpenACCGangKind::Static:
1175 return CheckGangStaticExpr(S, E);
1176 case OpenACCGangKind::Num:
1180 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1181 case OpenACCGangKind::Dim:
1182 return CheckGangDimExpr(S, E);
1184 llvm_unreachable(
"Unknown gang kind in gang parallel check");
1187ExprResult CheckGangKernelsExpr(SemaOpenACC &S,
1188 ArrayRef<const OpenACCClause *> ExistingClauses,
1196 case OpenACCGangKind::Dim:
1197 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1198 case OpenACCGangKind::Num: {
1213 llvm::find_if(Collection, llvm::IsaPred<OpenACCNumGangsClause>);
1215 if (Itr != Collection.end()) {
1217 <<
"num" << OpenACCClauseKind::Gang << DK
1218 << HasAssocKind(DK, AssocKind) << AssocKind
1219 << OpenACCClauseKind::NumGangs;
1221 S.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1222 << (*Itr)->getClauseKind();
1227 case OpenACCGangKind::Static:
1228 return CheckGangStaticExpr(S, E);
1230 llvm_unreachable(
"Unknown gang kind in gang kernels check");
1239 case OpenACCGangKind::Dim:
1240 case OpenACCGangKind::Num:
1241 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1242 case OpenACCGangKind::Static:
1243 return CheckGangStaticExpr(S, E);
1245 llvm_unreachable(
"Unknown gang kind in gang serial check");
1253 case OpenACCGangKind::Num:
1254 case OpenACCGangKind::Static:
1255 return DiagIntArgInvalid(S, E, GK, OpenACCClauseKind::Gang, DK, AssocKind);
1256 case OpenACCGangKind::Dim:
1257 return CheckGangDimExpr(S, E);
1259 llvm_unreachable(
"Unknown gang kind in gang serial check");
1262OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorClause(
1263 SemaOpenACC::OpenACCParsedClause &Clause) {
1264 if (DiagGangWorkerVectorSeqConflict(Clause))
1272 llvm_unreachable(
"Invalid directive kind for this clause");
1273 case OpenACCDirectiveKind::Loop:
1275 case OpenACCDirectiveKind::Invalid:
1276 case OpenACCDirectiveKind::Parallel:
1277 case OpenACCDirectiveKind::ParallelLoop:
1280 case OpenACCDirectiveKind::Serial:
1281 case OpenACCDirectiveKind::SerialLoop:
1284 DiagIntArgInvalid(SemaRef, IntExpr,
"length", OpenACCClauseKind::Vector,
1289 case OpenACCDirectiveKind::Kernels:
1290 case OpenACCDirectiveKind::KernelsLoop: {
1293 llvm::IsaPred<OpenACCVectorLengthClause>);
1296 <<
"length" << OpenACCClauseKind::Vector
1301 << OpenACCClauseKind::VectorLength;
1302 SemaRef.
Diag((*Itr)->getBeginLoc(),
1303 diag::note_acc_previous_clause_here)
1304 << (*Itr)->getClauseKind();
1311 llvm_unreachable(
"Non compute construct in active compute construct");
1314 case OpenACCDirectiveKind::KernelsLoop: {
1315 const auto *Itr = llvm::find_if(ExistingClauses,
1316 llvm::IsaPred<OpenACCVectorLengthClause>);
1317 if (Itr != ExistingClauses.end()) {
1319 <<
"length" << OpenACCClauseKind::Vector
1324 << OpenACCClauseKind::VectorLength;
1325 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1326 << (*Itr)->getClauseKind();
1332 case OpenACCDirectiveKind::SerialLoop:
1333 case OpenACCDirectiveKind::Routine:
1334 DiagIntArgInvalid(SemaRef, IntExpr,
"length", OpenACCClauseKind::Vector,
1339 case OpenACCDirectiveKind::ParallelLoop:
1341 case OpenACCDirectiveKind::Invalid:
1357 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1358 << OpenACCClauseKind::Vector << OpenACCClauseKind::Vector
1361 diag::note_acc_previous_clause_here)
1372OpenACCClause *SemaOpenACCClauseVisitor::VisitWorkerClause(
1373 SemaOpenACC::OpenACCParsedClause &Clause) {
1374 if (DiagGangWorkerVectorSeqConflict(Clause))
1383 llvm_unreachable(
"Invalid directive kind for this clause");
1384 case OpenACCDirectiveKind::Invalid:
1392 case OpenACCDirectiveKind::Loop:
1394 case OpenACCDirectiveKind::Invalid:
1395 case OpenACCDirectiveKind::ParallelLoop:
1396 case OpenACCDirectiveKind::SerialLoop:
1397 case OpenACCDirectiveKind::Parallel:
1398 case OpenACCDirectiveKind::Serial:
1399 DiagIntArgInvalid(SemaRef, IntExpr, OpenACCGangKind::Num,
1404 case OpenACCDirectiveKind::KernelsLoop:
1405 case OpenACCDirectiveKind::Kernels: {
1408 llvm::IsaPred<OpenACCNumWorkersClause>);
1415 << OpenACCClauseKind::NumWorkers;
1416 SemaRef.
Diag((*Itr)->getBeginLoc(),
1417 diag::note_acc_previous_clause_here)
1418 << (*Itr)->getClauseKind();
1425 llvm_unreachable(
"Non compute construct in active compute construct");
1428 case OpenACCDirectiveKind::ParallelLoop:
1429 case OpenACCDirectiveKind::SerialLoop:
1430 case OpenACCDirectiveKind::Routine:
1431 DiagIntArgInvalid(SemaRef, IntExpr, OpenACCGangKind::Num,
1436 case OpenACCDirectiveKind::KernelsLoop: {
1437 const auto *Itr = llvm::find_if(ExistingClauses,
1438 llvm::IsaPred<OpenACCNumWorkersClause>);
1439 if (Itr != ExistingClauses.end()) {
1445 << OpenACCClauseKind::NumWorkers;
1446 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1447 << (*Itr)->getClauseKind();
1462 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1463 << OpenACCClauseKind::Worker << OpenACCClauseKind::Worker
1466 diag::note_acc_previous_clause_here)
1477 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1478 << OpenACCClauseKind::Worker << OpenACCClauseKind::Vector
1481 diag::note_acc_previous_clause_here)
1492OpenACCClause *SemaOpenACCClauseVisitor::VisitGangClause(
1493 SemaOpenACC::OpenACCParsedClause &Clause) {
1495 if (DiagGangWorkerVectorSeqConflict(Clause))
1503 OpenACCDirectiveKind::Invalid) ||
1506 auto ActiveComputeConstructContainer =
1510 auto *NumGangsClauseItr = llvm::find_if(
1511 ActiveComputeConstructContainer, llvm::IsaPred<OpenACCNumGangsClause>);
1513 if (NumGangsClauseItr != ActiveComputeConstructContainer.end() &&
1516 auto *ReductionClauseItr =
1517 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
1519 if (ReductionClauseItr != ExistingClauses.end()) {
1521 diag::err_acc_gang_reduction_numgangs_conflict)
1522 << OpenACCClauseKind::Gang << OpenACCClauseKind::Reduction
1525 SemaRef.
Diag((*ReductionClauseItr)->getBeginLoc(),
1526 diag::note_acc_previous_clause_here)
1527 << (*ReductionClauseItr)->getClauseKind();
1528 SemaRef.
Diag((*NumGangsClauseItr)->getBeginLoc(),
1529 diag::note_acc_previous_clause_here)
1530 << (*NumGangsClauseItr)->getClauseKind();
1536 llvm::SmallVector<OpenACCGangKind> GangKinds;
1537 llvm::SmallVector<Expr *> IntExprs;
1541 SourceLocation ExistingElemLoc[3];
1543 for (
unsigned I = 0; I < Clause.
getIntExprs().size(); ++I) {
1554 if (ExistingElemLoc[
static_cast<unsigned>(GK)].isValid()) {
1556 <<
static_cast<unsigned>(GK);
1557 SemaRef.
Diag(ExistingElemLoc[
static_cast<unsigned>(GK)],
1558 diag::note_acc_previous_expr_here);
1562 ExistingElemLoc[
static_cast<unsigned>(GK)] = ER.
get()->
getBeginLoc();
1563 GangKinds.push_back(GK);
1564 IntExprs.push_back(ER.
get());
1575 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1576 << OpenACCClauseKind::Gang << OpenACCClauseKind::Gang
1580 diag::note_acc_previous_clause_here)
1591 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1592 << OpenACCClauseKind::Gang << OpenACCClauseKind::Worker
1595 diag::note_acc_previous_clause_here)
1606 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_in_clause_region)
1607 << OpenACCClauseKind::Gang << OpenACCClauseKind::Vector
1610 diag::note_acc_previous_clause_here)
1618 GangKinds, IntExprs, Clause.
getEndLoc());
1621OpenACCClause *SemaOpenACCClauseVisitor::VisitFinalizeClause(
1622 SemaOpenACC::OpenACCParsedClause &Clause) {
1629OpenACCClause *SemaOpenACCClauseVisitor::VisitIfPresentClause(
1630 SemaOpenACC::OpenACCParsedClause &Clause) {
1637OpenACCClause *SemaOpenACCClauseVisitor::VisitSeqClause(
1638 SemaOpenACC::OpenACCParsedClause &Clause) {
1644 const auto *Itr = llvm::find_if(
1645 ExistingClauses, llvm::IsaPred<OpenACCGangClause, OpenACCVectorClause,
1646 OpenACCWorkerClause>);
1647 if (Itr != ExistingClauses.end()) {
1648 SemaRef.
Diag(Clause.
getBeginLoc(), diag::err_acc_clause_cannot_combine)
1651 SemaRef.
Diag((*Itr)->getBeginLoc(), diag::note_acc_previous_clause_here)
1652 << (*Itr)->getClauseKind();
1661OpenACCClause *SemaOpenACCClauseVisitor::VisitReductionClause(
1662 SemaOpenACC::OpenACCParsedClause &Clause) {
1668 OpenACCDirectiveKind::Invalid) ||
1671 auto ActiveComputeConstructContainer =
1675 auto *NumGangsClauseItr = llvm::find_if(
1676 ActiveComputeConstructContainer, llvm::IsaPred<OpenACCNumGangsClause>);
1678 if (NumGangsClauseItr != ActiveComputeConstructContainer.end() &&
1681 auto *GangClauseItr =
1682 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
1684 if (GangClauseItr != ExistingClauses.end()) {
1686 diag::err_acc_gang_reduction_numgangs_conflict)
1687 << OpenACCClauseKind::Reduction << OpenACCClauseKind::Gang
1690 SemaRef.
Diag((*GangClauseItr)->getBeginLoc(),
1691 diag::note_acc_previous_clause_here)
1692 << (*GangClauseItr)->getClauseKind();
1693 SemaRef.
Diag((*NumGangsClauseItr)->getBeginLoc(),
1694 diag::note_acc_previous_clause_here)
1695 << (*NumGangsClauseItr)->getClauseKind();
1723 auto NumGangsClauses = llvm::make_filter_range(
1724 ExistingClauses, llvm::IsaPred<OpenACCNumGangsClause>);
1726 for (
auto *NGC : NumGangsClauses) {
1732 diag::err_acc_reduction_num_gangs_conflict)
1735 SemaRef.
Diag(NGC->getBeginLoc(), diag::note_acc_previous_clause_here)
1736 << NGC->getClauseKind();
1742 SmallVector<Expr *> ValidVars;
1743 SmallVector<OpenACCReductionRecipeWithStorage> Recipes;
1750 ValidVars.push_back(Res.
get());
1764OpenACCClause *SemaOpenACCClauseVisitor::VisitCollapseClause(
1765 SemaOpenACC::OpenACCParsedClause &Clause) {
1767 if (DisallowSinceLastDeviceType(llvm::IsaPred<OpenACCCollapseClause>, Clause))
1780OpenACCClause *SemaOpenACCClauseVisitor::VisitBindClause(
1781 SemaOpenACC::OpenACCParsedClause &Clause) {
1783 if (std::holds_alternative<StringLiteral *>(Clause.
getBindDetails()))
1794bool areVarsEqual(Expr *VarExpr1, Expr *VarExpr2) {
1807 auto *Expr2AS = dyn_cast<ArraySectionExpr>(VarExpr2);
1813 if (!areVarsEqual(Expr1AS->getBase(), Expr2AS->getBase()))
1822 auto *Expr2AS = dyn_cast<ArraySubscriptExpr>(VarExpr2);
1828 if (!areVarsEqual(Expr1AS->getBase(), Expr2AS->getBase()))
1839 auto *Expr2DRE = dyn_cast<DeclRefExpr>(VarExpr2);
1845 return Expr1DRE->getDecl()->getMostRecentDecl() ==
1846 Expr2DRE->getDecl()->getMostRecentDecl();
1849 llvm_unreachable(
"Unknown variable type encountered");
1859 if (DiagnoseAllowedClauses(Clause.getDirectiveKind(), Clause.getClauseKind(),
1860 Clause.getBeginLoc()))
1863 if (
const auto *DevTypeClause = llvm::find_if(
1864 ExistingClauses, llvm::IsaPred<OpenACCDeviceTypeClause>);
1865 DevTypeClause != ExistingClauses.end()) {
1866 if (checkValidAfterDeviceType(
1871 SemaOpenACCClauseVisitor Visitor{*
this, ExistingClauses};
1873 assert((!
Result ||
Result->getClauseKind() == Clause.getClauseKind()) &&
1874 "Created wrong clause?");
1904 << diag::OACCReductionArray::ArrayTy << CurType;
1905 Notes.push_back({VarLoc, PD});
1906 CurType = AT->getElementType();
1909 auto IsValidMemberOfComposite = [](
QualType Ty) {
1910 return !Ty->isAnyComplexType() &&
1911 (Ty->isDependentType() ||
1912 (Ty->isScalarType() && !Ty->isPointerType()));
1918 for (
auto [Loc, PD] : Notes)
1921 return Diag(VarLoc, diag::note_acc_reduction_type_summary);
1925 if (IsValidMemberOfComposite(CurType)) {
1928 if (!RD->isStruct() && !RD->isClass())
1929 return EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1931 << diag::OACCReductionTy::NotClassStruct);
1933 if (!RD->isCompleteDefinition())
1934 return EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1935 << RD << diag::OACCReductionTy::NotComplete);
1937 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
1938 CXXRD && !CXXRD->isAggregate())
1939 return EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1940 << CXXRD << diag::OACCReductionTy::NotAgg);
1943 if (!IsValidMemberOfComposite(FD->getType())) {
1945 PDiag(diag::note_acc_reduction_member_of_composite)
1946 << FD->getName() << RD->getName();
1947 Notes.push_back({FD->getBeginLoc(), PD});
1949 return EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1951 << diag::OACCReductionTy::MemberNotScalar);
1955 return EmitDiags(VarLoc,
PDiag(diag::err_acc_reduction_type)
1957 << diag::OACCReductionTy::NotScalar);
1985 if (RClause->getReductionOp() == ReductionOp)
1988 for (
Expr *OldVarExpr : RClause->getVarList()) {
1989 if (OldVarExpr->isInstantiationDependent())
1992 if (areVarsEqual(VarExpr, OldVarExpr)) {
1994 << ReductionOp << RClause->getReductionOp();
1995 Diag(OldVarExpr->getExprLoc(), diag::note_acc_previous_clause_here)
1996 << RClause->getClauseKind();
2012 "size argument non integer?");
2019 std::optional<llvm::APSInt> ICE =
2024 if (!ICE || *ICE <= 0) {
2026 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
2040 "Loop argument non integer?");
2046 std::optional<llvm::APSInt> ICE =
2052 if (!ICE || *ICE <= 0) {
2054 << ICE.has_value() << ICE.value_or(llvm::APSInt{}).getExtValue();
2072 return CheckGangParallelExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2075 return CheckGangSerialExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2078 return CheckGangKernelsExpr(*
this, ExistingClauses, DK,
2079 ActiveComputeConstructInfo.Kind, GK, E);
2081 return CheckGangRoutineExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2084 switch (ActiveComputeConstructInfo.Kind) {
2088 return CheckGangParallelExpr(*
this, DK, ActiveComputeConstructInfo.Kind,
2092 return CheckGangSerialExpr(*
this, DK, ActiveComputeConstructInfo.Kind, GK,
2096 return CheckGangKernelsExpr(*
this, ExistingClauses, DK,
2097 ActiveComputeConstructInfo.Kind, GK, E);
2099 llvm_unreachable(
"Non compute construct in active compute construct?");
2108 llvm_unreachable(
"Invalid directive kind for a Gang clause");
2110 llvm_unreachable(
"Compute construct directive not handled?");
2124 const auto *ReductionItr =
2125 llvm::find_if(ExistingClauses, llvm::IsaPred<OpenACCReductionClause>);
2127 if (ReductionItr != ExistingClauses.end()) {
2128 const auto GangZip = llvm::zip_equal(GangKinds, IntExprs);
2129 const auto GangItr = llvm::find_if(GangZip, [](
const auto &Tuple) {
2133 if (GangItr != GangZip.end()) {
2134 const Expr *DimExpr = std::get<1>(*GangItr);
2138 "Improperly formed gang argument");
2139 if (
const auto *DimVal = dyn_cast<ConstantExpr>(DimExpr);
2140 DimVal && DimVal->getResultAsAPSInt() > 1) {
2141 Diag(DimVal->getBeginLoc(), diag::err_acc_gang_reduction_conflict)
2143 Diag((*ReductionItr)->getBeginLoc(),
2144 diag::note_acc_previous_clause_here)
2145 << (*ReductionItr)->getClauseKind();
2153 GangKinds, IntExprs, EndLoc);
2167 const auto GangClauses = llvm::make_filter_range(
2168 ExistingClauses, llvm::IsaPred<OpenACCGangClause>);
2170 for (
auto *GC : GangClauses) {
2172 for (
unsigned I = 0; I < GangClause->getNumExprs(); ++I) {
2173 std::pair<OpenACCGangKind, const Expr *> EPair = GangClause->getExpr(I);
2177 if (
const auto *DimVal = dyn_cast<ConstantExpr>(EPair.second);
2178 DimVal && DimVal->getResultAsAPSInt() > 1) {
2179 Diag(BeginLoc, diag::err_acc_gang_reduction_conflict)
2180 << 1 << DirectiveKind;
2181 Diag(GangClause->getBeginLoc(), diag::note_acc_previous_clause_here)
2182 << GangClause->getClauseKind();
2190 getASTContext(), BeginLoc, LParenLoc, ReductionOp, Vars, Recipes, EndLoc);
2205 for (
Expr *VarExpr : VarExprs) {
2207 NewVarList.push_back(VarExpr);
2216 NewVarList.push_back(VarExpr);
2220 Expr *OrigExpr = VarExpr;
2223 if (
auto *ASE = dyn_cast<ArraySectionExpr>(VarExpr))
2224 VarExpr = ASE->getBase()->IgnoreParenImpCasts();
2231 const VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl());
2234 Diag(VarExpr->getBeginLoc(), diag::err_acc_link_not_extern);
2236 NewVarList.push_back(OrigExpr);
2251 bool IsSpecialClause =
2263 return Diag(Clause.getBeginLoc(), diag::err_acc_declare_clause_at_global)
2264 << Clause.getClauseKind();
2269 for (
Expr *VarExpr : Clause.getVarList()) {
2273 }
else if (
const auto *MemExpr = dyn_cast<MemberExpr>(VarExpr)) {
2278 if (removeLinkageSpecDC(
2280 Diag(MemExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2281 << Clause.getClauseKind();
2286 const Expr *VarExprTemp = VarExpr;
2288 while (
const auto *ASE = dyn_cast<ArraySectionExpr>(VarExprTemp))
2292 if (
const auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
2302 if (removeLinkageSpecDC(
2303 Var->getLexicalDeclContext()->getPrimaryContext()) != DC) {
2304 Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2305 << Clause.getClauseKind();
2312 if (!IsSpecialClause && Var->hasExternalStorage()) {
2313 Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_extern)
2314 << Clause.getClauseKind();
2324 auto [Itr, Inserted] = DeclareVarReferences.try_emplace(CurDecl);
2326 Diag(VarExpr->getBeginLoc(), diag::err_acc_multiple_references)
2327 << Clause.getClauseKind();
2328 Diag(Itr->second, diag::note_acc_previous_reference);
2331 Itr->second = VarExpr->getBeginLoc();
2335 FilteredVarList.push_back(VarExpr);
2338 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 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.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo * getIdentifierInfo() const
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.
ArrayRef< DeviceTypeArgument > getArchitectures() const
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< OpenACCReductionRecipeWithStorage > 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.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ASTContext & getASTContext() const
DeclContext * getCurContext() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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()
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'.
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)
bool CheckReductionVarType(Expr *VarExpr)
OpenACCClause * CheckReductionClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCDirectiveKind DirectiveKind, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCReductionOperator ReductionOp, ArrayRef< Expr * > Vars, ArrayRef< OpenACCReductionRecipeWithStorage > Recipes, SourceLocation EndLoc)
ExprResult CheckTileSizeExpr(Expr *SizeExpr)
Checks a single size expr for a tile clause.
OpenACCReductionRecipeWithStorage CreateReductionInitRecipe(OpenACCReductionOperator ReductionOperator, const Expr *VarExpr)
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
OpenACCDirectiveKind DirKind