1 //===---- OpenACCClause.cpp - Classes for OpenACC Clauses ----------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements the subclasses of the OpenACCClause class declared in
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
) {
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
,
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
,
85 SourceLocation EndLoc
) {
86 void *Mem
= C
.Allocate(sizeof(OpenACCIfClause
), alignof(OpenACCIfClause
));
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()) {
104 assert(false && "Clause children function not implemented");
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
,
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
,
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
));
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
),
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
) {
170 (LoopCount
->isInstantiationDependent() || isa
<ConstantExpr
>(LoopCount
)) &&
171 "Loop count not constant expression");
173 C
.Allocate(sizeof(OpenACCCollapseClause
), alignof(OpenACCCollapseClause
));
175 OpenACCCollapseClause(BeginLoc
, LParenLoc
, HasForce
, LoopCount
, EndLoc
);
178 OpenACCVectorLengthClause::OpenACCVectorLengthClause(SourceLocation BeginLoc
,
179 SourceLocation LParenLoc
,
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
));
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
,
213 SourceLocation EndLoc
) {
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
) {
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()));
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
) {
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
);
311 OpenACCCopyClause::Create(const ASTContext
&C
, OpenACCClauseKind Spelling
,
312 SourceLocation BeginLoc
, SourceLocation LParenLoc
,
313 ArrayRef
<Expr
*> VarList
, SourceLocation EndLoc
) {
315 C
.Allocate(OpenACCCopyClause::totalSizeToAlloc
<Expr
*>(VarList
.size()));
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
) {
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
,
342 OpenACCCreateClause
*
343 OpenACCCreateClause::Create(const ASTContext
&C
, OpenACCClauseKind Spelling
,
344 SourceLocation BeginLoc
, SourceLocation LParenLoc
,
345 bool IsZero
, ArrayRef
<Expr
*> VarList
,
346 SourceLocation EndLoc
) {
348 C
.Allocate(OpenACCCreateClause::totalSizeToAlloc
<Expr
*>(VarList
.size()));
349 return new (Mem
) OpenACCCreateClause(Spelling
, BeginLoc
, LParenLoc
, IsZero
,
353 OpenACCDeviceTypeClause
*OpenACCDeviceTypeClause::Create(
354 const ASTContext
&C
, OpenACCClauseKind K
, SourceLocation BeginLoc
,
355 SourceLocation LParenLoc
, ArrayRef
<DeviceTypeArgument
> Archs
,
356 SourceLocation EndLoc
) {
358 C
.Allocate(OpenACCDeviceTypeClause::totalSizeToAlloc
<DeviceTypeArgument
>(
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()));
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
);
396 OpenACCGangClause::Create(const ASTContext
&C
, SourceLocation BeginLoc
,
397 SourceLocation LParenLoc
,
398 ArrayRef
<OpenACCGangKind
> GangKinds
,
399 ArrayRef
<Expr
*> IntExprs
, SourceLocation EndLoc
) {
401 C
.Allocate(OpenACCGangClause::totalSizeToAlloc
<Expr
*, OpenACCGangKind
>(
402 IntExprs
.size(), GangKinds
.size()));
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
,
421 SourceLocation EndLoc
) {
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
,
441 SourceLocation EndLoc
) {
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
) {
461 printExpr(C
.getConditionExpr());
465 void OpenACCClausePrinter::VisitSelfClause(const OpenACCSelfClause
&C
) {
467 if (const Expr
*CondExpr
= C
.getConditionExpr()) {
474 void OpenACCClausePrinter::VisitNumGangsClause(const OpenACCNumGangsClause
&C
) {
476 llvm::interleaveComma(C
.getIntExprs(), OS
,
477 [&](const Expr
*E
) { printExpr(E
); });
481 void OpenACCClausePrinter::VisitTileClause(const OpenACCTileClause
&C
) {
483 llvm::interleaveComma(C
.getSizeExprs(), OS
,
484 [&](const Expr
*E
) { printExpr(E
); });
488 void OpenACCClausePrinter::VisitNumWorkersClause(
489 const OpenACCNumWorkersClause
&C
) {
490 OS
<< "num_workers(";
491 printExpr(C
.getIntExpr());
495 void OpenACCClausePrinter::VisitVectorLengthClause(
496 const OpenACCVectorLengthClause
&C
) {
497 OS
<< "vector_length(";
498 printExpr(C
.getIntExpr());
502 void OpenACCClausePrinter::VisitAsyncClause(const OpenACCAsyncClause
&C
) {
504 if (C
.hasIntExpr()) {
506 printExpr(C
.getIntExpr());
511 void OpenACCClausePrinter::VisitPrivateClause(const OpenACCPrivateClause
&C
) {
513 llvm::interleaveComma(C
.getVarList(), OS
,
514 [&](const Expr
*E
) { printExpr(E
); });
518 void OpenACCClausePrinter::VisitFirstPrivateClause(
519 const OpenACCFirstPrivateClause
&C
) {
520 OS
<< "firstprivate(";
521 llvm::interleaveComma(C
.getVarList(), OS
,
522 [&](const Expr
*E
) { printExpr(E
); });
526 void OpenACCClausePrinter::VisitAttachClause(const OpenACCAttachClause
&C
) {
528 llvm::interleaveComma(C
.getVarList(), OS
,
529 [&](const Expr
*E
) { printExpr(E
); });
533 void OpenACCClausePrinter::VisitDevicePtrClause(
534 const OpenACCDevicePtrClause
&C
) {
536 llvm::interleaveComma(C
.getVarList(), OS
,
537 [&](const Expr
*E
) { printExpr(E
); });
541 void OpenACCClausePrinter::VisitNoCreateClause(const OpenACCNoCreateClause
&C
) {
543 llvm::interleaveComma(C
.getVarList(), OS
,
544 [&](const Expr
*E
) { printExpr(E
); });
548 void OpenACCClausePrinter::VisitPresentClause(const OpenACCPresentClause
&C
) {
550 llvm::interleaveComma(C
.getVarList(), OS
,
551 [&](const Expr
*E
) { printExpr(E
); });
555 void OpenACCClausePrinter::VisitCopyClause(const OpenACCCopyClause
&C
) {
556 OS
<< C
.getClauseKind() << '(';
557 llvm::interleaveComma(C
.getVarList(), OS
,
558 [&](const Expr
*E
) { printExpr(E
); });
562 void OpenACCClausePrinter::VisitCopyInClause(const OpenACCCopyInClause
&C
) {
563 OS
<< C
.getClauseKind() << '(';
566 llvm::interleaveComma(C
.getVarList(), OS
,
567 [&](const Expr
*E
) { printExpr(E
); });
571 void OpenACCClausePrinter::VisitCopyOutClause(const OpenACCCopyOutClause
&C
) {
572 OS
<< C
.getClauseKind() << '(';
575 llvm::interleaveComma(C
.getVarList(), OS
,
576 [&](const Expr
*E
) { printExpr(E
); });
580 void OpenACCClausePrinter::VisitCreateClause(const OpenACCCreateClause
&C
) {
581 OS
<< C
.getClauseKind() << '(';
584 llvm::interleaveComma(C
.getVarList(), OS
,
585 [&](const Expr
*E
) { printExpr(E
); });
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
); });
597 void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause
&C
) {
599 if (!C
.getLParenLoc().isInvalid()) {
601 if (C
.hasDevNumExpr()) {
603 printExpr(C
.getDevNumExpr());
607 if (C
.hasQueuesTag())
610 llvm::interleaveComma(C
.getQueueIdExprs(), OS
,
611 [&](const Expr
*E
) { printExpr(E
); });
616 void OpenACCClausePrinter::VisitDeviceTypeClause(
617 const OpenACCDeviceTypeClause
&C
) {
618 OS
<< C
.getClauseKind();
620 llvm::interleaveComma(C
.getArchitectures(), OS
,
621 [&](const DeviceTypeArgument
&Arch
) {
622 if (Arch
.first
== nullptr)
625 OS
<< Arch
.first
->getName();
630 void OpenACCClausePrinter::VisitAutoClause(const OpenACCAutoClause
&C
) {
634 void OpenACCClausePrinter::VisitIndependentClause(
635 const OpenACCIndependentClause
&C
) {
639 void OpenACCClausePrinter::VisitSeqClause(const OpenACCSeqClause
&C
) {
643 void OpenACCClausePrinter::VisitCollapseClause(const OpenACCCollapseClause
&C
) {
647 printExpr(C
.getLoopCount());
651 void OpenACCClausePrinter::VisitGangClause(const OpenACCGangClause
&C
) {
654 if (C
.getNumExprs() > 0) {
657 for (unsigned I
= 0; I
< C
.getNumExprs(); ++I
) {
662 OS
<< C
.getExpr(I
).first
<< ": ";
663 printExpr(C
.getExpr(I
).second
);
669 void OpenACCClausePrinter::VisitWorkerClause(const OpenACCWorkerClause
&C
) {
672 if (C
.hasIntExpr()) {
674 printExpr(C
.getIntExpr());
679 void OpenACCClausePrinter::VisitVectorClause(const OpenACCVectorClause
&C
) {
682 if (C
.hasIntExpr()) {
684 printExpr(C
.getIntExpr());