xref: /freebsd/contrib/llvm-project/clang/lib/AST/StmtOpenMP.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
1 //===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//
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 Stmt class declared in StmtOpenMP.h
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/ASTContext.h"
14 #include "clang/AST/StmtOpenMP.h"
15 
16 using namespace clang;
17 using namespace llvm::omp;
18 
size(unsigned NumClauses,bool HasAssociatedStmt,unsigned NumChildren)19 size_t OMPChildren::size(unsigned NumClauses, bool HasAssociatedStmt,
20                          unsigned NumChildren) {
21   return llvm::alignTo(
22       totalSizeToAlloc<OMPClause *, Stmt *>(
23           NumClauses, NumChildren + (HasAssociatedStmt ? 1 : 0)),
24       alignof(OMPChildren));
25 }
26 
setClauses(ArrayRef<OMPClause * > Clauses)27 void OMPChildren::setClauses(ArrayRef<OMPClause *> Clauses) {
28   assert(Clauses.size() == NumClauses &&
29          "Number of clauses is not the same as the preallocated buffer");
30   llvm::copy(Clauses, getTrailingObjects<OMPClause *>());
31 }
32 
getChildren()33 MutableArrayRef<Stmt *> OMPChildren::getChildren() {
34   return llvm::MutableArrayRef(getTrailingObjects<Stmt *>(), NumChildren);
35 }
36 
Create(void * Mem,ArrayRef<OMPClause * > Clauses)37 OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses) {
38   auto *Data = CreateEmpty(Mem, Clauses.size());
39   Data->setClauses(Clauses);
40   return Data;
41 }
42 
Create(void * Mem,ArrayRef<OMPClause * > Clauses,Stmt * S,unsigned NumChildren)43 OMPChildren *OMPChildren::Create(void *Mem, ArrayRef<OMPClause *> Clauses,
44                                  Stmt *S, unsigned NumChildren) {
45   auto *Data = CreateEmpty(Mem, Clauses.size(), S, NumChildren);
46   Data->setClauses(Clauses);
47   if (S)
48     Data->setAssociatedStmt(S);
49   return Data;
50 }
51 
CreateEmpty(void * Mem,unsigned NumClauses,bool HasAssociatedStmt,unsigned NumChildren)52 OMPChildren *OMPChildren::CreateEmpty(void *Mem, unsigned NumClauses,
53                                       bool HasAssociatedStmt,
54                                       unsigned NumChildren) {
55   return new (Mem) OMPChildren(NumClauses, NumChildren, HasAssociatedStmt);
56 }
57 
isStandaloneDirective() const58 bool OMPExecutableDirective::isStandaloneDirective() const {
59   // Special case: 'omp target enter data', 'omp target exit data',
60   // 'omp target update' are stand-alone directives, but for implementation
61   // reasons they have empty synthetic structured block, to simplify codegen.
62   if (isa<OMPTargetEnterDataDirective>(this) ||
63       isa<OMPTargetExitDataDirective>(this) ||
64       isa<OMPTargetUpdateDirective>(this))
65     return true;
66   return !hasAssociatedStmt();
67 }
68 
getStructuredBlock()69 Stmt *OMPExecutableDirective::getStructuredBlock() {
70   assert(!isStandaloneDirective() &&
71          "Standalone Executable Directives don't have Structured Blocks.");
72   if (auto *LD = dyn_cast<OMPLoopDirective>(this))
73     return LD->getBody();
74   return getRawStmt();
75 }
76 
77 Stmt *
tryToFindNextInnerLoop(Stmt * CurStmt,bool TryImperfectlyNestedLoops)78 OMPLoopBasedDirective::tryToFindNextInnerLoop(Stmt *CurStmt,
79                                               bool TryImperfectlyNestedLoops) {
80   Stmt *OrigStmt = CurStmt;
81   CurStmt = CurStmt->IgnoreContainers();
82   // Additional work for imperfectly nested loops, introduced in OpenMP 5.0.
83   if (TryImperfectlyNestedLoops) {
84     if (auto *CS = dyn_cast<CompoundStmt>(CurStmt)) {
85       CurStmt = nullptr;
86       SmallVector<CompoundStmt *, 4> Statements(1, CS);
87       SmallVector<CompoundStmt *, 4> NextStatements;
88       while (!Statements.empty()) {
89         CS = Statements.pop_back_val();
90         if (!CS)
91           continue;
92         for (Stmt *S : CS->body()) {
93           if (!S)
94             continue;
95           if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(S))
96             S = CanonLoop->getLoopStmt();
97           if (isa<ForStmt>(S) || isa<CXXForRangeStmt>(S) ||
98               (isa<OMPLoopBasedDirective>(S) && !isa<OMPLoopDirective>(S))) {
99             // Only single loop construct is allowed.
100             if (CurStmt) {
101               CurStmt = OrigStmt;
102               break;
103             }
104             CurStmt = S;
105             continue;
106           }
107           S = S->IgnoreContainers();
108           if (auto *InnerCS = dyn_cast_or_null<CompoundStmt>(S))
109             NextStatements.push_back(InnerCS);
110         }
111         if (Statements.empty()) {
112           // Found single inner loop or multiple loops - exit.
113           if (CurStmt)
114             break;
115           Statements.swap(NextStatements);
116         }
117       }
118       if (!CurStmt)
119         CurStmt = OrigStmt;
120     }
121   }
122   return CurStmt;
123 }
124 
doForAllLoops(Stmt * CurStmt,bool TryImperfectlyNestedLoops,unsigned NumLoops,llvm::function_ref<bool (unsigned,Stmt *)> Callback,llvm::function_ref<void (OMPLoopTransformationDirective *)> OnTransformationCallback)125 bool OMPLoopBasedDirective::doForAllLoops(
126     Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
127     llvm::function_ref<bool(unsigned, Stmt *)> Callback,
128     llvm::function_ref<void(OMPLoopTransformationDirective *)>
129         OnTransformationCallback) {
130   CurStmt = CurStmt->IgnoreContainers();
131   for (unsigned Cnt = 0; Cnt < NumLoops; ++Cnt) {
132     while (true) {
133       auto *Dir = dyn_cast<OMPLoopTransformationDirective>(CurStmt);
134       if (!Dir)
135         break;
136 
137       OnTransformationCallback(Dir);
138 
139       Stmt *TransformedStmt = Dir->getTransformedStmt();
140       if (!TransformedStmt) {
141         unsigned NumGeneratedLoops = Dir->getNumGeneratedLoops();
142         if (NumGeneratedLoops == 0) {
143           // May happen if the loop transformation does not result in a
144           // generated loop (such as full unrolling).
145           break;
146         }
147         if (NumGeneratedLoops > 0) {
148           // The loop transformation construct has generated loops, but these
149           // may not have been generated yet due to being in a dependent
150           // context.
151           return true;
152         }
153       }
154 
155       CurStmt = TransformedStmt;
156     }
157     if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(CurStmt))
158       CurStmt = CanonLoop->getLoopStmt();
159     if (Callback(Cnt, CurStmt))
160       return false;
161     // Move on to the next nested for loop, or to the loop body.
162     // OpenMP [2.8.1, simd construct, Restrictions]
163     // All loops associated with the construct must be perfectly nested; that
164     // is, there must be no intervening code nor any OpenMP directive between
165     // any two loops.
166     if (auto *For = dyn_cast<ForStmt>(CurStmt)) {
167       CurStmt = For->getBody();
168     } else {
169       assert(isa<CXXForRangeStmt>(CurStmt) &&
170              "Expected canonical for or range-based for loops.");
171       CurStmt = cast<CXXForRangeStmt>(CurStmt)->getBody();
172     }
173     CurStmt = OMPLoopBasedDirective::tryToFindNextInnerLoop(
174         CurStmt, TryImperfectlyNestedLoops);
175   }
176   return true;
177 }
178 
doForAllLoopsBodies(Stmt * CurStmt,bool TryImperfectlyNestedLoops,unsigned NumLoops,llvm::function_ref<void (unsigned,Stmt *,Stmt *)> Callback)179 void OMPLoopBasedDirective::doForAllLoopsBodies(
180     Stmt *CurStmt, bool TryImperfectlyNestedLoops, unsigned NumLoops,
181     llvm::function_ref<void(unsigned, Stmt *, Stmt *)> Callback) {
182   bool Res = OMPLoopBasedDirective::doForAllLoops(
183       CurStmt, TryImperfectlyNestedLoops, NumLoops,
184       [Callback](unsigned Cnt, Stmt *Loop) {
185         Stmt *Body = nullptr;
186         if (auto *For = dyn_cast<ForStmt>(Loop)) {
187           Body = For->getBody();
188         } else {
189           assert(isa<CXXForRangeStmt>(Loop) &&
190                  "Expected canonical for or range-based for loops.");
191           Body = cast<CXXForRangeStmt>(Loop)->getBody();
192         }
193         if (auto *CanonLoop = dyn_cast<OMPCanonicalLoop>(Body))
194           Body = CanonLoop->getLoopStmt();
195         Callback(Cnt, Loop, Body);
196         return false;
197       });
198   assert(Res && "Expected only loops");
199   (void)Res;
200 }
201 
getBody()202 Stmt *OMPLoopDirective::getBody() {
203   // This relies on the loop form is already checked by Sema.
204   Stmt *Body = nullptr;
205   OMPLoopBasedDirective::doForAllLoopsBodies(
206       Data->getRawStmt(), /*TryImperfectlyNestedLoops=*/true,
207       NumAssociatedLoops,
208       [&Body](unsigned, Stmt *, Stmt *BodyStmt) { Body = BodyStmt; });
209   return Body;
210 }
211 
setCounters(ArrayRef<Expr * > A)212 void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
213   assert(A.size() == getLoopsNumber() &&
214          "Number of loop counters is not the same as the collapsed number");
215   llvm::copy(A, getCounters().begin());
216 }
217 
setPrivateCounters(ArrayRef<Expr * > A)218 void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
219   assert(A.size() == getLoopsNumber() && "Number of loop private counters "
220                                          "is not the same as the collapsed "
221                                          "number");
222   llvm::copy(A, getPrivateCounters().begin());
223 }
224 
setInits(ArrayRef<Expr * > A)225 void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
226   assert(A.size() == getLoopsNumber() &&
227          "Number of counter inits is not the same as the collapsed number");
228   llvm::copy(A, getInits().begin());
229 }
230 
setUpdates(ArrayRef<Expr * > A)231 void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
232   assert(A.size() == getLoopsNumber() &&
233          "Number of counter updates is not the same as the collapsed number");
234   llvm::copy(A, getUpdates().begin());
235 }
236 
setFinals(ArrayRef<Expr * > A)237 void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
238   assert(A.size() == getLoopsNumber() &&
239          "Number of counter finals is not the same as the collapsed number");
240   llvm::copy(A, getFinals().begin());
241 }
242 
setDependentCounters(ArrayRef<Expr * > A)243 void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) {
244   assert(
245       A.size() == getLoopsNumber() &&
246       "Number of dependent counters is not the same as the collapsed number");
247   llvm::copy(A, getDependentCounters().begin());
248 }
249 
setDependentInits(ArrayRef<Expr * > A)250 void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) {
251   assert(A.size() == getLoopsNumber() &&
252          "Number of dependent inits is not the same as the collapsed number");
253   llvm::copy(A, getDependentInits().begin());
254 }
255 
setFinalsConditions(ArrayRef<Expr * > A)256 void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {
257   assert(A.size() == getLoopsNumber() &&
258          "Number of finals conditions is not the same as the collapsed number");
259   llvm::copy(A, getFinalsConditions().begin());
260 }
261 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Stmt * IfStmt)262 OMPMetaDirective *OMPMetaDirective::Create(const ASTContext &C,
263                                            SourceLocation StartLoc,
264                                            SourceLocation EndLoc,
265                                            ArrayRef<OMPClause *> Clauses,
266                                            Stmt *AssociatedStmt, Stmt *IfStmt) {
267   auto *Dir = createDirective<OMPMetaDirective>(
268       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
269   Dir->setIfStmt(IfStmt);
270   return Dir;
271 }
272 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)273 OMPMetaDirective *OMPMetaDirective::CreateEmpty(const ASTContext &C,
274                                                 unsigned NumClauses,
275                                                 EmptyShell) {
276   return createEmptyDirective<OMPMetaDirective>(C, NumClauses,
277                                                 /*HasAssociatedStmt=*/true,
278                                                 /*NumChildren=*/1);
279 }
280 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * TaskRedRef,bool HasCancel)281 OMPParallelDirective *OMPParallelDirective::Create(
282     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
283     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
284     bool HasCancel) {
285   auto *Dir = createDirective<OMPParallelDirective>(
286       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
287   Dir->setTaskReductionRefExpr(TaskRedRef);
288   Dir->setHasCancel(HasCancel);
289   return Dir;
290 }
291 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)292 OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
293                                                         unsigned NumClauses,
294                                                         EmptyShell) {
295   return createEmptyDirective<OMPParallelDirective>(C, NumClauses,
296                                                     /*HasAssociatedStmt=*/true,
297                                                     /*NumChildren=*/1);
298 }
299 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,OpenMPDirectiveKind ParamPrevMappedDirective)300 OMPSimdDirective *OMPSimdDirective::Create(
301     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
302     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
303     const HelperExprs &Exprs, OpenMPDirectiveKind ParamPrevMappedDirective) {
304   auto *Dir = createDirective<OMPSimdDirective>(
305       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_simd),
306       StartLoc, EndLoc, CollapsedNum);
307   Dir->setIterationVariable(Exprs.IterationVarRef);
308   Dir->setLastIteration(Exprs.LastIteration);
309   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
310   Dir->setPreCond(Exprs.PreCond);
311   Dir->setCond(Exprs.Cond);
312   Dir->setInit(Exprs.Init);
313   Dir->setInc(Exprs.Inc);
314   Dir->setCounters(Exprs.Counters);
315   Dir->setPrivateCounters(Exprs.PrivateCounters);
316   Dir->setInits(Exprs.Inits);
317   Dir->setUpdates(Exprs.Updates);
318   Dir->setFinals(Exprs.Finals);
319   Dir->setDependentCounters(Exprs.DependentCounters);
320   Dir->setDependentInits(Exprs.DependentInits);
321   Dir->setFinalsConditions(Exprs.FinalsConditions);
322   Dir->setPreInits(Exprs.PreInits);
323   Dir->setMappedDirective(ParamPrevMappedDirective);
324   return Dir;
325 }
326 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)327 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
328                                                 unsigned NumClauses,
329                                                 unsigned CollapsedNum,
330                                                 EmptyShell) {
331   return createEmptyDirective<OMPSimdDirective>(
332       C, NumClauses, /*HasAssociatedStmt=*/true,
333       numLoopChildren(CollapsedNum, OMPD_simd), CollapsedNum);
334 }
335 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,Expr * TaskRedRef,bool HasCancel,OpenMPDirectiveKind ParamPrevMappedDirective)336 OMPForDirective *OMPForDirective::Create(
337     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
338     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
339     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel,
340     OpenMPDirectiveKind ParamPrevMappedDirective) {
341   auto *Dir = createDirective<OMPForDirective>(
342       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for) + 1,
343       StartLoc, EndLoc, CollapsedNum);
344   Dir->setIterationVariable(Exprs.IterationVarRef);
345   Dir->setLastIteration(Exprs.LastIteration);
346   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
347   Dir->setPreCond(Exprs.PreCond);
348   Dir->setCond(Exprs.Cond);
349   Dir->setInit(Exprs.Init);
350   Dir->setInc(Exprs.Inc);
351   Dir->setIsLastIterVariable(Exprs.IL);
352   Dir->setLowerBoundVariable(Exprs.LB);
353   Dir->setUpperBoundVariable(Exprs.UB);
354   Dir->setStrideVariable(Exprs.ST);
355   Dir->setEnsureUpperBound(Exprs.EUB);
356   Dir->setNextLowerBound(Exprs.NLB);
357   Dir->setNextUpperBound(Exprs.NUB);
358   Dir->setNumIterations(Exprs.NumIterations);
359   Dir->setCounters(Exprs.Counters);
360   Dir->setPrivateCounters(Exprs.PrivateCounters);
361   Dir->setInits(Exprs.Inits);
362   Dir->setUpdates(Exprs.Updates);
363   Dir->setFinals(Exprs.Finals);
364   Dir->setDependentCounters(Exprs.DependentCounters);
365   Dir->setDependentInits(Exprs.DependentInits);
366   Dir->setFinalsConditions(Exprs.FinalsConditions);
367   Dir->setPreInits(Exprs.PreInits);
368   Dir->setTaskReductionRefExpr(TaskRedRef);
369   Dir->setHasCancel(HasCancel);
370   Dir->setMappedDirective(ParamPrevMappedDirective);
371   return Dir;
372 }
373 
getTransformedStmt() const374 Stmt *OMPLoopTransformationDirective::getTransformedStmt() const {
375   switch (getStmtClass()) {
376 #define STMT(CLASS, PARENT)
377 #define ABSTRACT_STMT(CLASS)
378 #define OMPLOOPTRANSFORMATIONDIRECTIVE(CLASS, PARENT)                          \
379   case Stmt::CLASS##Class:                                                     \
380     return static_cast<const CLASS *>(this)->getTransformedStmt();
381 #include "clang/AST/StmtNodes.inc"
382   default:
383     llvm_unreachable("Not a loop transformation");
384   }
385 }
386 
getPreInits() const387 Stmt *OMPLoopTransformationDirective::getPreInits() const {
388   switch (getStmtClass()) {
389 #define STMT(CLASS, PARENT)
390 #define ABSTRACT_STMT(CLASS)
391 #define OMPLOOPTRANSFORMATIONDIRECTIVE(CLASS, PARENT)                          \
392   case Stmt::CLASS##Class:                                                     \
393     return static_cast<const CLASS *>(this)->getPreInits();
394 #include "clang/AST/StmtNodes.inc"
395   default:
396     llvm_unreachable("Not a loop transformation");
397   }
398 }
399 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)400 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
401                                               unsigned NumClauses,
402                                               unsigned CollapsedNum,
403                                               EmptyShell) {
404   return createEmptyDirective<OMPForDirective>(
405       C, NumClauses, /*HasAssociatedStmt=*/true,
406       numLoopChildren(CollapsedNum, OMPD_for) + 1, CollapsedNum);
407 }
408 
409 OMPTileDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,unsigned NumLoops,Stmt * AssociatedStmt,Stmt * TransformedStmt,Stmt * PreInits)410 OMPTileDirective::Create(const ASTContext &C, SourceLocation StartLoc,
411                          SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
412                          unsigned NumLoops, Stmt *AssociatedStmt,
413                          Stmt *TransformedStmt, Stmt *PreInits) {
414   OMPTileDirective *Dir = createDirective<OMPTileDirective>(
415       C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,
416       NumLoops);
417   Dir->setTransformedStmt(TransformedStmt);
418   Dir->setPreInits(PreInits);
419   return Dir;
420 }
421 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned NumLoops)422 OMPTileDirective *OMPTileDirective::CreateEmpty(const ASTContext &C,
423                                                 unsigned NumClauses,
424                                                 unsigned NumLoops) {
425   return createEmptyDirective<OMPTileDirective>(
426       C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,
427       SourceLocation(), SourceLocation(), NumLoops);
428 }
429 
430 OMPUnrollDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,unsigned NumGeneratedLoops,Stmt * TransformedStmt,Stmt * PreInits)431 OMPUnrollDirective::Create(const ASTContext &C, SourceLocation StartLoc,
432                            SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
433                            Stmt *AssociatedStmt, unsigned NumGeneratedLoops,
434                            Stmt *TransformedStmt, Stmt *PreInits) {
435   assert(NumGeneratedLoops <= 1 && "Unrolling generates at most one loop");
436 
437   auto *Dir = createDirective<OMPUnrollDirective>(
438       C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc);
439   Dir->setNumGeneratedLoops(NumGeneratedLoops);
440   Dir->setTransformedStmt(TransformedStmt);
441   Dir->setPreInits(PreInits);
442   return Dir;
443 }
444 
CreateEmpty(const ASTContext & C,unsigned NumClauses)445 OMPUnrollDirective *OMPUnrollDirective::CreateEmpty(const ASTContext &C,
446                                                     unsigned NumClauses) {
447   return createEmptyDirective<OMPUnrollDirective>(
448       C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,
449       SourceLocation(), SourceLocation());
450 }
451 
452 OMPReverseDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,Stmt * AssociatedStmt,Stmt * TransformedStmt,Stmt * PreInits)453 OMPReverseDirective::Create(const ASTContext &C, SourceLocation StartLoc,
454                             SourceLocation EndLoc, Stmt *AssociatedStmt,
455                             Stmt *TransformedStmt, Stmt *PreInits) {
456   OMPReverseDirective *Dir = createDirective<OMPReverseDirective>(
457       C, std::nullopt, AssociatedStmt, TransformedStmtOffset + 1, StartLoc,
458       EndLoc);
459   Dir->setTransformedStmt(TransformedStmt);
460   Dir->setPreInits(PreInits);
461   return Dir;
462 }
463 
CreateEmpty(const ASTContext & C)464 OMPReverseDirective *OMPReverseDirective::CreateEmpty(const ASTContext &C) {
465   return createEmptyDirective<OMPReverseDirective>(
466       C, /*NumClauses=*/0, /*HasAssociatedStmt=*/true,
467       TransformedStmtOffset + 1, SourceLocation(), SourceLocation());
468 }
469 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,unsigned NumLoops,Stmt * AssociatedStmt,Stmt * TransformedStmt,Stmt * PreInits)470 OMPInterchangeDirective *OMPInterchangeDirective::Create(
471     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
472     ArrayRef<OMPClause *> Clauses, unsigned NumLoops, Stmt *AssociatedStmt,
473     Stmt *TransformedStmt, Stmt *PreInits) {
474   OMPInterchangeDirective *Dir = createDirective<OMPInterchangeDirective>(
475       C, Clauses, AssociatedStmt, TransformedStmtOffset + 1, StartLoc, EndLoc,
476       NumLoops);
477   Dir->setTransformedStmt(TransformedStmt);
478   Dir->setPreInits(PreInits);
479   return Dir;
480 }
481 
482 OMPInterchangeDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned NumLoops)483 OMPInterchangeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
484                                      unsigned NumLoops) {
485   return createEmptyDirective<OMPInterchangeDirective>(
486       C, NumClauses, /*HasAssociatedStmt=*/true, TransformedStmtOffset + 1,
487       SourceLocation(), SourceLocation(), NumLoops);
488 }
489 
490 OMPForSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)491 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
492                             SourceLocation EndLoc, unsigned CollapsedNum,
493                             ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
494                             const HelperExprs &Exprs) {
495   auto *Dir = createDirective<OMPForSimdDirective>(
496       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for_simd),
497       StartLoc, EndLoc, CollapsedNum);
498   Dir->setIterationVariable(Exprs.IterationVarRef);
499   Dir->setLastIteration(Exprs.LastIteration);
500   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
501   Dir->setPreCond(Exprs.PreCond);
502   Dir->setCond(Exprs.Cond);
503   Dir->setInit(Exprs.Init);
504   Dir->setInc(Exprs.Inc);
505   Dir->setIsLastIterVariable(Exprs.IL);
506   Dir->setLowerBoundVariable(Exprs.LB);
507   Dir->setUpperBoundVariable(Exprs.UB);
508   Dir->setStrideVariable(Exprs.ST);
509   Dir->setEnsureUpperBound(Exprs.EUB);
510   Dir->setNextLowerBound(Exprs.NLB);
511   Dir->setNextUpperBound(Exprs.NUB);
512   Dir->setNumIterations(Exprs.NumIterations);
513   Dir->setCounters(Exprs.Counters);
514   Dir->setPrivateCounters(Exprs.PrivateCounters);
515   Dir->setInits(Exprs.Inits);
516   Dir->setUpdates(Exprs.Updates);
517   Dir->setFinals(Exprs.Finals);
518   Dir->setDependentCounters(Exprs.DependentCounters);
519   Dir->setDependentInits(Exprs.DependentInits);
520   Dir->setFinalsConditions(Exprs.FinalsConditions);
521   Dir->setPreInits(Exprs.PreInits);
522   return Dir;
523 }
524 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)525 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
526                                                       unsigned NumClauses,
527                                                       unsigned CollapsedNum,
528                                                       EmptyShell) {
529   return createEmptyDirective<OMPForSimdDirective>(
530       C, NumClauses, /*HasAssociatedStmt=*/true,
531       numLoopChildren(CollapsedNum, OMPD_for_simd), CollapsedNum);
532 }
533 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * TaskRedRef,bool HasCancel)534 OMPSectionsDirective *OMPSectionsDirective::Create(
535     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
536     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
537     bool HasCancel) {
538   auto *Dir = createDirective<OMPSectionsDirective>(C, Clauses, AssociatedStmt,
539                                                     /*NumChildren=*/1, StartLoc,
540                                                     EndLoc);
541   Dir->setTaskReductionRefExpr(TaskRedRef);
542   Dir->setHasCancel(HasCancel);
543   return Dir;
544 }
545 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)546 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
547                                                         unsigned NumClauses,
548                                                         EmptyShell) {
549   return createEmptyDirective<OMPSectionsDirective>(C, NumClauses,
550                                                     /*HasAssociatedStmt=*/true,
551                                                     /*NumChildren=*/1);
552 }
553 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,Stmt * AssociatedStmt,bool HasCancel)554 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
555                                                  SourceLocation StartLoc,
556                                                  SourceLocation EndLoc,
557                                                  Stmt *AssociatedStmt,
558                                                  bool HasCancel) {
559   auto *Dir =
560       createDirective<OMPSectionDirective>(C, std::nullopt, AssociatedStmt,
561                                            /*NumChildren=*/0, StartLoc, EndLoc);
562   Dir->setHasCancel(HasCancel);
563   return Dir;
564 }
565 
CreateEmpty(const ASTContext & C,EmptyShell)566 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
567                                                       EmptyShell) {
568   return createEmptyDirective<OMPSectionDirective>(C, /*NumClauses=*/0,
569                                                    /*HasAssociatedStmt=*/true);
570 }
571 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)572 OMPScopeDirective *OMPScopeDirective::Create(const ASTContext &C,
573                                              SourceLocation StartLoc,
574                                              SourceLocation EndLoc,
575                                              ArrayRef<OMPClause *> Clauses,
576                                              Stmt *AssociatedStmt) {
577   return createDirective<OMPScopeDirective>(C, Clauses, AssociatedStmt,
578                                             /*NumChildren=*/0, StartLoc,
579                                             EndLoc);
580 }
581 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)582 OMPScopeDirective *OMPScopeDirective::CreateEmpty(const ASTContext &C,
583                                                   unsigned NumClauses,
584                                                   EmptyShell) {
585   return createEmptyDirective<OMPScopeDirective>(C, NumClauses,
586                                                  /*HasAssociatedStmt=*/true);
587 }
588 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)589 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
590                                                SourceLocation StartLoc,
591                                                SourceLocation EndLoc,
592                                                ArrayRef<OMPClause *> Clauses,
593                                                Stmt *AssociatedStmt) {
594   return createDirective<OMPSingleDirective>(C, Clauses, AssociatedStmt,
595                                              /*NumChildren=*/0, StartLoc,
596                                              EndLoc);
597 }
598 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)599 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
600                                                     unsigned NumClauses,
601                                                     EmptyShell) {
602   return createEmptyDirective<OMPSingleDirective>(C, NumClauses,
603                                                   /*HasAssociatedStmt=*/true);
604 }
605 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,Stmt * AssociatedStmt)606 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
607                                                SourceLocation StartLoc,
608                                                SourceLocation EndLoc,
609                                                Stmt *AssociatedStmt) {
610   return createDirective<OMPMasterDirective>(C, std::nullopt, AssociatedStmt,
611                                              /*NumChildren=*/0, StartLoc,
612                                              EndLoc);
613 }
614 
CreateEmpty(const ASTContext & C,EmptyShell)615 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
616                                                     EmptyShell) {
617   return createEmptyDirective<OMPMasterDirective>(C, /*NumClauses=*/0,
618                                                   /*HasAssociatedStmt=*/true);
619 }
620 
Create(const ASTContext & C,const DeclarationNameInfo & Name,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)621 OMPCriticalDirective *OMPCriticalDirective::Create(
622     const ASTContext &C, const DeclarationNameInfo &Name,
623     SourceLocation StartLoc, SourceLocation EndLoc,
624     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
625   return createDirective<OMPCriticalDirective>(C, Clauses, AssociatedStmt,
626                                                /*NumChildren=*/0, Name,
627                                                StartLoc, EndLoc);
628 }
629 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)630 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
631                                                         unsigned NumClauses,
632                                                         EmptyShell) {
633   return createEmptyDirective<OMPCriticalDirective>(C, NumClauses,
634                                                     /*HasAssociatedStmt=*/true);
635 }
636 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,Expr * TaskRedRef,bool HasCancel)637 OMPParallelForDirective *OMPParallelForDirective::Create(
638     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
639     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
640     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
641   auto *Dir = createDirective<OMPParallelForDirective>(
642       C, Clauses, AssociatedStmt,
643       numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, StartLoc, EndLoc,
644       CollapsedNum);
645   Dir->setIterationVariable(Exprs.IterationVarRef);
646   Dir->setLastIteration(Exprs.LastIteration);
647   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
648   Dir->setPreCond(Exprs.PreCond);
649   Dir->setCond(Exprs.Cond);
650   Dir->setInit(Exprs.Init);
651   Dir->setInc(Exprs.Inc);
652   Dir->setIsLastIterVariable(Exprs.IL);
653   Dir->setLowerBoundVariable(Exprs.LB);
654   Dir->setUpperBoundVariable(Exprs.UB);
655   Dir->setStrideVariable(Exprs.ST);
656   Dir->setEnsureUpperBound(Exprs.EUB);
657   Dir->setNextLowerBound(Exprs.NLB);
658   Dir->setNextUpperBound(Exprs.NUB);
659   Dir->setNumIterations(Exprs.NumIterations);
660   Dir->setCounters(Exprs.Counters);
661   Dir->setPrivateCounters(Exprs.PrivateCounters);
662   Dir->setInits(Exprs.Inits);
663   Dir->setUpdates(Exprs.Updates);
664   Dir->setFinals(Exprs.Finals);
665   Dir->setDependentCounters(Exprs.DependentCounters);
666   Dir->setDependentInits(Exprs.DependentInits);
667   Dir->setFinalsConditions(Exprs.FinalsConditions);
668   Dir->setPreInits(Exprs.PreInits);
669   Dir->setTaskReductionRefExpr(TaskRedRef);
670   Dir->setHasCancel(HasCancel);
671   return Dir;
672 }
673 
674 OMPParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)675 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
676                                      unsigned CollapsedNum, EmptyShell) {
677   return createEmptyDirective<OMPParallelForDirective>(
678       C, NumClauses, /*HasAssociatedStmt=*/true,
679       numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, CollapsedNum);
680 }
681 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)682 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
683     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
684     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
685     const HelperExprs &Exprs) {
686   auto *Dir = createDirective<OMPParallelForSimdDirective>(
687       C, Clauses, AssociatedStmt,
688       numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), StartLoc, EndLoc,
689       CollapsedNum);
690   Dir->setIterationVariable(Exprs.IterationVarRef);
691   Dir->setLastIteration(Exprs.LastIteration);
692   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
693   Dir->setPreCond(Exprs.PreCond);
694   Dir->setCond(Exprs.Cond);
695   Dir->setInit(Exprs.Init);
696   Dir->setInc(Exprs.Inc);
697   Dir->setIsLastIterVariable(Exprs.IL);
698   Dir->setLowerBoundVariable(Exprs.LB);
699   Dir->setUpperBoundVariable(Exprs.UB);
700   Dir->setStrideVariable(Exprs.ST);
701   Dir->setEnsureUpperBound(Exprs.EUB);
702   Dir->setNextLowerBound(Exprs.NLB);
703   Dir->setNextUpperBound(Exprs.NUB);
704   Dir->setNumIterations(Exprs.NumIterations);
705   Dir->setCounters(Exprs.Counters);
706   Dir->setPrivateCounters(Exprs.PrivateCounters);
707   Dir->setInits(Exprs.Inits);
708   Dir->setUpdates(Exprs.Updates);
709   Dir->setFinals(Exprs.Finals);
710   Dir->setDependentCounters(Exprs.DependentCounters);
711   Dir->setDependentInits(Exprs.DependentInits);
712   Dir->setFinalsConditions(Exprs.FinalsConditions);
713   Dir->setPreInits(Exprs.PreInits);
714   return Dir;
715 }
716 
717 OMPParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)718 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
719                                          unsigned NumClauses,
720                                          unsigned CollapsedNum, EmptyShell) {
721   return createEmptyDirective<OMPParallelForSimdDirective>(
722       C, NumClauses, /*HasAssociatedStmt=*/true,
723       numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), CollapsedNum);
724 }
725 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * TaskRedRef)726 OMPParallelMasterDirective *OMPParallelMasterDirective::Create(
727     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
728     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {
729   auto *Dir = createDirective<OMPParallelMasterDirective>(
730       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
731   Dir->setTaskReductionRefExpr(TaskRedRef);
732   return Dir;
733 }
734 
735 OMPParallelMasterDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)736 OMPParallelMasterDirective::CreateEmpty(const ASTContext &C,
737                                         unsigned NumClauses, EmptyShell) {
738   return createEmptyDirective<OMPParallelMasterDirective>(
739       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
740 }
741 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * TaskRedRef)742 OMPParallelMaskedDirective *OMPParallelMaskedDirective::Create(
743     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
744     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {
745   auto *Dir = createDirective<OMPParallelMaskedDirective>(
746       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
747   Dir->setTaskReductionRefExpr(TaskRedRef);
748   return Dir;
749 }
750 
751 OMPParallelMaskedDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)752 OMPParallelMaskedDirective::CreateEmpty(const ASTContext &C,
753                                         unsigned NumClauses, EmptyShell) {
754   return createEmptyDirective<OMPParallelMaskedDirective>(
755       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
756 }
757 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * TaskRedRef,bool HasCancel)758 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
759     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
760     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
761     bool HasCancel) {
762   auto *Dir = createDirective<OMPParallelSectionsDirective>(
763       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
764   Dir->setTaskReductionRefExpr(TaskRedRef);
765   Dir->setHasCancel(HasCancel);
766   return Dir;
767 }
768 
769 OMPParallelSectionsDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)770 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
771                                           unsigned NumClauses, EmptyShell) {
772   return createEmptyDirective<OMPParallelSectionsDirective>(
773       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
774 }
775 
776 OMPTaskDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,bool HasCancel)777 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
778                          SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
779                          Stmt *AssociatedStmt, bool HasCancel) {
780   auto *Dir = createDirective<OMPTaskDirective>(
781       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
782   Dir->setHasCancel(HasCancel);
783   return Dir;
784 }
785 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)786 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
787                                                 unsigned NumClauses,
788                                                 EmptyShell) {
789   return createEmptyDirective<OMPTaskDirective>(C, NumClauses,
790                                                 /*HasAssociatedStmt=*/true);
791 }
792 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc)793 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
794                                                      SourceLocation StartLoc,
795                                                      SourceLocation EndLoc) {
796   return new (C) OMPTaskyieldDirective(StartLoc, EndLoc);
797 }
798 
CreateEmpty(const ASTContext & C,EmptyShell)799 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
800                                                           EmptyShell) {
801   return new (C) OMPTaskyieldDirective();
802 }
803 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)804 OMPErrorDirective *OMPErrorDirective::Create(const ASTContext &C,
805                                              SourceLocation StartLoc,
806                                              SourceLocation EndLoc,
807                                              ArrayRef<OMPClause *> Clauses) {
808   return createDirective<OMPErrorDirective>(
809       C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
810       EndLoc);
811 }
812 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)813 OMPErrorDirective *OMPErrorDirective::CreateEmpty(const ASTContext &C,
814                                                   unsigned NumClauses,
815                                                   EmptyShell) {
816   return createEmptyDirective<OMPErrorDirective>(C, NumClauses);
817 }
818 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc)819 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
820                                                  SourceLocation StartLoc,
821                                                  SourceLocation EndLoc) {
822   return new (C) OMPBarrierDirective(StartLoc, EndLoc);
823 }
824 
CreateEmpty(const ASTContext & C,EmptyShell)825 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
826                                                       EmptyShell) {
827   return new (C) OMPBarrierDirective();
828 }
829 
830 OMPTaskwaitDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)831 OMPTaskwaitDirective::Create(const ASTContext &C, SourceLocation StartLoc,
832                              SourceLocation EndLoc,
833                              ArrayRef<OMPClause *> Clauses) {
834   return createDirective<OMPTaskwaitDirective>(
835       C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
836       EndLoc);
837 }
838 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)839 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
840                                                         unsigned NumClauses,
841                                                         EmptyShell) {
842   return createEmptyDirective<OMPTaskwaitDirective>(C, NumClauses);
843 }
844 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * ReductionRef)845 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
846     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
847     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
848   auto *Dir = createDirective<OMPTaskgroupDirective>(
849       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
850   Dir->setReductionRef(ReductionRef);
851   return Dir;
852 }
853 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)854 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
855                                                           unsigned NumClauses,
856                                                           EmptyShell) {
857   return createEmptyDirective<OMPTaskgroupDirective>(
858       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
859 }
860 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,OpenMPDirectiveKind CancelRegion)861 OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
862     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
863     OpenMPDirectiveKind CancelRegion) {
864   auto *Dir = new (C) OMPCancellationPointDirective(StartLoc, EndLoc);
865   Dir->setCancelRegion(CancelRegion);
866   return Dir;
867 }
868 
869 OMPCancellationPointDirective *
CreateEmpty(const ASTContext & C,EmptyShell)870 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
871   return new (C) OMPCancellationPointDirective();
872 }
873 
874 OMPCancelDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,OpenMPDirectiveKind CancelRegion)875 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
876                            SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
877                            OpenMPDirectiveKind CancelRegion) {
878   auto *Dir = createDirective<OMPCancelDirective>(
879       C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
880       EndLoc);
881   Dir->setCancelRegion(CancelRegion);
882   return Dir;
883 }
884 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)885 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
886                                                     unsigned NumClauses,
887                                                     EmptyShell) {
888   return createEmptyDirective<OMPCancelDirective>(C, NumClauses);
889 }
890 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)891 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
892                                              SourceLocation StartLoc,
893                                              SourceLocation EndLoc,
894                                              ArrayRef<OMPClause *> Clauses) {
895   return createDirective<OMPFlushDirective>(
896       C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
897       EndLoc);
898 }
899 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)900 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
901                                                   unsigned NumClauses,
902                                                   EmptyShell) {
903   return createEmptyDirective<OMPFlushDirective>(C, NumClauses);
904 }
905 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)906 OMPDepobjDirective *OMPDepobjDirective::Create(const ASTContext &C,
907                                                SourceLocation StartLoc,
908                                                SourceLocation EndLoc,
909                                                ArrayRef<OMPClause *> Clauses) {
910   return createDirective<OMPDepobjDirective>(
911       C, Clauses, /*AssociatedStmt=*/nullptr,
912       /*NumChildren=*/0, StartLoc, EndLoc);
913 }
914 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)915 OMPDepobjDirective *OMPDepobjDirective::CreateEmpty(const ASTContext &C,
916                                                     unsigned NumClauses,
917                                                     EmptyShell) {
918   return createEmptyDirective<OMPDepobjDirective>(C, NumClauses);
919 }
920 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)921 OMPScanDirective *OMPScanDirective::Create(const ASTContext &C,
922                                            SourceLocation StartLoc,
923                                            SourceLocation EndLoc,
924                                            ArrayRef<OMPClause *> Clauses) {
925   return createDirective<OMPScanDirective>(C, Clauses,
926                                            /*AssociatedStmt=*/nullptr,
927                                            /*NumChildren=*/0, StartLoc, EndLoc);
928 }
929 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)930 OMPScanDirective *OMPScanDirective::CreateEmpty(const ASTContext &C,
931                                                 unsigned NumClauses,
932                                                 EmptyShell) {
933   return createEmptyDirective<OMPScanDirective>(C, NumClauses);
934 }
935 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)936 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
937                                                  SourceLocation StartLoc,
938                                                  SourceLocation EndLoc,
939                                                  ArrayRef<OMPClause *> Clauses,
940                                                  Stmt *AssociatedStmt) {
941   return createDirective<OMPOrderedDirective>(
942       C, Clauses, cast_or_null<CapturedStmt>(AssociatedStmt),
943       /*NumChildren=*/0, StartLoc, EndLoc);
944 }
945 
CreateEmpty(const ASTContext & C,unsigned NumClauses,bool IsStandalone,EmptyShell)946 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
947                                                       unsigned NumClauses,
948                                                       bool IsStandalone,
949                                                       EmptyShell) {
950   return createEmptyDirective<OMPOrderedDirective>(C, NumClauses,
951                                                    !IsStandalone);
952 }
953 
954 OMPAtomicDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expressions Exprs)955 OMPAtomicDirective::Create(const ASTContext &C, SourceLocation StartLoc,
956                            SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
957                            Stmt *AssociatedStmt, Expressions Exprs) {
958   auto *Dir = createDirective<OMPAtomicDirective>(
959       C, Clauses, AssociatedStmt, /*NumChildren=*/7, StartLoc, EndLoc);
960   Dir->setX(Exprs.X);
961   Dir->setV(Exprs.V);
962   Dir->setR(Exprs.R);
963   Dir->setExpr(Exprs.E);
964   Dir->setUpdateExpr(Exprs.UE);
965   Dir->setD(Exprs.D);
966   Dir->setCond(Exprs.Cond);
967   Dir->Flags.IsXLHSInRHSPart = Exprs.IsXLHSInRHSPart ? 1 : 0;
968   Dir->Flags.IsPostfixUpdate = Exprs.IsPostfixUpdate ? 1 : 0;
969   Dir->Flags.IsFailOnly = Exprs.IsFailOnly ? 1 : 0;
970   return Dir;
971 }
972 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)973 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
974                                                     unsigned NumClauses,
975                                                     EmptyShell) {
976   return createEmptyDirective<OMPAtomicDirective>(
977       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/7);
978 }
979 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)980 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
981                                                SourceLocation StartLoc,
982                                                SourceLocation EndLoc,
983                                                ArrayRef<OMPClause *> Clauses,
984                                                Stmt *AssociatedStmt) {
985   return createDirective<OMPTargetDirective>(
986       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
987 }
988 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)989 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
990                                                     unsigned NumClauses,
991                                                     EmptyShell) {
992   return createEmptyDirective<OMPTargetDirective>(C, NumClauses,
993                                                   /*HasAssociatedStmt=*/true);
994 }
995 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * TaskRedRef,bool HasCancel)996 OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
997     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
998     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
999     bool HasCancel) {
1000   auto *Dir = createDirective<OMPTargetParallelDirective>(
1001       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
1002   Dir->setTaskReductionRefExpr(TaskRedRef);
1003   Dir->setHasCancel(HasCancel);
1004   return Dir;
1005 }
1006 
1007 OMPTargetParallelDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)1008 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
1009                                         unsigned NumClauses, EmptyShell) {
1010   return createEmptyDirective<OMPTargetParallelDirective>(
1011       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
1012 }
1013 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,Expr * TaskRedRef,bool HasCancel)1014 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
1015     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1016     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1017     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1018   auto *Dir = createDirective<OMPTargetParallelForDirective>(
1019       C, Clauses, AssociatedStmt,
1020       numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1, StartLoc,
1021       EndLoc, CollapsedNum);
1022   Dir->setIterationVariable(Exprs.IterationVarRef);
1023   Dir->setLastIteration(Exprs.LastIteration);
1024   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1025   Dir->setPreCond(Exprs.PreCond);
1026   Dir->setCond(Exprs.Cond);
1027   Dir->setInit(Exprs.Init);
1028   Dir->setInc(Exprs.Inc);
1029   Dir->setIsLastIterVariable(Exprs.IL);
1030   Dir->setLowerBoundVariable(Exprs.LB);
1031   Dir->setUpperBoundVariable(Exprs.UB);
1032   Dir->setStrideVariable(Exprs.ST);
1033   Dir->setEnsureUpperBound(Exprs.EUB);
1034   Dir->setNextLowerBound(Exprs.NLB);
1035   Dir->setNextUpperBound(Exprs.NUB);
1036   Dir->setNumIterations(Exprs.NumIterations);
1037   Dir->setCounters(Exprs.Counters);
1038   Dir->setPrivateCounters(Exprs.PrivateCounters);
1039   Dir->setInits(Exprs.Inits);
1040   Dir->setUpdates(Exprs.Updates);
1041   Dir->setFinals(Exprs.Finals);
1042   Dir->setDependentCounters(Exprs.DependentCounters);
1043   Dir->setDependentInits(Exprs.DependentInits);
1044   Dir->setFinalsConditions(Exprs.FinalsConditions);
1045   Dir->setPreInits(Exprs.PreInits);
1046   Dir->setTaskReductionRefExpr(TaskRedRef);
1047   Dir->setHasCancel(HasCancel);
1048   return Dir;
1049 }
1050 
1051 OMPTargetParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1052 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
1053                                            unsigned NumClauses,
1054                                            unsigned CollapsedNum, EmptyShell) {
1055   return createEmptyDirective<OMPTargetParallelForDirective>(
1056       C, NumClauses, /*HasAssociatedStmt=*/true,
1057       numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1,
1058       CollapsedNum);
1059 }
1060 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)1061 OMPTargetDataDirective *OMPTargetDataDirective::Create(
1062     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1063     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1064   return createDirective<OMPTargetDataDirective>(
1065       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
1066 }
1067 
CreateEmpty(const ASTContext & C,unsigned N,EmptyShell)1068 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
1069                                                             unsigned N,
1070                                                             EmptyShell) {
1071   return createEmptyDirective<OMPTargetDataDirective>(
1072       C, N, /*HasAssociatedStmt=*/true);
1073 }
1074 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)1075 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
1076     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1077     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1078   return createDirective<OMPTargetEnterDataDirective>(
1079       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
1080 }
1081 
1082 OMPTargetEnterDataDirective *
CreateEmpty(const ASTContext & C,unsigned N,EmptyShell)1083 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
1084                                          EmptyShell) {
1085   return createEmptyDirective<OMPTargetEnterDataDirective>(
1086       C, N, /*HasAssociatedStmt=*/true);
1087 }
1088 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)1089 OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
1090     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1091     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1092   return createDirective<OMPTargetExitDataDirective>(
1093       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
1094 }
1095 
1096 OMPTargetExitDataDirective *
CreateEmpty(const ASTContext & C,unsigned N,EmptyShell)1097 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
1098                                         EmptyShell) {
1099   return createEmptyDirective<OMPTargetExitDataDirective>(
1100       C, N, /*HasAssociatedStmt=*/true);
1101 }
1102 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)1103 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
1104                                              SourceLocation StartLoc,
1105                                              SourceLocation EndLoc,
1106                                              ArrayRef<OMPClause *> Clauses,
1107                                              Stmt *AssociatedStmt) {
1108   return createDirective<OMPTeamsDirective>(
1109       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
1110 }
1111 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)1112 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
1113                                                   unsigned NumClauses,
1114                                                   EmptyShell) {
1115   return createEmptyDirective<OMPTeamsDirective>(C, NumClauses,
1116                                                  /*HasAssociatedStmt=*/true);
1117 }
1118 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)1119 OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
1120     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1121     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1122     const HelperExprs &Exprs, bool HasCancel) {
1123   auto *Dir = createDirective<OMPTaskLoopDirective>(
1124       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_taskloop),
1125       StartLoc, EndLoc, CollapsedNum);
1126   Dir->setIterationVariable(Exprs.IterationVarRef);
1127   Dir->setLastIteration(Exprs.LastIteration);
1128   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1129   Dir->setPreCond(Exprs.PreCond);
1130   Dir->setCond(Exprs.Cond);
1131   Dir->setInit(Exprs.Init);
1132   Dir->setInc(Exprs.Inc);
1133   Dir->setIsLastIterVariable(Exprs.IL);
1134   Dir->setLowerBoundVariable(Exprs.LB);
1135   Dir->setUpperBoundVariable(Exprs.UB);
1136   Dir->setStrideVariable(Exprs.ST);
1137   Dir->setEnsureUpperBound(Exprs.EUB);
1138   Dir->setNextLowerBound(Exprs.NLB);
1139   Dir->setNextUpperBound(Exprs.NUB);
1140   Dir->setNumIterations(Exprs.NumIterations);
1141   Dir->setCounters(Exprs.Counters);
1142   Dir->setPrivateCounters(Exprs.PrivateCounters);
1143   Dir->setInits(Exprs.Inits);
1144   Dir->setUpdates(Exprs.Updates);
1145   Dir->setFinals(Exprs.Finals);
1146   Dir->setDependentCounters(Exprs.DependentCounters);
1147   Dir->setDependentInits(Exprs.DependentInits);
1148   Dir->setFinalsConditions(Exprs.FinalsConditions);
1149   Dir->setPreInits(Exprs.PreInits);
1150   Dir->setHasCancel(HasCancel);
1151   return Dir;
1152 }
1153 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1154 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
1155                                                         unsigned NumClauses,
1156                                                         unsigned CollapsedNum,
1157                                                         EmptyShell) {
1158   return createEmptyDirective<OMPTaskLoopDirective>(
1159       C, NumClauses, /*HasAssociatedStmt=*/true,
1160       numLoopChildren(CollapsedNum, OMPD_taskloop), CollapsedNum);
1161 }
1162 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1163 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
1164     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1165     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1166     const HelperExprs &Exprs) {
1167   auto *Dir = createDirective<OMPTaskLoopSimdDirective>(
1168       C, Clauses, AssociatedStmt,
1169       numLoopChildren(CollapsedNum, OMPD_taskloop_simd), StartLoc, EndLoc,
1170       CollapsedNum);
1171   Dir->setIterationVariable(Exprs.IterationVarRef);
1172   Dir->setLastIteration(Exprs.LastIteration);
1173   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1174   Dir->setPreCond(Exprs.PreCond);
1175   Dir->setCond(Exprs.Cond);
1176   Dir->setInit(Exprs.Init);
1177   Dir->setInc(Exprs.Inc);
1178   Dir->setIsLastIterVariable(Exprs.IL);
1179   Dir->setLowerBoundVariable(Exprs.LB);
1180   Dir->setUpperBoundVariable(Exprs.UB);
1181   Dir->setStrideVariable(Exprs.ST);
1182   Dir->setEnsureUpperBound(Exprs.EUB);
1183   Dir->setNextLowerBound(Exprs.NLB);
1184   Dir->setNextUpperBound(Exprs.NUB);
1185   Dir->setNumIterations(Exprs.NumIterations);
1186   Dir->setCounters(Exprs.Counters);
1187   Dir->setPrivateCounters(Exprs.PrivateCounters);
1188   Dir->setInits(Exprs.Inits);
1189   Dir->setUpdates(Exprs.Updates);
1190   Dir->setFinals(Exprs.Finals);
1191   Dir->setDependentCounters(Exprs.DependentCounters);
1192   Dir->setDependentInits(Exprs.DependentInits);
1193   Dir->setFinalsConditions(Exprs.FinalsConditions);
1194   Dir->setPreInits(Exprs.PreInits);
1195   return Dir;
1196 }
1197 
1198 OMPTaskLoopSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1199 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1200                                       unsigned CollapsedNum, EmptyShell) {
1201   return createEmptyDirective<OMPTaskLoopSimdDirective>(
1202       C, NumClauses, /*HasAssociatedStmt=*/true,
1203       numLoopChildren(CollapsedNum, OMPD_taskloop_simd), CollapsedNum);
1204 }
1205 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)1206 OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
1207     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1208     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1209     const HelperExprs &Exprs, bool HasCancel) {
1210   auto *Dir = createDirective<OMPMasterTaskLoopDirective>(
1211       C, Clauses, AssociatedStmt,
1212       numLoopChildren(CollapsedNum, OMPD_master_taskloop), StartLoc, EndLoc,
1213       CollapsedNum);
1214   Dir->setIterationVariable(Exprs.IterationVarRef);
1215   Dir->setLastIteration(Exprs.LastIteration);
1216   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1217   Dir->setPreCond(Exprs.PreCond);
1218   Dir->setCond(Exprs.Cond);
1219   Dir->setInit(Exprs.Init);
1220   Dir->setInc(Exprs.Inc);
1221   Dir->setIsLastIterVariable(Exprs.IL);
1222   Dir->setLowerBoundVariable(Exprs.LB);
1223   Dir->setUpperBoundVariable(Exprs.UB);
1224   Dir->setStrideVariable(Exprs.ST);
1225   Dir->setEnsureUpperBound(Exprs.EUB);
1226   Dir->setNextLowerBound(Exprs.NLB);
1227   Dir->setNextUpperBound(Exprs.NUB);
1228   Dir->setNumIterations(Exprs.NumIterations);
1229   Dir->setCounters(Exprs.Counters);
1230   Dir->setPrivateCounters(Exprs.PrivateCounters);
1231   Dir->setInits(Exprs.Inits);
1232   Dir->setUpdates(Exprs.Updates);
1233   Dir->setFinals(Exprs.Finals);
1234   Dir->setDependentCounters(Exprs.DependentCounters);
1235   Dir->setDependentInits(Exprs.DependentInits);
1236   Dir->setFinalsConditions(Exprs.FinalsConditions);
1237   Dir->setPreInits(Exprs.PreInits);
1238   Dir->setHasCancel(HasCancel);
1239   return Dir;
1240 }
1241 
1242 OMPMasterTaskLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1243 OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1244                                         unsigned NumClauses,
1245                                         unsigned CollapsedNum, EmptyShell) {
1246   return createEmptyDirective<OMPMasterTaskLoopDirective>(
1247       C, NumClauses, /*HasAssociatedStmt=*/true,
1248       numLoopChildren(CollapsedNum, OMPD_master_taskloop), CollapsedNum);
1249 }
1250 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)1251 OMPMaskedTaskLoopDirective *OMPMaskedTaskLoopDirective::Create(
1252     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1253     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1254     const HelperExprs &Exprs, bool HasCancel) {
1255   auto *Dir = createDirective<OMPMaskedTaskLoopDirective>(
1256       C, Clauses, AssociatedStmt,
1257       numLoopChildren(CollapsedNum, OMPD_masked_taskloop), StartLoc, EndLoc,
1258       CollapsedNum);
1259   Dir->setIterationVariable(Exprs.IterationVarRef);
1260   Dir->setLastIteration(Exprs.LastIteration);
1261   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1262   Dir->setPreCond(Exprs.PreCond);
1263   Dir->setCond(Exprs.Cond);
1264   Dir->setInit(Exprs.Init);
1265   Dir->setInc(Exprs.Inc);
1266   Dir->setIsLastIterVariable(Exprs.IL);
1267   Dir->setLowerBoundVariable(Exprs.LB);
1268   Dir->setUpperBoundVariable(Exprs.UB);
1269   Dir->setStrideVariable(Exprs.ST);
1270   Dir->setEnsureUpperBound(Exprs.EUB);
1271   Dir->setNextLowerBound(Exprs.NLB);
1272   Dir->setNextUpperBound(Exprs.NUB);
1273   Dir->setNumIterations(Exprs.NumIterations);
1274   Dir->setCounters(Exprs.Counters);
1275   Dir->setPrivateCounters(Exprs.PrivateCounters);
1276   Dir->setInits(Exprs.Inits);
1277   Dir->setUpdates(Exprs.Updates);
1278   Dir->setFinals(Exprs.Finals);
1279   Dir->setDependentCounters(Exprs.DependentCounters);
1280   Dir->setDependentInits(Exprs.DependentInits);
1281   Dir->setFinalsConditions(Exprs.FinalsConditions);
1282   Dir->setPreInits(Exprs.PreInits);
1283   Dir->setHasCancel(HasCancel);
1284   return Dir;
1285 }
1286 
1287 OMPMaskedTaskLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1288 OMPMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,
1289                                         unsigned NumClauses,
1290                                         unsigned CollapsedNum, EmptyShell) {
1291   return createEmptyDirective<OMPMaskedTaskLoopDirective>(
1292       C, NumClauses, /*HasAssociatedStmt=*/true,
1293       numLoopChildren(CollapsedNum, OMPD_masked_taskloop), CollapsedNum);
1294 }
1295 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1296 OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
1297     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1298     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1299     const HelperExprs &Exprs) {
1300   auto *Dir = createDirective<OMPMasterTaskLoopSimdDirective>(
1301       C, Clauses, AssociatedStmt,
1302       numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), StartLoc,
1303       EndLoc, CollapsedNum);
1304   Dir->setIterationVariable(Exprs.IterationVarRef);
1305   Dir->setLastIteration(Exprs.LastIteration);
1306   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1307   Dir->setPreCond(Exprs.PreCond);
1308   Dir->setCond(Exprs.Cond);
1309   Dir->setInit(Exprs.Init);
1310   Dir->setInc(Exprs.Inc);
1311   Dir->setIsLastIterVariable(Exprs.IL);
1312   Dir->setLowerBoundVariable(Exprs.LB);
1313   Dir->setUpperBoundVariable(Exprs.UB);
1314   Dir->setStrideVariable(Exprs.ST);
1315   Dir->setEnsureUpperBound(Exprs.EUB);
1316   Dir->setNextLowerBound(Exprs.NLB);
1317   Dir->setNextUpperBound(Exprs.NUB);
1318   Dir->setNumIterations(Exprs.NumIterations);
1319   Dir->setCounters(Exprs.Counters);
1320   Dir->setPrivateCounters(Exprs.PrivateCounters);
1321   Dir->setInits(Exprs.Inits);
1322   Dir->setUpdates(Exprs.Updates);
1323   Dir->setFinals(Exprs.Finals);
1324   Dir->setDependentCounters(Exprs.DependentCounters);
1325   Dir->setDependentInits(Exprs.DependentInits);
1326   Dir->setFinalsConditions(Exprs.FinalsConditions);
1327   Dir->setPreInits(Exprs.PreInits);
1328   return Dir;
1329 }
1330 
1331 OMPMasterTaskLoopSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1332 OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1333                                             unsigned NumClauses,
1334                                             unsigned CollapsedNum, EmptyShell) {
1335   return createEmptyDirective<OMPMasterTaskLoopSimdDirective>(
1336       C, NumClauses, /*HasAssociatedStmt=*/true,
1337       numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), CollapsedNum);
1338 }
1339 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1340 OMPMaskedTaskLoopSimdDirective *OMPMaskedTaskLoopSimdDirective::Create(
1341     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1342     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1343     const HelperExprs &Exprs) {
1344   auto *Dir = createDirective<OMPMaskedTaskLoopSimdDirective>(
1345       C, Clauses, AssociatedStmt,
1346       numLoopChildren(CollapsedNum, OMPD_masked_taskloop_simd), StartLoc,
1347       EndLoc, CollapsedNum);
1348   Dir->setIterationVariable(Exprs.IterationVarRef);
1349   Dir->setLastIteration(Exprs.LastIteration);
1350   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1351   Dir->setPreCond(Exprs.PreCond);
1352   Dir->setCond(Exprs.Cond);
1353   Dir->setInit(Exprs.Init);
1354   Dir->setInc(Exprs.Inc);
1355   Dir->setIsLastIterVariable(Exprs.IL);
1356   Dir->setLowerBoundVariable(Exprs.LB);
1357   Dir->setUpperBoundVariable(Exprs.UB);
1358   Dir->setStrideVariable(Exprs.ST);
1359   Dir->setEnsureUpperBound(Exprs.EUB);
1360   Dir->setNextLowerBound(Exprs.NLB);
1361   Dir->setNextUpperBound(Exprs.NUB);
1362   Dir->setNumIterations(Exprs.NumIterations);
1363   Dir->setCounters(Exprs.Counters);
1364   Dir->setPrivateCounters(Exprs.PrivateCounters);
1365   Dir->setInits(Exprs.Inits);
1366   Dir->setUpdates(Exprs.Updates);
1367   Dir->setFinals(Exprs.Finals);
1368   Dir->setDependentCounters(Exprs.DependentCounters);
1369   Dir->setDependentInits(Exprs.DependentInits);
1370   Dir->setFinalsConditions(Exprs.FinalsConditions);
1371   Dir->setPreInits(Exprs.PreInits);
1372   return Dir;
1373 }
1374 
1375 OMPMaskedTaskLoopSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1376 OMPMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1377                                             unsigned NumClauses,
1378                                             unsigned CollapsedNum, EmptyShell) {
1379   return createEmptyDirective<OMPMaskedTaskLoopSimdDirective>(
1380       C, NumClauses, /*HasAssociatedStmt=*/true,
1381       numLoopChildren(CollapsedNum, OMPD_masked_taskloop_simd), CollapsedNum);
1382 }
1383 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)1384 OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
1385     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1386     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1387     const HelperExprs &Exprs, bool HasCancel) {
1388   auto *Dir = createDirective<OMPParallelMasterTaskLoopDirective>(
1389       C, Clauses, AssociatedStmt,
1390       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop), StartLoc,
1391       EndLoc, CollapsedNum);
1392   Dir->setIterationVariable(Exprs.IterationVarRef);
1393   Dir->setLastIteration(Exprs.LastIteration);
1394   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1395   Dir->setPreCond(Exprs.PreCond);
1396   Dir->setCond(Exprs.Cond);
1397   Dir->setInit(Exprs.Init);
1398   Dir->setInc(Exprs.Inc);
1399   Dir->setIsLastIterVariable(Exprs.IL);
1400   Dir->setLowerBoundVariable(Exprs.LB);
1401   Dir->setUpperBoundVariable(Exprs.UB);
1402   Dir->setStrideVariable(Exprs.ST);
1403   Dir->setEnsureUpperBound(Exprs.EUB);
1404   Dir->setNextLowerBound(Exprs.NLB);
1405   Dir->setNextUpperBound(Exprs.NUB);
1406   Dir->setNumIterations(Exprs.NumIterations);
1407   Dir->setCounters(Exprs.Counters);
1408   Dir->setPrivateCounters(Exprs.PrivateCounters);
1409   Dir->setInits(Exprs.Inits);
1410   Dir->setUpdates(Exprs.Updates);
1411   Dir->setFinals(Exprs.Finals);
1412   Dir->setDependentCounters(Exprs.DependentCounters);
1413   Dir->setDependentInits(Exprs.DependentInits);
1414   Dir->setFinalsConditions(Exprs.FinalsConditions);
1415   Dir->setPreInits(Exprs.PreInits);
1416   Dir->setHasCancel(HasCancel);
1417   return Dir;
1418 }
1419 
1420 OMPParallelMasterTaskLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1421 OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1422                                                 unsigned NumClauses,
1423                                                 unsigned CollapsedNum,
1424                                                 EmptyShell) {
1425   return createEmptyDirective<OMPParallelMasterTaskLoopDirective>(
1426       C, NumClauses, /*HasAssociatedStmt=*/true,
1427       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop),
1428       CollapsedNum);
1429 }
1430 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)1431 OMPParallelMaskedTaskLoopDirective *OMPParallelMaskedTaskLoopDirective::Create(
1432     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1433     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1434     const HelperExprs &Exprs, bool HasCancel) {
1435   auto *Dir = createDirective<OMPParallelMaskedTaskLoopDirective>(
1436       C, Clauses, AssociatedStmt,
1437       numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop), StartLoc,
1438       EndLoc, CollapsedNum);
1439   Dir->setIterationVariable(Exprs.IterationVarRef);
1440   Dir->setLastIteration(Exprs.LastIteration);
1441   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1442   Dir->setPreCond(Exprs.PreCond);
1443   Dir->setCond(Exprs.Cond);
1444   Dir->setInit(Exprs.Init);
1445   Dir->setInc(Exprs.Inc);
1446   Dir->setIsLastIterVariable(Exprs.IL);
1447   Dir->setLowerBoundVariable(Exprs.LB);
1448   Dir->setUpperBoundVariable(Exprs.UB);
1449   Dir->setStrideVariable(Exprs.ST);
1450   Dir->setEnsureUpperBound(Exprs.EUB);
1451   Dir->setNextLowerBound(Exprs.NLB);
1452   Dir->setNextUpperBound(Exprs.NUB);
1453   Dir->setNumIterations(Exprs.NumIterations);
1454   Dir->setCounters(Exprs.Counters);
1455   Dir->setPrivateCounters(Exprs.PrivateCounters);
1456   Dir->setInits(Exprs.Inits);
1457   Dir->setUpdates(Exprs.Updates);
1458   Dir->setFinals(Exprs.Finals);
1459   Dir->setDependentCounters(Exprs.DependentCounters);
1460   Dir->setDependentInits(Exprs.DependentInits);
1461   Dir->setFinalsConditions(Exprs.FinalsConditions);
1462   Dir->setPreInits(Exprs.PreInits);
1463   Dir->setHasCancel(HasCancel);
1464   return Dir;
1465 }
1466 
1467 OMPParallelMaskedTaskLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1468 OMPParallelMaskedTaskLoopDirective::CreateEmpty(const ASTContext &C,
1469                                                 unsigned NumClauses,
1470                                                 unsigned CollapsedNum,
1471                                                 EmptyShell) {
1472   return createEmptyDirective<OMPParallelMaskedTaskLoopDirective>(
1473       C, NumClauses, /*HasAssociatedStmt=*/true,
1474       numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop),
1475       CollapsedNum);
1476 }
1477 
1478 OMPParallelMasterTaskLoopSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1479 OMPParallelMasterTaskLoopSimdDirective::Create(
1480     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1481     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1482     const HelperExprs &Exprs) {
1483   auto *Dir = createDirective<OMPParallelMasterTaskLoopSimdDirective>(
1484       C, Clauses, AssociatedStmt,
1485       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),
1486       StartLoc, EndLoc, CollapsedNum);
1487   Dir->setIterationVariable(Exprs.IterationVarRef);
1488   Dir->setLastIteration(Exprs.LastIteration);
1489   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1490   Dir->setPreCond(Exprs.PreCond);
1491   Dir->setCond(Exprs.Cond);
1492   Dir->setInit(Exprs.Init);
1493   Dir->setInc(Exprs.Inc);
1494   Dir->setIsLastIterVariable(Exprs.IL);
1495   Dir->setLowerBoundVariable(Exprs.LB);
1496   Dir->setUpperBoundVariable(Exprs.UB);
1497   Dir->setStrideVariable(Exprs.ST);
1498   Dir->setEnsureUpperBound(Exprs.EUB);
1499   Dir->setNextLowerBound(Exprs.NLB);
1500   Dir->setNextUpperBound(Exprs.NUB);
1501   Dir->setNumIterations(Exprs.NumIterations);
1502   Dir->setCounters(Exprs.Counters);
1503   Dir->setPrivateCounters(Exprs.PrivateCounters);
1504   Dir->setInits(Exprs.Inits);
1505   Dir->setUpdates(Exprs.Updates);
1506   Dir->setFinals(Exprs.Finals);
1507   Dir->setDependentCounters(Exprs.DependentCounters);
1508   Dir->setDependentInits(Exprs.DependentInits);
1509   Dir->setFinalsConditions(Exprs.FinalsConditions);
1510   Dir->setPreInits(Exprs.PreInits);
1511   return Dir;
1512 }
1513 
1514 OMPParallelMasterTaskLoopSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1515 OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1516                                                     unsigned NumClauses,
1517                                                     unsigned CollapsedNum,
1518                                                     EmptyShell) {
1519   return createEmptyDirective<OMPParallelMasterTaskLoopSimdDirective>(
1520       C, NumClauses, /*HasAssociatedStmt=*/true,
1521       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),
1522       CollapsedNum);
1523 }
1524 
1525 OMPParallelMaskedTaskLoopSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1526 OMPParallelMaskedTaskLoopSimdDirective::Create(
1527     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1528     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1529     const HelperExprs &Exprs) {
1530   auto *Dir = createDirective<OMPParallelMaskedTaskLoopSimdDirective>(
1531       C, Clauses, AssociatedStmt,
1532       numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop_simd),
1533       StartLoc, EndLoc, CollapsedNum);
1534   Dir->setIterationVariable(Exprs.IterationVarRef);
1535   Dir->setLastIteration(Exprs.LastIteration);
1536   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1537   Dir->setPreCond(Exprs.PreCond);
1538   Dir->setCond(Exprs.Cond);
1539   Dir->setInit(Exprs.Init);
1540   Dir->setInc(Exprs.Inc);
1541   Dir->setIsLastIterVariable(Exprs.IL);
1542   Dir->setLowerBoundVariable(Exprs.LB);
1543   Dir->setUpperBoundVariable(Exprs.UB);
1544   Dir->setStrideVariable(Exprs.ST);
1545   Dir->setEnsureUpperBound(Exprs.EUB);
1546   Dir->setNextLowerBound(Exprs.NLB);
1547   Dir->setNextUpperBound(Exprs.NUB);
1548   Dir->setNumIterations(Exprs.NumIterations);
1549   Dir->setCounters(Exprs.Counters);
1550   Dir->setPrivateCounters(Exprs.PrivateCounters);
1551   Dir->setInits(Exprs.Inits);
1552   Dir->setUpdates(Exprs.Updates);
1553   Dir->setFinals(Exprs.Finals);
1554   Dir->setDependentCounters(Exprs.DependentCounters);
1555   Dir->setDependentInits(Exprs.DependentInits);
1556   Dir->setFinalsConditions(Exprs.FinalsConditions);
1557   Dir->setPreInits(Exprs.PreInits);
1558   return Dir;
1559 }
1560 
1561 OMPParallelMaskedTaskLoopSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1562 OMPParallelMaskedTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1563                                                     unsigned NumClauses,
1564                                                     unsigned CollapsedNum,
1565                                                     EmptyShell) {
1566   return createEmptyDirective<OMPParallelMaskedTaskLoopSimdDirective>(
1567       C, NumClauses, /*HasAssociatedStmt=*/true,
1568       numLoopChildren(CollapsedNum, OMPD_parallel_masked_taskloop_simd),
1569       CollapsedNum);
1570 }
1571 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,OpenMPDirectiveKind ParamPrevMappedDirective)1572 OMPDistributeDirective *OMPDistributeDirective::Create(
1573     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1574     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1575     const HelperExprs &Exprs, OpenMPDirectiveKind ParamPrevMappedDirective) {
1576   auto *Dir = createDirective<OMPDistributeDirective>(
1577       C, Clauses, AssociatedStmt,
1578       numLoopChildren(CollapsedNum, OMPD_distribute), StartLoc, EndLoc,
1579       CollapsedNum);
1580   Dir->setIterationVariable(Exprs.IterationVarRef);
1581   Dir->setLastIteration(Exprs.LastIteration);
1582   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1583   Dir->setPreCond(Exprs.PreCond);
1584   Dir->setCond(Exprs.Cond);
1585   Dir->setInit(Exprs.Init);
1586   Dir->setInc(Exprs.Inc);
1587   Dir->setIsLastIterVariable(Exprs.IL);
1588   Dir->setLowerBoundVariable(Exprs.LB);
1589   Dir->setUpperBoundVariable(Exprs.UB);
1590   Dir->setStrideVariable(Exprs.ST);
1591   Dir->setEnsureUpperBound(Exprs.EUB);
1592   Dir->setNextLowerBound(Exprs.NLB);
1593   Dir->setNextUpperBound(Exprs.NUB);
1594   Dir->setNumIterations(Exprs.NumIterations);
1595   Dir->setCounters(Exprs.Counters);
1596   Dir->setPrivateCounters(Exprs.PrivateCounters);
1597   Dir->setInits(Exprs.Inits);
1598   Dir->setUpdates(Exprs.Updates);
1599   Dir->setFinals(Exprs.Finals);
1600   Dir->setDependentCounters(Exprs.DependentCounters);
1601   Dir->setDependentInits(Exprs.DependentInits);
1602   Dir->setFinalsConditions(Exprs.FinalsConditions);
1603   Dir->setPreInits(Exprs.PreInits);
1604   Dir->setMappedDirective(ParamPrevMappedDirective);
1605   return Dir;
1606 }
1607 
1608 OMPDistributeDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1609 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1610                                     unsigned CollapsedNum, EmptyShell) {
1611   return createEmptyDirective<OMPDistributeDirective>(
1612       C, NumClauses, /*HasAssociatedStmt=*/true,
1613       numLoopChildren(CollapsedNum, OMPD_distribute), CollapsedNum);
1614 }
1615 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)1616 OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1617     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1618     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1619   return createDirective<OMPTargetUpdateDirective>(C, Clauses, AssociatedStmt,
1620                                                    /*NumChildren=*/0, StartLoc,
1621                                                    EndLoc);
1622 }
1623 
1624 OMPTargetUpdateDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)1625 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1626                                       EmptyShell) {
1627   return createEmptyDirective<OMPTargetUpdateDirective>(
1628       C, NumClauses, /*HasAssociatedStmt=*/true);
1629 }
1630 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,Expr * TaskRedRef,bool HasCancel)1631 OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1632     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1633     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1634     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1635   auto *Dir = createDirective<OMPDistributeParallelForDirective>(
1636       C, Clauses, AssociatedStmt,
1637       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1, StartLoc,
1638       EndLoc, CollapsedNum);
1639   Dir->setIterationVariable(Exprs.IterationVarRef);
1640   Dir->setLastIteration(Exprs.LastIteration);
1641   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1642   Dir->setPreCond(Exprs.PreCond);
1643   Dir->setCond(Exprs.Cond);
1644   Dir->setInit(Exprs.Init);
1645   Dir->setInc(Exprs.Inc);
1646   Dir->setIsLastIterVariable(Exprs.IL);
1647   Dir->setLowerBoundVariable(Exprs.LB);
1648   Dir->setUpperBoundVariable(Exprs.UB);
1649   Dir->setStrideVariable(Exprs.ST);
1650   Dir->setEnsureUpperBound(Exprs.EUB);
1651   Dir->setNextLowerBound(Exprs.NLB);
1652   Dir->setNextUpperBound(Exprs.NUB);
1653   Dir->setNumIterations(Exprs.NumIterations);
1654   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1655   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1656   Dir->setDistInc(Exprs.DistInc);
1657   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1658   Dir->setCounters(Exprs.Counters);
1659   Dir->setPrivateCounters(Exprs.PrivateCounters);
1660   Dir->setInits(Exprs.Inits);
1661   Dir->setUpdates(Exprs.Updates);
1662   Dir->setFinals(Exprs.Finals);
1663   Dir->setDependentCounters(Exprs.DependentCounters);
1664   Dir->setDependentInits(Exprs.DependentInits);
1665   Dir->setFinalsConditions(Exprs.FinalsConditions);
1666   Dir->setPreInits(Exprs.PreInits);
1667   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1668   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1669   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1670   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1671   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1672   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1673   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1674   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1675   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1676   Dir->setTaskReductionRefExpr(TaskRedRef);
1677   Dir->HasCancel = HasCancel;
1678   return Dir;
1679 }
1680 
1681 OMPDistributeParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1682 OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1683                                                unsigned NumClauses,
1684                                                unsigned CollapsedNum,
1685                                                EmptyShell) {
1686   return createEmptyDirective<OMPDistributeParallelForDirective>(
1687       C, NumClauses, /*HasAssociatedStmt=*/true,
1688       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1,
1689       CollapsedNum);
1690 }
1691 
1692 OMPDistributeParallelForSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1693 OMPDistributeParallelForSimdDirective::Create(
1694     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1695     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1696     const HelperExprs &Exprs) {
1697   auto *Dir = createDirective<OMPDistributeParallelForSimdDirective>(
1698       C, Clauses, AssociatedStmt,
1699       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),
1700       StartLoc, EndLoc, CollapsedNum);
1701   Dir->setIterationVariable(Exprs.IterationVarRef);
1702   Dir->setLastIteration(Exprs.LastIteration);
1703   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1704   Dir->setPreCond(Exprs.PreCond);
1705   Dir->setCond(Exprs.Cond);
1706   Dir->setInit(Exprs.Init);
1707   Dir->setInc(Exprs.Inc);
1708   Dir->setIsLastIterVariable(Exprs.IL);
1709   Dir->setLowerBoundVariable(Exprs.LB);
1710   Dir->setUpperBoundVariable(Exprs.UB);
1711   Dir->setStrideVariable(Exprs.ST);
1712   Dir->setEnsureUpperBound(Exprs.EUB);
1713   Dir->setNextLowerBound(Exprs.NLB);
1714   Dir->setNextUpperBound(Exprs.NUB);
1715   Dir->setNumIterations(Exprs.NumIterations);
1716   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1717   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1718   Dir->setDistInc(Exprs.DistInc);
1719   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1720   Dir->setCounters(Exprs.Counters);
1721   Dir->setPrivateCounters(Exprs.PrivateCounters);
1722   Dir->setInits(Exprs.Inits);
1723   Dir->setUpdates(Exprs.Updates);
1724   Dir->setFinals(Exprs.Finals);
1725   Dir->setDependentCounters(Exprs.DependentCounters);
1726   Dir->setDependentInits(Exprs.DependentInits);
1727   Dir->setFinalsConditions(Exprs.FinalsConditions);
1728   Dir->setPreInits(Exprs.PreInits);
1729   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1730   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1731   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1732   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1733   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1734   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1735   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1736   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1737   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1738   return Dir;
1739 }
1740 
1741 OMPDistributeParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1742 OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1743                                                    unsigned NumClauses,
1744                                                    unsigned CollapsedNum,
1745                                                    EmptyShell) {
1746   return createEmptyDirective<OMPDistributeParallelForSimdDirective>(
1747       C, NumClauses, /*HasAssociatedStmt=*/true,
1748       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),
1749       CollapsedNum);
1750 }
1751 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1752 OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1753     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1754     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1755     const HelperExprs &Exprs) {
1756   auto *Dir = createDirective<OMPDistributeSimdDirective>(
1757       C, Clauses, AssociatedStmt,
1758       numLoopChildren(CollapsedNum, OMPD_distribute_simd), StartLoc, EndLoc,
1759       CollapsedNum);
1760   Dir->setIterationVariable(Exprs.IterationVarRef);
1761   Dir->setLastIteration(Exprs.LastIteration);
1762   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1763   Dir->setPreCond(Exprs.PreCond);
1764   Dir->setCond(Exprs.Cond);
1765   Dir->setInit(Exprs.Init);
1766   Dir->setInc(Exprs.Inc);
1767   Dir->setIsLastIterVariable(Exprs.IL);
1768   Dir->setLowerBoundVariable(Exprs.LB);
1769   Dir->setUpperBoundVariable(Exprs.UB);
1770   Dir->setStrideVariable(Exprs.ST);
1771   Dir->setEnsureUpperBound(Exprs.EUB);
1772   Dir->setNextLowerBound(Exprs.NLB);
1773   Dir->setNextUpperBound(Exprs.NUB);
1774   Dir->setNumIterations(Exprs.NumIterations);
1775   Dir->setCounters(Exprs.Counters);
1776   Dir->setPrivateCounters(Exprs.PrivateCounters);
1777   Dir->setInits(Exprs.Inits);
1778   Dir->setUpdates(Exprs.Updates);
1779   Dir->setFinals(Exprs.Finals);
1780   Dir->setDependentCounters(Exprs.DependentCounters);
1781   Dir->setDependentInits(Exprs.DependentInits);
1782   Dir->setFinalsConditions(Exprs.FinalsConditions);
1783   Dir->setPreInits(Exprs.PreInits);
1784   return Dir;
1785 }
1786 
1787 OMPDistributeSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1788 OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1789                                         unsigned NumClauses,
1790                                         unsigned CollapsedNum, EmptyShell) {
1791   return createEmptyDirective<OMPDistributeSimdDirective>(
1792       C, NumClauses, /*HasAssociatedStmt=*/true,
1793       numLoopChildren(CollapsedNum, OMPD_distribute_simd), CollapsedNum);
1794 }
1795 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1796 OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1797     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1798     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1799     const HelperExprs &Exprs) {
1800   auto *Dir = createDirective<OMPTargetParallelForSimdDirective>(
1801       C, Clauses, AssociatedStmt,
1802       numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd), StartLoc,
1803       EndLoc, CollapsedNum);
1804   Dir->setIterationVariable(Exprs.IterationVarRef);
1805   Dir->setLastIteration(Exprs.LastIteration);
1806   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1807   Dir->setPreCond(Exprs.PreCond);
1808   Dir->setCond(Exprs.Cond);
1809   Dir->setInit(Exprs.Init);
1810   Dir->setInc(Exprs.Inc);
1811   Dir->setIsLastIterVariable(Exprs.IL);
1812   Dir->setLowerBoundVariable(Exprs.LB);
1813   Dir->setUpperBoundVariable(Exprs.UB);
1814   Dir->setStrideVariable(Exprs.ST);
1815   Dir->setEnsureUpperBound(Exprs.EUB);
1816   Dir->setNextLowerBound(Exprs.NLB);
1817   Dir->setNextUpperBound(Exprs.NUB);
1818   Dir->setNumIterations(Exprs.NumIterations);
1819   Dir->setCounters(Exprs.Counters);
1820   Dir->setPrivateCounters(Exprs.PrivateCounters);
1821   Dir->setInits(Exprs.Inits);
1822   Dir->setUpdates(Exprs.Updates);
1823   Dir->setFinals(Exprs.Finals);
1824   Dir->setDependentCounters(Exprs.DependentCounters);
1825   Dir->setDependentInits(Exprs.DependentInits);
1826   Dir->setFinalsConditions(Exprs.FinalsConditions);
1827   Dir->setPreInits(Exprs.PreInits);
1828   return Dir;
1829 }
1830 
1831 OMPTargetParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1832 OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1833                                                unsigned NumClauses,
1834                                                unsigned CollapsedNum,
1835                                                EmptyShell) {
1836   return createEmptyDirective<OMPTargetParallelForSimdDirective>(
1837       C, NumClauses, /*HasAssociatedStmt=*/true,
1838       numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd),
1839       CollapsedNum);
1840 }
1841 
1842 OMPTargetSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1843 OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1844                                SourceLocation EndLoc, unsigned CollapsedNum,
1845                                ArrayRef<OMPClause *> Clauses,
1846                                Stmt *AssociatedStmt, const HelperExprs &Exprs) {
1847   auto *Dir = createDirective<OMPTargetSimdDirective>(
1848       C, Clauses, AssociatedStmt,
1849       numLoopChildren(CollapsedNum, OMPD_target_simd), StartLoc, EndLoc,
1850       CollapsedNum);
1851   Dir->setIterationVariable(Exprs.IterationVarRef);
1852   Dir->setLastIteration(Exprs.LastIteration);
1853   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1854   Dir->setPreCond(Exprs.PreCond);
1855   Dir->setCond(Exprs.Cond);
1856   Dir->setInit(Exprs.Init);
1857   Dir->setInc(Exprs.Inc);
1858   Dir->setCounters(Exprs.Counters);
1859   Dir->setPrivateCounters(Exprs.PrivateCounters);
1860   Dir->setInits(Exprs.Inits);
1861   Dir->setUpdates(Exprs.Updates);
1862   Dir->setFinals(Exprs.Finals);
1863   Dir->setDependentCounters(Exprs.DependentCounters);
1864   Dir->setDependentInits(Exprs.DependentInits);
1865   Dir->setFinalsConditions(Exprs.FinalsConditions);
1866   Dir->setPreInits(Exprs.PreInits);
1867   return Dir;
1868 }
1869 
1870 OMPTargetSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1871 OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1872                                     unsigned CollapsedNum, EmptyShell) {
1873   return createEmptyDirective<OMPTargetSimdDirective>(
1874       C, NumClauses, /*HasAssociatedStmt=*/true,
1875       numLoopChildren(CollapsedNum, OMPD_target_simd), CollapsedNum);
1876 }
1877 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1878 OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1879     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1880     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1881     const HelperExprs &Exprs) {
1882   auto *Dir = createDirective<OMPTeamsDistributeDirective>(
1883       C, Clauses, AssociatedStmt,
1884       numLoopChildren(CollapsedNum, OMPD_teams_distribute), StartLoc, EndLoc,
1885       CollapsedNum);
1886   Dir->setIterationVariable(Exprs.IterationVarRef);
1887   Dir->setLastIteration(Exprs.LastIteration);
1888   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1889   Dir->setPreCond(Exprs.PreCond);
1890   Dir->setCond(Exprs.Cond);
1891   Dir->setInit(Exprs.Init);
1892   Dir->setInc(Exprs.Inc);
1893   Dir->setIsLastIterVariable(Exprs.IL);
1894   Dir->setLowerBoundVariable(Exprs.LB);
1895   Dir->setUpperBoundVariable(Exprs.UB);
1896   Dir->setStrideVariable(Exprs.ST);
1897   Dir->setEnsureUpperBound(Exprs.EUB);
1898   Dir->setNextLowerBound(Exprs.NLB);
1899   Dir->setNextUpperBound(Exprs.NUB);
1900   Dir->setNumIterations(Exprs.NumIterations);
1901   Dir->setCounters(Exprs.Counters);
1902   Dir->setPrivateCounters(Exprs.PrivateCounters);
1903   Dir->setInits(Exprs.Inits);
1904   Dir->setUpdates(Exprs.Updates);
1905   Dir->setFinals(Exprs.Finals);
1906   Dir->setDependentCounters(Exprs.DependentCounters);
1907   Dir->setDependentInits(Exprs.DependentInits);
1908   Dir->setFinalsConditions(Exprs.FinalsConditions);
1909   Dir->setPreInits(Exprs.PreInits);
1910   return Dir;
1911 }
1912 
1913 OMPTeamsDistributeDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1914 OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1915                                          unsigned NumClauses,
1916                                          unsigned CollapsedNum, EmptyShell) {
1917   return createEmptyDirective<OMPTeamsDistributeDirective>(
1918       C, NumClauses, /*HasAssociatedStmt=*/true,
1919       numLoopChildren(CollapsedNum, OMPD_teams_distribute), CollapsedNum);
1920 }
1921 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1922 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1923     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1924     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1925     const HelperExprs &Exprs) {
1926   auto *Dir = createDirective<OMPTeamsDistributeSimdDirective>(
1927       C, Clauses, AssociatedStmt,
1928       numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), StartLoc,
1929       EndLoc, CollapsedNum);
1930   Dir->setIterationVariable(Exprs.IterationVarRef);
1931   Dir->setLastIteration(Exprs.LastIteration);
1932   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1933   Dir->setPreCond(Exprs.PreCond);
1934   Dir->setCond(Exprs.Cond);
1935   Dir->setInit(Exprs.Init);
1936   Dir->setInc(Exprs.Inc);
1937   Dir->setIsLastIterVariable(Exprs.IL);
1938   Dir->setLowerBoundVariable(Exprs.LB);
1939   Dir->setUpperBoundVariable(Exprs.UB);
1940   Dir->setStrideVariable(Exprs.ST);
1941   Dir->setEnsureUpperBound(Exprs.EUB);
1942   Dir->setNextLowerBound(Exprs.NLB);
1943   Dir->setNextUpperBound(Exprs.NUB);
1944   Dir->setNumIterations(Exprs.NumIterations);
1945   Dir->setCounters(Exprs.Counters);
1946   Dir->setPrivateCounters(Exprs.PrivateCounters);
1947   Dir->setInits(Exprs.Inits);
1948   Dir->setUpdates(Exprs.Updates);
1949   Dir->setFinals(Exprs.Finals);
1950   Dir->setDependentCounters(Exprs.DependentCounters);
1951   Dir->setDependentInits(Exprs.DependentInits);
1952   Dir->setFinalsConditions(Exprs.FinalsConditions);
1953   Dir->setPreInits(Exprs.PreInits);
1954   return Dir;
1955 }
1956 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1957 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1958     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1959     EmptyShell) {
1960   return createEmptyDirective<OMPTeamsDistributeSimdDirective>(
1961       C, NumClauses, /*HasAssociatedStmt=*/true,
1962       numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), CollapsedNum);
1963 }
1964 
1965 OMPTeamsDistributeParallelForSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1966 OMPTeamsDistributeParallelForSimdDirective::Create(
1967     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1968     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1969     const HelperExprs &Exprs) {
1970   auto *Dir = createDirective<OMPTeamsDistributeParallelForSimdDirective>(
1971       C, Clauses, AssociatedStmt,
1972       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),
1973       StartLoc, EndLoc, CollapsedNum);
1974   Dir->setIterationVariable(Exprs.IterationVarRef);
1975   Dir->setLastIteration(Exprs.LastIteration);
1976   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1977   Dir->setPreCond(Exprs.PreCond);
1978   Dir->setCond(Exprs.Cond);
1979   Dir->setInit(Exprs.Init);
1980   Dir->setInc(Exprs.Inc);
1981   Dir->setIsLastIterVariable(Exprs.IL);
1982   Dir->setLowerBoundVariable(Exprs.LB);
1983   Dir->setUpperBoundVariable(Exprs.UB);
1984   Dir->setStrideVariable(Exprs.ST);
1985   Dir->setEnsureUpperBound(Exprs.EUB);
1986   Dir->setNextLowerBound(Exprs.NLB);
1987   Dir->setNextUpperBound(Exprs.NUB);
1988   Dir->setNumIterations(Exprs.NumIterations);
1989   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1990   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1991   Dir->setDistInc(Exprs.DistInc);
1992   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1993   Dir->setCounters(Exprs.Counters);
1994   Dir->setPrivateCounters(Exprs.PrivateCounters);
1995   Dir->setInits(Exprs.Inits);
1996   Dir->setUpdates(Exprs.Updates);
1997   Dir->setFinals(Exprs.Finals);
1998   Dir->setDependentCounters(Exprs.DependentCounters);
1999   Dir->setDependentInits(Exprs.DependentInits);
2000   Dir->setFinalsConditions(Exprs.FinalsConditions);
2001   Dir->setPreInits(Exprs.PreInits);
2002   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2003   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2004   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2005   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2006   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2007   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2008   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2009   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2010   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2011   return Dir;
2012 }
2013 
2014 OMPTeamsDistributeParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2015 OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
2016                                                         unsigned NumClauses,
2017                                                         unsigned CollapsedNum,
2018                                                         EmptyShell) {
2019   return createEmptyDirective<OMPTeamsDistributeParallelForSimdDirective>(
2020       C, NumClauses, /*HasAssociatedStmt=*/true,
2021       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),
2022       CollapsedNum);
2023 }
2024 
2025 OMPTeamsDistributeParallelForDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,Expr * TaskRedRef,bool HasCancel)2026 OMPTeamsDistributeParallelForDirective::Create(
2027     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2028     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2029     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
2030   auto *Dir = createDirective<OMPTeamsDistributeParallelForDirective>(
2031       C, Clauses, AssociatedStmt,
2032       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,
2033       StartLoc, EndLoc, CollapsedNum);
2034   Dir->setIterationVariable(Exprs.IterationVarRef);
2035   Dir->setLastIteration(Exprs.LastIteration);
2036   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2037   Dir->setPreCond(Exprs.PreCond);
2038   Dir->setCond(Exprs.Cond);
2039   Dir->setInit(Exprs.Init);
2040   Dir->setInc(Exprs.Inc);
2041   Dir->setIsLastIterVariable(Exprs.IL);
2042   Dir->setLowerBoundVariable(Exprs.LB);
2043   Dir->setUpperBoundVariable(Exprs.UB);
2044   Dir->setStrideVariable(Exprs.ST);
2045   Dir->setEnsureUpperBound(Exprs.EUB);
2046   Dir->setNextLowerBound(Exprs.NLB);
2047   Dir->setNextUpperBound(Exprs.NUB);
2048   Dir->setNumIterations(Exprs.NumIterations);
2049   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2050   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2051   Dir->setDistInc(Exprs.DistInc);
2052   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2053   Dir->setCounters(Exprs.Counters);
2054   Dir->setPrivateCounters(Exprs.PrivateCounters);
2055   Dir->setInits(Exprs.Inits);
2056   Dir->setUpdates(Exprs.Updates);
2057   Dir->setFinals(Exprs.Finals);
2058   Dir->setDependentCounters(Exprs.DependentCounters);
2059   Dir->setDependentInits(Exprs.DependentInits);
2060   Dir->setFinalsConditions(Exprs.FinalsConditions);
2061   Dir->setPreInits(Exprs.PreInits);
2062   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2063   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2064   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2065   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2066   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2067   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2068   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2069   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2070   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2071   Dir->setTaskReductionRefExpr(TaskRedRef);
2072   Dir->HasCancel = HasCancel;
2073   return Dir;
2074 }
2075 
2076 OMPTeamsDistributeParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2077 OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
2078                                                     unsigned NumClauses,
2079                                                     unsigned CollapsedNum,
2080                                                     EmptyShell) {
2081   return createEmptyDirective<OMPTeamsDistributeParallelForDirective>(
2082       C, NumClauses, /*HasAssociatedStmt=*/true,
2083       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,
2084       CollapsedNum);
2085 }
2086 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)2087 OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
2088     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2089     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
2090   return createDirective<OMPTargetTeamsDirective>(C, Clauses, AssociatedStmt,
2091                                                   /*NumChildren=*/0, StartLoc,
2092                                                   EndLoc);
2093 }
2094 
2095 OMPTargetTeamsDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)2096 OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
2097                                      EmptyShell) {
2098   return createEmptyDirective<OMPTargetTeamsDirective>(
2099       C, NumClauses, /*HasAssociatedStmt=*/true);
2100 }
2101 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)2102 OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
2103     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2104     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2105     const HelperExprs &Exprs) {
2106   auto *Dir = createDirective<OMPTargetTeamsDistributeDirective>(
2107       C, Clauses, AssociatedStmt,
2108       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute), StartLoc,
2109       EndLoc, CollapsedNum);
2110   Dir->setIterationVariable(Exprs.IterationVarRef);
2111   Dir->setLastIteration(Exprs.LastIteration);
2112   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2113   Dir->setPreCond(Exprs.PreCond);
2114   Dir->setCond(Exprs.Cond);
2115   Dir->setInit(Exprs.Init);
2116   Dir->setInc(Exprs.Inc);
2117   Dir->setIsLastIterVariable(Exprs.IL);
2118   Dir->setLowerBoundVariable(Exprs.LB);
2119   Dir->setUpperBoundVariable(Exprs.UB);
2120   Dir->setStrideVariable(Exprs.ST);
2121   Dir->setEnsureUpperBound(Exprs.EUB);
2122   Dir->setNextLowerBound(Exprs.NLB);
2123   Dir->setNextUpperBound(Exprs.NUB);
2124   Dir->setNumIterations(Exprs.NumIterations);
2125   Dir->setCounters(Exprs.Counters);
2126   Dir->setPrivateCounters(Exprs.PrivateCounters);
2127   Dir->setInits(Exprs.Inits);
2128   Dir->setUpdates(Exprs.Updates);
2129   Dir->setFinals(Exprs.Finals);
2130   Dir->setDependentCounters(Exprs.DependentCounters);
2131   Dir->setDependentInits(Exprs.DependentInits);
2132   Dir->setFinalsConditions(Exprs.FinalsConditions);
2133   Dir->setPreInits(Exprs.PreInits);
2134   return Dir;
2135 }
2136 
2137 OMPTargetTeamsDistributeDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2138 OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
2139                                                unsigned NumClauses,
2140                                                unsigned CollapsedNum,
2141                                                EmptyShell) {
2142   return createEmptyDirective<OMPTargetTeamsDistributeDirective>(
2143       C, NumClauses, /*HasAssociatedStmt=*/true,
2144       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute),
2145       CollapsedNum);
2146 }
2147 
2148 OMPTargetTeamsDistributeParallelForDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,Expr * TaskRedRef,bool HasCancel)2149 OMPTargetTeamsDistributeParallelForDirective::Create(
2150     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2151     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2152     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
2153   auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForDirective>(
2154       C, Clauses, AssociatedStmt,
2155       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +
2156           1,
2157       StartLoc, EndLoc, CollapsedNum);
2158   Dir->setIterationVariable(Exprs.IterationVarRef);
2159   Dir->setLastIteration(Exprs.LastIteration);
2160   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2161   Dir->setPreCond(Exprs.PreCond);
2162   Dir->setCond(Exprs.Cond);
2163   Dir->setInit(Exprs.Init);
2164   Dir->setInc(Exprs.Inc);
2165   Dir->setIsLastIterVariable(Exprs.IL);
2166   Dir->setLowerBoundVariable(Exprs.LB);
2167   Dir->setUpperBoundVariable(Exprs.UB);
2168   Dir->setStrideVariable(Exprs.ST);
2169   Dir->setEnsureUpperBound(Exprs.EUB);
2170   Dir->setNextLowerBound(Exprs.NLB);
2171   Dir->setNextUpperBound(Exprs.NUB);
2172   Dir->setNumIterations(Exprs.NumIterations);
2173   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2174   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2175   Dir->setDistInc(Exprs.DistInc);
2176   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2177   Dir->setCounters(Exprs.Counters);
2178   Dir->setPrivateCounters(Exprs.PrivateCounters);
2179   Dir->setInits(Exprs.Inits);
2180   Dir->setUpdates(Exprs.Updates);
2181   Dir->setFinals(Exprs.Finals);
2182   Dir->setDependentCounters(Exprs.DependentCounters);
2183   Dir->setDependentInits(Exprs.DependentInits);
2184   Dir->setFinalsConditions(Exprs.FinalsConditions);
2185   Dir->setPreInits(Exprs.PreInits);
2186   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2187   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2188   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2189   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2190   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2191   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2192   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2193   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2194   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2195   Dir->setTaskReductionRefExpr(TaskRedRef);
2196   Dir->HasCancel = HasCancel;
2197   return Dir;
2198 }
2199 
2200 OMPTargetTeamsDistributeParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2201 OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
2202                                                           unsigned NumClauses,
2203                                                           unsigned CollapsedNum,
2204                                                           EmptyShell) {
2205   return createEmptyDirective<OMPTargetTeamsDistributeParallelForDirective>(
2206       C, NumClauses, /*HasAssociatedStmt=*/true,
2207       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +
2208           1,
2209       CollapsedNum);
2210 }
2211 
2212 OMPTargetTeamsDistributeParallelForSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)2213 OMPTargetTeamsDistributeParallelForSimdDirective::Create(
2214     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2215     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2216     const HelperExprs &Exprs) {
2217   auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
2218       C, Clauses, AssociatedStmt,
2219       numLoopChildren(CollapsedNum,
2220                       OMPD_target_teams_distribute_parallel_for_simd),
2221       StartLoc, EndLoc, CollapsedNum);
2222   Dir->setIterationVariable(Exprs.IterationVarRef);
2223   Dir->setLastIteration(Exprs.LastIteration);
2224   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2225   Dir->setPreCond(Exprs.PreCond);
2226   Dir->setCond(Exprs.Cond);
2227   Dir->setInit(Exprs.Init);
2228   Dir->setInc(Exprs.Inc);
2229   Dir->setIsLastIterVariable(Exprs.IL);
2230   Dir->setLowerBoundVariable(Exprs.LB);
2231   Dir->setUpperBoundVariable(Exprs.UB);
2232   Dir->setStrideVariable(Exprs.ST);
2233   Dir->setEnsureUpperBound(Exprs.EUB);
2234   Dir->setNextLowerBound(Exprs.NLB);
2235   Dir->setNextUpperBound(Exprs.NUB);
2236   Dir->setNumIterations(Exprs.NumIterations);
2237   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2238   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2239   Dir->setDistInc(Exprs.DistInc);
2240   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2241   Dir->setCounters(Exprs.Counters);
2242   Dir->setPrivateCounters(Exprs.PrivateCounters);
2243   Dir->setInits(Exprs.Inits);
2244   Dir->setUpdates(Exprs.Updates);
2245   Dir->setFinals(Exprs.Finals);
2246   Dir->setDependentCounters(Exprs.DependentCounters);
2247   Dir->setDependentInits(Exprs.DependentInits);
2248   Dir->setFinalsConditions(Exprs.FinalsConditions);
2249   Dir->setPreInits(Exprs.PreInits);
2250   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2251   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2252   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2253   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2254   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2255   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2256   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2257   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2258   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2259   return Dir;
2260 }
2261 
2262 OMPTargetTeamsDistributeParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2263 OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
2264     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
2265     EmptyShell) {
2266   return createEmptyDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
2267       C, NumClauses, /*HasAssociatedStmt=*/true,
2268       numLoopChildren(CollapsedNum,
2269                       OMPD_target_teams_distribute_parallel_for_simd),
2270       CollapsedNum);
2271 }
2272 
2273 OMPTargetTeamsDistributeSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)2274 OMPTargetTeamsDistributeSimdDirective::Create(
2275     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2276     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2277     const HelperExprs &Exprs) {
2278   auto *Dir = createDirective<OMPTargetTeamsDistributeSimdDirective>(
2279       C, Clauses, AssociatedStmt,
2280       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),
2281       StartLoc, EndLoc, CollapsedNum);
2282   Dir->setIterationVariable(Exprs.IterationVarRef);
2283   Dir->setLastIteration(Exprs.LastIteration);
2284   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2285   Dir->setPreCond(Exprs.PreCond);
2286   Dir->setCond(Exprs.Cond);
2287   Dir->setInit(Exprs.Init);
2288   Dir->setInc(Exprs.Inc);
2289   Dir->setIsLastIterVariable(Exprs.IL);
2290   Dir->setLowerBoundVariable(Exprs.LB);
2291   Dir->setUpperBoundVariable(Exprs.UB);
2292   Dir->setStrideVariable(Exprs.ST);
2293   Dir->setEnsureUpperBound(Exprs.EUB);
2294   Dir->setNextLowerBound(Exprs.NLB);
2295   Dir->setNextUpperBound(Exprs.NUB);
2296   Dir->setNumIterations(Exprs.NumIterations);
2297   Dir->setCounters(Exprs.Counters);
2298   Dir->setPrivateCounters(Exprs.PrivateCounters);
2299   Dir->setInits(Exprs.Inits);
2300   Dir->setUpdates(Exprs.Updates);
2301   Dir->setFinals(Exprs.Finals);
2302   Dir->setDependentCounters(Exprs.DependentCounters);
2303   Dir->setDependentInits(Exprs.DependentInits);
2304   Dir->setFinalsConditions(Exprs.FinalsConditions);
2305   Dir->setPreInits(Exprs.PreInits);
2306   return Dir;
2307 }
2308 
2309 OMPTargetTeamsDistributeSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2310 OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
2311                                                    unsigned NumClauses,
2312                                                    unsigned CollapsedNum,
2313                                                    EmptyShell) {
2314   return createEmptyDirective<OMPTargetTeamsDistributeSimdDirective>(
2315       C, NumClauses, /*HasAssociatedStmt=*/true,
2316       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),
2317       CollapsedNum);
2318 }
2319 
2320 OMPInteropDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)2321 OMPInteropDirective::Create(const ASTContext &C, SourceLocation StartLoc,
2322                             SourceLocation EndLoc,
2323                             ArrayRef<OMPClause *> Clauses) {
2324   return createDirective<OMPInteropDirective>(
2325       C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
2326       EndLoc);
2327 }
2328 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)2329 OMPInteropDirective *OMPInteropDirective::CreateEmpty(const ASTContext &C,
2330                                                       unsigned NumClauses,
2331                                                       EmptyShell) {
2332   return createEmptyDirective<OMPInteropDirective>(C, NumClauses);
2333 }
2334 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,SourceLocation TargetCallLoc)2335 OMPDispatchDirective *OMPDispatchDirective::Create(
2336     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2337     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2338     SourceLocation TargetCallLoc) {
2339   auto *Dir = createDirective<OMPDispatchDirective>(
2340       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
2341   Dir->setTargetCallLoc(TargetCallLoc);
2342   return Dir;
2343 }
2344 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)2345 OMPDispatchDirective *OMPDispatchDirective::CreateEmpty(const ASTContext &C,
2346                                                         unsigned NumClauses,
2347                                                         EmptyShell) {
2348   return createEmptyDirective<OMPDispatchDirective>(C, NumClauses,
2349                                                     /*HasAssociatedStmt=*/true,
2350                                                     /*NumChildren=*/0);
2351 }
2352 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)2353 OMPMaskedDirective *OMPMaskedDirective::Create(const ASTContext &C,
2354                                                SourceLocation StartLoc,
2355                                                SourceLocation EndLoc,
2356                                                ArrayRef<OMPClause *> Clauses,
2357                                                Stmt *AssociatedStmt) {
2358   return createDirective<OMPMaskedDirective>(C, Clauses, AssociatedStmt,
2359                                              /*NumChildren=*/0, StartLoc,
2360                                              EndLoc);
2361 }
2362 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)2363 OMPMaskedDirective *OMPMaskedDirective::CreateEmpty(const ASTContext &C,
2364                                                     unsigned NumClauses,
2365                                                     EmptyShell) {
2366   return createEmptyDirective<OMPMaskedDirective>(C, NumClauses,
2367                                                   /*HasAssociatedStmt=*/true);
2368 }
2369 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)2370 OMPGenericLoopDirective *OMPGenericLoopDirective::Create(
2371     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2372     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2373     const HelperExprs &Exprs) {
2374   auto *Dir = createDirective<OMPGenericLoopDirective>(
2375       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_loop),
2376       StartLoc, EndLoc, CollapsedNum);
2377   Dir->setIterationVariable(Exprs.IterationVarRef);
2378   Dir->setLastIteration(Exprs.LastIteration);
2379   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2380   Dir->setPreCond(Exprs.PreCond);
2381   Dir->setCond(Exprs.Cond);
2382   Dir->setInit(Exprs.Init);
2383   Dir->setInc(Exprs.Inc);
2384   Dir->setIsLastIterVariable(Exprs.IL);
2385   Dir->setLowerBoundVariable(Exprs.LB);
2386   Dir->setUpperBoundVariable(Exprs.UB);
2387   Dir->setStrideVariable(Exprs.ST);
2388   Dir->setEnsureUpperBound(Exprs.EUB);
2389   Dir->setNextLowerBound(Exprs.NLB);
2390   Dir->setNextUpperBound(Exprs.NUB);
2391   Dir->setNumIterations(Exprs.NumIterations);
2392   Dir->setCounters(Exprs.Counters);
2393   Dir->setPrivateCounters(Exprs.PrivateCounters);
2394   Dir->setInits(Exprs.Inits);
2395   Dir->setUpdates(Exprs.Updates);
2396   Dir->setFinals(Exprs.Finals);
2397   Dir->setDependentCounters(Exprs.DependentCounters);
2398   Dir->setDependentInits(Exprs.DependentInits);
2399   Dir->setFinalsConditions(Exprs.FinalsConditions);
2400   Dir->setPreInits(Exprs.PreInits);
2401   return Dir;
2402 }
2403 
2404 OMPGenericLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2405 OMPGenericLoopDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
2406                                      unsigned CollapsedNum, EmptyShell) {
2407   return createEmptyDirective<OMPGenericLoopDirective>(
2408       C, NumClauses, /*HasAssociatedStmt=*/true,
2409       numLoopChildren(CollapsedNum, OMPD_loop), CollapsedNum);
2410 }
2411 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)2412 OMPTeamsGenericLoopDirective *OMPTeamsGenericLoopDirective::Create(
2413     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2414     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2415     const HelperExprs &Exprs) {
2416   auto *Dir = createDirective<OMPTeamsGenericLoopDirective>(
2417       C, Clauses, AssociatedStmt,
2418       numLoopChildren(CollapsedNum, OMPD_teams_loop), StartLoc, EndLoc,
2419       CollapsedNum);
2420   Dir->setIterationVariable(Exprs.IterationVarRef);
2421   Dir->setLastIteration(Exprs.LastIteration);
2422   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2423   Dir->setPreCond(Exprs.PreCond);
2424   Dir->setCond(Exprs.Cond);
2425   Dir->setInit(Exprs.Init);
2426   Dir->setInc(Exprs.Inc);
2427   Dir->setIsLastIterVariable(Exprs.IL);
2428   Dir->setLowerBoundVariable(Exprs.LB);
2429   Dir->setUpperBoundVariable(Exprs.UB);
2430   Dir->setStrideVariable(Exprs.ST);
2431   Dir->setEnsureUpperBound(Exprs.EUB);
2432   Dir->setNextLowerBound(Exprs.NLB);
2433   Dir->setNextUpperBound(Exprs.NUB);
2434   Dir->setNumIterations(Exprs.NumIterations);
2435   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2436   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2437   Dir->setDistInc(Exprs.DistInc);
2438   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2439   Dir->setCounters(Exprs.Counters);
2440   Dir->setPrivateCounters(Exprs.PrivateCounters);
2441   Dir->setInits(Exprs.Inits);
2442   Dir->setUpdates(Exprs.Updates);
2443   Dir->setFinals(Exprs.Finals);
2444   Dir->setDependentCounters(Exprs.DependentCounters);
2445   Dir->setDependentInits(Exprs.DependentInits);
2446   Dir->setFinalsConditions(Exprs.FinalsConditions);
2447   Dir->setPreInits(Exprs.PreInits);
2448   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2449   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2450   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2451   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2452   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2453   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2454   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2455   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2456   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2457   return Dir;
2458 }
2459 
2460 OMPTeamsGenericLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2461 OMPTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,
2462                                           unsigned NumClauses,
2463                                           unsigned CollapsedNum, EmptyShell) {
2464   return createEmptyDirective<OMPTeamsGenericLoopDirective>(
2465       C, NumClauses, /*HasAssociatedStmt=*/true,
2466       numLoopChildren(CollapsedNum, OMPD_teams_loop), CollapsedNum);
2467 }
2468 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool CanBeParallelFor)2469 OMPTargetTeamsGenericLoopDirective *OMPTargetTeamsGenericLoopDirective::Create(
2470     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2471     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2472     const HelperExprs &Exprs, bool CanBeParallelFor) {
2473   auto *Dir = createDirective<OMPTargetTeamsGenericLoopDirective>(
2474       C, Clauses, AssociatedStmt,
2475       numLoopChildren(CollapsedNum, OMPD_target_teams_loop), StartLoc, EndLoc,
2476       CollapsedNum);
2477   Dir->setIterationVariable(Exprs.IterationVarRef);
2478   Dir->setLastIteration(Exprs.LastIteration);
2479   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2480   Dir->setPreCond(Exprs.PreCond);
2481   Dir->setCond(Exprs.Cond);
2482   Dir->setInit(Exprs.Init);
2483   Dir->setInc(Exprs.Inc);
2484   Dir->setIsLastIterVariable(Exprs.IL);
2485   Dir->setLowerBoundVariable(Exprs.LB);
2486   Dir->setUpperBoundVariable(Exprs.UB);
2487   Dir->setStrideVariable(Exprs.ST);
2488   Dir->setEnsureUpperBound(Exprs.EUB);
2489   Dir->setNextLowerBound(Exprs.NLB);
2490   Dir->setNextUpperBound(Exprs.NUB);
2491   Dir->setNumIterations(Exprs.NumIterations);
2492   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
2493   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
2494   Dir->setDistInc(Exprs.DistInc);
2495   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
2496   Dir->setCounters(Exprs.Counters);
2497   Dir->setPrivateCounters(Exprs.PrivateCounters);
2498   Dir->setInits(Exprs.Inits);
2499   Dir->setUpdates(Exprs.Updates);
2500   Dir->setFinals(Exprs.Finals);
2501   Dir->setDependentCounters(Exprs.DependentCounters);
2502   Dir->setDependentInits(Exprs.DependentInits);
2503   Dir->setFinalsConditions(Exprs.FinalsConditions);
2504   Dir->setPreInits(Exprs.PreInits);
2505   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2506   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2507   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2508   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2509   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2510   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2511   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
2512   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2513   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
2514   Dir->setCanBeParallelFor(CanBeParallelFor);
2515   return Dir;
2516 }
2517 
2518 OMPTargetTeamsGenericLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2519 OMPTargetTeamsGenericLoopDirective::CreateEmpty(const ASTContext &C,
2520                                                 unsigned NumClauses,
2521                                                 unsigned CollapsedNum,
2522                                                 EmptyShell) {
2523   return createEmptyDirective<OMPTargetTeamsGenericLoopDirective>(
2524       C, NumClauses, /*HasAssociatedStmt=*/true,
2525       numLoopChildren(CollapsedNum, OMPD_target_teams_loop), CollapsedNum);
2526 }
2527 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)2528 OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::Create(
2529     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2530     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2531     const HelperExprs &Exprs) {
2532   auto *Dir = createDirective<OMPParallelGenericLoopDirective>(
2533       C, Clauses, AssociatedStmt,
2534       numLoopChildren(CollapsedNum, OMPD_parallel_loop), StartLoc, EndLoc,
2535       CollapsedNum);
2536   Dir->setIterationVariable(Exprs.IterationVarRef);
2537   Dir->setLastIteration(Exprs.LastIteration);
2538   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2539   Dir->setPreCond(Exprs.PreCond);
2540   Dir->setCond(Exprs.Cond);
2541   Dir->setInit(Exprs.Init);
2542   Dir->setInc(Exprs.Inc);
2543   Dir->setIsLastIterVariable(Exprs.IL);
2544   Dir->setLowerBoundVariable(Exprs.LB);
2545   Dir->setUpperBoundVariable(Exprs.UB);
2546   Dir->setStrideVariable(Exprs.ST);
2547   Dir->setEnsureUpperBound(Exprs.EUB);
2548   Dir->setNextLowerBound(Exprs.NLB);
2549   Dir->setNextUpperBound(Exprs.NUB);
2550   Dir->setNumIterations(Exprs.NumIterations);
2551   Dir->setCounters(Exprs.Counters);
2552   Dir->setPrivateCounters(Exprs.PrivateCounters);
2553   Dir->setInits(Exprs.Inits);
2554   Dir->setUpdates(Exprs.Updates);
2555   Dir->setFinals(Exprs.Finals);
2556   Dir->setDependentCounters(Exprs.DependentCounters);
2557   Dir->setDependentInits(Exprs.DependentInits);
2558   Dir->setFinalsConditions(Exprs.FinalsConditions);
2559   Dir->setPreInits(Exprs.PreInits);
2560   return Dir;
2561 }
2562 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2563 OMPParallelGenericLoopDirective *OMPParallelGenericLoopDirective::CreateEmpty(
2564     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
2565     EmptyShell) {
2566   return createEmptyDirective<OMPParallelGenericLoopDirective>(
2567       C, NumClauses, /*HasAssociatedStmt=*/true,
2568       numLoopChildren(CollapsedNum, OMPD_parallel_loop), CollapsedNum);
2569 }
2570 
2571 OMPTargetParallelGenericLoopDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)2572 OMPTargetParallelGenericLoopDirective::Create(
2573     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2574     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2575     const HelperExprs &Exprs) {
2576   auto *Dir = createDirective<OMPTargetParallelGenericLoopDirective>(
2577       C, Clauses, AssociatedStmt,
2578       numLoopChildren(CollapsedNum, OMPD_target_parallel_loop), StartLoc,
2579       EndLoc, CollapsedNum);
2580   Dir->setIterationVariable(Exprs.IterationVarRef);
2581   Dir->setLastIteration(Exprs.LastIteration);
2582   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2583   Dir->setPreCond(Exprs.PreCond);
2584   Dir->setCond(Exprs.Cond);
2585   Dir->setInit(Exprs.Init);
2586   Dir->setInc(Exprs.Inc);
2587   Dir->setIsLastIterVariable(Exprs.IL);
2588   Dir->setLowerBoundVariable(Exprs.LB);
2589   Dir->setUpperBoundVariable(Exprs.UB);
2590   Dir->setStrideVariable(Exprs.ST);
2591   Dir->setEnsureUpperBound(Exprs.EUB);
2592   Dir->setNextLowerBound(Exprs.NLB);
2593   Dir->setNextUpperBound(Exprs.NUB);
2594   Dir->setNumIterations(Exprs.NumIterations);
2595   Dir->setCounters(Exprs.Counters);
2596   Dir->setPrivateCounters(Exprs.PrivateCounters);
2597   Dir->setInits(Exprs.Inits);
2598   Dir->setUpdates(Exprs.Updates);
2599   Dir->setFinals(Exprs.Finals);
2600   Dir->setDependentCounters(Exprs.DependentCounters);
2601   Dir->setDependentInits(Exprs.DependentInits);
2602   Dir->setFinalsConditions(Exprs.FinalsConditions);
2603   Dir->setPreInits(Exprs.PreInits);
2604   return Dir;
2605 }
2606 
2607 OMPTargetParallelGenericLoopDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)2608 OMPTargetParallelGenericLoopDirective::CreateEmpty(const ASTContext &C,
2609                                                    unsigned NumClauses,
2610                                                    unsigned CollapsedNum,
2611                                                    EmptyShell) {
2612   return createEmptyDirective<OMPTargetParallelGenericLoopDirective>(
2613       C, NumClauses, /*HasAssociatedStmt=*/true,
2614       numLoopChildren(CollapsedNum, OMPD_target_parallel_loop), CollapsedNum);
2615 }
2616