clang 19.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
19
20#include <utility>
21
22namespace clang {
23/// This is the base type for all OpenACC Clauses.
26 SourceRange Location;
27
28protected:
30 SourceLocation EndLoc)
31 : Kind(K), Location(BeginLoc, EndLoc) {
32 assert(!BeginLoc.isInvalid() && !EndLoc.isInvalid() &&
33 "Begin and end location must be valid for OpenACCClause");
34 }
35
36public:
37 OpenACCClauseKind getClauseKind() const { return Kind; }
38 SourceLocation getBeginLoc() const { return Location.getBegin(); }
39 SourceLocation getEndLoc() const { return Location.getEnd(); }
40
41 static bool classof(const OpenACCClause *) { return false; }
42
45 using child_range = llvm::iterator_range<child_iterator>;
46 using const_child_range = llvm::iterator_range<const_child_iterator>;
47
50 auto Children = const_cast<OpenACCClause *>(this)->children();
51 return const_child_range(Children.begin(), Children.end());
52 }
53
54 virtual ~OpenACCClause() = default;
55};
56
57/// Represents a clause that has a list of parameters.
59 /// Location of the '('.
60 SourceLocation LParenLoc;
61
62protected:
64 SourceLocation LParenLoc, SourceLocation EndLoc)
65 : OpenACCClause(K, BeginLoc, EndLoc), LParenLoc(LParenLoc) {}
66
67public:
68 static bool classof(const OpenACCClause *C);
69
70 SourceLocation getLParenLoc() const { return LParenLoc; }
71
74 }
77 }
78};
79
80using DeviceTypeArgument = std::pair<IdentifierInfo *, SourceLocation>;
81/// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or
82/// an identifier. The 'asterisk' means 'the rest'.
85 public llvm::TrailingObjects<OpenACCDeviceTypeClause,
86 DeviceTypeArgument> {
87 // Data stored in trailing objects as IdentifierInfo* /SourceLocation pairs. A
88 // nullptr IdentifierInfo* represents an asterisk.
89 unsigned NumArchs;
91 SourceLocation LParenLoc,
93 SourceLocation EndLoc)
94 : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
95 NumArchs(Archs.size()) {
96 assert(
98 "Invalid clause kind for device-type");
99
100 assert(!llvm::any_of(Archs, [](const DeviceTypeArgument &Arg) {
101 return Arg.second.isInvalid();
102 }) && "Invalid SourceLocation for an argument");
103
104 assert(
105 (Archs.size() == 1 || !llvm::any_of(Archs,
106 [](const DeviceTypeArgument &Arg) {
107 return Arg.first == nullptr;
108 })) &&
109 "Only a single asterisk version is permitted, and must be the "
110 "only one");
111
112 std::uninitialized_copy(Archs.begin(), Archs.end(),
113 getTrailingObjects<DeviceTypeArgument>());
114 }
115
116public:
117 static bool classof(const OpenACCClause *C) {
118 return C->getClauseKind() == OpenACCClauseKind::DType ||
119 C->getClauseKind() == OpenACCClauseKind::DeviceType;
120 }
121 bool hasAsterisk() const {
122 return getArchitectures().size() > 0 &&
123 getArchitectures()[0].first == nullptr;
124 }
125
128 getTrailingObjects<DeviceTypeArgument>(), NumArchs);
129 }
130
134 SourceLocation EndLoc);
135};
136
137/// A 'default' clause, has the optional 'none' or 'present' argument.
139 friend class ASTReaderStmt;
140 friend class ASTWriterStmt;
141
142 OpenACCDefaultClauseKind DefaultClauseKind;
143
144protected:
146 SourceLocation LParenLoc, SourceLocation EndLoc)
147 : OpenACCClauseWithParams(OpenACCClauseKind::Default, BeginLoc, LParenLoc,
148 EndLoc),
149 DefaultClauseKind(K) {
150 assert((DefaultClauseKind == OpenACCDefaultClauseKind::None ||
151 DefaultClauseKind == OpenACCDefaultClauseKind::Present) &&
152 "Invalid Clause Kind");
153 }
154
155public:
156 static bool classof(const OpenACCClause *C) {
157 return C->getClauseKind() == OpenACCClauseKind::Default;
158 }
160 return DefaultClauseKind;
161 }
162
165 SourceLocation BeginLoc,
166 SourceLocation LParenLoc,
167 SourceLocation EndLoc);
168};
169
170/// Represents one of the handful of classes that has an optional/required
171/// 'condition' expression as an argument.
173 Expr *ConditionExpr = nullptr;
174
175protected:
177 SourceLocation LParenLoc, Expr *ConditionExpr,
178 SourceLocation EndLoc)
179 : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
180 ConditionExpr(ConditionExpr) {}
181
182public:
183 static bool classof(const OpenACCClause *C);
184
185 bool hasConditionExpr() const { return ConditionExpr; }
186 const Expr *getConditionExpr() const { return ConditionExpr; }
187 Expr *getConditionExpr() { return ConditionExpr; }
188
190 if (ConditionExpr)
191 return child_range(reinterpret_cast<Stmt **>(&ConditionExpr),
192 reinterpret_cast<Stmt **>(&ConditionExpr + 1));
194 }
195
197 if (ConditionExpr)
198 return const_child_range(
199 reinterpret_cast<Stmt *const *>(&ConditionExpr),
200 reinterpret_cast<Stmt *const *>(&ConditionExpr + 1));
202 }
203};
204
205/// An 'if' clause, which has a required condition expression.
207protected:
209 Expr *ConditionExpr, SourceLocation EndLoc);
210
211public:
212 static bool classof(const OpenACCClause *C) {
213 return C->getClauseKind() == OpenACCClauseKind::If;
214 }
215 static OpenACCIfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
216 SourceLocation LParenLoc, Expr *ConditionExpr,
217 SourceLocation EndLoc);
218};
219
220/// A 'self' clause, which has an optional condition expression.
223 Expr *ConditionExpr, SourceLocation EndLoc);
224
225public:
226 static bool classof(const OpenACCClause *C) {
227 return C->getClauseKind() == OpenACCClauseKind::Self;
228 }
229 static OpenACCSelfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
230 SourceLocation LParenLoc,
231 Expr *ConditionExpr, SourceLocation EndLoc);
232};
233
234/// Represents a clause that has one or more expressions associated with it.
237
238protected:
240 SourceLocation LParenLoc, SourceLocation EndLoc)
241 : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc) {}
242
243 /// Used only for initialization, the leaf class can initialize this to
244 /// trailing storage.
246 assert(Exprs.empty() && "Cannot change Exprs list");
247 Exprs = NewExprs;
248 }
249
250 /// Gets the entire list of expressions, but leave it to the
251 /// individual clauses to expose this how they'd like.
252 llvm::ArrayRef<Expr *> getExprs() const { return Exprs; }
253
254public:
255 static bool classof(const OpenACCClause *C);
257 return child_range(reinterpret_cast<Stmt **>(Exprs.begin()),
258 reinterpret_cast<Stmt **>(Exprs.end()));
259 }
260
262 child_range Children =
263 const_cast<OpenACCClauseWithExprs *>(this)->children();
264 return const_child_range(Children.begin(), Children.end());
265 }
266};
267
268// Represents the 'devnum' and expressions lists for the 'wait' clause.
270 : public OpenACCClauseWithExprs,
271 public llvm::TrailingObjects<OpenACCWaitClause, Expr *> {
272 SourceLocation QueuesLoc;
274 Expr *DevNumExpr, SourceLocation QueuesLoc,
275 ArrayRef<Expr *> QueueIdExprs, SourceLocation EndLoc)
276 : OpenACCClauseWithExprs(OpenACCClauseKind::Wait, BeginLoc, LParenLoc,
277 EndLoc),
278 QueuesLoc(QueuesLoc) {
279 // The first element of the trailing storage is always the devnum expr,
280 // whether it is used or not.
281 std::uninitialized_copy(&DevNumExpr, &DevNumExpr + 1,
282 getTrailingObjects<Expr *>());
283 std::uninitialized_copy(QueueIdExprs.begin(), QueueIdExprs.end(),
284 getTrailingObjects<Expr *>() + 1);
285 setExprs(
286 MutableArrayRef(getTrailingObjects<Expr *>(), QueueIdExprs.size() + 1));
287 }
288
289public:
290 static bool classof(const OpenACCClause *C) {
291 return C->getClauseKind() == OpenACCClauseKind::Wait;
292 }
293 static OpenACCWaitClause *Create(const ASTContext &C, SourceLocation BeginLoc,
294 SourceLocation LParenLoc, Expr *DevNumExpr,
295 SourceLocation QueuesLoc,
296 ArrayRef<Expr *> QueueIdExprs,
297 SourceLocation EndLoc);
298
299 bool hasQueuesTag() const { return !QueuesLoc.isInvalid(); }
300 SourceLocation getQueuesLoc() const { return QueuesLoc; }
301 bool hasDevNumExpr() const { return getExprs()[0]; }
302 Expr *getDevNumExpr() const { return getExprs()[0]; }
304 return OpenACCClauseWithExprs::getExprs().drop_front();
305 }
307 return OpenACCClauseWithExprs::getExprs().drop_front();
308 }
309};
310
312 : public OpenACCClauseWithExprs,
313 public llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
314
316 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
318 EndLoc) {
319 std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
320 getTrailingObjects<Expr *>());
321 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
322 }
323
324public:
325 static bool classof(const OpenACCClause *C) {
326 return C->getClauseKind() == OpenACCClauseKind::NumGangs;
327 }
328 static OpenACCNumGangsClause *
329 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
330 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc);
331
334 }
335
338 }
339};
340
341/// Represents one of a handful of clauses that have a single integer
342/// expression.
344 Expr *IntExpr;
345
346protected:
348 SourceLocation LParenLoc, Expr *IntExpr,
349 SourceLocation EndLoc)
350 : OpenACCClauseWithExprs(K, BeginLoc, LParenLoc, EndLoc),
351 IntExpr(IntExpr) {
352 if (IntExpr)
353 setExprs(MutableArrayRef<Expr *>{&this->IntExpr, 1});
354 }
355
356public:
357 static bool classof(const OpenACCClause *C);
358 bool hasIntExpr() const { return !getExprs().empty(); }
359 const Expr *getIntExpr() const {
360 return hasIntExpr() ? getExprs()[0] : nullptr;
361 }
362
363 Expr *getIntExpr() { return hasIntExpr() ? getExprs()[0] : nullptr; };
364};
365
368 Expr *IntExpr, SourceLocation EndLoc);
369
370public:
371 static bool classof(const OpenACCClause *C) {
372 return C->getClauseKind() == OpenACCClauseKind::NumWorkers;
373 }
375 SourceLocation BeginLoc,
376 SourceLocation LParenLoc,
377 Expr *IntExpr, SourceLocation EndLoc);
378};
379
382 Expr *IntExpr, SourceLocation EndLoc);
383
384public:
385 static bool classof(const OpenACCClause *C) {
386 return C->getClauseKind() == OpenACCClauseKind::VectorLength;
387 }
389 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
390 Expr *IntExpr, SourceLocation EndLoc);
391};
392
395 Expr *IntExpr, SourceLocation EndLoc);
396
397public:
398 static bool classof(const OpenACCClause *C) {
399 return C->getClauseKind() == OpenACCClauseKind::Async;
400 }
401 static OpenACCAsyncClause *Create(const ASTContext &C,
402 SourceLocation BeginLoc,
403 SourceLocation LParenLoc, Expr *IntExpr,
404 SourceLocation EndLoc);
405};
406
407/// Represents a clause with one or more 'var' objects, represented as an expr,
408/// as its arguments. Var-list is expected to be stored in trailing storage.
409/// For now, we're just storing the original expression in its entirety, unlike
410/// OMP which has to do a bunch of work to create a private.
412protected:
414 SourceLocation LParenLoc, SourceLocation EndLoc)
415 : OpenACCClauseWithExprs(K, BeginLoc, LParenLoc, EndLoc) {}
416
417public:
418 static bool classof(const OpenACCClause *C);
421};
422
425 public llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
426
428 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
430 LParenLoc, EndLoc) {
431 std::uninitialized_copy(VarList.begin(), VarList.end(),
432 getTrailingObjects<Expr *>());
433 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
434 }
435
436public:
437 static bool classof(const OpenACCClause *C) {
438 return C->getClauseKind() == OpenACCClauseKind::Private;
439 }
440 static OpenACCPrivateClause *
441 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
442 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
443};
444
447 public llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {
448
450 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
452 LParenLoc, EndLoc) {
453 std::uninitialized_copy(VarList.begin(), VarList.end(),
454 getTrailingObjects<Expr *>());
455 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
456 }
457
458public:
459 static bool classof(const OpenACCClause *C) {
460 return C->getClauseKind() == OpenACCClauseKind::FirstPrivate;
461 }
463 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
464 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
465};
466
469 public llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {
470
472 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
474 LParenLoc, EndLoc) {
475 std::uninitialized_copy(VarList.begin(), VarList.end(),
476 getTrailingObjects<Expr *>());
477 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
478 }
479
480public:
481 static bool classof(const OpenACCClause *C) {
482 return C->getClauseKind() == OpenACCClauseKind::DevicePtr;
483 }
485 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
486 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
487};
488
491 public llvm::TrailingObjects<OpenACCAttachClause, Expr *> {
492
494 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
496 EndLoc) {
497 std::uninitialized_copy(VarList.begin(), VarList.end(),
498 getTrailingObjects<Expr *>());
499 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
500 }
501
502public:
503 static bool classof(const OpenACCClause *C) {
504 return C->getClauseKind() == OpenACCClauseKind::Attach;
505 }
506 static OpenACCAttachClause *
507 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
508 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
509};
510
513 public llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {
514
516 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
518 LParenLoc, EndLoc) {
519 std::uninitialized_copy(VarList.begin(), VarList.end(),
520 getTrailingObjects<Expr *>());
521 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
522 }
523
524public:
525 static bool classof(const OpenACCClause *C) {
526 return C->getClauseKind() == OpenACCClauseKind::NoCreate;
527 }
528 static OpenACCNoCreateClause *
529 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
530 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
531};
532
535 public llvm::TrailingObjects<OpenACCPresentClause, Expr *> {
536
538 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
540 LParenLoc, EndLoc) {
541 std::uninitialized_copy(VarList.begin(), VarList.end(),
542 getTrailingObjects<Expr *>());
543 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
544 }
545
546public:
547 static bool classof(const OpenACCClause *C) {
548 return C->getClauseKind() == OpenACCClauseKind::Present;
549 }
550 static OpenACCPresentClause *
551 Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
552 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
553};
554
557 public llvm::TrailingObjects<OpenACCCopyClause, Expr *> {
558
560 SourceLocation LParenLoc, ArrayRef<Expr *> VarList,
561 SourceLocation EndLoc)
562 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc) {
563 assert((Spelling == OpenACCClauseKind::Copy ||
564 Spelling == OpenACCClauseKind::PCopy ||
566 "Invalid clause kind for copy-clause");
567 std::uninitialized_copy(VarList.begin(), VarList.end(),
568 getTrailingObjects<Expr *>());
569 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
570 }
571
572public:
573 static bool classof(const OpenACCClause *C) {
574 return C->getClauseKind() == OpenACCClauseKind::Copy ||
575 C->getClauseKind() == OpenACCClauseKind::PCopy ||
576 C->getClauseKind() == OpenACCClauseKind::PresentOrCopy;
577 }
578 static OpenACCCopyClause *
579 Create(const ASTContext &C, OpenACCClauseKind Spelling,
580 SourceLocation BeginLoc, SourceLocation LParenLoc,
581 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
582};
583
586 public llvm::TrailingObjects<OpenACCCopyInClause, Expr *> {
587 bool IsReadOnly;
588
590 SourceLocation LParenLoc, bool IsReadOnly,
591 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
592 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc),
593 IsReadOnly(IsReadOnly) {
594 assert((Spelling == OpenACCClauseKind::CopyIn ||
595 Spelling == OpenACCClauseKind::PCopyIn ||
597 "Invalid clause kind for copyin-clause");
598 std::uninitialized_copy(VarList.begin(), VarList.end(),
599 getTrailingObjects<Expr *>());
600 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
601 }
602
603public:
604 static bool classof(const OpenACCClause *C) {
605 return C->getClauseKind() == OpenACCClauseKind::CopyIn ||
606 C->getClauseKind() == OpenACCClauseKind::PCopyIn ||
607 C->getClauseKind() == OpenACCClauseKind::PresentOrCopyIn;
608 }
609 bool isReadOnly() const { return IsReadOnly; }
610 static OpenACCCopyInClause *
611 Create(const ASTContext &C, OpenACCClauseKind Spelling,
612 SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsReadOnly,
613 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
614};
615
618 public llvm::TrailingObjects<OpenACCCopyOutClause, Expr *> {
619 bool IsZero;
620
622 SourceLocation LParenLoc, bool IsZero,
623 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
624 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc),
625 IsZero(IsZero) {
626 assert((Spelling == OpenACCClauseKind::CopyOut ||
627 Spelling == OpenACCClauseKind::PCopyOut ||
629 "Invalid clause kind for copyout-clause");
630 std::uninitialized_copy(VarList.begin(), VarList.end(),
631 getTrailingObjects<Expr *>());
632 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
633 }
634
635public:
636 static bool classof(const OpenACCClause *C) {
637 return C->getClauseKind() == OpenACCClauseKind::CopyOut ||
638 C->getClauseKind() == OpenACCClauseKind::PCopyOut ||
639 C->getClauseKind() == OpenACCClauseKind::PresentOrCopyOut;
640 }
641 bool isZero() const { return IsZero; }
642 static OpenACCCopyOutClause *
643 Create(const ASTContext &C, OpenACCClauseKind Spelling,
644 SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsZero,
645 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
646};
647
650 public llvm::TrailingObjects<OpenACCCreateClause, Expr *> {
651 bool IsZero;
652
654 SourceLocation LParenLoc, bool IsZero,
655 ArrayRef<Expr *> VarList, SourceLocation EndLoc)
656 : OpenACCClauseWithVarList(Spelling, BeginLoc, LParenLoc, EndLoc),
657 IsZero(IsZero) {
658 assert((Spelling == OpenACCClauseKind::Create ||
659 Spelling == OpenACCClauseKind::PCreate ||
661 "Invalid clause kind for create-clause");
662 std::uninitialized_copy(VarList.begin(), VarList.end(),
663 getTrailingObjects<Expr *>());
664 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
665 }
666
667public:
668 static bool classof(const OpenACCClause *C) {
669 return C->getClauseKind() == OpenACCClauseKind::Create ||
670 C->getClauseKind() == OpenACCClauseKind::PCreate ||
671 C->getClauseKind() == OpenACCClauseKind::PresentOrCreate;
672 }
673 bool isZero() const { return IsZero; }
674 static OpenACCCreateClause *
675 Create(const ASTContext &C, OpenACCClauseKind Spelling,
676 SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsZero,
677 ArrayRef<Expr *> VarList, SourceLocation EndLoc);
678};
679
680template <class Impl> class OpenACCClauseVisitor {
681 Impl &getDerived() { return static_cast<Impl &>(*this); }
682
683public:
685 for (const OpenACCClause *Clause : List)
686 Visit(Clause);
687 }
688
689 void Visit(const OpenACCClause *C) {
690 if (!C)
691 return;
692
693 switch (C->getClauseKind()) {
694#define VISIT_CLAUSE(CLAUSE_NAME) \
695 case OpenACCClauseKind::CLAUSE_NAME: \
696 Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
697 return;
698#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME) \
699 case OpenACCClauseKind::ALIAS_NAME: \
700 Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
701 return;
702#include "clang/Basic/OpenACCClauses.def"
703
704 default:
705 llvm_unreachable("Clause visitor not yet implemented");
706 }
707 llvm_unreachable("Invalid Clause kind");
708 }
709
710#define VISIT_CLAUSE(CLAUSE_NAME) \
711 void Visit##CLAUSE_NAME##Clause( \
712 const OpenACC##CLAUSE_NAME##Clause &Clause) { \
713 return getDerived().Visit##CLAUSE_NAME##Clause(Clause); \
714 }
715
716#include "clang/Basic/OpenACCClauses.def"
717};
718
720 : public OpenACCClauseVisitor<OpenACCClausePrinter> {
721 raw_ostream &OS;
722 const PrintingPolicy &Policy;
723
724 void printExpr(const Expr *E);
725
726public:
728 for (const OpenACCClause *Clause : List) {
729 Visit(Clause);
730
731 if (Clause != List.back())
732 OS << ' ';
733 }
734 }
735 OpenACCClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
736 : OS(OS), Policy(Policy) {}
737
738#define VISIT_CLAUSE(CLAUSE_NAME) \
739 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
740#include "clang/Basic/OpenACCClauses.def"
741};
742
743} // namespace clang
744
745#endif // LLVM_CLANG_AST_OPENACCCLAUSE_H
Defines the clang::ASTContext interface.
Defines some OpenACC-specific enums and functions.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:182
This represents one expression.
Definition: Expr.h:110
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
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.
static bool classof(const OpenACCClause *C)
OpenACCClauseWithExprs(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
llvm::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.
Definition: OpenACCClause.h:58
SourceLocation getLParenLoc() const
Definition: OpenACCClause.h:70
static bool classof(const OpenACCClause *C)
OpenACCClauseWithParams(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Definition: OpenACCClause.h:63
const_child_range children() const
Definition: OpenACCClause.h:75
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:24
child_range children()
StmtIterator child_iterator
Definition: OpenACCClause.h:43
OpenACCClauseKind getClauseKind() const
Definition: OpenACCClause.h:37
SourceLocation getBeginLoc() const
Definition: OpenACCClause.h:38
const_child_range children() const
Definition: OpenACCClause.h:49
static bool classof(const OpenACCClause *)
Definition: OpenACCClause.h:41
llvm::iterator_range< child_iterator > child_range
Definition: OpenACCClause.h:45
ConstStmtIterator const_child_iterator
Definition: OpenACCClause.h:44
OpenACCClause(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation EndLoc)
Definition: OpenACCClause.h:29
virtual ~OpenACCClause()=default
llvm::iterator_range< const_child_iterator > const_child_range
Definition: OpenACCClause.h:46
SourceLocation getEndLoc() const
Definition: OpenACCClause.h:39
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 '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)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
Definition: OpenACCClause.h:86
ArrayRef< DeviceTypeArgument > getArchitectures() const
static bool classof(const OpenACCClause *C)
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)
static bool classof(const OpenACCClause *C)
llvm::ArrayRef< Expr * > getIntExprs() const
llvm::ArrayRef< Expr * > getIntExprs()
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
A 'self' clause, which has an optional condition expression.
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
Expr * getDevNumExpr() const
llvm::ArrayRef< Expr * > getQueueIdExprs()
llvm::ArrayRef< Expr * > getQueueIdExprs() const
SourceLocation getQueuesLoc() const
static bool classof(const OpenACCClause *C)
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition: Stmt.h:84
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
Definition: OpenACCKinds.h:164
@ 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'.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ 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',...
@ 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.
@ NoCreate
'no_create' clause, allowed on allowed on Compute and Combined constructs, plus 'data'.
@ PresentOrCopyOut
'copyout' clause alias 'present_or_copyout'.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ CopyOut
'copyout' clause, allowed on Compute and Combined constructs, plus 'data', 'exit data',...
@ FirstPrivate
'firstprivate' clause, allowed on 'parallel', 'serial', 'parallel loop', and 'serial loop' constructs...
@ PCopy
'copy' clause alias 'pcopy'. Preserved for diagnostic purposes.
@ PCopyIn
'copyin' clause alias 'pcopyin'. Preserved for diagnostic purposes.
@ 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',...
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
@ PresentOrCopyIn
'copyin' clause alias 'present_or_copyin'.
OpenACCDefaultClauseKind
Definition: OpenACCKinds.h:462
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument
Definition: OpenACCClause.h:80
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57