xref: /llvm-project/clang/lib/AST/OpenACCClause.cpp (revision be32621ce8cbffe674c62e87c0c51c9fc4a21e5f)
130f6eafaSErich Keane //===---- OpenACCClause.cpp - Classes for OpenACC Clauses  ----------------===//
230f6eafaSErich Keane //
330f6eafaSErich Keane // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
430f6eafaSErich Keane // See https://llvm.org/LICENSE.txt for license information.
530f6eafaSErich Keane // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
630f6eafaSErich Keane //
730f6eafaSErich Keane //===----------------------------------------------------------------------===//
830f6eafaSErich Keane //
930f6eafaSErich Keane // This file implements the subclasses of the OpenACCClause class declared in
1030f6eafaSErich Keane // OpenACCClause.h
1130f6eafaSErich Keane //
1230f6eafaSErich Keane //===----------------------------------------------------------------------===//
1330f6eafaSErich Keane 
1430f6eafaSErich Keane #include "clang/AST/OpenACCClause.h"
1530f6eafaSErich Keane #include "clang/AST/ASTContext.h"
16daa88364SErich Keane #include "clang/AST/Expr.h"
1730f6eafaSErich Keane 
1830f6eafaSErich Keane using namespace clang;
190c7b92a4SErich Keane 
2063177422Serichkeane bool OpenACCClauseWithParams::classof(const OpenACCClause *C) {
218ef2011bSerichkeane   return OpenACCDeviceTypeClause::classof(C) ||
228ef2011bSerichkeane          OpenACCClauseWithCondition::classof(C) ||
232c2accbcSerichkeane          OpenACCClauseWithExprs::classof(C) || OpenACCSelfClause::classof(C);
2463177422Serichkeane }
2563177422Serichkeane bool OpenACCClauseWithExprs::classof(const OpenACCClause *C) {
2663177422Serichkeane   return OpenACCWaitClause::classof(C) || OpenACCNumGangsClause::classof(C) ||
27d412cea8SErich Keane          OpenACCTileClause::classof(C) ||
2863177422Serichkeane          OpenACCClauseWithSingleIntExpr::classof(C) ||
295b25c313SErich Keane          OpenACCGangClause::classof(C) || OpenACCClauseWithVarList::classof(C);
3063177422Serichkeane }
3163177422Serichkeane bool OpenACCClauseWithVarList::classof(const OpenACCClause *C) {
3263177422Serichkeane   return OpenACCPrivateClause::classof(C) ||
3363177422Serichkeane          OpenACCFirstPrivateClause::classof(C) ||
3463177422Serichkeane          OpenACCDevicePtrClause::classof(C) ||
351ab81f8eSerichkeane          OpenACCDeleteClause::classof(C) ||
36fbb14dd9Serichkeane          OpenACCUseDeviceClause::classof(C) ||
373351b3bfSerichkeane          OpenACCDetachClause::classof(C) || OpenACCAttachClause::classof(C) ||
383351b3bfSerichkeane          OpenACCNoCreateClause::classof(C) ||
3963177422Serichkeane          OpenACCPresentClause::classof(C) || OpenACCCopyClause::classof(C) ||
4063177422Serichkeane          OpenACCCopyInClause::classof(C) || OpenACCCopyOutClause::classof(C) ||
41*be32621cSerichkeane          OpenACCReductionClause::classof(C) ||
42*be32621cSerichkeane          OpenACCCreateClause::classof(C) || OpenACCDeviceClause::classof(C) ||
43*be32621cSerichkeane          OpenACCHostClause::classof(C);
4463177422Serichkeane }
4563177422Serichkeane bool OpenACCClauseWithCondition::classof(const OpenACCClause *C) {
462c2accbcSerichkeane   return OpenACCIfClause::classof(C);
4763177422Serichkeane }
4863177422Serichkeane bool OpenACCClauseWithSingleIntExpr::classof(const OpenACCClause *C) {
4963177422Serichkeane   return OpenACCNumWorkersClause::classof(C) ||
5063177422Serichkeane          OpenACCVectorLengthClause::classof(C) ||
51bdf25553Serichkeane          OpenACCDeviceNumClause::classof(C) ||
52ff24e9a1Serichkeane          OpenACCDefaultAsyncClause::classof(C) ||
53c8cbdc65SErich Keane          OpenACCVectorClause::classof(C) || OpenACCWorkerClause::classof(C) ||
54c8cbdc65SErich Keane          OpenACCCollapseClause::classof(C) || OpenACCAsyncClause::classof(C);
5563177422Serichkeane }
560c7b92a4SErich Keane OpenACCDefaultClause *OpenACCDefaultClause::Create(const ASTContext &C,
570c7b92a4SErich Keane                                                    OpenACCDefaultClauseKind K,
580c7b92a4SErich Keane                                                    SourceLocation BeginLoc,
590c7b92a4SErich Keane                                                    SourceLocation LParenLoc,
600c7b92a4SErich Keane                                                    SourceLocation EndLoc) {
610c7b92a4SErich Keane   void *Mem =
620c7b92a4SErich Keane       C.Allocate(sizeof(OpenACCDefaultClause), alignof(OpenACCDefaultClause));
630c7b92a4SErich Keane 
640c7b92a4SErich Keane   return new (Mem) OpenACCDefaultClause(K, BeginLoc, LParenLoc, EndLoc);
650c7b92a4SErich Keane }
660c7b92a4SErich Keane 
67daa88364SErich Keane OpenACCIfClause *OpenACCIfClause::Create(const ASTContext &C,
68daa88364SErich Keane                                          SourceLocation BeginLoc,
69daa88364SErich Keane                                          SourceLocation LParenLoc,
70daa88364SErich Keane                                          Expr *ConditionExpr,
71daa88364SErich Keane                                          SourceLocation EndLoc) {
72daa88364SErich Keane   void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause));
73daa88364SErich Keane   return new (Mem) OpenACCIfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
74daa88364SErich Keane }
75daa88364SErich Keane 
76daa88364SErich Keane OpenACCIfClause::OpenACCIfClause(SourceLocation BeginLoc,
77daa88364SErich Keane                                  SourceLocation LParenLoc, Expr *ConditionExpr,
78daa88364SErich Keane                                  SourceLocation EndLoc)
79daa88364SErich Keane     : OpenACCClauseWithCondition(OpenACCClauseKind::If, BeginLoc, LParenLoc,
80daa88364SErich Keane                                  ConditionExpr, EndLoc) {
81daa88364SErich Keane   assert(ConditionExpr && "if clause requires condition expr");
82daa88364SErich Keane   assert((ConditionExpr->isInstantiationDependent() ||
83daa88364SErich Keane           ConditionExpr->getType()->isScalarType()) &&
84daa88364SErich Keane          "Condition expression type not scalar/dependent");
85daa88364SErich Keane }
86daa88364SErich Keane 
8761338782SErich Keane OpenACCSelfClause *OpenACCSelfClause::Create(const ASTContext &C,
8861338782SErich Keane                                              SourceLocation BeginLoc,
8961338782SErich Keane                                              SourceLocation LParenLoc,
9061338782SErich Keane                                              Expr *ConditionExpr,
9161338782SErich Keane                                              SourceLocation EndLoc) {
922c2accbcSerichkeane   void *Mem = C.Allocate(OpenACCSelfClause::totalSizeToAlloc<Expr *>(1));
9361338782SErich Keane   return new (Mem)
9461338782SErich Keane       OpenACCSelfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc);
9561338782SErich Keane }
9661338782SErich Keane 
972c2accbcSerichkeane OpenACCSelfClause *OpenACCSelfClause::Create(const ASTContext &C,
982c2accbcSerichkeane                                              SourceLocation BeginLoc,
992c2accbcSerichkeane                                              SourceLocation LParenLoc,
1002c2accbcSerichkeane                                              ArrayRef<Expr *> VarList,
1012c2accbcSerichkeane                                              SourceLocation EndLoc) {
1022c2accbcSerichkeane   void *Mem =
1032c2accbcSerichkeane       C.Allocate(OpenACCSelfClause::totalSizeToAlloc<Expr *>(VarList.size()));
1042c2accbcSerichkeane   return new (Mem) OpenACCSelfClause(BeginLoc, LParenLoc, VarList, EndLoc);
1052c2accbcSerichkeane }
1062c2accbcSerichkeane 
1072c2accbcSerichkeane OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
1082c2accbcSerichkeane                                      SourceLocation LParenLoc,
1092c2accbcSerichkeane                                      llvm::ArrayRef<Expr *> VarList,
1102c2accbcSerichkeane                                      SourceLocation EndLoc)
1112c2accbcSerichkeane     : OpenACCClauseWithParams(OpenACCClauseKind::Self, BeginLoc, LParenLoc,
1122c2accbcSerichkeane                               EndLoc),
1132c2accbcSerichkeane       HasConditionExpr(std::nullopt), NumExprs(VarList.size()) {
1142c2accbcSerichkeane   std::uninitialized_copy(VarList.begin(), VarList.end(),
1152c2accbcSerichkeane                           getTrailingObjects<Expr *>());
1162c2accbcSerichkeane }
1172c2accbcSerichkeane 
11861338782SErich Keane OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
11961338782SErich Keane                                      SourceLocation LParenLoc,
12061338782SErich Keane                                      Expr *ConditionExpr, SourceLocation EndLoc)
1212c2accbcSerichkeane     : OpenACCClauseWithParams(OpenACCClauseKind::Self, BeginLoc, LParenLoc,
1222c2accbcSerichkeane                               EndLoc),
1232c2accbcSerichkeane       HasConditionExpr(ConditionExpr != nullptr), NumExprs(1) {
12461338782SErich Keane   assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() ||
12561338782SErich Keane           ConditionExpr->getType()->isScalarType()) &&
12661338782SErich Keane          "Condition expression type not scalar/dependent");
1272c2accbcSerichkeane   std::uninitialized_copy(&ConditionExpr, &ConditionExpr + 1,
1282c2accbcSerichkeane                           getTrailingObjects<Expr *>());
12961338782SErich Keane }
13061338782SErich Keane 
131daa88364SErich Keane OpenACCClause::child_range OpenACCClause::children() {
132daa88364SErich Keane   switch (getClauseKind()) {
133daa88364SErich Keane   default:
134daa88364SErich Keane     assert(false && "Clause children function not implemented");
135daa88364SErich Keane     break;
136daa88364SErich Keane #define VISIT_CLAUSE(CLAUSE_NAME)                                              \
137daa88364SErich Keane   case OpenACCClauseKind::CLAUSE_NAME:                                         \
138daa88364SErich Keane     return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
139e675d0d5Serichkeane #define CLAUSE_ALIAS(ALIAS_NAME, CLAUSE_NAME, DEPRECATED)                      \
140054f7c05Serichkeane   case OpenACCClauseKind::ALIAS_NAME:                                          \
141054f7c05Serichkeane     return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
142daa88364SErich Keane 
143daa88364SErich Keane #include "clang/Basic/OpenACCClauses.def"
144daa88364SErich Keane   }
145daa88364SErich Keane   return child_range(child_iterator(), child_iterator());
146daa88364SErich Keane }
147daa88364SErich Keane 
14876600aeeSErich Keane OpenACCNumWorkersClause::OpenACCNumWorkersClause(SourceLocation BeginLoc,
14976600aeeSErich Keane                                                  SourceLocation LParenLoc,
15076600aeeSErich Keane                                                  Expr *IntExpr,
15176600aeeSErich Keane                                                  SourceLocation EndLoc)
15276600aeeSErich Keane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::NumWorkers, BeginLoc,
15376600aeeSErich Keane                                      LParenLoc, IntExpr, EndLoc) {
15476600aeeSErich Keane   assert((!IntExpr || IntExpr->isInstantiationDependent() ||
15576600aeeSErich Keane           IntExpr->getType()->isIntegerType()) &&
15676600aeeSErich Keane          "Condition expression type not scalar/dependent");
15776600aeeSErich Keane }
15876600aeeSErich Keane 
1595b25c313SErich Keane OpenACCGangClause::OpenACCGangClause(SourceLocation BeginLoc,
1605b25c313SErich Keane                                      SourceLocation LParenLoc,
1615b25c313SErich Keane                                      ArrayRef<OpenACCGangKind> GangKinds,
1625b25c313SErich Keane                                      ArrayRef<Expr *> IntExprs,
1635b25c313SErich Keane                                      SourceLocation EndLoc)
1645b25c313SErich Keane     : OpenACCClauseWithExprs(OpenACCClauseKind::Gang, BeginLoc, LParenLoc,
1655b25c313SErich Keane                              EndLoc) {
1665b25c313SErich Keane   assert(GangKinds.size() == IntExprs.size() && "Mismatch exprs/kind?");
1675b25c313SErich Keane   std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
1685b25c313SErich Keane                           getTrailingObjects<Expr *>());
1695b25c313SErich Keane   setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
1705b25c313SErich Keane   std::uninitialized_copy(GangKinds.begin(), GangKinds.end(),
1715b25c313SErich Keane                           getTrailingObjects<OpenACCGangKind>());
1725b25c313SErich Keane }
1735b25c313SErich Keane 
17476600aeeSErich Keane OpenACCNumWorkersClause *
17576600aeeSErich Keane OpenACCNumWorkersClause::Create(const ASTContext &C, SourceLocation BeginLoc,
17676600aeeSErich Keane                                 SourceLocation LParenLoc, Expr *IntExpr,
17776600aeeSErich Keane                                 SourceLocation EndLoc) {
17876600aeeSErich Keane   void *Mem = C.Allocate(sizeof(OpenACCNumWorkersClause),
17976600aeeSErich Keane                          alignof(OpenACCNumWorkersClause));
18076600aeeSErich Keane   return new (Mem)
18176600aeeSErich Keane       OpenACCNumWorkersClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
18276600aeeSErich Keane }
18376600aeeSErich Keane 
18497da34e0SErich Keane OpenACCCollapseClause::OpenACCCollapseClause(SourceLocation BeginLoc,
18597da34e0SErich Keane                                              SourceLocation LParenLoc,
18697da34e0SErich Keane                                              bool HasForce, Expr *LoopCount,
18797da34e0SErich Keane                                              SourceLocation EndLoc)
18897da34e0SErich Keane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Collapse, BeginLoc,
18997da34e0SErich Keane                                      LParenLoc, LoopCount, EndLoc),
19097da34e0SErich Keane       HasForce(HasForce) {
19197da34e0SErich Keane   assert(LoopCount && "LoopCount required");
19297da34e0SErich Keane }
19397da34e0SErich Keane 
19497da34e0SErich Keane OpenACCCollapseClause *
19597da34e0SErich Keane OpenACCCollapseClause::Create(const ASTContext &C, SourceLocation BeginLoc,
19697da34e0SErich Keane                               SourceLocation LParenLoc, bool HasForce,
19797da34e0SErich Keane                               Expr *LoopCount, SourceLocation EndLoc) {
19897da34e0SErich Keane   assert(
19997da34e0SErich Keane       LoopCount &&
20097da34e0SErich Keane       (LoopCount->isInstantiationDependent() || isa<ConstantExpr>(LoopCount)) &&
20197da34e0SErich Keane       "Loop count not constant expression");
20297da34e0SErich Keane   void *Mem =
20397da34e0SErich Keane       C.Allocate(sizeof(OpenACCCollapseClause), alignof(OpenACCCollapseClause));
20497da34e0SErich Keane   return new (Mem)
20597da34e0SErich Keane       OpenACCCollapseClause(BeginLoc, LParenLoc, HasForce, LoopCount, EndLoc);
20697da34e0SErich Keane }
20797da34e0SErich Keane 
208b8adf169SErich Keane OpenACCVectorLengthClause::OpenACCVectorLengthClause(SourceLocation BeginLoc,
209b8adf169SErich Keane                                                      SourceLocation LParenLoc,
210b8adf169SErich Keane                                                      Expr *IntExpr,
211b8adf169SErich Keane                                                      SourceLocation EndLoc)
212b8adf169SErich Keane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::VectorLength, BeginLoc,
213b8adf169SErich Keane                                      LParenLoc, IntExpr, EndLoc) {
214b8adf169SErich Keane   assert((!IntExpr || IntExpr->isInstantiationDependent() ||
215b8adf169SErich Keane           IntExpr->getType()->isIntegerType()) &&
216b8adf169SErich Keane          "Condition expression type not scalar/dependent");
217b8adf169SErich Keane }
218b8adf169SErich Keane 
219b8adf169SErich Keane OpenACCVectorLengthClause *
220b8adf169SErich Keane OpenACCVectorLengthClause::Create(const ASTContext &C, SourceLocation BeginLoc,
221b8adf169SErich Keane                                   SourceLocation LParenLoc, Expr *IntExpr,
222b8adf169SErich Keane                                   SourceLocation EndLoc) {
223b8adf169SErich Keane   void *Mem = C.Allocate(sizeof(OpenACCVectorLengthClause),
224b8adf169SErich Keane                          alignof(OpenACCVectorLengthClause));
225b8adf169SErich Keane   return new (Mem)
226b8adf169SErich Keane       OpenACCVectorLengthClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
227b8adf169SErich Keane }
228b8adf169SErich Keane 
22930cfe2b2Serichkeane OpenACCAsyncClause::OpenACCAsyncClause(SourceLocation BeginLoc,
23030cfe2b2Serichkeane                                        SourceLocation LParenLoc, Expr *IntExpr,
23130cfe2b2Serichkeane                                        SourceLocation EndLoc)
23230cfe2b2Serichkeane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Async, BeginLoc,
23330cfe2b2Serichkeane                                      LParenLoc, IntExpr, EndLoc) {
23430cfe2b2Serichkeane   assert((!IntExpr || IntExpr->isInstantiationDependent() ||
23530cfe2b2Serichkeane           IntExpr->getType()->isIntegerType()) &&
23630cfe2b2Serichkeane          "Condition expression type not scalar/dependent");
23730cfe2b2Serichkeane }
23830cfe2b2Serichkeane 
23930cfe2b2Serichkeane OpenACCAsyncClause *OpenACCAsyncClause::Create(const ASTContext &C,
24030cfe2b2Serichkeane                                                SourceLocation BeginLoc,
24130cfe2b2Serichkeane                                                SourceLocation LParenLoc,
24230cfe2b2Serichkeane                                                Expr *IntExpr,
24330cfe2b2Serichkeane                                                SourceLocation EndLoc) {
24430cfe2b2Serichkeane   void *Mem =
24530cfe2b2Serichkeane       C.Allocate(sizeof(OpenACCAsyncClause), alignof(OpenACCAsyncClause));
24630cfe2b2Serichkeane   return new (Mem) OpenACCAsyncClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
24730cfe2b2Serichkeane }
24830cfe2b2Serichkeane 
249bdf25553Serichkeane OpenACCDeviceNumClause::OpenACCDeviceNumClause(SourceLocation BeginLoc,
250bdf25553Serichkeane                                        SourceLocation LParenLoc, Expr *IntExpr,
251bdf25553Serichkeane                                        SourceLocation EndLoc)
252bdf25553Serichkeane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::DeviceNum, BeginLoc,
253bdf25553Serichkeane                                      LParenLoc, IntExpr, EndLoc) {
254bdf25553Serichkeane   assert((IntExpr->isInstantiationDependent() ||
255bdf25553Serichkeane           IntExpr->getType()->isIntegerType()) &&
256bdf25553Serichkeane          "device_num expression type not scalar/dependent");
257bdf25553Serichkeane }
258bdf25553Serichkeane 
259bdf25553Serichkeane OpenACCDeviceNumClause *OpenACCDeviceNumClause::Create(const ASTContext &C,
260bdf25553Serichkeane                                                SourceLocation BeginLoc,
261bdf25553Serichkeane                                                SourceLocation LParenLoc,
262bdf25553Serichkeane                                                Expr *IntExpr,
263bdf25553Serichkeane                                                SourceLocation EndLoc) {
264bdf25553Serichkeane   void *Mem =
265bdf25553Serichkeane       C.Allocate(sizeof(OpenACCDeviceNumClause), alignof(OpenACCDeviceNumClause));
266bdf25553Serichkeane   return new (Mem) OpenACCDeviceNumClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
267bdf25553Serichkeane }
268bdf25553Serichkeane 
269ff24e9a1Serichkeane OpenACCDefaultAsyncClause::OpenACCDefaultAsyncClause(SourceLocation BeginLoc,
270ff24e9a1Serichkeane                                                      SourceLocation LParenLoc,
271ff24e9a1Serichkeane                                                      Expr *IntExpr,
272ff24e9a1Serichkeane                                                      SourceLocation EndLoc)
273ff24e9a1Serichkeane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::DefaultAsync, BeginLoc,
274ff24e9a1Serichkeane                                      LParenLoc, IntExpr, EndLoc) {
275ff24e9a1Serichkeane   assert((IntExpr->isInstantiationDependent() ||
276ff24e9a1Serichkeane           IntExpr->getType()->isIntegerType()) &&
277ff24e9a1Serichkeane          "default_async expression type not scalar/dependent");
278ff24e9a1Serichkeane }
279ff24e9a1Serichkeane 
280ff24e9a1Serichkeane OpenACCDefaultAsyncClause *
281ff24e9a1Serichkeane OpenACCDefaultAsyncClause::Create(const ASTContext &C, SourceLocation BeginLoc,
282ff24e9a1Serichkeane                                   SourceLocation LParenLoc, Expr *IntExpr,
283ff24e9a1Serichkeane                                   SourceLocation EndLoc) {
284ff24e9a1Serichkeane   void *Mem = C.Allocate(sizeof(OpenACCDefaultAsyncClause),
285ff24e9a1Serichkeane                          alignof(OpenACCDefaultAsyncClause));
286ff24e9a1Serichkeane   return new (Mem)
287ff24e9a1Serichkeane       OpenACCDefaultAsyncClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
288ff24e9a1Serichkeane }
289ff24e9a1Serichkeane 
290b1b46521Serichkeane OpenACCWaitClause *OpenACCWaitClause::Create(
291b1b46521Serichkeane     const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
292b1b46521Serichkeane     Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
293b1b46521Serichkeane     SourceLocation EndLoc) {
294b1b46521Serichkeane   // Allocates enough room in trailing storage for all the int-exprs, plus a
295b1b46521Serichkeane   // placeholder for the devnum.
296b1b46521Serichkeane   void *Mem = C.Allocate(
297b1b46521Serichkeane       OpenACCWaitClause::totalSizeToAlloc<Expr *>(QueueIdExprs.size() + 1));
298b1b46521Serichkeane   return new (Mem) OpenACCWaitClause(BeginLoc, LParenLoc, DevNumExpr, QueuesLoc,
299b1b46521Serichkeane                                      QueueIdExprs, EndLoc);
300b1b46521Serichkeane }
301b1b46521Serichkeane 
302dc20a0eaSErich Keane OpenACCNumGangsClause *OpenACCNumGangsClause::Create(const ASTContext &C,
303dc20a0eaSErich Keane                                                      SourceLocation BeginLoc,
304dc20a0eaSErich Keane                                                      SourceLocation LParenLoc,
305dc20a0eaSErich Keane                                                      ArrayRef<Expr *> IntExprs,
306dc20a0eaSErich Keane                                                      SourceLocation EndLoc) {
307dc20a0eaSErich Keane   void *Mem = C.Allocate(
308dc20a0eaSErich Keane       OpenACCNumGangsClause::totalSizeToAlloc<Expr *>(IntExprs.size()));
309dc20a0eaSErich Keane   return new (Mem) OpenACCNumGangsClause(BeginLoc, LParenLoc, IntExprs, EndLoc);
310dc20a0eaSErich Keane }
311dc20a0eaSErich Keane 
312d412cea8SErich Keane OpenACCTileClause *OpenACCTileClause::Create(const ASTContext &C,
313d412cea8SErich Keane                                              SourceLocation BeginLoc,
314d412cea8SErich Keane                                              SourceLocation LParenLoc,
315d412cea8SErich Keane                                              ArrayRef<Expr *> SizeExprs,
316d412cea8SErich Keane                                              SourceLocation EndLoc) {
317d412cea8SErich Keane   void *Mem =
318d412cea8SErich Keane       C.Allocate(OpenACCTileClause::totalSizeToAlloc<Expr *>(SizeExprs.size()));
319d412cea8SErich Keane   return new (Mem) OpenACCTileClause(BeginLoc, LParenLoc, SizeExprs, EndLoc);
320d412cea8SErich Keane }
321d412cea8SErich Keane 
322fa67986dSErich Keane OpenACCPrivateClause *OpenACCPrivateClause::Create(const ASTContext &C,
323fa67986dSErich Keane                                                    SourceLocation BeginLoc,
324fa67986dSErich Keane                                                    SourceLocation LParenLoc,
325fa67986dSErich Keane                                                    ArrayRef<Expr *> VarList,
326fa67986dSErich Keane                                                    SourceLocation EndLoc) {
327fa67986dSErich Keane   void *Mem = C.Allocate(
328fa67986dSErich Keane       OpenACCPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
329fa67986dSErich Keane   return new (Mem) OpenACCPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
330fa67986dSErich Keane }
331fa67986dSErich Keane 
332a13c5140Serichkeane OpenACCFirstPrivateClause *OpenACCFirstPrivateClause::Create(
333a13c5140Serichkeane     const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
334a13c5140Serichkeane     ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
335a13c5140Serichkeane   void *Mem = C.Allocate(
336a13c5140Serichkeane       OpenACCFirstPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
337a13c5140Serichkeane   return new (Mem)
338a13c5140Serichkeane       OpenACCFirstPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
339a13c5140Serichkeane }
340a13c5140Serichkeane 
34148c8a579Serichkeane OpenACCAttachClause *OpenACCAttachClause::Create(const ASTContext &C,
34248c8a579Serichkeane                                                  SourceLocation BeginLoc,
34348c8a579Serichkeane                                                  SourceLocation LParenLoc,
34448c8a579Serichkeane                                                  ArrayRef<Expr *> VarList,
34548c8a579Serichkeane                                                  SourceLocation EndLoc) {
34648c8a579Serichkeane   void *Mem =
34748c8a579Serichkeane       C.Allocate(OpenACCAttachClause::totalSizeToAlloc<Expr *>(VarList.size()));
34848c8a579Serichkeane   return new (Mem) OpenACCAttachClause(BeginLoc, LParenLoc, VarList, EndLoc);
34948c8a579Serichkeane }
35048c8a579Serichkeane 
3513351b3bfSerichkeane OpenACCDetachClause *OpenACCDetachClause::Create(const ASTContext &C,
3523351b3bfSerichkeane                                                  SourceLocation BeginLoc,
3533351b3bfSerichkeane                                                  SourceLocation LParenLoc,
3543351b3bfSerichkeane                                                  ArrayRef<Expr *> VarList,
3553351b3bfSerichkeane                                                  SourceLocation EndLoc) {
3563351b3bfSerichkeane   void *Mem =
3573351b3bfSerichkeane       C.Allocate(OpenACCDetachClause::totalSizeToAlloc<Expr *>(VarList.size()));
3583351b3bfSerichkeane   return new (Mem) OpenACCDetachClause(BeginLoc, LParenLoc, VarList, EndLoc);
3593351b3bfSerichkeane }
3603351b3bfSerichkeane 
3611ab81f8eSerichkeane OpenACCDeleteClause *OpenACCDeleteClause::Create(const ASTContext &C,
3621ab81f8eSerichkeane                                                  SourceLocation BeginLoc,
3631ab81f8eSerichkeane                                                  SourceLocation LParenLoc,
3641ab81f8eSerichkeane                                                  ArrayRef<Expr *> VarList,
3651ab81f8eSerichkeane                                                  SourceLocation EndLoc) {
3661ab81f8eSerichkeane   void *Mem =
3671ab81f8eSerichkeane       C.Allocate(OpenACCDeleteClause::totalSizeToAlloc<Expr *>(VarList.size()));
3681ab81f8eSerichkeane   return new (Mem) OpenACCDeleteClause(BeginLoc, LParenLoc, VarList, EndLoc);
3691ab81f8eSerichkeane }
3701ab81f8eSerichkeane 
371fbb14dd9Serichkeane OpenACCUseDeviceClause *OpenACCUseDeviceClause::Create(const ASTContext &C,
372fbb14dd9Serichkeane                                                        SourceLocation BeginLoc,
373fbb14dd9Serichkeane                                                        SourceLocation LParenLoc,
374fbb14dd9Serichkeane                                                        ArrayRef<Expr *> VarList,
375fbb14dd9Serichkeane                                                        SourceLocation EndLoc) {
376fbb14dd9Serichkeane   void *Mem = C.Allocate(
377fbb14dd9Serichkeane       OpenACCUseDeviceClause::totalSizeToAlloc<Expr *>(VarList.size()));
378fbb14dd9Serichkeane   return new (Mem) OpenACCUseDeviceClause(BeginLoc, LParenLoc, VarList, EndLoc);
379fbb14dd9Serichkeane }
380fbb14dd9Serichkeane 
38148c8a579Serichkeane OpenACCDevicePtrClause *OpenACCDevicePtrClause::Create(const ASTContext &C,
38248c8a579Serichkeane                                                        SourceLocation BeginLoc,
38348c8a579Serichkeane                                                        SourceLocation LParenLoc,
38448c8a579Serichkeane                                                        ArrayRef<Expr *> VarList,
38548c8a579Serichkeane                                                        SourceLocation EndLoc) {
38648c8a579Serichkeane   void *Mem = C.Allocate(
38748c8a579Serichkeane       OpenACCDevicePtrClause::totalSizeToAlloc<Expr *>(VarList.size()));
38848c8a579Serichkeane   return new (Mem) OpenACCDevicePtrClause(BeginLoc, LParenLoc, VarList, EndLoc);
38948c8a579Serichkeane }
39048c8a579Serichkeane 
391bd909d2eSerichkeane OpenACCNoCreateClause *OpenACCNoCreateClause::Create(const ASTContext &C,
392bd909d2eSerichkeane                                                      SourceLocation BeginLoc,
393bd909d2eSerichkeane                                                      SourceLocation LParenLoc,
394bd909d2eSerichkeane                                                      ArrayRef<Expr *> VarList,
395bd909d2eSerichkeane                                                      SourceLocation EndLoc) {
396bd909d2eSerichkeane   void *Mem = C.Allocate(
397bd909d2eSerichkeane       OpenACCNoCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
398bd909d2eSerichkeane   return new (Mem) OpenACCNoCreateClause(BeginLoc, LParenLoc, VarList, EndLoc);
399bd909d2eSerichkeane }
400bd909d2eSerichkeane 
401bd909d2eSerichkeane OpenACCPresentClause *OpenACCPresentClause::Create(const ASTContext &C,
402bd909d2eSerichkeane                                                    SourceLocation BeginLoc,
403bd909d2eSerichkeane                                                    SourceLocation LParenLoc,
404bd909d2eSerichkeane                                                    ArrayRef<Expr *> VarList,
405bd909d2eSerichkeane                                                    SourceLocation EndLoc) {
406bd909d2eSerichkeane   void *Mem = C.Allocate(
407bd909d2eSerichkeane       OpenACCPresentClause::totalSizeToAlloc<Expr *>(VarList.size()));
408bd909d2eSerichkeane   return new (Mem) OpenACCPresentClause(BeginLoc, LParenLoc, VarList, EndLoc);
409bd909d2eSerichkeane }
410bd909d2eSerichkeane 
411*be32621cSerichkeane OpenACCHostClause *OpenACCHostClause::Create(const ASTContext &C,
412*be32621cSerichkeane                                              SourceLocation BeginLoc,
413*be32621cSerichkeane                                              SourceLocation LParenLoc,
414*be32621cSerichkeane                                              ArrayRef<Expr *> VarList,
415*be32621cSerichkeane                                              SourceLocation EndLoc) {
416*be32621cSerichkeane   void *Mem =
417*be32621cSerichkeane       C.Allocate(OpenACCHostClause::totalSizeToAlloc<Expr *>(VarList.size()));
418*be32621cSerichkeane   return new (Mem) OpenACCHostClause(BeginLoc, LParenLoc, VarList, EndLoc);
419*be32621cSerichkeane }
420*be32621cSerichkeane 
421*be32621cSerichkeane OpenACCDeviceClause *OpenACCDeviceClause::Create(const ASTContext &C,
422*be32621cSerichkeane                                                  SourceLocation BeginLoc,
423*be32621cSerichkeane                                                  SourceLocation LParenLoc,
424*be32621cSerichkeane                                                  ArrayRef<Expr *> VarList,
425*be32621cSerichkeane                                                  SourceLocation EndLoc) {
426*be32621cSerichkeane   void *Mem =
427*be32621cSerichkeane       C.Allocate(OpenACCDeviceClause::totalSizeToAlloc<Expr *>(VarList.size()));
428*be32621cSerichkeane   return new (Mem) OpenACCDeviceClause(BeginLoc, LParenLoc, VarList, EndLoc);
429*be32621cSerichkeane }
430*be32621cSerichkeane 
431054f7c05Serichkeane OpenACCCopyClause *
432054f7c05Serichkeane OpenACCCopyClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
433054f7c05Serichkeane                           SourceLocation BeginLoc, SourceLocation LParenLoc,
434054f7c05Serichkeane                           ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
435054f7c05Serichkeane   void *Mem =
436054f7c05Serichkeane       C.Allocate(OpenACCCopyClause::totalSizeToAlloc<Expr *>(VarList.size()));
437054f7c05Serichkeane   return new (Mem)
438054f7c05Serichkeane       OpenACCCopyClause(Spelling, BeginLoc, LParenLoc, VarList, EndLoc);
439054f7c05Serichkeane }
440054f7c05Serichkeane 
44101e91a2dSerichkeane OpenACCCopyInClause *
44201e91a2dSerichkeane OpenACCCopyInClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
44301e91a2dSerichkeane                             SourceLocation BeginLoc, SourceLocation LParenLoc,
44401e91a2dSerichkeane                             bool IsReadOnly, ArrayRef<Expr *> VarList,
44501e91a2dSerichkeane                             SourceLocation EndLoc) {
44601e91a2dSerichkeane   void *Mem =
44701e91a2dSerichkeane       C.Allocate(OpenACCCopyInClause::totalSizeToAlloc<Expr *>(VarList.size()));
44801e91a2dSerichkeane   return new (Mem) OpenACCCopyInClause(Spelling, BeginLoc, LParenLoc,
44901e91a2dSerichkeane                                        IsReadOnly, VarList, EndLoc);
45001e91a2dSerichkeane }
45101e91a2dSerichkeane 
45201e91a2dSerichkeane OpenACCCopyOutClause *
45301e91a2dSerichkeane OpenACCCopyOutClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
45401e91a2dSerichkeane                              SourceLocation BeginLoc, SourceLocation LParenLoc,
45501e91a2dSerichkeane                              bool IsZero, ArrayRef<Expr *> VarList,
45601e91a2dSerichkeane                              SourceLocation EndLoc) {
45701e91a2dSerichkeane   void *Mem = C.Allocate(
45801e91a2dSerichkeane       OpenACCCopyOutClause::totalSizeToAlloc<Expr *>(VarList.size()));
45901e91a2dSerichkeane   return new (Mem) OpenACCCopyOutClause(Spelling, BeginLoc, LParenLoc, IsZero,
46001e91a2dSerichkeane                                         VarList, EndLoc);
46101e91a2dSerichkeane }
46201e91a2dSerichkeane 
46301e91a2dSerichkeane OpenACCCreateClause *
46401e91a2dSerichkeane OpenACCCreateClause::Create(const ASTContext &C, OpenACCClauseKind Spelling,
46501e91a2dSerichkeane                             SourceLocation BeginLoc, SourceLocation LParenLoc,
46601e91a2dSerichkeane                             bool IsZero, ArrayRef<Expr *> VarList,
46701e91a2dSerichkeane                             SourceLocation EndLoc) {
46801e91a2dSerichkeane   void *Mem =
46901e91a2dSerichkeane       C.Allocate(OpenACCCreateClause::totalSizeToAlloc<Expr *>(VarList.size()));
47001e91a2dSerichkeane   return new (Mem) OpenACCCreateClause(Spelling, BeginLoc, LParenLoc, IsZero,
47101e91a2dSerichkeane                                        VarList, EndLoc);
47201e91a2dSerichkeane }
47301e91a2dSerichkeane 
4748ef2011bSerichkeane OpenACCDeviceTypeClause *OpenACCDeviceTypeClause::Create(
4758ef2011bSerichkeane     const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc,
4768ef2011bSerichkeane     SourceLocation LParenLoc, ArrayRef<DeviceTypeArgument> Archs,
4778ef2011bSerichkeane     SourceLocation EndLoc) {
4788ef2011bSerichkeane   void *Mem =
4798ef2011bSerichkeane       C.Allocate(OpenACCDeviceTypeClause::totalSizeToAlloc<DeviceTypeArgument>(
4808ef2011bSerichkeane           Archs.size()));
4818ef2011bSerichkeane   return new (Mem)
4828ef2011bSerichkeane       OpenACCDeviceTypeClause(K, BeginLoc, LParenLoc, Archs, EndLoc);
4838ef2011bSerichkeane }
4848ef2011bSerichkeane 
485a15b685cSErich Keane OpenACCReductionClause *OpenACCReductionClause::Create(
486a15b685cSErich Keane     const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
487a15b685cSErich Keane     OpenACCReductionOperator Operator, ArrayRef<Expr *> VarList,
488a15b685cSErich Keane     SourceLocation EndLoc) {
489a15b685cSErich Keane   void *Mem = C.Allocate(
490a15b685cSErich Keane       OpenACCReductionClause::totalSizeToAlloc<Expr *>(VarList.size()));
491a15b685cSErich Keane   return new (Mem)
492a15b685cSErich Keane       OpenACCReductionClause(BeginLoc, LParenLoc, Operator, VarList, EndLoc);
493a15b685cSErich Keane }
494a15b685cSErich Keane 
4952b939e18Serichkeane OpenACCAutoClause *OpenACCAutoClause::Create(const ASTContext &C,
4962b939e18Serichkeane                                              SourceLocation BeginLoc,
4972b939e18Serichkeane                                              SourceLocation EndLoc) {
4982b939e18Serichkeane   void *Mem = C.Allocate(sizeof(OpenACCAutoClause));
4992b939e18Serichkeane   return new (Mem) OpenACCAutoClause(BeginLoc, EndLoc);
5002b939e18Serichkeane }
5012b939e18Serichkeane 
5022b939e18Serichkeane OpenACCIndependentClause *
5032b939e18Serichkeane OpenACCIndependentClause::Create(const ASTContext &C, SourceLocation BeginLoc,
5042b939e18Serichkeane                                  SourceLocation EndLoc) {
5052b939e18Serichkeane   void *Mem = C.Allocate(sizeof(OpenACCIndependentClause));
5062b939e18Serichkeane   return new (Mem) OpenACCIndependentClause(BeginLoc, EndLoc);
5072b939e18Serichkeane }
5082b939e18Serichkeane 
5092b939e18Serichkeane OpenACCSeqClause *OpenACCSeqClause::Create(const ASTContext &C,
5102b939e18Serichkeane                                            SourceLocation BeginLoc,
5112b939e18Serichkeane                                            SourceLocation EndLoc) {
5122b939e18Serichkeane   void *Mem = C.Allocate(sizeof(OpenACCSeqClause));
5132b939e18Serichkeane   return new (Mem) OpenACCSeqClause(BeginLoc, EndLoc);
5142b939e18Serichkeane }
5152b939e18Serichkeane 
5165b25c313SErich Keane OpenACCGangClause *
5175b25c313SErich Keane OpenACCGangClause::Create(const ASTContext &C, SourceLocation BeginLoc,
5185b25c313SErich Keane                           SourceLocation LParenLoc,
5195b25c313SErich Keane                           ArrayRef<OpenACCGangKind> GangKinds,
5205b25c313SErich Keane                           ArrayRef<Expr *> IntExprs, SourceLocation EndLoc) {
5215b25c313SErich Keane   void *Mem =
5225b25c313SErich Keane       C.Allocate(OpenACCGangClause::totalSizeToAlloc<Expr *, OpenACCGangKind>(
5235b25c313SErich Keane           IntExprs.size(), GangKinds.size()));
5245b25c313SErich Keane   return new (Mem)
5255b25c313SErich Keane       OpenACCGangClause(BeginLoc, LParenLoc, GangKinds, IntExprs, EndLoc);
5262b939e18Serichkeane }
5272b939e18Serichkeane 
528cf456ed2SErich Keane OpenACCWorkerClause::OpenACCWorkerClause(SourceLocation BeginLoc,
529cf456ed2SErich Keane                                          SourceLocation LParenLoc,
530cf456ed2SErich Keane                                          Expr *IntExpr, SourceLocation EndLoc)
531cf456ed2SErich Keane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Worker, BeginLoc,
532cf456ed2SErich Keane                                      LParenLoc, IntExpr, EndLoc) {
533cf456ed2SErich Keane   assert((!IntExpr || IntExpr->isInstantiationDependent() ||
534cf456ed2SErich Keane           IntExpr->getType()->isIntegerType()) &&
535cf456ed2SErich Keane          "Int expression type not scalar/dependent");
536cf456ed2SErich Keane }
537cf456ed2SErich Keane 
5382b939e18Serichkeane OpenACCWorkerClause *OpenACCWorkerClause::Create(const ASTContext &C,
5392b939e18Serichkeane                                                  SourceLocation BeginLoc,
540cf456ed2SErich Keane                                                  SourceLocation LParenLoc,
541cf456ed2SErich Keane                                                  Expr *IntExpr,
5422b939e18Serichkeane                                                  SourceLocation EndLoc) {
543cf456ed2SErich Keane   void *Mem =
544cf456ed2SErich Keane       C.Allocate(sizeof(OpenACCWorkerClause), alignof(OpenACCWorkerClause));
545cf456ed2SErich Keane   return new (Mem) OpenACCWorkerClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
5462b939e18Serichkeane }
5472b939e18Serichkeane 
548c8cbdc65SErich Keane OpenACCVectorClause::OpenACCVectorClause(SourceLocation BeginLoc,
549c8cbdc65SErich Keane                                          SourceLocation LParenLoc,
550c8cbdc65SErich Keane                                          Expr *IntExpr, SourceLocation EndLoc)
551c8cbdc65SErich Keane     : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::Vector, BeginLoc,
552c8cbdc65SErich Keane                                      LParenLoc, IntExpr, EndLoc) {
553c8cbdc65SErich Keane   assert((!IntExpr || IntExpr->isInstantiationDependent() ||
554c8cbdc65SErich Keane           IntExpr->getType()->isIntegerType()) &&
555c8cbdc65SErich Keane          "Int expression type not scalar/dependent");
556c8cbdc65SErich Keane }
557c8cbdc65SErich Keane 
5582b939e18Serichkeane OpenACCVectorClause *OpenACCVectorClause::Create(const ASTContext &C,
5592b939e18Serichkeane                                                  SourceLocation BeginLoc,
560c8cbdc65SErich Keane                                                  SourceLocation LParenLoc,
561c8cbdc65SErich Keane                                                  Expr *IntExpr,
5622b939e18Serichkeane                                                  SourceLocation EndLoc) {
563c8cbdc65SErich Keane   void *Mem =
564c8cbdc65SErich Keane       C.Allocate(sizeof(OpenACCVectorClause), alignof(OpenACCVectorClause));
565c8cbdc65SErich Keane   return new (Mem) OpenACCVectorClause(BeginLoc, LParenLoc, IntExpr, EndLoc);
5662b939e18Serichkeane }
5672b939e18Serichkeane 
568003eb5e8Serichkeane OpenACCFinalizeClause *OpenACCFinalizeClause::Create(const ASTContext &C,
569003eb5e8Serichkeane                                                      SourceLocation BeginLoc,
570003eb5e8Serichkeane                                                      SourceLocation EndLoc) {
571003eb5e8Serichkeane   void *Mem =
572003eb5e8Serichkeane       C.Allocate(sizeof(OpenACCFinalizeClause), alignof(OpenACCFinalizeClause));
573003eb5e8Serichkeane   return new (Mem) OpenACCFinalizeClause(BeginLoc, EndLoc);
574003eb5e8Serichkeane }
575003eb5e8Serichkeane 
5762244d2e7Serichkeane OpenACCIfPresentClause *OpenACCIfPresentClause::Create(const ASTContext &C,
5772244d2e7Serichkeane                                                        SourceLocation BeginLoc,
5782244d2e7Serichkeane                                                        SourceLocation EndLoc) {
5792244d2e7Serichkeane   void *Mem = C.Allocate(sizeof(OpenACCIfPresentClause),
5802244d2e7Serichkeane                          alignof(OpenACCIfPresentClause));
5812244d2e7Serichkeane   return new (Mem) OpenACCIfPresentClause(BeginLoc, EndLoc);
5822244d2e7Serichkeane }
5832244d2e7Serichkeane 
5840c7b92a4SErich Keane //===----------------------------------------------------------------------===//
5850c7b92a4SErich Keane //  OpenACC clauses printing methods
5860c7b92a4SErich Keane //===----------------------------------------------------------------------===//
587cc6113daSerichkeane 
588cc6113daSerichkeane void OpenACCClausePrinter::printExpr(const Expr *E) {
589cc6113daSerichkeane   E->printPretty(OS, nullptr, Policy, 0);
590cc6113daSerichkeane }
591cc6113daSerichkeane 
592db8e1829Serichkeane void OpenACCClausePrinter::VisitDefaultClause(const OpenACCDefaultClause &C) {
5930c7b92a4SErich Keane   OS << "default(" << C.getDefaultClauseKind() << ")";
5940c7b92a4SErich Keane }
595daa88364SErich Keane 
596a472e647Serichkeane void OpenACCClausePrinter::VisitIfClause(const OpenACCIfClause &C) {
597cc6113daSerichkeane   OS << "if(";
598cc6113daSerichkeane   printExpr(C.getConditionExpr());
599cc6113daSerichkeane   OS << ")";
600daa88364SErich Keane }
60161338782SErich Keane 
60261338782SErich Keane void OpenACCClausePrinter::VisitSelfClause(const OpenACCSelfClause &C) {
60361338782SErich Keane   OS << "self";
6042c2accbcSerichkeane 
6052c2accbcSerichkeane   if (C.isConditionExprClause()) {
606cc6113daSerichkeane     if (const Expr *CondExpr = C.getConditionExpr()) {
607cc6113daSerichkeane       OS << "(";
608cc6113daSerichkeane       printExpr(CondExpr);
609cc6113daSerichkeane       OS << ")";
610cc6113daSerichkeane     }
6112c2accbcSerichkeane   } else {
6122c2accbcSerichkeane     OS << "(";
6132c2accbcSerichkeane     llvm::interleaveComma(C.getVarList(), OS,
6142c2accbcSerichkeane                           [&](const Expr *E) { printExpr(E); });
6152c2accbcSerichkeane     OS << ")";
6162c2accbcSerichkeane   }
61761338782SErich Keane }
61876600aeeSErich Keane 
619dc20a0eaSErich Keane void OpenACCClausePrinter::VisitNumGangsClause(const OpenACCNumGangsClause &C) {
620dc20a0eaSErich Keane   OS << "num_gangs(";
621cc6113daSerichkeane   llvm::interleaveComma(C.getIntExprs(), OS,
622cc6113daSerichkeane                         [&](const Expr *E) { printExpr(E); });
623dc20a0eaSErich Keane   OS << ")";
624dc20a0eaSErich Keane }
625dc20a0eaSErich Keane 
626d412cea8SErich Keane void OpenACCClausePrinter::VisitTileClause(const OpenACCTileClause &C) {
627d412cea8SErich Keane   OS << "tile(";
628d412cea8SErich Keane   llvm::interleaveComma(C.getSizeExprs(), OS,
629d412cea8SErich Keane                         [&](const Expr *E) { printExpr(E); });
630d412cea8SErich Keane   OS << ")";
631d412cea8SErich Keane }
632d412cea8SErich Keane 
63376600aeeSErich Keane void OpenACCClausePrinter::VisitNumWorkersClause(
63476600aeeSErich Keane     const OpenACCNumWorkersClause &C) {
635cc6113daSerichkeane   OS << "num_workers(";
636cc6113daSerichkeane   printExpr(C.getIntExpr());
637cc6113daSerichkeane   OS << ")";
63876600aeeSErich Keane }
639b8adf169SErich Keane 
640b8adf169SErich Keane void OpenACCClausePrinter::VisitVectorLengthClause(
641b8adf169SErich Keane     const OpenACCVectorLengthClause &C) {
642cc6113daSerichkeane   OS << "vector_length(";
643cc6113daSerichkeane   printExpr(C.getIntExpr());
644cc6113daSerichkeane   OS << ")";
645b8adf169SErich Keane }
646fa67986dSErich Keane 
647bdf25553Serichkeane void OpenACCClausePrinter::VisitDeviceNumClause(
648bdf25553Serichkeane     const OpenACCDeviceNumClause &C) {
649bdf25553Serichkeane   OS << "device_num(";
650bdf25553Serichkeane   printExpr(C.getIntExpr());
651bdf25553Serichkeane   OS << ")";
652bdf25553Serichkeane }
653bdf25553Serichkeane 
654ff24e9a1Serichkeane void OpenACCClausePrinter::VisitDefaultAsyncClause(
655ff24e9a1Serichkeane     const OpenACCDefaultAsyncClause &C) {
656ff24e9a1Serichkeane   OS << "default_async(";
657ff24e9a1Serichkeane   printExpr(C.getIntExpr());
658ff24e9a1Serichkeane   OS << ")";
659ff24e9a1Serichkeane }
660ff24e9a1Serichkeane 
66130cfe2b2Serichkeane void OpenACCClausePrinter::VisitAsyncClause(const OpenACCAsyncClause &C) {
66230cfe2b2Serichkeane   OS << "async";
66330cfe2b2Serichkeane   if (C.hasIntExpr()) {
66430cfe2b2Serichkeane     OS << "(";
66530cfe2b2Serichkeane     printExpr(C.getIntExpr());
66630cfe2b2Serichkeane     OS << ")";
66730cfe2b2Serichkeane   }
66830cfe2b2Serichkeane }
66930cfe2b2Serichkeane 
670fa67986dSErich Keane void OpenACCClausePrinter::VisitPrivateClause(const OpenACCPrivateClause &C) {
671fa67986dSErich Keane   OS << "private(";
672fa67986dSErich Keane   llvm::interleaveComma(C.getVarList(), OS,
673fa67986dSErich Keane                         [&](const Expr *E) { printExpr(E); });
674fa67986dSErich Keane   OS << ")";
675fa67986dSErich Keane }
676a13c5140Serichkeane 
677a13c5140Serichkeane void OpenACCClausePrinter::VisitFirstPrivateClause(
678a13c5140Serichkeane     const OpenACCFirstPrivateClause &C) {
679a13c5140Serichkeane   OS << "firstprivate(";
680a13c5140Serichkeane   llvm::interleaveComma(C.getVarList(), OS,
681a13c5140Serichkeane                         [&](const Expr *E) { printExpr(E); });
682a13c5140Serichkeane   OS << ")";
683a13c5140Serichkeane }
684bd909d2eSerichkeane 
68548c8a579Serichkeane void OpenACCClausePrinter::VisitAttachClause(const OpenACCAttachClause &C) {
68648c8a579Serichkeane   OS << "attach(";
68748c8a579Serichkeane   llvm::interleaveComma(C.getVarList(), OS,
68848c8a579Serichkeane                         [&](const Expr *E) { printExpr(E); });
68948c8a579Serichkeane   OS << ")";
69048c8a579Serichkeane }
69148c8a579Serichkeane 
6923351b3bfSerichkeane void OpenACCClausePrinter::VisitDetachClause(const OpenACCDetachClause &C) {
6933351b3bfSerichkeane   OS << "detach(";
6943351b3bfSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
6953351b3bfSerichkeane                         [&](const Expr *E) { printExpr(E); });
6963351b3bfSerichkeane   OS << ")";
6973351b3bfSerichkeane }
6983351b3bfSerichkeane 
6991ab81f8eSerichkeane void OpenACCClausePrinter::VisitDeleteClause(const OpenACCDeleteClause &C) {
7001ab81f8eSerichkeane   OS << "delete(";
7011ab81f8eSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
7021ab81f8eSerichkeane                         [&](const Expr *E) { printExpr(E); });
7031ab81f8eSerichkeane   OS << ")";
7041ab81f8eSerichkeane }
7051ab81f8eSerichkeane 
706fbb14dd9Serichkeane void OpenACCClausePrinter::VisitUseDeviceClause(
707fbb14dd9Serichkeane     const OpenACCUseDeviceClause &C) {
708fbb14dd9Serichkeane   OS << "use_device(";
709fbb14dd9Serichkeane   llvm::interleaveComma(C.getVarList(), OS,
710fbb14dd9Serichkeane                         [&](const Expr *E) { printExpr(E); });
711fbb14dd9Serichkeane   OS << ")";
712fbb14dd9Serichkeane }
713fbb14dd9Serichkeane 
71448c8a579Serichkeane void OpenACCClausePrinter::VisitDevicePtrClause(
71548c8a579Serichkeane     const OpenACCDevicePtrClause &C) {
71648c8a579Serichkeane   OS << "deviceptr(";
71748c8a579Serichkeane   llvm::interleaveComma(C.getVarList(), OS,
71848c8a579Serichkeane                         [&](const Expr *E) { printExpr(E); });
71948c8a579Serichkeane   OS << ")";
72048c8a579Serichkeane }
72148c8a579Serichkeane 
722bd909d2eSerichkeane void OpenACCClausePrinter::VisitNoCreateClause(const OpenACCNoCreateClause &C) {
723bd909d2eSerichkeane   OS << "no_create(";
724bd909d2eSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
725bd909d2eSerichkeane                         [&](const Expr *E) { printExpr(E); });
726bd909d2eSerichkeane   OS << ")";
727bd909d2eSerichkeane }
728bd909d2eSerichkeane 
729bd909d2eSerichkeane void OpenACCClausePrinter::VisitPresentClause(const OpenACCPresentClause &C) {
730bd909d2eSerichkeane   OS << "present(";
731bd909d2eSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
732bd909d2eSerichkeane                         [&](const Expr *E) { printExpr(E); });
733bd909d2eSerichkeane   OS << ")";
734bd909d2eSerichkeane }
735054f7c05Serichkeane 
736*be32621cSerichkeane void OpenACCClausePrinter::VisitHostClause(const OpenACCHostClause &C) {
737*be32621cSerichkeane   OS << "host(";
738*be32621cSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
739*be32621cSerichkeane                         [&](const Expr *E) { printExpr(E); });
740*be32621cSerichkeane   OS << ")";
741*be32621cSerichkeane }
742*be32621cSerichkeane 
743*be32621cSerichkeane void OpenACCClausePrinter::VisitDeviceClause(const OpenACCDeviceClause &C) {
744*be32621cSerichkeane   OS << "device(";
745*be32621cSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
746*be32621cSerichkeane                         [&](const Expr *E) { printExpr(E); });
747*be32621cSerichkeane   OS << ")";
748*be32621cSerichkeane }
749*be32621cSerichkeane 
750054f7c05Serichkeane void OpenACCClausePrinter::VisitCopyClause(const OpenACCCopyClause &C) {
751054f7c05Serichkeane   OS << C.getClauseKind() << '(';
752054f7c05Serichkeane   llvm::interleaveComma(C.getVarList(), OS,
753054f7c05Serichkeane                         [&](const Expr *E) { printExpr(E); });
754054f7c05Serichkeane   OS << ")";
755054f7c05Serichkeane }
75601e91a2dSerichkeane 
75701e91a2dSerichkeane void OpenACCClausePrinter::VisitCopyInClause(const OpenACCCopyInClause &C) {
75801e91a2dSerichkeane   OS << C.getClauseKind() << '(';
75901e91a2dSerichkeane   if (C.isReadOnly())
76001e91a2dSerichkeane     OS << "readonly: ";
76101e91a2dSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
76201e91a2dSerichkeane                         [&](const Expr *E) { printExpr(E); });
76301e91a2dSerichkeane   OS << ")";
76401e91a2dSerichkeane }
76501e91a2dSerichkeane 
76601e91a2dSerichkeane void OpenACCClausePrinter::VisitCopyOutClause(const OpenACCCopyOutClause &C) {
76701e91a2dSerichkeane   OS << C.getClauseKind() << '(';
76801e91a2dSerichkeane   if (C.isZero())
76901e91a2dSerichkeane     OS << "zero: ";
77001e91a2dSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
77101e91a2dSerichkeane                         [&](const Expr *E) { printExpr(E); });
77201e91a2dSerichkeane   OS << ")";
77301e91a2dSerichkeane }
77401e91a2dSerichkeane 
77501e91a2dSerichkeane void OpenACCClausePrinter::VisitCreateClause(const OpenACCCreateClause &C) {
77601e91a2dSerichkeane   OS << C.getClauseKind() << '(';
77701e91a2dSerichkeane   if (C.isZero())
77801e91a2dSerichkeane     OS << "zero: ";
77901e91a2dSerichkeane   llvm::interleaveComma(C.getVarList(), OS,
78001e91a2dSerichkeane                         [&](const Expr *E) { printExpr(E); });
78101e91a2dSerichkeane   OS << ")";
78201e91a2dSerichkeane }
783b1b46521Serichkeane 
784a15b685cSErich Keane void OpenACCClausePrinter::VisitReductionClause(
785a15b685cSErich Keane     const OpenACCReductionClause &C) {
786a15b685cSErich Keane   OS << "reduction(" << C.getReductionOp() << ": ";
787a15b685cSErich Keane   llvm::interleaveComma(C.getVarList(), OS,
788a15b685cSErich Keane                         [&](const Expr *E) { printExpr(E); });
789a15b685cSErich Keane   OS << ")";
790a15b685cSErich Keane }
791a15b685cSErich Keane 
792b1b46521Serichkeane void OpenACCClausePrinter::VisitWaitClause(const OpenACCWaitClause &C) {
793b1b46521Serichkeane   OS << "wait";
794b1b46521Serichkeane   if (!C.getLParenLoc().isInvalid()) {
795b1b46521Serichkeane     OS << "(";
796b1b46521Serichkeane     if (C.hasDevNumExpr()) {
797b1b46521Serichkeane       OS << "devnum: ";
798b1b46521Serichkeane       printExpr(C.getDevNumExpr());
799b1b46521Serichkeane       OS << " : ";
800b1b46521Serichkeane     }
801b1b46521Serichkeane 
802b1b46521Serichkeane     if (C.hasQueuesTag())
803b1b46521Serichkeane       OS << "queues: ";
804b1b46521Serichkeane 
805b1b46521Serichkeane     llvm::interleaveComma(C.getQueueIdExprs(), OS,
806b1b46521Serichkeane                           [&](const Expr *E) { printExpr(E); });
807b1b46521Serichkeane     OS << ")";
808b1b46521Serichkeane   }
809b1b46521Serichkeane }
8108ef2011bSerichkeane 
8118ef2011bSerichkeane void OpenACCClausePrinter::VisitDeviceTypeClause(
8128ef2011bSerichkeane     const OpenACCDeviceTypeClause &C) {
8138ef2011bSerichkeane   OS << C.getClauseKind();
8148ef2011bSerichkeane   OS << "(";
8158ef2011bSerichkeane   llvm::interleaveComma(C.getArchitectures(), OS,
8168ef2011bSerichkeane                         [&](const DeviceTypeArgument &Arch) {
8178ef2011bSerichkeane                           if (Arch.first == nullptr)
8188ef2011bSerichkeane                             OS << "*";
8198ef2011bSerichkeane                           else
82003eba209Serichkeane                             OS << Arch.first->getName();
8218ef2011bSerichkeane                         });
8228ef2011bSerichkeane   OS << ")";
8238ef2011bSerichkeane }
8242b939e18Serichkeane 
8252b939e18Serichkeane void OpenACCClausePrinter::VisitAutoClause(const OpenACCAutoClause &C) {
8262b939e18Serichkeane   OS << "auto";
8272b939e18Serichkeane }
8282b939e18Serichkeane 
8292b939e18Serichkeane void OpenACCClausePrinter::VisitIndependentClause(
8302b939e18Serichkeane     const OpenACCIndependentClause &C) {
8312b939e18Serichkeane   OS << "independent";
8322b939e18Serichkeane }
8332b939e18Serichkeane 
8342b939e18Serichkeane void OpenACCClausePrinter::VisitSeqClause(const OpenACCSeqClause &C) {
8352b939e18Serichkeane   OS << "seq";
8362b939e18Serichkeane }
83797da34e0SErich Keane 
83897da34e0SErich Keane void OpenACCClausePrinter::VisitCollapseClause(const OpenACCCollapseClause &C) {
83997da34e0SErich Keane   OS << "collapse(";
84097da34e0SErich Keane   if (C.hasForce())
84197da34e0SErich Keane     OS << "force:";
84297da34e0SErich Keane   printExpr(C.getLoopCount());
84397da34e0SErich Keane   OS << ")";
84497da34e0SErich Keane }
8455b25c313SErich Keane 
8465b25c313SErich Keane void OpenACCClausePrinter::VisitGangClause(const OpenACCGangClause &C) {
8475b25c313SErich Keane   OS << "gang";
8485b25c313SErich Keane 
8495b25c313SErich Keane   if (C.getNumExprs() > 0) {
8505b25c313SErich Keane     OS << "(";
8515b25c313SErich Keane     bool first = true;
8525b25c313SErich Keane     for (unsigned I = 0; I < C.getNumExprs(); ++I) {
8535b25c313SErich Keane       if (!first)
8545b25c313SErich Keane         OS << ", ";
8555b25c313SErich Keane       first = false;
8565b25c313SErich Keane 
8575b25c313SErich Keane       OS << C.getExpr(I).first << ": ";
8585b25c313SErich Keane       printExpr(C.getExpr(I).second);
8595b25c313SErich Keane     }
8605b25c313SErich Keane     OS << ")";
8615b25c313SErich Keane   }
8625b25c313SErich Keane }
863cf456ed2SErich Keane 
864cf456ed2SErich Keane void OpenACCClausePrinter::VisitWorkerClause(const OpenACCWorkerClause &C) {
865cf456ed2SErich Keane   OS << "worker";
866cf456ed2SErich Keane 
867cf456ed2SErich Keane   if (C.hasIntExpr()) {
868cf456ed2SErich Keane     OS << "(num: ";
869cf456ed2SErich Keane     printExpr(C.getIntExpr());
870cf456ed2SErich Keane     OS << ")";
871cf456ed2SErich Keane   }
872cf456ed2SErich Keane }
873c8cbdc65SErich Keane 
874c8cbdc65SErich Keane void OpenACCClausePrinter::VisitVectorClause(const OpenACCVectorClause &C) {
875c8cbdc65SErich Keane   OS << "vector";
876c8cbdc65SErich Keane 
877c8cbdc65SErich Keane   if (C.hasIntExpr()) {
878c8cbdc65SErich Keane     OS << "(length: ";
879c8cbdc65SErich Keane     printExpr(C.getIntExpr());
880c8cbdc65SErich Keane     OS << ")";
881c8cbdc65SErich Keane   }
882c8cbdc65SErich Keane }
883003eb5e8Serichkeane 
884003eb5e8Serichkeane void OpenACCClausePrinter::VisitFinalizeClause(const OpenACCFinalizeClause &C) {
885003eb5e8Serichkeane   OS << "finalize";
886003eb5e8Serichkeane }
8872244d2e7Serichkeane 
8882244d2e7Serichkeane void OpenACCClausePrinter::VisitIfPresentClause(
8892244d2e7Serichkeane     const OpenACCIfPresentClause &C) {
8902244d2e7Serichkeane   OS << "if_present";
8912244d2e7Serichkeane }
892