14#ifndef LLVM_CLANG_AST_OPENACCCLAUSE_H
15#define LLVM_CLANG_AST_OPENACCCLAUSE_H
31 : Kind(K), Location(BeginLoc, EndLoc) {
33 "Begin and end location must be valid for OpenACCClause");
174 :
OpenACCClause(K, BeginLoc, EndLoc), LParenLoc(LParenLoc) {}
194 private llvm::TrailingObjects<OpenACCDeviceTypeClause,
195 DeviceTypeArgument> {
196 friend TrailingObjects;
205 NumArchs(Archs.size()) {
208 "Invalid clause kind for device-type");
211 return Arg.second.isInvalid();
212 }) &&
"Invalid SourceLocation for an argument");
215 (Archs.size() == 1 || !llvm::any_of(Archs,
217 return Arg.first == nullptr;
219 "Only a single asterisk version is permitted, and must be the "
222 std::uninitialized_copy(Archs.begin(), Archs.end(),
223 getTrailingObjects<DeviceTypeArgument>());
238 getTrailingObjects<DeviceTypeArgument>(), NumArchs);
259 DefaultClauseKind(K) {
262 "Invalid Clause Kind");
270 return DefaultClauseKind;
283 Expr *ConditionExpr =
nullptr;
290 ConditionExpr(ConditionExpr) {}
302 reinterpret_cast<Stmt **
>(&ConditionExpr + 1));
309 reinterpret_cast<Stmt *
const *
>(&ConditionExpr),
310 reinterpret_cast<Stmt *
const *
>(&ConditionExpr + 1));
356 assert(Exprs.empty() &&
"Cannot change Exprs list");
368 reinterpret_cast<Stmt **
>(Exprs.end()));
381 private llvm::TrailingObjects<OpenACCWaitClause, Expr *> {
382 friend TrailingObjects;
389 QueuesLoc(QueuesLoc) {
392 std::uninitialized_copy(&DevNumExpr, &DevNumExpr + 1,
393 getTrailingObjects<Expr *>());
394 std::uninitialized_copy(QueueIdExprs.begin(), QueueIdExprs.end(),
395 getTrailingObjects<Expr *>() + 1);
397 MutableArrayRef(getTrailingObjects<Expr *>(), QueueIdExprs.size() + 1));
424 private llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
425 friend TrailingObjects;
431 std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
432 getTrailingObjects<Expr *>());
455 private llvm::TrailingObjects<OpenACCTileClause, Expr *> {
456 friend TrailingObjects;
461 std::uninitialized_copy(SizeExprs.begin(), SizeExprs.end(),
462 getTrailingObjects<Expr *>());
510 private llvm::TrailingObjects<OpenACCGangClause, Expr *, OpenACCGangKind> {
511 friend TrailingObjects;
518 return getTrailingObjects<OpenACCGangKind>()[I];
531 std::pair<OpenACCGangKind, const Expr *>
getExpr(
unsigned I)
const {
641 bool HasForce =
false;
680 private llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
681 friend TrailingObjects;
687 std::uninitialized_copy(VarList.begin(), VarList.end(),
688 getTrailingObjects<Expr *>());
703 private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {
704 friend TrailingObjects;
710 std::uninitialized_copy(VarList.begin(), VarList.end(),
711 getTrailingObjects<Expr *>());
726 private llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {
727 friend TrailingObjects;
733 std::uninitialized_copy(VarList.begin(), VarList.end(),
734 getTrailingObjects<Expr *>());
749 private llvm::TrailingObjects<OpenACCAttachClause, Expr *> {
750 friend TrailingObjects;
756 std::uninitialized_copy(VarList.begin(), VarList.end(),
757 getTrailingObjects<Expr *>());
772 private llvm::TrailingObjects<OpenACCDetachClause, Expr *> {
773 friend TrailingObjects;
779 std::uninitialized_copy(VarList.begin(), VarList.end(),
780 getTrailingObjects<Expr *>());
795 private llvm::TrailingObjects<OpenACCDeleteClause, Expr *> {
796 friend TrailingObjects;
802 std::uninitialized_copy(VarList.begin(), VarList.end(),
803 getTrailingObjects<Expr *>());
818 private llvm::TrailingObjects<OpenACCUseDeviceClause, Expr *> {
819 friend TrailingObjects;
825 std::uninitialized_copy(VarList.begin(), VarList.end(),
826 getTrailingObjects<Expr *>());
841 private llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {
842 friend TrailingObjects;
848 std::uninitialized_copy(VarList.begin(), VarList.end(),
849 getTrailingObjects<Expr *>());
864 private llvm::TrailingObjects<OpenACCPresentClause, Expr *> {
865 friend TrailingObjects;
871 std::uninitialized_copy(VarList.begin(), VarList.end(),
872 getTrailingObjects<Expr *>());
887 private llvm::TrailingObjects<OpenACCCopyClause, Expr *> {
888 friend TrailingObjects;
897 "Invalid clause kind for copy-clause");
898 std::uninitialized_copy(VarList.begin(), VarList.end(),
899 getTrailingObjects<Expr *>());
917 private llvm::TrailingObjects<OpenACCCopyInClause, Expr *> {
918 friend TrailingObjects;
925 IsReadOnly(IsReadOnly) {
929 "Invalid clause kind for copyin-clause");
930 std::uninitialized_copy(VarList.begin(), VarList.end(),
931 getTrailingObjects<Expr *>());
950 private llvm::TrailingObjects<OpenACCCopyOutClause, Expr *> {
951 friend TrailingObjects;
962 "Invalid clause kind for copyout-clause");
963 std::uninitialized_copy(VarList.begin(), VarList.end(),
964 getTrailingObjects<Expr *>());
983 private llvm::TrailingObjects<OpenACCCreateClause, Expr *> {
984 friend TrailingObjects;
995 "Invalid clause kind for create-clause");
996 std::uninitialized_copy(VarList.begin(), VarList.end(),
997 getTrailingObjects<Expr *>());
1016 private llvm::TrailingObjects<OpenACCReductionClause, Expr *> {
1017 friend TrailingObjects;
1026 std::uninitialized_copy(VarList.begin(), VarList.end(),
1027 getTrailingObjects<Expr *>());
1045 Impl &getDerived() {
return static_cast<Impl &
>(*this); }
1057 switch (
C->getClauseKind()) {
1058#define VISIT_CLAUSE(CLAUSE_NAME) \
1059 case OpenACCClauseKind::CLAUSE_NAME: \
1060 Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1062#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED) \
1063 case OpenACCClauseKind::ALIAS_NAME: \
1064 Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1066#include "clang/Basic/OpenACCClauses.def"
1069 llvm_unreachable(
"Clause visitor not yet implemented");
1071 llvm_unreachable(
"Invalid Clause kind");
1074#define VISIT_CLAUSE(CLAUSE_NAME) \
1075 void Visit##CLAUSE_NAME##Clause( \
1076 const OpenACC##CLAUSE_NAME##Clause &Clause) { \
1077 return getDerived().Visit##CLAUSE_NAME##Clause(Clause); \
1080#include "clang/Basic/OpenACCClauses.def"
1088 void printExpr(
const Expr *
E);
1095 if (Clause != List.back())
1100 : OS(OS), Policy(Policy) {}
1102#define VISIT_CLAUSE(CLAUSE_NAME) \
1103 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
1104#include "clang/Basic/OpenACCClauses.def"
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 ...
This represents one expression.
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
const_child_range children() const
OpenACCAutoClause(SourceLocation BeginLoc, SourceLocation EndLoc)
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)
bool hasConditionExpr() const
const Expr * getConditionExpr() const
Expr * getConditionExpr()
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.
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)
const Expr * getIntExpr() const
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.
StmtIterator child_iterator
OpenACCClauseKind getClauseKind() const
SourceLocation getBeginLoc() const
const_child_range children() const
static bool classof(const OpenACCClause *)
llvm::iterator_range< child_iterator > child_range
ConstStmtIterator const_child_iterator
OpenACCClause(OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation EndLoc)
virtual ~OpenACCClause()=default
llvm::iterator_range< const_child_iterator > const_child_range
SourceLocation getEndLoc() const
Represents a 'collapse' clause on a 'loop' construct.
const Expr * getLoopCount() 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)
A 'default' clause, has the optional 'none' or 'present' argument.
OpenACCDefaultClause(OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
friend class ASTWriterStmt
OpenACCDefaultClauseKind getDefaultClauseKind() const
static bool classof(const OpenACCClause *C)
friend class ASTReaderStmt
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)
static bool classof(const OpenACCClause *C)
const_child_range children() const
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
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)
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)
static bool classof(const OpenACCClause *C)
OpenACCReductionOperator getReductionOp() const
A 'self' clause, which has an optional condition expression.
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
const_child_range children() const
OpenACCSeqClause(SourceLocation BeginLoc, SourceLocation EndLoc)
llvm::ArrayRef< Expr * > getSizeExprs() const
static bool classof(const OpenACCClause *C)
llvm::ArrayRef< Expr * > getSizeExprs()
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
Expr * getDevNumExpr() const
llvm::ArrayRef< Expr * > getQueueIdExprs()
bool hasDevNumExpr() const
bool hasQueuesTag() const
llvm::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.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ Auto
'auto' clause, allowed on 'loop' directives.
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ Wait
'wait' clause, allowed on Compute, Data, 'update', and Combined constructs.
@ DevicePtr
'deviceptr' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ PCopyOut
'copyout' clause alias 'pcopyout'. Preserved for diagnostic purposes.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ PresentOrCreate
'create' clause alias 'present_or_create'.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ PresentOrCopy
'copy' clause alias 'present_or_copy'. Preserved for diagnostic purposes.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Private
'private' clause, allowed on 'parallel', 'serial', 'loop', 'parallel loop', and 'serial loop' constru...
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Copy
'copy' clause, allowed on Compute and Combined Constructs, plus 'data' and 'declare'.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ DeviceType
'device_type' clause, allowed on Compute, 'data', 'init', 'shutdown', 'set', update',...
@ 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'.
@ 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...
@ 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.
@ 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',...
@ 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.
@ Present
'present' option.
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument
Describes how types, statements, expressions, and declarations should be printed.