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