[NFC][Fuzzer] Extract CreateGateBranch method. (#117236)
[llvm-project.git] / clang / lib / AST / OpenACCClause.cpp
blob1299e4f807ceb11616f3b39e29219ceb418074fb
1 //===---- OpenACCClause.cpp - Classes for OpenACC Clauses ----------------===//
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 the OpenACCClause class declared in
10 // OpenACCClause.h
12 //===----------------------------------------------------------------------===//
14 #include "clang/AST/OpenACCClause.h"
15 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Expr.h"
18 using namespace clang;
20 bool OpenACCClauseWithParams::classof(const OpenACCClause *C) {
21 return OpenACCDeviceTypeClause::classof(C) ||
22 OpenACCClauseWithCondition::classof(C) ||
23 OpenACCClauseWithExprs::classof(C);
25 bool OpenACCClauseWithExprs::classof(const OpenACCClause *C) {
26 return OpenACCWaitClause::classof(C) || OpenACCNumGangsClause::classof(C) ||
27 OpenACCTileClause::classof(C) ||
28 OpenACCClauseWithSingleIntExpr::classof(C) ||
29 OpenACCGangClause::classof(C) || OpenACCClauseWithVarList::classof(C);
31 bool OpenACCClauseWithVarList::classof(const OpenACCClause *C) {
32 return OpenACCPrivateClause::classof(C) ||
33 OpenACCFirstPrivateClause::classof(C) ||
34 OpenACCDevicePtrClause::classof(C) ||
35 OpenACCDevicePtrClause::classof(C) ||
36 OpenACCAttachClause::classof(C) || OpenACCNoCreateClause::classof(C) ||
37 OpenACCPresentClause::classof(C) || OpenACCCopyClause::classof(C) ||
38 OpenACCCopyInClause::classof(C) || OpenACCCopyOutClause::classof(C) ||
39 OpenACCReductionClause::classof(C) || OpenACCCreateClause::classof(C);
41 bool OpenACCClauseWithCondition::classof(const OpenACCClause *C) {
42 return OpenACCIfClause::classof(C) || OpenACCSelfClause::classof(C);
44 bool OpenACCClauseWithSingleIntExpr::classof(const OpenACCClause *C) {
45 return OpenACCNumWorkersClause::classof(C) ||
46 OpenACCVectorLengthClause::classof(C) ||
47 OpenACCVectorClause::classof(C) || OpenACCWorkerClause::classof(C) ||
48 OpenACCCollapseClause::classof(C) || OpenACCAsyncClause::classof(C);
50 OpenACCDefaultClause *OpenACCDefaultClause::Create(const ASTContext &C,
51 OpenACCDefaultClauseKind K,
52 SourceLocation BeginLoc,
53 SourceLocation LParenLoc,
54 SourceLocation EndLoc) {
55 void *Mem =
56 C.Allocate(sizeof(OpenACCDefaultClause), alignof(OpenACCDefaultClause));
58 return new (Mem) OpenACCDefaultClause(K, BeginLoc, LParenLoc, EndLoc);
61 OpenACCIfClause *OpenACCIfClause::Create(const ASTContext &C,
62 SourceLocation BeginLoc,
63 SourceLocation LParenLoc,
64 Expr *ConditionExpr,
65 SourceLocation EndLoc) {
66 void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
67 return new (Mem) OpenACCIfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
70 OpenACCIfClause::OpenACCIfClause(SourceLocation BeginLoc,
71 SourceLocation LParenLoc, Expr *ConditionExpr,
72 SourceLocation EndLoc)
73 : OpenACCClauseWithCondition(OpenACCClauseKind::If, BeginLoc, LParenLoc,
74 ConditionExpr, EndLoc) {
75 assert(ConditionExpr && "if clause requires condition expr");
76 assert((ConditionExpr->isInstantiationDependent() ||
77 ConditionExpr->getType()->isScalarType()) &&
78 "Condition expression type not scalar/dependent");
81 OpenACCSelfClause *OpenACCSelfClause::Create(const ASTContext &C,
82 SourceLocation BeginLoc,
83 SourceLocation LParenLoc,
84 Expr *ConditionExpr,
85 SourceLocation EndLoc) {
86 void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
87 return new (Mem)
88 OpenACCSelfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
91 OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
92 SourceLocation LParenLoc,
93 Expr *ConditionExpr, SourceLocation EndLoc)
94 : OpenACCClauseWithCondition(OpenACCClauseKind::Self, BeginLoc, LParenLoc,
95 ConditionExpr, EndLoc) {
96 assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() ||
97 ConditionExpr->getType()->isScalarType()) &&
98 "Condition expression type not scalar/dependent");
101 OpenACCClause::child_range OpenACCClause::children() {
102 switch (getClauseKind()) {
103 default:
104 assert(false && "Clause children function not implemented");
105 break;
106 #define VISIT_CLAUSE(CLAUSE_NAME) \
107 case OpenACCClauseKind::CLAUSE_NAME: \
108 return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
109 #define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED) \
110 case OpenACCClauseKind::ALIAS_NAME: \
111 return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
113 #include "clang/Basic/OpenACCClauses.def"
115 return child_range(child_iterator(), child_iterator());
118 OpenACCNumWorkersClause::OpenACCNumWorkersClause(SourceLocation BeginLoc,
119 SourceLocation LParenLoc,
120 Expr *IntExpr,
121 SourceLocation EndLoc)
122 : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::NumWorkers, BeginLoc,
123 LParenLoc, IntExpr, EndLoc) {
124 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
125 IntExpr->getType()->isIntegerType()) &&
126 "Condition expression type not scalar/dependent");
129 OpenACCGangClause::OpenACCGangClause(SourceLocation BeginLoc,
130 SourceLocation LParenLoc,
131 ArrayRef<OpenACCGangKind> GangKinds,
132 ArrayRef<Expr *> IntExprs,
133 SourceLocation EndLoc)
134 : OpenACCClauseWithExprs(OpenACCClauseKind::Gang, BeginLoc, LParenLoc,
135 EndLoc) {
136 assert(GangKinds.size() == IntExprs.size() && "Mismatch exprs/kind?");
137 std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
138 getTrailingObjects<Expr *>());
139 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
140 std::uninitialized_copy(GangKinds.begin(), GangKinds.end(),
141 getTrailingObjects<OpenACCGangKind>());
144 OpenACCNumWorkersClause *
145 OpenACCNumWorkersClause::Create(const ASTContext &C, SourceLocation BeginLoc,
146 SourceLocation LParenLoc, Expr *IntExpr,
147 SourceLocation EndLoc) {
148 void *Mem = C.Allocate(sizeof(OpenACCNumWorkersClause),
149 alignof(OpenACCNumWorkersClause));
150 return new (Mem)
151 OpenACCNumWorkersClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
154 OpenACCCollapseClause::OpenACCCollapseClause(SourceLocation BeginLoc,
155 SourceLocation LParenLoc,
156 bool HasForce, Expr *LoopCount,
157 SourceLocation EndLoc)
158 : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Collapse, BeginLoc,
159 LParenLoc, LoopCount, EndLoc),
160 HasForce(HasForce) {
161 assert(LoopCount && "LoopCount required");
164 OpenACCCollapseClause *
165 OpenACCCollapseClause::Create(const ASTContext &C, SourceLocation BeginLoc,
166 SourceLocation LParenLoc, bool HasForce,
167 Expr *LoopCount, SourceLocation EndLoc) {
168 assert(
169 LoopCount &&
170 (LoopCount->isInstantiationDependent() || isa<ConstantExpr>(LoopCount)) &&
171 "Loop count not constant expression");
172 void *Mem =
173 C.Allocate(sizeof(OpenACCCollapseClause), alignof(OpenACCCollapseClause));
174 return new (Mem)
175 OpenACCCollapseClause(BeginLoc, LParenLoc, HasForce, LoopCount, EndLoc);
178 OpenACCVectorLengthClause::OpenACCVectorLengthClause(SourceLocation BeginLoc,
179 SourceLocation LParenLoc,
180 Expr *IntExpr,
181 SourceLocation EndLoc)
182 : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::VectorLength, BeginLoc,
183 LParenLoc, IntExpr, EndLoc) {
184 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
185 IntExpr->getType()->isIntegerType()) &&
186 "Condition expression type not scalar/dependent");
189 OpenACCVectorLengthClause *
190 OpenACCVectorLengthClause::Create(const ASTContext &C, SourceLocation BeginLoc,
191 SourceLocation LParenLoc, Expr *IntExpr,
192 SourceLocation EndLoc) {
193 void *Mem = C.Allocate(sizeof(OpenACCVectorLengthClause),
194 alignof(OpenACCVectorLengthClause));
195 return new (Mem)
196 OpenACCVectorLengthClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
199 OpenACCAsyncClause::OpenACCAsyncClause(SourceLocation BeginLoc,
200 SourceLocation LParenLoc, Expr *IntExpr,
201 SourceLocation EndLoc)
202 : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Async, BeginLoc,
203 LParenLoc, IntExpr, EndLoc) {
204 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
205 IntExpr->getType()->isIntegerType()) &&
206 "Condition expression type not scalar/dependent");
209 OpenACCAsyncClause *OpenACCAsyncClause::Create(const ASTContext &C,
210 SourceLocation BeginLoc,
211 SourceLocation LParenLoc,
212 Expr *IntExpr,
213 SourceLocation EndLoc) {
214 void *Mem =
215 C.Allocate(sizeof(OpenACCAsyncClause), alignof(OpenACCAsyncClause));
216 return new (Mem) OpenACCAsyncClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
219 OpenACCWaitClause *OpenACCWaitClause::Create(
220 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
221 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
222 SourceLocation EndLoc) {
223 // Allocates enough room in trailing storage for all the int-exprs, plus a
224 // placeholder for the devnum.
225 void *Mem = C.Allocate(
226 OpenACCWaitClause::totalSizeToAlloc<Expr *>(QueueIdExprs.size() + 1));
227 return new (Mem) OpenACCWaitClause(BeginLoc, LParenLoc, DevNumExpr, QueuesLoc,
228 QueueIdExprs, EndLoc);
231 OpenACCNumGangsClause *OpenACCNumGangsClause::Create(const ASTContext &C,
232 SourceLocation BeginLoc,
233 SourceLocation LParenLoc,
234 ArrayRef<Expr *> IntExprs,
235 SourceLocation EndLoc) {
236 void *Mem = C.Allocate(
237 OpenACCNumGangsClause::totalSizeToAlloc<Expr *>(IntExprs.size()));
238 return new (Mem) OpenACCNumGangsClause(BeginLoc, LParenLoc, IntExprs, EndLoc);
241 OpenACCTileClause *OpenACCTileClause::Create(const ASTContext &C,
242 SourceLocation BeginLoc,
243 SourceLocation LParenLoc,
244 ArrayRef<Expr *> SizeExprs,
245 SourceLocation EndLoc) {
246 void *Mem =
247 C.Allocate(OpenACCTileClause::totalSizeToAlloc<Expr *>(SizeExprs.size()));
248 return new (Mem) OpenACCTileClause(BeginLoc, LParenLoc, SizeExprs, EndLoc);
251 OpenACCPrivateClause *OpenACCPrivateClause::Create(const ASTContext &C,
252 SourceLocation BeginLoc,
253 SourceLocation LParenLoc,
254 ArrayRef<Expr *> VarList,
255 SourceLocation EndLoc) {
256 void *Mem = C.Allocate(
257 OpenACCPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
258 return new (Mem) OpenACCPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
261 OpenACCFirstPrivateClause *OpenACCFirstPrivateClause::Create(
262 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
263 ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
264 void *Mem = C.Allocate(
265 OpenACCFirstPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
266 return new (Mem)
267 OpenACCFirstPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
270 OpenACCAttachClause *OpenACCAttachClause::Create(const ASTContext &C,
271 SourceLocation BeginLoc,
272 SourceLocation LParenLoc,
273 ArrayRef<Expr *> VarList,
274 SourceLocation EndLoc) {
275 void *Mem =
276 C.Allocate(OpenACCAttachClause::totalSizeToAlloc<Expr *>(VarList.size()));
277 return new (Mem) OpenACCAttachClause(BeginLoc, LParenLoc, VarList, EndLoc);
280 OpenACCDevicePtrClause *OpenACCDevicePtrClause::Create(const ASTContext &C,
281 SourceLocation BeginLoc,
282 SourceLocation LParenLoc,
283 ArrayRef<Expr *> VarList,
284 SourceLocation EndLoc) {
285 void *Mem = C.Allocate(
286 OpenACCDevicePtrClause::totalSizeToAlloc<Expr *>(VarList.size()));
287 return new (Mem) OpenACCDevicePtrClause(BeginLoc, LParenLoc, VarList, EndLoc);
290 OpenACCNoCreateClause *OpenACCNoCreateClause::Create(const ASTContext &C,
291 SourceLocation BeginLoc,
292 SourceLocation LParenLoc,
293 ArrayRef<Expr *> VarList,
294 SourceLocation EndLoc) {
295 void *Mem = C.Allocate(
296 OpenACCNoCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
297 return new (Mem) OpenACCNoCreateClause(BeginLoc, LParenLoc, VarList, EndLoc);
300 OpenACCPresentClause *OpenACCPresentClause::Create(const ASTContext &C,
301 SourceLocation BeginLoc,
302 SourceLocation LParenLoc,
303 ArrayRef<Expr *> VarList,
304 SourceLocation EndLoc) {
305 void *Mem = C.Allocate(
306 OpenACCPresentClause::totalSizeToAlloc<Expr *>(VarList.size()));
307 return new (Mem) OpenACCPresentClause(BeginLoc, LParenLoc, VarList, EndLoc);
310 OpenACCCopyClause *
311 OpenACCCopyClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
312 SourceLocation BeginLoc, SourceLocation LParenLoc,
313 ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
314 void *Mem =
315 C.Allocate(OpenACCCopyClause::totalSizeToAlloc<Expr *>(VarList.size()));
316 return new (Mem)
317 OpenACCCopyClause(Spelling, BeginLoc, LParenLoc, VarList, EndLoc);
320 OpenACCCopyInClause *
321 OpenACCCopyInClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
322 SourceLocation BeginLoc, SourceLocation LParenLoc,
323 bool IsReadOnly, ArrayRef<Expr *> VarList,
324 SourceLocation EndLoc) {
325 void *Mem =
326 C.Allocate(OpenACCCopyInClause::totalSizeToAlloc<Expr *>(VarList.size()));
327 return new (Mem) OpenACCCopyInClause(Spelling, BeginLoc, LParenLoc,
328 IsReadOnly, VarList, EndLoc);
331 OpenACCCopyOutClause *
332 OpenACCCopyOutClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
333 SourceLocation BeginLoc, SourceLocation LParenLoc,
334 bool IsZero, ArrayRef<Expr *> VarList,
335 SourceLocation EndLoc) {
336 void *Mem = C.Allocate(
337 OpenACCCopyOutClause::totalSizeToAlloc<Expr *>(VarList.size()));
338 return new (Mem) OpenACCCopyOutClause(Spelling, BeginLoc, LParenLoc, IsZero,
339 VarList, EndLoc);
342 OpenACCCreateClause *
343 OpenACCCreateClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
344 SourceLocation BeginLoc, SourceLocation LParenLoc,
345 bool IsZero, ArrayRef<Expr *> VarList,
346 SourceLocation EndLoc) {
347 void *Mem =
348 C.Allocate(OpenACCCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
349 return new (Mem) OpenACCCreateClause(Spelling, BeginLoc, LParenLoc, IsZero,
350 VarList, EndLoc);
353 OpenACCDeviceTypeClause *OpenACCDeviceTypeClause::Create(
354 const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc,
355 SourceLocation LParenLoc, ArrayRef<DeviceTypeArgument> Archs,
356 SourceLocation EndLoc) {
357 void *Mem =
358 C.Allocate(OpenACCDeviceTypeClause::totalSizeToAlloc<DeviceTypeArgument>(
359 Archs.size()));
360 return new (Mem)
361 OpenACCDeviceTypeClause(K, BeginLoc, LParenLoc, Archs, EndLoc);
364 OpenACCReductionClause *OpenACCReductionClause::Create(
365 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
366 OpenACCReductionOperator Operator, ArrayRef<Expr *> VarList,
367 SourceLocation EndLoc) {
368 void *Mem = C.Allocate(
369 OpenACCReductionClause::totalSizeToAlloc<Expr *>(VarList.size()));
370 return new (Mem)
371 OpenACCReductionClause(BeginLoc, LParenLoc, Operator, VarList, EndLoc);
374 OpenACCAutoClause *OpenACCAutoClause::Create(const ASTContext &C,
375 SourceLocation BeginLoc,
376 SourceLocation EndLoc) {
377 void *Mem = C.Allocate(sizeof(OpenACCAutoClause));
378 return new (Mem) OpenACCAutoClause(BeginLoc, EndLoc);
381 OpenACCIndependentClause *
382 OpenACCIndependentClause::Create(const ASTContext &C, SourceLocation BeginLoc,
383 SourceLocation EndLoc) {
384 void *Mem = C.Allocate(sizeof(OpenACCIndependentClause));
385 return new (Mem) OpenACCIndependentClause(BeginLoc, EndLoc);
388 OpenACCSeqClause *OpenACCSeqClause::Create(const ASTContext &C,
389 SourceLocation BeginLoc,
390 SourceLocation EndLoc) {
391 void *Mem = C.Allocate(sizeof(OpenACCSeqClause));
392 return new (Mem) OpenACCSeqClause(BeginLoc, EndLoc);
395 OpenACCGangClause *
396 OpenACCGangClause::Create(const ASTContext &C, SourceLocation BeginLoc,
397 SourceLocation LParenLoc,
398 ArrayRef<OpenACCGangKind> GangKinds,
399 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc) {
400 void *Mem =
401 C.Allocate(OpenACCGangClause::totalSizeToAlloc<Expr *, OpenACCGangKind>(
402 IntExprs.size(), GangKinds.size()));
403 return new (Mem)
404 OpenACCGangClause(BeginLoc, LParenLoc, GangKinds, IntExprs, EndLoc);
407 OpenACCWorkerClause::OpenACCWorkerClause(SourceLocation BeginLoc,
408 SourceLocation LParenLoc,
409 Expr *IntExpr, SourceLocation EndLoc)
410 : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Worker, BeginLoc,
411 LParenLoc, IntExpr, EndLoc) {
412 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
413 IntExpr->getType()->isIntegerType()) &&
414 "Int expression type not scalar/dependent");
417 OpenACCWorkerClause *OpenACCWorkerClause::Create(const ASTContext &C,
418 SourceLocation BeginLoc,
419 SourceLocation LParenLoc,
420 Expr *IntExpr,
421 SourceLocation EndLoc) {
422 void *Mem =
423 C.Allocate(sizeof(OpenACCWorkerClause), alignof(OpenACCWorkerClause));
424 return new (Mem) OpenACCWorkerClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
427 OpenACCVectorClause::OpenACCVectorClause(SourceLocation BeginLoc,
428 SourceLocation LParenLoc,
429 Expr *IntExpr, SourceLocation EndLoc)
430 : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Vector, BeginLoc,
431 LParenLoc, IntExpr, EndLoc) {
432 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
433 IntExpr->getType()->isIntegerType()) &&
434 "Int expression type not scalar/dependent");
437 OpenACCVectorClause *OpenACCVectorClause::Create(const ASTContext &C,
438 SourceLocation BeginLoc,
439 SourceLocation LParenLoc,
440 Expr *IntExpr,
441 SourceLocation EndLoc) {
442 void *Mem =
443 C.Allocate(sizeof(OpenACCVectorClause), alignof(OpenACCVectorClause));
444 return new (Mem) OpenACCVectorClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
447 //===----------------------------------------------------------------------===//
448 // OpenACC clauses printing methods
449 //===----------------------------------------------------------------------===//
451 void OpenACCClausePrinter::printExpr(const Expr *E) {
452 E->printPretty(OS, nullptr, Policy, 0);
455 void OpenACCClausePrinter::VisitDefaultClause(const OpenACCDefaultClause &C) {
456 OS << "default(" << C.getDefaultClauseKind() << ")";
459 void OpenACCClausePrinter::VisitIfClause(const OpenACCIfClause &C) {
460 OS << "if(";
461 printExpr(C.getConditionExpr());
462 OS << ")";
465 void OpenACCClausePrinter::VisitSelfClause(const OpenACCSelfClause &C) {
466 OS << "self";
467 if (const Expr *CondExpr = C.getConditionExpr()) {
468 OS << "(";
469 printExpr(CondExpr);
470 OS << ")";
474 void OpenACCClausePrinter::VisitNumGangsClause(const OpenACCNumGangsClause &C) {
475 OS << "num_gangs(";
476 llvm::interleaveComma(C.getIntExprs(), OS,
477 [&](const Expr *E) { printExpr(E); });
478 OS << ")";
481 void OpenACCClausePrinter::VisitTileClause(const OpenACCTileClause &C) {
482 OS << "tile(";
483 llvm::interleaveComma(C.getSizeExprs(), OS,
484 [&](const Expr *E) { printExpr(E); });
485 OS << ")";
488 void OpenACCClausePrinter::VisitNumWorkersClause(
489 const OpenACCNumWorkersClause &C) {
490 OS << "num_workers(";
491 printExpr(C.getIntExpr());
492 OS << ")";
495 void OpenACCClausePrinter::VisitVectorLengthClause(
496 const OpenACCVectorLengthClause &C) {
497 OS << "vector_length(";
498 printExpr(C.getIntExpr());
499 OS << ")";
502 void OpenACCClausePrinter::VisitAsyncClause(const OpenACCAsyncClause &C) {
503 OS << "async";
504 if (C.hasIntExpr()) {
505 OS << "(";
506 printExpr(C.getIntExpr());
507 OS << ")";
511 void OpenACCClausePrinter::VisitPrivateClause(const OpenACCPrivateClause &C) {
512 OS << "private(";
513 llvm::interleaveComma(C.getVarList(), OS,
514 [&](const Expr *E) { printExpr(E); });
515 OS << ")";
518 void OpenACCClausePrinter::VisitFirstPrivateClause(
519 const OpenACCFirstPrivateClause &C) {
520 OS << "firstprivate(";
521 llvm::interleaveComma(C.getVarList(), OS,
522 [&](const Expr *E) { printExpr(E); });
523 OS << ")";
526 void OpenACCClausePrinter::VisitAttachClause(const OpenACCAttachClause &C) {
527 OS << "attach(";
528 llvm::interleaveComma(C.getVarList(), OS,
529 [&](const Expr *E) { printExpr(E); });
530 OS << ")";
533 void OpenACCClausePrinter::VisitDevicePtrClause(
534 const OpenACCDevicePtrClause &C) {
535 OS << "deviceptr(";
536 llvm::interleaveComma(C.getVarList(), OS,
537 [&](const Expr *E) { printExpr(E); });
538 OS << ")";
541 void OpenACCClausePrinter::VisitNoCreateClause(const OpenACCNoCreateClause &C) {
542 OS << "no_create(";
543 llvm::interleaveComma(C.getVarList(), OS,
544 [&](const Expr *E) { printExpr(E); });
545 OS << ")";
548 void OpenACCClausePrinter::VisitPresentClause(const OpenACCPresentClause &C) {
549 OS << "present(";
550 llvm::interleaveComma(C.getVarList(), OS,
551 [&](const Expr *E) { printExpr(E); });
552 OS << ")";
555 void OpenACCClausePrinter::VisitCopyClause(const OpenACCCopyClause &C) {
556 OS << C.getClauseKind() << '(';
557 llvm::interleaveComma(C.getVarList(), OS,
558 [&](const Expr *E) { printExpr(E); });
559 OS << ")";
562 void OpenACCClausePrinter::VisitCopyInClause(const OpenACCCopyInClause &C) {
563 OS << C.getClauseKind() << '(';
564 if (C.isReadOnly())
565 OS << "readonly: ";
566 llvm::interleaveComma(C.getVarList(), OS,
567 [&](const Expr *E) { printExpr(E); });
568 OS << ")";
571 void OpenACCClausePrinter::VisitCopyOutClause(const OpenACCCopyOutClause &C) {
572 OS << C.getClauseKind() << '(';
573 if (C.isZero())
574 OS << "zero: ";
575 llvm::interleaveComma(C.getVarList(), OS,
576 [&](const Expr *E) { printExpr(E); });
577 OS << ")";
580 void OpenACCClausePrinter::VisitCreateClause(const OpenACCCreateClause &C) {
581 OS << C.getClauseKind() << '(';
582 if (C.isZero())
583 OS << "zero: ";
584 llvm::interleaveComma(C.getVarList(), OS,
585 [&](const Expr *E) { printExpr(E); });
586 OS << ")";
589 void OpenACCClausePrinter::VisitReductionClause(
590 const OpenACCReductionClause &C) {
591 OS << "reduction(" << C.getReductionOp() << ": ";
592 llvm::interleaveComma(C.getVarList(), OS,
593 [&](const Expr *E) { printExpr(E); });
594 OS << ")";
597 void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause &C) {
598 OS << "wait";
599 if (!C.getLParenLoc().isInvalid()) {
600 OS << "(";
601 if (C.hasDevNumExpr()) {
602 OS << "devnum: ";
603 printExpr(C.getDevNumExpr());
604 OS << " : ";
607 if (C.hasQueuesTag())
608 OS << "queues: ";
610 llvm::interleaveComma(C.getQueueIdExprs(), OS,
611 [&](const Expr *E) { printExpr(E); });
612 OS << ")";
616 void OpenACCClausePrinter::VisitDeviceTypeClause(
617 const OpenACCDeviceTypeClause &C) {
618 OS << C.getClauseKind();
619 OS << "(";
620 llvm::interleaveComma(C.getArchitectures(), OS,
621 [&](const DeviceTypeArgument &Arch) {
622 if (Arch.first == nullptr)
623 OS << "*";
624 else
625 OS << Arch.first->getName();
627 OS << ")";
630 void OpenACCClausePrinter::VisitAutoClause(const OpenACCAutoClause &C) {
631 OS << "auto";
634 void OpenACCClausePrinter::VisitIndependentClause(
635 const OpenACCIndependentClause &C) {
636 OS << "independent";
639 void OpenACCClausePrinter::VisitSeqClause(const OpenACCSeqClause &C) {
640 OS << "seq";
643 void OpenACCClausePrinter::VisitCollapseClause(const OpenACCCollapseClause &C) {
644 OS << "collapse(";
645 if (C.hasForce())
646 OS << "force:";
647 printExpr(C.getLoopCount());
648 OS << ")";
651 void OpenACCClausePrinter::VisitGangClause(const OpenACCGangClause &C) {
652 OS << "gang";
654 if (C.getNumExprs() > 0) {
655 OS << "(";
656 bool first = true;
657 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
658 if (!first)
659 OS << ", ";
660 first = false;
662 OS << C.getExpr(I).first << ": ";
663 printExpr(C.getExpr(I).second);
665 OS << ")";
669 void OpenACCClausePrinter::VisitWorkerClause(const OpenACCWorkerClause &C) {
670 OS << "worker";
672 if (C.hasIntExpr()) {
673 OS << "(num: ";
674 printExpr(C.getIntExpr());
675 OS << ")";
679 void OpenACCClausePrinter::VisitVectorClause(const OpenACCVectorClause &C) {
680 OS << "vector";
682 if (C.hasIntExpr()) {
683 OS << "(length: ";
684 printExpr(C.getIntExpr());
685 OS << ")";