14#ifndef LLVM_CLANG_SEMA_SEMAOPENACC_H
15#define LLVM_CLANG_SEMA_SEMAOPENACC_H
42 struct DefaultDetails {
46 struct ConditionDetails {
50 struct IntExprDetails {
54 struct VarListDetails {
66 struct DeviceTypeDetails {
70 std::variant<std::monostate, DefaultDetails, ConditionDetails,
71 IntExprDetails, VarListDetails, WaitDetails, DeviceTypeDetails>
72 Details = std::monostate{};
77 : DirKind(DirKind), ClauseKind(ClauseKind), ClauseRange(BeginLoc, {}) {}
91 "Parsed clause is not a default clause");
92 return std::get<DefaultDetails>(Details).DefaultClauseKind;
103 "Parsed clause kind does not have a condition expr");
108 std::holds_alternative<std::monostate>(Details))
111 return std::get<ConditionDetails>(Details).ConditionExpr;
119 "Parsed clause kind does not have a int exprs");
124 std::holds_alternative<std::monostate>(Details))
126 return std::get<IntExprDetails>(Details).IntExprs.size();
131 "Parsed clause kind does not have a queues location");
133 if (std::holds_alternative<std::monostate>(Details))
136 return std::get<WaitDetails>(Details).QueuesLoc;
141 "Parsed clause kind does not have a device number expr");
143 if (std::holds_alternative<std::monostate>(Details))
146 return std::get<WaitDetails>(Details).DevNumExpr;
151 "Parsed clause kind does not have a queue id expr list");
153 if (std::holds_alternative<std::monostate>(Details))
156 return std::get<WaitDetails>(Details).QueueIdExprs;
164 "Parsed clause kind does not have a int exprs");
166 return std::get<IntExprDetails>(Details).IntExprs;
192 "Parsed clause kind does not have a var-list");
193 return std::get<VarListDetails>(Details).VarList;
204 "Only copyin accepts 'readonly:' tag");
205 return std::get<VarListDetails>(Details).IsReadOnly;
215 "Only copyout/create accepts 'zero' tag");
216 return std::get<VarListDetails>(Details).IsZero;
222 "Only 'device_type'/'dtype' has a device-type-arg list");
223 return std::get<DeviceTypeDetails>(Details).Archs;
231 "Parsed clause is not a default clause");
232 Details = DefaultDetails{DefKind};
239 "Parsed clause kind does not have a condition expr");
244 "Condition expression type not scalar/dependent");
246 Details = ConditionDetails{ConditionExpr};
254 "Parsed clause kind does not have a int exprs");
255 Details = IntExprDetails{{IntExprs.begin(), IntExprs.end()}};
262 "Parsed clause kind does not have a int exprs");
263 Details = IntExprDetails{std::move(IntExprs)};
286 "Parsed clause kind does not have a var-list");
290 "readonly: tag only valid on copyin");
297 "zero: tag only valid on copyout/create");
299 VarListDetails{{VarList.begin(), VarList.end()}, IsReadOnly, IsZero};
322 "Parsed clause kind does not have a var-list");
326 "readonly: tag only valid on copyin");
333 "zero: tag only valid on copyout/create");
334 Details = VarListDetails{std::move(VarList), IsReadOnly, IsZero};
340 "Parsed clause kind does not have a wait-details");
341 Details = WaitDetails{DevNum, QueuesLoc, std::move(IntExprs)};
347 "Only 'device_type'/'dtype' has a device-type-arg list");
348 Details = DeviceTypeDetails{std::move(Archs)};
356 OpenACCParsedClause &Clause);
Defines some OpenACC-specific enums and functions.
Defines the clang::SourceLocation class and associated facilities.
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.
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)
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)
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(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'.
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
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' ...
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 ...
void ActOnConstruct(OpenACCDirectiveKind K, SourceLocation StartLoc)
Called after the construct has been parsed, but clauses haven't been parsed.
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument
StmtResult ActOnAssociatedStmt(OpenACCDirectiveKind K, StmtResult AssocStmt)
Called when we encounter an associated statement for our construct, this should check legality of the...
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'.
@ 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'.