blob: c850c099d64c4416ef276210c77fb35005f76c5a [file] [log] [blame]
James Y Knightb8bfd962015-10-02 13:41:04 +00001//===--- 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
18using namespace clang;
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
26void 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
32void 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
39void 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
45void 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
51void 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
57OMPParallelDirective *OMPParallelDirective::Create(
58 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
59 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +000060 unsigned Size =
61 llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +000062 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
72OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
73 unsigned NumClauses,
74 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +000075 unsigned Size =
76 llvm::alignTo(sizeof(OMPParallelDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +000077 void *Mem =
78 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
79 return new (Mem) OMPParallelDirective(NumClauses);
80}
81
82OMPSimdDirective *
83OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
84 SourceLocation EndLoc, unsigned CollapsedNum,
85 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
86 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +000087 unsigned Size =
88 llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +000089 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);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000108 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000109 return Dir;
110}
111
112OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
113 unsigned NumClauses,
114 unsigned CollapsedNum,
115 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000116 unsigned Size =
117 llvm::alignTo(sizeof(OMPSimdDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000118 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
124OMPForDirective *
125OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc,
126 SourceLocation EndLoc, unsigned CollapsedNum,
127 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
128 const HelperExprs &Exprs, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000129 unsigned Size =
130 llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000131 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);
Alexey Bataev8b427062016-05-25 12:36:08 +0000152 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000153 Dir->setCounters(Exprs.Counters);
154 Dir->setPrivateCounters(Exprs.PrivateCounters);
155 Dir->setInits(Exprs.Inits);
156 Dir->setUpdates(Exprs.Updates);
157 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000158 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000159 Dir->setHasCancel(HasCancel);
160 return Dir;
161}
162
163OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
164 unsigned NumClauses,
165 unsigned CollapsedNum,
166 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000167 unsigned Size =
168 llvm::alignTo(sizeof(OMPForDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000169 void *Mem =
170 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
171 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
172 return new (Mem) OMPForDirective(CollapsedNum, NumClauses);
173}
174
175OMPForSimdDirective *
176OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
177 SourceLocation EndLoc, unsigned CollapsedNum,
178 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
179 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000180 unsigned Size =
181 llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000182 void *Mem =
183 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
184 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
185 OMPForSimdDirective *Dir = new (Mem)
186 OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
187 Dir->setClauses(Clauses);
188 Dir->setAssociatedStmt(AssociatedStmt);
189 Dir->setIterationVariable(Exprs.IterationVarRef);
190 Dir->setLastIteration(Exprs.LastIteration);
191 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
192 Dir->setPreCond(Exprs.PreCond);
193 Dir->setCond(Exprs.Cond);
194 Dir->setInit(Exprs.Init);
195 Dir->setInc(Exprs.Inc);
196 Dir->setIsLastIterVariable(Exprs.IL);
197 Dir->setLowerBoundVariable(Exprs.LB);
198 Dir->setUpperBoundVariable(Exprs.UB);
199 Dir->setStrideVariable(Exprs.ST);
200 Dir->setEnsureUpperBound(Exprs.EUB);
201 Dir->setNextLowerBound(Exprs.NLB);
202 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000203 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000204 Dir->setCounters(Exprs.Counters);
205 Dir->setPrivateCounters(Exprs.PrivateCounters);
206 Dir->setInits(Exprs.Inits);
207 Dir->setUpdates(Exprs.Updates);
208 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000209 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000210 return Dir;
211}
212
213OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
214 unsigned NumClauses,
215 unsigned CollapsedNum,
216 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000217 unsigned Size =
218 llvm::alignTo(sizeof(OMPForSimdDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000219 void *Mem =
220 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
221 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
222 return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses);
223}
224
225OMPSectionsDirective *OMPSectionsDirective::Create(
226 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
227 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000228 unsigned Size =
229 llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000230 void *Mem =
231 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
232 OMPSectionsDirective *Dir =
233 new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size());
234 Dir->setClauses(Clauses);
235 Dir->setAssociatedStmt(AssociatedStmt);
236 Dir->setHasCancel(HasCancel);
237 return Dir;
238}
239
240OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
241 unsigned NumClauses,
242 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000243 unsigned Size =
244 llvm::alignTo(sizeof(OMPSectionsDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000245 void *Mem =
246 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
247 return new (Mem) OMPSectionsDirective(NumClauses);
248}
249
250OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
251 SourceLocation StartLoc,
252 SourceLocation EndLoc,
253 Stmt *AssociatedStmt,
254 bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000255 unsigned Size =
256 llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000257 void *Mem = C.Allocate(Size + sizeof(Stmt *));
258 OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);
259 Dir->setAssociatedStmt(AssociatedStmt);
260 Dir->setHasCancel(HasCancel);
261 return Dir;
262}
263
264OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
265 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000266 unsigned Size =
267 llvm::alignTo(sizeof(OMPSectionDirective), llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000268 void *Mem = C.Allocate(Size + sizeof(Stmt *));
269 return new (Mem) OMPSectionDirective();
270}
271
272OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
273 SourceLocation StartLoc,
274 SourceLocation EndLoc,
275 ArrayRef<OMPClause *> Clauses,
276 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000277 unsigned Size =
278 llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000279 void *Mem =
280 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
281 OMPSingleDirective *Dir =
282 new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
283 Dir->setClauses(Clauses);
284 Dir->setAssociatedStmt(AssociatedStmt);
285 return Dir;
286}
287
288OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
289 unsigned NumClauses,
290 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000291 unsigned Size =
292 llvm::alignTo(sizeof(OMPSingleDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000293 void *Mem =
294 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
295 return new (Mem) OMPSingleDirective(NumClauses);
296}
297
298OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
299 SourceLocation StartLoc,
300 SourceLocation EndLoc,
301 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000302 unsigned Size =
303 llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000304 void *Mem = C.Allocate(Size + sizeof(Stmt *));
305 OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc);
306 Dir->setAssociatedStmt(AssociatedStmt);
307 return Dir;
308}
309
310OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
311 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000312 unsigned Size =
313 llvm::alignTo(sizeof(OMPMasterDirective), llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000314 void *Mem = C.Allocate(Size + sizeof(Stmt *));
315 return new (Mem) OMPMasterDirective();
316}
317
318OMPCriticalDirective *OMPCriticalDirective::Create(
319 const ASTContext &C, const DeclarationNameInfo &Name,
Alexey Bataev28c75412015-12-15 08:19:24 +0000320 SourceLocation StartLoc, SourceLocation EndLoc,
321 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000322 unsigned Size =
323 llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>());
Alexey Bataev28c75412015-12-15 08:19:24 +0000324 void *Mem =
325 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000326 OMPCriticalDirective *Dir =
Alexey Bataev28c75412015-12-15 08:19:24 +0000327 new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size());
328 Dir->setClauses(Clauses);
James Y Knightb8bfd962015-10-02 13:41:04 +0000329 Dir->setAssociatedStmt(AssociatedStmt);
330 return Dir;
331}
332
333OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
Alexey Bataev28c75412015-12-15 08:19:24 +0000334 unsigned NumClauses,
James Y Knightb8bfd962015-10-02 13:41:04 +0000335 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000336 unsigned Size =
337 llvm::alignTo(sizeof(OMPCriticalDirective), llvm::alignOf<OMPClause *>());
Alexey Bataev28c75412015-12-15 08:19:24 +0000338 void *Mem =
339 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
340 return new (Mem) OMPCriticalDirective(NumClauses);
James Y Knightb8bfd962015-10-02 13:41:04 +0000341}
342
343OMPParallelForDirective *OMPParallelForDirective::Create(
344 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
345 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
346 const HelperExprs &Exprs, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000347 unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective),
348 llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000349 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
350 sizeof(Stmt *) *
351 numLoopChildren(CollapsedNum, OMPD_parallel_for));
352 OMPParallelForDirective *Dir = new (Mem)
353 OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
354 Dir->setClauses(Clauses);
355 Dir->setAssociatedStmt(AssociatedStmt);
356 Dir->setIterationVariable(Exprs.IterationVarRef);
357 Dir->setLastIteration(Exprs.LastIteration);
358 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
359 Dir->setPreCond(Exprs.PreCond);
360 Dir->setCond(Exprs.Cond);
361 Dir->setInit(Exprs.Init);
362 Dir->setInc(Exprs.Inc);
363 Dir->setIsLastIterVariable(Exprs.IL);
364 Dir->setLowerBoundVariable(Exprs.LB);
365 Dir->setUpperBoundVariable(Exprs.UB);
366 Dir->setStrideVariable(Exprs.ST);
367 Dir->setEnsureUpperBound(Exprs.EUB);
368 Dir->setNextLowerBound(Exprs.NLB);
369 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000370 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000371 Dir->setCounters(Exprs.Counters);
372 Dir->setPrivateCounters(Exprs.PrivateCounters);
373 Dir->setInits(Exprs.Inits);
374 Dir->setUpdates(Exprs.Updates);
375 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000376 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000377 Dir->setHasCancel(HasCancel);
378 return Dir;
379}
380
381OMPParallelForDirective *
382OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
383 unsigned CollapsedNum, EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000384 unsigned Size = llvm::alignTo(sizeof(OMPParallelForDirective),
385 llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000386 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
387 sizeof(Stmt *) *
388 numLoopChildren(CollapsedNum, OMPD_parallel_for));
389 return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
390}
391
392OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
393 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
394 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
395 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000396 unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective),
397 llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000398 void *Mem = C.Allocate(
399 Size + sizeof(OMPClause *) * Clauses.size() +
400 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
401 OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective(
402 StartLoc, EndLoc, CollapsedNum, Clauses.size());
403 Dir->setClauses(Clauses);
404 Dir->setAssociatedStmt(AssociatedStmt);
405 Dir->setIterationVariable(Exprs.IterationVarRef);
406 Dir->setLastIteration(Exprs.LastIteration);
407 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
408 Dir->setPreCond(Exprs.PreCond);
409 Dir->setCond(Exprs.Cond);
410 Dir->setInit(Exprs.Init);
411 Dir->setInc(Exprs.Inc);
412 Dir->setIsLastIterVariable(Exprs.IL);
413 Dir->setLowerBoundVariable(Exprs.LB);
414 Dir->setUpperBoundVariable(Exprs.UB);
415 Dir->setStrideVariable(Exprs.ST);
416 Dir->setEnsureUpperBound(Exprs.EUB);
417 Dir->setNextLowerBound(Exprs.NLB);
418 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000419 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000420 Dir->setCounters(Exprs.Counters);
421 Dir->setPrivateCounters(Exprs.PrivateCounters);
422 Dir->setInits(Exprs.Inits);
423 Dir->setUpdates(Exprs.Updates);
424 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000425 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000426 return Dir;
427}
428
429OMPParallelForSimdDirective *
430OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
431 unsigned NumClauses,
432 unsigned CollapsedNum, EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000433 unsigned Size = llvm::alignTo(sizeof(OMPParallelForSimdDirective),
434 llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000435 void *Mem = C.Allocate(
436 Size + sizeof(OMPClause *) * NumClauses +
437 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
438 return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses);
439}
440
441OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
442 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
443 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000444 unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective),
445 llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000446 void *Mem =
447 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
448 OMPParallelSectionsDirective *Dir =
449 new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
450 Dir->setClauses(Clauses);
451 Dir->setAssociatedStmt(AssociatedStmt);
452 Dir->setHasCancel(HasCancel);
453 return Dir;
454}
455
456OMPParallelSectionsDirective *
457OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
458 unsigned NumClauses, EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000459 unsigned Size = llvm::alignTo(sizeof(OMPParallelSectionsDirective),
460 llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000461 void *Mem =
462 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
463 return new (Mem) OMPParallelSectionsDirective(NumClauses);
464}
465
466OMPTaskDirective *
467OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
468 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
469 Stmt *AssociatedStmt, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000470 unsigned Size =
471 llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000472 void *Mem =
473 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
474 OMPTaskDirective *Dir =
475 new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size());
476 Dir->setClauses(Clauses);
477 Dir->setAssociatedStmt(AssociatedStmt);
478 Dir->setHasCancel(HasCancel);
479 return Dir;
480}
481
482OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
483 unsigned NumClauses,
484 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000485 unsigned Size =
486 llvm::alignTo(sizeof(OMPTaskDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000487 void *Mem =
488 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
489 return new (Mem) OMPTaskDirective(NumClauses);
490}
491
492OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
493 SourceLocation StartLoc,
494 SourceLocation EndLoc) {
495 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
496 OMPTaskyieldDirective *Dir =
497 new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc);
498 return Dir;
499}
500
501OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
502 EmptyShell) {
503 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
504 return new (Mem) OMPTaskyieldDirective();
505}
506
507OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
508 SourceLocation StartLoc,
509 SourceLocation EndLoc) {
510 void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
511 OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
512 return Dir;
513}
514
515OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
516 EmptyShell) {
517 void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
518 return new (Mem) OMPBarrierDirective();
519}
520
521OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C,
522 SourceLocation StartLoc,
523 SourceLocation EndLoc) {
524 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
525 OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc);
526 return Dir;
527}
528
529OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
530 EmptyShell) {
531 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
532 return new (Mem) OMPTaskwaitDirective();
533}
534
535OMPTaskgroupDirective *OMPTaskgroupDirective::Create(const ASTContext &C,
536 SourceLocation StartLoc,
537 SourceLocation EndLoc,
538 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000539 unsigned Size =
540 llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000541 void *Mem = C.Allocate(Size + sizeof(Stmt *));
542 OMPTaskgroupDirective *Dir =
543 new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc);
544 Dir->setAssociatedStmt(AssociatedStmt);
545 return Dir;
546}
547
548OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
549 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000550 unsigned Size =
551 llvm::alignTo(sizeof(OMPTaskgroupDirective), llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000552 void *Mem = C.Allocate(Size + sizeof(Stmt *));
553 return new (Mem) OMPTaskgroupDirective();
554}
555
556OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
557 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
558 OpenMPDirectiveKind CancelRegion) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000559 unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective),
560 llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000561 void *Mem = C.Allocate(Size);
562 OMPCancellationPointDirective *Dir =
563 new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc);
564 Dir->setCancelRegion(CancelRegion);
565 return Dir;
566}
567
568OMPCancellationPointDirective *
569OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000570 unsigned Size = llvm::alignTo(sizeof(OMPCancellationPointDirective),
571 llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000572 void *Mem = C.Allocate(Size);
573 return new (Mem) OMPCancellationPointDirective();
574}
575
576OMPCancelDirective *
577OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
578 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
579 OpenMPDirectiveKind CancelRegion) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000580 unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
581 sizeof(OMPClause *) * Clauses.size(),
582 llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000583 void *Mem = C.Allocate(Size);
584 OMPCancelDirective *Dir =
585 new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size());
586 Dir->setClauses(Clauses);
587 Dir->setCancelRegion(CancelRegion);
588 return Dir;
589}
590
591OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
592 unsigned NumClauses,
593 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000594 unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
595 sizeof(OMPClause *) * NumClauses,
596 llvm::alignOf<Stmt *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000597 void *Mem = C.Allocate(Size);
598 return new (Mem) OMPCancelDirective(NumClauses);
599}
600
601OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
602 SourceLocation StartLoc,
603 SourceLocation EndLoc,
604 ArrayRef<OMPClause *> Clauses) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000605 unsigned Size =
606 llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000607 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
608 OMPFlushDirective *Dir =
609 new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size());
610 Dir->setClauses(Clauses);
611 return Dir;
612}
613
614OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
615 unsigned NumClauses,
616 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000617 unsigned Size =
618 llvm::alignTo(sizeof(OMPFlushDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000619 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
620 return new (Mem) OMPFlushDirective(NumClauses);
621}
622
623OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
624 SourceLocation StartLoc,
625 SourceLocation EndLoc,
626 ArrayRef<OMPClause *> Clauses,
627 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000628 unsigned Size =
629 llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000630 void *Mem =
631 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size());
632 OMPOrderedDirective *Dir =
633 new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size());
634 Dir->setClauses(Clauses);
635 Dir->setAssociatedStmt(AssociatedStmt);
636 return Dir;
637}
638
639OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
640 unsigned NumClauses,
641 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000642 unsigned Size =
643 llvm::alignTo(sizeof(OMPOrderedDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000644 void *Mem =
645 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses);
646 return new (Mem) OMPOrderedDirective(NumClauses);
647}
648
649OMPAtomicDirective *OMPAtomicDirective::Create(
650 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
651 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
652 Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000653 unsigned Size =
654 llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000655 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
656 5 * sizeof(Stmt *));
657 OMPAtomicDirective *Dir =
658 new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
659 Dir->setClauses(Clauses);
660 Dir->setAssociatedStmt(AssociatedStmt);
661 Dir->setX(X);
662 Dir->setV(V);
663 Dir->setExpr(E);
664 Dir->setUpdateExpr(UE);
665 Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
666 Dir->IsPostfixUpdate = IsPostfixUpdate;
667 return Dir;
668}
669
670OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
671 unsigned NumClauses,
672 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000673 unsigned Size =
674 llvm::alignTo(sizeof(OMPAtomicDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000675 void *Mem =
676 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
677 return new (Mem) OMPAtomicDirective(NumClauses);
678}
679
680OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
681 SourceLocation StartLoc,
682 SourceLocation EndLoc,
683 ArrayRef<OMPClause *> Clauses,
684 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000685 unsigned Size =
686 llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000687 void *Mem =
688 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
689 OMPTargetDirective *Dir =
690 new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
691 Dir->setClauses(Clauses);
692 Dir->setAssociatedStmt(AssociatedStmt);
693 return Dir;
694}
695
696OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
697 unsigned NumClauses,
698 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000699 unsigned Size =
700 llvm::alignTo(sizeof(OMPTargetDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000701 void *Mem =
702 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
703 return new (Mem) OMPTargetDirective(NumClauses);
704}
705
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000706OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
707 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
708 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
709 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective),
710 llvm::alignOf<OMPClause *>());
711 void *Mem =
712 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
713 OMPTargetParallelDirective *Dir =
714 new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size());
715 Dir->setClauses(Clauses);
716 Dir->setAssociatedStmt(AssociatedStmt);
717 return Dir;
718}
719
720OMPTargetParallelDirective *
721OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
722 unsigned NumClauses, EmptyShell) {
723 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelDirective),
724 llvm::alignOf<OMPClause *>());
725 void *Mem =
726 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
727 return new (Mem) OMPTargetParallelDirective(NumClauses);
728}
729
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000730OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
731 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
732 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
733 const HelperExprs &Exprs, bool HasCancel) {
734 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
735 llvm::alignOf<OMPClause *>());
736 void *Mem = C.Allocate(
737 Size + sizeof(OMPClause *) * Clauses.size() +
738 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
739 OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective(
740 StartLoc, EndLoc, CollapsedNum, Clauses.size());
741 Dir->setClauses(Clauses);
742 Dir->setAssociatedStmt(AssociatedStmt);
743 Dir->setIterationVariable(Exprs.IterationVarRef);
744 Dir->setLastIteration(Exprs.LastIteration);
745 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
746 Dir->setPreCond(Exprs.PreCond);
747 Dir->setCond(Exprs.Cond);
748 Dir->setInit(Exprs.Init);
749 Dir->setInc(Exprs.Inc);
750 Dir->setIsLastIterVariable(Exprs.IL);
751 Dir->setLowerBoundVariable(Exprs.LB);
752 Dir->setUpperBoundVariable(Exprs.UB);
753 Dir->setStrideVariable(Exprs.ST);
754 Dir->setEnsureUpperBound(Exprs.EUB);
755 Dir->setNextLowerBound(Exprs.NLB);
756 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000757 Dir->setNumIterations(Exprs.NumIterations);
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000758 Dir->setCounters(Exprs.Counters);
759 Dir->setPrivateCounters(Exprs.PrivateCounters);
760 Dir->setInits(Exprs.Inits);
761 Dir->setUpdates(Exprs.Updates);
762 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000763 Dir->setPreInits(Exprs.PreInits);
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000764 Dir->setHasCancel(HasCancel);
765 return Dir;
766}
767
768OMPTargetParallelForDirective *
769OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
770 unsigned NumClauses,
771 unsigned CollapsedNum, EmptyShell) {
772 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
773 llvm::alignOf<OMPClause *>());
774 void *Mem = C.Allocate(
775 Size + sizeof(OMPClause *) * NumClauses +
776 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
777 return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses);
778}
779
James Y Knightb8bfd962015-10-02 13:41:04 +0000780OMPTargetDataDirective *OMPTargetDataDirective::Create(
781 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
782 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000783 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective),
784 llvm::alignOf<OMPClause *>()) +
785 sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000786 OMPTargetDataDirective *Dir =
787 new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size());
788 Dir->setClauses(Clauses);
789 Dir->setAssociatedStmt(AssociatedStmt);
790 return Dir;
791}
792
793OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
794 unsigned N,
795 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000796 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetDataDirective),
797 llvm::alignOf<OMPClause *>()) +
798 sizeof(OMPClause *) * N + sizeof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000799 return new (Mem) OMPTargetDataDirective(N);
800}
801
Samuel Antaodf67fc42016-01-19 19:15:56 +0000802OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
803 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
804 ArrayRef<OMPClause *> Clauses) {
805 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective),
806 llvm::alignOf<OMPClause *>()) +
807 sizeof(OMPClause *) * Clauses.size());
808 OMPTargetEnterDataDirective *Dir =
809 new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size());
810 Dir->setClauses(Clauses);
811 return Dir;
812}
813
814OMPTargetEnterDataDirective *
815OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
816 EmptyShell) {
817 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetEnterDataDirective),
818 llvm::alignOf<OMPClause *>()) +
819 sizeof(OMPClause *) * N);
820 return new (Mem) OMPTargetEnterDataDirective(N);
821}
822
Samuel Antao72590762016-01-19 20:04:50 +0000823OMPTargetExitDataDirective *
824OMPTargetExitDataDirective::Create(const ASTContext &C, SourceLocation StartLoc,
825 SourceLocation EndLoc,
826 ArrayRef<OMPClause *> Clauses) {
827 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective),
828 llvm::alignOf<OMPClause *>()) +
829 sizeof(OMPClause *) * Clauses.size());
830 OMPTargetExitDataDirective *Dir =
831 new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size());
832 Dir->setClauses(Clauses);
833 return Dir;
834}
835
836OMPTargetExitDataDirective *
837OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
838 EmptyShell) {
839 void *Mem = C.Allocate(llvm::alignTo(sizeof(OMPTargetExitDataDirective),
840 llvm::alignOf<OMPClause *>()) +
841 sizeof(OMPClause *) * N);
842 return new (Mem) OMPTargetExitDataDirective(N);
843}
844
James Y Knightb8bfd962015-10-02 13:41:04 +0000845OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
846 SourceLocation StartLoc,
847 SourceLocation EndLoc,
848 ArrayRef<OMPClause *> Clauses,
849 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000850 unsigned Size =
851 llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000852 void *Mem =
853 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
854 OMPTeamsDirective *Dir =
855 new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
856 Dir->setClauses(Clauses);
857 Dir->setAssociatedStmt(AssociatedStmt);
858 return Dir;
859}
860
861OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
862 unsigned NumClauses,
863 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000864 unsigned Size =
865 llvm::alignTo(sizeof(OMPTeamsDirective), llvm::alignOf<OMPClause *>());
James Y Knightb8bfd962015-10-02 13:41:04 +0000866 void *Mem =
867 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
868 return new (Mem) OMPTeamsDirective(NumClauses);
869}
Alexey Bataev49f6e782015-12-01 04:18:41 +0000870
871OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
872 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
873 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
874 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000875 unsigned Size =
876 llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>());
Alexey Bataev49f6e782015-12-01 04:18:41 +0000877 void *Mem =
878 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
879 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
880 OMPTaskLoopDirective *Dir = new (Mem)
881 OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
882 Dir->setClauses(Clauses);
883 Dir->setAssociatedStmt(AssociatedStmt);
884 Dir->setIterationVariable(Exprs.IterationVarRef);
885 Dir->setLastIteration(Exprs.LastIteration);
886 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
887 Dir->setPreCond(Exprs.PreCond);
888 Dir->setCond(Exprs.Cond);
889 Dir->setInit(Exprs.Init);
890 Dir->setInc(Exprs.Inc);
891 Dir->setIsLastIterVariable(Exprs.IL);
892 Dir->setLowerBoundVariable(Exprs.LB);
893 Dir->setUpperBoundVariable(Exprs.UB);
894 Dir->setStrideVariable(Exprs.ST);
895 Dir->setEnsureUpperBound(Exprs.EUB);
896 Dir->setNextLowerBound(Exprs.NLB);
897 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000898 Dir->setNumIterations(Exprs.NumIterations);
Alexey Bataev49f6e782015-12-01 04:18:41 +0000899 Dir->setCounters(Exprs.Counters);
900 Dir->setPrivateCounters(Exprs.PrivateCounters);
901 Dir->setInits(Exprs.Inits);
902 Dir->setUpdates(Exprs.Updates);
903 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000904 Dir->setPreInits(Exprs.PreInits);
Alexey Bataev49f6e782015-12-01 04:18:41 +0000905 return Dir;
906}
907
908OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
909 unsigned NumClauses,
910 unsigned CollapsedNum,
911 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000912 unsigned Size =
913 llvm::alignTo(sizeof(OMPTaskLoopDirective), llvm::alignOf<OMPClause *>());
Alexey Bataev49f6e782015-12-01 04:18:41 +0000914 void *Mem =
915 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
916 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
917 return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses);
918}
919
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000920OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
921 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
922 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
923 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000924 unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective),
925 llvm::alignOf<OMPClause *>());
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000926 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
927 sizeof(Stmt *) *
928 numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
929 OMPTaskLoopSimdDirective *Dir = new (Mem)
930 OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
931 Dir->setClauses(Clauses);
932 Dir->setAssociatedStmt(AssociatedStmt);
933 Dir->setIterationVariable(Exprs.IterationVarRef);
934 Dir->setLastIteration(Exprs.LastIteration);
935 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
936 Dir->setPreCond(Exprs.PreCond);
937 Dir->setCond(Exprs.Cond);
938 Dir->setInit(Exprs.Init);
939 Dir->setInc(Exprs.Inc);
940 Dir->setIsLastIterVariable(Exprs.IL);
941 Dir->setLowerBoundVariable(Exprs.LB);
942 Dir->setUpperBoundVariable(Exprs.UB);
943 Dir->setStrideVariable(Exprs.ST);
944 Dir->setEnsureUpperBound(Exprs.EUB);
945 Dir->setNextLowerBound(Exprs.NLB);
946 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000947 Dir->setNumIterations(Exprs.NumIterations);
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000948 Dir->setCounters(Exprs.Counters);
949 Dir->setPrivateCounters(Exprs.PrivateCounters);
950 Dir->setInits(Exprs.Inits);
951 Dir->setUpdates(Exprs.Updates);
952 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000953 Dir->setPreInits(Exprs.PreInits);
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000954 return Dir;
955}
956
957OMPTaskLoopSimdDirective *
958OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
959 unsigned CollapsedNum, EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000960 unsigned Size = llvm::alignTo(sizeof(OMPTaskLoopSimdDirective),
961 llvm::alignOf<OMPClause *>());
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000962 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
963 sizeof(Stmt *) *
964 numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
965 return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);
966}
967
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000968OMPDistributeDirective *OMPDistributeDirective::Create(
969 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
970 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
971 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000972 unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective),
973 llvm::alignOf<OMPClause *>());
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000974 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
975 sizeof(Stmt *) *
976 numLoopChildren(CollapsedNum, OMPD_distribute));
977 OMPDistributeDirective *Dir = new (Mem)
978 OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
979 Dir->setClauses(Clauses);
980 Dir->setAssociatedStmt(AssociatedStmt);
981 Dir->setIterationVariable(Exprs.IterationVarRef);
982 Dir->setLastIteration(Exprs.LastIteration);
983 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
984 Dir->setPreCond(Exprs.PreCond);
985 Dir->setCond(Exprs.Cond);
986 Dir->setInit(Exprs.Init);
987 Dir->setInc(Exprs.Inc);
988 Dir->setIsLastIterVariable(Exprs.IL);
989 Dir->setLowerBoundVariable(Exprs.LB);
990 Dir->setUpperBoundVariable(Exprs.UB);
991 Dir->setStrideVariable(Exprs.ST);
992 Dir->setEnsureUpperBound(Exprs.EUB);
993 Dir->setNextLowerBound(Exprs.NLB);
994 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000995 Dir->setNumIterations(Exprs.NumIterations);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +0000996 Dir->setCounters(Exprs.Counters);
997 Dir->setPrivateCounters(Exprs.PrivateCounters);
998 Dir->setInits(Exprs.Inits);
999 Dir->setUpdates(Exprs.Updates);
1000 Dir->setFinals(Exprs.Finals);
Alexey Bataev5a3af132016-03-29 08:58:54 +00001001 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001002 return Dir;
1003}
1004
1005OMPDistributeDirective *
1006OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1007 unsigned CollapsedNum, EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +00001008 unsigned Size = llvm::alignTo(sizeof(OMPDistributeDirective),
1009 llvm::alignOf<OMPClause *>());
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001010 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1011 sizeof(Stmt *) *
1012 numLoopChildren(CollapsedNum, OMPD_distribute));
1013 return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1014}
Samuel Antao686c70c2016-05-26 17:30:50 +00001015
1016OMPTargetUpdateDirective *
1017OMPTargetUpdateDirective::Create(const ASTContext &C, SourceLocation StartLoc,
1018 SourceLocation EndLoc,
1019 ArrayRef<OMPClause *> Clauses) {
1020 unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective),
1021 llvm::alignOf<OMPClause *>());
1022 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
1023 OMPTargetUpdateDirective *Dir =
1024 new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1025 Dir->setClauses(Clauses);
1026 return Dir;
1027}
1028
1029OMPTargetUpdateDirective *
1030OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1031 EmptyShell) {
1032 unsigned Size = llvm::alignTo(sizeof(OMPTargetUpdateDirective),
1033 llvm::alignOf<OMPClause *>());
1034 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
1035 return new (Mem) OMPTargetUpdateDirective(NumClauses);
1036}