clang 22.0.0git
SemaOpenACC.h
Go to the documentation of this file.
1//===----- SemaOpenACC.h - Semantic Analysis for OpenACC constructs -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file declares semantic analysis for OpenACC constructs and
10/// clauses.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_SEMAOPENACC_H
15#define LLVM_CLANG_SEMA_SEMAOPENACC_H
16
17#include "clang/AST/DeclGroup.h"
20#include "clang/Basic/LLVM.h"
24#include "clang/Sema/SemaBase.h"
25#include "llvm/ADT/SmallVector.h"
26#include "llvm/Support/Compiler.h"
27#include <cassert>
28#include <optional>
29#include <utility>
30#include <variant>
31
32namespace clang {
33class IdentifierInfo;
34class OpenACCClause;
35class Scope;
36
37class SemaOpenACC : public SemaBase {
38public:
40 using RoutineRefListTy = std::pair<FunctionDecl *, OpenACCRoutineDecl *>;
41
42private:
43 // We save a list of routine clauses that refer to a different function(that
44 // is, routine-with-a-name) so that we can do the emission at the 'end'. We
45 // have to do this, since functions can be emitted before they are referenced,
46 // and the OpenACCRoutineDecl isn't necessarily emitted, as it might be in a
47 // function/etc. So we do these emits at the end of the TU.
49
50 struct ComputeConstructInfo {
51 /// Which type of compute construct we are inside of, which we can use to
52 /// determine whether we should add loops to the above collection. We can
53 /// also use it to diagnose loop construct clauses.
55 // If we have an active compute construct, stores the list of clauses we've
56 // prepared for it, so that we can diagnose limitations on child constructs.
58 } ActiveComputeConstructInfo;
59
60 bool isInComputeConstruct() const {
61 return ActiveComputeConstructInfo.Kind != OpenACCDirectiveKind::Invalid;
62 }
63
64 /// Certain clauses care about the same things that aren't specific to the
65 /// individual clause, but can be shared by a few, so store them here. All
66 /// require a 'no intervening constructs' rule, so we know they are all from
67 /// the same 'place'.
68 struct LoopCheckingInfo {
69 /// Records whether we've seen the top level 'for'. We already diagnose
70 /// later that the 'top level' is a for loop, so we use this to suppress the
71 /// 'collapse inner loop not a 'for' loop' diagnostic.
72 LLVM_PREFERRED_TYPE(bool)
73 unsigned TopLevelLoopSeen : 1;
74
75 /// Records whether this 'tier' of the loop has already seen a 'for' loop,
76 /// used to diagnose if there are multiple 'for' loops at any one level.
77 LLVM_PREFERRED_TYPE(bool)
78 unsigned CurLevelHasLoopAlready : 1;
79
80 } LoopInfo{/*TopLevelLoopSeen=*/false, /*CurLevelHasLoopAlready=*/false};
81
82 /// The 'collapse' clause requires quite a bit of checking while
83 /// parsing/instantiating its body, so this structure/object keeps all of the
84 /// necessary information as we do checking. This should rarely be directly
85 /// modified, and typically should be controlled by the RAII objects.
86 ///
87 /// Collapse has an 'N' count that makes it apply to a number of loops 'below'
88 /// it.
89 struct CollapseCheckingInfo {
90 const OpenACCCollapseClause *ActiveCollapse = nullptr;
91
92 /// This is a value that maintains the current value of the 'N' on the
93 /// current collapse, minus the depth that has already been traversed. When
94 /// there is not an active collapse, or a collapse whose depth we don't know
95 /// (for example, if it is a dependent value), this should be `nullopt`,
96 /// else it should be 'N' minus the current depth traversed.
97 std::optional<llvm::APSInt> CurCollapseCount;
98
99 /// Records whether we've hit a CurCollapseCount of '0' on the way down,
100 /// which allows us to diagnose if the value of 'N' is too large for the
101 /// current number of 'for' loops.
102 bool CollapseDepthSatisfied = true;
103
104 /// Records the kind of the directive that this clause is attached to, which
105 /// allows us to use it in diagnostics.
107 } CollapseInfo;
108
109 /// The 'tile' clause requires a bit of additional checking as well, so like
110 /// the `CollapseCheckingInfo`, ensure we maintain information here too.
111 struct TileCheckingInfo {
112 OpenACCTileClause *ActiveTile = nullptr;
113
114 /// This is the number of expressions on a 'tile' clause. This doesn't have
115 /// to be an APSInt because it isn't the result of a constexpr, just by our
116 /// own counting of elements.
117 UnsignedOrNone CurTileCount = std::nullopt;
118
119 /// Records whether we've hit a 'CurTileCount' of '0' on the way down,
120 /// which allows us to diagnose if the number of arguments is too large for
121 /// the current number of 'for' loops.
122 bool TileDepthSatisfied = true;
123
124 /// Records the kind of the directive that this clause is attached to, which
125 /// allows us to use it in diagnostics.
127 } TileInfo;
128
129 /// The 'cache' var-list requires some additional work to track variable
130 /// references to make sure they are on the 'other' side of a `loop`. This
131 /// structure is used during parse time to track vardecl use while parsing a
132 /// cache var list.
133 struct CacheParseInfo {
134 bool ParsingCacheVarList = false;
135 bool IsInvalidCacheRef = false;
136 } CacheInfo;
137
138 /// A list of the active reduction clauses, which allows us to check that all
139 /// vars on nested constructs for the same reduction var have the same
140 /// reduction operator. Currently this is enforced against all constructs
141 /// despite the rule being in the 'loop' section. By current reading, this
142 /// should apply to all anyway, but we may need to make this more like the
143 /// 'loop' clause enforcement, where this is 'blocked' by a compute construct.
144 llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
145
146 // Type to check the 'for' (or range-for) statement for compatibility with the
147 // 'loop' directive.
148 class ForStmtBeginChecker {
149 SemaOpenACC &SemaRef;
150 SourceLocation ForLoc;
151 bool IsInstantiation = false;
152
153 struct RangeForInfo {
154 const CXXForRangeStmt *Uninstantiated = nullptr;
155 const CXXForRangeStmt *CurrentVersion = nullptr;
156 // GCC 7.x requires this constructor, else the construction of variant
157 // doesn't work correctly.
158 RangeForInfo() : Uninstantiated{nullptr}, CurrentVersion{nullptr} {}
159 RangeForInfo(const CXXForRangeStmt *Uninst, const CXXForRangeStmt *Cur)
160 : Uninstantiated{Uninst}, CurrentVersion{Cur} {}
161 };
162
163 struct ForInfo {
164 const Stmt *Init = nullptr;
165 const Stmt *Condition = nullptr;
166 const Stmt *Increment = nullptr;
167 };
168
169 struct CheckForInfo {
170 ForInfo Uninst;
171 ForInfo Current;
172 };
173
174 std::variant<RangeForInfo, CheckForInfo> Info;
175 // Prevent us from checking 2x, which can happen with collapse & tile.
176 bool AlreadyChecked = false;
177
178 void checkRangeFor();
179
180 bool checkForInit(const Stmt *InitStmt, const ValueDecl *&InitVar,
181 bool Diag);
182 bool checkForCond(const Stmt *CondStmt, const ValueDecl *InitVar,
183 bool Diag);
184 bool checkForInc(const Stmt *IncStmt, const ValueDecl *InitVar, bool Diag);
185
186 void checkFor();
187
188 public:
189 // Checking for non-instantiation version of a Range-for.
190 ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
191 const CXXForRangeStmt *RangeFor)
192 : SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(false),
193 Info(RangeForInfo{nullptr, RangeFor}) {}
194 // Checking for an instantiation of the range-for.
195 ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
196 const CXXForRangeStmt *OldRangeFor,
197 const CXXForRangeStmt *RangeFor)
198 : SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(true),
199 Info(RangeForInfo{OldRangeFor, RangeFor}) {}
200 // Checking for a non-instantiation version of a traditional for.
201 ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
202 const Stmt *Init, const Stmt *Cond, const Stmt *Inc)
203 : SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(false),
204 Info(CheckForInfo{{}, {Init, Cond, Inc}}) {}
205 // Checking for an instantiation version of a traditional for.
206 ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
207 const Stmt *OldInit, const Stmt *OldCond,
208 const Stmt *OldInc, const Stmt *Init, const Stmt *Cond,
209 const Stmt *Inc)
210 : SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(true),
211 Info(CheckForInfo{{OldInit, OldCond, OldInc}, {Init, Cond, Inc}}) {}
212
213 void check();
214 };
215
216 /// Helper function for checking the 'for' and 'range for' stmts.
217 void ForStmtBeginHelper(SourceLocation ForLoc, ForStmtBeginChecker &C);
218
219 // The 'declare' construct requires only a single reference among ALL declare
220 // directives in a context. We store existing references to check. Because the
221 // rules prevent referencing the same variable from multiple declaration
222 // contexts, we can just store the declaration and location of the reference.
223 llvm::DenseMap<const clang::DeclaratorDecl *, SourceLocation>
224 DeclareVarReferences;
225 // The 'routine' construct disallows magic-statics in a function referred to
226 // by a 'routine' directive. So record any of these that we see so we can
227 // check them later.
228 llvm::SmallDenseMap<const clang::FunctionDecl *, SourceLocation>
229 MagicStaticLocs;
230 OpenACCRoutineDecl *LastRoutineDecl = nullptr;
231
232 void CheckLastRoutineDeclNameConflict(const NamedDecl *ND);
233
234 bool DiagnoseRequiredClauses(OpenACCDirectiveKind DK, SourceLocation DirLoc,
236
237 bool DiagnoseAllowedClauses(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
238 SourceLocation ClauseLoc);
239 bool CreateReductionCombinerRecipe(
240 SourceLocation loc, OpenACCReductionOperator ReductionOperator,
241 QualType VarTy,
243 &CombinerRecipes);
244
245public:
246 // Needed from the visitor, so should be public.
247 bool DiagnoseAllowedOnceClauses(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
248 SourceLocation ClauseLoc,
250 bool DiagnoseExclusiveClauses(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
251 SourceLocation ClauseLoc,
253
254 OpenACCPrivateRecipe CreatePrivateInitRecipe(const Expr *VarExpr);
255 OpenACCFirstPrivateRecipe CreateFirstPrivateInitRecipe(const Expr *VarExpr);
256 OpenACCReductionRecipeWithStorage
257 CreateReductionInitRecipe(OpenACCReductionOperator ReductionOperator,
258 const Expr *VarExpr);
259
260public:
261 ComputeConstructInfo &getActiveComputeConstructInfo() {
262 return ActiveComputeConstructInfo;
263 }
264
265 /// If there is a current 'active' loop construct with a 'gang' clause on a
266 /// 'kernel' construct, this will have the source location for it, and the
267 /// 'kernel kind'. This permits us to implement the restriction of no further
268 /// 'gang' clauses.
273
274 /// If there is a current 'active' loop construct with a 'worker' clause on it
275 /// (on any sort of construct), this has the source location for it. This
276 /// permits us to implement the restriction of no further 'gang' or 'worker'
277 /// clauses.
279 /// If there is a current 'active' loop construct with a 'vector' clause on it
280 /// (on any sort of construct), this has the source location for it. This
281 /// permits us to implement the restriction of no further 'gang', 'vector', or
282 /// 'worker' clauses.
284 /// If there is a current 'active' loop construct that does NOT have a 'seq'
285 /// clause on it, this has that source location and loop Directive 'kind'.
286 /// This permits us to implement the 'loop' restrictions on the loop variable.
287 /// This can be extended via 'collapse', so we need to keep this around for a
288 /// while.
293
294 // Redeclaration of the version in OpenACCClause.h.
296
297 /// A type to represent all the data for an OpenACC Clause that has been
298 /// parsed, but not yet created/semantically analyzed. This is effectively a
299 /// discriminated union on the 'Clause Kind', with all of the individual
300 /// clause details stored in a std::variant.
302 OpenACCDirectiveKind DirKind;
303 OpenACCClauseKind ClauseKind;
304 SourceRange ClauseRange;
305 SourceLocation LParenLoc;
306
307 struct DefaultDetails {
308 OpenACCDefaultClauseKind DefaultClauseKind;
309 };
310
311 struct ConditionDetails {
312 Expr *ConditionExpr;
313 };
314
315 struct IntExprDetails {
316 SmallVector<Expr *> IntExprs;
317 };
318
319 struct VarListDetails {
320 SmallVector<Expr *> VarList;
321 OpenACCModifierKind ModifierKind;
322 };
323
324 struct WaitDetails {
325 Expr *DevNumExpr;
326 SourceLocation QueuesLoc;
327 SmallVector<Expr *> QueueIdExprs;
328 };
329
330 struct DeviceTypeDetails {
332 };
333 struct ReductionDetails {
335 SmallVector<Expr *> VarList;
336 };
337
338 struct CollapseDetails {
339 bool IsForce;
340 Expr *LoopCount;
341 };
342
343 struct GangDetails {
345 SmallVector<Expr *> IntExprs;
346 };
347 struct BindDetails {
348 std::variant<std::monostate, clang::StringLiteral *, IdentifierInfo *>
349 Argument;
350 };
351
352 std::variant<std::monostate, DefaultDetails, ConditionDetails,
353 IntExprDetails, VarListDetails, WaitDetails, DeviceTypeDetails,
354 ReductionDetails, CollapseDetails, GangDetails, BindDetails>
355 Details = std::monostate{};
356
357 public:
359 OpenACCClauseKind ClauseKind, SourceLocation BeginLoc)
360 : DirKind(DirKind), ClauseKind(ClauseKind), ClauseRange(BeginLoc, {}) {}
361
362 OpenACCDirectiveKind getDirectiveKind() const { return DirKind; }
363
364 OpenACCClauseKind getClauseKind() const { return ClauseKind; }
365
366 SourceLocation getBeginLoc() const { return ClauseRange.getBegin(); }
367
368 SourceLocation getLParenLoc() const { return LParenLoc; }
369
370 SourceLocation getEndLoc() const { return ClauseRange.getEnd(); }
371
373 assert(ClauseKind == OpenACCClauseKind::Default &&
374 "Parsed clause is not a default clause");
375 return std::get<DefaultDetails>(Details).DefaultClauseKind;
376 }
377
378 const Expr *getConditionExpr() const {
379 return const_cast<OpenACCParsedClause *>(this)->getConditionExpr();
380 }
381
383 assert((ClauseKind == OpenACCClauseKind::If ||
384 (ClauseKind == OpenACCClauseKind::Self &&
385 DirKind != OpenACCDirectiveKind::Update)) &&
386 "Parsed clause kind does not have a condition expr");
387
388 // 'self' has an optional ConditionExpr, so be tolerant of that. This will
389 // assert in variant otherwise.
390 if (ClauseKind == OpenACCClauseKind::Self &&
391 std::holds_alternative<std::monostate>(Details))
392 return nullptr;
393
394 return std::get<ConditionDetails>(Details).ConditionExpr;
395 }
396
397 unsigned getNumIntExprs() const {
398 assert((ClauseKind == OpenACCClauseKind::NumGangs ||
399 ClauseKind == OpenACCClauseKind::NumWorkers ||
400 ClauseKind == OpenACCClauseKind::Async ||
401 ClauseKind == OpenACCClauseKind::DeviceNum ||
402 ClauseKind == OpenACCClauseKind::DefaultAsync ||
403 ClauseKind == OpenACCClauseKind::Tile ||
404 ClauseKind == OpenACCClauseKind::Worker ||
405 ClauseKind == OpenACCClauseKind::Vector ||
406 ClauseKind == OpenACCClauseKind::VectorLength) &&
407 "Parsed clause kind does not have a int exprs");
408
409 // 'async', 'worker', 'vector', and 'wait' have an optional IntExpr, so be
410 // tolerant of that.
411 if ((ClauseKind == OpenACCClauseKind::Async ||
412 ClauseKind == OpenACCClauseKind::Worker ||
413 ClauseKind == OpenACCClauseKind::Vector ||
414 ClauseKind == OpenACCClauseKind::Wait) &&
415 std::holds_alternative<std::monostate>(Details))
416 return 0;
417 return std::get<IntExprDetails>(Details).IntExprs.size();
418 }
419
421 assert(ClauseKind == OpenACCClauseKind::Wait &&
422 "Parsed clause kind does not have a queues location");
423
424 if (std::holds_alternative<std::monostate>(Details))
425 return SourceLocation{};
426
427 return std::get<WaitDetails>(Details).QueuesLoc;
428 }
429
431 assert(ClauseKind == OpenACCClauseKind::Wait &&
432 "Parsed clause kind does not have a device number expr");
433
434 if (std::holds_alternative<std::monostate>(Details))
435 return nullptr;
436
437 return std::get<WaitDetails>(Details).DevNumExpr;
438 }
439
441 assert(ClauseKind == OpenACCClauseKind::Wait &&
442 "Parsed clause kind does not have a queue id expr list");
443
444 if (std::holds_alternative<std::monostate>(Details))
445 return ArrayRef<Expr *>();
446
447 return std::get<WaitDetails>(Details).QueueIdExprs;
448 }
449
451 assert((ClauseKind == OpenACCClauseKind::NumGangs ||
452 ClauseKind == OpenACCClauseKind::NumWorkers ||
453 ClauseKind == OpenACCClauseKind::Async ||
454 ClauseKind == OpenACCClauseKind::DeviceNum ||
455 ClauseKind == OpenACCClauseKind::DefaultAsync ||
456 ClauseKind == OpenACCClauseKind::Tile ||
457 ClauseKind == OpenACCClauseKind::Gang ||
458 ClauseKind == OpenACCClauseKind::Worker ||
459 ClauseKind == OpenACCClauseKind::Vector ||
460 ClauseKind == OpenACCClauseKind::VectorLength) &&
461 "Parsed clause kind does not have a int exprs");
462
463 if (ClauseKind == OpenACCClauseKind::Gang) {
464 // There might not be any gang int exprs, as this is an optional
465 // argument.
466 if (std::holds_alternative<std::monostate>(Details))
467 return {};
468 return std::get<GangDetails>(Details).IntExprs;
469 }
470
471 return std::get<IntExprDetails>(Details).IntExprs;
472 }
473
475 return const_cast<OpenACCParsedClause *>(this)->getIntExprs();
476 }
477
479 return std::get<ReductionDetails>(Details).Op;
480 }
481
483 assert(ClauseKind == OpenACCClauseKind::Gang &&
484 "Parsed clause kind does not have gang kind");
485 // The args on gang are optional, so this might not actually hold
486 // anything.
487 if (std::holds_alternative<std::monostate>(Details))
488 return {};
489 return std::get<GangDetails>(Details).GangKinds;
490 }
491
493 assert((ClauseKind == OpenACCClauseKind::Private ||
494 ClauseKind == OpenACCClauseKind::NoCreate ||
495 ClauseKind == OpenACCClauseKind::Present ||
496 ClauseKind == OpenACCClauseKind::Copy ||
497 ClauseKind == OpenACCClauseKind::PCopy ||
498 ClauseKind == OpenACCClauseKind::PresentOrCopy ||
499 ClauseKind == OpenACCClauseKind::CopyIn ||
500 ClauseKind == OpenACCClauseKind::PCopyIn ||
502 ClauseKind == OpenACCClauseKind::CopyOut ||
503 ClauseKind == OpenACCClauseKind::PCopyOut ||
505 ClauseKind == OpenACCClauseKind::Create ||
506 ClauseKind == OpenACCClauseKind::PCreate ||
508 ClauseKind == OpenACCClauseKind::Attach ||
509 ClauseKind == OpenACCClauseKind::Delete ||
510 ClauseKind == OpenACCClauseKind::UseDevice ||
511 ClauseKind == OpenACCClauseKind::Detach ||
512 ClauseKind == OpenACCClauseKind::DevicePtr ||
513 ClauseKind == OpenACCClauseKind::Reduction ||
514 ClauseKind == OpenACCClauseKind::Host ||
515 ClauseKind == OpenACCClauseKind::Device ||
516 ClauseKind == OpenACCClauseKind::DeviceResident ||
517 ClauseKind == OpenACCClauseKind::Link ||
518 (ClauseKind == OpenACCClauseKind::Self &&
519 DirKind == OpenACCDirectiveKind::Update) ||
520 ClauseKind == OpenACCClauseKind::FirstPrivate) &&
521 "Parsed clause kind does not have a var-list");
522
523 if (ClauseKind == OpenACCClauseKind::Reduction)
524 return std::get<ReductionDetails>(Details).VarList;
525
526 return std::get<VarListDetails>(Details).VarList;
527 }
528
530 return const_cast<OpenACCParsedClause *>(this)->getVarList();
531 }
532
534 return std::get<VarListDetails>(Details).ModifierKind;
535 }
536
537 bool isForce() const {
538 assert(ClauseKind == OpenACCClauseKind::Collapse &&
539 "Only 'collapse' has a force tag");
540 return std::get<CollapseDetails>(Details).IsForce;
541 }
542
544 assert(ClauseKind == OpenACCClauseKind::Collapse &&
545 "Only 'collapse' has a loop count");
546 return std::get<CollapseDetails>(Details).LoopCount;
547 }
548
550 assert((ClauseKind == OpenACCClauseKind::DeviceType ||
551 ClauseKind == OpenACCClauseKind::DType) &&
552 "Only 'device_type'/'dtype' has a device-type-arg list");
553 return std::get<DeviceTypeDetails>(Details).Archs;
554 }
555
556 std::variant<std::monostate, clang::StringLiteral *, IdentifierInfo *>
558 assert(ClauseKind == OpenACCClauseKind::Bind &&
559 "Only 'bind' has bind details");
560 return std::get<BindDetails>(Details).Argument;
561 }
562
563 void setLParenLoc(SourceLocation EndLoc) { LParenLoc = EndLoc; }
564 void setEndLoc(SourceLocation EndLoc) { ClauseRange.setEnd(EndLoc); }
565
567 assert(ClauseKind == OpenACCClauseKind::Default &&
568 "Parsed clause is not a default clause");
569 Details = DefaultDetails{DefKind};
570 }
571
572 void setConditionDetails(Expr *ConditionExpr) {
573 assert((ClauseKind == OpenACCClauseKind::If ||
574 (ClauseKind == OpenACCClauseKind::Self &&
575 DirKind != OpenACCDirectiveKind::Update)) &&
576 "Parsed clause kind does not have a condition expr");
577 // In C++ we can count on this being a 'bool', but in C this gets left as
578 // some sort of scalar that codegen will have to take care of converting.
579 assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() ||
580 ConditionExpr->getType()->isScalarType()) &&
581 "Condition expression type not scalar/dependent");
582
583 Details = ConditionDetails{ConditionExpr};
584 }
585
587 assert((ClauseKind == OpenACCClauseKind::NumGangs ||
588 ClauseKind == OpenACCClauseKind::NumWorkers ||
589 ClauseKind == OpenACCClauseKind::Async ||
590 ClauseKind == OpenACCClauseKind::DeviceNum ||
591 ClauseKind == OpenACCClauseKind::DefaultAsync ||
592 ClauseKind == OpenACCClauseKind::Tile ||
593 ClauseKind == OpenACCClauseKind::Worker ||
594 ClauseKind == OpenACCClauseKind::Vector ||
595 ClauseKind == OpenACCClauseKind::VectorLength) &&
596 "Parsed clause kind does not have a int exprs");
597 Details = IntExprDetails{{IntExprs.begin(), IntExprs.end()}};
598 }
600 assert((ClauseKind == OpenACCClauseKind::NumGangs ||
601 ClauseKind == OpenACCClauseKind::NumWorkers ||
602 ClauseKind == OpenACCClauseKind::Async ||
603 ClauseKind == OpenACCClauseKind::DeviceNum ||
604 ClauseKind == OpenACCClauseKind::DefaultAsync ||
605 ClauseKind == OpenACCClauseKind::Tile ||
606 ClauseKind == OpenACCClauseKind::Worker ||
607 ClauseKind == OpenACCClauseKind::Vector ||
608 ClauseKind == OpenACCClauseKind::VectorLength) &&
609 "Parsed clause kind does not have a int exprs");
610 Details = IntExprDetails{std::move(IntExprs)};
611 }
612
614 ArrayRef<Expr *> IntExprs) {
615 assert(ClauseKind == OpenACCClauseKind::Gang &&
616 "Parsed Clause kind does not have gang details");
617 assert(GKs.size() == IntExprs.size() && "Mismatched kind/size?");
618
619 Details = GangDetails{{GKs.begin(), GKs.end()},
620 {IntExprs.begin(), IntExprs.end()}};
621 }
622
624 llvm::SmallVector<Expr *> &&IntExprs) {
625 assert(ClauseKind == OpenACCClauseKind::Gang &&
626 "Parsed Clause kind does not have gang details");
627 assert(GKs.size() == IntExprs.size() && "Mismatched kind/size?");
628
629 Details = GangDetails{std::move(GKs), std::move(IntExprs)};
630 }
631
633 OpenACCModifierKind ModKind) {
634 assert((ClauseKind == OpenACCClauseKind::Private ||
635 ClauseKind == OpenACCClauseKind::NoCreate ||
636 ClauseKind == OpenACCClauseKind::Present ||
637 ClauseKind == OpenACCClauseKind::Copy ||
638 ClauseKind == OpenACCClauseKind::PCopy ||
639 ClauseKind == OpenACCClauseKind::PresentOrCopy ||
640 ClauseKind == OpenACCClauseKind::CopyIn ||
641 ClauseKind == OpenACCClauseKind::PCopyIn ||
643 ClauseKind == OpenACCClauseKind::CopyOut ||
644 ClauseKind == OpenACCClauseKind::PCopyOut ||
646 ClauseKind == OpenACCClauseKind::Create ||
647 ClauseKind == OpenACCClauseKind::PCreate ||
649 ClauseKind == OpenACCClauseKind::Attach ||
650 ClauseKind == OpenACCClauseKind::Delete ||
651 ClauseKind == OpenACCClauseKind::UseDevice ||
652 ClauseKind == OpenACCClauseKind::Detach ||
653 ClauseKind == OpenACCClauseKind::DevicePtr ||
654 ClauseKind == OpenACCClauseKind::Host ||
655 ClauseKind == OpenACCClauseKind::Device ||
656 ClauseKind == OpenACCClauseKind::DeviceResident ||
657 ClauseKind == OpenACCClauseKind::Link ||
658 (ClauseKind == OpenACCClauseKind::Self &&
659 DirKind == OpenACCDirectiveKind::Update) ||
660 ClauseKind == OpenACCClauseKind::FirstPrivate) &&
661 "Parsed clause kind does not have a var-list");
662 assert((ModKind == OpenACCModifierKind::Invalid ||
663 ClauseKind == OpenACCClauseKind::Copy ||
664 ClauseKind == OpenACCClauseKind::PCopy ||
665 ClauseKind == OpenACCClauseKind::PresentOrCopy ||
666 ClauseKind == OpenACCClauseKind::CopyIn ||
667 ClauseKind == OpenACCClauseKind::PCopyIn ||
669 ClauseKind == OpenACCClauseKind::CopyOut ||
670 ClauseKind == OpenACCClauseKind::PCopyOut ||
672 ClauseKind == OpenACCClauseKind::Create ||
673 ClauseKind == OpenACCClauseKind::PCreate ||
674 ClauseKind == OpenACCClauseKind::PresentOrCreate) &&
675 "Modifier Kind only valid on copy, copyin, copyout, create");
676 Details = VarListDetails{{VarList.begin(), VarList.end()}, ModKind};
677 }
678
680 OpenACCModifierKind ModKind) {
681 assert((ClauseKind == OpenACCClauseKind::Private ||
682 ClauseKind == OpenACCClauseKind::NoCreate ||
683 ClauseKind == OpenACCClauseKind::Present ||
684 ClauseKind == OpenACCClauseKind::Copy ||
685 ClauseKind == OpenACCClauseKind::PCopy ||
686 ClauseKind == OpenACCClauseKind::PresentOrCopy ||
687 ClauseKind == OpenACCClauseKind::CopyIn ||
688 ClauseKind == OpenACCClauseKind::PCopyIn ||
690 ClauseKind == OpenACCClauseKind::CopyOut ||
691 ClauseKind == OpenACCClauseKind::PCopyOut ||
693 ClauseKind == OpenACCClauseKind::Create ||
694 ClauseKind == OpenACCClauseKind::PCreate ||
696 ClauseKind == OpenACCClauseKind::Attach ||
697 ClauseKind == OpenACCClauseKind::Delete ||
698 ClauseKind == OpenACCClauseKind::UseDevice ||
699 ClauseKind == OpenACCClauseKind::Detach ||
700 ClauseKind == OpenACCClauseKind::DevicePtr ||
701 ClauseKind == OpenACCClauseKind::Host ||
702 ClauseKind == OpenACCClauseKind::Device ||
703 ClauseKind == OpenACCClauseKind::DeviceResident ||
704 ClauseKind == OpenACCClauseKind::Link ||
705 (ClauseKind == OpenACCClauseKind::Self &&
706 DirKind == OpenACCDirectiveKind::Update) ||
707 ClauseKind == OpenACCClauseKind::FirstPrivate) &&
708 "Parsed clause kind does not have a var-list");
709 assert((ModKind == OpenACCModifierKind::Invalid ||
710 ClauseKind == OpenACCClauseKind::Copy ||
711 ClauseKind == OpenACCClauseKind::PCopy ||
712 ClauseKind == OpenACCClauseKind::PresentOrCopy ||
713 ClauseKind == OpenACCClauseKind::CopyIn ||
714 ClauseKind == OpenACCClauseKind::PCopyIn ||
716 ClauseKind == OpenACCClauseKind::CopyOut ||
717 ClauseKind == OpenACCClauseKind::PCopyOut ||
719 ClauseKind == OpenACCClauseKind::Create ||
720 ClauseKind == OpenACCClauseKind::PCreate ||
721 ClauseKind == OpenACCClauseKind::PresentOrCreate) &&
722 "Modifier Kind only valid on copy, copyin, copyout, create");
723 Details = VarListDetails{std::move(VarList), ModKind};
724 }
725
727 llvm::SmallVector<Expr *> &&VarList) {
728 assert(ClauseKind == OpenACCClauseKind::Reduction &&
729 "reduction details only valid on reduction");
730 Details = ReductionDetails{Op, std::move(VarList)};
731 }
732
733 void setWaitDetails(Expr *DevNum, SourceLocation QueuesLoc,
734 llvm::SmallVector<Expr *> &&IntExprs) {
735 assert(ClauseKind == OpenACCClauseKind::Wait &&
736 "Parsed clause kind does not have a wait-details");
737 Details = WaitDetails{DevNum, QueuesLoc, std::move(IntExprs)};
738 }
739
741 assert((ClauseKind == OpenACCClauseKind::DeviceType ||
742 ClauseKind == OpenACCClauseKind::DType) &&
743 "Only 'device_type'/'dtype' has a device-type-arg list");
744 Details = DeviceTypeDetails{std::move(Archs)};
745 }
746
747 void setCollapseDetails(bool IsForce, Expr *LoopCount) {
748 assert(ClauseKind == OpenACCClauseKind::Collapse &&
749 "Only 'collapse' has collapse details");
750 Details = CollapseDetails{IsForce, LoopCount};
751 }
752
754 std::variant<std::monostate, clang::StringLiteral *, IdentifierInfo *>
755 Arg) {
756 assert(ClauseKind == OpenACCClauseKind::Bind &&
757 "Only 'bind' has bind details");
758 Details = BindDetails{Arg};
759 }
760 };
761
762 SemaOpenACC(Sema &S);
763 void ActOnEndOfTranslationUnit(TranslationUnitDecl *TU);
764
765 // Called when we encounter a 'while' statement, before looking at its 'body'.
766 void ActOnWhileStmt(SourceLocation WhileLoc);
767 // Called when we encounter a 'do' statement, before looking at its 'body'.
768 void ActOnDoStmt(SourceLocation DoLoc);
769 // Called when we encounter a 'for' statement, before looking at its 'body',
770 // for the 'range-for'. 'ActOnForStmtEnd' is used after the body.
771 void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor,
772 const Stmt *RangeFor);
773 void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *RangeFor);
774 // Called when we encounter a 'for' statement, before looking at its 'body'.
775 // 'ActOnForStmtEnd' is used after the body.
776 void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First,
777 const Stmt *Second, const Stmt *Third);
778 void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *OldFirst,
779 const Stmt *First, const Stmt *OldSecond,
780 const Stmt *Second, const Stmt *OldThird,
781 const Stmt *Third);
782 // Called when we encounter a 'for' statement, after we've consumed/checked
783 // the body. This is necessary for a number of checks on the contents of the
784 // 'for' statement.
785 void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body);
786
787 /// Called after parsing an OpenACC Clause so that it can be checked.
788 OpenACCClause *ActOnClause(ArrayRef<const OpenACCClause *> ExistingClauses,
789 OpenACCParsedClause &Clause);
790
791 /// Called after the construct has been parsed, but clauses haven't been
792 /// parsed. This allows us to diagnose not-implemented, as well as set up any
793 /// state required for parsing the clauses.
794 void ActOnConstruct(OpenACCDirectiveKind K, SourceLocation DirLoc);
795
796 /// Called after the directive, including its clauses, have been parsed and
797 /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
798 /// happen before any associated declarations or statements have been parsed.
799 /// This function is only called when we are parsing a 'statement' context.
800 bool ActOnStartStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc,
802
803 /// Called after the directive, including its clauses, have been parsed and
804 /// parsing has consumed the 'annot_pragma_openacc_end' token. This DOES
805 /// happen before any associated declarations or statements have been parsed.
806 /// This function is only called when we are parsing a 'Decl' context.
807 bool ActOnStartDeclDirective(OpenACCDirectiveKind K, SourceLocation StartLoc,
809 /// Called when we encounter an associated statement for our construct, this
810 /// should check legality of the statement as it appertains to this Construct.
811 StmtResult ActOnAssociatedStmt(SourceLocation DirectiveLoc,
813 OpenACCAtomicKind AtKind,
815 StmtResult AssocStmt);
816
820 StmtResult AssocStmt) {
821 return ActOnAssociatedStmt(DirectiveLoc, K, OpenACCAtomicKind::None,
822 Clauses, AssocStmt);
823 }
824 /// Called to check the form of the `atomic` construct which has some fairly
825 /// sizable restrictions.
826 StmtResult CheckAtomicAssociatedStmt(SourceLocation AtomicDirLoc,
827 OpenACCAtomicKind AtKind,
828 StmtResult AssocStmt);
829
830 /// Called after the directive has been completely parsed, including the
831 /// declaration group or associated statement.
832 /// DirLoc: Location of the actual directive keyword.
833 /// LParenLoc: Location of the left paren, if it exists (not on all
834 /// constructs).
835 /// MiscLoc: First misc location, if necessary (not all constructs).
836 /// Exprs: List of expressions on the construct itself, if necessary (not all
837 /// constructs).
838 /// FuncRef: used only for Routine, this is the function being referenced.
839 /// AK: The atomic kind of the directive, if necessary (atomic only)
840 /// RParenLoc: Location of the right paren, if it exists (not on all
841 /// constructs).
842 /// EndLoc: The last source location of the driective.
843 /// Clauses: The list of clauses for the directive, if present.
844 /// AssocStmt: The associated statement for this construct, if necessary.
845 StmtResult ActOnEndStmtDirective(
847 SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef<Expr *> Exprs,
848 OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc,
849 ArrayRef<OpenACCClause *> Clauses, StmtResult AssocStmt);
850
851 /// Called after the directive has been completely parsed, including the
852 /// declaration group or associated statement.
854 ActOnEndDeclDirective(OpenACCDirectiveKind K, SourceLocation StartLoc,
855 SourceLocation DirLoc, SourceLocation LParenLoc,
856 SourceLocation RParenLoc, SourceLocation EndLoc,
858
859 // Helper functions for ActOnEndRoutine*Directive, which does all the checking
860 // given the proper list of declarations.
861 void CheckRoutineDecl(SourceLocation DirLoc,
863 Decl *NextParsedDecl);
864 OpenACCRoutineDecl *CheckRoutineDecl(SourceLocation StartLoc,
865 SourceLocation DirLoc,
866 SourceLocation LParenLoc, Expr *FuncRef,
867 SourceLocation RParenLoc,
869 SourceLocation EndLoc);
870 OpenACCRoutineDeclAttr *
871 mergeRoutineDeclAttr(const OpenACCRoutineDeclAttr &Old);
873 ActOnEndRoutineDeclDirective(SourceLocation StartLoc, SourceLocation DirLoc,
874 SourceLocation LParenLoc, Expr *ReferencedFunc,
875 SourceLocation RParenLoc,
877 SourceLocation EndLoc, DeclGroupPtrTy NextDecl);
879 ActOnEndRoutineStmtDirective(SourceLocation StartLoc, SourceLocation DirLoc,
880 SourceLocation LParenLoc, Expr *ReferencedFunc,
881 SourceLocation RParenLoc,
883 SourceLocation EndLoc, Stmt *NextStmt);
884
885 /// Called when encountering an 'int-expr' for OpenACC, and manages
886 /// conversions and diagnostics to 'int'.
888 SourceLocation Loc, Expr *IntExpr);
889
890 /// Called right before a 'var' is parsed, so we can set the state for parsing
891 /// a 'cache' var.
892 void ActOnStartParseVar(OpenACCDirectiveKind DK, OpenACCClauseKind CK);
893 /// Called only if the parse of a 'var' was invalid, else 'ActOnVar' should be
894 /// called.
895 void ActOnInvalidParseVar();
896 /// Called when encountering a 'var' for OpenACC, ensures it is actually a
897 /// declaration reference to a variable of the correct type.
899 Expr *VarExpr);
900 /// Helper function called by ActonVar that is used to check a 'cache' var.
901 ExprResult ActOnCacheVar(Expr *VarExpr);
902 /// Function called when a variable declarator is created, which lets us
903 /// implement the 'routine' 'function static variables' restriction.
904 void ActOnVariableDeclarator(VarDecl *VD);
905 /// Called when a function decl is created, which lets us implement the
906 /// 'routine' 'doesn't match next thing' warning.
907 void ActOnFunctionDeclarator(FunctionDecl *FD);
908 /// Called when a variable is initialized, so we can implement the 'routine
909 /// 'doesn't match the next thing' warning for lambda init.
910 void ActOnVariableInit(VarDecl *VD, QualType InitType);
911
912 // Called after 'ActOnVar' specifically for a 'link' clause, which has to do
913 // some minor additional checks.
914 llvm::SmallVector<Expr *> CheckLinkClauseVarList(ArrayRef<Expr *> VarExpr);
915
916 // Checking for the arguments specific to the declare-clause that need to be
917 // checked during both phases of template translation.
918 bool CheckDeclareClause(SemaOpenACC::OpenACCParsedClause &Clause,
920
921 ExprResult ActOnRoutineName(Expr *RoutineName);
922
923 /// Called while semantically analyzing the reduction clause, ensuring the var
924 /// is the correct kind of reference.
925 ExprResult CheckReductionVar(OpenACCDirectiveKind DirectiveKind,
926 OpenACCReductionOperator ReductionOp,
927 Expr *VarExpr);
928 bool CheckReductionVarType(Expr *VarExpr);
929
930 /// Called to check the 'var' type is a variable of pointer type, necessary
931 /// for 'deviceptr' and 'attach' clauses. Returns true on success.
932 bool CheckVarIsPointerType(OpenACCClauseKind ClauseKind, Expr *VarExpr);
933
934 /// Checks and creates an Array Section used in an OpenACC construct/clause.
935 ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
936 Expr *LowerBound,
937 SourceLocation ColonLocFirst, Expr *Length,
938 SourceLocation RBLoc);
939 /// Checks the loop depth value for a collapse clause.
940 ExprResult CheckCollapseLoopCount(Expr *LoopCount);
941 /// Checks a single size expr for a tile clause.
942 ExprResult CheckTileSizeExpr(Expr *SizeExpr);
943
944 // Check a single expression on a gang clause.
945 ExprResult CheckGangExpr(ArrayRef<const OpenACCClause *> ExistingClauses,
947 Expr *E);
948
949 // Called when a declaration is referenced, so that we can make sure certain
950 // clauses don't do the 'wrong' thing/have incorrect references.
951 void CheckDeclReference(SourceLocation Loc, Expr *E, Decl *D);
952
953 // Does the checking for a 'gang' clause that needs to be done in dependent
954 // and not dependent cases.
956 CheckGangClause(OpenACCDirectiveKind DirKind,
957 ArrayRef<const OpenACCClause *> ExistingClauses,
958 SourceLocation BeginLoc, SourceLocation LParenLoc,
960 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
961 // Does the checking for a 'reduction ' clause that needs to be done in
962 // dependent and not dependent cases.
964 CheckReductionClause(ArrayRef<const OpenACCClause *> ExistingClauses,
965 OpenACCDirectiveKind DirectiveKind,
966 SourceLocation BeginLoc, SourceLocation LParenLoc,
967 OpenACCReductionOperator ReductionOp,
968 ArrayRef<Expr *> Vars,
970 SourceLocation EndLoc);
971
972 ExprResult BuildOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc);
973 ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc);
974
975 /// Helper type to restore the state of various 'loop' constructs when we run
976 /// into a loop (for, etc) inside the construct.
978 SemaOpenACC &SemaRef;
979 LoopCheckingInfo OldLoopInfo;
980 CollapseCheckingInfo OldCollapseInfo;
981 TileCheckingInfo OldTileInfo;
982 bool PreserveDepth;
983
984 public:
985 LoopInConstructRAII(SemaOpenACC &SemaRef, bool PreserveDepth = true)
986 : SemaRef(SemaRef), OldLoopInfo(SemaRef.LoopInfo),
987 OldCollapseInfo(SemaRef.CollapseInfo), OldTileInfo(SemaRef.TileInfo),
988 PreserveDepth(PreserveDepth) {}
990 // The associated-statement level of this should NOT preserve this, as it
991 // is a new construct, but other loop uses need to preserve the depth so
992 // it makes it to the 'top level' for diagnostics.
993 bool CollapseDepthSatisified =
994 PreserveDepth ? SemaRef.CollapseInfo.CollapseDepthSatisfied
995 : OldCollapseInfo.CollapseDepthSatisfied;
996 bool TileDepthSatisfied = PreserveDepth
997 ? SemaRef.TileInfo.TileDepthSatisfied
998 : OldTileInfo.TileDepthSatisfied;
999 bool CurLevelHasLoopAlready =
1000 PreserveDepth ? SemaRef.LoopInfo.CurLevelHasLoopAlready
1001 : OldLoopInfo.CurLevelHasLoopAlready;
1002
1003 SemaRef.LoopInfo = OldLoopInfo;
1004 SemaRef.CollapseInfo = OldCollapseInfo;
1005 SemaRef.TileInfo = OldTileInfo;
1006
1007 SemaRef.CollapseInfo.CollapseDepthSatisfied = CollapseDepthSatisified;
1008 SemaRef.TileInfo.TileDepthSatisfied = TileDepthSatisfied;
1009 SemaRef.LoopInfo.CurLevelHasLoopAlready = CurLevelHasLoopAlready;
1010 }
1011 };
1012
1013 /// Helper type for the registration/assignment of constructs that need to
1014 /// 'know' about their parent constructs and hold a reference to them, such as
1015 /// Loop needing its parent construct.
1017 SemaOpenACC &SemaRef;
1018 ComputeConstructInfo OldActiveComputeConstructInfo;
1019 OpenACCDirectiveKind DirKind;
1020 LoopGangOnKernelTy OldLoopGangClauseOnKernel;
1021 SourceLocation OldLoopWorkerClauseLoc;
1022 SourceLocation OldLoopVectorClauseLoc;
1023 LoopWithoutSeqCheckingInfo OldLoopWithoutSeqInfo;
1024 llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
1025 LoopInConstructRAII LoopRAII;
1026
1027 public:
1032 ArrayRef<const OpenACCClause *> UnInstClauses,
1035 ArrayRef<const OpenACCClause *> UnInstClauses,
1038 };
1039};
1040
1041} // namespace clang
1042
1043#endif // LLVM_CLANG_SEMA_SEMAOPENACC_H
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines some OpenACC-specific enums and functions.
Defines the clang::SourceLocation class and associated facilities.
This file defines OpenACC AST classes for statement-level contructs.
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
This represents one expression.
Definition Expr.h:112
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Definition Expr.h:223
QualType getType() const
Definition Expr.h:144
Represents a function declaration or definition.
Definition Decl.h:2000
One of these records is kept for each identifier that is lexed.
A simple pair of identifier info and location.
Wrapper for void* pointer.
Definition Ownership.h:51
This is the base type for all OpenACC Clauses.
A (possibly-)qualified type.
Definition TypeBase.h:937
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
SemaBase(Sema &S)
Definition SemaBase.cpp:7
Sema & SemaRef
Definition SemaBase.h:40
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition SemaBase.cpp:61
AssociatedStmtRAII(SemaOpenACC &, OpenACCDirectiveKind, SourceLocation, ArrayRef< const OpenACCClause * >, ArrayRef< OpenACCClause * >)
void SetTileInfoBeforeAssociatedStmt(ArrayRef< const OpenACCClause * > UnInstClauses, ArrayRef< OpenACCClause * > Clauses)
void SetCollapseInfoBeforeAssociatedStmt(ArrayRef< const OpenACCClause * > UnInstClauses, ArrayRef< OpenACCClause * > Clauses)
Helper type to restore the state of various 'loop' constructs when we run into a loop (for,...
LoopInConstructRAII(SemaOpenACC &SemaRef, bool PreserveDepth=true)
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 * > getQueueIdExprs() const
OpenACCDirectiveKind getDirectiveKind() const
ArrayRef< OpenACCGangKind > getGangKinds() const
OpenACCParsedClause(OpenACCDirectiveKind DirKind, OpenACCClauseKind ClauseKind, SourceLocation BeginLoc)
OpenACCReductionOperator getReductionOp() const
void setLParenLoc(SourceLocation EndLoc)
void setConditionDetails(Expr *ConditionExpr)
void setCollapseDetails(bool IsForce, Expr *LoopCount)
OpenACCClauseKind getClauseKind() const
void setGangDetails(ArrayRef< OpenACCGangKind > GKs, ArrayRef< Expr * > IntExprs)
ArrayRef< DeviceTypeArgument > getDeviceTypeArchitectures() const
std::variant< std::monostate, clang::StringLiteral *, IdentifierInfo * > getBindDetails() const
void setIntExprDetails(llvm::SmallVector< Expr * > &&IntExprs)
void setReductionDetails(OpenACCReductionOperator Op, llvm::SmallVector< Expr * > &&VarList)
ArrayRef< Expr * > getVarList() const
void setDefaultDetails(OpenACCDefaultClauseKind DefKind)
OpenACCModifierKind getModifierList() const
void setWaitDetails(Expr *DevNum, SourceLocation QueuesLoc, llvm::SmallVector< Expr * > &&IntExprs)
void setEndLoc(SourceLocation EndLoc)
ArrayRef< Expr * > getIntExprs() const
void setIntExprDetails(ArrayRef< Expr * > IntExprs)
void setBindDetails(std::variant< std::monostate, clang::StringLiteral *, IdentifierInfo * > Arg)
void setVarListDetails(llvm::SmallVector< Expr * > &&VarList, OpenACCModifierKind ModKind)
void setDeviceTypeDetails(llvm::SmallVector< DeviceTypeArgument > &&Archs)
void setGangDetails(llvm::SmallVector< OpenACCGangKind > &&GKs, llvm::SmallVector< Expr * > &&IntExprs)
OpenACCDefaultClauseKind getDefaultClauseKind() const
ComputeConstructInfo & getActiveComputeConstructInfo()
SourceLocation LoopWorkerClauseLoc
If there is a current 'active' loop construct with a 'worker' clause on it (on any sort of construct)...
IdentifierLoc DeviceTypeArgument
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition SemaOpenACC.h:39
StmtResult ActOnAssociatedStmt(SourceLocation DirectiveLoc, OpenACCDirectiveKind K, OpenACCAtomicKind AtKind, ArrayRef< const OpenACCClause * > Clauses, StmtResult AssocStmt)
Called when we encounter an associated statement for our construct, this should check legality of the...
SourceLocation LoopVectorClauseLoc
If there is a current 'active' loop construct with a 'vector' clause on it (on any sort of construct)...
StmtResult ActOnAssociatedStmt(SourceLocation DirectiveLoc, OpenACCDirectiveKind K, ArrayRef< const OpenACCClause * > Clauses, StmtResult AssocStmt)
std::pair< FunctionDecl *, OpenACCRoutineDecl * > RoutineRefListTy
Definition SemaOpenACC.h:40
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:854
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Definition Stmt.h:85
The top declaration context.
Definition Decl.h:105
bool isScalarType() const
Definition TypeBase.h:8973
Represents a variable declaration or definition.
Definition Decl.h:926
bool Inc(InterpState &S, CodePtr OpPC, bool CanOverflow)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
Definition Interp.h:776
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCDirectiveKind
OpenACCReductionOperator
OpenACCAtomicKind
OpenACCModifierKind
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...
@ 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'.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Expr * Cond
};
OpenACCDefaultClauseKind
ActionResult< Expr * > ExprResult
Definition Ownership.h:249
ActionResult< Stmt * > StmtResult
Definition Ownership.h:250
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25
If there is a current 'active' loop construct with a 'gang' clause on a 'kernel' construct,...
If there is a current 'active' loop construct that does NOT have a 'seq' clause on it,...