xref: /freebsd/contrib/llvm-project/clang/lib/AST/StmtOpenMP.cpp (revision 77013d11e6483b970af25e13c9b892075742f7e5)
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 subclesses 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 
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 
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 
33 MutableArrayRef<Stmt *> OMPChildren::getChildren() {
34   return llvm::makeMutableArrayRef(getTrailingObjects<Stmt *>(), NumChildren);
35 }
36 
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 
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 
52 OMPChildren *OMPChildren::CreateEmpty(void *Mem, unsigned NumClauses,
53                                       bool HasAssociatedStmt,
54                                       unsigned NumChildren) {
55   return new (Mem) OMPChildren(NumClauses, NumChildren, HasAssociatedStmt);
56 }
57 
58 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 
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 *OMPLoopDirective::tryToFindNextInnerLoop(Stmt *CurStmt,
78                                                bool TryImperfectlyNestedLoops) {
79   Stmt *OrigStmt = CurStmt;
80   CurStmt = CurStmt->IgnoreContainers();
81   // Additional work for imperfectly nested loops, introduced in OpenMP 5.0.
82   if (TryImperfectlyNestedLoops) {
83     if (auto *CS = dyn_cast<CompoundStmt>(CurStmt)) {
84       CurStmt = nullptr;
85       SmallVector<CompoundStmt *, 4> Statements(1, CS);
86       SmallVector<CompoundStmt *, 4> NextStatements;
87       while (!Statements.empty()) {
88         CS = Statements.pop_back_val();
89         if (!CS)
90           continue;
91         for (Stmt *S : CS->body()) {
92           if (!S)
93             continue;
94           if (isa<ForStmt>(S) || isa<CXXForRangeStmt>(S)) {
95             // Only single loop construct is allowed.
96             if (CurStmt) {
97               CurStmt = OrigStmt;
98               break;
99             }
100             CurStmt = S;
101             continue;
102           }
103           S = S->IgnoreContainers();
104           if (auto *InnerCS = dyn_cast_or_null<CompoundStmt>(S))
105             NextStatements.push_back(InnerCS);
106         }
107         if (Statements.empty()) {
108           // Found single inner loop or multiple loops - exit.
109           if (CurStmt)
110             break;
111           Statements.swap(NextStatements);
112         }
113       }
114       if (!CurStmt)
115         CurStmt = OrigStmt;
116     }
117   }
118   return CurStmt;
119 }
120 
121 Stmt *OMPLoopDirective::getBody() {
122   // This relies on the loop form is already checked by Sema.
123   Stmt *Body = Data->getRawStmt()->IgnoreContainers();
124   if (auto *For = dyn_cast<ForStmt>(Body)) {
125     Body = For->getBody();
126   } else {
127     assert(isa<CXXForRangeStmt>(Body) &&
128            "Expected canonical for loop or range-based for loop.");
129     Body = cast<CXXForRangeStmt>(Body)->getBody();
130   }
131   for (unsigned Cnt = 1; Cnt < CollapsedNum; ++Cnt) {
132     Body = tryToFindNextInnerLoop(Body, /*TryImperfectlyNestedLoops=*/true);
133     if (auto *For = dyn_cast<ForStmt>(Body)) {
134       Body = For->getBody();
135     } else {
136       assert(isa<CXXForRangeStmt>(Body) &&
137              "Expected canonical for loop or range-based for loop.");
138       Body = cast<CXXForRangeStmt>(Body)->getBody();
139     }
140   }
141   return Body;
142 }
143 
144 void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
145   assert(A.size() == getCollapsedNumber() &&
146          "Number of loop counters is not the same as the collapsed number");
147   llvm::copy(A, getCounters().begin());
148 }
149 
150 void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
151   assert(A.size() == getCollapsedNumber() && "Number of loop private counters "
152                                              "is not the same as the collapsed "
153                                              "number");
154   llvm::copy(A, getPrivateCounters().begin());
155 }
156 
157 void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
158   assert(A.size() == getCollapsedNumber() &&
159          "Number of counter inits is not the same as the collapsed number");
160   llvm::copy(A, getInits().begin());
161 }
162 
163 void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
164   assert(A.size() == getCollapsedNumber() &&
165          "Number of counter updates is not the same as the collapsed number");
166   llvm::copy(A, getUpdates().begin());
167 }
168 
169 void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
170   assert(A.size() == getCollapsedNumber() &&
171          "Number of counter finals is not the same as the collapsed number");
172   llvm::copy(A, getFinals().begin());
173 }
174 
175 void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) {
176   assert(
177       A.size() == getCollapsedNumber() &&
178       "Number of dependent counters is not the same as the collapsed number");
179   llvm::copy(A, getDependentCounters().begin());
180 }
181 
182 void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) {
183   assert(A.size() == getCollapsedNumber() &&
184          "Number of dependent inits is not the same as the collapsed number");
185   llvm::copy(A, getDependentInits().begin());
186 }
187 
188 void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {
189   assert(A.size() == getCollapsedNumber() &&
190          "Number of finals conditions is not the same as the collapsed number");
191   llvm::copy(A, getFinalsConditions().begin());
192 }
193 
194 OMPParallelDirective *OMPParallelDirective::Create(
195     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
196     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
197     bool HasCancel) {
198   auto *Dir = createDirective<OMPParallelDirective>(
199       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
200   Dir->setTaskReductionRefExpr(TaskRedRef);
201   Dir->setHasCancel(HasCancel);
202   return Dir;
203 }
204 
205 OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
206                                                         unsigned NumClauses,
207                                                         EmptyShell) {
208   return createEmptyDirective<OMPParallelDirective>(C, NumClauses,
209                                                     /*HasAssociatedStmt=*/true,
210                                                     /*NumChildren=*/1);
211 }
212 
213 OMPSimdDirective *
214 OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
215                          SourceLocation EndLoc, unsigned CollapsedNum,
216                          ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
217                          const HelperExprs &Exprs) {
218   auto *Dir = createDirective<OMPSimdDirective>(
219       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_simd),
220       StartLoc, EndLoc, CollapsedNum);
221   Dir->setIterationVariable(Exprs.IterationVarRef);
222   Dir->setLastIteration(Exprs.LastIteration);
223   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
224   Dir->setPreCond(Exprs.PreCond);
225   Dir->setCond(Exprs.Cond);
226   Dir->setInit(Exprs.Init);
227   Dir->setInc(Exprs.Inc);
228   Dir->setCounters(Exprs.Counters);
229   Dir->setPrivateCounters(Exprs.PrivateCounters);
230   Dir->setInits(Exprs.Inits);
231   Dir->setUpdates(Exprs.Updates);
232   Dir->setFinals(Exprs.Finals);
233   Dir->setDependentCounters(Exprs.DependentCounters);
234   Dir->setDependentInits(Exprs.DependentInits);
235   Dir->setFinalsConditions(Exprs.FinalsConditions);
236   Dir->setPreInits(Exprs.PreInits);
237   return Dir;
238 }
239 
240 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
241                                                 unsigned NumClauses,
242                                                 unsigned CollapsedNum,
243                                                 EmptyShell) {
244   return createEmptyDirective<OMPSimdDirective>(
245       C, NumClauses, /*HasAssociatedStmt=*/true,
246       numLoopChildren(CollapsedNum, OMPD_simd), CollapsedNum);
247 }
248 
249 OMPForDirective *OMPForDirective::Create(
250     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
251     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
252     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
253   auto *Dir = createDirective<OMPForDirective>(
254       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for) + 1,
255       StartLoc, EndLoc, CollapsedNum);
256   Dir->setIterationVariable(Exprs.IterationVarRef);
257   Dir->setLastIteration(Exprs.LastIteration);
258   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
259   Dir->setPreCond(Exprs.PreCond);
260   Dir->setCond(Exprs.Cond);
261   Dir->setInit(Exprs.Init);
262   Dir->setInc(Exprs.Inc);
263   Dir->setIsLastIterVariable(Exprs.IL);
264   Dir->setLowerBoundVariable(Exprs.LB);
265   Dir->setUpperBoundVariable(Exprs.UB);
266   Dir->setStrideVariable(Exprs.ST);
267   Dir->setEnsureUpperBound(Exprs.EUB);
268   Dir->setNextLowerBound(Exprs.NLB);
269   Dir->setNextUpperBound(Exprs.NUB);
270   Dir->setNumIterations(Exprs.NumIterations);
271   Dir->setCounters(Exprs.Counters);
272   Dir->setPrivateCounters(Exprs.PrivateCounters);
273   Dir->setInits(Exprs.Inits);
274   Dir->setUpdates(Exprs.Updates);
275   Dir->setFinals(Exprs.Finals);
276   Dir->setDependentCounters(Exprs.DependentCounters);
277   Dir->setDependentInits(Exprs.DependentInits);
278   Dir->setFinalsConditions(Exprs.FinalsConditions);
279   Dir->setPreInits(Exprs.PreInits);
280   Dir->setTaskReductionRefExpr(TaskRedRef);
281   Dir->setHasCancel(HasCancel);
282   return Dir;
283 }
284 
285 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
286                                               unsigned NumClauses,
287                                               unsigned CollapsedNum,
288                                               EmptyShell) {
289   return createEmptyDirective<OMPForDirective>(
290       C, NumClauses, /*HasAssociatedStmt=*/true,
291       numLoopChildren(CollapsedNum, OMPD_for) + 1, CollapsedNum);
292 }
293 
294 OMPForSimdDirective *
295 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
296                             SourceLocation EndLoc, unsigned CollapsedNum,
297                             ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
298                             const HelperExprs &Exprs) {
299   auto *Dir = createDirective<OMPForSimdDirective>(
300       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_for_simd),
301       StartLoc, EndLoc, CollapsedNum);
302   Dir->setIterationVariable(Exprs.IterationVarRef);
303   Dir->setLastIteration(Exprs.LastIteration);
304   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
305   Dir->setPreCond(Exprs.PreCond);
306   Dir->setCond(Exprs.Cond);
307   Dir->setInit(Exprs.Init);
308   Dir->setInc(Exprs.Inc);
309   Dir->setIsLastIterVariable(Exprs.IL);
310   Dir->setLowerBoundVariable(Exprs.LB);
311   Dir->setUpperBoundVariable(Exprs.UB);
312   Dir->setStrideVariable(Exprs.ST);
313   Dir->setEnsureUpperBound(Exprs.EUB);
314   Dir->setNextLowerBound(Exprs.NLB);
315   Dir->setNextUpperBound(Exprs.NUB);
316   Dir->setNumIterations(Exprs.NumIterations);
317   Dir->setCounters(Exprs.Counters);
318   Dir->setPrivateCounters(Exprs.PrivateCounters);
319   Dir->setInits(Exprs.Inits);
320   Dir->setUpdates(Exprs.Updates);
321   Dir->setFinals(Exprs.Finals);
322   Dir->setDependentCounters(Exprs.DependentCounters);
323   Dir->setDependentInits(Exprs.DependentInits);
324   Dir->setFinalsConditions(Exprs.FinalsConditions);
325   Dir->setPreInits(Exprs.PreInits);
326   return Dir;
327 }
328 
329 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
330                                                       unsigned NumClauses,
331                                                       unsigned CollapsedNum,
332                                                       EmptyShell) {
333   return createEmptyDirective<OMPForSimdDirective>(
334       C, NumClauses, /*HasAssociatedStmt=*/true,
335       numLoopChildren(CollapsedNum, OMPD_for_simd), CollapsedNum);
336 }
337 
338 OMPSectionsDirective *OMPSectionsDirective::Create(
339     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
340     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
341     bool HasCancel) {
342   auto *Dir = createDirective<OMPSectionsDirective>(C, Clauses, AssociatedStmt,
343                                                     /*NumChildren=*/1, StartLoc,
344                                                     EndLoc);
345   Dir->setTaskReductionRefExpr(TaskRedRef);
346   Dir->setHasCancel(HasCancel);
347   return Dir;
348 }
349 
350 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
351                                                         unsigned NumClauses,
352                                                         EmptyShell) {
353   return createEmptyDirective<OMPSectionsDirective>(C, NumClauses,
354                                                     /*HasAssociatedStmt=*/true,
355                                                     /*NumChildren=*/1);
356 }
357 
358 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
359                                                  SourceLocation StartLoc,
360                                                  SourceLocation EndLoc,
361                                                  Stmt *AssociatedStmt,
362                                                  bool HasCancel) {
363   auto *Dir =
364       createDirective<OMPSectionDirective>(C, llvm::None, AssociatedStmt,
365                                            /*NumChildre=*/0, StartLoc, EndLoc);
366   Dir->setHasCancel(HasCancel);
367   return Dir;
368 }
369 
370 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
371                                                       EmptyShell) {
372   return createEmptyDirective<OMPSectionDirective>(C, /*NumClauses=*/0,
373                                                    /*HasAssociatedStmt=*/true);
374 }
375 
376 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
377                                                SourceLocation StartLoc,
378                                                SourceLocation EndLoc,
379                                                ArrayRef<OMPClause *> Clauses,
380                                                Stmt *AssociatedStmt) {
381   return createDirective<OMPSingleDirective>(C, Clauses, AssociatedStmt,
382                                              /*NumChildren=*/0, StartLoc,
383                                              EndLoc);
384 }
385 
386 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
387                                                     unsigned NumClauses,
388                                                     EmptyShell) {
389   return createEmptyDirective<OMPSingleDirective>(C, NumClauses,
390                                                   /*HasAssociatedStmt=*/true);
391 }
392 
393 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
394                                                SourceLocation StartLoc,
395                                                SourceLocation EndLoc,
396                                                Stmt *AssociatedStmt) {
397   return createDirective<OMPMasterDirective>(C, llvm::None, AssociatedStmt,
398                                              /*NumChildren=*/0, StartLoc,
399                                              EndLoc);
400 }
401 
402 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
403                                                     EmptyShell) {
404   return createEmptyDirective<OMPMasterDirective>(C, /*NumClauses=*/0,
405                                                   /*HasAssociatedStmt=*/true);
406 }
407 
408 OMPCriticalDirective *OMPCriticalDirective::Create(
409     const ASTContext &C, const DeclarationNameInfo &Name,
410     SourceLocation StartLoc, SourceLocation EndLoc,
411     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
412   return createDirective<OMPCriticalDirective>(C, Clauses, AssociatedStmt,
413                                                /*NumChildren=*/0, Name,
414                                                StartLoc, EndLoc);
415 }
416 
417 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
418                                                         unsigned NumClauses,
419                                                         EmptyShell) {
420   return createEmptyDirective<OMPCriticalDirective>(C, NumClauses,
421                                                     /*HasAssociatedStmt=*/true);
422 }
423 
424 OMPParallelForDirective *OMPParallelForDirective::Create(
425     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
426     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
427     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
428   auto *Dir = createDirective<OMPParallelForDirective>(
429       C, Clauses, AssociatedStmt,
430       numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, StartLoc, EndLoc,
431       CollapsedNum);
432   Dir->setIterationVariable(Exprs.IterationVarRef);
433   Dir->setLastIteration(Exprs.LastIteration);
434   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
435   Dir->setPreCond(Exprs.PreCond);
436   Dir->setCond(Exprs.Cond);
437   Dir->setInit(Exprs.Init);
438   Dir->setInc(Exprs.Inc);
439   Dir->setIsLastIterVariable(Exprs.IL);
440   Dir->setLowerBoundVariable(Exprs.LB);
441   Dir->setUpperBoundVariable(Exprs.UB);
442   Dir->setStrideVariable(Exprs.ST);
443   Dir->setEnsureUpperBound(Exprs.EUB);
444   Dir->setNextLowerBound(Exprs.NLB);
445   Dir->setNextUpperBound(Exprs.NUB);
446   Dir->setNumIterations(Exprs.NumIterations);
447   Dir->setCounters(Exprs.Counters);
448   Dir->setPrivateCounters(Exprs.PrivateCounters);
449   Dir->setInits(Exprs.Inits);
450   Dir->setUpdates(Exprs.Updates);
451   Dir->setFinals(Exprs.Finals);
452   Dir->setDependentCounters(Exprs.DependentCounters);
453   Dir->setDependentInits(Exprs.DependentInits);
454   Dir->setFinalsConditions(Exprs.FinalsConditions);
455   Dir->setPreInits(Exprs.PreInits);
456   Dir->setTaskReductionRefExpr(TaskRedRef);
457   Dir->setHasCancel(HasCancel);
458   return Dir;
459 }
460 
461 OMPParallelForDirective *
462 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
463                                      unsigned CollapsedNum, EmptyShell) {
464   return createEmptyDirective<OMPParallelForDirective>(
465       C, NumClauses, /*HasAssociatedStmt=*/true,
466       numLoopChildren(CollapsedNum, OMPD_parallel_for) + 1, CollapsedNum);
467 }
468 
469 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
470     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
471     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
472     const HelperExprs &Exprs) {
473   auto *Dir = createDirective<OMPParallelForSimdDirective>(
474       C, Clauses, AssociatedStmt,
475       numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), StartLoc, EndLoc,
476       CollapsedNum);
477   Dir->setIterationVariable(Exprs.IterationVarRef);
478   Dir->setLastIteration(Exprs.LastIteration);
479   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
480   Dir->setPreCond(Exprs.PreCond);
481   Dir->setCond(Exprs.Cond);
482   Dir->setInit(Exprs.Init);
483   Dir->setInc(Exprs.Inc);
484   Dir->setIsLastIterVariable(Exprs.IL);
485   Dir->setLowerBoundVariable(Exprs.LB);
486   Dir->setUpperBoundVariable(Exprs.UB);
487   Dir->setStrideVariable(Exprs.ST);
488   Dir->setEnsureUpperBound(Exprs.EUB);
489   Dir->setNextLowerBound(Exprs.NLB);
490   Dir->setNextUpperBound(Exprs.NUB);
491   Dir->setNumIterations(Exprs.NumIterations);
492   Dir->setCounters(Exprs.Counters);
493   Dir->setPrivateCounters(Exprs.PrivateCounters);
494   Dir->setInits(Exprs.Inits);
495   Dir->setUpdates(Exprs.Updates);
496   Dir->setFinals(Exprs.Finals);
497   Dir->setDependentCounters(Exprs.DependentCounters);
498   Dir->setDependentInits(Exprs.DependentInits);
499   Dir->setFinalsConditions(Exprs.FinalsConditions);
500   Dir->setPreInits(Exprs.PreInits);
501   return Dir;
502 }
503 
504 OMPParallelForSimdDirective *
505 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
506                                          unsigned NumClauses,
507                                          unsigned CollapsedNum, EmptyShell) {
508   return createEmptyDirective<OMPParallelForSimdDirective>(
509       C, NumClauses, /*HasAssociatedStmt=*/true,
510       numLoopChildren(CollapsedNum, OMPD_parallel_for_simd), CollapsedNum);
511 }
512 
513 OMPParallelMasterDirective *OMPParallelMasterDirective::Create(
514     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
515     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef) {
516   auto *Dir = createDirective<OMPParallelMasterDirective>(
517       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
518   Dir->setTaskReductionRefExpr(TaskRedRef);
519   return Dir;
520 }
521 
522 OMPParallelMasterDirective *
523 OMPParallelMasterDirective::CreateEmpty(const ASTContext &C,
524                                         unsigned NumClauses, EmptyShell) {
525   return createEmptyDirective<OMPParallelMasterDirective>(
526       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
527 }
528 
529 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
530     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
531     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
532     bool HasCancel) {
533   auto *Dir = createDirective<OMPParallelSectionsDirective>(
534       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
535   Dir->setTaskReductionRefExpr(TaskRedRef);
536   Dir->setHasCancel(HasCancel);
537   return Dir;
538 }
539 
540 OMPParallelSectionsDirective *
541 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
542                                           unsigned NumClauses, EmptyShell) {
543   return createEmptyDirective<OMPParallelSectionsDirective>(
544       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
545 }
546 
547 OMPTaskDirective *
548 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
549                          SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
550                          Stmt *AssociatedStmt, bool HasCancel) {
551   auto *Dir = createDirective<OMPTaskDirective>(
552       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
553   Dir->setHasCancel(HasCancel);
554   return Dir;
555 }
556 
557 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
558                                                 unsigned NumClauses,
559                                                 EmptyShell) {
560   return createEmptyDirective<OMPTaskDirective>(C, NumClauses,
561                                                 /*HasAssociatedStmt=*/true);
562 }
563 
564 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
565                                                      SourceLocation StartLoc,
566                                                      SourceLocation EndLoc) {
567   return new (C) OMPTaskyieldDirective(StartLoc, EndLoc);
568 }
569 
570 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
571                                                           EmptyShell) {
572   return new (C) OMPTaskyieldDirective();
573 }
574 
575 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
576                                                  SourceLocation StartLoc,
577                                                  SourceLocation EndLoc) {
578   return new (C) OMPBarrierDirective(StartLoc, EndLoc);
579 }
580 
581 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
582                                                       EmptyShell) {
583   return new (C) OMPBarrierDirective();
584 }
585 
586 OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C,
587                                                    SourceLocation StartLoc,
588                                                    SourceLocation EndLoc) {
589   return new (C) OMPTaskwaitDirective(StartLoc, EndLoc);
590 }
591 
592 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
593                                                         EmptyShell) {
594   return new (C) OMPTaskwaitDirective();
595 }
596 
597 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
598     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
599     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
600   auto *Dir = createDirective<OMPTaskgroupDirective>(
601       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
602   Dir->setReductionRef(ReductionRef);
603   return Dir;
604 }
605 
606 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
607                                                           unsigned NumClauses,
608                                                           EmptyShell) {
609   return createEmptyDirective<OMPTaskgroupDirective>(
610       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
611 }
612 
613 OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
614     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
615     OpenMPDirectiveKind CancelRegion) {
616   auto *Dir = new (C) OMPCancellationPointDirective(StartLoc, EndLoc);
617   Dir->setCancelRegion(CancelRegion);
618   return Dir;
619 }
620 
621 OMPCancellationPointDirective *
622 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
623   return new (C) OMPCancellationPointDirective();
624 }
625 
626 OMPCancelDirective *
627 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
628                            SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
629                            OpenMPDirectiveKind CancelRegion) {
630   auto *Dir = createDirective<OMPCancelDirective>(
631       C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
632       EndLoc);
633   Dir->setCancelRegion(CancelRegion);
634   return Dir;
635 }
636 
637 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
638                                                     unsigned NumClauses,
639                                                     EmptyShell) {
640   return createEmptyDirective<OMPCancelDirective>(C, NumClauses);
641 }
642 
643 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
644                                              SourceLocation StartLoc,
645                                              SourceLocation EndLoc,
646                                              ArrayRef<OMPClause *> Clauses) {
647   return createDirective<OMPFlushDirective>(
648       C, Clauses, /*AssociatedStmt=*/nullptr, /*NumChildren=*/0, StartLoc,
649       EndLoc);
650 }
651 
652 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
653                                                   unsigned NumClauses,
654                                                   EmptyShell) {
655   return createEmptyDirective<OMPFlushDirective>(C, NumClauses);
656 }
657 
658 OMPDepobjDirective *OMPDepobjDirective::Create(const ASTContext &C,
659                                                SourceLocation StartLoc,
660                                                SourceLocation EndLoc,
661                                                ArrayRef<OMPClause *> Clauses) {
662   return createDirective<OMPDepobjDirective>(
663       C, Clauses, /*AssociatedStmt=*/nullptr,
664       /*NumChildren=*/0, StartLoc, EndLoc);
665 }
666 
667 OMPDepobjDirective *OMPDepobjDirective::CreateEmpty(const ASTContext &C,
668                                                     unsigned NumClauses,
669                                                     EmptyShell) {
670   return createEmptyDirective<OMPDepobjDirective>(C, NumClauses);
671 }
672 
673 OMPScanDirective *OMPScanDirective::Create(const ASTContext &C,
674                                            SourceLocation StartLoc,
675                                            SourceLocation EndLoc,
676                                            ArrayRef<OMPClause *> Clauses) {
677   return createDirective<OMPScanDirective>(C, Clauses,
678                                            /*AssociatedStmt=*/nullptr,
679                                            /*NumChildren=*/0, StartLoc, EndLoc);
680 }
681 
682 OMPScanDirective *OMPScanDirective::CreateEmpty(const ASTContext &C,
683                                                 unsigned NumClauses,
684                                                 EmptyShell) {
685   return createEmptyDirective<OMPScanDirective>(C, NumClauses);
686 }
687 
688 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
689                                                  SourceLocation StartLoc,
690                                                  SourceLocation EndLoc,
691                                                  ArrayRef<OMPClause *> Clauses,
692                                                  Stmt *AssociatedStmt) {
693   return createDirective<OMPOrderedDirective>(
694       C, Clauses, cast_or_null<CapturedStmt>(AssociatedStmt),
695       /*NumChildren=*/0, StartLoc, EndLoc);
696 }
697 
698 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
699                                                       unsigned NumClauses,
700                                                       bool IsStandalone,
701                                                       EmptyShell) {
702   return createEmptyDirective<OMPOrderedDirective>(C, NumClauses,
703                                                    !IsStandalone);
704 }
705 
706 OMPAtomicDirective *OMPAtomicDirective::Create(
707     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
708     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
709     Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
710   auto *Dir = createDirective<OMPAtomicDirective>(
711       C, Clauses, AssociatedStmt, /*NumChildren=*/4, StartLoc, EndLoc);
712   Dir->setX(X);
713   Dir->setV(V);
714   Dir->setExpr(E);
715   Dir->setUpdateExpr(UE);
716   Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
717   Dir->IsPostfixUpdate = IsPostfixUpdate;
718   return Dir;
719 }
720 
721 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
722                                                     unsigned NumClauses,
723                                                     EmptyShell) {
724   return createEmptyDirective<OMPAtomicDirective>(
725       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/4);
726 }
727 
728 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
729                                                SourceLocation StartLoc,
730                                                SourceLocation EndLoc,
731                                                ArrayRef<OMPClause *> Clauses,
732                                                Stmt *AssociatedStmt) {
733   return createDirective<OMPTargetDirective>(
734       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
735 }
736 
737 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
738                                                     unsigned NumClauses,
739                                                     EmptyShell) {
740   return createEmptyDirective<OMPTargetDirective>(C, NumClauses,
741                                                   /*HasAssociatedStmt=*/true);
742 }
743 
744 OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
745     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
746     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *TaskRedRef,
747     bool HasCancel) {
748   auto *Dir = createDirective<OMPTargetParallelDirective>(
749       C, Clauses, AssociatedStmt, /*NumChildren=*/1, StartLoc, EndLoc);
750   Dir->setTaskReductionRefExpr(TaskRedRef);
751   Dir->setHasCancel(HasCancel);
752   return Dir;
753 }
754 
755 OMPTargetParallelDirective *
756 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
757                                         unsigned NumClauses, EmptyShell) {
758   return createEmptyDirective<OMPTargetParallelDirective>(
759       C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1);
760 }
761 
762 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
763     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
764     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
765     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
766   auto *Dir = createDirective<OMPTargetParallelForDirective>(
767       C, Clauses, AssociatedStmt,
768       numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1, StartLoc,
769       EndLoc, CollapsedNum);
770   Dir->setIterationVariable(Exprs.IterationVarRef);
771   Dir->setLastIteration(Exprs.LastIteration);
772   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
773   Dir->setPreCond(Exprs.PreCond);
774   Dir->setCond(Exprs.Cond);
775   Dir->setInit(Exprs.Init);
776   Dir->setInc(Exprs.Inc);
777   Dir->setIsLastIterVariable(Exprs.IL);
778   Dir->setLowerBoundVariable(Exprs.LB);
779   Dir->setUpperBoundVariable(Exprs.UB);
780   Dir->setStrideVariable(Exprs.ST);
781   Dir->setEnsureUpperBound(Exprs.EUB);
782   Dir->setNextLowerBound(Exprs.NLB);
783   Dir->setNextUpperBound(Exprs.NUB);
784   Dir->setNumIterations(Exprs.NumIterations);
785   Dir->setCounters(Exprs.Counters);
786   Dir->setPrivateCounters(Exprs.PrivateCounters);
787   Dir->setInits(Exprs.Inits);
788   Dir->setUpdates(Exprs.Updates);
789   Dir->setFinals(Exprs.Finals);
790   Dir->setDependentCounters(Exprs.DependentCounters);
791   Dir->setDependentInits(Exprs.DependentInits);
792   Dir->setFinalsConditions(Exprs.FinalsConditions);
793   Dir->setPreInits(Exprs.PreInits);
794   Dir->setTaskReductionRefExpr(TaskRedRef);
795   Dir->setHasCancel(HasCancel);
796   return Dir;
797 }
798 
799 OMPTargetParallelForDirective *
800 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
801                                            unsigned NumClauses,
802                                            unsigned CollapsedNum, EmptyShell) {
803   return createEmptyDirective<OMPTargetParallelForDirective>(
804       C, NumClauses, /*HasAssociatedStmt=*/true,
805       numLoopChildren(CollapsedNum, OMPD_target_parallel_for) + 1,
806       CollapsedNum);
807 }
808 
809 OMPTargetDataDirective *OMPTargetDataDirective::Create(
810     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
811     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
812   return createDirective<OMPTargetDataDirective>(
813       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
814 }
815 
816 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
817                                                             unsigned N,
818                                                             EmptyShell) {
819   return createEmptyDirective<OMPTargetDataDirective>(
820       C, N, /*HasAssociatedStmt=*/true);
821 }
822 
823 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
824     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
825     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
826   return createDirective<OMPTargetEnterDataDirective>(
827       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
828 }
829 
830 OMPTargetEnterDataDirective *
831 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
832                                          EmptyShell) {
833   return createEmptyDirective<OMPTargetEnterDataDirective>(
834       C, N, /*HasAssociatedStmt=*/true);
835 }
836 
837 OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
838     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
839     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
840   return createDirective<OMPTargetExitDataDirective>(
841       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
842 }
843 
844 OMPTargetExitDataDirective *
845 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
846                                         EmptyShell) {
847   return createEmptyDirective<OMPTargetExitDataDirective>(
848       C, N, /*HasAssociatedStmt=*/true);
849 }
850 
851 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
852                                              SourceLocation StartLoc,
853                                              SourceLocation EndLoc,
854                                              ArrayRef<OMPClause *> Clauses,
855                                              Stmt *AssociatedStmt) {
856   return createDirective<OMPTeamsDirective>(
857       C, Clauses, AssociatedStmt, /*NumChildren=*/0, StartLoc, EndLoc);
858 }
859 
860 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
861                                                   unsigned NumClauses,
862                                                   EmptyShell) {
863   return createEmptyDirective<OMPTeamsDirective>(C, NumClauses,
864                                                  /*HasAssociatedStmt=*/true);
865 }
866 
867 OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
868     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
869     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
870     const HelperExprs &Exprs, bool HasCancel) {
871   auto *Dir = createDirective<OMPTaskLoopDirective>(
872       C, Clauses, AssociatedStmt, numLoopChildren(CollapsedNum, OMPD_taskloop),
873       StartLoc, EndLoc, CollapsedNum);
874   Dir->setIterationVariable(Exprs.IterationVarRef);
875   Dir->setLastIteration(Exprs.LastIteration);
876   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
877   Dir->setPreCond(Exprs.PreCond);
878   Dir->setCond(Exprs.Cond);
879   Dir->setInit(Exprs.Init);
880   Dir->setInc(Exprs.Inc);
881   Dir->setIsLastIterVariable(Exprs.IL);
882   Dir->setLowerBoundVariable(Exprs.LB);
883   Dir->setUpperBoundVariable(Exprs.UB);
884   Dir->setStrideVariable(Exprs.ST);
885   Dir->setEnsureUpperBound(Exprs.EUB);
886   Dir->setNextLowerBound(Exprs.NLB);
887   Dir->setNextUpperBound(Exprs.NUB);
888   Dir->setNumIterations(Exprs.NumIterations);
889   Dir->setCounters(Exprs.Counters);
890   Dir->setPrivateCounters(Exprs.PrivateCounters);
891   Dir->setInits(Exprs.Inits);
892   Dir->setUpdates(Exprs.Updates);
893   Dir->setFinals(Exprs.Finals);
894   Dir->setDependentCounters(Exprs.DependentCounters);
895   Dir->setDependentInits(Exprs.DependentInits);
896   Dir->setFinalsConditions(Exprs.FinalsConditions);
897   Dir->setPreInits(Exprs.PreInits);
898   Dir->setHasCancel(HasCancel);
899   return Dir;
900 }
901 
902 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
903                                                         unsigned NumClauses,
904                                                         unsigned CollapsedNum,
905                                                         EmptyShell) {
906   return createEmptyDirective<OMPTaskLoopDirective>(
907       C, NumClauses, /*HasAssociatedStmt=*/true,
908       numLoopChildren(CollapsedNum, OMPD_taskloop), CollapsedNum);
909 }
910 
911 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
912     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
913     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
914     const HelperExprs &Exprs) {
915   auto *Dir = createDirective<OMPTaskLoopSimdDirective>(
916       C, Clauses, AssociatedStmt,
917       numLoopChildren(CollapsedNum, OMPD_taskloop_simd), StartLoc, EndLoc,
918       CollapsedNum);
919   Dir->setIterationVariable(Exprs.IterationVarRef);
920   Dir->setLastIteration(Exprs.LastIteration);
921   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
922   Dir->setPreCond(Exprs.PreCond);
923   Dir->setCond(Exprs.Cond);
924   Dir->setInit(Exprs.Init);
925   Dir->setInc(Exprs.Inc);
926   Dir->setIsLastIterVariable(Exprs.IL);
927   Dir->setLowerBoundVariable(Exprs.LB);
928   Dir->setUpperBoundVariable(Exprs.UB);
929   Dir->setStrideVariable(Exprs.ST);
930   Dir->setEnsureUpperBound(Exprs.EUB);
931   Dir->setNextLowerBound(Exprs.NLB);
932   Dir->setNextUpperBound(Exprs.NUB);
933   Dir->setNumIterations(Exprs.NumIterations);
934   Dir->setCounters(Exprs.Counters);
935   Dir->setPrivateCounters(Exprs.PrivateCounters);
936   Dir->setInits(Exprs.Inits);
937   Dir->setUpdates(Exprs.Updates);
938   Dir->setFinals(Exprs.Finals);
939   Dir->setDependentCounters(Exprs.DependentCounters);
940   Dir->setDependentInits(Exprs.DependentInits);
941   Dir->setFinalsConditions(Exprs.FinalsConditions);
942   Dir->setPreInits(Exprs.PreInits);
943   return Dir;
944 }
945 
946 OMPTaskLoopSimdDirective *
947 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
948                                       unsigned CollapsedNum, EmptyShell) {
949   return createEmptyDirective<OMPTaskLoopSimdDirective>(
950       C, NumClauses, /*HasAssociatedStmt=*/true,
951       numLoopChildren(CollapsedNum, OMPD_taskloop_simd), CollapsedNum);
952 }
953 
954 OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
955     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
956     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
957     const HelperExprs &Exprs, bool HasCancel) {
958   auto *Dir = createDirective<OMPMasterTaskLoopDirective>(
959       C, Clauses, AssociatedStmt,
960       numLoopChildren(CollapsedNum, OMPD_master_taskloop), StartLoc, EndLoc,
961       CollapsedNum);
962   Dir->setIterationVariable(Exprs.IterationVarRef);
963   Dir->setLastIteration(Exprs.LastIteration);
964   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
965   Dir->setPreCond(Exprs.PreCond);
966   Dir->setCond(Exprs.Cond);
967   Dir->setInit(Exprs.Init);
968   Dir->setInc(Exprs.Inc);
969   Dir->setIsLastIterVariable(Exprs.IL);
970   Dir->setLowerBoundVariable(Exprs.LB);
971   Dir->setUpperBoundVariable(Exprs.UB);
972   Dir->setStrideVariable(Exprs.ST);
973   Dir->setEnsureUpperBound(Exprs.EUB);
974   Dir->setNextLowerBound(Exprs.NLB);
975   Dir->setNextUpperBound(Exprs.NUB);
976   Dir->setNumIterations(Exprs.NumIterations);
977   Dir->setCounters(Exprs.Counters);
978   Dir->setPrivateCounters(Exprs.PrivateCounters);
979   Dir->setInits(Exprs.Inits);
980   Dir->setUpdates(Exprs.Updates);
981   Dir->setFinals(Exprs.Finals);
982   Dir->setDependentCounters(Exprs.DependentCounters);
983   Dir->setDependentInits(Exprs.DependentInits);
984   Dir->setFinalsConditions(Exprs.FinalsConditions);
985   Dir->setPreInits(Exprs.PreInits);
986   Dir->setHasCancel(HasCancel);
987   return Dir;
988 }
989 
990 OMPMasterTaskLoopDirective *
991 OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
992                                         unsigned NumClauses,
993                                         unsigned CollapsedNum, EmptyShell) {
994   return createEmptyDirective<OMPMasterTaskLoopDirective>(
995       C, NumClauses, /*HasAssociatedStmt=*/true,
996       numLoopChildren(CollapsedNum, OMPD_master_taskloop), CollapsedNum);
997 }
998 
999 OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
1000     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1001     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1002     const HelperExprs &Exprs) {
1003   auto *Dir = createDirective<OMPMasterTaskLoopSimdDirective>(
1004       C, Clauses, AssociatedStmt,
1005       numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), StartLoc,
1006       EndLoc, CollapsedNum);
1007   Dir->setIterationVariable(Exprs.IterationVarRef);
1008   Dir->setLastIteration(Exprs.LastIteration);
1009   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1010   Dir->setPreCond(Exprs.PreCond);
1011   Dir->setCond(Exprs.Cond);
1012   Dir->setInit(Exprs.Init);
1013   Dir->setInc(Exprs.Inc);
1014   Dir->setIsLastIterVariable(Exprs.IL);
1015   Dir->setLowerBoundVariable(Exprs.LB);
1016   Dir->setUpperBoundVariable(Exprs.UB);
1017   Dir->setStrideVariable(Exprs.ST);
1018   Dir->setEnsureUpperBound(Exprs.EUB);
1019   Dir->setNextLowerBound(Exprs.NLB);
1020   Dir->setNextUpperBound(Exprs.NUB);
1021   Dir->setNumIterations(Exprs.NumIterations);
1022   Dir->setCounters(Exprs.Counters);
1023   Dir->setPrivateCounters(Exprs.PrivateCounters);
1024   Dir->setInits(Exprs.Inits);
1025   Dir->setUpdates(Exprs.Updates);
1026   Dir->setFinals(Exprs.Finals);
1027   Dir->setDependentCounters(Exprs.DependentCounters);
1028   Dir->setDependentInits(Exprs.DependentInits);
1029   Dir->setFinalsConditions(Exprs.FinalsConditions);
1030   Dir->setPreInits(Exprs.PreInits);
1031   return Dir;
1032 }
1033 
1034 OMPMasterTaskLoopSimdDirective *
1035 OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1036                                             unsigned NumClauses,
1037                                             unsigned CollapsedNum, EmptyShell) {
1038   return createEmptyDirective<OMPMasterTaskLoopSimdDirective>(
1039       C, NumClauses, /*HasAssociatedStmt=*/true,
1040       numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd), CollapsedNum);
1041 }
1042 
1043 OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
1044     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1045     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1046     const HelperExprs &Exprs, bool HasCancel) {
1047   auto *Dir = createDirective<OMPParallelMasterTaskLoopDirective>(
1048       C, Clauses, AssociatedStmt,
1049       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop), StartLoc,
1050       EndLoc, CollapsedNum);
1051   Dir->setIterationVariable(Exprs.IterationVarRef);
1052   Dir->setLastIteration(Exprs.LastIteration);
1053   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1054   Dir->setPreCond(Exprs.PreCond);
1055   Dir->setCond(Exprs.Cond);
1056   Dir->setInit(Exprs.Init);
1057   Dir->setInc(Exprs.Inc);
1058   Dir->setIsLastIterVariable(Exprs.IL);
1059   Dir->setLowerBoundVariable(Exprs.LB);
1060   Dir->setUpperBoundVariable(Exprs.UB);
1061   Dir->setStrideVariable(Exprs.ST);
1062   Dir->setEnsureUpperBound(Exprs.EUB);
1063   Dir->setNextLowerBound(Exprs.NLB);
1064   Dir->setNextUpperBound(Exprs.NUB);
1065   Dir->setNumIterations(Exprs.NumIterations);
1066   Dir->setCounters(Exprs.Counters);
1067   Dir->setPrivateCounters(Exprs.PrivateCounters);
1068   Dir->setInits(Exprs.Inits);
1069   Dir->setUpdates(Exprs.Updates);
1070   Dir->setFinals(Exprs.Finals);
1071   Dir->setDependentCounters(Exprs.DependentCounters);
1072   Dir->setDependentInits(Exprs.DependentInits);
1073   Dir->setFinalsConditions(Exprs.FinalsConditions);
1074   Dir->setPreInits(Exprs.PreInits);
1075   Dir->setHasCancel(HasCancel);
1076   return Dir;
1077 }
1078 
1079 OMPParallelMasterTaskLoopDirective *
1080 OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1081                                                 unsigned NumClauses,
1082                                                 unsigned CollapsedNum,
1083                                                 EmptyShell) {
1084   return createEmptyDirective<OMPParallelMasterTaskLoopDirective>(
1085       C, NumClauses, /*HasAssociatedStmt=*/true,
1086       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop),
1087       CollapsedNum);
1088 }
1089 
1090 OMPParallelMasterTaskLoopSimdDirective *
1091 OMPParallelMasterTaskLoopSimdDirective::Create(
1092     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1093     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1094     const HelperExprs &Exprs) {
1095   auto *Dir = createDirective<OMPParallelMasterTaskLoopSimdDirective>(
1096       C, Clauses, AssociatedStmt,
1097       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),
1098       StartLoc, EndLoc, CollapsedNum);
1099   Dir->setIterationVariable(Exprs.IterationVarRef);
1100   Dir->setLastIteration(Exprs.LastIteration);
1101   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1102   Dir->setPreCond(Exprs.PreCond);
1103   Dir->setCond(Exprs.Cond);
1104   Dir->setInit(Exprs.Init);
1105   Dir->setInc(Exprs.Inc);
1106   Dir->setIsLastIterVariable(Exprs.IL);
1107   Dir->setLowerBoundVariable(Exprs.LB);
1108   Dir->setUpperBoundVariable(Exprs.UB);
1109   Dir->setStrideVariable(Exprs.ST);
1110   Dir->setEnsureUpperBound(Exprs.EUB);
1111   Dir->setNextLowerBound(Exprs.NLB);
1112   Dir->setNextUpperBound(Exprs.NUB);
1113   Dir->setNumIterations(Exprs.NumIterations);
1114   Dir->setCounters(Exprs.Counters);
1115   Dir->setPrivateCounters(Exprs.PrivateCounters);
1116   Dir->setInits(Exprs.Inits);
1117   Dir->setUpdates(Exprs.Updates);
1118   Dir->setFinals(Exprs.Finals);
1119   Dir->setDependentCounters(Exprs.DependentCounters);
1120   Dir->setDependentInits(Exprs.DependentInits);
1121   Dir->setFinalsConditions(Exprs.FinalsConditions);
1122   Dir->setPreInits(Exprs.PreInits);
1123   return Dir;
1124 }
1125 
1126 OMPParallelMasterTaskLoopSimdDirective *
1127 OMPParallelMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1128                                                     unsigned NumClauses,
1129                                                     unsigned CollapsedNum,
1130                                                     EmptyShell) {
1131   return createEmptyDirective<OMPParallelMasterTaskLoopSimdDirective>(
1132       C, NumClauses, /*HasAssociatedStmt=*/true,
1133       numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop_simd),
1134       CollapsedNum);
1135 }
1136 
1137 OMPDistributeDirective *OMPDistributeDirective::Create(
1138     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1139     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1140     const HelperExprs &Exprs) {
1141   auto *Dir = createDirective<OMPDistributeDirective>(
1142       C, Clauses, AssociatedStmt,
1143       numLoopChildren(CollapsedNum, OMPD_distribute), StartLoc, EndLoc,
1144       CollapsedNum);
1145   Dir->setIterationVariable(Exprs.IterationVarRef);
1146   Dir->setLastIteration(Exprs.LastIteration);
1147   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1148   Dir->setPreCond(Exprs.PreCond);
1149   Dir->setCond(Exprs.Cond);
1150   Dir->setInit(Exprs.Init);
1151   Dir->setInc(Exprs.Inc);
1152   Dir->setIsLastIterVariable(Exprs.IL);
1153   Dir->setLowerBoundVariable(Exprs.LB);
1154   Dir->setUpperBoundVariable(Exprs.UB);
1155   Dir->setStrideVariable(Exprs.ST);
1156   Dir->setEnsureUpperBound(Exprs.EUB);
1157   Dir->setNextLowerBound(Exprs.NLB);
1158   Dir->setNextUpperBound(Exprs.NUB);
1159   Dir->setNumIterations(Exprs.NumIterations);
1160   Dir->setCounters(Exprs.Counters);
1161   Dir->setPrivateCounters(Exprs.PrivateCounters);
1162   Dir->setInits(Exprs.Inits);
1163   Dir->setUpdates(Exprs.Updates);
1164   Dir->setFinals(Exprs.Finals);
1165   Dir->setDependentCounters(Exprs.DependentCounters);
1166   Dir->setDependentInits(Exprs.DependentInits);
1167   Dir->setFinalsConditions(Exprs.FinalsConditions);
1168   Dir->setPreInits(Exprs.PreInits);
1169   return Dir;
1170 }
1171 
1172 OMPDistributeDirective *
1173 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1174                                     unsigned CollapsedNum, EmptyShell) {
1175   return createEmptyDirective<OMPDistributeDirective>(
1176       C, NumClauses, /*HasAssociatedStmt=*/true,
1177       numLoopChildren(CollapsedNum, OMPD_distribute), CollapsedNum);
1178 }
1179 
1180 OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1181     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1182     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1183   return createDirective<OMPTargetUpdateDirective>(C, Clauses, AssociatedStmt,
1184                                                    /*NumChildren=*/0, StartLoc,
1185                                                    EndLoc);
1186 }
1187 
1188 OMPTargetUpdateDirective *
1189 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1190                                       EmptyShell) {
1191   return createEmptyDirective<OMPTargetUpdateDirective>(
1192       C, NumClauses, /*HasAssociatedStmt=*/true);
1193 }
1194 
1195 OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1196     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1197     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1198     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1199   auto *Dir = createDirective<OMPDistributeParallelForDirective>(
1200       C, Clauses, AssociatedStmt,
1201       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1, StartLoc,
1202       EndLoc, CollapsedNum);
1203   Dir->setIterationVariable(Exprs.IterationVarRef);
1204   Dir->setLastIteration(Exprs.LastIteration);
1205   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1206   Dir->setPreCond(Exprs.PreCond);
1207   Dir->setCond(Exprs.Cond);
1208   Dir->setInit(Exprs.Init);
1209   Dir->setInc(Exprs.Inc);
1210   Dir->setIsLastIterVariable(Exprs.IL);
1211   Dir->setLowerBoundVariable(Exprs.LB);
1212   Dir->setUpperBoundVariable(Exprs.UB);
1213   Dir->setStrideVariable(Exprs.ST);
1214   Dir->setEnsureUpperBound(Exprs.EUB);
1215   Dir->setNextLowerBound(Exprs.NLB);
1216   Dir->setNextUpperBound(Exprs.NUB);
1217   Dir->setNumIterations(Exprs.NumIterations);
1218   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1219   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1220   Dir->setDistInc(Exprs.DistInc);
1221   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1222   Dir->setCounters(Exprs.Counters);
1223   Dir->setPrivateCounters(Exprs.PrivateCounters);
1224   Dir->setInits(Exprs.Inits);
1225   Dir->setUpdates(Exprs.Updates);
1226   Dir->setFinals(Exprs.Finals);
1227   Dir->setDependentCounters(Exprs.DependentCounters);
1228   Dir->setDependentInits(Exprs.DependentInits);
1229   Dir->setFinalsConditions(Exprs.FinalsConditions);
1230   Dir->setPreInits(Exprs.PreInits);
1231   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1232   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1233   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1234   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1235   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1236   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1237   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1238   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1239   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1240   Dir->setTaskReductionRefExpr(TaskRedRef);
1241   Dir->HasCancel = HasCancel;
1242   return Dir;
1243 }
1244 
1245 OMPDistributeParallelForDirective *
1246 OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1247                                                unsigned NumClauses,
1248                                                unsigned CollapsedNum,
1249                                                EmptyShell) {
1250   return createEmptyDirective<OMPDistributeParallelForDirective>(
1251       C, NumClauses, /*HasAssociatedStmt=*/true,
1252       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for) + 1,
1253       CollapsedNum);
1254 }
1255 
1256 OMPDistributeParallelForSimdDirective *
1257 OMPDistributeParallelForSimdDirective::Create(
1258     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1259     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1260     const HelperExprs &Exprs) {
1261   auto *Dir = createDirective<OMPDistributeParallelForSimdDirective>(
1262       C, Clauses, AssociatedStmt,
1263       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),
1264       StartLoc, EndLoc, CollapsedNum);
1265   Dir->setIterationVariable(Exprs.IterationVarRef);
1266   Dir->setLastIteration(Exprs.LastIteration);
1267   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1268   Dir->setPreCond(Exprs.PreCond);
1269   Dir->setCond(Exprs.Cond);
1270   Dir->setInit(Exprs.Init);
1271   Dir->setInc(Exprs.Inc);
1272   Dir->setIsLastIterVariable(Exprs.IL);
1273   Dir->setLowerBoundVariable(Exprs.LB);
1274   Dir->setUpperBoundVariable(Exprs.UB);
1275   Dir->setStrideVariable(Exprs.ST);
1276   Dir->setEnsureUpperBound(Exprs.EUB);
1277   Dir->setNextLowerBound(Exprs.NLB);
1278   Dir->setNextUpperBound(Exprs.NUB);
1279   Dir->setNumIterations(Exprs.NumIterations);
1280   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1281   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1282   Dir->setDistInc(Exprs.DistInc);
1283   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1284   Dir->setCounters(Exprs.Counters);
1285   Dir->setPrivateCounters(Exprs.PrivateCounters);
1286   Dir->setInits(Exprs.Inits);
1287   Dir->setUpdates(Exprs.Updates);
1288   Dir->setFinals(Exprs.Finals);
1289   Dir->setDependentCounters(Exprs.DependentCounters);
1290   Dir->setDependentInits(Exprs.DependentInits);
1291   Dir->setFinalsConditions(Exprs.FinalsConditions);
1292   Dir->setPreInits(Exprs.PreInits);
1293   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1294   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1295   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1296   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1297   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1298   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1299   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1300   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1301   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1302   return Dir;
1303 }
1304 
1305 OMPDistributeParallelForSimdDirective *
1306 OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1307                                                    unsigned NumClauses,
1308                                                    unsigned CollapsedNum,
1309                                                    EmptyShell) {
1310   return createEmptyDirective<OMPDistributeParallelForSimdDirective>(
1311       C, NumClauses, /*HasAssociatedStmt=*/true,
1312       numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd),
1313       CollapsedNum);
1314 }
1315 
1316 OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1317     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1318     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1319     const HelperExprs &Exprs) {
1320   auto *Dir = createDirective<OMPDistributeSimdDirective>(
1321       C, Clauses, AssociatedStmt,
1322       numLoopChildren(CollapsedNum, OMPD_distribute_simd), StartLoc, EndLoc,
1323       CollapsedNum);
1324   Dir->setIterationVariable(Exprs.IterationVarRef);
1325   Dir->setLastIteration(Exprs.LastIteration);
1326   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1327   Dir->setPreCond(Exprs.PreCond);
1328   Dir->setCond(Exprs.Cond);
1329   Dir->setInit(Exprs.Init);
1330   Dir->setInc(Exprs.Inc);
1331   Dir->setIsLastIterVariable(Exprs.IL);
1332   Dir->setLowerBoundVariable(Exprs.LB);
1333   Dir->setUpperBoundVariable(Exprs.UB);
1334   Dir->setStrideVariable(Exprs.ST);
1335   Dir->setEnsureUpperBound(Exprs.EUB);
1336   Dir->setNextLowerBound(Exprs.NLB);
1337   Dir->setNextUpperBound(Exprs.NUB);
1338   Dir->setNumIterations(Exprs.NumIterations);
1339   Dir->setCounters(Exprs.Counters);
1340   Dir->setPrivateCounters(Exprs.PrivateCounters);
1341   Dir->setInits(Exprs.Inits);
1342   Dir->setUpdates(Exprs.Updates);
1343   Dir->setFinals(Exprs.Finals);
1344   Dir->setDependentCounters(Exprs.DependentCounters);
1345   Dir->setDependentInits(Exprs.DependentInits);
1346   Dir->setFinalsConditions(Exprs.FinalsConditions);
1347   Dir->setPreInits(Exprs.PreInits);
1348   return Dir;
1349 }
1350 
1351 OMPDistributeSimdDirective *
1352 OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1353                                         unsigned NumClauses,
1354                                         unsigned CollapsedNum, EmptyShell) {
1355   return createEmptyDirective<OMPDistributeSimdDirective>(
1356       C, NumClauses, /*HasAssociatedStmt=*/true,
1357       numLoopChildren(CollapsedNum, OMPD_distribute_simd), CollapsedNum);
1358 }
1359 
1360 OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1361     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1362     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1363     const HelperExprs &Exprs) {
1364   auto *Dir = createDirective<OMPTargetParallelForSimdDirective>(
1365       C, Clauses, AssociatedStmt,
1366       numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd), StartLoc,
1367       EndLoc, CollapsedNum);
1368   Dir->setIterationVariable(Exprs.IterationVarRef);
1369   Dir->setLastIteration(Exprs.LastIteration);
1370   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1371   Dir->setPreCond(Exprs.PreCond);
1372   Dir->setCond(Exprs.Cond);
1373   Dir->setInit(Exprs.Init);
1374   Dir->setInc(Exprs.Inc);
1375   Dir->setIsLastIterVariable(Exprs.IL);
1376   Dir->setLowerBoundVariable(Exprs.LB);
1377   Dir->setUpperBoundVariable(Exprs.UB);
1378   Dir->setStrideVariable(Exprs.ST);
1379   Dir->setEnsureUpperBound(Exprs.EUB);
1380   Dir->setNextLowerBound(Exprs.NLB);
1381   Dir->setNextUpperBound(Exprs.NUB);
1382   Dir->setNumIterations(Exprs.NumIterations);
1383   Dir->setCounters(Exprs.Counters);
1384   Dir->setPrivateCounters(Exprs.PrivateCounters);
1385   Dir->setInits(Exprs.Inits);
1386   Dir->setUpdates(Exprs.Updates);
1387   Dir->setFinals(Exprs.Finals);
1388   Dir->setDependentCounters(Exprs.DependentCounters);
1389   Dir->setDependentInits(Exprs.DependentInits);
1390   Dir->setFinalsConditions(Exprs.FinalsConditions);
1391   Dir->setPreInits(Exprs.PreInits);
1392   return Dir;
1393 }
1394 
1395 OMPTargetParallelForSimdDirective *
1396 OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1397                                                unsigned NumClauses,
1398                                                unsigned CollapsedNum,
1399                                                EmptyShell) {
1400   return createEmptyDirective<OMPTargetParallelForSimdDirective>(
1401       C, NumClauses, /*HasAssociatedStmt=*/true,
1402       numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd),
1403       CollapsedNum);
1404 }
1405 
1406 OMPTargetSimdDirective *
1407 OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1408                                SourceLocation EndLoc, unsigned CollapsedNum,
1409                                ArrayRef<OMPClause *> Clauses,
1410                                Stmt *AssociatedStmt, const HelperExprs &Exprs) {
1411   auto *Dir = createDirective<OMPTargetSimdDirective>(
1412       C, Clauses, AssociatedStmt,
1413       numLoopChildren(CollapsedNum, OMPD_target_simd), StartLoc, EndLoc,
1414       CollapsedNum);
1415   Dir->setIterationVariable(Exprs.IterationVarRef);
1416   Dir->setLastIteration(Exprs.LastIteration);
1417   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1418   Dir->setPreCond(Exprs.PreCond);
1419   Dir->setCond(Exprs.Cond);
1420   Dir->setInit(Exprs.Init);
1421   Dir->setInc(Exprs.Inc);
1422   Dir->setCounters(Exprs.Counters);
1423   Dir->setPrivateCounters(Exprs.PrivateCounters);
1424   Dir->setInits(Exprs.Inits);
1425   Dir->setUpdates(Exprs.Updates);
1426   Dir->setFinals(Exprs.Finals);
1427   Dir->setDependentCounters(Exprs.DependentCounters);
1428   Dir->setDependentInits(Exprs.DependentInits);
1429   Dir->setFinalsConditions(Exprs.FinalsConditions);
1430   Dir->setPreInits(Exprs.PreInits);
1431   return Dir;
1432 }
1433 
1434 OMPTargetSimdDirective *
1435 OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1436                                     unsigned CollapsedNum, EmptyShell) {
1437   return createEmptyDirective<OMPTargetSimdDirective>(
1438       C, NumClauses, /*HasAssociatedStmt=*/true,
1439       numLoopChildren(CollapsedNum, OMPD_target_simd), CollapsedNum);
1440 }
1441 
1442 OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1443     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1444     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1445     const HelperExprs &Exprs) {
1446   auto *Dir = createDirective<OMPTeamsDistributeDirective>(
1447       C, Clauses, AssociatedStmt,
1448       numLoopChildren(CollapsedNum, OMPD_teams_distribute), StartLoc, EndLoc,
1449       CollapsedNum);
1450   Dir->setIterationVariable(Exprs.IterationVarRef);
1451   Dir->setLastIteration(Exprs.LastIteration);
1452   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1453   Dir->setPreCond(Exprs.PreCond);
1454   Dir->setCond(Exprs.Cond);
1455   Dir->setInit(Exprs.Init);
1456   Dir->setInc(Exprs.Inc);
1457   Dir->setIsLastIterVariable(Exprs.IL);
1458   Dir->setLowerBoundVariable(Exprs.LB);
1459   Dir->setUpperBoundVariable(Exprs.UB);
1460   Dir->setStrideVariable(Exprs.ST);
1461   Dir->setEnsureUpperBound(Exprs.EUB);
1462   Dir->setNextLowerBound(Exprs.NLB);
1463   Dir->setNextUpperBound(Exprs.NUB);
1464   Dir->setNumIterations(Exprs.NumIterations);
1465   Dir->setCounters(Exprs.Counters);
1466   Dir->setPrivateCounters(Exprs.PrivateCounters);
1467   Dir->setInits(Exprs.Inits);
1468   Dir->setUpdates(Exprs.Updates);
1469   Dir->setFinals(Exprs.Finals);
1470   Dir->setDependentCounters(Exprs.DependentCounters);
1471   Dir->setDependentInits(Exprs.DependentInits);
1472   Dir->setFinalsConditions(Exprs.FinalsConditions);
1473   Dir->setPreInits(Exprs.PreInits);
1474   return Dir;
1475 }
1476 
1477 OMPTeamsDistributeDirective *
1478 OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1479                                          unsigned NumClauses,
1480                                          unsigned CollapsedNum, EmptyShell) {
1481   return createEmptyDirective<OMPTeamsDistributeDirective>(
1482       C, NumClauses, /*HasAssociatedStmt=*/true,
1483       numLoopChildren(CollapsedNum, OMPD_teams_distribute), CollapsedNum);
1484 }
1485 
1486 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1487     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1488     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1489     const HelperExprs &Exprs) {
1490   auto *Dir = createDirective<OMPTeamsDistributeSimdDirective>(
1491       C, Clauses, AssociatedStmt,
1492       numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), StartLoc,
1493       EndLoc, CollapsedNum);
1494   Dir->setIterationVariable(Exprs.IterationVarRef);
1495   Dir->setLastIteration(Exprs.LastIteration);
1496   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1497   Dir->setPreCond(Exprs.PreCond);
1498   Dir->setCond(Exprs.Cond);
1499   Dir->setInit(Exprs.Init);
1500   Dir->setInc(Exprs.Inc);
1501   Dir->setIsLastIterVariable(Exprs.IL);
1502   Dir->setLowerBoundVariable(Exprs.LB);
1503   Dir->setUpperBoundVariable(Exprs.UB);
1504   Dir->setStrideVariable(Exprs.ST);
1505   Dir->setEnsureUpperBound(Exprs.EUB);
1506   Dir->setNextLowerBound(Exprs.NLB);
1507   Dir->setNextUpperBound(Exprs.NUB);
1508   Dir->setNumIterations(Exprs.NumIterations);
1509   Dir->setCounters(Exprs.Counters);
1510   Dir->setPrivateCounters(Exprs.PrivateCounters);
1511   Dir->setInits(Exprs.Inits);
1512   Dir->setUpdates(Exprs.Updates);
1513   Dir->setFinals(Exprs.Finals);
1514   Dir->setDependentCounters(Exprs.DependentCounters);
1515   Dir->setDependentInits(Exprs.DependentInits);
1516   Dir->setFinalsConditions(Exprs.FinalsConditions);
1517   Dir->setPreInits(Exprs.PreInits);
1518   return Dir;
1519 }
1520 
1521 OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1522     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1523     EmptyShell) {
1524   return createEmptyDirective<OMPTeamsDistributeSimdDirective>(
1525       C, NumClauses, /*HasAssociatedStmt=*/true,
1526       numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd), CollapsedNum);
1527 }
1528 
1529 OMPTeamsDistributeParallelForSimdDirective *
1530 OMPTeamsDistributeParallelForSimdDirective::Create(
1531     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1532     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1533     const HelperExprs &Exprs) {
1534   auto *Dir = createDirective<OMPTeamsDistributeParallelForSimdDirective>(
1535       C, Clauses, AssociatedStmt,
1536       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),
1537       StartLoc, EndLoc, CollapsedNum);
1538   Dir->setIterationVariable(Exprs.IterationVarRef);
1539   Dir->setLastIteration(Exprs.LastIteration);
1540   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1541   Dir->setPreCond(Exprs.PreCond);
1542   Dir->setCond(Exprs.Cond);
1543   Dir->setInit(Exprs.Init);
1544   Dir->setInc(Exprs.Inc);
1545   Dir->setIsLastIterVariable(Exprs.IL);
1546   Dir->setLowerBoundVariable(Exprs.LB);
1547   Dir->setUpperBoundVariable(Exprs.UB);
1548   Dir->setStrideVariable(Exprs.ST);
1549   Dir->setEnsureUpperBound(Exprs.EUB);
1550   Dir->setNextLowerBound(Exprs.NLB);
1551   Dir->setNextUpperBound(Exprs.NUB);
1552   Dir->setNumIterations(Exprs.NumIterations);
1553   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1554   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1555   Dir->setDistInc(Exprs.DistInc);
1556   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1557   Dir->setCounters(Exprs.Counters);
1558   Dir->setPrivateCounters(Exprs.PrivateCounters);
1559   Dir->setInits(Exprs.Inits);
1560   Dir->setUpdates(Exprs.Updates);
1561   Dir->setFinals(Exprs.Finals);
1562   Dir->setDependentCounters(Exprs.DependentCounters);
1563   Dir->setDependentInits(Exprs.DependentInits);
1564   Dir->setFinalsConditions(Exprs.FinalsConditions);
1565   Dir->setPreInits(Exprs.PreInits);
1566   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1567   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1568   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1569   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1570   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1571   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1572   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1573   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1574   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1575   return Dir;
1576 }
1577 
1578 OMPTeamsDistributeParallelForSimdDirective *
1579 OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1580                                                         unsigned NumClauses,
1581                                                         unsigned CollapsedNum,
1582                                                         EmptyShell) {
1583   return createEmptyDirective<OMPTeamsDistributeParallelForSimdDirective>(
1584       C, NumClauses, /*HasAssociatedStmt=*/true,
1585       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for_simd),
1586       CollapsedNum);
1587 }
1588 
1589 OMPTeamsDistributeParallelForDirective *
1590 OMPTeamsDistributeParallelForDirective::Create(
1591     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1592     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1593     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1594   auto *Dir = createDirective<OMPTeamsDistributeParallelForDirective>(
1595       C, Clauses, AssociatedStmt,
1596       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,
1597       StartLoc, EndLoc, CollapsedNum);
1598   Dir->setIterationVariable(Exprs.IterationVarRef);
1599   Dir->setLastIteration(Exprs.LastIteration);
1600   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1601   Dir->setPreCond(Exprs.PreCond);
1602   Dir->setCond(Exprs.Cond);
1603   Dir->setInit(Exprs.Init);
1604   Dir->setInc(Exprs.Inc);
1605   Dir->setIsLastIterVariable(Exprs.IL);
1606   Dir->setLowerBoundVariable(Exprs.LB);
1607   Dir->setUpperBoundVariable(Exprs.UB);
1608   Dir->setStrideVariable(Exprs.ST);
1609   Dir->setEnsureUpperBound(Exprs.EUB);
1610   Dir->setNextLowerBound(Exprs.NLB);
1611   Dir->setNextUpperBound(Exprs.NUB);
1612   Dir->setNumIterations(Exprs.NumIterations);
1613   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1614   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1615   Dir->setDistInc(Exprs.DistInc);
1616   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1617   Dir->setCounters(Exprs.Counters);
1618   Dir->setPrivateCounters(Exprs.PrivateCounters);
1619   Dir->setInits(Exprs.Inits);
1620   Dir->setUpdates(Exprs.Updates);
1621   Dir->setFinals(Exprs.Finals);
1622   Dir->setDependentCounters(Exprs.DependentCounters);
1623   Dir->setDependentInits(Exprs.DependentInits);
1624   Dir->setFinalsConditions(Exprs.FinalsConditions);
1625   Dir->setPreInits(Exprs.PreInits);
1626   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1627   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1628   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1629   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1630   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1631   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1632   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1633   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1634   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1635   Dir->setTaskReductionRefExpr(TaskRedRef);
1636   Dir->HasCancel = HasCancel;
1637   return Dir;
1638 }
1639 
1640 OMPTeamsDistributeParallelForDirective *
1641 OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1642                                                     unsigned NumClauses,
1643                                                     unsigned CollapsedNum,
1644                                                     EmptyShell) {
1645   return createEmptyDirective<OMPTeamsDistributeParallelForDirective>(
1646       C, NumClauses, /*HasAssociatedStmt=*/true,
1647       numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for) + 1,
1648       CollapsedNum);
1649 }
1650 
1651 OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
1652     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1653     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1654   return createDirective<OMPTargetTeamsDirective>(C, Clauses, AssociatedStmt,
1655                                                   /*NumChildren=*/0, StartLoc,
1656                                                   EndLoc);
1657 }
1658 
1659 OMPTargetTeamsDirective *
1660 OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1661                                      EmptyShell) {
1662   return createEmptyDirective<OMPTargetTeamsDirective>(
1663       C, NumClauses, /*HasAssociatedStmt=*/true);
1664 }
1665 
1666 OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
1667     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1668     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1669     const HelperExprs &Exprs) {
1670   auto *Dir = createDirective<OMPTargetTeamsDistributeDirective>(
1671       C, Clauses, AssociatedStmt,
1672       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute), StartLoc,
1673       EndLoc, CollapsedNum);
1674   Dir->setIterationVariable(Exprs.IterationVarRef);
1675   Dir->setLastIteration(Exprs.LastIteration);
1676   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1677   Dir->setPreCond(Exprs.PreCond);
1678   Dir->setCond(Exprs.Cond);
1679   Dir->setInit(Exprs.Init);
1680   Dir->setInc(Exprs.Inc);
1681   Dir->setIsLastIterVariable(Exprs.IL);
1682   Dir->setLowerBoundVariable(Exprs.LB);
1683   Dir->setUpperBoundVariable(Exprs.UB);
1684   Dir->setStrideVariable(Exprs.ST);
1685   Dir->setEnsureUpperBound(Exprs.EUB);
1686   Dir->setNextLowerBound(Exprs.NLB);
1687   Dir->setNextUpperBound(Exprs.NUB);
1688   Dir->setNumIterations(Exprs.NumIterations);
1689   Dir->setCounters(Exprs.Counters);
1690   Dir->setPrivateCounters(Exprs.PrivateCounters);
1691   Dir->setInits(Exprs.Inits);
1692   Dir->setUpdates(Exprs.Updates);
1693   Dir->setFinals(Exprs.Finals);
1694   Dir->setDependentCounters(Exprs.DependentCounters);
1695   Dir->setDependentInits(Exprs.DependentInits);
1696   Dir->setFinalsConditions(Exprs.FinalsConditions);
1697   Dir->setPreInits(Exprs.PreInits);
1698   return Dir;
1699 }
1700 
1701 OMPTargetTeamsDistributeDirective *
1702 OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1703                                                unsigned NumClauses,
1704                                                unsigned CollapsedNum,
1705                                                EmptyShell) {
1706   return createEmptyDirective<OMPTargetTeamsDistributeDirective>(
1707       C, NumClauses, /*HasAssociatedStmt=*/true,
1708       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute),
1709       CollapsedNum);
1710 }
1711 
1712 OMPTargetTeamsDistributeParallelForDirective *
1713 OMPTargetTeamsDistributeParallelForDirective::Create(
1714     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1715     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1716     const HelperExprs &Exprs, Expr *TaskRedRef, bool HasCancel) {
1717   auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForDirective>(
1718       C, Clauses, AssociatedStmt,
1719       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +
1720           1,
1721       StartLoc, EndLoc, CollapsedNum);
1722   Dir->setIterationVariable(Exprs.IterationVarRef);
1723   Dir->setLastIteration(Exprs.LastIteration);
1724   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1725   Dir->setPreCond(Exprs.PreCond);
1726   Dir->setCond(Exprs.Cond);
1727   Dir->setInit(Exprs.Init);
1728   Dir->setInc(Exprs.Inc);
1729   Dir->setIsLastIterVariable(Exprs.IL);
1730   Dir->setLowerBoundVariable(Exprs.LB);
1731   Dir->setUpperBoundVariable(Exprs.UB);
1732   Dir->setStrideVariable(Exprs.ST);
1733   Dir->setEnsureUpperBound(Exprs.EUB);
1734   Dir->setNextLowerBound(Exprs.NLB);
1735   Dir->setNextUpperBound(Exprs.NUB);
1736   Dir->setNumIterations(Exprs.NumIterations);
1737   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1738   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1739   Dir->setDistInc(Exprs.DistInc);
1740   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1741   Dir->setCounters(Exprs.Counters);
1742   Dir->setPrivateCounters(Exprs.PrivateCounters);
1743   Dir->setInits(Exprs.Inits);
1744   Dir->setUpdates(Exprs.Updates);
1745   Dir->setFinals(Exprs.Finals);
1746   Dir->setDependentCounters(Exprs.DependentCounters);
1747   Dir->setDependentInits(Exprs.DependentInits);
1748   Dir->setFinalsConditions(Exprs.FinalsConditions);
1749   Dir->setPreInits(Exprs.PreInits);
1750   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1751   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1752   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1753   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1754   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1755   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1756   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1757   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1758   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1759   Dir->setTaskReductionRefExpr(TaskRedRef);
1760   Dir->HasCancel = HasCancel;
1761   return Dir;
1762 }
1763 
1764 OMPTargetTeamsDistributeParallelForDirective *
1765 OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1766                                                           unsigned NumClauses,
1767                                                           unsigned CollapsedNum,
1768                                                           EmptyShell) {
1769   return createEmptyDirective<OMPTargetTeamsDistributeParallelForDirective>(
1770       C, NumClauses, /*HasAssociatedStmt=*/true,
1771       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_parallel_for) +
1772           1,
1773       CollapsedNum);
1774 }
1775 
1776 OMPTargetTeamsDistributeParallelForSimdDirective *
1777 OMPTargetTeamsDistributeParallelForSimdDirective::Create(
1778     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1779     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1780     const HelperExprs &Exprs) {
1781   auto *Dir = createDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
1782       C, Clauses, AssociatedStmt,
1783       numLoopChildren(CollapsedNum,
1784                       OMPD_target_teams_distribute_parallel_for_simd),
1785       StartLoc, EndLoc, CollapsedNum);
1786   Dir->setIterationVariable(Exprs.IterationVarRef);
1787   Dir->setLastIteration(Exprs.LastIteration);
1788   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1789   Dir->setPreCond(Exprs.PreCond);
1790   Dir->setCond(Exprs.Cond);
1791   Dir->setInit(Exprs.Init);
1792   Dir->setInc(Exprs.Inc);
1793   Dir->setIsLastIterVariable(Exprs.IL);
1794   Dir->setLowerBoundVariable(Exprs.LB);
1795   Dir->setUpperBoundVariable(Exprs.UB);
1796   Dir->setStrideVariable(Exprs.ST);
1797   Dir->setEnsureUpperBound(Exprs.EUB);
1798   Dir->setNextLowerBound(Exprs.NLB);
1799   Dir->setNextUpperBound(Exprs.NUB);
1800   Dir->setNumIterations(Exprs.NumIterations);
1801   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1802   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1803   Dir->setDistInc(Exprs.DistInc);
1804   Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
1805   Dir->setCounters(Exprs.Counters);
1806   Dir->setPrivateCounters(Exprs.PrivateCounters);
1807   Dir->setInits(Exprs.Inits);
1808   Dir->setUpdates(Exprs.Updates);
1809   Dir->setFinals(Exprs.Finals);
1810   Dir->setDependentCounters(Exprs.DependentCounters);
1811   Dir->setDependentInits(Exprs.DependentInits);
1812   Dir->setFinalsConditions(Exprs.FinalsConditions);
1813   Dir->setPreInits(Exprs.PreInits);
1814   Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1815   Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1816   Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1817   Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1818   Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1819   Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1820   Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
1821   Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1822   Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
1823   return Dir;
1824 }
1825 
1826 OMPTargetTeamsDistributeParallelForSimdDirective *
1827 OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
1828     const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1829     EmptyShell) {
1830   return createEmptyDirective<OMPTargetTeamsDistributeParallelForSimdDirective>(
1831       C, NumClauses, /*HasAssociatedStmt=*/true,
1832       numLoopChildren(CollapsedNum,
1833                       OMPD_target_teams_distribute_parallel_for_simd),
1834       CollapsedNum);
1835 }
1836 
1837 OMPTargetTeamsDistributeSimdDirective *
1838 OMPTargetTeamsDistributeSimdDirective::Create(
1839     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1840     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1841     const HelperExprs &Exprs) {
1842   auto *Dir = createDirective<OMPTargetTeamsDistributeSimdDirective>(
1843       C, Clauses, AssociatedStmt,
1844       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),
1845       StartLoc, EndLoc, CollapsedNum);
1846   Dir->setIterationVariable(Exprs.IterationVarRef);
1847   Dir->setLastIteration(Exprs.LastIteration);
1848   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1849   Dir->setPreCond(Exprs.PreCond);
1850   Dir->setCond(Exprs.Cond);
1851   Dir->setInit(Exprs.Init);
1852   Dir->setInc(Exprs.Inc);
1853   Dir->setIsLastIterVariable(Exprs.IL);
1854   Dir->setLowerBoundVariable(Exprs.LB);
1855   Dir->setUpperBoundVariable(Exprs.UB);
1856   Dir->setStrideVariable(Exprs.ST);
1857   Dir->setEnsureUpperBound(Exprs.EUB);
1858   Dir->setNextLowerBound(Exprs.NLB);
1859   Dir->setNextUpperBound(Exprs.NUB);
1860   Dir->setNumIterations(Exprs.NumIterations);
1861   Dir->setCounters(Exprs.Counters);
1862   Dir->setPrivateCounters(Exprs.PrivateCounters);
1863   Dir->setInits(Exprs.Inits);
1864   Dir->setUpdates(Exprs.Updates);
1865   Dir->setFinals(Exprs.Finals);
1866   Dir->setDependentCounters(Exprs.DependentCounters);
1867   Dir->setDependentInits(Exprs.DependentInits);
1868   Dir->setFinalsConditions(Exprs.FinalsConditions);
1869   Dir->setPreInits(Exprs.PreInits);
1870   return Dir;
1871 }
1872 
1873 OMPTargetTeamsDistributeSimdDirective *
1874 OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1875                                                    unsigned NumClauses,
1876                                                    unsigned CollapsedNum,
1877                                                    EmptyShell) {
1878   return createEmptyDirective<OMPTargetTeamsDistributeSimdDirective>(
1879       C, NumClauses, /*HasAssociatedStmt=*/true,
1880       numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd),
1881       CollapsedNum);
1882 }
1883