clang 20.0.0git
StmtOpenACC.cpp
Go to the documentation of this file.
1//===--- StmtOpenACC.cpp - Classes for OpenACC Constructs -----------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the subclasses of Stmt class declared in StmtOpenACC.h
10//
11//===----------------------------------------------------------------------===//
12
15#include "clang/AST/StmtCXX.h"
16using namespace clang;
17
20 void *Mem = C.Allocate(
21 OpenACCComputeConstruct::totalSizeToAlloc<const OpenACCClause *>(
22 NumClauses));
23 auto *Inst = new (Mem) OpenACCComputeConstruct(NumClauses);
24 return Inst;
25}
26
29 SourceLocation DirLoc, SourceLocation EndLoc,
30 ArrayRef<const OpenACCClause *> Clauses, Stmt *StructuredBlock) {
31 void *Mem = C.Allocate(
32 OpenACCComputeConstruct::totalSizeToAlloc<const OpenACCClause *>(
33 Clauses.size()));
34 auto *Inst = new (Mem) OpenACCComputeConstruct(K, BeginLoc, DirLoc, EndLoc,
35 Clauses, StructuredBlock);
36 return Inst;
37}
38
39OpenACCLoopConstruct::OpenACCLoopConstruct(unsigned NumClauses)
41 OpenACCLoopConstructClass, OpenACCDirectiveKind::Loop,
43 /*AssociatedStmt=*/nullptr) {
44 std::uninitialized_value_construct(
45 getTrailingObjects<const OpenACCClause *>(),
46 getTrailingObjects<const OpenACCClause *>() + NumClauses);
48 MutableArrayRef(getTrailingObjects<const OpenACCClause *>(), NumClauses));
49}
50
51OpenACCLoopConstruct::OpenACCLoopConstruct(
52 OpenACCDirectiveKind ParentKind, SourceLocation Start,
55 : OpenACCAssociatedStmtConstruct(OpenACCLoopConstructClass,
56 OpenACCDirectiveKind::Loop, Start, DirLoc,
57 End, Loop),
58 ParentComputeConstructKind(ParentKind) {
59 // accept 'nullptr' for the loop. This is diagnosed somewhere, but this gives
60 // us some level of AST fidelity in the error case.
61 assert((Loop == nullptr || isa<ForStmt, CXXForRangeStmt>(Loop)) &&
62 "Associated Loop not a for loop?");
63 // Initialize the trailing storage.
64 std::uninitialized_copy(Clauses.begin(), Clauses.end(),
65 getTrailingObjects<const OpenACCClause *>());
66
67 setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
68 Clauses.size()));
69}
70
72 unsigned NumClauses) {
73 void *Mem =
74 C.Allocate(OpenACCLoopConstruct::totalSizeToAlloc<const OpenACCClause *>(
75 NumClauses));
76 auto *Inst = new (Mem) OpenACCLoopConstruct(NumClauses);
77 return Inst;
78}
79
81 const ASTContext &C, OpenACCDirectiveKind ParentKind,
82 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc,
84 void *Mem =
85 C.Allocate(OpenACCLoopConstruct::totalSizeToAlloc<const OpenACCClause *>(
86 Clauses.size()));
87 auto *Inst = new (Mem)
88 OpenACCLoopConstruct(ParentKind, BeginLoc, DirLoc, EndLoc, Clauses, Loop);
89 return Inst;
90}
91
94 unsigned NumClauses) {
95 void *Mem = C.Allocate(
96 OpenACCCombinedConstruct::totalSizeToAlloc<const OpenACCClause *>(
97 NumClauses));
98 auto *Inst = new (Mem) OpenACCCombinedConstruct(NumClauses);
99 return Inst;
100}
101
103 const ASTContext &C, OpenACCDirectiveKind DK, SourceLocation BeginLoc,
104 SourceLocation DirLoc, SourceLocation EndLoc,
106 void *Mem = C.Allocate(
107 OpenACCCombinedConstruct::totalSizeToAlloc<const OpenACCClause *>(
108 Clauses.size()));
109 auto *Inst = new (Mem)
110 OpenACCCombinedConstruct(DK, BeginLoc, DirLoc, EndLoc, Clauses, Loop);
111 return Inst;
112}
113
115 unsigned NumClauses) {
116 void *Mem =
117 C.Allocate(OpenACCDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
118 NumClauses));
119 auto *Inst = new (Mem) OpenACCDataConstruct(NumClauses);
120 return Inst;
121}
122
125 SourceLocation DirectiveLoc, SourceLocation End,
127 Stmt *StructuredBlock) {
128 void *Mem =
129 C.Allocate(OpenACCDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
130 Clauses.size()));
131 auto *Inst = new (Mem)
132 OpenACCDataConstruct(Start, DirectiveLoc, End, Clauses, StructuredBlock);
133 return Inst;
134}
135
138 unsigned NumClauses) {
139 void *Mem = C.Allocate(
140 OpenACCEnterDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
141 NumClauses));
142 auto *Inst = new (Mem) OpenACCEnterDataConstruct(NumClauses);
143 return Inst;
144}
145
147 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
149 void *Mem = C.Allocate(
150 OpenACCEnterDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
151 Clauses.size()));
152 auto *Inst =
153 new (Mem) OpenACCEnterDataConstruct(Start, DirectiveLoc, End, Clauses);
154 return Inst;
155}
156
159 unsigned NumClauses) {
160 void *Mem = C.Allocate(
161 OpenACCExitDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
162 NumClauses));
163 auto *Inst = new (Mem) OpenACCExitDataConstruct(NumClauses);
164 return Inst;
165}
166
168 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
170 void *Mem = C.Allocate(
171 OpenACCExitDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
172 Clauses.size()));
173 auto *Inst =
174 new (Mem) OpenACCExitDataConstruct(Start, DirectiveLoc, End, Clauses);
175 return Inst;
176}
177
180 unsigned NumClauses) {
181 void *Mem = C.Allocate(
182 OpenACCHostDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
183 NumClauses));
184 auto *Inst = new (Mem) OpenACCHostDataConstruct(NumClauses);
185 return Inst;
186}
187
189 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
191 Stmt *StructuredBlock) {
192 void *Mem = C.Allocate(
193 OpenACCHostDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
194 Clauses.size()));
195 auto *Inst = new (Mem) OpenACCHostDataConstruct(Start, DirectiveLoc, End,
196 Clauses, StructuredBlock);
197 return Inst;
198}
199
201 unsigned NumExprs,
202 unsigned NumClauses) {
203 void *Mem = C.Allocate(
204 OpenACCWaitConstruct::totalSizeToAlloc<Expr *, OpenACCClause *>(
205 NumExprs, NumClauses));
206
207 auto *Inst = new (Mem) OpenACCWaitConstruct(NumExprs, NumClauses);
208 return Inst;
209}
210
212 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
213 SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc,
214 ArrayRef<Expr *> QueueIdExprs, SourceLocation RParenLoc, SourceLocation End,
216
217 assert(llvm::all_of(QueueIdExprs, [](Expr *E) { return E != nullptr; }));
218
219 void *Mem = C.Allocate(
220 OpenACCWaitConstruct::totalSizeToAlloc<Expr *, OpenACCClause *>(
221 QueueIdExprs.size() + 1, Clauses.size()));
222
223 auto *Inst = new (Mem)
224 OpenACCWaitConstruct(Start, DirectiveLoc, LParenLoc, DevNumExpr,
225 QueuesLoc, QueueIdExprs, RParenLoc, End, Clauses);
226 return Inst;
227}
229 unsigned NumClauses) {
230 void *Mem =
231 C.Allocate(OpenACCInitConstruct::totalSizeToAlloc<const OpenACCClause *>(
232 NumClauses));
233 auto *Inst = new (Mem) OpenACCInitConstruct(NumClauses);
234 return Inst;
235}
236
239 SourceLocation DirectiveLoc, SourceLocation End,
241 void *Mem =
242 C.Allocate(OpenACCInitConstruct::totalSizeToAlloc<const OpenACCClause *>(
243 Clauses.size()));
244 auto *Inst =
245 new (Mem) OpenACCInitConstruct(Start, DirectiveLoc, End, Clauses);
246 return Inst;
247}
250 unsigned NumClauses) {
251 void *Mem = C.Allocate(
252 OpenACCShutdownConstruct::totalSizeToAlloc<const OpenACCClause *>(
253 NumClauses));
254 auto *Inst = new (Mem) OpenACCShutdownConstruct(NumClauses);
255 return Inst;
256}
257
259 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
261 void *Mem = C.Allocate(
262 OpenACCShutdownConstruct::totalSizeToAlloc<const OpenACCClause *>(
263 Clauses.size()));
264 auto *Inst =
265 new (Mem) OpenACCShutdownConstruct(Start, DirectiveLoc, End, Clauses);
266 return Inst;
267}
Defines the clang::ASTContext interface.
Expr * E
This file defines OpenACC AST classes for statement-level contructs.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
This represents one expression.
Definition: Expr.h:110
This is a base class for any OpenACC statement-level constructs that have an associated statement.
Definition: StmtOpenACC.h:80
static OpenACCCombinedConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
Definition: StmtOpenACC.cpp:93
static OpenACCCombinedConstruct * Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Definition: StmtOpenACC.h:131
static OpenACCComputeConstruct * Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirectiveLoc, SourceLocation EndLoc, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
Definition: StmtOpenACC.cpp:27
static OpenACCComputeConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
Definition: StmtOpenACC.cpp:19
void setClauseList(MutableArrayRef< const OpenACCClause * > NewClauses)
Definition: StmtOpenACC.h:50
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)
This class represents a 'loop' construct.
Definition: StmtOpenACC.h:194
static OpenACCLoopConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
Definition: StmtOpenACC.cpp:71
static OpenACCLoopConstruct * Create(const ASTContext &C, OpenACCDirectiveKind ParentKind, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< const OpenACCClause * > Clauses, Stmt *Loop)
Definition: StmtOpenACC.cpp:80
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 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)
Encodes a location in the source.
Stmt - This represents one statement.
Definition: Stmt.h:84
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCDirectiveKind
Definition: OpenACCKinds.h:25