clang 20.0.0git
OpenACCClause.cpp
Go to the documentation of this file.
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
11//
12//===----------------------------------------------------------------------===//
13
16#include "clang/AST/Expr.h"
17
18using namespace clang;
19
24}
30}
42}
45}
53}
56 SourceLocation BeginLoc,
57 SourceLocation LParenLoc,
58 SourceLocation EndLoc) {
59 void *Mem =
60 C.Allocate(sizeof(OpenACCDefaultClause), alignof(OpenACCDefaultClause));
61
62 return new (Mem) OpenACCDefaultClause(K, BeginLoc, LParenLoc, EndLoc);
63}
64
66 SourceLocation BeginLoc,
67 SourceLocation LParenLoc,
68 Expr *ConditionExpr,
69 SourceLocation EndLoc) {
70 void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
71 return new (Mem) OpenACCIfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
72}
73
75 SourceLocation LParenLoc, Expr *ConditionExpr,
76 SourceLocation EndLoc)
77 : OpenACCClauseWithCondition(OpenACCClauseKind::If, BeginLoc, LParenLoc,
78 ConditionExpr, EndLoc) {
79 assert(ConditionExpr && "if clause requires condition expr");
80 assert((ConditionExpr->isInstantiationDependent() ||
81 ConditionExpr->getType()->isScalarType()) &&
82 "Condition expression type not scalar/dependent");
83}
84
86 SourceLocation BeginLoc,
87 SourceLocation LParenLoc,
88 Expr *ConditionExpr,
89 SourceLocation EndLoc) {
90 void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
91 return new (Mem)
92 OpenACCSelfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
93}
94
95OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
96 SourceLocation LParenLoc,
97 Expr *ConditionExpr, SourceLocation EndLoc)
99 ConditionExpr, EndLoc) {
100 assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() ||
101 ConditionExpr->getType()->isScalarType()) &&
102 "Condition expression type not scalar/dependent");
103}
104
106 switch (getClauseKind()) {
107 default:
108 assert(false && "Clause children function not implemented");
109 break;
110#define VISIT_CLAUSE(CLAUSE_NAME) \
111 case OpenACCClauseKind::CLAUSE_NAME: \
112 return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
113#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED) \
114 case OpenACCClauseKind::ALIAS_NAME: \
115 return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
116
117#include "clang/Basic/OpenACCClauses.def"
118 }
120}
121
122OpenACCNumWorkersClause::OpenACCNumWorkersClause(SourceLocation BeginLoc,
123 SourceLocation LParenLoc,
124 Expr *IntExpr,
125 SourceLocation EndLoc)
127 LParenLoc, IntExpr, EndLoc) {
128 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
129 IntExpr->getType()->isIntegerType()) &&
130 "Condition expression type not scalar/dependent");
131}
132
134 SourceLocation LParenLoc,
136 ArrayRef<Expr *> IntExprs,
137 SourceLocation EndLoc)
138 : OpenACCClauseWithExprs(OpenACCClauseKind::Gang, BeginLoc, LParenLoc,
139 EndLoc) {
140 assert(GangKinds.size() == IntExprs.size() && "Mismatch exprs/kind?");
141 std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
142 getTrailingObjects<Expr *>());
143 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
144 std::uninitialized_copy(GangKinds.begin(), GangKinds.end(),
145 getTrailingObjects<OpenACCGangKind>());
146}
147
150 SourceLocation LParenLoc, Expr *IntExpr,
151 SourceLocation EndLoc) {
152 void *Mem = C.Allocate(sizeof(OpenACCNumWorkersClause),
153 alignof(OpenACCNumWorkersClause));
154 return new (Mem)
155 OpenACCNumWorkersClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
156}
157
158OpenACCCollapseClause::OpenACCCollapseClause(SourceLocation BeginLoc,
159 SourceLocation LParenLoc,
160 bool HasForce, Expr *LoopCount,
161 SourceLocation EndLoc)
163 LParenLoc, LoopCount, EndLoc),
164 HasForce(HasForce) {
165 assert(LoopCount && "LoopCount required");
166}
167
170 SourceLocation LParenLoc, bool HasForce,
171 Expr *LoopCount, SourceLocation EndLoc) {
172 assert(
173 LoopCount &&
174 (LoopCount->isInstantiationDependent() || isa<ConstantExpr>(LoopCount)) &&
175 "Loop count not constant expression");
176 void *Mem =
177 C.Allocate(sizeof(OpenACCCollapseClause), alignof(OpenACCCollapseClause));
178 return new (Mem)
179 OpenACCCollapseClause(BeginLoc, LParenLoc, HasForce, LoopCount, EndLoc);
180}
181
182OpenACCVectorLengthClause::OpenACCVectorLengthClause(SourceLocation BeginLoc,
183 SourceLocation LParenLoc,
184 Expr *IntExpr,
185 SourceLocation EndLoc)
187 LParenLoc, IntExpr, EndLoc) {
188 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
189 IntExpr->getType()->isIntegerType()) &&
190 "Condition expression type not scalar/dependent");
191}
192
195 SourceLocation LParenLoc, Expr *IntExpr,
196 SourceLocation EndLoc) {
197 void *Mem = C.Allocate(sizeof(OpenACCVectorLengthClause),
199 return new (Mem)
200 OpenACCVectorLengthClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
201}
202
203OpenACCAsyncClause::OpenACCAsyncClause(SourceLocation BeginLoc,
204 SourceLocation LParenLoc, Expr *IntExpr,
205 SourceLocation EndLoc)
207 LParenLoc, IntExpr, EndLoc) {
208 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
209 IntExpr->getType()->isIntegerType()) &&
210 "Condition expression type not scalar/dependent");
211}
212
214 SourceLocation BeginLoc,
215 SourceLocation LParenLoc,
216 Expr *IntExpr,
217 SourceLocation EndLoc) {
218 void *Mem =
219 C.Allocate(sizeof(OpenACCAsyncClause), alignof(OpenACCAsyncClause));
220 return new (Mem) OpenACCAsyncClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
221}
222
223OpenACCDeviceNumClause::OpenACCDeviceNumClause(SourceLocation BeginLoc,
224 SourceLocation LParenLoc, Expr *IntExpr,
225 SourceLocation EndLoc)
227 LParenLoc, IntExpr, EndLoc) {
228 assert((IntExpr->isInstantiationDependent() ||
229 IntExpr->getType()->isIntegerType()) &&
230 "device_num expression type not scalar/dependent");
231}
232
234 SourceLocation BeginLoc,
235 SourceLocation LParenLoc,
236 Expr *IntExpr,
237 SourceLocation EndLoc) {
238 void *Mem =
239 C.Allocate(sizeof(OpenACCDeviceNumClause), alignof(OpenACCDeviceNumClause));
240 return new (Mem) OpenACCDeviceNumClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
241}
242
243OpenACCDefaultAsyncClause::OpenACCDefaultAsyncClause(SourceLocation BeginLoc,
244 SourceLocation LParenLoc,
245 Expr *IntExpr,
246 SourceLocation EndLoc)
248 LParenLoc, IntExpr, EndLoc) {
249 assert((IntExpr->isInstantiationDependent() ||
250 IntExpr->getType()->isIntegerType()) &&
251 "default_async expression type not scalar/dependent");
252}
253
256 SourceLocation LParenLoc, Expr *IntExpr,
257 SourceLocation EndLoc) {
258 void *Mem = C.Allocate(sizeof(OpenACCDefaultAsyncClause),
260 return new (Mem)
261 OpenACCDefaultAsyncClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
262}
263
265 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
266 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
267 SourceLocation EndLoc) {
268 // Allocates enough room in trailing storage for all the int-exprs, plus a
269 // placeholder for the devnum.
270 void *Mem = C.Allocate(
271 OpenACCWaitClause::totalSizeToAlloc<Expr *>(QueueIdExprs.size() + 1));
272 return new (Mem) OpenACCWaitClause(BeginLoc, LParenLoc, DevNumExpr, QueuesLoc,
273 QueueIdExprs, EndLoc);
274}
275
277 SourceLocation BeginLoc,
278 SourceLocation LParenLoc,
279 ArrayRef<Expr *> IntExprs,
280 SourceLocation EndLoc) {
281 void *Mem = C.Allocate(
282 OpenACCNumGangsClause::totalSizeToAlloc<Expr *>(IntExprs.size()));
283 return new (Mem) OpenACCNumGangsClause(BeginLoc, LParenLoc, IntExprs, EndLoc);
284}
285
287 SourceLocation BeginLoc,
288 SourceLocation LParenLoc,
289 ArrayRef<Expr *> SizeExprs,
290 SourceLocation EndLoc) {
291 void *Mem =
292 C.Allocate(OpenACCTileClause::totalSizeToAlloc<Expr *>(SizeExprs.size()));
293 return new (Mem) OpenACCTileClause(BeginLoc, LParenLoc, SizeExprs, EndLoc);
294}
295
297 SourceLocation BeginLoc,
298 SourceLocation LParenLoc,
299 ArrayRef<Expr *> VarList,
300 SourceLocation EndLoc) {
301 void *Mem = C.Allocate(
302 OpenACCPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
303 return new (Mem) OpenACCPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
304}
305
307 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
308 ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
309 void *Mem = C.Allocate(
310 OpenACCFirstPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
311 return new (Mem)
312 OpenACCFirstPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
313}
314
316 SourceLocation BeginLoc,
317 SourceLocation LParenLoc,
318 ArrayRef<Expr *> VarList,
319 SourceLocation EndLoc) {
320 void *Mem =
321 C.Allocate(OpenACCAttachClause::totalSizeToAlloc<Expr *>(VarList.size()));
322 return new (Mem) OpenACCAttachClause(BeginLoc, LParenLoc, VarList, EndLoc);
323}
324
326 SourceLocation BeginLoc,
327 SourceLocation LParenLoc,
328 ArrayRef<Expr *> VarList,
329 SourceLocation EndLoc) {
330 void *Mem =
331 C.Allocate(OpenACCDetachClause::totalSizeToAlloc<Expr *>(VarList.size()));
332 return new (Mem) OpenACCDetachClause(BeginLoc, LParenLoc, VarList, EndLoc);
333}
334
336 SourceLocation BeginLoc,
337 SourceLocation LParenLoc,
338 ArrayRef<Expr *> VarList,
339 SourceLocation EndLoc) {
340 void *Mem =
341 C.Allocate(OpenACCDeleteClause::totalSizeToAlloc<Expr *>(VarList.size()));
342 return new (Mem) OpenACCDeleteClause(BeginLoc, LParenLoc, VarList, EndLoc);
343}
344
346 SourceLocation BeginLoc,
347 SourceLocation LParenLoc,
348 ArrayRef<Expr *> VarList,
349 SourceLocation EndLoc) {
350 void *Mem = C.Allocate(
351 OpenACCUseDeviceClause::totalSizeToAlloc<Expr *>(VarList.size()));
352 return new (Mem) OpenACCUseDeviceClause(BeginLoc, LParenLoc, VarList, EndLoc);
353}
354
356 SourceLocation BeginLoc,
357 SourceLocation LParenLoc,
358 ArrayRef<Expr *> VarList,
359 SourceLocation EndLoc) {
360 void *Mem = C.Allocate(
361 OpenACCDevicePtrClause::totalSizeToAlloc<Expr *>(VarList.size()));
362 return new (Mem) OpenACCDevicePtrClause(BeginLoc, LParenLoc, VarList, EndLoc);
363}
364
366 SourceLocation BeginLoc,
367 SourceLocation LParenLoc,
368 ArrayRef<Expr *> VarList,
369 SourceLocation EndLoc) {
370 void *Mem = C.Allocate(
371 OpenACCNoCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
372 return new (Mem) OpenACCNoCreateClause(BeginLoc, LParenLoc, VarList, EndLoc);
373}
374
376 SourceLocation BeginLoc,
377 SourceLocation LParenLoc,
378 ArrayRef<Expr *> VarList,
379 SourceLocation EndLoc) {
380 void *Mem = C.Allocate(
381 OpenACCPresentClause::totalSizeToAlloc<Expr *>(VarList.size()));
382 return new (Mem) OpenACCPresentClause(BeginLoc, LParenLoc, VarList, EndLoc);
383}
384
387 SourceLocation BeginLoc, SourceLocation LParenLoc,
388 ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
389 void *Mem =
390 C.Allocate(OpenACCCopyClause::totalSizeToAlloc<Expr *>(VarList.size()));
391 return new (Mem)
392 OpenACCCopyClause(Spelling, BeginLoc, LParenLoc, VarList, EndLoc);
393}
394
397 SourceLocation BeginLoc, SourceLocation LParenLoc,
398 bool IsReadOnly, ArrayRef<Expr *> VarList,
399 SourceLocation EndLoc) {
400 void *Mem =
401 C.Allocate(OpenACCCopyInClause::totalSizeToAlloc<Expr *>(VarList.size()));
402 return new (Mem) OpenACCCopyInClause(Spelling, BeginLoc, LParenLoc,
403 IsReadOnly, VarList, EndLoc);
404}
405
408 SourceLocation BeginLoc, SourceLocation LParenLoc,
409 bool IsZero, ArrayRef<Expr *> VarList,
410 SourceLocation EndLoc) {
411 void *Mem = C.Allocate(
412 OpenACCCopyOutClause::totalSizeToAlloc<Expr *>(VarList.size()));
413 return new (Mem) OpenACCCopyOutClause(Spelling, BeginLoc, LParenLoc, IsZero,
414 VarList, EndLoc);
415}
416
419 SourceLocation BeginLoc, SourceLocation LParenLoc,
420 bool IsZero, ArrayRef<Expr *> VarList,
421 SourceLocation EndLoc) {
422 void *Mem =
423 C.Allocate(OpenACCCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
424 return new (Mem) OpenACCCreateClause(Spelling, BeginLoc, LParenLoc, IsZero,
425 VarList, EndLoc);
426}
427
429 const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc,
431 SourceLocation EndLoc) {
432 void *Mem =
433 C.Allocate(OpenACCDeviceTypeClause::totalSizeToAlloc<DeviceTypeArgument>(
434 Archs.size()));
435 return new (Mem)
436 OpenACCDeviceTypeClause(K, BeginLoc, LParenLoc, Archs, EndLoc);
437}
438
440 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
442 SourceLocation EndLoc) {
443 void *Mem = C.Allocate(
444 OpenACCReductionClause::totalSizeToAlloc<Expr *>(VarList.size()));
445 return new (Mem)
446 OpenACCReductionClause(BeginLoc, LParenLoc, Operator, VarList, EndLoc);
447}
448
450 SourceLocation BeginLoc,
451 SourceLocation EndLoc) {
452 void *Mem = C.Allocate(sizeof(OpenACCAutoClause));
453 return new (Mem) OpenACCAutoClause(BeginLoc, EndLoc);
454}
455
458 SourceLocation EndLoc) {
459 void *Mem = C.Allocate(sizeof(OpenACCIndependentClause));
460 return new (Mem) OpenACCIndependentClause(BeginLoc, EndLoc);
461}
462
464 SourceLocation BeginLoc,
465 SourceLocation EndLoc) {
466 void *Mem = C.Allocate(sizeof(OpenACCSeqClause));
467 return new (Mem) OpenACCSeqClause(BeginLoc, EndLoc);
468}
469
472 SourceLocation LParenLoc,
474 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc) {
475 void *Mem =
476 C.Allocate(OpenACCGangClause::totalSizeToAlloc<Expr *, OpenACCGangKind>(
477 IntExprs.size(), GangKinds.size()));
478 return new (Mem)
479 OpenACCGangClause(BeginLoc, LParenLoc, GangKinds, IntExprs, EndLoc);
480}
481
483 SourceLocation LParenLoc,
484 Expr *IntExpr, SourceLocation EndLoc)
486 LParenLoc, IntExpr, EndLoc) {
487 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
488 IntExpr->getType()->isIntegerType()) &&
489 "Int expression type not scalar/dependent");
490}
491
493 SourceLocation BeginLoc,
494 SourceLocation LParenLoc,
495 Expr *IntExpr,
496 SourceLocation EndLoc) {
497 void *Mem =
498 C.Allocate(sizeof(OpenACCWorkerClause), alignof(OpenACCWorkerClause));
499 return new (Mem) OpenACCWorkerClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
500}
501
503 SourceLocation LParenLoc,
504 Expr *IntExpr, SourceLocation EndLoc)
506 LParenLoc, IntExpr, EndLoc) {
507 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
508 IntExpr->getType()->isIntegerType()) &&
509 "Int expression type not scalar/dependent");
510}
511
513 SourceLocation BeginLoc,
514 SourceLocation LParenLoc,
515 Expr *IntExpr,
516 SourceLocation EndLoc) {
517 void *Mem =
518 C.Allocate(sizeof(OpenACCVectorClause), alignof(OpenACCVectorClause));
519 return new (Mem) OpenACCVectorClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
520}
521
523 SourceLocation BeginLoc,
524 SourceLocation EndLoc) {
525 void *Mem =
526 C.Allocate(sizeof(OpenACCFinalizeClause), alignof(OpenACCFinalizeClause));
527 return new (Mem) OpenACCFinalizeClause(BeginLoc, EndLoc);
528}
529
531 SourceLocation BeginLoc,
532 SourceLocation EndLoc) {
533 void *Mem = C.Allocate(sizeof(OpenACCIfPresentClause),
534 alignof(OpenACCIfPresentClause));
535 return new (Mem) OpenACCIfPresentClause(BeginLoc, EndLoc);
536}
537
538//===----------------------------------------------------------------------===//
539// OpenACC clauses printing methods
540//===----------------------------------------------------------------------===//
541
542void OpenACCClausePrinter::printExpr(const Expr *E) {
543 E->printPretty(OS, nullptr, Policy, 0);
544}
545
546void OpenACCClausePrinter::VisitDefaultClause(const OpenACCDefaultClause &C) {
547 OS << "default(" << C.getDefaultClauseKind() << ")";
548}
549
550void OpenACCClausePrinter::VisitIfClause(const OpenACCIfClause &C) {
551 OS << "if(";
552 printExpr(C.getConditionExpr());
553 OS << ")";
554}
555
556void OpenACCClausePrinter::VisitSelfClause(const OpenACCSelfClause &C) {
557 OS << "self";
558 if (const Expr *CondExpr = C.getConditionExpr()) {
559 OS << "(";
560 printExpr(CondExpr);
561 OS << ")";
562 }
563}
564
565void OpenACCClausePrinter::VisitNumGangsClause(const OpenACCNumGangsClause &C) {
566 OS << "num_gangs(";
567 llvm::interleaveComma(C.getIntExprs(), OS,
568 [&](const Expr *E) { printExpr(E); });
569 OS << ")";
570}
571
572void OpenACCClausePrinter::VisitTileClause(const OpenACCTileClause &C) {
573 OS << "tile(";
574 llvm::interleaveComma(C.getSizeExprs(), OS,
575 [&](const Expr *E) { printExpr(E); });
576 OS << ")";
577}
578
579void OpenACCClausePrinter::VisitNumWorkersClause(
580 const OpenACCNumWorkersClause &C) {
581 OS << "num_workers(";
582 printExpr(C.getIntExpr());
583 OS << ")";
584}
585
586void OpenACCClausePrinter::VisitVectorLengthClause(
588 OS << "vector_length(";
589 printExpr(C.getIntExpr());
590 OS << ")";
591}
592
593void OpenACCClausePrinter::VisitDeviceNumClause(
594 const OpenACCDeviceNumClause &C) {
595 OS << "device_num(";
596 printExpr(C.getIntExpr());
597 OS << ")";
598}
599
600void OpenACCClausePrinter::VisitDefaultAsyncClause(
602 OS << "default_async(";
603 printExpr(C.getIntExpr());
604 OS << ")";
605}
606
607void OpenACCClausePrinter::VisitAsyncClause(const OpenACCAsyncClause &C) {
608 OS << "async";
609 if (C.hasIntExpr()) {
610 OS << "(";
611 printExpr(C.getIntExpr());
612 OS << ")";
613 }
614}
615
616void OpenACCClausePrinter::VisitPrivateClause(const OpenACCPrivateClause &C) {
617 OS << "private(";
618 llvm::interleaveComma(C.getVarList(), OS,
619 [&](const Expr *E) { printExpr(E); });
620 OS << ")";
621}
622
623void OpenACCClausePrinter::VisitFirstPrivateClause(
625 OS << "firstprivate(";
626 llvm::interleaveComma(C.getVarList(), OS,
627 [&](const Expr *E) { printExpr(E); });
628 OS << ")";
629}
630
631void OpenACCClausePrinter::VisitAttachClause(const OpenACCAttachClause &C) {
632 OS << "attach(";
633 llvm::interleaveComma(C.getVarList(), OS,
634 [&](const Expr *E) { printExpr(E); });
635 OS << ")";
636}
637
638void OpenACCClausePrinter::VisitDetachClause(const OpenACCDetachClause &C) {
639 OS << "detach(";
640 llvm::interleaveComma(C.getVarList(), OS,
641 [&](const Expr *E) { printExpr(E); });
642 OS << ")";
643}
644
645void OpenACCClausePrinter::VisitDeleteClause(const OpenACCDeleteClause &C) {
646 OS << "delete(";
647 llvm::interleaveComma(C.getVarList(), OS,
648 [&](const Expr *E) { printExpr(E); });
649 OS << ")";
650}
651
652void OpenACCClausePrinter::VisitUseDeviceClause(
653 const OpenACCUseDeviceClause &C) {
654 OS << "use_device(";
655 llvm::interleaveComma(C.getVarList(), OS,
656 [&](const Expr *E) { printExpr(E); });
657 OS << ")";
658}
659
660void OpenACCClausePrinter::VisitDevicePtrClause(
661 const OpenACCDevicePtrClause &C) {
662 OS << "deviceptr(";
663 llvm::interleaveComma(C.getVarList(), OS,
664 [&](const Expr *E) { printExpr(E); });
665 OS << ")";
666}
667
668void OpenACCClausePrinter::VisitNoCreateClause(const OpenACCNoCreateClause &C) {
669 OS << "no_create(";
670 llvm::interleaveComma(C.getVarList(), OS,
671 [&](const Expr *E) { printExpr(E); });
672 OS << ")";
673}
674
675void OpenACCClausePrinter::VisitPresentClause(const OpenACCPresentClause &C) {
676 OS << "present(";
677 llvm::interleaveComma(C.getVarList(), OS,
678 [&](const Expr *E) { printExpr(E); });
679 OS << ")";
680}
681
682void OpenACCClausePrinter::VisitCopyClause(const OpenACCCopyClause &C) {
683 OS << C.getClauseKind() << '(';
684 llvm::interleaveComma(C.getVarList(), OS,
685 [&](const Expr *E) { printExpr(E); });
686 OS << ")";
687}
688
689void OpenACCClausePrinter::VisitCopyInClause(const OpenACCCopyInClause &C) {
690 OS << C.getClauseKind() << '(';
691 if (C.isReadOnly())
692 OS << "readonly: ";
693 llvm::interleaveComma(C.getVarList(), OS,
694 [&](const Expr *E) { printExpr(E); });
695 OS << ")";
696}
697
698void OpenACCClausePrinter::VisitCopyOutClause(const OpenACCCopyOutClause &C) {
699 OS << C.getClauseKind() << '(';
700 if (C.isZero())
701 OS << "zero: ";
702 llvm::interleaveComma(C.getVarList(), OS,
703 [&](const Expr *E) { printExpr(E); });
704 OS << ")";
705}
706
707void OpenACCClausePrinter::VisitCreateClause(const OpenACCCreateClause &C) {
708 OS << C.getClauseKind() << '(';
709 if (C.isZero())
710 OS << "zero: ";
711 llvm::interleaveComma(C.getVarList(), OS,
712 [&](const Expr *E) { printExpr(E); });
713 OS << ")";
714}
715
716void OpenACCClausePrinter::VisitReductionClause(
717 const OpenACCReductionClause &C) {
718 OS << "reduction(" << C.getReductionOp() << ": ";
719 llvm::interleaveComma(C.getVarList(), OS,
720 [&](const Expr *E) { printExpr(E); });
721 OS << ")";
722}
723
724void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause &C) {
725 OS << "wait";
726 if (!C.getLParenLoc().isInvalid()) {
727 OS << "(";
728 if (C.hasDevNumExpr()) {
729 OS << "devnum: ";
730 printExpr(C.getDevNumExpr());
731 OS << " : ";
732 }
733
734 if (C.hasQueuesTag())
735 OS << "queues: ";
736
737 llvm::interleaveComma(C.getQueueIdExprs(), OS,
738 [&](const Expr *E) { printExpr(E); });
739 OS << ")";
740 }
741}
742
743void OpenACCClausePrinter::VisitDeviceTypeClause(
744 const OpenACCDeviceTypeClause &C) {
745 OS << C.getClauseKind();
746 OS << "(";
747 llvm::interleaveComma(C.getArchitectures(), OS,
748 [&](const DeviceTypeArgument &Arch) {
749 if (Arch.first == nullptr)
750 OS << "*";
751 else
752 OS << Arch.first->getName();
753 });
754 OS << ")";
755}
756
757void OpenACCClausePrinter::VisitAutoClause(const OpenACCAutoClause &C) {
758 OS << "auto";
759}
760
761void OpenACCClausePrinter::VisitIndependentClause(
763 OS << "independent";
764}
765
766void OpenACCClausePrinter::VisitSeqClause(const OpenACCSeqClause &C) {
767 OS << "seq";
768}
769
770void OpenACCClausePrinter::VisitCollapseClause(const OpenACCCollapseClause &C) {
771 OS << "collapse(";
772 if (C.hasForce())
773 OS << "force:";
774 printExpr(C.getLoopCount());
775 OS << ")";
776}
777
778void OpenACCClausePrinter::VisitGangClause(const OpenACCGangClause &C) {
779 OS << "gang";
780
781 if (C.getNumExprs() > 0) {
782 OS << "(";
783 bool first = true;
784 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
785 if (!first)
786 OS << ", ";
787 first = false;
788
789 OS << C.getExpr(I).first << ": ";
790 printExpr(C.getExpr(I).second);
791 }
792 OS << ")";
793 }
794}
795
796void OpenACCClausePrinter::VisitWorkerClause(const OpenACCWorkerClause &C) {
797 OS << "worker";
798
799 if (C.hasIntExpr()) {
800 OS << "(num: ";
801 printExpr(C.getIntExpr());
802 OS << ")";
803 }
804}
805
806void OpenACCClausePrinter::VisitVectorClause(const OpenACCVectorClause &C) {
807 OS << "vector";
808
809 if (C.hasIntExpr()) {
810 OS << "(length: ";
811 printExpr(C.getIntExpr());
812 OS << ")";
813 }
814}
815
816void OpenACCClausePrinter::VisitFinalizeClause(const OpenACCFinalizeClause &C) {
817 OS << "finalize";
818}
819
820void OpenACCClausePrinter::VisitIfPresentClause(
821 const OpenACCIfPresentClause &C) {
822 OS << "if_present";
823}
Defines the clang::ASTContext interface.
Expr * E
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
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
Definition: Expr.h:221
QualType getType() const
Definition: Expr.h:142
static bool classof(const OpenACCClause *C)
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
Represents one of the handful of classes that has an optional/required 'condition' expression as an a...
static bool classof(const OpenACCClause *C)
Represents a clause that has one or more expressions associated with it.
static bool classof(const OpenACCClause *C)
void setExprs(MutableArrayRef< Expr * > NewExprs)
Used only for initialization, the leaf class can initialize this to trailing storage.
static bool classof(const OpenACCClause *C)
Represents one of a handful of clauses that have a single integer expression.
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
This is the base type for all OpenACC Clauses.
Definition: OpenACCClause.h:24
child_range children()
StmtIterator child_iterator
Definition: OpenACCClause.h:43
OpenACCClauseKind getClauseKind() const
Definition: OpenACCClause.h:37
llvm::iterator_range< child_iterator > child_range
Definition: OpenACCClause.h:45
Represents a 'collapse' clause on a 'loop' construct.
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsReadOnly, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsZero, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsZero, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A 'default' clause, has the optional 'none' or 'present' argument.
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or an identifier.
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCGangClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< OpenACCGangKind > GangKinds, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
OpenACCGangClause(SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< OpenACCGangKind > GangKinds, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
An 'if' clause, which has a required condition expression.
OpenACCIfClause(SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCReductionClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, OpenACCReductionOperator Operator, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
A 'self' clause, which has an optional condition expression.
static bool classof(const OpenACCClause *C)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
OpenACCVectorClause(SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static bool classof(const OpenACCClause *C)
static bool classof(const OpenACCClause *C)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
OpenACCWorkerClause(SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
Encodes a location in the source.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Definition: Type.h:8550
bool isScalarType() const
Definition: Type.h:8609
The JSON file list parser is used to communicate input to InstallAPI.
OpenACCReductionOperator
Definition: OpenACCKinds.h:509
OpenACCClauseKind
Represents the kind of an OpenACC clause.
Definition: OpenACCKinds.h:178
@ Gang
'gang' clause, allowed on 'loop' and Combined constructs.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
@ Async
'async' clause, allowed on Compute, Data, 'update', 'wait', and Combined constructs.
@ Collapse
'collapse' clause, allowed on 'loop' and Combined constructs.
@ DeviceNum
'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
@ Vector
'vector' clause, allowed on 'loop', Combined, and 'routine' directives.
@ Worker
'worker' clause, allowed on 'loop', Combined, and 'routine' directives.
@ DefaultAsync
'default_async' clause, allowed on 'set' construct.
@ If
'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ NumWorkers
'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop', and 'kernels loop' constructs...
OpenACCDefaultClauseKind
Definition: OpenACCKinds.h:476
std::pair< IdentifierInfo *, SourceLocation > DeviceTypeArgument