;
29enum classOpenACCDirectiveKindEx {
30 Invalid=
static_cast<int>(OpenACCDirectiveKind::Invalid),
41OpenACCDirectiveKindEx getOpenACCDirectiveKind(
TokenTok) {
42 if(!Tok.
is(tok::identifier))
43 returnOpenACCDirectiveKindEx::Invalid;
45llvm::StringSwitch<OpenACCDirectiveKind>(
47.Case(
"parallel", OpenACCDirectiveKind::Parallel)
48.Case(
"serial", OpenACCDirectiveKind::Serial)
49.Case(
"kernels", OpenACCDirectiveKind::Kernels)
50.Case(
"data", OpenACCDirectiveKind::Data)
51.Case(
"host_data", OpenACCDirectiveKind::HostData)
52.Case(
"loop", OpenACCDirectiveKind::Loop)
53.Case(
"cache", OpenACCDirectiveKind::Cache)
54.Case(
"atomic", OpenACCDirectiveKind::Atomic)
55.Case(
"routine", OpenACCDirectiveKind::Routine)
56.Case(
"declare", OpenACCDirectiveKind::Declare)
57.Case(
"init", OpenACCDirectiveKind::Init)
58.Case(
"shutdown", OpenACCDirectiveKind::Shutdown)
59.Case(
"set", OpenACCDirectiveKind::Set)
60.Case(
"update", OpenACCDirectiveKind::Update)
61.Case(
"wait", OpenACCDirectiveKind::Wait)
62.Default(OpenACCDirectiveKind::Invalid);
64 if(DirKind != OpenACCDirectiveKind::Invalid)
65 return static_cast<OpenACCDirectiveKindEx
>(DirKind);
67 returnllvm::StringSwitch<OpenACCDirectiveKindEx>(
69.Case(
"enter", OpenACCDirectiveKindEx::Enter)
70.Case(
"exit", OpenACCDirectiveKindEx::Exit)
71.Default(OpenACCDirectiveKindEx::Invalid);
78 if(Tok.
is(tok::kw_auto))
79 returnOpenACCClauseKind::Auto;
82 if(Tok.
is(tok::kw_default))
83 returnOpenACCClauseKind::Default;
86 if(Tok.
is(tok::kw_if))
87 returnOpenACCClauseKind::If;
90 if(Tok.
is(tok::kw_private))
91 returnOpenACCClauseKind::Private;
94 if(Tok.
is(tok::kw_delete))
95 returnOpenACCClauseKind::Delete;
97 if(!Tok.
is(tok::identifier))
98 returnOpenACCClauseKind::Invalid;
100 returnllvm::StringSwitch<OpenACCClauseKind>(
102.Case(
"async", OpenACCClauseKind::Async)
103.Case(
"attach", OpenACCClauseKind::Attach)
104.Case(
"auto", OpenACCClauseKind::Auto)
105.Case(
"bind", OpenACCClauseKind::Bind)
106.Case(
"create", OpenACCClauseKind::Create)
107.Case(
"pcreate", OpenACCClauseKind::PCreate)
108.Case(
"present_or_create", OpenACCClauseKind::PresentOrCreate)
109.Case(
"collapse", OpenACCClauseKind::Collapse)
110.Case(
"copy", OpenACCClauseKind::Copy)
111.Case(
"pcopy", OpenACCClauseKind::PCopy)
112.Case(
"present_or_copy", OpenACCClauseKind::PresentOrCopy)
113.Case(
"copyin", OpenACCClauseKind::CopyIn)
114.Case(
"pcopyin", OpenACCClauseKind::PCopyIn)
115.Case(
"present_or_copyin", OpenACCClauseKind::PresentOrCopyIn)
116.Case(
"copyout", OpenACCClauseKind::CopyOut)
117.Case(
"pcopyout", OpenACCClauseKind::PCopyOut)
118.Case(
"present_or_copyout", OpenACCClauseKind::PresentOrCopyOut)
119.Case(
"default", OpenACCClauseKind::Default)
120.Case(
"default_async", OpenACCClauseKind::DefaultAsync)
121.Case(
"delete", OpenACCClauseKind::Delete)
122.Case(
"detach", OpenACCClauseKind::Detach)
123.Case(
"device", OpenACCClauseKind::Device)
124.Case(
"device_num", OpenACCClauseKind::DeviceNum)
125.Case(
"device_resident", OpenACCClauseKind::DeviceResident)
126.Case(
"device_type", OpenACCClauseKind::DeviceType)
127.Case(
"deviceptr", OpenACCClauseKind::DevicePtr)
128.Case(
"dtype", OpenACCClauseKind::DType)
129.Case(
"finalize", OpenACCClauseKind::Finalize)
130.Case(
"firstprivate", OpenACCClauseKind::FirstPrivate)
131.Case(
"gang", OpenACCClauseKind::Gang)
132.Case(
"host", OpenACCClauseKind::Host)
133.Case(
"if", OpenACCClauseKind::If)
134.Case(
"if_present", OpenACCClauseKind::IfPresent)
135.Case(
"independent", OpenACCClauseKind::Independent)
136.Case(
"link", OpenACCClauseKind::Link)
137.Case(
"no_create", OpenACCClauseKind::NoCreate)
138.Case(
"num_gangs", OpenACCClauseKind::NumGangs)
139.Case(
"num_workers", OpenACCClauseKind::NumWorkers)
140.Case(
"nohost", OpenACCClauseKind::NoHost)
141.Case(
"present", OpenACCClauseKind::Present)
142.Case(
"private", OpenACCClauseKind::Private)
143.Case(
"reduction", OpenACCClauseKind::Reduction)
144.Case(
"self", OpenACCClauseKind::Self)
145.Case(
"seq", OpenACCClauseKind::Seq)
146.Case(
"tile", OpenACCClauseKind::Tile)
147.Case(
"use_device", OpenACCClauseKind::UseDevice)
148.Case(
"vector", OpenACCClauseKind::Vector)
149.Case(
"vector_length", OpenACCClauseKind::VectorLength)
150.Case(
"wait", OpenACCClauseKind::Wait)
151.Case(
"worker", OpenACCClauseKind::Worker)
152.Default(OpenACCClauseKind::Invalid);
158 if(!Tok.
is(tok::identifier))
159 returnOpenACCAtomicKind::Invalid;
160 returnllvm::StringSwitch<OpenACCAtomicKind>(
162.Case(
"read", OpenACCAtomicKind::Read)
163.Case(
"write", OpenACCAtomicKind::Write)
164.Case(
"update", OpenACCAtomicKind::Update)
165.Case(
"capture", OpenACCAtomicKind::Capture)
166.Default(OpenACCAtomicKind::Invalid);
170 if(!Tok.
is(tok::identifier))
171 returnOpenACCDefaultClauseKind::Invalid;
173 returnllvm::StringSwitch<OpenACCDefaultClauseKind>(
175.Case(
"none", OpenACCDefaultClauseKind::None)
176.Case(
"present", OpenACCDefaultClauseKind::Present)
177.Default(OpenACCDefaultClauseKind::Invalid);
180enum classOpenACCSpecialTokenKind {
192boolisOpenACCSpecialToken(OpenACCSpecialTokenKind Kind,
TokenTok) {
193 if(Tok.
is(tok::kw_static) && Kind == OpenACCSpecialTokenKind::Static)
196 if(!Tok.
is(tok::identifier))
200 caseOpenACCSpecialTokenKind::ReadOnly:
202 caseOpenACCSpecialTokenKind::DevNum:
204 caseOpenACCSpecialTokenKind::Queues:
206 caseOpenACCSpecialTokenKind::Zero:
208 caseOpenACCSpecialTokenKind::Force:
210 caseOpenACCSpecialTokenKind::Num:
212 caseOpenACCSpecialTokenKind::Length:
214 caseOpenACCSpecialTokenKind::Dim:
216 caseOpenACCSpecialTokenKind::Static:
219llvm_unreachable(
"Unknown 'Kind' Passed");
225boolisTokenIdentifierOrKeyword(
Parser&
P,
TokenTok) {
226 if(Tok.
is(tok::identifier))
241template<
typenameDirOrClauseTy>
242booltryParseAndConsumeSpecialTokenKind(
Parser&
P, OpenACCSpecialTokenKind Kind,
243DirOrClauseTy DirOrClause) {
244 TokenIdentTok =
P.getCurToken();
247 if(isTokenIdentifierOrKeyword(
P, IdentTok) &&
P.NextToken().is(tok::colon)) {
251 if(!isOpenACCSpecialToken(Kind, IdentTok)) {
252 P.Diag(IdentTok, diag::err_acc_invalid_tag_kind)
254<< std::is_same_v<DirOrClauseTy, OpenACCClauseKind>;
265 if(!Tok.
is(tok::identifier))
269 caseOpenACCDirectiveKind::Parallel:
271 caseOpenACCDirectiveKind::Serial:
273 caseOpenACCDirectiveKind::Kernels:
275 caseOpenACCDirectiveKind::Data:
277 caseOpenACCDirectiveKind::HostData:
279 caseOpenACCDirectiveKind::Loop:
281 caseOpenACCDirectiveKind::Cache:
284 caseOpenACCDirectiveKind::ParallelLoop:
285 caseOpenACCDirectiveKind::SerialLoop:
286 caseOpenACCDirectiveKind::KernelsLoop:
287 caseOpenACCDirectiveKind::EnterData:
288 caseOpenACCDirectiveKind::ExitData:
291 caseOpenACCDirectiveKind::Atomic:
293 caseOpenACCDirectiveKind::Routine:
295 caseOpenACCDirectiveKind::Declare:
297 caseOpenACCDirectiveKind::Init:
299 caseOpenACCDirectiveKind::Shutdown:
301 caseOpenACCDirectiveKind::Set:
303 caseOpenACCDirectiveKind::Update:
305 caseOpenACCDirectiveKind::Wait:
307 caseOpenACCDirectiveKind::Invalid:
310llvm_unreachable(
"Unknown 'Kind' Passed");
317 if(
P.NextToken().isNot(tok::colon)) {
318 P.Diag(
P.getCurToken(), diag::err_acc_expected_reduction_operator);
319 returnOpenACCReductionOperator::Invalid;
321 TokenReductionKindTok =
P.getCurToken();
326 switch(ReductionKindTok.
getKind()) {
328 returnOpenACCReductionOperator::Addition;
330 returnOpenACCReductionOperator::Multiplication;
332 returnOpenACCReductionOperator::BitwiseAnd;
334 returnOpenACCReductionOperator::BitwiseOr;
336 returnOpenACCReductionOperator::BitwiseXOr;
338 returnOpenACCReductionOperator::And;
340 returnOpenACCReductionOperator::Or;
341 casetok::identifier:
343 returnOpenACCReductionOperator::Max;
345 returnOpenACCReductionOperator::Min;
348 P.Diag(ReductionKindTok, diag::err_acc_invalid_reduction_operator);
349 returnOpenACCReductionOperator::Invalid;
351llvm_unreachable(
"Reduction op token kind not caught by 'default'?");
356boolexpectIdentifierOrKeyword(
Parser&
P) {
357 TokenTok =
P.getCurToken();
359 if(isTokenIdentifierOrKeyword(
P, Tok))
362 P.Diag(
P.getCurToken(), diag::err_expected) << tok::identifier;
367ParseOpenACCEnterExitDataDirective(
Parser&
P,
TokenFirstTok,
368OpenACCDirectiveKindEx ExtDirKind) {
369 TokenSecondTok =
P.getCurToken();
372 P.Diag(FirstTok, diag::err_acc_invalid_directive)
374 returnOpenACCDirectiveKind::Invalid;
379 P.ConsumeAnyToken();
381 if(!isOpenACCDirectiveKind(OpenACCDirectiveKind::Data, SecondTok)) {
382 if(!SecondTok.
is(tok::identifier))
383 P.Diag(SecondTok, diag::err_expected) << tok::identifier;
385 P.Diag(FirstTok, diag::err_acc_invalid_directive)
388 returnOpenACCDirectiveKind::Invalid;
391 returnExtDirKind == OpenACCDirectiveKindEx::Enter
392? OpenACCDirectiveKind::EnterData
393: OpenACCDirectiveKind::ExitData;
397 TokenAtomicClauseToken =
P.getCurToken();
401 returnOpenACCAtomicKind::Update;
408 if(AtomicKind == OpenACCAtomicKind::Invalid)
409 returnOpenACCAtomicKind::Update;
417 TokenFirstTok =
P.getCurToken();
421 if(FirstTok.
isNot(tok::identifier)) {
422 P.Diag(FirstTok, diag::err_acc_missing_directive);
424 if(
P.getCurToken().isNot(tok::annot_pragma_openacc_end))
425 P.ConsumeAnyToken();
427 returnOpenACCDirectiveKind::Invalid;
432OpenACCDirectiveKindEx ExDirKind = getOpenACCDirectiveKind(FirstTok);
440 if(ExDirKind >= OpenACCDirectiveKindEx::Invalid) {
442 caseOpenACCDirectiveKindEx::Invalid: {
443 P.Diag(FirstTok, diag::err_acc_invalid_directive)
445 returnOpenACCDirectiveKind::Invalid;
447 caseOpenACCDirectiveKindEx::Enter:
448 caseOpenACCDirectiveKindEx::Exit:
449 returnParseOpenACCEnterExitDataDirective(
P, FirstTok, ExDirKind);
458 TokenSecondTok =
P.getCurToken();
460isOpenACCDirectiveKind(OpenACCDirectiveKind::Loop, SecondTok)) {
466 caseOpenACCDirectiveKind::Parallel:
468 returnOpenACCDirectiveKind::ParallelLoop;
469 caseOpenACCDirectiveKind::Serial:
471 returnOpenACCDirectiveKind::SerialLoop;
472 caseOpenACCDirectiveKind::Kernels:
474 returnOpenACCDirectiveKind::KernelsLoop;
481enumClauseParensKind {
490 caseOpenACCClauseKind::Self:
491 returnDirKind == OpenACCDirectiveKind::Update ? ClauseParensKind::Required
492: ClauseParensKind::Optional;
493 caseOpenACCClauseKind::Async:
494 caseOpenACCClauseKind::Worker:
495 caseOpenACCClauseKind::Vector:
496 caseOpenACCClauseKind::Gang:
497 caseOpenACCClauseKind::Wait:
498 returnClauseParensKind::Optional;
500 caseOpenACCClauseKind::Default:
501 caseOpenACCClauseKind::If:
502 caseOpenACCClauseKind::Create:
503 caseOpenACCClauseKind::PCreate:
504 caseOpenACCClauseKind::PresentOrCreate:
505 caseOpenACCClauseKind::Copy:
506 caseOpenACCClauseKind::PCopy:
507 caseOpenACCClauseKind::PresentOrCopy:
508 caseOpenACCClauseKind::CopyIn:
509 caseOpenACCClauseKind::PCopyIn:
510 caseOpenACCClauseKind::PresentOrCopyIn:
511 caseOpenACCClauseKind::CopyOut:
512 caseOpenACCClauseKind::PCopyOut:
513 caseOpenACCClauseKind::PresentOrCopyOut:
514 caseOpenACCClauseKind::UseDevice:
515 caseOpenACCClauseKind::NoCreate:
516 caseOpenACCClauseKind::Present:
517 caseOpenACCClauseKind::DevicePtr:
518 caseOpenACCClauseKind::Attach:
519 caseOpenACCClauseKind::Detach:
520 caseOpenACCClauseKind::Private:
521 caseOpenACCClauseKind::FirstPrivate:
522 caseOpenACCClauseKind::Delete:
523 caseOpenACCClauseKind::DeviceResident:
524 caseOpenACCClauseKind::Device:
525 caseOpenACCClauseKind::Link:
526 caseOpenACCClauseKind::Host:
527 caseOpenACCClauseKind::Reduction:
528 caseOpenACCClauseKind::Collapse:
529 caseOpenACCClauseKind::Bind:
530 caseOpenACCClauseKind::VectorLength:
531 caseOpenACCClauseKind::NumGangs:
532 caseOpenACCClauseKind::NumWorkers:
533 caseOpenACCClauseKind::DeviceNum:
534 caseOpenACCClauseKind::DefaultAsync:
535 caseOpenACCClauseKind::DeviceType:
536 caseOpenACCClauseKind::DType:
537 caseOpenACCClauseKind::Tile:
538 returnClauseParensKind::Required;
540 caseOpenACCClauseKind::Auto:
541 caseOpenACCClauseKind::Finalize:
542 caseOpenACCClauseKind::IfPresent:
543 caseOpenACCClauseKind::Independent:
544 caseOpenACCClauseKind::Invalid:
545 caseOpenACCClauseKind::NoHost:
546 caseOpenACCClauseKind::Seq:
547 returnClauseParensKind::None;
549llvm_unreachable(
"Unhandled clause kind");
554 returngetClauseParensKind(DirKind, Kind) == ClauseParensKind::Optional;
559 returngetClauseParensKind(DirKind, Kind) == ClauseParensKind::Required;
566voidSkipUntilEndOfDirective(
Parser&
P) {
567 while(
P.getCurToken().isNot(tok::annot_pragma_openacc_end))
568 P.ConsumeAnyToken();
574 caseOpenACCDirectiveKind::EnterData:
575 caseOpenACCDirectiveKind::ExitData:
576 caseOpenACCDirectiveKind::Wait:
577 caseOpenACCDirectiveKind::Init:
578 caseOpenACCDirectiveKind::Shutdown:
580 caseOpenACCDirectiveKind::Parallel:
581 caseOpenACCDirectiveKind::Serial:
582 caseOpenACCDirectiveKind::Kernels:
583 caseOpenACCDirectiveKind::ParallelLoop:
584 caseOpenACCDirectiveKind::SerialLoop:
585 caseOpenACCDirectiveKind::KernelsLoop:
586 caseOpenACCDirectiveKind::Loop:
587 caseOpenACCDirectiveKind::Data:
588 caseOpenACCDirectiveKind::HostData:
591llvm_unreachable(
"Unhandled directive->assoc stmt");
596 caseOpenACCDirectiveKind::Parallel:
597 caseOpenACCDirectiveKind::Serial:
598 caseOpenACCDirectiveKind::Kernels:
599 caseOpenACCDirectiveKind::ParallelLoop:
600 caseOpenACCDirectiveKind::SerialLoop:
601 caseOpenACCDirectiveKind::KernelsLoop:
606 caseOpenACCDirectiveKind::Data:
607 caseOpenACCDirectiveKind::EnterData:
608 caseOpenACCDirectiveKind::ExitData:
609 caseOpenACCDirectiveKind::HostData:
610 caseOpenACCDirectiveKind::Wait:
611 caseOpenACCDirectiveKind::Init:
612 caseOpenACCDirectiveKind::Shutdown:
614 caseOpenACCDirectiveKind::Invalid:
615llvm_unreachable(
"Shouldn't be creating a scope for an invalid construct");
624Parser::OpenACCClauseParseResult Parser::OpenACCCanContinue() {
625 return{
nullptr, OpenACCParseCanContinue::Can};
628Parser::OpenACCClauseParseResult Parser::OpenACCCannotContinue() {
629 return{
nullptr, OpenACCParseCanContinue::Cannot};
632Parser::OpenACCClauseParseResult Parser::OpenACCSuccess(
OpenACCClause*Clause) {
633 return{Clause, OpenACCParseCanContinue::Can};
636ExprResultParser::ParseOpenACCConditionExpr() {
661 boolFirstClause =
true;
662 while(
getCurToken().isNot(tok::annot_pragma_openacc_end)) {
666FirstClause =
false;
668OpenACCClauseParseResult
Result= ParseOpenACCClause(Clauses, DirKind);
670Clauses.push_back(Clause);
671}
else if(
Result.getInt() == OpenACCParseCanContinue::Cannot) {
674SkipUntilEndOfDirective(*
this);
681Parser::OpenACCIntExprParseResult
689 return{ER, OpenACCParseCanContinue::Cannot};
695 return{ER, OpenACCParseCanContinue::Can};
698OpenACCParseCanContinue::Can};
704OpenACCIntExprParseResult CurResult = ParseOpenACCIntExpr(DK, CK,
Loc);
706 if(!CurResult.first.isUsable() &&
707CurResult.second == OpenACCParseCanContinue::Cannot) {
708 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
713IntExprs.push_back(CurResult.first.get());
716ExpectAndConsume(tok::comma);
718CurResult = ParseOpenACCIntExpr(DK, CK,
Loc);
720 if(!CurResult.first.isUsable() &&
721CurResult.second == OpenACCParseCanContinue::Cannot) {
722 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
726IntExprs.push_back(CurResult.first.get());
740boolParser::ParseOpenACCDeviceTypeList(
743 if(expectIdentifierOrKeyword(*
this)) {
744 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
752ExpectAndConsume(tok::comma);
754 if(expectIdentifierOrKeyword(*
this)) {
755 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
776tok::annot_pragma_openacc_end)) {
794boolParser::ParseOpenACCSizeExprList(
796 ExprResultSizeExpr = ParseOpenACCSizeExpr(CK);
798 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
803SizeExprs.push_back(SizeExpr.
get());
806ExpectAndConsume(tok::comma);
808SizeExpr = ParseOpenACCSizeExpr(CK);
810 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
814SizeExprs.push_back(SizeExpr.
get());
825Parser::OpenACCGangArgRes Parser::ParseOpenACCGangArg(
SourceLocationGangLoc) {
827 if(isOpenACCSpecialToken(OpenACCSpecialTokenKind::Static,
getCurToken()) &&
836 if(isOpenACCSpecialToken(OpenACCSpecialTokenKind::Dim,
getCurToken()) &&
847 if(isOpenACCSpecialToken(OpenACCSpecialTokenKind::Num,
getCurToken()) &&
861boolParser::ParseOpenACCGangArgList(
865Parser::OpenACCGangArgRes Res = ParseOpenACCGangArg(GangLoc);
866 if(!Res.second.isUsable()) {
867 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
872GKs.push_back(Res.first);
873IntExprs.push_back(Res.second.get());
876ExpectAndConsume(tok::comma);
878Res = ParseOpenACCGangArg(GangLoc);
879 if(!Res.second.isUsable()) {
880 SkipUntil(tok::r_paren, tok::annot_pragma_openacc_end,
885GKs.push_back(Res.first);
886IntExprs.push_back(Res.second.get());
896Parser::OpenACCClauseParseResult
901 if(expectIdentifierOrKeyword(*
this))
902 returnOpenACCCannotContinue();
909 returnOpenACCCannotContinue();
915 returnParseOpenACCClauseParams(ExistingClauses, DirKind, Kind, ClauseLoc);
918Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
923tok::annot_pragma_openacc_end);
926 if(ClauseHasRequiredParens(DirKind, ClauseKind)) {
927 if(
Parens.expectAndConsume()) {
931 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openacc_end,
933 returnOpenACCCanContinue();
937 switch(ClauseKind) {
941 if(expectIdentifierOrKeyword(*
this)) {
943 returnOpenACCCanContinue();
949getOpenACCDefaultClauseKind(DefKindTok);
952 Diag(DefKindTok, diag::err_acc_invalid_default_clause_kind);
954 returnOpenACCCanContinue();
961 ExprResultCondExpr = ParseOpenACCConditionExpr();
967 returnOpenACCCanContinue();
975 boolIsReadOnly = tryParseAndConsumeSpecialTokenKind(
976*
this, OpenACCSpecialTokenKind::ReadOnly, ClauseKind);
988 boolIsZero = tryParseAndConsumeSpecialTokenKind(
989*
this, OpenACCSpecialTokenKind::Zero, ClauseKind);
1014ParseOpenACCVarList(ClauseKind);
1035 boolHasForce = tryParseAndConsumeSpecialTokenKind(
1036*
this, OpenACCSpecialTokenKind::Force, ClauseKind);
1041 returnOpenACCCanContinue();
1050 returnOpenACCCanContinue();
1057 ExprResultBindArg = ParseOpenACCBindClauseArgument();
1060 returnOpenACCCanContinue();
1071 returnOpenACCCanContinue();
1081ClauseKind, ClauseLoc)
1085 returnOpenACCCanContinue();
1098}
else if(!ParseOpenACCDeviceTypeList(Archs)) {
1102 returnOpenACCCanContinue();
1110 returnOpenACCCanContinue();
1117llvm_unreachable(
"Not a required parens type?");
1122 if(
Parens.consumeClose())
1123 returnOpenACCCannotContinue();
1125}
else if(ClauseHasOptionalParens(DirKind, ClauseKind)) {
1126 if(!
Parens.consumeOpen()) {
1128 switch(ClauseKind) {
1131 ExprResultCondExpr = ParseOpenACCConditionExpr();
1137 returnOpenACCCanContinue();
1143tryParseAndConsumeSpecialTokenKind(*
this,
1146? OpenACCSpecialTokenKind::Length
1147: OpenACCSpecialTokenKind::Num,
1150ClauseKind, ClauseLoc)
1154 returnOpenACCCanContinue();
1168 returnOpenACCCanContinue();
1175 if(ParseOpenACCGangArgList(ClauseLoc, GKs, IntExprs)) {
1177 returnOpenACCCanContinue();
1179ParsedClause.
setGangDetails(std::move(GKs), std::move(IntExprs));
1183OpenACCWaitParseInfo Info =
1184ParseOpenACCWaitArgument(ClauseLoc,
1188 returnOpenACCCanContinue();
1192std::move(Info.QueueIdExprs));
1196llvm_unreachable(
"Not an optional parens type?");
1199 if(
Parens.consumeClose())
1200 returnOpenACCCannotContinue();
1209 returnOpenACCSuccess(
1220Parser::OpenACCIntExprParseResult
1223 returnParseOpenACCIntExpr(DK, CK,
Loc);
1230Parser::OpenACCWaitParseInfo
1232OpenACCWaitParseInfo
Result;
1234 if(isOpenACCSpecialToken(OpenACCSpecialTokenKind::DevNum, Tok) &&
1241OpenACCIntExprParseResult Res = ParseOpenACCIntExpr(
1246 if(Res.first.isInvalid() &&
1247Res.second == OpenACCParseCanContinue::Cannot) {
1252 if(ExpectAndConsume(tok::colon)) {
1257 Result.DevNumExpr = Res.first.get();
1261 if(isOpenACCSpecialToken(OpenACCSpecialTokenKind::Queues, Tok) &&
1273 boolFirstArg =
true;
1276 if(ExpectAndConsume(tok::comma)) {
1283OpenACCIntExprParseResult Res = ParseOpenACCAsyncArgument(
1289 if(Res.first.isInvalid() &&
1290Res.second == OpenACCParseCanContinue::Cannot) {
1295 if(Res.first.isUsable())
1296 Result.QueueIdExprs.push_back(Res.first.get());
1302ExprResultParser::ParseOpenACCIDExpression() {
1305Res = ParseCXXIdExpression(
true);
1310 if(Tok.
isNot(tok::identifier)) {
1311 Diag(Tok, diag::err_expected) << tok::identifier;
1332ExprResultParser::ParseOpenACCBindClauseArgument() {
1348 returnParseOpenACCIDExpression();
1359OpenACCArraySectionRAII ArraySections(*
this);
1363 return{Res, OpenACCParseCanContinue::Cannot};
1367 return{Res, OpenACCParseCanContinue::Can};
1371 return{Res, OpenACCParseCanContinue::Can};
1377 auto[Res, CanContinue] = ParseOpenACCVar(CK);
1379Vars.push_back(Res.
get());
1380}
else if(CanContinue == OpenACCParseCanContinue::Cannot) {
1386ExpectAndConsume(tok::comma);
1388 auto[Res, CanContinue] = ParseOpenACCVar(CK);
1391Vars.push_back(Res.
get());
1392}
else if(CanContinue == OpenACCParseCanContinue::Cannot) {
1404voidParser::ParseOpenACCCacheVarList() {
1413 if(tryParseAndConsumeSpecialTokenKind(*
this,
1414OpenACCSpecialTokenKind::ReadOnly,
1425Parser::OpenACCDirectiveParseInfo
1426Parser::ParseOpenACCDirective() {
1430Parser::OpenACCWaitParseInfo WaitInfo;
1438ParseOpenACCAtomicKind(*
this);
1443tok::annot_pragma_openacc_end);
1445 if(!
T.consumeOpen()) {
1448 Diag(
T.getOpenLocation(), diag::err_acc_invalid_open_paren);
1454 ExprResultRoutineName = ParseOpenACCIDExpression();
1464ParseOpenACCCacheVarList();
1471WaitInfo = ParseOpenACCWaitArgument(DirLoc,
true);
1472 if(WaitInfo.Failed)
1482 Diag(Tok, diag::err_expected) << tok::l_paren;
1486OpenACCDirectiveParseInfo ParseInfo{DirKind,
1489 T.getOpenLocation(),
1490 T.getCloseLocation(),
1493WaitInfo.getAllExprs(),
1494ParseOpenACCClauseList(DirKind)};
1496assert(Tok.
is(tok::annot_pragma_openacc_end) &&
1497 "Didn't parse all OpenACC Clauses");
1498ParseInfo.EndLoc = ConsumeAnnotationToken();
1499assert(ParseInfo.EndLoc.isValid() &&
1500 "Terminating annotation token not present");
1507assert(Tok.
is(tok::annot_pragma_openacc) &&
"expected OpenACC Start Token");
1511OpenACCDirectiveParseInfo DirInfo = ParseOpenACCDirective();
1513 if(
getActions().OpenACC().ActOnStartDeclDirective(DirInfo.DirKind,
1523assert(Tok.
is(tok::annot_pragma_openacc) &&
"expected OpenACC Start Token");
1527OpenACCDirectiveParseInfo DirInfo = ParseOpenACCDirective();
1528 if(
getActions().OpenACC().ActOnStartStmtDirective(
1529DirInfo.DirKind, DirInfo.StartLoc, DirInfo.Clauses))
1533 if(doesDirectiveHaveAssociatedStmt(DirInfo.DirKind)) {
1535 getActions().OpenACC(), DirInfo.DirKind, DirInfo.DirLoc, {},
1538 ParseScopeACCScope(
this, getOpenACCScopeFlags(DirInfo.DirKind));
1541DirInfo.StartLoc, DirInfo.DirKind, DirInfo.Clauses, ParseStatement());
1545DirInfo.DirKind, DirInfo.StartLoc, DirInfo.DirLoc, DirInfo.LParenLoc,
1546DirInfo.MiscLoc, DirInfo.Exprs, DirInfo.RParenLoc, DirInfo.EndLoc,
1547DirInfo.Clauses, AssocStmt);
static Decl::Kind getKind(const Decl *D)
Defines some OpenACC-specific enums and functions.
static constexpr bool isOneOf()
This file declares semantic analysis for OpenACC constructs and clauses.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Represents a C++ nested-name-specifier or a global scope specifier.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
One of these records is kept for each identifier that is lexed.
bool isKeyword(const LangOptions &LangOpts) const
Return true if this token is a keyword in the specified language.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
Wrapper for void* pointer.
static OpaquePtr make(PtrTy P)
This is the base type for all OpenACC Clauses.
ParseScope - Introduces a new scope for parsing.
Parser - This implements a parser for the C family of languages.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
DeclGroupPtrTy ParseOpenACCDirectiveDecl()
Placeholder for now, should just ignore the directives after emitting a diagnostic.
Sema & getActions() const
ExprResult ParseConstantExpression()
StmtResult ParseOpenACCDirectiveStmt()
Scope * getCurScope() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
const Token & getCurToken() const
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
Activates OpenACC parsing mode to preseve OpenACC specific annotation tokens.
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
@ OpenACCComputeConstructScope
This is the scope of an OpenACC Compute Construct, which restricts jumping into/out of it.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
void setLParenLoc(SourceLocation EndLoc)
void setConditionDetails(Expr *ConditionExpr)
void setCollapseDetails(bool IsForce, Expr *LoopCount)
void setGangDetails(ArrayRef< OpenACCGangKind > GKs, ArrayRef< Expr * > IntExprs)
void setReductionDetails(OpenACCReductionOperator Op, llvm::SmallVector< Expr * > &&VarList)
void setDefaultDetails(OpenACCDefaultClauseKind DefKind)
void setVarListDetails(ArrayRef< Expr * > VarList, bool IsReadOnly, bool IsZero)
void setWaitDetails(Expr *DevNum, SourceLocation QueuesLoc, llvm::SmallVector< Expr * > &&IntExprs)
void setEndLoc(SourceLocation EndLoc)
void setIntExprDetails(ArrayRef< Expr * > IntExprs)
void setDeviceTypeDetails(llvm::SmallVector< DeviceTypeArgument > &&Archs)
ExprResult ActOnVar(OpenACCClauseKind CK, Expr *VarExpr)
Called when encountering a 'var' for OpenACC, ensures it is actually a declaration reference to a var...
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 * ActOnClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCParsedClause &Clause)
Called after parsing an OpenACC Clause so that it can be checked.
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnConstruct(OpenACCDirectiveKind K, SourceLocation DirLoc)
Called after the construct has been parsed, but clauses haven't been parsed.
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
StmtResult ActOnAssociatedStmt(SourceLocation DirectiveLoc, OpenACCDirectiveKind K, ArrayRef< const OpenACCClause * > Clauses, StmtResult AssocStmt)
Called when we encounter an associated statement for our construct, this should check legality of the...
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
Encodes a location in the source.
SourceLocation getBeginLoc() const LLVM_READONLY
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
Represents a C++ unqualified-id that has been parsed.
bool Zero(InterpState &S, CodePtr OpPC)
bool isStringLiteral(TokenKind K)
Return true if this is a C or C++ string-literal (or C++11 user-defined-string-literal) token.
bool isAnnotation(TokenKind K)
Return true if this is any of tok::annot_* kinds.
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ 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'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ 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.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ 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',...
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ Attach
'attach' clause, allowed on Compute and Combined constructs, plus 'data' and 'enter data'.
@ NumGangs
'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Default
'default' clause, allowed on parallel, serial, kernel (and compound) constructs.
@ UseDevice
'use_device' clause, allowed on 'host_data' construct.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ PresentOrCopyOut
'copyout' clause alias 'present_or_copyout'.
@ Link
'link' clause, allowed on 'declare' construct.
@ Reduction
'reduction' clause, allowed on Parallel, Serial, Loop, and the combined constructs.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ CopyOut
'copyout' clause, allowed on Compute and Combined constructs, plus 'data', 'exit data',...
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ Host
'host' clause, allowed on 'update' construct.
@ PCopy
'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
@ Tile
'tile' clause, allowed on 'loop' and Combined constructs.
@ PCopyIn
'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
@ DeviceResident
'device_resident' clause, allowed on the 'declare' construct.
@ PCreate
'create' clause alias 'pcreate'. Preserved for diagnostic purposes.
@ Present
'present' clause, allowed on Compute and Combined constructs, plus 'data' and 'declare'.
@ 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',...
@ Device
'device' clause, allowed on the 'update' construct.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ Detach
'detach' clause, allowed on the 'exit data' construct.
@ Delete
'delete' clause, allowed on the 'exit data' construct.
@ PresentOrCopyIn
'copyin' clause alias 'present_or_copyin'.
@ Invalid
Not a valid option.
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ None
The alignment was not explicit in code.
@ Parens
New-expression has a C++98 paren-delimited initializer.
Diagnostic wrappers for TextAPI types for error reporting.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4