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