14#ifndef LLVM_CLANG_SEMA_SEMAOPENACC_H
15#define LLVM_CLANG_SEMA_SEMAOPENACC_H
36 bool InsideComputeConstruct =
false;
52 struct DefaultDetails {
56 struct ConditionDetails {
60 struct IntExprDetails {
64 struct VarListDetails {
76 struct DeviceTypeDetails {
79 struct ReductionDetails {
84 std::variant<std::monostate, DefaultDetails, ConditionDetails,
85 IntExprDetails, VarListDetails, WaitDetails, DeviceTypeDetails,
87 Details = std::monostate{};
92 : DirKind(DirKind), ClauseKind(ClauseKind), ClauseRange(BeginLoc, {}) {}
106 "Parsed clause is not a default clause");
107 return std::get<DefaultDetails>(Details).DefaultClauseKind;
118 "Parsed clause kind does not have a condition expr");
123 std::holds_alternative<std::monostate>(Details))
126 return std::get<ConditionDetails>(Details).ConditionExpr;
134 "Parsed clause kind does not have a int exprs");
139 std::holds_alternative<std::monostate>(Details))
141 return std::get<IntExprDetails>(Details).IntExprs.size();
146 "Parsed clause kind does not have a queues location");
148 if (std::holds_alternative<std::monostate>(Details))
151 return std::get<WaitDetails>(Details).QueuesLoc;
156 "Parsed clause kind does not have a device number expr");
158 if (std::holds_alternative<std::monostate>(Details))
161 return std::get<WaitDetails>(Details).DevNumExpr;
166 "Parsed clause kind does not have a queue id expr list");
168 if (std::holds_alternative<std::monostate>(Details))
171 return std::get<WaitDetails>(Details).QueueIdExprs;
179 "Parsed clause kind does not have a int exprs");
181 return std::get<IntExprDetails>(Details).IntExprs;
189 return std::get<ReductionDetails>(Details).Op;
212 "Parsed clause kind does not have a var-list");
215 return std::get<ReductionDetails>(Details).VarList;
217 return std::get<VarListDetails>(Details).VarList;
228 "Only copyin accepts 'readonly:' tag");
229 return std::get<VarListDetails>(Details).IsReadOnly;
239 "Only copyout/create accepts 'zero' tag");
240 return std::get<VarListDetails>(Details).IsZero;
246 "Only 'device_type'/'dtype' has a device-type-arg list");
247 return std::get<DeviceTypeDetails>(Details).Archs;
255 "Parsed clause is not a default clause");
256 Details = DefaultDetails{DefKind};
263 "Parsed clause kind does not have a condition expr");
268 "Condition expression type not scalar/dependent");
270 Details = ConditionDetails{ConditionExpr};
278 "Parsed clause kind does not have a int exprs");
279 Details = IntExprDetails{{IntExprs.begin(), IntExprs.end()}};
286 "Parsed clause kind does not have a int exprs");
287 Details = IntExprDetails{std::move(IntExprs)};
310 "Parsed clause kind does not have a var-list");
314 "readonly: tag only valid on copyin");
321 "zero: tag only valid on copyout/create");
323 VarListDetails{{VarList.begin(), VarList.end()}, IsReadOnly, IsZero};
346 "Parsed clause kind does not have a var-list");
350 "readonly: tag only valid on copyin");
357 "zero: tag only valid on copyout/create");
358 Details = VarListDetails{std::move(VarList), IsReadOnly, IsZero};
364 "reduction details only valid on reduction");
365 Details = ReductionDetails{Op, std::move(VarList)};
371 "Parsed clause kind does not have a wait-details");
372 Details = WaitDetails{DevNum, QueuesLoc, std::move(IntExprs)};
378 "Only 'device_type'/'dtype' has a device-type-arg list");
379 Details = DeviceTypeDetails{std::move(Archs)};
387 OpenACCParsedClause &Clause);
451 bool WasInsideComputeConstruct;
Defines some OpenACC-specific enums and functions.
Defines the clang::SourceLocation class and associated facilities.
This file defines OpenACC AST classes for statement-level contructs.
This represents one expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
This is the base type for all OpenACC Clauses.
Helper type for the registration/assignment of constructs that need to 'know' about their parent cons...
A type to represent all the data for an OpenACC Clause that has been parsed, but not yet created/sema...
ArrayRef< Expr * > getIntExprs()
ArrayRef< Expr * > getQueueIdExprs() const
OpenACCDirectiveKind getDirectiveKind() const
OpenACCParsedClause(OpenACCDirectiveKind DirKind, OpenACCClauseKind ClauseKind, SourceLocation BeginLoc)
OpenACCReductionOperator getReductionOp() const
SourceLocation getEndLoc() const
void setLParenLoc(SourceLocation EndLoc)
void setConditionDetails(Expr *ConditionExpr)
OpenACCClauseKind getClauseKind() const
const Expr * getConditionExpr() const
SourceLocation getLParenLoc() const
ArrayRef< DeviceTypeArgument > getDeviceTypeArchitectures() const
void setIntExprDetails(llvm::SmallVector< Expr * > &&IntExprs)
void setReductionDetails(OpenACCReductionOperator Op, llvm::SmallVector< Expr * > &&VarList)
Expr * getConditionExpr()
ArrayRef< Expr * > getVarList() const
SourceLocation getBeginLoc() const
void setDefaultDetails(OpenACCDefaultClauseKind DefKind)
SourceLocation getQueuesLoc() const
void setVarListDetails(llvm::SmallVector< Expr * > &&VarList, bool IsReadOnly, bool IsZero)
void setVarListDetails(ArrayRef< Expr * > VarList, bool IsReadOnly, bool IsZero)
Expr * getDevNumExpr() const
ArrayRef< Expr * > getVarList()
unsigned getNumIntExprs() const
void setWaitDetails(Expr *DevNum, SourceLocation QueuesLoc, llvm::SmallVector< Expr * > &&IntExprs)
void setEndLoc(SourceLocation EndLoc)
ArrayRef< Expr * > getIntExprs() const
void setIntExprDetails(ArrayRef< Expr * > IntExprs)
void setDeviceTypeDetails(llvm::SmallVector< DeviceTypeArgument > &&Archs)
OpenACCDefaultClauseKind getDefaultClauseKind() const
ExprResult ActOnVar(OpenACCClauseKind CK, Expr *VarExpr)
Called when encountering a 'var' for OpenACC, ensures it is actually a declaration reference to a var...
ExprResult ActOnIntExpr(OpenACCDirectiveKind DK, OpenACCClauseKind CK, SourceLocation Loc, Expr *IntExpr)
Called when encountering an 'int-expr' for OpenACC, and manages conversions and diagnostics to 'int'.
OpenACCClause * ActOnClause(ArrayRef< const OpenACCClause * > ExistingClauses, OpenACCParsedClause &Clause)
Called after parsing an OpenACC Clause so that it can be checked.
bool ActOnStartDeclDirective(OpenACCDirectiveKind K, SourceLocation StartLoc)
Called after the directive, including its clauses, have been parsed and parsing has consumed the 'ann...
bool CheckVarIsPointerType(OpenACCClauseKind ClauseKind, Expr *VarExpr)
Called to check the 'var' type is a variable of pointer type, necessary for 'deviceptr' and 'attach' ...
StmtResult ActOnAssociatedStmt(SourceLocation DirectiveLoc, OpenACCDirectiveKind K, StmtResult AssocStmt)
Called when we encounter an associated statement for our construct, this should check legality of the...
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
bool ActOnStartStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc)
Called after the directive, including its clauses, have been parsed and parsing has consumed the 'ann...
DeclGroupRef ActOnEndDeclDirective()
Called after the directive has been completely parsed, including the declaration group or associated ...
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument
ExprResult CheckReductionVar(Expr *VarExpr)
Called while semantically analyzing the reduction clause, ensuring the var is the correct kind of ref...
void ActOnConstruct(OpenACCDirectiveKind K, SourceLocation DirLoc)
Called after the construct has been parsed, but clauses haven't been parsed.
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
Sema - This implements semantic analysis and AST building for C.
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
bool isScalarType() const
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCClauseKind
Represents the kind of an OpenACC clause.
@ 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'.
@ 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',...
@ 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'.