clang 22.0.0git
OpenACCClause.h
Go to the documentation of this file.
1//===- OpenACCClause.h - Classes for OpenACC clauses ------------*- C++ -*-===//
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//
9// \file
10// This file defines OpenACC AST classes for clauses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_AST_OPENACCCLAUSE_H
15#define LLVM_CLANG_AST_OPENACCCLAUSE_H
16
20#include "llvm/ADT/STLExtras.h"
21
22#include <utility>
23#include <variant>
24
25namespace clang {
26/// This is the base type for all OpenACC Clauses.
29 SourceRange Location;
30
31protected:
33 SourceLocation EndLoc)
34 : Kind(K), Location(BeginLoc, EndLoc) {
35 assert(!BeginLoc.isInvalid() && !EndLoc.isInvalid() &&
36 "Begin and end location must be valid for OpenACCClause");
37 }
38
39public:
40 OpenACCClauseKind getClauseKind() const { return Kind; }
41 SourceLocation getBeginLoc() const { return Location.getBegin(); }
42 SourceLocation getEndLoc() const { return Location.getEnd(); }
43 SourceRange getSourceRange() const { return Location; }
44
45 static bool classof(const OpenACCClause *) { return true; }
46
49 using child_range = llvm::iterator_range<child_iterator>;
50 using const_child_range = llvm::iterator_range<const_child_iterator>;
51
54 auto Children = const_cast<OpenACCClause *>(this)->children();
55 return const_child_range(Children.begin(), Children.end());
56 }
57
58 virtual ~OpenACCClause() = default;
59};
60
61// Represents the 'auto' clause.
63protected:
65 : OpenACCClause(OpenACCClauseKind::Auto, BeginLoc, EndLoc) {}
66
67public:
68 static bool classof(const OpenACCClause *C) {
69 return C->getClauseKind() == OpenACCClauseKind::Auto;
70 }
71
72 static OpenACCAutoClause *
73 Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
74
77 }
80 }
81};
82
83// Represents the 'finalize' clause.
85protected:
87 : OpenACCClause(OpenACCClauseKind::Finalize, BeginLoc, EndLoc) {}
88
89public:
90 static bool classof(const OpenACCClause *C) {
91 return C->getClauseKind() == OpenACCClauseKind::Finalize;
92 }
93
95 Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
96
99 }
102 }
103};
104
105// Represents the 'if_present' clause.
107protected:
109 : OpenACCClause(OpenACCClauseKind::IfPresent, BeginLoc, EndLoc) {}
110
111public:
112 static bool classof(const OpenACCClause *C) {
113 return C->getClauseKind() == OpenACCClauseKind::IfPresent;
114 }
115
117 Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
118
121 }
124 }
125};
126
127// Represents the 'independent' clause.
129protected:
131 : OpenACCClause(OpenACCClauseKind::Independent, BeginLoc, EndLoc) {}
132
133public:
134 static bool classof(const OpenACCClause *C) {
135 return C->getClauseKind() == OpenACCClauseKind::Independent;
136 }
137
139 Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
140
143 }
146 }
147};
148// Represents the 'seq' clause.
150protected:
152 : OpenACCClause(OpenACCClauseKind::Seq, BeginLoc, EndLoc) {}
153
154public:
155 static bool classof(const OpenACCClause *C) {
156 return C->getClauseKind() == OpenACCClauseKind::Seq;
157 }
158
159 static OpenACCSeqClause *
160 Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
161
164 }
167 }
168};
169// Represents the 'nohost' clause.
171protected:
173 : OpenACCClause(OpenACCClauseKind::NoHost, BeginLoc, EndLoc) {}
174
175public:
176 static bool classof(const OpenACCClause *C) {
177 return C->getClauseKind() == OpenACCClauseKind::NoHost;
178 }
179 static OpenACCNoHostClause *
180 Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc);
181
184 }
187 }
188};
189
190/// Represents a clause that has a list of parameters.
192 /// Location of the '('.
193 SourceLocation LParenLoc;
194
195protected:
197 SourceLocation LParenLoc, SourceLocation EndLoc)
198 : OpenACCClause(K, BeginLoc, EndLoc), LParenLoc(LParenLoc) {}
199
200public:
201 static bool classof(const OpenACCClause *C);
202
203 SourceLocation getLParenLoc() const { return LParenLoc; }
204
207 }
210 }
211};
212
214 std::variant<const StringLiteral *, const IdentifierInfo *> Argument;
215
217 const clang::StringLiteral *SL, SourceLocation EndLoc)
219 EndLoc),
220 Argument(SL) {}
222 const IdentifierInfo *ID, SourceLocation EndLoc)
224 EndLoc),
225 Argument(ID) {}
226
227public:
228 static bool classof(const OpenACCClause *C) {
229 return C->getClauseKind() == OpenACCClauseKind::Bind;
230 }
231 static OpenACCBindClause *Create(const ASTContext &C, SourceLocation BeginLoc,
232 SourceLocation LParenLoc,
233 const IdentifierInfo *ID,
234 SourceLocation EndLoc);
235 static OpenACCBindClause *Create(const ASTContext &C, SourceLocation BeginLoc,
236 SourceLocation LParenLoc,
237 const StringLiteral *SL,
238 SourceLocation EndLoc);
239
240 bool isStringArgument() const {
241 return std::holds_alternative<const StringLiteral *>(Argument);
242 }
243
245 return std::get<const StringLiteral *>(Argument);
246 }
247
248 bool isIdentifierArgument() const {
249 return std::holds_alternative<const IdentifierInfo *>(Argument);
250 }
251
253 return std::get<const IdentifierInfo *>(Argument);
254 }
255};
256
257bool operator==(const OpenACCBindClause &LHS, const OpenACCBindClause &RHS);
258inline bool operator!=(const OpenACCBindClause &LHS,
259 const OpenACCBindClause &RHS) {
260 return !(LHS == RHS);
261}
262
264/// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or
265/// an identifier. The 'asterisk' means 'the rest'.
268 private llvm::TrailingObjects<OpenACCDeviceTypeClause,
269 DeviceTypeArgument> {
270 friend TrailingObjects;
271 // Data stored in trailing objects as IdentifierInfo* /SourceLocation pairs. A
272 // nullptr IdentifierInfo* represents an asterisk.
273 unsigned NumArchs;
275 SourceLocation LParenLoc,
277 SourceLocation EndLoc)
278 : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
279 NumArchs(Archs.size()) {
280 assert(
282 "Invalid clause kind for device-type");
283
284 assert(!llvm::any_of(Archs, [](const DeviceTypeArgument &Arg) {
285 return Arg.getLoc().isInvalid();
286 }) && "Invalid SourceLocation for an argument");
287
288 assert((Archs.size() == 1 ||
289 !llvm::any_of(Archs,
290 [](const DeviceTypeArgument &Arg) {
291 return Arg.getIdentifierInfo() == nullptr;
292 })) &&
293 "Only a single asterisk version is permitted, and must be the "
294 "only one");
295
296 llvm::uninitialized_copy(Archs, getTrailingObjects());
297 }
298
299public:
300 static bool classof(const OpenACCClause *C) {
301 return C->getClauseKind() == OpenACCClauseKind::DType ||
302 C->getClauseKind() == OpenACCClauseKind::DeviceType;
303 }
304 bool hasAsterisk() const {
305 return getArchitectures().size() > 0 &&
306 getArchitectures()[0].getIdentifierInfo() == nullptr;
307 }
308
310 return getTrailingObjects(NumArchs);
311 }
312
316 SourceLocation EndLoc);
317};
318
319/// A 'default' clause, has the optional 'none' or 'present' argument.
321 friend class ASTReaderStmt;
322 friend class ASTWriterStmt;
323
324 OpenACCDefaultClauseKind DefaultClauseKind;
325
326protected:
328 SourceLocation LParenLoc, SourceLocation EndLoc)
329 : OpenACCClauseWithParams(OpenACCClauseKind::Default, BeginLoc, LParenLoc,
330 EndLoc),
331 DefaultClauseKind(K) {
332 assert((DefaultClauseKind == OpenACCDefaultClauseKind::None ||
333 DefaultClauseKind == OpenACCDefaultClauseKind::Present) &&
334 "Invalid Clause Kind");
335 }
336
337public:
338 static bool classof(const OpenACCClause *C) {
339 return C->getClauseKind() == OpenACCClauseKind::Default;
340 }
342 return DefaultClauseKind;
343 }
344
347 SourceLocation BeginLoc,
348 SourceLocation LParenLoc,
349 SourceLocation EndLoc);
350};
351
352/// Represents one of the handful of classes that has an optional/required
353/// 'condition' expression as an argument.
355 Expr *ConditionExpr = nullptr;
356
357protected:
359 SourceLocation LParenLoc, Expr *ConditionExpr,
360 SourceLocation EndLoc)
361 : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
362 ConditionExpr(ConditionExpr) {}
363
364public:
365 static bool classof(const OpenACCClause *C);
366
367 bool hasConditionExpr() const { return ConditionExpr; }
368 const Expr *getConditionExpr() const { return ConditionExpr; }
369 Expr *getConditionExpr() { return ConditionExpr; }
370
372 if (ConditionExpr)
373 return child_range(reinterpret_cast<Stmt **>(&ConditionExpr),
374 reinterpret_cast<Stmt **>(&ConditionExpr + 1));
376 }
377
379 if (ConditionExpr)
380 return const_child_range(
381 reinterpret_cast<Stmt *const *>(&ConditionExpr),
382 reinterpret_cast<Stmt *const *>(&ConditionExpr + 1));
384 }
385};
386
387/// An 'if' clause, which has a required condition expression.
389protected:
391 Expr *ConditionExpr, SourceLocation EndLoc);
392
393public:
394 static bool classof(const OpenACCClause *C) {
395 return C->getClauseKind() == OpenACCClauseKind::If;
396 }
397 static OpenACCIfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
398 SourceLocation LParenLoc, Expr *ConditionExpr,
399 SourceLocation EndLoc);
400};
401
402/// A 'self' clause, which has an optional condition expression, or, in the
403/// event of an 'update' directive, contains a 'VarList'.
406 private llvm::TrailingObjects<OpenACCSelfClause, Expr *> {
407 friend TrailingObjects;
408 // Holds whether this HAS a condition expression. Lacks a value if this is NOT
409 // a condition-expr self clause.
410 std::optional<bool> HasConditionExpr;
411 // Holds the number of stored expressions. In the case of a condition-expr
412 // self clause, this is expected to be ONE (and there to be 1 trailing
413 // object), whether or not that is null.
414 unsigned NumExprs;
415
417 Expr *ConditionExpr, SourceLocation EndLoc);
419 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
420
421 // Intentionally internal, meant to be an implementation detail of everything
422 // else. All non-internal uses should go through getConditionExpr/getVarList.
423 ArrayRef<Expr *> getExprs() const { return getTrailingObjects(NumExprs); }
424
425public:
426 static bool classof(const OpenACCClause *C) {
427 return C->getClauseKind() == OpenACCClauseKind::Self;
428 }
429
430 bool isConditionExprClause() const { return HasConditionExpr.has_value(); }
431 bool isVarListClause() const { return !isConditionExprClause(); }
432 bool isEmptySelfClause() const {
433 return (isConditionExprClause() && !hasConditionExpr()) ||
434 (!isConditionExprClause() && getVarList().empty());
435 }
436
437 bool hasConditionExpr() const {
438 assert(HasConditionExpr.has_value() &&
439 "VarList Self Clause asked about condition expression");
440 return *HasConditionExpr;
441 }
442
443 const Expr *getConditionExpr() const {
444 assert(HasConditionExpr.has_value() &&
445 "VarList Self Clause asked about condition expression");
446 assert(getExprs().size() == 1 &&
447 "ConditionExpr Self Clause with too many Exprs");
448 return getExprs()[0];
449 }
450
452 assert(HasConditionExpr.has_value() &&
453 "VarList Self Clause asked about condition expression");
454 assert(getExprs().size() == 1 &&
455 "ConditionExpr Self Clause with too many Exprs");
456 return getExprs()[0];
457 }
458
460 assert(!HasConditionExpr.has_value() &&
461 "Condition Expr self clause asked about var list");
462 return getExprs();
463 }
465 assert(!HasConditionExpr.has_value() &&
466 "Condition Expr self clause asked about var list");
467 return getExprs();
468 }
469
471 return child_range(
472 reinterpret_cast<Stmt **>(getTrailingObjects()),
473 reinterpret_cast<Stmt **>(getTrailingObjects() + NumExprs));
474 }
475
477 child_range Children = const_cast<OpenACCSelfClause *>(this)->children();
478 return const_child_range(Children.begin(), Children.end());
479 }
480
481 static OpenACCSelfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
482 SourceLocation LParenLoc,
483 Expr *ConditionExpr, SourceLocation EndLoc);
484 static OpenACCSelfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
485 SourceLocation LParenLoc,
486 ArrayRef<Expr *> ConditionExpr,
487 SourceLocation EndLoc);
488};
489
490/// Represents a clause that has one or more expressions associated with it.
493
494protected:
496 SourceLocation LParenLoc, SourceLocation EndLoc)
497 : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc) {}
498
499 /// Used only for initialization, the leaf class can initialize this to
500 /// trailing storage.
502 assert(Exprs.empty() && "Cannot change Exprs list");
503 Exprs = NewExprs;
504 }
505
506 /// Used only for initialization, the leaf class can initialize this to
507 /// trailing storage, and initialize the data in the trailing storage as well.
509 assert(NewStorage.size() == Exprs.size());
510 llvm::uninitialized_copy(Exprs, NewStorage.begin());
511 setExprs(NewStorage);
512 }
513
514 /// Gets the entire list of expressions, but leave it to the
515 /// individual clauses to expose this how they'd like.
516 ArrayRef<Expr *> getExprs() const { return Exprs; }
517
518public:
519 static bool classof(const OpenACCClause *C);
521 return child_range(reinterpret_cast<Stmt **>(Exprs.begin()),
522 reinterpret_cast<Stmt **>(Exprs.end()));
523 }
524
526 child_range Children =
527 const_cast<OpenACCClauseWithExprs *>(this)->children();
528 return const_child_range(Children.begin(), Children.end());
529 }
530};
531
532// Represents the 'devnum' and expressions lists for the 'wait' clause.
534 : public OpenACCClauseWithExprs,
535 private llvm::TrailingObjects<OpenACCWaitClause, Expr *> {
536 friend TrailingObjects;
537 SourceLocation QueuesLoc;
539 Expr *DevNumExpr, SourceLocation QueuesLoc,
540 ArrayRef<Expr *> QueueIdExprs, SourceLocation EndLoc)
541 : OpenACCClauseWithExprs(OpenACCClauseKind::Wait, BeginLoc, LParenLoc,
542 EndLoc),
543 QueuesLoc(QueuesLoc) {
544 // The first element of the trailing storage is always the devnum expr,
545 // whether it is used or not.
546 auto *Exprs = getTrailingObjects();
547 llvm::uninitialized_copy(ArrayRef(DevNumExpr), Exprs);
548 llvm::uninitialized_copy(QueueIdExprs, Exprs + 1);
549 setExprs(getTrailingObjects(QueueIdExprs.size() + 1));
550 }
551
552public:
553 static bool classof(const OpenACCClause *C) {
554 return C->getClauseKind() == OpenACCClauseKind::Wait;
555 }
556 static OpenACCWaitClause *Create(const ASTContext &C, SourceLocation BeginLoc,
557 SourceLocation LParenLoc, Expr *DevNumExpr,
558 SourceLocation QueuesLoc,
559 ArrayRef<Expr *> QueueIdExprs,
560 SourceLocation EndLoc);
561
562 bool hasQueuesTag() const { return !QueuesLoc.isInvalid(); }
563 SourceLocation getQueuesLoc() const { return QueuesLoc; }
564 bool hasDevNumExpr() const { return getExprs()[0]; }
565 Expr *getDevNumExpr() const { return getExprs()[0]; }
567 return OpenACCClauseWithExprs::getExprs().drop_front();
568 }
570 return OpenACCClauseWithExprs::getExprs().drop_front();
571 }
572 // If this is a plain `wait` (no parens) this returns 'false'. Else Sema/Parse
573 // ensures we have at least one QueueId expression.
574 bool hasExprs() const { return getLParenLoc().isValid(); }
575};
576
578 : public OpenACCClauseWithExprs,
579 private llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
580 friend TrailingObjects;
581
583 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
585 EndLoc) {
586 setExprs(getTrailingObjects(IntExprs.size()), IntExprs);
587 }
588
589public:
590 static bool classof(const OpenACCClause *C) {
591 return C->getClauseKind() == OpenACCClauseKind::NumGangs;
592 }
593 static OpenACCNumGangsClause *
594 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
595 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
596
598
601 }
602};
603
605 : public OpenACCClauseWithExprs,
606 private llvm::TrailingObjects<OpenACCTileClause, Expr *> {
607 friend TrailingObjects;
609 ArrayRef<Expr *> SizeExprs, SourceLocation EndLoc)
610 : OpenACCClauseWithExprs(OpenACCClauseKind::Tile, BeginLoc, LParenLoc,
611 EndLoc) {
612 setExprs(getTrailingObjects(SizeExprs.size()), SizeExprs);
613 }
614
615public:
616 static bool classof(const OpenACCClause *C) {
617 return C->getClauseKind() == OpenACCClauseKind::Tile;
618 }
619 static OpenACCTileClause *Create(const ASTContext &C, SourceLocation BeginLoc,
620 SourceLocation LParenLoc,
621 ArrayRef<Expr *> SizeExprs,
622 SourceLocation EndLoc);
624
627 }
628};
629
630/// Represents one of a handful of clauses that have a single integer
631/// expression.
633 Expr *IntExpr;
634
635protected:
637 SourceLocation LParenLoc, Expr *IntExpr,
638 SourceLocation EndLoc)
639 : OpenACCClauseWithExprs(K, BeginLoc, LParenLoc, EndLoc),
640 IntExpr(IntExpr) {
641 if (IntExpr)
642 setExprs(MutableArrayRef<Expr *>{&this->IntExpr, 1});
643 }
644
645public:
646 static bool classof(const OpenACCClause *C);
647 bool hasIntExpr() const { return !getExprs().empty(); }
648 const Expr *getIntExpr() const {
649 return hasIntExpr() ? getExprs()[0] : nullptr;
650 }
651
652 Expr *getIntExpr() { return hasIntExpr() ? getExprs()[0] : nullptr; };
653};
654
656 : public OpenACCClauseWithExprs,
657 private llvm::TrailingObjects<OpenACCGangClause, Expr *, OpenACCGangKind> {
658 friend TrailingObjects;
659protected:
662 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
663
664 OpenACCGangKind getGangKind(unsigned I) const {
665 return getTrailingObjects<OpenACCGangKind>()[I];
666 }
667
668public:
669 static bool classof(const OpenACCClause *C) {
670 return C->getClauseKind() == OpenACCClauseKind::Gang;
671 }
672
673 size_t numTrailingObjects(OverloadToken<Expr *>) const {
674 return getNumExprs();
675 }
676
677 unsigned getNumExprs() const { return getExprs().size(); }
678 std::pair<OpenACCGangKind, const Expr *> getExpr(unsigned I) const {
679 return {getGangKind(I), getExprs()[I]};
680 }
681
683 for (unsigned I = 0; I < getNumExprs(); ++I) {
684 if (getGangKind(I) == GK)
685 return true;
686 }
687 return false;
688 }
689
690 static OpenACCGangClause *
691 Create(const ASTContext &Ctx, SourceLocation BeginLoc,
692 SourceLocation LParenLoc, ArrayRef<OpenACCGangKind> GangKinds,
693 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
694};
695
697protected:
699 Expr *IntExpr, SourceLocation EndLoc);
700
701public:
702 static bool classof(const OpenACCClause *C) {
703 return C->getClauseKind() == OpenACCClauseKind::Worker;
704 }
705
706 static OpenACCWorkerClause *Create(const ASTContext &Ctx,
707 SourceLocation BeginLoc,
708 SourceLocation LParenLoc, Expr *IntExpr,
709 SourceLocation EndLoc);
710};
711
713protected:
715 Expr *IntExpr, SourceLocation EndLoc);
716
717public:
718 static bool classof(const OpenACCClause *C) {
719 return C->getClauseKind() == OpenACCClauseKind::Vector;
720 }
721
722 static OpenACCVectorClause *Create(const ASTContext &Ctx,
723 SourceLocation BeginLoc,
724 SourceLocation LParenLoc, Expr *IntExpr,
725 SourceLocation EndLoc);
726};
727
730 Expr *IntExpr, SourceLocation EndLoc);
731
732public:
733 static bool classof(const OpenACCClause *C) {
734 return C->getClauseKind() == OpenACCClauseKind::NumWorkers;
735 }
737 SourceLocation BeginLoc,
738 SourceLocation LParenLoc,
739 Expr *IntExpr, SourceLocation EndLoc);
740};
741
744 Expr *IntExpr, SourceLocation EndLoc);
745
746public:
747 static bool classof(const OpenACCClause *C) {
748 return C->getClauseKind() == OpenACCClauseKind::VectorLength;
749 }
751 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
752 Expr *IntExpr, SourceLocation EndLoc);
753};
754
757 Expr *IntExpr, SourceLocation EndLoc);
758
759public:
760 static bool classof(const OpenACCClause *C) {
761 return C->getClauseKind() == OpenACCClauseKind::Async;
762 }
763 static OpenACCAsyncClause *Create(const ASTContext &C,
764 SourceLocation BeginLoc,
765 SourceLocation LParenLoc, Expr *IntExpr,
766 SourceLocation EndLoc);
767};
768
771 Expr *IntExpr, SourceLocation EndLoc);
772
773public:
774 static bool classof(const OpenACCClause *C) {
775 return C->getClauseKind() == OpenACCClauseKind::DeviceNum;
776 }
778 SourceLocation BeginLoc,
779 SourceLocation LParenLoc, Expr *IntExpr,
780 SourceLocation EndLoc);
781};
782
785 Expr *IntExpr, SourceLocation EndLoc);
786
787public:
788 static bool classof(const OpenACCClause *C) {
789 return C->getClauseKind() == OpenACCClauseKind::DefaultAsync;
790 }
792 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
793 Expr *IntExpr, SourceLocation EndLoc);
794};
795
796/// Represents a 'collapse' clause on a 'loop' construct. This clause takes an
797/// integer constant expression 'N' that represents how deep to collapse the
798/// construct. It also takes an optional 'force' tag that permits intervening
799/// code in the loops.
801 bool HasForce = false;
802
804 bool HasForce, Expr *LoopCount, SourceLocation EndLoc);
805
806public:
807 const Expr *getLoopCount() const { return getIntExpr(); }
808 Expr *getLoopCount() { return getIntExpr(); }
809
810 bool hasForce() const { return HasForce; }
811
812 static bool classof(const OpenACCClause *C) {
813 return C->getClauseKind() == OpenACCClauseKind::Collapse;
814 }
815
817 SourceLocation BeginLoc,
818 SourceLocation LParenLoc, bool HasForce,
819 Expr *LoopCount, SourceLocation EndLoc);
820};
821
822/// Represents a clause with one or more 'var' objects, represented as an expr,
823/// as its arguments. Var-list is expected to be stored in trailing storage.
824/// For now, we're just storing the original expression in its entirety, unlike
825/// OMP which has to do a bunch of work to create a private.
827protected:
829 SourceLocation LParenLoc, SourceLocation EndLoc)
830 : OpenACCClauseWithExprs(K, BeginLoc, LParenLoc, EndLoc) {}
831
832public:
833 static bool classof(const OpenACCClause *C);
836};
837
840 private llvm::TrailingObjects<OpenACCPrivateClause, Expr *, VarDecl *> {
841 friend TrailingObjects;
842
844 ArrayRef<Expr *> VarList,
845 ArrayRef<VarDecl *> InitRecipes, SourceLocation EndLoc)
847 LParenLoc, EndLoc) {
848 assert(VarList.size() == InitRecipes.size());
849 setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
850 llvm::uninitialized_copy(InitRecipes, getTrailingObjects<VarDecl *>());
851 }
852
853public:
854 static bool classof(const OpenACCClause *C) {
855 return C->getClauseKind() == OpenACCClauseKind::Private;
856 }
857 // Gets a list of 'made up' `VarDecl` objects that can be used by codegen to
858 // ensure that we properly initialize each of these variables.
860 return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
861 getExprs().size()};
862 }
863
865 return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
866 getExprs().size()};
867 }
868
869 static OpenACCPrivateClause *
870 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
871 ArrayRef<Expr *> VarList, ArrayRef<VarDecl *> InitRecipes,
872 SourceLocation EndLoc);
873
874 size_t numTrailingObjects(OverloadToken<Expr *>) const {
875 return getExprs().size();
876 }
877};
878
879// A 'pair' to stand in for the recipe. RecipeDecl is the main declaration, and
880// InitFromTemporary is the 'temp' declaration we put in to be 'copied from'.
885 OpenACCFirstPrivateRecipe(std::pair<VarDecl *, VarDecl *> p)
886 : RecipeDecl(p.first), InitFromTemporary(p.second) {}
887};
888
891 private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *,
892 OpenACCFirstPrivateRecipe> {
893 friend TrailingObjects;
894
896 ArrayRef<Expr *> VarList,
898 SourceLocation EndLoc)
900 LParenLoc, EndLoc) {
901 assert(VarList.size() == InitRecipes.size());
902 setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
903 llvm::uninitialized_copy(InitRecipes,
904 getTrailingObjects<OpenACCFirstPrivateRecipe>());
905 }
906
907public:
908 static bool classof(const OpenACCClause *C) {
909 return C->getClauseKind() == OpenACCClauseKind::FirstPrivate;
910 }
911
912 // Gets a list of 'made up' `VarDecl` objects that can be used by codegen to
913 // ensure that we properly initialize each of these variables.
916 getTrailingObjects<OpenACCFirstPrivateRecipe>(), getExprs().size()};
917 }
918
921 getTrailingObjects<OpenACCFirstPrivateRecipe>(), getExprs().size()};
922 }
923
925 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
926 ArrayRef<Expr *> VarList,
928 SourceLocation EndLoc);
929
930 size_t numTrailingObjects(OverloadToken<Expr *>) const {
931 return getExprs().size();
932 }
933};
934
937 private llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {
938 friend TrailingObjects;
939
941 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
943 LParenLoc, EndLoc) {
944 setExprs(getTrailingObjects(VarList.size()), VarList);
945 }
946
947public:
948 static bool classof(const OpenACCClause *C) {
949 return C->getClauseKind() == OpenACCClauseKind::DevicePtr;
950 }
952 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
953 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
954};
955
958 private llvm::TrailingObjects<OpenACCAttachClause, Expr *> {
959 friend TrailingObjects;
960
962 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
964 EndLoc) {
965 setExprs(getTrailingObjects(VarList.size()), VarList);
966 }
967
968public:
969 static bool classof(const OpenACCClause *C) {
970 return C->getClauseKind() == OpenACCClauseKind::Attach;
971 }
972 static OpenACCAttachClause *
973 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
974 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
975};
976
979 private llvm::TrailingObjects<OpenACCDetachClause, Expr *> {
980 friend TrailingObjects;
981
983 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
985 EndLoc) {
986 setExprs(getTrailingObjects(VarList.size()), VarList);
987 }
988
989public:
990 static bool classof(const OpenACCClause *C) {
991 return C->getClauseKind() == OpenACCClauseKind::Detach;
992 }
993 static OpenACCDetachClause *
994 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
995 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
996};
997
1000 private llvm::TrailingObjects<OpenACCDeleteClause, Expr *> {
1001 friend TrailingObjects;
1002
1004 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1006 EndLoc) {
1007 setExprs(getTrailingObjects(VarList.size()), VarList);
1008 }
1009
1010public:
1011 static bool classof(const OpenACCClause *C) {
1012 return C->getClauseKind() == OpenACCClauseKind::Delete;
1013 }
1014 static OpenACCDeleteClause *
1015 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
1016 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
1017};
1018
1020 : public OpenACCClauseWithVarList,
1021 private llvm::TrailingObjects<OpenACCUseDeviceClause, Expr *> {
1022 friend TrailingObjects;
1023
1025 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1027 LParenLoc, EndLoc) {
1028 setExprs(getTrailingObjects(VarList.size()), VarList);
1029 }
1030
1031public:
1032 static bool classof(const OpenACCClause *C) {
1033 return C->getClauseKind() == OpenACCClauseKind::UseDevice;
1034 }
1035 static OpenACCUseDeviceClause *
1036 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
1037 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
1038};
1039
1041 : public OpenACCClauseWithVarList,
1042 private llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {
1043 friend TrailingObjects;
1044
1046 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1048 LParenLoc, EndLoc) {
1049 setExprs(getTrailingObjects(VarList.size()), VarList);
1050 }
1051
1052public:
1053 static bool classof(const OpenACCClause *C) {
1054 return C->getClauseKind() == OpenACCClauseKind::NoCreate;
1055 }
1056 static OpenACCNoCreateClause *
1057 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
1058 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
1059};
1060
1062 : public OpenACCClauseWithVarList,
1063 private llvm::TrailingObjects<OpenACCPresentClause, Expr *> {
1064 friend TrailingObjects;
1065
1067 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1069 LParenLoc, EndLoc) {
1070 setExprs(getTrailingObjects(VarList.size()), VarList);
1071 }
1072
1073public:
1074 static bool classof(const OpenACCClause *C) {
1075 return C->getClauseKind() == OpenACCClauseKind::Present;
1076 }
1077 static OpenACCPresentClause *
1078 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
1079 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
1080};
1082 : public OpenACCClauseWithVarList,
1083 private llvm::TrailingObjects<OpenACCHostClause, Expr *> {
1084 friend TrailingObjects;
1085
1087 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1089 EndLoc) {
1090 setExprs(getTrailingObjects(VarList.size()), VarList);
1091 }
1092
1093public:
1094 static bool classof(const OpenACCClause *C) {
1095 return C->getClauseKind() == OpenACCClauseKind::Host;
1096 }
1097 static OpenACCHostClause *Create(const ASTContext &C, SourceLocation BeginLoc,
1098 SourceLocation LParenLoc,
1099 ArrayRef<Expr *> VarList,
1100 SourceLocation EndLoc);
1101};
1102
1104 : public OpenACCClauseWithVarList,
1105 private llvm::TrailingObjects<OpenACCDeviceClause, Expr *> {
1106 friend TrailingObjects;
1107
1109 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1111 EndLoc) {
1112 setExprs(getTrailingObjects(VarList.size()), VarList);
1113 }
1114
1115public:
1116 static bool classof(const OpenACCClause *C) {
1117 return C->getClauseKind() == OpenACCClauseKind::Device;
1118 }
1119 static OpenACCDeviceClause *
1120 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
1121 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
1122};
1123
1125 : public OpenACCClauseWithVarList,
1126 private llvm::TrailingObjects<OpenACCCopyClause, Expr *> {
1127 friend TrailingObjects;
1128 OpenACCModifierKind Modifiers;
1129
1131 SourceLocation LParenLoc, OpenACCModifierKind Mods,
1132 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1133 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc),
1134 Modifiers(Mods) {
1135 assert((Spelling == OpenACCClauseKind::Copy ||
1136 Spelling == OpenACCClauseKind::PCopy ||
1137 Spelling == OpenACCClauseKind::PresentOrCopy) &&
1138 "Invalid clause kind for copy-clause");
1139 setExprs(getTrailingObjects(VarList.size()), VarList);
1140 }
1141
1142public:
1143 static bool classof(const OpenACCClause *C) {
1144 return C->getClauseKind() == OpenACCClauseKind::Copy ||
1145 C->getClauseKind() == OpenACCClauseKind::PCopy ||
1146 C->getClauseKind() == OpenACCClauseKind::PresentOrCopy;
1147 }
1148 static OpenACCCopyClause *
1149 Create(const ASTContext &C, OpenACCClauseKind Spelling,
1150 SourceLocation BeginLoc, SourceLocation LParenLoc,
1152 SourceLocation EndLoc);
1153
1154 OpenACCModifierKind getModifierList() const { return Modifiers; }
1155};
1156
1158 : public OpenACCClauseWithVarList,
1159 private llvm::TrailingObjects<OpenACCCopyInClause, Expr *> {
1160 friend TrailingObjects;
1161 OpenACCModifierKind Modifiers;
1162
1164 SourceLocation LParenLoc, OpenACCModifierKind Mods,
1165 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1166 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc),
1167 Modifiers(Mods) {
1168 assert((Spelling == OpenACCClauseKind::CopyIn ||
1169 Spelling == OpenACCClauseKind::PCopyIn ||
1171 "Invalid clause kind for copyin-clause");
1172 setExprs(getTrailingObjects(VarList.size()), VarList);
1173 }
1174
1175public:
1176 static bool classof(const OpenACCClause *C) {
1177 return C->getClauseKind() == OpenACCClauseKind::CopyIn ||
1178 C->getClauseKind() == OpenACCClauseKind::PCopyIn ||
1179 C->getClauseKind() == OpenACCClauseKind::PresentOrCopyIn;
1180 }
1181 OpenACCModifierKind getModifierList() const { return Modifiers; }
1182 static OpenACCCopyInClause *
1183 Create(const ASTContext &C, OpenACCClauseKind Spelling,
1184 SourceLocation BeginLoc, SourceLocation LParenLoc,
1186 SourceLocation EndLoc);
1187};
1188
1190 : public OpenACCClauseWithVarList,
1191 private llvm::TrailingObjects<OpenACCCopyOutClause, Expr *> {
1192 friend TrailingObjects;
1193 OpenACCModifierKind Modifiers;
1194
1196 SourceLocation LParenLoc, OpenACCModifierKind Mods,
1197 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1198 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc),
1199 Modifiers(Mods) {
1200 assert((Spelling == OpenACCClauseKind::CopyOut ||
1201 Spelling == OpenACCClauseKind::PCopyOut ||
1203 "Invalid clause kind for copyout-clause");
1204 setExprs(getTrailingObjects(VarList.size()), VarList);
1205 }
1206
1207public:
1208 static bool classof(const OpenACCClause *C) {
1209 return C->getClauseKind() == OpenACCClauseKind::CopyOut ||
1210 C->getClauseKind() == OpenACCClauseKind::PCopyOut ||
1211 C->getClauseKind() == OpenACCClauseKind::PresentOrCopyOut;
1212 }
1213 OpenACCModifierKind getModifierList() const { return Modifiers; }
1214 static OpenACCCopyOutClause *
1215 Create(const ASTContext &C, OpenACCClauseKind Spelling,
1216 SourceLocation BeginLoc, SourceLocation LParenLoc,
1218 SourceLocation EndLoc);
1219};
1220
1222 : public OpenACCClauseWithVarList,
1223 private llvm::TrailingObjects<OpenACCCreateClause, Expr *> {
1224 friend TrailingObjects;
1225 OpenACCModifierKind Modifiers;
1226
1228 SourceLocation LParenLoc, OpenACCModifierKind Mods,
1229 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1230 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc),
1231 Modifiers(Mods) {
1232 assert((Spelling == OpenACCClauseKind::Create ||
1233 Spelling == OpenACCClauseKind::PCreate ||
1235 "Invalid clause kind for create-clause");
1236 setExprs(getTrailingObjects(VarList.size()), VarList);
1237 }
1238
1239public:
1240 static bool classof(const OpenACCClause *C) {
1241 return C->getClauseKind() == OpenACCClauseKind::Create ||
1242 C->getClauseKind() == OpenACCClauseKind::PCreate ||
1243 C->getClauseKind() == OpenACCClauseKind::PresentOrCreate;
1244 }
1245 OpenACCModifierKind getModifierList() const { return Modifiers; }
1246 static OpenACCCreateClause *
1247 Create(const ASTContext &C, OpenACCClauseKind Spelling,
1248 SourceLocation BeginLoc, SourceLocation LParenLoc,
1250 SourceLocation EndLoc);
1251};
1252
1253// A structure to stand in for the recipe on a reduction. RecipeDecl is the
1254// 'main' declaration used for initializaiton, which is fixed.
1257 // TODO: OpenACC: this should eventually have the operations here too.
1258};
1259
1261 : public OpenACCClauseWithVarList,
1262 private llvm::TrailingObjects<OpenACCReductionClause, Expr *,
1263 OpenACCReductionRecipe> {
1264 friend TrailingObjects;
1266
1268 OpenACCReductionOperator Operator,
1269 ArrayRef<Expr *> VarList,
1271 SourceLocation EndLoc)
1273 LParenLoc, EndLoc),
1274 Op(Operator) {
1275 assert(VarList.size() == Recipes.size());
1276 setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
1277 llvm::uninitialized_copy(Recipes, getTrailingObjects<
1279 }
1280
1281public:
1282 static bool classof(const OpenACCClause *C) {
1283 return C->getClauseKind() == OpenACCClauseKind::Reduction;
1284 }
1285
1288 getTrailingObjects<OpenACCReductionRecipe>(), getExprs().size()};
1289 }
1290
1293 getTrailingObjects<OpenACCReductionRecipe>(), getExprs().size()};
1294 }
1295
1296 static OpenACCReductionClause *
1297 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
1300
1302
1303 size_t numTrailingObjects(OverloadToken<Expr *>) const {
1304 return getExprs().size();
1305 }
1306};
1307
1309 : public OpenACCClauseWithVarList,
1310 private llvm::TrailingObjects<OpenACCLinkClause, Expr *> {
1311 friend TrailingObjects;
1312
1314 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1316 EndLoc) {
1317 setExprs(getTrailingObjects(VarList.size()), VarList);
1318 }
1319
1320public:
1321 static bool classof(const OpenACCClause *C) {
1322 return C->getClauseKind() == OpenACCClauseKind::Link;
1323 }
1324
1325 static OpenACCLinkClause *Create(const ASTContext &C, SourceLocation BeginLoc,
1326 SourceLocation LParenLoc,
1327 ArrayRef<Expr *> VarList,
1328 SourceLocation EndLoc);
1329};
1330
1332 : public OpenACCClauseWithVarList,
1333 private llvm::TrailingObjects<OpenACCDeviceResidentClause, Expr *> {
1334 friend TrailingObjects;
1335
1337 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
1339 LParenLoc, EndLoc) {
1340 setExprs(getTrailingObjects(VarList.size()), VarList);
1341 }
1342
1343public:
1344 static bool classof(const OpenACCClause *C) {
1345 return C->getClauseKind() == OpenACCClauseKind::DeviceResident;
1346 }
1347
1349 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
1350 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
1351};
1352
1353template <class Impl> class OpenACCClauseVisitor {
1354 Impl &getDerived() { return static_cast<Impl &>(*this); }
1355
1356public:
1358 for (const OpenACCClause *Clause : List)
1359 Visit(Clause);
1360 }
1361
1362 void Visit(const OpenACCClause *C) {
1363 if (!C)
1364 return;
1365
1366 switch (C->getClauseKind()) {
1367#define VISIT_CLAUSE(CLAUSE_NAME) \
1368 case OpenACCClauseKind::CLAUSE_NAME: \
1369 getDerived().Visit##CLAUSE_NAME##Clause( \
1370 *cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1371 return;
1372#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED) \
1373 case OpenACCClauseKind::ALIAS_NAME: \
1374 getDerived().Visit##CLAUSE_NAME##Clause( \
1375 *cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1376 return;
1377#include "clang/Basic/OpenACCClauses.def"
1378
1379 default:
1380 llvm_unreachable("Clause visitor not yet implemented");
1381 }
1382 llvm_unreachable("Invalid Clause kind");
1383 }
1384
1385#define VISIT_CLAUSE(CLAUSE_NAME) \
1386 void Visit##CLAUSE_NAME##Clause( \
1387 const OpenACC##CLAUSE_NAME##Clause &Clause) { \
1388 return getDerived().VisitClause(Clause); \
1389 }
1390
1391#include "clang/Basic/OpenACCClauses.def"
1392};
1393
1395 : public OpenACCClauseVisitor<OpenACCClausePrinter> {
1396 raw_ostream &OS;
1397 const PrintingPolicy &Policy;
1398
1399 void printExpr(const Expr *E);
1400
1401public:
1403 for (const OpenACCClause *Clause : List) {
1404 Visit(Clause);
1405
1406 if (Clause != List.back())
1407 OS << ' ';
1408 }
1409 }
1410 OpenACCClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
1411 : OS(OS), Policy(Policy) {}
1412
1413#define VISIT_CLAUSE(CLAUSE_NAME) \
1414 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
1415#include "clang/Basic/OpenACCClauses.def"
1416};
1417
1418} // namespace clang
1419
1420#endif // LLVM_CLANG_AST_OPENACCCLAUSE_H
Defines the clang::ASTContext interface.
static char ID
Definition: Arena.cpp:183
Expr * E
Defines some OpenACC-specific enums and functions.
static bool isInvalid(LocType Loc, bool *Invalid)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
This represents one expression.
Definition: Expr.h:112
One of these records is kept for each identifier that is lexed.
A simple pair of identifier info and location.
SourceLocation getLoc() const
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
const_child_range children() const
Definition: OpenACCClause.h:78
OpenACCAutoClause(SourceLocation BeginLoc, SourceLocation EndLoc)
Definition: OpenACCClause.h:64
static bool classof(const OpenACCClause *C)
Definition: OpenACCClause.h:68
const IdentifierInfo * getIdentifierArgument() const
const StringLiteral * getStringArgument() const
static bool classof(const OpenACCClause *C)
bool isIdentifierArgument() const
bool isStringArgument() const
OpenACCClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
void VisitClauseList(ArrayRef< const OpenACCClause * > List)
void Visit(const OpenACCClause *C)
void VisitClauseList(ArrayRef< const OpenACCClause * > List)
Represents one of the handful of classes that has an optional/required 'condition' expression as an a...
static bool classof(const OpenACCClause *C)
const Expr * getConditionExpr() const
OpenACCClauseWithCondition(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
const_child_range children() const
Represents a clause that has one or more expressions associated with it.
void setExprs(MutableArrayRef< Expr * > NewStorage, ArrayRef< Expr * > Exprs)
Used only for initialization, the leaf class can initialize this to trailing storage,...
static bool classof(const OpenACCClause *C)
OpenACCClauseWithExprs(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ArrayRef< Expr * > getExprs() const
Gets the entire list of expressions, but leave it to the individual clauses to expose this how they'd...
const_child_range children() const
void setExprs(MutableArrayRef< Expr * > NewExprs)
Used only for initialization, the leaf class can initialize this to trailing storage.
Represents a clause that has a list of parameters.
SourceLocation getLParenLoc() const
static bool classof(const OpenACCClause *C)
OpenACCClauseWithParams(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
const_child_range children() const
Represents one of a handful of clauses that have a single integer expression.
OpenACCClauseWithSingleIntExpr(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
Represents a clause with one or more 'var' objects, represented as an expr, as its arguments.
OpenACCClauseWithVarList(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
ArrayRef< Expr * > getVarList()
ArrayRef< Expr * > getVarList() const
This is the base type for all OpenACC Clauses.
Definition: OpenACCClause.h:27
child_range children()
StmtIterator child_iterator
Definition: OpenACCClause.h:47
OpenACCClauseKind getClauseKind() const
Definition: OpenACCClause.h:40
SourceLocation getBeginLoc() const
Definition: OpenACCClause.h:41
SourceRange getSourceRange() const
Definition: OpenACCClause.h:43
const_child_range children() const
Definition: OpenACCClause.h:53
static bool classof(const OpenACCClause *)
Definition: OpenACCClause.h:45
llvm::iterator_range< child_iterator > child_range
Definition: OpenACCClause.h:49
ConstStmtIterator const_child_iterator
Definition: OpenACCClause.h:48
OpenACCClause(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation EndLoc)
Definition: OpenACCClause.h:32
virtual ~OpenACCClause()=default
llvm::iterator_range< const_child_iterator > const_child_range
Definition: OpenACCClause.h:50
SourceLocation getEndLoc() const
Definition: OpenACCClause.h:42
Represents a 'collapse' clause on a 'loop' construct.
const Expr * getLoopCount() const
static bool classof(const OpenACCClause *C)
OpenACCModifierKind getModifierList() const
static bool classof(const OpenACCClause *C)
OpenACCModifierKind getModifierList() const
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
OpenACCModifierKind getModifierList() const
static bool classof(const OpenACCClause *C)
OpenACCModifierKind getModifierList() const
static bool classof(const OpenACCClause *C)
A 'default' clause, has the optional 'none' or 'present' argument.
OpenACCDefaultClause(OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
OpenACCDefaultClauseKind getDefaultClauseKind() const
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
ArrayRef< DeviceTypeArgument > getArchitectures() const
static bool classof(const OpenACCClause *C)
OpenACCFinalizeClause(SourceLocation BeginLoc, SourceLocation EndLoc)
Definition: OpenACCClause.h:86
static bool classof(const OpenACCClause *C)
Definition: OpenACCClause.h:90
const_child_range children() const
size_t numTrailingObjects(OverloadToken< Expr * >) const
ArrayRef< OpenACCFirstPrivateRecipe > getInitRecipes() const
ArrayRef< OpenACCFirstPrivateRecipe > getInitRecipes()
static bool classof(const OpenACCClause *C)
OpenACCGangKind getGangKind(unsigned I) const
bool hasExprOfKind(OpenACCGangKind GK) const
size_t numTrailingObjects(OverloadToken< Expr * >) const
static bool classof(const OpenACCClause *C)
unsigned getNumExprs() const
std::pair< OpenACCGangKind, const Expr * > getExpr(unsigned I) const
static bool classof(const OpenACCClause *C)
An 'if' clause, which has a required condition expression.
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
const_child_range children() const
OpenACCIfPresentClause(SourceLocation BeginLoc, SourceLocation EndLoc)
OpenACCIndependentClause(SourceLocation BeginLoc, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
const_child_range children() const
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
OpenACCNoHostClause(SourceLocation BeginLoc, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
const_child_range children() const
ArrayRef< Expr * > getIntExprs() const
static bool classof(const OpenACCClause *C)
ArrayRef< Expr * > getIntExprs()
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
ArrayRef< VarDecl * > getInitRecipes()
size_t numTrailingObjects(OverloadToken< Expr * >) const
ArrayRef< VarDecl * > getInitRecipes() const
ArrayRef< OpenACCReductionRecipe > getRecipes() const
size_t numTrailingObjects(OverloadToken< Expr * >) const
ArrayRef< OpenACCReductionRecipe > getRecipes()
static bool classof(const OpenACCClause *C)
OpenACCReductionOperator getReductionOp() const
A 'self' clause, which has an optional condition expression, or, in the event of an 'update' directiv...
const Expr * getConditionExpr() const
bool isConditionExprClause() const
const_child_range children() const
static bool classof(const OpenACCClause *C)
ArrayRef< Expr * > getVarList()
bool hasConditionExpr() const
bool isEmptySelfClause() const
bool isVarListClause() const
ArrayRef< Expr * > getVarList() const
static bool classof(const OpenACCClause *C)
const_child_range children() const
OpenACCSeqClause(SourceLocation BeginLoc, SourceLocation EndLoc)
ArrayRef< Expr * > getSizeExprs()
ArrayRef< Expr * > getSizeExprs() const
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
ArrayRef< Expr * > getQueueIdExprs()
Expr * getDevNumExpr() const
ArrayRef< Expr * > getQueueIdExprs() const
SourceLocation getQueuesLoc() const
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition: Stmt.h:85
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1801
Represents a variable declaration or definition.
Definition: Decl.h:925
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCReductionOperator
Definition: OpenACCKinds.h:547
OpenACCModifierKind
Definition: OpenACCKinds.h:641
OpenACCClauseKind
Represents the kind of an OpenACC clause.
Definition: OpenACCKinds.h:207
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Bind
'bind' clause, allowed on routine constructs.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ 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.
@ NoHost
'nohost' clause, allowed on 'routine' directives.
@ 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',...
@ Seq
'seq' clause, allowed on 'loop' and 'routine' directives.
@ 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.
@ Independent
'independent' clause, allowed on 'loop' directives.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ IfPresent
'if_present' clause, allowed on 'host_data' and 'update' directives.
@ 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'.
@ Finalize
'finalize' clause, allowed on 'exit data' directive.
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition: CallGraph.h:204
OpenACCDefaultClauseKind
Definition: OpenACCKinds.h:514
bool operator!=(CanQual< T > x, CanQual< U > y)
const FunctionProtoType * T
OpenACCGangKind
Definition: OpenACCKinds.h:606
OpenACCFirstPrivateRecipe(std::pair< VarDecl *, VarDecl * > p)
OpenACCFirstPrivateRecipe(VarDecl *R, VarDecl *T)
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57