clang 22.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_n(getTrailingObjects(), NumClauses);
45 setClauseList(getTrailingObjects(NumClauses));
46}
47
48OpenACCLoopConstruct::OpenACCLoopConstruct(
49 OpenACCDirectiveKind ParentKind, SourceLocation Start,
52 : OpenACCAssociatedStmtConstruct(OpenACCLoopConstructClass,
53 OpenACCDirectiveKind::Loop, Start, DirLoc,
54 End, Loop),
55 ParentComputeConstructKind(ParentKind) {
56 // accept 'nullptr' for the loop. This is diagnosed somewhere, but this gives
57 // us some level of AST fidelity in the error case.
58 assert((Loop == nullptr || isa<ForStmt, CXXForRangeStmt>(Loop)) &&
59 "Associated Loop not a for loop?");
60 // Initialize the trailing storage.
61 llvm::uninitialized_copy(Clauses, getTrailingObjects());
62
63 setClauseList(getTrailingObjects(Clauses.size()));
64}
65
67 unsigned NumClauses) {
68 void *Mem =
69 C.Allocate(OpenACCLoopConstruct::totalSizeToAlloc<const OpenACCClause *>(
70 NumClauses));
71 auto *Inst = new (Mem) OpenACCLoopConstruct(NumClauses);
72 return Inst;
73}
74
76 const ASTContext &C, OpenACCDirectiveKind ParentKind,
77 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc,
79 void *Mem =
80 C.Allocate(OpenACCLoopConstruct::totalSizeToAlloc<const OpenACCClause *>(
81 Clauses.size()));
82 auto *Inst = new (Mem)
83 OpenACCLoopConstruct(ParentKind, BeginLoc, DirLoc, EndLoc, Clauses, Loop);
84 return Inst;
85}
86
89 unsigned NumClauses) {
90 void *Mem = C.Allocate(
91 OpenACCCombinedConstruct::totalSizeToAlloc<const OpenACCClause *>(
92 NumClauses));
93 auto *Inst = new (Mem) OpenACCCombinedConstruct(NumClauses);
94 return Inst;
95}
96
99 SourceLocation DirLoc, SourceLocation EndLoc,
101 void *Mem = C.Allocate(
102 OpenACCCombinedConstruct::totalSizeToAlloc<const OpenACCClause *>(
103 Clauses.size()));
104 auto *Inst = new (Mem)
105 OpenACCCombinedConstruct(DK, BeginLoc, DirLoc, EndLoc, Clauses, Loop);
106 return Inst;
107}
108
110 unsigned NumClauses) {
111 void *Mem =
112 C.Allocate(OpenACCDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
113 NumClauses));
114 auto *Inst = new (Mem) OpenACCDataConstruct(NumClauses);
115 return Inst;
116}
117
120 SourceLocation DirectiveLoc, SourceLocation End,
122 Stmt *StructuredBlock) {
123 void *Mem =
124 C.Allocate(OpenACCDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
125 Clauses.size()));
126 auto *Inst = new (Mem)
127 OpenACCDataConstruct(Start, DirectiveLoc, End, Clauses, StructuredBlock);
128 return Inst;
129}
130
133 unsigned NumClauses) {
134 void *Mem = C.Allocate(
135 OpenACCEnterDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
136 NumClauses));
137 auto *Inst = new (Mem) OpenACCEnterDataConstruct(NumClauses);
138 return Inst;
139}
140
142 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
144 void *Mem = C.Allocate(
145 OpenACCEnterDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
146 Clauses.size()));
147 auto *Inst =
148 new (Mem) OpenACCEnterDataConstruct(Start, DirectiveLoc, End, Clauses);
149 return Inst;
150}
151
154 unsigned NumClauses) {
155 void *Mem = C.Allocate(
156 OpenACCExitDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
157 NumClauses));
158 auto *Inst = new (Mem) OpenACCExitDataConstruct(NumClauses);
159 return Inst;
160}
161
163 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
165 void *Mem = C.Allocate(
166 OpenACCExitDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
167 Clauses.size()));
168 auto *Inst =
169 new (Mem) OpenACCExitDataConstruct(Start, DirectiveLoc, End, Clauses);
170 return Inst;
171}
172
175 unsigned NumClauses) {
176 void *Mem = C.Allocate(
177 OpenACCHostDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
178 NumClauses));
179 auto *Inst = new (Mem) OpenACCHostDataConstruct(NumClauses);
180 return Inst;
181}
182
184 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
186 Stmt *StructuredBlock) {
187 void *Mem = C.Allocate(
188 OpenACCHostDataConstruct::totalSizeToAlloc<const OpenACCClause *>(
189 Clauses.size()));
190 auto *Inst = new (Mem) OpenACCHostDataConstruct(Start, DirectiveLoc, End,
191 Clauses, StructuredBlock);
192 return Inst;
193}
194
196 unsigned NumExprs,
197 unsigned NumClauses) {
198 void *Mem = C.Allocate(
199 OpenACCWaitConstruct::totalSizeToAlloc<Expr *, OpenACCClause *>(
200 NumExprs, NumClauses));
201
202 auto *Inst = new (Mem) OpenACCWaitConstruct(NumExprs, NumClauses);
203 return Inst;
204}
205
207 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
208 SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc,
209 ArrayRef<Expr *> QueueIdExprs, SourceLocation RParenLoc, SourceLocation End,
211
212 assert(!llvm::is_contained(QueueIdExprs, nullptr));
213
214 void *Mem = C.Allocate(
215 OpenACCWaitConstruct::totalSizeToAlloc<Expr *, OpenACCClause *>(
216 QueueIdExprs.size() + 1, Clauses.size()));
217
218 auto *Inst = new (Mem)
219 OpenACCWaitConstruct(Start, DirectiveLoc, LParenLoc, DevNumExpr,
220 QueuesLoc, QueueIdExprs, RParenLoc, End, Clauses);
221 return Inst;
222}
224 unsigned NumClauses) {
225 void *Mem =
226 C.Allocate(OpenACCInitConstruct::totalSizeToAlloc<const OpenACCClause *>(
227 NumClauses));
228 auto *Inst = new (Mem) OpenACCInitConstruct(NumClauses);
229 return Inst;
230}
231
234 SourceLocation DirectiveLoc, SourceLocation End,
236 void *Mem =
237 C.Allocate(OpenACCInitConstruct::totalSizeToAlloc<const OpenACCClause *>(
238 Clauses.size()));
239 auto *Inst =
240 new (Mem) OpenACCInitConstruct(Start, DirectiveLoc, End, Clauses);
241 return Inst;
242}
245 unsigned NumClauses) {
246 void *Mem = C.Allocate(
247 OpenACCShutdownConstruct::totalSizeToAlloc<const OpenACCClause *>(
248 NumClauses));
249 auto *Inst = new (Mem) OpenACCShutdownConstruct(NumClauses);
250 return Inst;
251}
252
254 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
256 void *Mem = C.Allocate(
257 OpenACCShutdownConstruct::totalSizeToAlloc<const OpenACCClause *>(
258 Clauses.size()));
259 auto *Inst =
260 new (Mem) OpenACCShutdownConstruct(Start, DirectiveLoc, End, Clauses);
261 return Inst;
262}
263
265 unsigned NumClauses) {
266 void *Mem = C.Allocate(
267 OpenACCSetConstruct::totalSizeToAlloc<const OpenACCClause *>(NumClauses));
268 auto *Inst = new (Mem) OpenACCSetConstruct(NumClauses);
269 return Inst;
270}
271
274 SourceLocation DirectiveLoc, SourceLocation End,
276 void *Mem =
277 C.Allocate(OpenACCSetConstruct::totalSizeToAlloc<const OpenACCClause *>(
278 Clauses.size()));
279 auto *Inst = new (Mem) OpenACCSetConstruct(Start, DirectiveLoc, End, Clauses);
280 return Inst;
281}
282
285 void *Mem = C.Allocate(
286 OpenACCUpdateConstruct::totalSizeToAlloc<const OpenACCClause *>(
287 NumClauses));
288 auto *Inst = new (Mem) OpenACCUpdateConstruct(NumClauses);
289 return Inst;
290}
291
294 SourceLocation DirectiveLoc, SourceLocation End,
296 void *Mem = C.Allocate(
297 OpenACCUpdateConstruct::totalSizeToAlloc<const OpenACCClause *>(
298 Clauses.size()));
299 auto *Inst =
300 new (Mem) OpenACCUpdateConstruct(Start, DirectiveLoc, End, Clauses);
301 return Inst;
302}
303
306 void *Mem = C.Allocate(
307 OpenACCAtomicConstruct::totalSizeToAlloc<const OpenACCClause *>(
308 NumClauses));
309 auto *Inst = new (Mem) OpenACCAtomicConstruct(NumClauses);
310 return Inst;
311}
312
314 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
316 ArrayRef<const OpenACCClause *> Clauses, Stmt *AssociatedStmt) {
317 void *Mem = C.Allocate(
318 OpenACCAtomicConstruct::totalSizeToAlloc<const OpenACCClause *>(
319 Clauses.size()));
320 auto *Inst = new (Mem) OpenACCAtomicConstruct(Start, DirectiveLoc, AtKind,
321 End, Clauses, AssociatedStmt);
322 return Inst;
323}
324
326 unsigned NumVars) {
327 void *Mem =
328 C.Allocate(OpenACCCacheConstruct::totalSizeToAlloc<Expr *>(NumVars));
329 auto *Inst = new (Mem) OpenACCCacheConstruct(NumVars);
330 return Inst;
331}
332
334 const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
335 SourceLocation LParenLoc, SourceLocation ReadOnlyLoc,
336 ArrayRef<Expr *> VarList, SourceLocation RParenLoc, SourceLocation End) {
337 void *Mem = C.Allocate(
338 OpenACCCacheConstruct::totalSizeToAlloc<Expr *>(VarList.size()));
339 auto *Inst = new (Mem) OpenACCCacheConstruct(
340 Start, DirectiveLoc, LParenLoc, ReadOnlyLoc, VarList, RParenLoc, End);
341 return Inst;
342}
Defines the clang::ASTContext interface.
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:112
This is a base class for any OpenACC statement-level constructs that have an associated statement.
Definition: StmtOpenACC.h:81
static OpenACCAtomicConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
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)
Definition: StmtOpenACC.cpp:88
static OpenACCCombinedConstruct * Create(const ASTContext &C, OpenACCDirectiveKind K, SourceLocation Start, SourceLocation DirectiveLoc, SourceLocation End, ArrayRef< const OpenACCClause * > Clauses, Stmt *StructuredBlock)
Definition: StmtOpenACC.cpp:97
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Definition: StmtOpenACC.h:132
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:51
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:190
static OpenACCLoopConstruct * CreateEmpty(const ASTContext &C, unsigned NumClauses)
Definition: StmtOpenACC.cpp:66
static OpenACCLoopConstruct * Create(const ASTContext &C, OpenACCDirectiveKind ParentKind, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< const OpenACCClause * > Clauses, Stmt *Loop)
Definition: StmtOpenACC.cpp:75
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)
Encodes a location in the source.
Stmt - This represents one statement.
Definition: Stmt.h:85
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCDirectiveKind
Definition: OpenACCKinds.h:28
OpenACCAtomicKind
Definition: OpenACCKinds.h:172