• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the subclesses of Stmt class declared in StmtOpenMP.h
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/StmtOpenMP.h"
15 
16 #include "clang/AST/ASTContext.h"
17 
18 using namespace clang;
19 
setClauses(ArrayRef<OMPClause * > Clauses)20 void 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 
setCounters(ArrayRef<Expr * > A)26 void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
27   assert(A.size() == getCollapsedNumber() &&
28          "Number of loop counters is not the same as the collapsed number");
29   std::copy(A.begin(), A.end(), getCounters().begin());
30 }
31 
setPrivateCounters(ArrayRef<Expr * > A)32 void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
33   assert(A.size() == getCollapsedNumber() && "Number of loop private counters "
34                                              "is not the same as the collapsed "
35                                              "number");
36   std::copy(A.begin(), A.end(), getPrivateCounters().begin());
37 }
38 
setInits(ArrayRef<Expr * > A)39 void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
40   assert(A.size() == getCollapsedNumber() &&
41          "Number of counter inits is not the same as the collapsed number");
42   std::copy(A.begin(), A.end(), getInits().begin());
43 }
44 
setUpdates(ArrayRef<Expr * > A)45 void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
46   assert(A.size() == getCollapsedNumber() &&
47          "Number of counter updates is not the same as the collapsed number");
48   std::copy(A.begin(), A.end(), getUpdates().begin());
49 }
50 
setFinals(ArrayRef<Expr * > A)51 void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
52   assert(A.size() == getCollapsedNumber() &&
53          "Number of counter finals is not the same as the collapsed number");
54   std::copy(A.begin(), A.end(), getFinals().begin());
55 }
56 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,bool HasCancel)57 OMPParallelDirective *OMPParallelDirective::Create(
58     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
59     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
60   unsigned Size =
61       llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>());
62   void *Mem =
63       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
64   OMPParallelDirective *Dir =
65       new (Mem) OMPParallelDirective(StartLoc, EndLoc, Clauses.size());
66   Dir->setClauses(Clauses);
67   Dir->setAssociatedStmt(AssociatedStmt);
68   Dir->setHasCancel(HasCancel);
69   return Dir;
70 }
71 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)72 OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
73                                                         unsigned NumClauses,
74                                                         EmptyShell) {
75   unsigned Size =
76       llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>());
77   void *Mem =
78       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
79   return new (Mem) OMPParallelDirective(NumClauses);
80 }
81 
82 OMPSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)83 OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
84                          SourceLocation EndLoc, unsigned CollapsedNum,
85                          ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
86                          const HelperExprs &Exprs) {
87   unsigned Size =
88       llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>());
89   void *Mem =
90       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
91                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
92   OMPSimdDirective *Dir = new (Mem)
93       OMPSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
94   Dir->setClauses(Clauses);
95   Dir->setAssociatedStmt(AssociatedStmt);
96   Dir->setIterationVariable(Exprs.IterationVarRef);
97   Dir->setLastIteration(Exprs.LastIteration);
98   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
99   Dir->setPreCond(Exprs.PreCond);
100   Dir->setCond(Exprs.Cond);
101   Dir->setInit(Exprs.Init);
102   Dir->setInc(Exprs.Inc);
103   Dir->setCounters(Exprs.Counters);
104   Dir->setPrivateCounters(Exprs.PrivateCounters);
105   Dir->setInits(Exprs.Inits);
106   Dir->setUpdates(Exprs.Updates);
107   Dir->setFinals(Exprs.Finals);
108   Dir->setPreInits(Exprs.PreInits);
109   return Dir;
110 }
111 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)112 OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
113                                                 unsigned NumClauses,
114                                                 unsigned CollapsedNum,
115                                                 EmptyShell) {
116   unsigned Size =
117       llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>());
118   void *Mem =
119       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
120                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
121   return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses);
122 }
123 
124 OMPForDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)125 OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc,
126                         SourceLocation EndLoc, unsigned CollapsedNum,
127                         ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
128                         const HelperExprs &Exprs, bool HasCancel) {
129   unsigned Size =
130       llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>());
131   void *Mem =
132       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
133                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
134   OMPForDirective *Dir =
135       new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
136   Dir->setClauses(Clauses);
137   Dir->setAssociatedStmt(AssociatedStmt);
138   Dir->setIterationVariable(Exprs.IterationVarRef);
139   Dir->setLastIteration(Exprs.LastIteration);
140   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
141   Dir->setPreCond(Exprs.PreCond);
142   Dir->setCond(Exprs.Cond);
143   Dir->setInit(Exprs.Init);
144   Dir->setInc(Exprs.Inc);
145   Dir->setIsLastIterVariable(Exprs.IL);
146   Dir->setLowerBoundVariable(Exprs.LB);
147   Dir->setUpperBoundVariable(Exprs.UB);
148   Dir->setStrideVariable(Exprs.ST);
149   Dir->setEnsureUpperBound(Exprs.EUB);
150   Dir->setNextLowerBound(Exprs.NLB);
151   Dir->setNextUpperBound(Exprs.NUB);
152   Dir->setNumIterations(Exprs.NumIterations);
153   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
154   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
155   Dir->setCounters(Exprs.Counters);
156   Dir->setPrivateCounters(Exprs.PrivateCounters);
157   Dir->setInits(Exprs.Inits);
158   Dir->setUpdates(Exprs.Updates);
159   Dir->setFinals(Exprs.Finals);
160   Dir->setPreInits(Exprs.PreInits);
161   Dir->setHasCancel(HasCancel);
162   return Dir;
163 }
164 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)165 OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
166                                               unsigned NumClauses,
167                                               unsigned CollapsedNum,
168                                               EmptyShell) {
169   unsigned Size =
170       llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>());
171   void *Mem =
172       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
173                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
174   return new (Mem) OMPForDirective(CollapsedNum, NumClauses);
175 }
176 
177 OMPForSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)178 OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
179                             SourceLocation EndLoc, unsigned CollapsedNum,
180                             ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
181                             const HelperExprs &Exprs) {
182   unsigned Size =
183       llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>());
184   void *Mem =
185       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
186                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
187   OMPForSimdDirective *Dir = new (Mem)
188       OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
189   Dir->setClauses(Clauses);
190   Dir->setAssociatedStmt(AssociatedStmt);
191   Dir->setIterationVariable(Exprs.IterationVarRef);
192   Dir->setLastIteration(Exprs.LastIteration);
193   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
194   Dir->setPreCond(Exprs.PreCond);
195   Dir->setCond(Exprs.Cond);
196   Dir->setInit(Exprs.Init);
197   Dir->setInc(Exprs.Inc);
198   Dir->setIsLastIterVariable(Exprs.IL);
199   Dir->setLowerBoundVariable(Exprs.LB);
200   Dir->setUpperBoundVariable(Exprs.UB);
201   Dir->setStrideVariable(Exprs.ST);
202   Dir->setEnsureUpperBound(Exprs.EUB);
203   Dir->setNextLowerBound(Exprs.NLB);
204   Dir->setNextUpperBound(Exprs.NUB);
205   Dir->setNumIterations(Exprs.NumIterations);
206   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
207   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
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->setPreInits(Exprs.PreInits);
214   return Dir;
215 }
216 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)217 OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
218                                                       unsigned NumClauses,
219                                                       unsigned CollapsedNum,
220                                                       EmptyShell) {
221   unsigned Size =
222       llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>());
223   void *Mem =
224       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
225                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
226   return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses);
227 }
228 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,bool HasCancel)229 OMPSectionsDirective *OMPSectionsDirective::Create(
230     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
231     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
232   unsigned Size =
233       llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>());
234   void *Mem =
235       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
236   OMPSectionsDirective *Dir =
237       new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size());
238   Dir->setClauses(Clauses);
239   Dir->setAssociatedStmt(AssociatedStmt);
240   Dir->setHasCancel(HasCancel);
241   return Dir;
242 }
243 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)244 OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
245                                                         unsigned NumClauses,
246                                                         EmptyShell) {
247   unsigned Size =
248       llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>());
249   void *Mem =
250       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
251   return new (Mem) OMPSectionsDirective(NumClauses);
252 }
253 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,Stmt * AssociatedStmt,bool HasCancel)254 OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
255                                                  SourceLocation StartLoc,
256                                                  SourceLocation EndLoc,
257                                                  Stmt *AssociatedStmt,
258                                                  bool HasCancel) {
259   unsigned Size =
260       llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>());
261   void *Mem = C.Allocate(Size + sizeof(Stmt *));
262   OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);
263   Dir->setAssociatedStmt(AssociatedStmt);
264   Dir->setHasCancel(HasCancel);
265   return Dir;
266 }
267 
CreateEmpty(const ASTContext & C,EmptyShell)268 OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
269                                                       EmptyShell) {
270   unsigned Size =
271       llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>());
272   void *Mem = C.Allocate(Size + sizeof(Stmt *));
273   return new (Mem) OMPSectionDirective();
274 }
275 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)276 OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
277                                                SourceLocation StartLoc,
278                                                SourceLocation EndLoc,
279                                                ArrayRef<OMPClause *> Clauses,
280                                                Stmt *AssociatedStmt) {
281   unsigned Size =
282       llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>());
283   void *Mem =
284       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
285   OMPSingleDirective *Dir =
286       new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
287   Dir->setClauses(Clauses);
288   Dir->setAssociatedStmt(AssociatedStmt);
289   return Dir;
290 }
291 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)292 OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
293                                                     unsigned NumClauses,
294                                                     EmptyShell) {
295   unsigned Size =
296       llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>());
297   void *Mem =
298       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
299   return new (Mem) OMPSingleDirective(NumClauses);
300 }
301 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,Stmt * AssociatedStmt)302 OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
303                                                SourceLocation StartLoc,
304                                                SourceLocation EndLoc,
305                                                Stmt *AssociatedStmt) {
306   unsigned Size =
307       llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>());
308   void *Mem = C.Allocate(Size + sizeof(Stmt *));
309   OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc);
310   Dir->setAssociatedStmt(AssociatedStmt);
311   return Dir;
312 }
313 
CreateEmpty(const ASTContext & C,EmptyShell)314 OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
315                                                     EmptyShell) {
316   unsigned Size =
317       llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>());
318   void *Mem = C.Allocate(Size + sizeof(Stmt *));
319   return new (Mem) OMPMasterDirective();
320 }
321 
Create(const ASTContext & C,const DeclarationNameInfo & Name,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)322 OMPCriticalDirective *OMPCriticalDirective::Create(
323     const ASTContext &C, const DeclarationNameInfo &Name,
324     SourceLocation StartLoc, SourceLocation EndLoc,
325     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
326   unsigned Size =
327       llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>());
328   void *Mem =
329       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
330   OMPCriticalDirective *Dir =
331       new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size());
332   Dir->setClauses(Clauses);
333   Dir->setAssociatedStmt(AssociatedStmt);
334   return Dir;
335 }
336 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)337 OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
338                                                         unsigned NumClauses,
339                                                         EmptyShell) {
340   unsigned Size =
341       llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>());
342   void *Mem =
343       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
344   return new (Mem) OMPCriticalDirective(NumClauses);
345 }
346 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)347 OMPParallelForDirective *OMPParallelForDirective::Create(
348     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
349     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
350     const HelperExprs &Exprs, bool HasCancel) {
351   unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective),
352                                 llvm::alignOf<OMPClause *>());
353   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
354                          sizeof(Stmt *) *
355                              numLoopChildren(CollapsedNum, OMPD_parallel_for));
356   OMPParallelForDirective *Dir = new (Mem)
357       OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
358   Dir->setClauses(Clauses);
359   Dir->setAssociatedStmt(AssociatedStmt);
360   Dir->setIterationVariable(Exprs.IterationVarRef);
361   Dir->setLastIteration(Exprs.LastIteration);
362   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
363   Dir->setPreCond(Exprs.PreCond);
364   Dir->setCond(Exprs.Cond);
365   Dir->setInit(Exprs.Init);
366   Dir->setInc(Exprs.Inc);
367   Dir->setIsLastIterVariable(Exprs.IL);
368   Dir->setLowerBoundVariable(Exprs.LB);
369   Dir->setUpperBoundVariable(Exprs.UB);
370   Dir->setStrideVariable(Exprs.ST);
371   Dir->setEnsureUpperBound(Exprs.EUB);
372   Dir->setNextLowerBound(Exprs.NLB);
373   Dir->setNextUpperBound(Exprs.NUB);
374   Dir->setNumIterations(Exprs.NumIterations);
375   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
376   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
377   Dir->setCounters(Exprs.Counters);
378   Dir->setPrivateCounters(Exprs.PrivateCounters);
379   Dir->setInits(Exprs.Inits);
380   Dir->setUpdates(Exprs.Updates);
381   Dir->setFinals(Exprs.Finals);
382   Dir->setPreInits(Exprs.PreInits);
383   Dir->setHasCancel(HasCancel);
384   return Dir;
385 }
386 
387 OMPParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)388 OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
389                                      unsigned CollapsedNum, EmptyShell) {
390   unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective),
391                                 llvm::alignOf<OMPClause *>());
392   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
393                          sizeof(Stmt *) *
394                              numLoopChildren(CollapsedNum, OMPD_parallel_for));
395   return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
396 }
397 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)398 OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
399     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
400     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
401     const HelperExprs &Exprs) {
402   unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective),
403                                 llvm::alignOf<OMPClause *>());
404   void *Mem = C.Allocate(
405       Size + sizeof(OMPClause *) * Clauses.size() +
406       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
407   OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective(
408       StartLoc, EndLoc, CollapsedNum, Clauses.size());
409   Dir->setClauses(Clauses);
410   Dir->setAssociatedStmt(AssociatedStmt);
411   Dir->setIterationVariable(Exprs.IterationVarRef);
412   Dir->setLastIteration(Exprs.LastIteration);
413   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
414   Dir->setPreCond(Exprs.PreCond);
415   Dir->setCond(Exprs.Cond);
416   Dir->setInit(Exprs.Init);
417   Dir->setInc(Exprs.Inc);
418   Dir->setIsLastIterVariable(Exprs.IL);
419   Dir->setLowerBoundVariable(Exprs.LB);
420   Dir->setUpperBoundVariable(Exprs.UB);
421   Dir->setStrideVariable(Exprs.ST);
422   Dir->setEnsureUpperBound(Exprs.EUB);
423   Dir->setNextLowerBound(Exprs.NLB);
424   Dir->setNextUpperBound(Exprs.NUB);
425   Dir->setNumIterations(Exprs.NumIterations);
426   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
427   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
428   Dir->setCounters(Exprs.Counters);
429   Dir->setPrivateCounters(Exprs.PrivateCounters);
430   Dir->setInits(Exprs.Inits);
431   Dir->setUpdates(Exprs.Updates);
432   Dir->setFinals(Exprs.Finals);
433   Dir->setPreInits(Exprs.PreInits);
434   return Dir;
435 }
436 
437 OMPParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)438 OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
439                                          unsigned NumClauses,
440                                          unsigned CollapsedNum, EmptyShell) {
441   unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective),
442                                 llvm::alignOf<OMPClause *>());
443   void *Mem = C.Allocate(
444       Size + sizeof(OMPClause *) * NumClauses +
445       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
446   return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses);
447 }
448 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,bool HasCancel)449 OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
450     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
451     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
452   unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective),
453                                 llvm::alignOf<OMPClause *>());
454   void *Mem =
455       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
456   OMPParallelSectionsDirective *Dir =
457       new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
458   Dir->setClauses(Clauses);
459   Dir->setAssociatedStmt(AssociatedStmt);
460   Dir->setHasCancel(HasCancel);
461   return Dir;
462 }
463 
464 OMPParallelSectionsDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)465 OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
466                                           unsigned NumClauses, EmptyShell) {
467   unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective),
468                                 llvm::alignOf<OMPClause *>());
469   void *Mem =
470       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
471   return new (Mem) OMPParallelSectionsDirective(NumClauses);
472 }
473 
474 OMPTaskDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,bool HasCancel)475 OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
476                          SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
477                          Stmt *AssociatedStmt, bool HasCancel) {
478   unsigned Size =
479       llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>());
480   void *Mem =
481       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
482   OMPTaskDirective *Dir =
483       new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size());
484   Dir->setClauses(Clauses);
485   Dir->setAssociatedStmt(AssociatedStmt);
486   Dir->setHasCancel(HasCancel);
487   return Dir;
488 }
489 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)490 OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
491                                                 unsigned NumClauses,
492                                                 EmptyShell) {
493   unsigned Size =
494       llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>());
495   void *Mem =
496       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
497   return new (Mem) OMPTaskDirective(NumClauses);
498 }
499 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc)500 OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
501                                                      SourceLocation StartLoc,
502                                                      SourceLocation EndLoc) {
503   void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
504   OMPTaskyieldDirective *Dir =
505       new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc);
506   return Dir;
507 }
508 
CreateEmpty(const ASTContext & C,EmptyShell)509 OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
510                                                           EmptyShell) {
511   void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
512   return new (Mem) OMPTaskyieldDirective();
513 }
514 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc)515 OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
516                                                  SourceLocation StartLoc,
517                                                  SourceLocation EndLoc) {
518   void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
519   OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
520   return Dir;
521 }
522 
CreateEmpty(const ASTContext & C,EmptyShell)523 OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
524                                                       EmptyShell) {
525   void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
526   return new (Mem) OMPBarrierDirective();
527 }
528 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc)529 OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C,
530                                                    SourceLocation StartLoc,
531                                                    SourceLocation EndLoc) {
532   void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
533   OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc);
534   return Dir;
535 }
536 
CreateEmpty(const ASTContext & C,EmptyShell)537 OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
538                                                         EmptyShell) {
539   void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
540   return new (Mem) OMPTaskwaitDirective();
541 }
542 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,Stmt * AssociatedStmt)543 OMPTaskgroupDirective *OMPTaskgroupDirective::Create(const ASTContext &C,
544                                                      SourceLocation StartLoc,
545                                                      SourceLocation EndLoc,
546                                                      Stmt *AssociatedStmt) {
547   unsigned Size =
548       llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>());
549   void *Mem = C.Allocate(Size + sizeof(Stmt *));
550   OMPTaskgroupDirective *Dir =
551       new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc);
552   Dir->setAssociatedStmt(AssociatedStmt);
553   return Dir;
554 }
555 
CreateEmpty(const ASTContext & C,EmptyShell)556 OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
557                                                           EmptyShell) {
558   unsigned Size =
559       llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>());
560   void *Mem = C.Allocate(Size + sizeof(Stmt *));
561   return new (Mem) OMPTaskgroupDirective();
562 }
563 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,OpenMPDirectiveKind CancelRegion)564 OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
565     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
566     OpenMPDirectiveKind CancelRegion) {
567   unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective),
568                                 llvm::alignOf<Stmt *>());
569   void *Mem = C.Allocate(Size);
570   OMPCancellationPointDirective *Dir =
571       new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc);
572   Dir->setCancelRegion(CancelRegion);
573   return Dir;
574 }
575 
576 OMPCancellationPointDirective *
CreateEmpty(const ASTContext & C,EmptyShell)577 OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
578   unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective),
579                                 llvm::alignOf<Stmt *>());
580   void *Mem = C.Allocate(Size);
581   return new (Mem) OMPCancellationPointDirective();
582 }
583 
584 OMPCancelDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,OpenMPDirectiveKind CancelRegion)585 OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
586                            SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
587                            OpenMPDirectiveKind CancelRegion) {
588   unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
589                                     sizeof(OMPClause *) * Clauses.size(),
590                                 llvm::alignOf<Stmt *>());
591   void *Mem = C.Allocate(Size);
592   OMPCancelDirective *Dir =
593       new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size());
594   Dir->setClauses(Clauses);
595   Dir->setCancelRegion(CancelRegion);
596   return Dir;
597 }
598 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)599 OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
600                                                     unsigned NumClauses,
601                                                     EmptyShell) {
602   unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
603                                     sizeof(OMPClause *) * NumClauses,
604                                 llvm::alignOf<Stmt *>());
605   void *Mem = C.Allocate(Size);
606   return new (Mem) OMPCancelDirective(NumClauses);
607 }
608 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)609 OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
610                                              SourceLocation StartLoc,
611                                              SourceLocation EndLoc,
612                                              ArrayRef<OMPClause *> Clauses) {
613   unsigned Size =
614       llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>());
615   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
616   OMPFlushDirective *Dir =
617       new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size());
618   Dir->setClauses(Clauses);
619   return Dir;
620 }
621 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)622 OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
623                                                   unsigned NumClauses,
624                                                   EmptyShell) {
625   unsigned Size =
626       llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>());
627   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
628   return new (Mem) OMPFlushDirective(NumClauses);
629 }
630 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)631 OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
632                                                  SourceLocation StartLoc,
633                                                  SourceLocation EndLoc,
634                                                  ArrayRef<OMPClause *> Clauses,
635                                                  Stmt *AssociatedStmt) {
636   unsigned Size =
637       llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>());
638   void *Mem =
639       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size());
640   OMPOrderedDirective *Dir =
641       new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size());
642   Dir->setClauses(Clauses);
643   Dir->setAssociatedStmt(AssociatedStmt);
644   return Dir;
645 }
646 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)647 OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
648                                                       unsigned NumClauses,
649                                                       EmptyShell) {
650   unsigned Size =
651       llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>());
652   void *Mem =
653       C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses);
654   return new (Mem) OMPOrderedDirective(NumClauses);
655 }
656 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,Expr * X,Expr * V,Expr * E,Expr * UE,bool IsXLHSInRHSPart,bool IsPostfixUpdate)657 OMPAtomicDirective *OMPAtomicDirective::Create(
658     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
659     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
660     Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
661   unsigned Size =
662       llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>());
663   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
664                          5 * sizeof(Stmt *));
665   OMPAtomicDirective *Dir =
666       new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
667   Dir->setClauses(Clauses);
668   Dir->setAssociatedStmt(AssociatedStmt);
669   Dir->setX(X);
670   Dir->setV(V);
671   Dir->setExpr(E);
672   Dir->setUpdateExpr(UE);
673   Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
674   Dir->IsPostfixUpdate = IsPostfixUpdate;
675   return Dir;
676 }
677 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)678 OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
679                                                     unsigned NumClauses,
680                                                     EmptyShell) {
681   unsigned Size =
682       llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>());
683   void *Mem =
684       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
685   return new (Mem) OMPAtomicDirective(NumClauses);
686 }
687 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)688 OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
689                                                SourceLocation StartLoc,
690                                                SourceLocation EndLoc,
691                                                ArrayRef<OMPClause *> Clauses,
692                                                Stmt *AssociatedStmt) {
693   unsigned Size =
694       llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>());
695   void *Mem =
696       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
697   OMPTargetDirective *Dir =
698       new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
699   Dir->setClauses(Clauses);
700   Dir->setAssociatedStmt(AssociatedStmt);
701   return Dir;
702 }
703 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)704 OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
705                                                     unsigned NumClauses,
706                                                     EmptyShell) {
707   unsigned Size =
708       llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>());
709   void *Mem =
710       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
711   return new (Mem) OMPTargetDirective(NumClauses);
712 }
713 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)714 OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
715     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
716     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
717   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective),
718                                 llvm::alignOf<OMPClause *>());
719   void *Mem =
720       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
721   OMPTargetParallelDirective *Dir =
722       new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size());
723   Dir->setClauses(Clauses);
724   Dir->setAssociatedStmt(AssociatedStmt);
725   return Dir;
726 }
727 
728 OMPTargetParallelDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)729 OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
730                                         unsigned NumClauses, EmptyShell) {
731   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective),
732                                 llvm::alignOf<OMPClause *>());
733   void *Mem =
734       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
735   return new (Mem) OMPTargetParallelDirective(NumClauses);
736 }
737 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs,bool HasCancel)738 OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
739     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
740     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
741     const HelperExprs &Exprs, bool HasCancel) {
742   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
743                                 llvm::alignOf<OMPClause *>());
744   void *Mem = C.Allocate(
745       Size + sizeof(OMPClause *) * Clauses.size() +
746       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
747   OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective(
748       StartLoc, EndLoc, CollapsedNum, Clauses.size());
749   Dir->setClauses(Clauses);
750   Dir->setAssociatedStmt(AssociatedStmt);
751   Dir->setIterationVariable(Exprs.IterationVarRef);
752   Dir->setLastIteration(Exprs.LastIteration);
753   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
754   Dir->setPreCond(Exprs.PreCond);
755   Dir->setCond(Exprs.Cond);
756   Dir->setInit(Exprs.Init);
757   Dir->setInc(Exprs.Inc);
758   Dir->setIsLastIterVariable(Exprs.IL);
759   Dir->setLowerBoundVariable(Exprs.LB);
760   Dir->setUpperBoundVariable(Exprs.UB);
761   Dir->setStrideVariable(Exprs.ST);
762   Dir->setEnsureUpperBound(Exprs.EUB);
763   Dir->setNextLowerBound(Exprs.NLB);
764   Dir->setNextUpperBound(Exprs.NUB);
765   Dir->setNumIterations(Exprs.NumIterations);
766   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
767   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
768   Dir->setCounters(Exprs.Counters);
769   Dir->setPrivateCounters(Exprs.PrivateCounters);
770   Dir->setInits(Exprs.Inits);
771   Dir->setUpdates(Exprs.Updates);
772   Dir->setFinals(Exprs.Finals);
773   Dir->setPreInits(Exprs.PreInits);
774   Dir->setHasCancel(HasCancel);
775   return Dir;
776 }
777 
778 OMPTargetParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)779 OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
780                                            unsigned NumClauses,
781                                            unsigned CollapsedNum, EmptyShell) {
782   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
783                                 llvm::alignOf<OMPClause *>());
784   void *Mem = C.Allocate(
785       Size + sizeof(OMPClause *) * NumClauses +
786       sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
787   return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses);
788 }
789 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)790 OMPTargetDataDirective *OMPTargetDataDirective::Create(
791     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
792     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
793   void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective),
794                                        llvm::alignOf<OMPClause *>()) +
795                          sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
796   OMPTargetDataDirective *Dir =
797       new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size());
798   Dir->setClauses(Clauses);
799   Dir->setAssociatedStmt(AssociatedStmt);
800   return Dir;
801 }
802 
CreateEmpty(const ASTContext & C,unsigned N,EmptyShell)803 OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
804                                                             unsigned N,
805                                                             EmptyShell) {
806   void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective),
807                                        llvm::alignOf<OMPClause *>()) +
808                          sizeof(OMPClause *) * N + sizeof(Stmt *));
809   return new (Mem) OMPTargetDataDirective(N);
810 }
811 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)812 OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
813     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
814     ArrayRef<OMPClause *> Clauses) {
815   void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective),
816                                        llvm::alignOf<OMPClause *>()) +
817                          sizeof(OMPClause *) * Clauses.size());
818   OMPTargetEnterDataDirective *Dir =
819       new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size());
820   Dir->setClauses(Clauses);
821   return Dir;
822 }
823 
824 OMPTargetEnterDataDirective *
CreateEmpty(const ASTContext & C,unsigned N,EmptyShell)825 OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
826                                          EmptyShell) {
827   void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective),
828                                        llvm::alignOf<OMPClause *>()) +
829                          sizeof(OMPClause *) * N);
830   return new (Mem) OMPTargetEnterDataDirective(N);
831 }
832 
833 OMPTargetExitDataDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)834 OMPTargetExitDataDirective::Create(const ASTContext &C, SourceLocation StartLoc,
835                                    SourceLocation EndLoc,
836                                    ArrayRef<OMPClause *> Clauses) {
837   void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective),
838                                        llvm::alignOf<OMPClause *>()) +
839                          sizeof(OMPClause *) * Clauses.size());
840   OMPTargetExitDataDirective *Dir =
841       new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size());
842   Dir->setClauses(Clauses);
843   return Dir;
844 }
845 
846 OMPTargetExitDataDirective *
CreateEmpty(const ASTContext & C,unsigned N,EmptyShell)847 OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
848                                         EmptyShell) {
849   void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective),
850                                        llvm::alignOf<OMPClause *>()) +
851                          sizeof(OMPClause *) * N);
852   return new (Mem) OMPTargetExitDataDirective(N);
853 }
854 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt)855 OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
856                                              SourceLocation StartLoc,
857                                              SourceLocation EndLoc,
858                                              ArrayRef<OMPClause *> Clauses,
859                                              Stmt *AssociatedStmt) {
860   unsigned Size =
861       llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>());
862   void *Mem =
863       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
864   OMPTeamsDirective *Dir =
865       new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
866   Dir->setClauses(Clauses);
867   Dir->setAssociatedStmt(AssociatedStmt);
868   return Dir;
869 }
870 
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)871 OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
872                                                   unsigned NumClauses,
873                                                   EmptyShell) {
874   unsigned Size =
875       llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>());
876   void *Mem =
877       C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
878   return new (Mem) OMPTeamsDirective(NumClauses);
879 }
880 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)881 OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
882     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
883     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
884     const HelperExprs &Exprs) {
885   unsigned Size =
886       llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>());
887   void *Mem =
888       C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
889                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
890   OMPTaskLoopDirective *Dir = new (Mem)
891       OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
892   Dir->setClauses(Clauses);
893   Dir->setAssociatedStmt(AssociatedStmt);
894   Dir->setIterationVariable(Exprs.IterationVarRef);
895   Dir->setLastIteration(Exprs.LastIteration);
896   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
897   Dir->setPreCond(Exprs.PreCond);
898   Dir->setCond(Exprs.Cond);
899   Dir->setInit(Exprs.Init);
900   Dir->setInc(Exprs.Inc);
901   Dir->setIsLastIterVariable(Exprs.IL);
902   Dir->setLowerBoundVariable(Exprs.LB);
903   Dir->setUpperBoundVariable(Exprs.UB);
904   Dir->setStrideVariable(Exprs.ST);
905   Dir->setEnsureUpperBound(Exprs.EUB);
906   Dir->setNextLowerBound(Exprs.NLB);
907   Dir->setNextUpperBound(Exprs.NUB);
908   Dir->setNumIterations(Exprs.NumIterations);
909   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
910   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
911   Dir->setCounters(Exprs.Counters);
912   Dir->setPrivateCounters(Exprs.PrivateCounters);
913   Dir->setInits(Exprs.Inits);
914   Dir->setUpdates(Exprs.Updates);
915   Dir->setFinals(Exprs.Finals);
916   Dir->setPreInits(Exprs.PreInits);
917   return Dir;
918 }
919 
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)920 OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
921                                                         unsigned NumClauses,
922                                                         unsigned CollapsedNum,
923                                                         EmptyShell) {
924   unsigned Size =
925       llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>());
926   void *Mem =
927       C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
928                  sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
929   return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses);
930 }
931 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)932 OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
933     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
934     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
935     const HelperExprs &Exprs) {
936   unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective),
937                                 llvm::alignOf<OMPClause *>());
938   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
939                          sizeof(Stmt *) *
940                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
941   OMPTaskLoopSimdDirective *Dir = new (Mem)
942       OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
943   Dir->setClauses(Clauses);
944   Dir->setAssociatedStmt(AssociatedStmt);
945   Dir->setIterationVariable(Exprs.IterationVarRef);
946   Dir->setLastIteration(Exprs.LastIteration);
947   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
948   Dir->setPreCond(Exprs.PreCond);
949   Dir->setCond(Exprs.Cond);
950   Dir->setInit(Exprs.Init);
951   Dir->setInc(Exprs.Inc);
952   Dir->setIsLastIterVariable(Exprs.IL);
953   Dir->setLowerBoundVariable(Exprs.LB);
954   Dir->setUpperBoundVariable(Exprs.UB);
955   Dir->setStrideVariable(Exprs.ST);
956   Dir->setEnsureUpperBound(Exprs.EUB);
957   Dir->setNextLowerBound(Exprs.NLB);
958   Dir->setNextUpperBound(Exprs.NUB);
959   Dir->setNumIterations(Exprs.NumIterations);
960   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
961   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
962   Dir->setCounters(Exprs.Counters);
963   Dir->setPrivateCounters(Exprs.PrivateCounters);
964   Dir->setInits(Exprs.Inits);
965   Dir->setUpdates(Exprs.Updates);
966   Dir->setFinals(Exprs.Finals);
967   Dir->setPreInits(Exprs.PreInits);
968   return Dir;
969 }
970 
971 OMPTaskLoopSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)972 OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
973                                       unsigned CollapsedNum, EmptyShell) {
974   unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective),
975                                 llvm::alignOf<OMPClause *>());
976   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
977                          sizeof(Stmt *) *
978                              numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
979   return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);
980 }
981 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)982 OMPDistributeDirective *OMPDistributeDirective::Create(
983     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
984     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
985     const HelperExprs &Exprs) {
986   unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective),
987                                 llvm::alignOf<OMPClause *>());
988   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
989                          sizeof(Stmt *) *
990                              numLoopChildren(CollapsedNum, OMPD_distribute));
991   OMPDistributeDirective *Dir = new (Mem)
992       OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
993   Dir->setClauses(Clauses);
994   Dir->setAssociatedStmt(AssociatedStmt);
995   Dir->setIterationVariable(Exprs.IterationVarRef);
996   Dir->setLastIteration(Exprs.LastIteration);
997   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
998   Dir->setPreCond(Exprs.PreCond);
999   Dir->setCond(Exprs.Cond);
1000   Dir->setInit(Exprs.Init);
1001   Dir->setInc(Exprs.Inc);
1002   Dir->setIsLastIterVariable(Exprs.IL);
1003   Dir->setLowerBoundVariable(Exprs.LB);
1004   Dir->setUpperBoundVariable(Exprs.UB);
1005   Dir->setStrideVariable(Exprs.ST);
1006   Dir->setEnsureUpperBound(Exprs.EUB);
1007   Dir->setNextLowerBound(Exprs.NLB);
1008   Dir->setNextUpperBound(Exprs.NUB);
1009   Dir->setNumIterations(Exprs.NumIterations);
1010   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1011   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1012   Dir->setCounters(Exprs.Counters);
1013   Dir->setPrivateCounters(Exprs.PrivateCounters);
1014   Dir->setInits(Exprs.Inits);
1015   Dir->setUpdates(Exprs.Updates);
1016   Dir->setFinals(Exprs.Finals);
1017   Dir->setPreInits(Exprs.PreInits);
1018   return Dir;
1019 }
1020 
1021 OMPDistributeDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1022 OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1023                                     unsigned CollapsedNum, EmptyShell) {
1024   unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective),
1025                                 llvm::alignOf<OMPClause *>());
1026   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1027                          sizeof(Stmt *) *
1028                              numLoopChildren(CollapsedNum, OMPD_distribute));
1029   return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1030 }
1031 
1032 OMPTargetUpdateDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,ArrayRef<OMPClause * > Clauses)1033 OMPTargetUpdateDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1034                                  SourceLocation EndLoc,
1035                                  ArrayRef<OMPClause *> Clauses) {
1036   unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective),
1037                                 llvm::alignOf<OMPClause *>());
1038   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
1039   OMPTargetUpdateDirective *Dir =
1040       new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1041   Dir->setClauses(Clauses);
1042   return Dir;
1043 }
1044 
1045 OMPTargetUpdateDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,EmptyShell)1046 OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1047                                       EmptyShell) {
1048   unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective),
1049                                 llvm::alignOf<OMPClause *>());
1050   void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
1051   return new (Mem) OMPTargetUpdateDirective(NumClauses);
1052 }
1053 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1054 OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1055     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1056     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1057     const HelperExprs &Exprs) {
1058   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1059                                 llvm::alignOf<OMPClause *>());
1060   void *Mem = C.Allocate(
1061       Size + sizeof(OMPClause *) * Clauses.size() +
1062       sizeof(Stmt *) *
1063           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1064   OMPDistributeParallelForDirective *Dir =
1065       new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
1066                                                   CollapsedNum, Clauses.size());
1067   Dir->setClauses(Clauses);
1068   Dir->setAssociatedStmt(AssociatedStmt);
1069   Dir->setIterationVariable(Exprs.IterationVarRef);
1070   Dir->setLastIteration(Exprs.LastIteration);
1071   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1072   Dir->setPreCond(Exprs.PreCond);
1073   Dir->setCond(Exprs.Cond);
1074   Dir->setInit(Exprs.Init);
1075   Dir->setInc(Exprs.Inc);
1076   Dir->setIsLastIterVariable(Exprs.IL);
1077   Dir->setLowerBoundVariable(Exprs.LB);
1078   Dir->setUpperBoundVariable(Exprs.UB);
1079   Dir->setStrideVariable(Exprs.ST);
1080   Dir->setEnsureUpperBound(Exprs.EUB);
1081   Dir->setNextLowerBound(Exprs.NLB);
1082   Dir->setNextUpperBound(Exprs.NUB);
1083   Dir->setNumIterations(Exprs.NumIterations);
1084   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1085   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1086   Dir->setCounters(Exprs.Counters);
1087   Dir->setPrivateCounters(Exprs.PrivateCounters);
1088   Dir->setInits(Exprs.Inits);
1089   Dir->setUpdates(Exprs.Updates);
1090   Dir->setFinals(Exprs.Finals);
1091   Dir->setPreInits(Exprs.PreInits);
1092   return Dir;
1093 }
1094 
1095 OMPDistributeParallelForDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1096 OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1097                                                unsigned NumClauses,
1098                                                unsigned CollapsedNum,
1099                                                EmptyShell) {
1100   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
1101                                 llvm::alignOf<OMPClause *>());
1102   void *Mem = C.Allocate(
1103       Size + sizeof(OMPClause *) * NumClauses +
1104       sizeof(Stmt *) *
1105           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1106   return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
1107 }
1108 
1109 OMPDistributeParallelForSimdDirective *
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1110 OMPDistributeParallelForSimdDirective::Create(
1111     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1112     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1113     const HelperExprs &Exprs) {
1114   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1115                                 llvm::alignOf<OMPClause *>());
1116   void *Mem = C.Allocate(
1117       Size + sizeof(OMPClause *) * Clauses.size() +
1118       sizeof(Stmt *) *
1119           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1120   OMPDistributeParallelForSimdDirective *Dir = new (Mem)
1121       OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1122                                             Clauses.size());
1123   Dir->setClauses(Clauses);
1124   Dir->setAssociatedStmt(AssociatedStmt);
1125   Dir->setIterationVariable(Exprs.IterationVarRef);
1126   Dir->setLastIteration(Exprs.LastIteration);
1127   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1128   Dir->setPreCond(Exprs.PreCond);
1129   Dir->setCond(Exprs.Cond);
1130   Dir->setInit(Exprs.Init);
1131   Dir->setInc(Exprs.Inc);
1132   Dir->setIsLastIterVariable(Exprs.IL);
1133   Dir->setLowerBoundVariable(Exprs.LB);
1134   Dir->setUpperBoundVariable(Exprs.UB);
1135   Dir->setStrideVariable(Exprs.ST);
1136   Dir->setEnsureUpperBound(Exprs.EUB);
1137   Dir->setNextLowerBound(Exprs.NLB);
1138   Dir->setNextUpperBound(Exprs.NUB);
1139   Dir->setNumIterations(Exprs.NumIterations);
1140   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1141   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1142   Dir->setCounters(Exprs.Counters);
1143   Dir->setPrivateCounters(Exprs.PrivateCounters);
1144   Dir->setInits(Exprs.Inits);
1145   Dir->setUpdates(Exprs.Updates);
1146   Dir->setFinals(Exprs.Finals);
1147   Dir->setPreInits(Exprs.PreInits);
1148   return Dir;
1149 }
1150 
1151 OMPDistributeParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1152 OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1153                                                    unsigned NumClauses,
1154                                                    unsigned CollapsedNum,
1155                                                    EmptyShell) {
1156   unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
1157                                 llvm::alignOf<OMPClause *>());
1158   void *Mem = C.Allocate(
1159       Size + sizeof(OMPClause *) * NumClauses +
1160       sizeof(Stmt *) *
1161           numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1162   return new (Mem)
1163       OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1164 }
1165 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1166 OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1167     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1168     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1169     const HelperExprs &Exprs) {
1170   unsigned Size = llvm::alignTo(sizeof(OMPDistributeSimdDirective),
1171                                 llvm::alignOf<OMPClause *>());
1172   void *Mem = C.Allocate(
1173       Size + sizeof(OMPClause *) * Clauses.size() +
1174       sizeof(Stmt *) *
1175           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1176   OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
1177       StartLoc, EndLoc, CollapsedNum, Clauses.size());
1178   Dir->setClauses(Clauses);
1179   Dir->setAssociatedStmt(AssociatedStmt);
1180   Dir->setIterationVariable(Exprs.IterationVarRef);
1181   Dir->setLastIteration(Exprs.LastIteration);
1182   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1183   Dir->setPreCond(Exprs.PreCond);
1184   Dir->setCond(Exprs.Cond);
1185   Dir->setInit(Exprs.Init);
1186   Dir->setInc(Exprs.Inc);
1187   Dir->setIsLastIterVariable(Exprs.IL);
1188   Dir->setLowerBoundVariable(Exprs.LB);
1189   Dir->setUpperBoundVariable(Exprs.UB);
1190   Dir->setStrideVariable(Exprs.ST);
1191   Dir->setEnsureUpperBound(Exprs.EUB);
1192   Dir->setNextLowerBound(Exprs.NLB);
1193   Dir->setNextUpperBound(Exprs.NUB);
1194   Dir->setNumIterations(Exprs.NumIterations);
1195   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1196   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1197   Dir->setCounters(Exprs.Counters);
1198   Dir->setPrivateCounters(Exprs.PrivateCounters);
1199   Dir->setInits(Exprs.Inits);
1200   Dir->setUpdates(Exprs.Updates);
1201   Dir->setFinals(Exprs.Finals);
1202   Dir->setPreInits(Exprs.PreInits);
1203   return Dir;
1204 }
1205 
1206 OMPDistributeSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1207 OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1208                                         unsigned NumClauses,
1209                                         unsigned CollapsedNum, EmptyShell) {
1210   unsigned Size = llvm::alignTo(sizeof(OMPDistributeSimdDirective),
1211                                 llvm::alignOf<OMPClause *>());
1212   void *Mem = C.Allocate(
1213       Size + sizeof(OMPClause *) * NumClauses +
1214       sizeof(Stmt *) *
1215           numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1216   return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
1217 }
1218 
Create(const ASTContext & C,SourceLocation StartLoc,SourceLocation EndLoc,unsigned CollapsedNum,ArrayRef<OMPClause * > Clauses,Stmt * AssociatedStmt,const HelperExprs & Exprs)1219 OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1220     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1221     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1222     const HelperExprs &Exprs) {
1223   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1224                                 llvm::alignOf<OMPClause *>());
1225   void *Mem = C.Allocate(
1226       Size + sizeof(OMPClause *) * Clauses.size() +
1227       sizeof(Stmt *) *
1228           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1229   OMPTargetParallelForSimdDirective *Dir =
1230       new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
1231                                                   CollapsedNum, Clauses.size());
1232   Dir->setClauses(Clauses);
1233   Dir->setAssociatedStmt(AssociatedStmt);
1234   Dir->setIterationVariable(Exprs.IterationVarRef);
1235   Dir->setLastIteration(Exprs.LastIteration);
1236   Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1237   Dir->setPreCond(Exprs.PreCond);
1238   Dir->setCond(Exprs.Cond);
1239   Dir->setInit(Exprs.Init);
1240   Dir->setInc(Exprs.Inc);
1241   Dir->setIsLastIterVariable(Exprs.IL);
1242   Dir->setLowerBoundVariable(Exprs.LB);
1243   Dir->setUpperBoundVariable(Exprs.UB);
1244   Dir->setStrideVariable(Exprs.ST);
1245   Dir->setEnsureUpperBound(Exprs.EUB);
1246   Dir->setNextLowerBound(Exprs.NLB);
1247   Dir->setNextUpperBound(Exprs.NUB);
1248   Dir->setNumIterations(Exprs.NumIterations);
1249   Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1250   Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
1251   Dir->setCounters(Exprs.Counters);
1252   Dir->setPrivateCounters(Exprs.PrivateCounters);
1253   Dir->setInits(Exprs.Inits);
1254   Dir->setUpdates(Exprs.Updates);
1255   Dir->setFinals(Exprs.Finals);
1256   Dir->setPreInits(Exprs.PreInits);
1257   return Dir;
1258 }
1259 
1260 OMPTargetParallelForSimdDirective *
CreateEmpty(const ASTContext & C,unsigned NumClauses,unsigned CollapsedNum,EmptyShell)1261 OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1262                                                unsigned NumClauses,
1263                                                unsigned CollapsedNum,
1264                                                EmptyShell) {
1265   unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
1266                                 llvm::alignOf<OMPClause *>());
1267   void *Mem = C.Allocate(
1268       Size + sizeof(OMPClause *) * NumClauses +
1269       sizeof(Stmt *) *
1270           numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1271   return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
1272 }
1273