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));
334 private llvm::TrailingObjects<OpenACCSelfClause, Expr *> {
335 friend TrailingObjects;
338 std::optional<bool> HasConditionExpr;
352 return {getTrailingObjects<Expr *>(), NumExprs};
363 assert(HasConditionExpr.has_value() &&
364 "VarList Self Clause asked about condition expression");
365 return *HasConditionExpr;
369 assert(HasConditionExpr.has_value() &&
370 "VarList Self Clause asked about condition expression");
371 assert(getExprs().size() == 1 &&
372 "ConditionExpr Self Clause with too many Exprs");
373 return getExprs()[0];
377 assert(HasConditionExpr.has_value() &&
378 "VarList Self Clause asked about condition expression");
379 assert(getExprs().size() == 1 &&
380 "ConditionExpr Self Clause with too many Exprs");
381 return getExprs()[0];
385 assert(!HasConditionExpr.has_value() &&
386 "Condition Expr self clause asked about var list");
390 assert(!HasConditionExpr.has_value() &&
391 "Condition Expr self clause asked about var list");
397 reinterpret_cast<Stmt **
>(getTrailingObjects<Expr *>()),
398 reinterpret_cast<Stmt **
>(getTrailingObjects<Expr *>() + NumExprs));
427 assert(Exprs.empty() &&
"Cannot change Exprs list");
439 reinterpret_cast<Stmt **
>(Exprs.end()));
452 private llvm::TrailingObjects<OpenACCWaitClause, Expr *> {
453 friend TrailingObjects;
460 QueuesLoc(QueuesLoc) {
463 std::uninitialized_copy(&DevNumExpr, &DevNumExpr + 1,
464 getTrailingObjects<Expr *>());
465 std::uninitialized_copy(QueueIdExprs.begin(), QueueIdExprs.end(),
466 getTrailingObjects<Expr *>() + 1);
468 MutableArrayRef(getTrailingObjects<Expr *>(), QueueIdExprs.size() + 1));
495 private llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {
496 friend TrailingObjects;
502 std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
503 getTrailingObjects<Expr *>());
526 private llvm::TrailingObjects<OpenACCTileClause, Expr *> {
527 friend TrailingObjects;
532 std::uninitialized_copy(SizeExprs.begin(), SizeExprs.end(),
533 getTrailingObjects<Expr *>());
581 private llvm::TrailingObjects<OpenACCGangClause, Expr *, OpenACCGangKind> {
582 friend TrailingObjects;
589 return getTrailingObjects<OpenACCGangKind>()[I];
602 std::pair<OpenACCGangKind, const Expr *>
getExpr(
unsigned I)
const {
725 bool HasForce =
false;
764 private llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
765 friend TrailingObjects;
771 std::uninitialized_copy(VarList.begin(), VarList.end(),
772 getTrailingObjects<Expr *>());
787 private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {
788 friend TrailingObjects;
794 std::uninitialized_copy(VarList.begin(), VarList.end(),
795 getTrailingObjects<Expr *>());
810 private llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {
811 friend TrailingObjects;
817 std::uninitialized_copy(VarList.begin(), VarList.end(),
818 getTrailingObjects<Expr *>());
833 private llvm::TrailingObjects<OpenACCAttachClause, Expr *> {
834 friend TrailingObjects;
840 std::uninitialized_copy(VarList.begin(), VarList.end(),
841 getTrailingObjects<Expr *>());
856 private llvm::TrailingObjects<OpenACCDetachClause, Expr *> {
857 friend TrailingObjects;
863 std::uninitialized_copy(VarList.begin(), VarList.end(),
864 getTrailingObjects<Expr *>());
879 private llvm::TrailingObjects<OpenACCDeleteClause, Expr *> {
880 friend TrailingObjects;
886 std::uninitialized_copy(VarList.begin(), VarList.end(),
887 getTrailingObjects<Expr *>());
902 private llvm::TrailingObjects<OpenACCUseDeviceClause, Expr *> {
903 friend TrailingObjects;
909 std::uninitialized_copy(VarList.begin(), VarList.end(),
910 getTrailingObjects<Expr *>());
925 private llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {
926 friend TrailingObjects;
932 std::uninitialized_copy(VarList.begin(), VarList.end(),
933 getTrailingObjects<Expr *>());
948 private llvm::TrailingObjects<OpenACCPresentClause, Expr *> {
949 friend TrailingObjects;
955 std::uninitialized_copy(VarList.begin(), VarList.end(),
956 getTrailingObjects<Expr *>());
970 private llvm::TrailingObjects<OpenACCHostClause, Expr *> {
971 friend TrailingObjects;
977 std::uninitialized_copy(VarList.begin(), VarList.end(),
978 getTrailingObjects<Expr *>());
994 private llvm::TrailingObjects<OpenACCDeviceClause, Expr *> {
995 friend TrailingObjects;
1001 std::uninitialized_copy(VarList.begin(), VarList.end(),
1002 getTrailingObjects<Expr *>());
1017 private llvm::TrailingObjects<OpenACCCopyClause, Expr *> {
1018 friend TrailingObjects;
1027 "Invalid clause kind for copy-clause");
1028 std::uninitialized_copy(VarList.begin(), VarList.end(),
1029 getTrailingObjects<Expr *>());
1047 private llvm::TrailingObjects<OpenACCCopyInClause, Expr *> {
1048 friend TrailingObjects;
1055 IsReadOnly(IsReadOnly) {
1059 "Invalid clause kind for copyin-clause");
1060 std::uninitialized_copy(VarList.begin(), VarList.end(),
1061 getTrailingObjects<Expr *>());
1080 private llvm::TrailingObjects<OpenACCCopyOutClause, Expr *> {
1081 friend TrailingObjects;
1092 "Invalid clause kind for copyout-clause");
1093 std::uninitialized_copy(VarList.begin(), VarList.end(),
1094 getTrailingObjects<Expr *>());
1113 private llvm::TrailingObjects<OpenACCCreateClause, Expr *> {
1114 friend TrailingObjects;
1125 "Invalid clause kind for create-clause");
1126 std::uninitialized_copy(VarList.begin(), VarList.end(),
1127 getTrailingObjects<Expr *>());
1146 private llvm::TrailingObjects<OpenACCReductionClause, Expr *> {
1147 friend TrailingObjects;
1156 std::uninitialized_copy(VarList.begin(), VarList.end(),
1157 getTrailingObjects<Expr *>());
1175 Impl &getDerived() {
return static_cast<Impl &
>(*this); }
1187 switch (
C->getClauseKind()) {
1188#define VISIT_CLAUSE(CLAUSE_NAME) \
1189 case OpenACCClauseKind::CLAUSE_NAME: \
1190 Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1192#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED) \
1193 case OpenACCClauseKind::ALIAS_NAME: \
1194 Visit##CLAUSE_NAME##Clause(*cast<OpenACC##CLAUSE_NAME##Clause>(C)); \
1196#include "clang/Basic/OpenACCClauses.def"
1199 llvm_unreachable(
"Clause visitor not yet implemented");
1201 llvm_unreachable(
"Invalid Clause kind");
1204#define VISIT_CLAUSE(CLAUSE_NAME) \
1205 void Visit##CLAUSE_NAME##Clause( \
1206 const OpenACC##CLAUSE_NAME##Clause &Clause) { \
1207 return getDerived().Visit##CLAUSE_NAME##Clause(Clause); \
1210#include "clang/Basic/OpenACCClauses.def"
1218 void printExpr(
const Expr *
E);
1225 if (Clause != List.back())
1230 : OS(OS), Policy(Policy) {}
1232#define VISIT_CLAUSE(CLAUSE_NAME) \
1233 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
1234#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)
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)
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
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)
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, or, in the event of an 'update' directiv...
Expr * getConditionExpr()
const Expr * getConditionExpr() const
bool isConditionExprClause() const
const_child_range children() const
static bool classof(const OpenACCClause *C)
ArrayRef< Expr * > getVarList()
bool hasConditionExpr() const
ArrayRef< Expr * > getVarList() const
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',...
@ 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'.
@ 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.
@ 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.
@ Present
'present' option.
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument
Describes how types, statements, expressions, and declarations should be printed.