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}
52}
55 SourceLocation BeginLoc,
56 SourceLocation LParenLoc,
57 SourceLocation EndLoc) {
58 void *Mem =
59 C.Allocate(sizeof(OpenACCDefaultClause), alignof(OpenACCDefaultClause));
60
61 return new (Mem) OpenACCDefaultClause(K, BeginLoc, LParenLoc, EndLoc);
62}
63
65 SourceLocation BeginLoc,
66 SourceLocation LParenLoc,
67 Expr *ConditionExpr,
68 SourceLocation EndLoc) {
69 void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
70 return new (Mem) OpenACCIfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
71}
72
74 SourceLocation LParenLoc, Expr *ConditionExpr,
75 SourceLocation EndLoc)
76 : OpenACCClauseWithCondition(OpenACCClauseKind::If, BeginLoc, LParenLoc,
77 ConditionExpr, EndLoc) {
78 assert(ConditionExpr && "if clause requires condition expr");
79 assert((ConditionExpr->isInstantiationDependent() ||
80 ConditionExpr->getType()->isScalarType()) &&
81 "Condition expression type not scalar/dependent");
82}
83
85 SourceLocation BeginLoc,
86 SourceLocation LParenLoc,
87 Expr *ConditionExpr,
88 SourceLocation EndLoc) {
89 void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
90 return new (Mem)
91 OpenACCSelfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
92}
93
94OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
95 SourceLocation LParenLoc,
96 Expr *ConditionExpr, SourceLocation EndLoc)
98 ConditionExpr, EndLoc) {
99 assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() ||
100 ConditionExpr->getType()->isScalarType()) &&
101 "Condition expression type not scalar/dependent");
102}
103
105 switch (getClauseKind()) {
106 default:
107 assert(false && "Clause children function not implemented");
108 break;
109#define VISIT_CLAUSE(CLAUSE_NAME) \
110 case OpenACCClauseKind::CLAUSE_NAME: \
111 return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
112#define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED) \
113 case OpenACCClauseKind::ALIAS_NAME: \
114 return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
115
116#include "clang/Basic/OpenACCClauses.def"
117 }
119}
120
121OpenACCNumWorkersClause::OpenACCNumWorkersClause(SourceLocation BeginLoc,
122 SourceLocation LParenLoc,
123 Expr *IntExpr,
124 SourceLocation EndLoc)
126 LParenLoc, IntExpr, EndLoc) {
127 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
128 IntExpr->getType()->isIntegerType()) &&
129 "Condition expression type not scalar/dependent");
130}
131
133 SourceLocation LParenLoc,
135 ArrayRef<Expr *> IntExprs,
136 SourceLocation EndLoc)
137 : OpenACCClauseWithExprs(OpenACCClauseKind::Gang, BeginLoc, LParenLoc,
138 EndLoc) {
139 assert(GangKinds.size() == IntExprs.size() && "Mismatch exprs/kind?");
140 std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
141 getTrailingObjects<Expr *>());
142 setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
143 std::uninitialized_copy(GangKinds.begin(), GangKinds.end(),
144 getTrailingObjects<OpenACCGangKind>());
145}
146
149 SourceLocation LParenLoc, Expr *IntExpr,
150 SourceLocation EndLoc) {
151 void *Mem = C.Allocate(sizeof(OpenACCNumWorkersClause),
152 alignof(OpenACCNumWorkersClause));
153 return new (Mem)
154 OpenACCNumWorkersClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
155}
156
157OpenACCCollapseClause::OpenACCCollapseClause(SourceLocation BeginLoc,
158 SourceLocation LParenLoc,
159 bool HasForce, Expr *LoopCount,
160 SourceLocation EndLoc)
162 LParenLoc, LoopCount, EndLoc),
163 HasForce(HasForce) {
164 assert(LoopCount && "LoopCount required");
165}
166
169 SourceLocation LParenLoc, bool HasForce,
170 Expr *LoopCount, SourceLocation EndLoc) {
171 assert(
172 LoopCount &&
173 (LoopCount->isInstantiationDependent() || isa<ConstantExpr>(LoopCount)) &&
174 "Loop count not constant expression");
175 void *Mem =
176 C.Allocate(sizeof(OpenACCCollapseClause), alignof(OpenACCCollapseClause));
177 return new (Mem)
178 OpenACCCollapseClause(BeginLoc, LParenLoc, HasForce, LoopCount, EndLoc);
179}
180
181OpenACCVectorLengthClause::OpenACCVectorLengthClause(SourceLocation BeginLoc,
182 SourceLocation LParenLoc,
183 Expr *IntExpr,
184 SourceLocation EndLoc)
186 LParenLoc, IntExpr, EndLoc) {
187 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
188 IntExpr->getType()->isIntegerType()) &&
189 "Condition expression type not scalar/dependent");
190}
191
194 SourceLocation LParenLoc, Expr *IntExpr,
195 SourceLocation EndLoc) {
196 void *Mem = C.Allocate(sizeof(OpenACCVectorLengthClause),
198 return new (Mem)
199 OpenACCVectorLengthClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
200}
201
202OpenACCAsyncClause::OpenACCAsyncClause(SourceLocation BeginLoc,
203 SourceLocation LParenLoc, Expr *IntExpr,
204 SourceLocation EndLoc)
206 LParenLoc, IntExpr, EndLoc) {
207 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
208 IntExpr->getType()->isIntegerType()) &&
209 "Condition expression type not scalar/dependent");
210}
211
213 SourceLocation BeginLoc,
214 SourceLocation LParenLoc,
215 Expr *IntExpr,
216 SourceLocation EndLoc) {
217 void *Mem =
218 C.Allocate(sizeof(OpenACCAsyncClause), alignof(OpenACCAsyncClause));
219 return new (Mem) OpenACCAsyncClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
220}
221
222OpenACCDeviceNumClause::OpenACCDeviceNumClause(SourceLocation BeginLoc,
223 SourceLocation LParenLoc, Expr *IntExpr,
224 SourceLocation EndLoc)
226 LParenLoc, IntExpr, EndLoc) {
227 assert((IntExpr->isInstantiationDependent() ||
228 IntExpr->getType()->isIntegerType()) &&
229 "device_num expression type not scalar/dependent");
230}
231
233 SourceLocation BeginLoc,
234 SourceLocation LParenLoc,
235 Expr *IntExpr,
236 SourceLocation EndLoc) {
237 void *Mem =
238 C.Allocate(sizeof(OpenACCDeviceNumClause), alignof(OpenACCDeviceNumClause));
239 return new (Mem) OpenACCDeviceNumClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
240}
241
243 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
244 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
245 SourceLocation EndLoc) {
246 // Allocates enough room in trailing storage for all the int-exprs, plus a
247 // placeholder for the devnum.
248 void *Mem = C.Allocate(
249 OpenACCWaitClause::totalSizeToAlloc<Expr *>(QueueIdExprs.size() + 1));
250 return new (Mem) OpenACCWaitClause(BeginLoc, LParenLoc, DevNumExpr, QueuesLoc,
251 QueueIdExprs, EndLoc);
252}
253
255 SourceLocation BeginLoc,
256 SourceLocation LParenLoc,
257 ArrayRef<Expr *> IntExprs,
258 SourceLocation EndLoc) {
259 void *Mem = C.Allocate(
260 OpenACCNumGangsClause::totalSizeToAlloc<Expr *>(IntExprs.size()));
261 return new (Mem) OpenACCNumGangsClause(BeginLoc, LParenLoc, IntExprs, EndLoc);
262}
263
265 SourceLocation BeginLoc,
266 SourceLocation LParenLoc,
267 ArrayRef<Expr *> SizeExprs,
268 SourceLocation EndLoc) {
269 void *Mem =
270 C.Allocate(OpenACCTileClause::totalSizeToAlloc<Expr *>(SizeExprs.size()));
271 return new (Mem) OpenACCTileClause(BeginLoc, LParenLoc, SizeExprs, EndLoc);
272}
273
275 SourceLocation BeginLoc,
276 SourceLocation LParenLoc,
277 ArrayRef<Expr *> VarList,
278 SourceLocation EndLoc) {
279 void *Mem = C.Allocate(
280 OpenACCPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
281 return new (Mem) OpenACCPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
282}
283
285 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
286 ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
287 void *Mem = C.Allocate(
288 OpenACCFirstPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
289 return new (Mem)
290 OpenACCFirstPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
291}
292
294 SourceLocation BeginLoc,
295 SourceLocation LParenLoc,
296 ArrayRef<Expr *> VarList,
297 SourceLocation EndLoc) {
298 void *Mem =
299 C.Allocate(OpenACCAttachClause::totalSizeToAlloc<Expr *>(VarList.size()));
300 return new (Mem) OpenACCAttachClause(BeginLoc, LParenLoc, VarList, EndLoc);
301}
302
304 SourceLocation BeginLoc,
305 SourceLocation LParenLoc,
306 ArrayRef<Expr *> VarList,
307 SourceLocation EndLoc) {
308 void *Mem =
309 C.Allocate(OpenACCDetachClause::totalSizeToAlloc<Expr *>(VarList.size()));
310 return new (Mem) OpenACCDetachClause(BeginLoc, LParenLoc, VarList, EndLoc);
311}
312
314 SourceLocation BeginLoc,
315 SourceLocation LParenLoc,
316 ArrayRef<Expr *> VarList,
317 SourceLocation EndLoc) {
318 void *Mem =
319 C.Allocate(OpenACCDeleteClause::totalSizeToAlloc<Expr *>(VarList.size()));
320 return new (Mem) OpenACCDeleteClause(BeginLoc, LParenLoc, VarList, EndLoc);
321}
322
324 SourceLocation BeginLoc,
325 SourceLocation LParenLoc,
326 ArrayRef<Expr *> VarList,
327 SourceLocation EndLoc) {
328 void *Mem = C.Allocate(
329 OpenACCUseDeviceClause::totalSizeToAlloc<Expr *>(VarList.size()));
330 return new (Mem) OpenACCUseDeviceClause(BeginLoc, LParenLoc, VarList, EndLoc);
331}
332
334 SourceLocation BeginLoc,
335 SourceLocation LParenLoc,
336 ArrayRef<Expr *> VarList,
337 SourceLocation EndLoc) {
338 void *Mem = C.Allocate(
339 OpenACCDevicePtrClause::totalSizeToAlloc<Expr *>(VarList.size()));
340 return new (Mem) OpenACCDevicePtrClause(BeginLoc, LParenLoc, VarList, EndLoc);
341}
342
344 SourceLocation BeginLoc,
345 SourceLocation LParenLoc,
346 ArrayRef<Expr *> VarList,
347 SourceLocation EndLoc) {
348 void *Mem = C.Allocate(
349 OpenACCNoCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
350 return new (Mem) OpenACCNoCreateClause(BeginLoc, LParenLoc, VarList, EndLoc);
351}
352
354 SourceLocation BeginLoc,
355 SourceLocation LParenLoc,
356 ArrayRef<Expr *> VarList,
357 SourceLocation EndLoc) {
358 void *Mem = C.Allocate(
359 OpenACCPresentClause::totalSizeToAlloc<Expr *>(VarList.size()));
360 return new (Mem) OpenACCPresentClause(BeginLoc, LParenLoc, VarList, EndLoc);
361}
362
365 SourceLocation BeginLoc, SourceLocation LParenLoc,
366 ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
367 void *Mem =
368 C.Allocate(OpenACCCopyClause::totalSizeToAlloc<Expr *>(VarList.size()));
369 return new (Mem)
370 OpenACCCopyClause(Spelling, BeginLoc, LParenLoc, VarList, EndLoc);
371}
372
375 SourceLocation BeginLoc, SourceLocation LParenLoc,
376 bool IsReadOnly, ArrayRef<Expr *> VarList,
377 SourceLocation EndLoc) {
378 void *Mem =
379 C.Allocate(OpenACCCopyInClause::totalSizeToAlloc<Expr *>(VarList.size()));
380 return new (Mem) OpenACCCopyInClause(Spelling, BeginLoc, LParenLoc,
381 IsReadOnly, VarList, EndLoc);
382}
383
386 SourceLocation BeginLoc, SourceLocation LParenLoc,
387 bool IsZero, ArrayRef<Expr *> VarList,
388 SourceLocation EndLoc) {
389 void *Mem = C.Allocate(
390 OpenACCCopyOutClause::totalSizeToAlloc<Expr *>(VarList.size()));
391 return new (Mem) OpenACCCopyOutClause(Spelling, BeginLoc, LParenLoc, IsZero,
392 VarList, EndLoc);
393}
394
397 SourceLocation BeginLoc, SourceLocation LParenLoc,
398 bool IsZero, ArrayRef<Expr *> VarList,
399 SourceLocation EndLoc) {
400 void *Mem =
401 C.Allocate(OpenACCCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
402 return new (Mem) OpenACCCreateClause(Spelling, BeginLoc, LParenLoc, IsZero,
403 VarList, EndLoc);
404}
405
407 const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc,
409 SourceLocation EndLoc) {
410 void *Mem =
411 C.Allocate(OpenACCDeviceTypeClause::totalSizeToAlloc<DeviceTypeArgument>(
412 Archs.size()));
413 return new (Mem)
414 OpenACCDeviceTypeClause(K, BeginLoc, LParenLoc, Archs, EndLoc);
415}
416
418 const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
420 SourceLocation EndLoc) {
421 void *Mem = C.Allocate(
422 OpenACCReductionClause::totalSizeToAlloc<Expr *>(VarList.size()));
423 return new (Mem)
424 OpenACCReductionClause(BeginLoc, LParenLoc, Operator, VarList, EndLoc);
425}
426
428 SourceLocation BeginLoc,
429 SourceLocation EndLoc) {
430 void *Mem = C.Allocate(sizeof(OpenACCAutoClause));
431 return new (Mem) OpenACCAutoClause(BeginLoc, EndLoc);
432}
433
436 SourceLocation EndLoc) {
437 void *Mem = C.Allocate(sizeof(OpenACCIndependentClause));
438 return new (Mem) OpenACCIndependentClause(BeginLoc, EndLoc);
439}
440
442 SourceLocation BeginLoc,
443 SourceLocation EndLoc) {
444 void *Mem = C.Allocate(sizeof(OpenACCSeqClause));
445 return new (Mem) OpenACCSeqClause(BeginLoc, EndLoc);
446}
447
450 SourceLocation LParenLoc,
452 ArrayRef<Expr *> IntExprs, SourceLocation EndLoc) {
453 void *Mem =
454 C.Allocate(OpenACCGangClause::totalSizeToAlloc<Expr *, OpenACCGangKind>(
455 IntExprs.size(), GangKinds.size()));
456 return new (Mem)
457 OpenACCGangClause(BeginLoc, LParenLoc, GangKinds, IntExprs, EndLoc);
458}
459
461 SourceLocation LParenLoc,
462 Expr *IntExpr, SourceLocation EndLoc)
464 LParenLoc, IntExpr, EndLoc) {
465 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
466 IntExpr->getType()->isIntegerType()) &&
467 "Int expression type not scalar/dependent");
468}
469
471 SourceLocation BeginLoc,
472 SourceLocation LParenLoc,
473 Expr *IntExpr,
474 SourceLocation EndLoc) {
475 void *Mem =
476 C.Allocate(sizeof(OpenACCWorkerClause), alignof(OpenACCWorkerClause));
477 return new (Mem) OpenACCWorkerClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
478}
479
481 SourceLocation LParenLoc,
482 Expr *IntExpr, SourceLocation EndLoc)
484 LParenLoc, IntExpr, EndLoc) {
485 assert((!IntExpr || IntExpr->isInstantiationDependent() ||
486 IntExpr->getType()->isIntegerType()) &&
487 "Int expression type not scalar/dependent");
488}
489
491 SourceLocation BeginLoc,
492 SourceLocation LParenLoc,
493 Expr *IntExpr,
494 SourceLocation EndLoc) {
495 void *Mem =
496 C.Allocate(sizeof(OpenACCVectorClause), alignof(OpenACCVectorClause));
497 return new (Mem) OpenACCVectorClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
498}
499
501 SourceLocation BeginLoc,
502 SourceLocation EndLoc) {
503 void *Mem =
504 C.Allocate(sizeof(OpenACCFinalizeClause), alignof(OpenACCFinalizeClause));
505 return new (Mem) OpenACCFinalizeClause(BeginLoc, EndLoc);
506}
507
509 SourceLocation BeginLoc,
510 SourceLocation EndLoc) {
511 void *Mem = C.Allocate(sizeof(OpenACCIfPresentClause),
512 alignof(OpenACCIfPresentClause));
513 return new (Mem) OpenACCIfPresentClause(BeginLoc, EndLoc);
514}
515
516//===----------------------------------------------------------------------===//
517// OpenACC clauses printing methods
518//===----------------------------------------------------------------------===//
519
520void OpenACCClausePrinter::printExpr(const Expr *E) {
521 E->printPretty(OS, nullptr, Policy, 0);
522}
523
524void OpenACCClausePrinter::VisitDefaultClause(const OpenACCDefaultClause &C) {
525 OS << "default(" << C.getDefaultClauseKind() << ")";
526}
527
528void OpenACCClausePrinter::VisitIfClause(const OpenACCIfClause &C) {
529 OS << "if(";
530 printExpr(C.getConditionExpr());
531 OS << ")";
532}
533
534void OpenACCClausePrinter::VisitSelfClause(const OpenACCSelfClause &C) {
535 OS << "self";
536 if (const Expr *CondExpr = C.getConditionExpr()) {
537 OS << "(";
538 printExpr(CondExpr);
539 OS << ")";
540 }
541}
542
543void OpenACCClausePrinter::VisitNumGangsClause(const OpenACCNumGangsClause &C) {
544 OS << "num_gangs(";
545 llvm::interleaveComma(C.getIntExprs(), OS,
546 [&](const Expr *E) { printExpr(E); });
547 OS << ")";
548}
549
550void OpenACCClausePrinter::VisitTileClause(const OpenACCTileClause &C) {
551 OS << "tile(";
552 llvm::interleaveComma(C.getSizeExprs(), OS,
553 [&](const Expr *E) { printExpr(E); });
554 OS << ")";
555}
556
557void OpenACCClausePrinter::VisitNumWorkersClause(
558 const OpenACCNumWorkersClause &C) {
559 OS << "num_workers(";
560 printExpr(C.getIntExpr());
561 OS << ")";
562}
563
564void OpenACCClausePrinter::VisitVectorLengthClause(
566 OS << "vector_length(";
567 printExpr(C.getIntExpr());
568 OS << ")";
569}
570
571void OpenACCClausePrinter::VisitDeviceNumClause(
572 const OpenACCDeviceNumClause &C) {
573 OS << "device_num(";
574 printExpr(C.getIntExpr());
575 OS << ")";
576}
577
578void OpenACCClausePrinter::VisitAsyncClause(const OpenACCAsyncClause &C) {
579 OS << "async";
580 if (C.hasIntExpr()) {
581 OS << "(";
582 printExpr(C.getIntExpr());
583 OS << ")";
584 }
585}
586
587void OpenACCClausePrinter::VisitPrivateClause(const OpenACCPrivateClause &C) {
588 OS << "private(";
589 llvm::interleaveComma(C.getVarList(), OS,
590 [&](const Expr *E) { printExpr(E); });
591 OS << ")";
592}
593
594void OpenACCClausePrinter::VisitFirstPrivateClause(
596 OS << "firstprivate(";
597 llvm::interleaveComma(C.getVarList(), OS,
598 [&](const Expr *E) { printExpr(E); });
599 OS << ")";
600}
601
602void OpenACCClausePrinter::VisitAttachClause(const OpenACCAttachClause &C) {
603 OS << "attach(";
604 llvm::interleaveComma(C.getVarList(), OS,
605 [&](const Expr *E) { printExpr(E); });
606 OS << ")";
607}
608
609void OpenACCClausePrinter::VisitDetachClause(const OpenACCDetachClause &C) {
610 OS << "detach(";
611 llvm::interleaveComma(C.getVarList(), OS,
612 [&](const Expr *E) { printExpr(E); });
613 OS << ")";
614}
615
616void OpenACCClausePrinter::VisitDeleteClause(const OpenACCDeleteClause &C) {
617 OS << "delete(";
618 llvm::interleaveComma(C.getVarList(), OS,
619 [&](const Expr *E) { printExpr(E); });
620 OS << ")";
621}
622
623void OpenACCClausePrinter::VisitUseDeviceClause(
624 const OpenACCUseDeviceClause &C) {
625 OS << "use_device(";
626 llvm::interleaveComma(C.getVarList(), OS,
627 [&](const Expr *E) { printExpr(E); });
628 OS << ")";
629}
630
631void OpenACCClausePrinter::VisitDevicePtrClause(
632 const OpenACCDevicePtrClause &C) {
633 OS << "deviceptr(";
634 llvm::interleaveComma(C.getVarList(), OS,
635 [&](const Expr *E) { printExpr(E); });
636 OS << ")";
637}
638
639void OpenACCClausePrinter::VisitNoCreateClause(const OpenACCNoCreateClause &C) {
640 OS << "no_create(";
641 llvm::interleaveComma(C.getVarList(), OS,
642 [&](const Expr *E) { printExpr(E); });
643 OS << ")";
644}
645
646void OpenACCClausePrinter::VisitPresentClause(const OpenACCPresentClause &C) {
647 OS << "present(";
648 llvm::interleaveComma(C.getVarList(), OS,
649 [&](const Expr *E) { printExpr(E); });
650 OS << ")";
651}
652
653void OpenACCClausePrinter::VisitCopyClause(const OpenACCCopyClause &C) {
654 OS << C.getClauseKind() << '(';
655 llvm::interleaveComma(C.getVarList(), OS,
656 [&](const Expr *E) { printExpr(E); });
657 OS << ")";
658}
659
660void OpenACCClausePrinter::VisitCopyInClause(const OpenACCCopyInClause &C) {
661 OS << C.getClauseKind() << '(';
662 if (C.isReadOnly())
663 OS << "readonly: ";
664 llvm::interleaveComma(C.getVarList(), OS,
665 [&](const Expr *E) { printExpr(E); });
666 OS << ")";
667}
668
669void OpenACCClausePrinter::VisitCopyOutClause(const OpenACCCopyOutClause &C) {
670 OS << C.getClauseKind() << '(';
671 if (C.isZero())
672 OS << "zero: ";
673 llvm::interleaveComma(C.getVarList(), OS,
674 [&](const Expr *E) { printExpr(E); });
675 OS << ")";
676}
677
678void OpenACCClausePrinter::VisitCreateClause(const OpenACCCreateClause &C) {
679 OS << C.getClauseKind() << '(';
680 if (C.isZero())
681 OS << "zero: ";
682 llvm::interleaveComma(C.getVarList(), OS,
683 [&](const Expr *E) { printExpr(E); });
684 OS << ")";
685}
686
687void OpenACCClausePrinter::VisitReductionClause(
688 const OpenACCReductionClause &C) {
689 OS << "reduction(" << C.getReductionOp() << ": ";
690 llvm::interleaveComma(C.getVarList(), OS,
691 [&](const Expr *E) { printExpr(E); });
692 OS << ")";
693}
694
695void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause &C) {
696 OS << "wait";
697 if (!C.getLParenLoc().isInvalid()) {
698 OS << "(";
699 if (C.hasDevNumExpr()) {
700 OS << "devnum: ";
701 printExpr(C.getDevNumExpr());
702 OS << " : ";
703 }
704
705 if (C.hasQueuesTag())
706 OS << "queues: ";
707
708 llvm::interleaveComma(C.getQueueIdExprs(), OS,
709 [&](const Expr *E) { printExpr(E); });
710 OS << ")";
711 }
712}
713
714void OpenACCClausePrinter::VisitDeviceTypeClause(
715 const OpenACCDeviceTypeClause &C) {
716 OS << C.getClauseKind();
717 OS << "(";
718 llvm::interleaveComma(C.getArchitectures(), OS,
719 [&](const DeviceTypeArgument &Arch) {
720 if (Arch.first == nullptr)
721 OS << "*";
722 else
723 OS << Arch.first->getName();
724 });
725 OS << ")";
726}
727
728void OpenACCClausePrinter::VisitAutoClause(const OpenACCAutoClause &C) {
729 OS << "auto";
730}
731
732void OpenACCClausePrinter::VisitIndependentClause(
734 OS << "independent";
735}
736
737void OpenACCClausePrinter::VisitSeqClause(const OpenACCSeqClause &C) {
738 OS << "seq";
739}
740
741void OpenACCClausePrinter::VisitCollapseClause(const OpenACCCollapseClause &C) {
742 OS << "collapse(";
743 if (C.hasForce())
744 OS << "force:";
745 printExpr(C.getLoopCount());
746 OS << ")";
747}
748
749void OpenACCClausePrinter::VisitGangClause(const OpenACCGangClause &C) {
750 OS << "gang";
751
752 if (C.getNumExprs() > 0) {
753 OS << "(";
754 bool first = true;
755 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
756 if (!first)
757 OS << ", ";
758 first = false;
759
760 OS << C.getExpr(I).first << ": ";
761 printExpr(C.getExpr(I).second);
762 }
763 OS << ")";
764 }
765}
766
767void OpenACCClausePrinter::VisitWorkerClause(const OpenACCWorkerClause &C) {
768 OS << "worker";
769
770 if (C.hasIntExpr()) {
771 OS << "(num: ";
772 printExpr(C.getIntExpr());
773 OS << ")";
774 }
775}
776
777void OpenACCClausePrinter::VisitVectorClause(const OpenACCVectorClause &C) {
778 OS << "vector";
779
780 if (C.hasIntExpr()) {
781 OS << "(length: ";
782 printExpr(C.getIntExpr());
783 OS << ")";
784 }
785}
786
787void OpenACCClausePrinter::VisitFinalizeClause(const OpenACCFinalizeClause &C) {
788 OS << "finalize";
789}
790
791void OpenACCClausePrinter::VisitIfPresentClause(
792 const OpenACCIfPresentClause &C) {
793 OS << "if_present";
794}
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)
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.
@ 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