14#ifndef LLVM_CLANG_SEMA_SEMAOPENACC_H
15#define LLVM_CLANG_SEMA_SEMAOPENACC_H
24#include "llvm/ADT/SmallVector.h"
42 bool InsideComputeConstruct =
false;
58 struct DefaultDetails {
62 struct ConditionDetails {
66 struct IntExprDetails {
70 struct VarListDetails {
82 struct DeviceTypeDetails {
85 struct ReductionDetails {
90 std::variant<std::monostate, DefaultDetails, ConditionDetails,
91 IntExprDetails, VarListDetails, WaitDetails, DeviceTypeDetails,
93 Details = std::monostate{};
98 : DirKind(DirKind), ClauseKind(ClauseKind), ClauseRange(BeginLoc, {}) {}
112 "Parsed clause is not a default clause");
113 return std::get<DefaultDetails>(Details).DefaultClauseKind;
124 "Parsed clause kind does not have a condition expr");
129 std::holds_alternative<std::monostate>(Details))
132 return std::get<ConditionDetails>(Details).ConditionExpr;
140 "Parsed clause kind does not have a int exprs");
145 std::holds_alternative<std::monostate>(Details))
147 return std::get<IntExprDetails>(Details).IntExprs.size();
152 "Parsed clause kind does not have a queues location");
154 if (std::holds_alternative<std::monostate>(Details))
157 return std::get<WaitDetails>(Details).QueuesLoc;
162 "Parsed clause kind does not have a device number expr");
164 if (std::holds_alternative<std::monostate>(Details))
167 return std::get<WaitDetails>(Details).DevNumExpr;
172 "Parsed clause kind does not have a queue id expr list");
174 if (std::holds_alternative<std::monostate>(Details))
177 return std::get<WaitDetails>(Details).QueueIdExprs;
185 "Parsed clause kind does not have a int exprs");
187 return std::get<IntExprDetails>(Details).IntExprs;
195 return std::get<ReductionDetails>(Details).Op;
218 "Parsed clause kind does not have a var-list");
221 return std::get<ReductionDetails>(Details).VarList;
223 return std::get<VarListDetails>(Details).VarList;
234 "Only copyin accepts 'readonly:' tag");
235 return std::get<VarListDetails>(Details).IsReadOnly;
245 "Only copyout/create accepts 'zero' tag");
246 return std::get<VarListDetails>(Details).IsZero;
252 "Only 'device_type'/'dtype' has a device-type-arg list");
253 return std::get<DeviceTypeDetails>(Details).Archs;
261 "Parsed clause is not a default clause");
262 Details = DefaultDetails{DefKind};
269 "Parsed clause kind does not have a condition expr");
274 "Condition expression type not scalar/dependent");
276 Details = ConditionDetails{ConditionExpr};
284 "Parsed clause kind does not have a int exprs");
285 Details = IntExprDetails{{IntExprs.begin(), IntExprs.end()}};
292 "Parsed clause kind does not have a int exprs");
293 Details = IntExprDetails{std::move(IntExprs)};
316 "Parsed clause kind does not have a var-list");
320 "readonly: tag only valid on copyin");
327 "zero: tag only valid on copyout/create");
329 VarListDetails{{VarList.begin(), VarList.end()}, IsReadOnly, IsZero};
352 "Parsed clause kind does not have a var-list");
356 "readonly: tag only valid on copyin");
363 "zero: tag only valid on copyout/create");
364 Details = VarListDetails{std::move(VarList), IsReadOnly, IsZero};
370 "reduction details only valid on reduction");
371 Details = ReductionDetails{Op, std::move(VarList)};
377 "Parsed clause kind does not have a wait-details");
378 Details = WaitDetails{DevNum, QueuesLoc, std::move(IntExprs)};
384 "Only 'device_type'/'dtype' has a device-type-arg list");
385 Details = DeviceTypeDetails{std::move(Archs)};
393 OpenACCParsedClause &Clause);
457 bool WasInsideComputeConstruct;
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
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'.