13#ifndef LLVM_CLANG_AST_STMTOPENACC_H
14#define LLVM_CLANG_AST_STMTOPENACC_H
20#include "llvm/ADT/STLExtras.h"
47 :
Stmt(SC), Kind(K), Range(Start, End), DirectiveLoc(DirectiveLoc) {}
52 assert(Clauses.empty() &&
"Cannot change clause list");
60 return S->
getStmtClass() >= firstOpenACCConstructStmtConstant &&
85 Stmt *AssociatedStmt =
nullptr;
93 AssociatedStmt(AssocStmt) {}
109 return child_range(&AssociatedStmt, &AssociatedStmt + 1);
131 private llvm::TrailingObjects<OpenACCComputeConstruct,
132 const OpenACCClause *> {
133 friend class ASTStmtWriter;
134 friend class ASTStmtReader;
136 friend TrailingObjects;
139 OpenACCComputeConstructClass, OpenACCDirectiveKind::Invalid,
140 SourceLocation{}, SourceLocation{}, SourceLocation{},
145 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
152 Stmt *StructuredBlock)
154 DirectiveLoc, End, StructuredBlock) {
156 "Only parallel, serial, and kernels constructs should be "
157 "represented by this type");
160 llvm::uninitialized_copy(Clauses, getTrailingObjects());
169 return T->getStmtClass() == OpenACCComputeConstructClass;
173 unsigned NumClauses);
187class OpenACCLoopConstruct final
189 private llvm::TrailingObjects<OpenACCLoopConstruct,
190 const OpenACCClause *> {
193 OpenACCDirectiveKind ParentComputeConstructKind =
194 OpenACCDirectiveKind::Invalid;
202 friend TrailingObjects;
204 OpenACCLoopConstruct(
unsigned NumClauses);
206 OpenACCLoopConstruct(OpenACCDirectiveKind ParentKind, SourceLocation Start,
207 SourceLocation DirLoc, SourceLocation End,
212 return T->getStmtClass() == OpenACCLoopConstructClass;
216 unsigned NumClauses);
220 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc,
223 Stmt *
getLoop() {
return getAssociatedStmt(); }
225 return const_cast<OpenACCLoopConstruct *
>(
this)->
getLoop();
234 return ParentComputeConstructKind == OpenACCDirectiveKind::Invalid;
238 return ParentComputeConstructKind;
244class OpenACCCombinedConstruct final
246 private llvm::TrailingObjects<OpenACCCombinedConstruct,
247 const OpenACCClause *> {
248 friend TrailingObjects;
249 OpenACCCombinedConstruct(
unsigned NumClauses)
251 OpenACCCombinedConstructClass, OpenACCDirectiveKind::Invalid,
252 SourceLocation{}, SourceLocation{}, SourceLocation{},
254 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
255 setClauseList(getTrailingObjects(NumClauses));
258 OpenACCCombinedConstruct(OpenACCDirectiveKind K, SourceLocation Start,
259 SourceLocation DirectiveLoc, SourceLocation End,
261 Stmt *StructuredBlock)
263 DirectiveLoc, End, StructuredBlock) {
264 assert(isOpenACCCombinedDirectiveKind(K) &&
265 "Only parallel loop, serial loop, and kernels loop constructs "
266 "should be represented by this type");
268 llvm::uninitialized_copy(Clauses, getTrailingObjects());
269 setClauseList(getTrailingObjects(Clauses.size()));
271 void setStructuredBlock(Stmt *S) { setAssociatedStmt(S); }
275 return T->getStmtClass() == OpenACCCombinedConstructClass;
279 unsigned NumClauses);
282 SourceLocation DirectiveLoc, SourceLocation End,
284 Stmt *
getLoop() {
return getAssociatedStmt(); }
286 return const_cast<OpenACCCombinedConstruct *
>(
this)->
getLoop();
292class OpenACCDataConstruct final
294 private llvm::TrailingObjects<OpenACCDataConstruct,
295 const OpenACCClause *> {
296 friend TrailingObjects;
297 OpenACCDataConstruct(
unsigned NumClauses)
299 OpenACCDataConstructClass, OpenACCDirectiveKind::Data,
300 SourceLocation{}, SourceLocation{}, SourceLocation{},
302 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
303 setClauseList(getTrailingObjects(NumClauses));
306 OpenACCDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
309 Stmt *StructuredBlock)
311 OpenACCDirectiveKind::Data, Start,
312 DirectiveLoc, End, StructuredBlock) {
313 llvm::uninitialized_copy(Clauses, getTrailingObjects());
314 setClauseList(getTrailingObjects(Clauses.size()));
316 void setStructuredBlock(Stmt *S) { setAssociatedStmt(S); }
320 return T->getStmtClass() == OpenACCDataConstructClass;
324 unsigned NumClauses);
326 SourceLocation DirectiveLoc,
329 Stmt *StructuredBlock);
336class OpenACCEnterDataConstruct final
338 private llvm::TrailingObjects<OpenACCEnterDataConstruct,
339 const OpenACCClause *> {
340 friend TrailingObjects;
341 OpenACCEnterDataConstruct(
unsigned NumClauses)
343 OpenACCDirectiveKind::EnterData, SourceLocation{},
344 SourceLocation{}, SourceLocation{}) {
345 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
346 setClauseList(getTrailingObjects(NumClauses));
348 OpenACCEnterDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
352 OpenACCDirectiveKind::EnterData, Start,
354 llvm::uninitialized_copy(Clauses, getTrailingObjects());
355 setClauseList(getTrailingObjects(Clauses.size()));
360 return T->getStmtClass() == OpenACCEnterDataConstructClass;
363 unsigned NumClauses);
365 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
369class OpenACCExitDataConstruct final
371 private llvm::TrailingObjects<OpenACCExitDataConstruct,
372 const OpenACCClause *> {
373 friend TrailingObjects;
374 OpenACCExitDataConstruct(
unsigned NumClauses)
376 OpenACCDirectiveKind::ExitData, SourceLocation{},
377 SourceLocation{}, SourceLocation{}) {
378 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
379 setClauseList(getTrailingObjects(NumClauses));
381 OpenACCExitDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
385 OpenACCDirectiveKind::ExitData, Start,
387 llvm::uninitialized_copy(Clauses, getTrailingObjects());
388 setClauseList(getTrailingObjects(Clauses.size()));
393 return T->getStmtClass() == OpenACCExitDataConstructClass;
396 unsigned NumClauses);
398 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
403class OpenACCHostDataConstruct final
405 private llvm::TrailingObjects<OpenACCHostDataConstruct,
406 const OpenACCClause *> {
407 friend TrailingObjects;
408 OpenACCHostDataConstruct(
unsigned NumClauses)
410 OpenACCHostDataConstructClass, OpenACCDirectiveKind::HostData,
411 SourceLocation{}, SourceLocation{}, SourceLocation{},
413 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
414 setClauseList(getTrailingObjects(NumClauses));
416 OpenACCHostDataConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
419 Stmt *StructuredBlock)
421 OpenACCDirectiveKind::HostData, Start,
422 DirectiveLoc, End, StructuredBlock) {
423 llvm::uninitialized_copy(Clauses, getTrailingObjects());
424 setClauseList(getTrailingObjects(Clauses.size()));
426 void setStructuredBlock(Stmt *S) { setAssociatedStmt(S); }
430 return T->getStmtClass() == OpenACCHostDataConstructClass;
433 unsigned NumClauses);
435 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
437 Stmt *StructuredBlock);
446class OpenACCWaitConstruct final
448 private llvm::TrailingObjects<OpenACCWaitConstruct, Expr *,
454 friend TrailingObjects;
459 SourceLocation LParenLoc, RParenLoc;
461 SourceLocation QueuesLoc;
465 unsigned NumExprs = 0;
467 OpenACCWaitConstruct(
unsigned NumExprs,
unsigned NumClauses)
469 OpenACCDirectiveKind::Wait, SourceLocation{},
470 SourceLocation{}, SourceLocation{}),
472 assert(NumExprs >= 1 &&
473 "NumExprs should always be >= 1 because the 'devnum' "
474 "expr is represented by a null if necessary");
475 std::uninitialized_value_construct_n(getExprPtr(), NumExprs);
476 std::uninitialized_value_construct_n(getTrailingObjects<OpenACCClause *>(),
478 setClauseList(MutableArrayRef(
const_cast<const OpenACCClause **
>(
479 getTrailingObjects<OpenACCClause *>()),
484 SourceLocation LParenLoc, Expr *DevNumExpr,
486 SourceLocation RParenLoc, SourceLocation End,
489 OpenACCDirectiveKind::Wait, Start, DirectiveLoc,
491 LParenLoc(LParenLoc), RParenLoc(RParenLoc), QueuesLoc(QueuesLoc),
492 NumExprs(QueueIdExprs.size() + 1) {
493 assert(NumExprs >= 1 &&
494 "NumExprs should always be >= 1 because the 'devnum' "
495 "expr is represented by a null if necessary");
497 llvm::uninitialized_copy(
ArrayRef(DevNumExpr), getExprPtr());
498 llvm::uninitialized_copy(QueueIdExprs, getExprPtr() + 1);
499 std::uninitialized_copy(
const_cast<OpenACCClause **
>(Clauses.begin()),
500 const_cast<OpenACCClause **
>(Clauses.end()),
501 getTrailingObjects<OpenACCClause *>());
502 setClauseList(MutableArrayRef(
const_cast<const OpenACCClause **
>(
503 getTrailingObjects<OpenACCClause *>()),
507 size_t numTrailingObjects(OverloadToken<Expr *>)
const {
return NumExprs; }
508 size_t numTrailingObjects(OverloadToken<const OpenACCClause *>)
const {
509 return clauses().size();
512 Expr **getExprPtr()
const {
513 return const_cast<Expr**
>(getTrailingObjects<Expr *>());
516 ArrayRef<Expr *> getExprs()
const {
return {getExprPtr(), NumExprs}; }
520 return T->getStmtClass() == OpenACCWaitConstructClass;
527 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
528 SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc,
542 Stmt **Begin =
reinterpret_cast<Stmt **
>(getExprPtr());
543 return child_range(Begin, Begin + NumExprs);
548 reinterpret_cast<Stmt *
const *
>(getExprPtr());
549 return const_child_range(Begin, Begin + NumExprs);
553class OpenACCCacheConstruct final
555 private llvm::TrailingObjects<OpenACCCacheConstruct, Expr *> {
556 friend TrailingObjects;
561 SourceRange ParensLoc;
562 SourceLocation ReadOnlyLoc;
564 unsigned NumVars = 0;
566 OpenACCCacheConstruct(
unsigned NumVars)
568 OpenACCDirectiveKind::
Cache, SourceLocation{},
569 SourceLocation{}, SourceLocation{}),
571 std::uninitialized_value_construct_n(getTrailingObjects(), NumVars);
574 SourceLocation LParenLoc, SourceLocation ReadOnlyLoc,
578 OpenACCDirectiveKind::
Cache, Start, DirectiveLoc,
580 ParensLoc(LParenLoc, RParenLoc), ReadOnlyLoc(ReadOnlyLoc),
581 NumVars(VarList.size()) {
583 llvm::uninitialized_copy(VarList, getTrailingObjects());
589 MutableArrayRef<Expr *>
getVarList() {
return getTrailingObjects(NumVars); }
592 return T->getStmtClass() == OpenACCCacheConstructClass;
598 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
599 SourceLocation LParenLoc, SourceLocation ReadOnlyLoc,
609 Stmt **Begin =
reinterpret_cast<Stmt **
>(getTrailingObjects());
610 return child_range(Begin, Begin + NumVars);
614 Stmt *
const *Begin =
reinterpret_cast<Stmt *
const *
>(getTrailingObjects());
615 return const_child_range(Begin, Begin + NumVars);
620class OpenACCInitConstruct final
622 private llvm::TrailingObjects<OpenACCInitConstruct,
623 const OpenACCClause *> {
624 friend TrailingObjects;
625 OpenACCInitConstruct(
unsigned NumClauses)
627 OpenACCDirectiveKind::Init, SourceLocation{},
628 SourceLocation{}, SourceLocation{}) {
629 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
630 setClauseList(getTrailingObjects(NumClauses));
632 OpenACCInitConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
636 OpenACCDirectiveKind::Init, Start, DirectiveLoc,
638 llvm::uninitialized_copy(Clauses, getTrailingObjects());
639 setClauseList(getTrailingObjects(Clauses.size()));
644 return T->getStmtClass() == OpenACCInitConstructClass;
647 unsigned NumClauses);
649 SourceLocation DirectiveLoc,
655class OpenACCShutdownConstruct final
657 private llvm::TrailingObjects<OpenACCShutdownConstruct,
658 const OpenACCClause *> {
659 friend TrailingObjects;
660 OpenACCShutdownConstruct(
unsigned NumClauses)
662 OpenACCDirectiveKind::Shutdown, SourceLocation{},
663 SourceLocation{}, SourceLocation{}) {
664 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
665 setClauseList(getTrailingObjects(NumClauses));
667 OpenACCShutdownConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
671 OpenACCDirectiveKind::Shutdown, Start,
673 llvm::uninitialized_copy(Clauses, getTrailingObjects());
674 setClauseList(getTrailingObjects(Clauses.size()));
679 return T->getStmtClass() == OpenACCShutdownConstructClass;
682 unsigned NumClauses);
684 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
689class OpenACCSetConstruct final
691 private llvm::TrailingObjects<OpenACCSetConstruct,
692 const OpenACCClause *> {
693 friend TrailingObjects;
694 OpenACCSetConstruct(
unsigned NumClauses)
696 OpenACCDirectiveKind::Set, SourceLocation{},
697 SourceLocation{}, SourceLocation{}) {
698 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
699 setClauseList(getTrailingObjects(NumClauses));
702 OpenACCSetConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
706 OpenACCDirectiveKind::Set, Start, DirectiveLoc,
708 llvm::uninitialized_copy(Clauses, getTrailingObjects());
709 setClauseList(getTrailingObjects(Clauses.size()));
714 return T->getStmtClass() == OpenACCSetConstructClass;
717 unsigned NumClauses);
719 SourceLocation DirectiveLoc,
724class OpenACCUpdateConstruct final
726 private llvm::TrailingObjects<OpenACCUpdateConstruct,
727 const OpenACCClause *> {
728 friend TrailingObjects;
729 OpenACCUpdateConstruct(
unsigned NumClauses)
731 OpenACCDirectiveKind::Update, SourceLocation{},
732 SourceLocation{}, SourceLocation{}) {
733 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
734 setClauseList(getTrailingObjects(NumClauses));
737 OpenACCUpdateConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
741 OpenACCDirectiveKind::Update, Start, DirectiveLoc,
743 llvm::uninitialized_copy(Clauses, getTrailingObjects());
744 setClauseList(getTrailingObjects(Clauses.size()));
749 return T->getStmtClass() == OpenACCUpdateConstructClass;
752 unsigned NumClauses);
754 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
760class OpenACCAtomicConstruct final
762 private llvm::TrailingObjects<OpenACCAtomicConstruct,
763 const OpenACCClause *> {
766 friend TrailingObjects;
767 OpenACCAtomicKind AtomicKind = OpenACCAtomicKind::None;
769 OpenACCAtomicConstruct(
unsigned NumClauses)
771 OpenACCAtomicConstructClass, OpenACCDirectiveKind::Atomic,
772 SourceLocation{}, SourceLocation{}, SourceLocation{},
774 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
775 setClauseList(getTrailingObjects(NumClauses));
779 OpenACCAtomicKind AtKind, SourceLocation End,
781 Stmt *AssociatedStmt)
783 OpenACCDirectiveKind::Atomic, Start,
784 DirectiveLoc, End, AssociatedStmt),
787 llvm::uninitialized_copy(Clauses, getTrailingObjects());
789 setClauseList(getTrailingObjects(Clauses.size()));
792 void setAssociatedStmt(Stmt *S) {
793 OpenACCAssociatedStmtConstruct::setAssociatedStmt(S);
798 return T->getStmtClass() == OpenACCAtomicConstructClass;
802 unsigned NumClauses);
804 Create(
const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
805 OpenACCAtomicKind AtKind, SourceLocation End,
810 return OpenACCAssociatedStmtConstruct::getAssociatedStmt();
813 return OpenACCAssociatedStmtConstruct::getAssociatedStmt();
835 return {
nullptr,
nullptr,
nullptr,
nullptr,
false};
847 bool PostfixIncDec) {
848 return {
WholeExpr,
nullptr,
X,
nullptr, PostfixIncDec};
877 const StmtInfo getAssociatedStmtInfo()
const;
Defines some OpenACC-specific enums and functions.
Defines the clang::SourceLocation class and associated facilities.
static OMPAtomicDirective * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OMPClause * > Clauses, Stmt *AssociatedStmt, Expressions Exprs)
Creates directive with a list of Clauses and 'x', 'v' and 'expr' parts of the atomic construct (see S...
static OMPAtomicDirective * CreateEmpty(const ASTContext &C, unsigned NumClauses, EmptyShell)
Creates an empty directive with the place for NumClauses clauses.
TypePropertyCache< Private > Cache
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static bool classof(const Stmt *T)
const Stmt * getAssociatedStmt() const
Stmt * getAssociatedStmt()
friend class ASTStmtReader
OpenACCAtomicKind getAtomicKind() const
SourceLocation getLParenLoc() const
MutableArrayRef< Expr * > getVarList()
const_child_range children() const
ArrayRef< Expr * > getVarList() const
friend class ASTStmtWriter
friend class ASTStmtReader
SourceLocation getReadOnlyLoc() const
SourceLocation getRParenLoc() const
static bool classof(const Stmt *T)
static bool classof(const Stmt *T)
const Stmt * getLoop() const
static bool classof(const Stmt *T)
const Stmt * getStructuredBlock() const
Stmt * getStructuredBlock()
static bool classof(const Stmt *T)
static bool classof(const Stmt *T)
static bool classof(const Stmt *T)
Stmt * getStructuredBlock()
const Stmt * getStructuredBlock() const
static bool classof(const Stmt *T)
This class represents a 'loop' construct. The 'loop' construct applies to a 'for' loop (or range-for ...
bool isOrphanedLoopConstruct() const
OpenACC 3.3 2.9: An orphaned loop construct is a loop construct that is not lexically enclosed within...
friend class OpenACCCombinedConstruct
const Stmt * getLoop() const
OpenACCDirectiveKind getParentComputeConstructKind() const
friend class OpenACCComputeConstruct
friend class OpenACCAssociatedStmtConstruct
friend class ASTStmtWriter
friend class ASTStmtReader
static bool classof(const Stmt *T)
static bool classof(const Stmt *T)
static bool classof(const Stmt *T)
static bool classof(const Stmt *T)
bool hasQueuesTag() const
SourceLocation getQueuesLoc() const
SourceLocation getRParenLoc() const
static bool classof(const Stmt *T)
bool hasDevNumExpr() const
const_child_range children() const
friend class ASTStmtWriter
ArrayRef< Expr * > getQueueIdExprs() const
friend class ASTStmtReader
SourceLocation getLParenLoc() const
Expr * getDevNumExpr() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
This is a base class for any OpenACC statement-level constructs that have an associated statement.
void setAssociatedStmt(Stmt *S)
Stmt * getAssociatedStmt()
friend class RecursiveASTVisitor
const_child_range children() const
const Stmt * getAssociatedStmt() const
OpenACCAssociatedStmtConstruct(StmtClass SC, OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, Stmt *AssocStmt)
friend class ASTStmtWriter
friend class ASTStmtReader
static bool classof(const Stmt *T)
SourceLocation getEndLoc() const
SourceLocation getBeginLoc() const
OpenACCDirectiveKind getDirectiveKind() const
void setClauseList(MutableArrayRef< const OpenACCClause * > NewClauses)
ArrayRef< const OpenACCClause * > clauses() const
const_child_range children() const
SourceLocation getDirectiveLoc() const
friend class ASTStmtWriter
static bool classof(const Stmt *S)
friend class ASTStmtReader
OpenACCConstructStmt(StmtClass SC, OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End)
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
StmtClass getStmtClass() const
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
llvm::iterator_range< child_iterator > child_range
llvm::iterator_range< const_child_iterator > const_child_range
The JSON file list parser is used to communicate input to InstallAPI.
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
bool isOpenACCComputeDirectiveKind(OpenACCDirectiveKind K)
static bool classof(const OMPClause *T)
void setStructuredBlock(Stmt *S)
Stmt * getStructuredBlock()
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
setClauseList(getTrailingObjects(NumClauses))
static SingleStmtInfo createRead(const Expr *WholeExpr, const Expr *V, const Expr *X)
static SingleStmtInfo Empty()
static SingleStmtInfo createWrite(const Expr *WholeExpr, const Expr *X, const Expr *RefExpr)
static SingleStmtInfo createUpdate(const Expr *WholeExpr, const Expr *X, bool PostfixIncDec)
static StmtInfo createReadUpdate(SingleStmtInfo First, SingleStmtInfo Second)
static StmtInfo createUpdateRead(SingleStmtInfo First, SingleStmtInfo Second)
static StmtInfo createReadWrite(SingleStmtInfo First, SingleStmtInfo Second)