21OpenACCComputeConstruct::CreateEmpty(
const ASTContext &
C,
unsigned NumClauses) {
22 void *Mem =
C.Allocate(
23 OpenACCComputeConstruct::totalSizeToAlloc<const OpenACCClause *>(
33 void *Mem =
C.Allocate(
34 OpenACCComputeConstruct::totalSizeToAlloc<const OpenACCClause *>(
37 Clauses, StructuredBlock);
41OpenACCLoopConstruct::OpenACCLoopConstruct(
unsigned NumClauses)
46 std::uninitialized_value_construct_n(getTrailingObjects(), NumClauses);
50OpenACCLoopConstruct::OpenACCLoopConstruct(
57 ParentComputeConstructKind(ParentKind) {
61 "Associated Loop not a for loop?");
63 llvm::uninitialized_copy(Clauses, getTrailingObjects());
69 unsigned NumClauses) {
71 C.Allocate(OpenACCLoopConstruct::totalSizeToAlloc<const OpenACCClause *>(
73 auto *Inst =
new (Mem) OpenACCLoopConstruct(NumClauses);
82 C.Allocate(OpenACCLoopConstruct::totalSizeToAlloc<const OpenACCClause *>(
84 auto *Inst =
new (Mem)
85 OpenACCLoopConstruct(ParentKind, BeginLoc, DirLoc, EndLoc, Clauses,
Loop);
91 unsigned NumClauses) {
92 void *Mem =
C.Allocate(
93 OpenACCCombinedConstruct::totalSizeToAlloc<const OpenACCClause *>(
95 auto *Inst =
new (Mem) OpenACCCombinedConstruct(NumClauses);
103 void *Mem =
C.Allocate(
104 OpenACCCombinedConstruct::totalSizeToAlloc<const OpenACCClause *>(
106 auto *Inst =
new (Mem)
107 OpenACCCombinedConstruct(DK, BeginLoc, DirLoc, EndLoc, Clauses,
Loop);
112 unsigned NumClauses) {
114 C.Allocate(OpenACCDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
116 auto *Inst =
new (Mem) OpenACCDataConstruct(NumClauses);
124 Stmt *StructuredBlock) {
126 C.Allocate(OpenACCDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
128 auto *Inst =
new (Mem)
129 OpenACCDataConstruct(Start, DirectiveLoc, End, Clauses, StructuredBlock);
135 unsigned NumClauses) {
136 void *Mem =
C.Allocate(
137 OpenACCEnterDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
139 auto *Inst =
new (Mem) OpenACCEnterDataConstruct(NumClauses);
146 void *Mem =
C.Allocate(
147 OpenACCEnterDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
150 new (Mem) OpenACCEnterDataConstruct(Start, DirectiveLoc, End, Clauses);
156 unsigned NumClauses) {
157 void *Mem =
C.Allocate(
158 OpenACCExitDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
160 auto *Inst =
new (Mem) OpenACCExitDataConstruct(NumClauses);
167 void *Mem =
C.Allocate(
168 OpenACCExitDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
171 new (Mem) OpenACCExitDataConstruct(Start, DirectiveLoc, End, Clauses);
177 unsigned NumClauses) {
178 void *Mem =
C.Allocate(
179 OpenACCHostDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
181 auto *Inst =
new (Mem) OpenACCHostDataConstruct(NumClauses);
188 Stmt *StructuredBlock) {
189 void *Mem =
C.Allocate(
190 OpenACCHostDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
192 auto *Inst =
new (Mem) OpenACCHostDataConstruct(Start, DirectiveLoc, End,
193 Clauses, StructuredBlock);
199 unsigned NumClauses) {
200 void *Mem =
C.Allocate(
201 OpenACCWaitConstruct::totalSizeToAlloc<Expr *, OpenACCClause *>(
202 NumExprs, NumClauses));
204 auto *Inst =
new (Mem) OpenACCWaitConstruct(NumExprs, NumClauses);
214 assert(!llvm::is_contained(QueueIdExprs,
nullptr));
216 void *Mem =
C.Allocate(
217 OpenACCWaitConstruct::totalSizeToAlloc<Expr *, OpenACCClause *>(
218 QueueIdExprs.size() + 1, Clauses.size()));
220 auto *Inst =
new (Mem)
221 OpenACCWaitConstruct(Start, DirectiveLoc, LParenLoc, DevNumExpr,
222 QueuesLoc, QueueIdExprs, RParenLoc, End, Clauses);
226 unsigned NumClauses) {
228 C.Allocate(OpenACCInitConstruct::totalSizeToAlloc<const OpenACCClause *>(
230 auto *Inst =
new (Mem) OpenACCInitConstruct(NumClauses);
239 C.Allocate(OpenACCInitConstruct::totalSizeToAlloc<const OpenACCClause *>(
242 new (Mem) OpenACCInitConstruct(Start, DirectiveLoc, End, Clauses);
247 unsigned NumClauses) {
248 void *Mem =
C.Allocate(
249 OpenACCShutdownConstruct::totalSizeToAlloc<const OpenACCClause *>(
251 auto *Inst =
new (Mem) OpenACCShutdownConstruct(NumClauses);
258 void *Mem =
C.Allocate(
259 OpenACCShutdownConstruct::totalSizeToAlloc<const OpenACCClause *>(
262 new (Mem) OpenACCShutdownConstruct(Start, DirectiveLoc, End, Clauses);
267 unsigned NumClauses) {
268 void *Mem =
C.Allocate(
269 OpenACCSetConstruct::totalSizeToAlloc<const OpenACCClause *>(NumClauses));
270 auto *Inst =
new (Mem) OpenACCSetConstruct(NumClauses);
279 C.Allocate(OpenACCSetConstruct::totalSizeToAlloc<const OpenACCClause *>(
281 auto *Inst =
new (Mem) OpenACCSetConstruct(Start, DirectiveLoc, End, Clauses);
287 void *Mem =
C.Allocate(
288 OpenACCUpdateConstruct::totalSizeToAlloc<const OpenACCClause *>(
290 auto *Inst =
new (Mem) OpenACCUpdateConstruct(NumClauses);
298 void *Mem =
C.Allocate(
299 OpenACCUpdateConstruct::totalSizeToAlloc<const OpenACCClause *>(
302 new (Mem) OpenACCUpdateConstruct(Start, DirectiveLoc, End, Clauses);
308 void *Mem =
C.Allocate(
309 OpenACCAtomicConstruct::totalSizeToAlloc<const OpenACCClause *>(
311 auto *Inst =
new (Mem) OpenACCAtomicConstruct(NumClauses);
319 void *Mem =
C.Allocate(
320 OpenACCAtomicConstruct::totalSizeToAlloc<const OpenACCClause *>(
322 auto *Inst =
new (Mem) OpenACCAtomicConstruct(Start, DirectiveLoc, AtKind,
323 End, Clauses, AssociatedStmt);
327static std::optional<std::pair<const Expr *, const Expr *>>
329 if (
const auto *BO = dyn_cast<BinaryOperator>(Op)) {
330 if (!BO->isAssignmentOp())
332 IsCompoundAssign = BO->isCompoundAssignmentOp();
333 return std::pair<const Expr *, const Expr *>(BO->getLHS(), BO->getRHS());
336 if (
const auto *OO = dyn_cast<CXXOperatorCallExpr>(Op)) {
337 if (!OO->isAssignmentOp())
339 IsCompoundAssign = OO->getOperator() != OO_Equal;
340 return std::pair<const Expr *, const Expr *>(OO->getArg(0), OO->getArg(1));
344static std::optional<std::pair<const Expr *, const Expr *>>
346 bool IsCompoundAssign;
350static std::optional<std::pair<const Expr *, bool>>
352 if (
const auto *UO = dyn_cast<UnaryOperator>(Op))
353 return {{UO->getSubExpr(), UO->isPostfix()}};
355 if (
const auto *OpCall = dyn_cast<CXXOperatorCallExpr>(Op)) {
358 if (OpCall->getNumArgs() == 1 || OpCall->getOperator() == OO_PlusPlus ||
359 OpCall->getOperator() == OO_MinusMinus)
360 return {{OpCall->getArg(0), OpCall->getNumArgs() == 1}};
368static std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
370 std::optional<std::pair<const Expr *, const Expr *>> BinaryArgs =
384 if ((!ForAtomicComputeSingleStmt &&
385 (!Res.X->isLValue() || !Res.X->getType()->isScalarType())) ||
386 !Res.V->isLValue() || !Res.V->getType()->isScalarType())
395static std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
397 std::optional<std::pair<const Expr *, const Expr *>> BinaryArgs =
407 if (!Res.X->isLValue() || !Res.X->getType()->isScalarType())
412static std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
414 std::optional<std::pair<const Expr *, bool>> UnaryArgs =
getUnaryOpArgs(E);
419 if (!Res.X->isLValue() || !Res.X->getType()->isScalarType())
425 bool IsRHSCompoundAssign =
false;
426 std::optional<std::pair<const Expr *, const Expr *>> BinaryArgs =
434 if (!Res.X->isLValue() || !Res.X->getType()->isScalarType())
440 if (IsRHSCompoundAssign)
448 }
else if (
const auto *OO = dyn_cast<CXXOperatorCallExpr>(RHS)) {
449 if (OO->isInfixBinaryOp())
465 if (
const auto *CmpdStmt = dyn_cast<CompoundStmt>(AssocStmt)) {
469 const Expr *Stmt1 =
cast<Expr>(*CmpdStmt->body().begin())->IgnoreImpCasts();
471 cast<Expr>(*(CmpdStmt->body().begin() + 1))->IgnoreImpCasts();
476 std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
Read =
490 std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
Update =
498 std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
Write =
511 std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
Update =
526 std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
Read =
528 std::optional<OpenACCAtomicConstruct::SingleStmtInfo>
Update =
536 if (
Update->IsPostfixIncDec)
551 switch (AtomicKind) {
575 llvm_unreachable(
"unknown OpenACC atomic kind");
581 C.Allocate(OpenACCCacheConstruct::totalSizeToAlloc<Expr *>(NumVars));
582 auto *Inst =
new (Mem) OpenACCCacheConstruct(NumVars);
590 void *Mem =
C.Allocate(
591 OpenACCCacheConstruct::totalSizeToAlloc<Expr *>(VarList.size()));
592 auto *Inst =
new (Mem) OpenACCCacheConstruct(
593 Start, DirectiveLoc, LParenLoc, ReadOnlyLoc, VarList, RParenLoc, End);
Defines the clang::ASTContext interface.
Defines the clang::Expr interface and subclasses for C++ expressions.
static std::optional< OpenACCAtomicConstruct::SingleStmtInfo > getReadStmtInfo(const Expr *E, bool ForAtomicComputeSingleStmt=false)
static std::optional< std::pair< const Expr *, bool > > getUnaryOpArgs(const Expr *Op)
static std::optional< OpenACCAtomicConstruct::SingleStmtInfo > getWriteStmtInfo(const Expr *E)
static OpenACCAtomicConstruct::StmtInfo getCaptureStmtInfo(const Stmt *AssocStmt)
The statement associated with an atomic capture comes in 1 of two forms: A compound statement contain...
static std::optional< OpenACCAtomicConstruct::SingleStmtInfo > getUpdateStmtInfo(const Expr *E)
static std::optional< std::pair< const Expr *, const Expr * > > getBinaryAssignOpArgs(const Expr *Op, bool &IsCompoundAssign)
This file defines OpenACC AST classes for statement-level contructs.
const Stmt * getAssociatedStmt() const
static OpenACCAtomicConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
const StmtInfo getAssociatedStmtInfo() const
static OpenACCAtomicConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, OpenACCAtomicKind AtKind, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *AssociatedStmt)
static OpenACCCacheConstruct * CreateEmpty(const ASTContext &C, unsigned NumVars)
static OpenACCCacheConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation LParenLoc, SourceLocation ReadOnlyLoc, ArrayRef< Expr * > VarList, SourceLocation RParenLoc, SourceLocation End)
static OpenACCCombinedConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCCombinedConstruct * Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
static OpenACCDataConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCDataConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
static OpenACCEnterDataConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses)
static OpenACCEnterDataConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCExitDataConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses)
static OpenACCExitDataConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCHostDataConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
static OpenACCHostDataConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCInitConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses)
static OpenACCInitConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCLoopConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCLoopConstruct * Create(const ASTContext &C, OpenACCDirectiveKind ParentKind, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< const OpenACCClause * > Clauses, Stmt *Loop)
static OpenACCSetConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCSetConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses)
static OpenACCShutdownConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCShutdownConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses)
static OpenACCUpdateConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
static OpenACCUpdateConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses)
static OpenACCWaitConstruct * CreateEmpty(const ASTContext &C, unsigned NumExprs, unsigned NumClauses)
static OpenACCWaitConstruct * Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation RParenLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
This represents one expression.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
This is a base class for any OpenACC statement-level constructs that have an associated statement.
Encodes a location in the source.
Stmt - This represents one statement.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
OpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
setClauseList(getTrailingObjects(NumClauses))
U cast(CodeGen::Address addr)
static SingleStmtInfo createRead(const Expr *WholeExpr, const Expr *V, const Expr *X)
static SingleStmtInfo Empty()
static SingleStmtInfo createWrite(const Expr *WholeExpr, const Expr *X, const Expr *RefExpr)
static SingleStmtInfo createUpdate(const Expr *WholeExpr, const Expr *X, bool PostfixIncDec)
static StmtInfo createReadUpdate(SingleStmtInfo First, SingleStmtInfo Second)
static StmtInfo createUpdateRead(SingleStmtInfo First, SingleStmtInfo Second)
static StmtInfo createReadWrite(SingleStmtInfo First, SingleStmtInfo Second)