blob: 7fda574bae0e8b4abd27e31a242cb2eeaeade1f2 [file] [log] [blame]
James Y Knightb8bfd962015-10-02 13:41:04 +00001//===--- StmtOpenMP.cpp - Classes for OpenMP directives -------------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
James Y Knightb8bfd962015-10-02 13:41:04 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the subclesses of Stmt class declared in StmtOpenMP.h
10//
11//===----------------------------------------------------------------------===//
12
13#include "clang/AST/StmtOpenMP.h"
14
15#include "clang/AST/ASTContext.h"
16
17using namespace clang;
18
19void OMPExecutableDirective::setClauses(ArrayRef<OMPClause *> Clauses) {
20 assert(Clauses.size() == getNumClauses() &&
21 "Number of clauses is not the same as the preallocated buffer");
22 std::copy(Clauses.begin(), Clauses.end(), getClauses().begin());
23}
24
Roman Lebedevb5700602019-03-20 16:32:36 +000025bool OMPExecutableDirective::isStandaloneDirective() const {
26 // Special case: 'omp target enter data', 'omp target exit data',
27 // 'omp target update' are stand-alone directives, but for implementation
28 // reasons they have empty synthetic structured block, to simplify codegen.
29 if (isa<OMPTargetEnterDataDirective>(this) ||
30 isa<OMPTargetExitDataDirective>(this) ||
31 isa<OMPTargetUpdateDirective>(this))
32 return true;
33 return !hasAssociatedStmt() || !getAssociatedStmt();
34}
35
36const Stmt *OMPExecutableDirective::getStructuredBlock() const {
37 assert(!isStandaloneDirective() &&
38 "Standalone Executable Directives don't have Structured Blocks.");
39 if (auto *LD = dyn_cast<OMPLoopDirective>(this))
40 return LD->getBody();
41 return getInnermostCapturedStmt()->getCapturedStmt();
42}
43
James Y Knightb8bfd962015-10-02 13:41:04 +000044void OMPLoopDirective::setCounters(ArrayRef<Expr *> A) {
45 assert(A.size() == getCollapsedNumber() &&
46 "Number of loop counters is not the same as the collapsed number");
47 std::copy(A.begin(), A.end(), getCounters().begin());
48}
49
50void OMPLoopDirective::setPrivateCounters(ArrayRef<Expr *> A) {
51 assert(A.size() == getCollapsedNumber() && "Number of loop private counters "
52 "is not the same as the collapsed "
53 "number");
54 std::copy(A.begin(), A.end(), getPrivateCounters().begin());
55}
56
57void OMPLoopDirective::setInits(ArrayRef<Expr *> A) {
58 assert(A.size() == getCollapsedNumber() &&
59 "Number of counter inits is not the same as the collapsed number");
60 std::copy(A.begin(), A.end(), getInits().begin());
61}
62
63void OMPLoopDirective::setUpdates(ArrayRef<Expr *> A) {
64 assert(A.size() == getCollapsedNumber() &&
65 "Number of counter updates is not the same as the collapsed number");
66 std::copy(A.begin(), A.end(), getUpdates().begin());
67}
68
69void OMPLoopDirective::setFinals(ArrayRef<Expr *> A) {
70 assert(A.size() == getCollapsedNumber() &&
71 "Number of counter finals is not the same as the collapsed number");
72 std::copy(A.begin(), A.end(), getFinals().begin());
73}
74
Alexey Bataevf8be4762019-08-14 19:30:06 +000075void OMPLoopDirective::setDependentCounters(ArrayRef<Expr *> A) {
76 assert(
77 A.size() == getCollapsedNumber() &&
78 "Number of dependent counters is not the same as the collapsed number");
79 llvm::copy(A, getDependentCounters().begin());
80}
81
82void OMPLoopDirective::setDependentInits(ArrayRef<Expr *> A) {
83 assert(A.size() == getCollapsedNumber() &&
84 "Number of dependent inits is not the same as the collapsed number");
85 llvm::copy(A, getDependentInits().begin());
86}
87
88void OMPLoopDirective::setFinalsConditions(ArrayRef<Expr *> A) {
89 assert(A.size() == getCollapsedNumber() &&
90 "Number of finals conditions is not the same as the collapsed number");
91 llvm::copy(A, getFinalsConditions().begin());
92}
93
James Y Knightb8bfd962015-10-02 13:41:04 +000094OMPParallelDirective *OMPParallelDirective::Create(
95 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
96 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +000097 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +000098 llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +000099 void *Mem =
100 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
101 OMPParallelDirective *Dir =
102 new (Mem) OMPParallelDirective(StartLoc, EndLoc, Clauses.size());
103 Dir->setClauses(Clauses);
104 Dir->setAssociatedStmt(AssociatedStmt);
105 Dir->setHasCancel(HasCancel);
106 return Dir;
107}
108
109OMPParallelDirective *OMPParallelDirective::CreateEmpty(const ASTContext &C,
110 unsigned NumClauses,
111 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000112 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000113 llvm::alignTo(sizeof(OMPParallelDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000114 void *Mem =
115 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
116 return new (Mem) OMPParallelDirective(NumClauses);
117}
118
119OMPSimdDirective *
120OMPSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
121 SourceLocation EndLoc, unsigned CollapsedNum,
122 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
123 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000124 unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000125 void *Mem =
126 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
127 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
128 OMPSimdDirective *Dir = new (Mem)
129 OMPSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
130 Dir->setClauses(Clauses);
131 Dir->setAssociatedStmt(AssociatedStmt);
132 Dir->setIterationVariable(Exprs.IterationVarRef);
133 Dir->setLastIteration(Exprs.LastIteration);
134 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
135 Dir->setPreCond(Exprs.PreCond);
136 Dir->setCond(Exprs.Cond);
137 Dir->setInit(Exprs.Init);
138 Dir->setInc(Exprs.Inc);
139 Dir->setCounters(Exprs.Counters);
140 Dir->setPrivateCounters(Exprs.PrivateCounters);
141 Dir->setInits(Exprs.Inits);
142 Dir->setUpdates(Exprs.Updates);
143 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +0000144 Dir->setDependentCounters(Exprs.DependentCounters);
145 Dir->setDependentInits(Exprs.DependentInits);
146 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000147 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000148 return Dir;
149}
150
151OMPSimdDirective *OMPSimdDirective::CreateEmpty(const ASTContext &C,
152 unsigned NumClauses,
153 unsigned CollapsedNum,
154 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000155 unsigned Size = llvm::alignTo(sizeof(OMPSimdDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000156 void *Mem =
157 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
158 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_simd));
159 return new (Mem) OMPSimdDirective(CollapsedNum, NumClauses);
160}
161
162OMPForDirective *
163OMPForDirective::Create(const ASTContext &C, SourceLocation StartLoc,
164 SourceLocation EndLoc, unsigned CollapsedNum,
165 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
166 const HelperExprs &Exprs, bool HasCancel) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000167 unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000168 void *Mem =
169 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
170 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
171 OMPForDirective *Dir =
172 new (Mem) OMPForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
173 Dir->setClauses(Clauses);
174 Dir->setAssociatedStmt(AssociatedStmt);
175 Dir->setIterationVariable(Exprs.IterationVarRef);
176 Dir->setLastIteration(Exprs.LastIteration);
177 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
178 Dir->setPreCond(Exprs.PreCond);
179 Dir->setCond(Exprs.Cond);
180 Dir->setInit(Exprs.Init);
181 Dir->setInc(Exprs.Inc);
182 Dir->setIsLastIterVariable(Exprs.IL);
183 Dir->setLowerBoundVariable(Exprs.LB);
184 Dir->setUpperBoundVariable(Exprs.UB);
185 Dir->setStrideVariable(Exprs.ST);
186 Dir->setEnsureUpperBound(Exprs.EUB);
187 Dir->setNextLowerBound(Exprs.NLB);
188 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000189 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000190 Dir->setCounters(Exprs.Counters);
191 Dir->setPrivateCounters(Exprs.PrivateCounters);
192 Dir->setInits(Exprs.Inits);
193 Dir->setUpdates(Exprs.Updates);
194 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +0000195 Dir->setDependentCounters(Exprs.DependentCounters);
196 Dir->setDependentInits(Exprs.DependentInits);
197 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000198 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000199 Dir->setHasCancel(HasCancel);
200 return Dir;
201}
202
203OMPForDirective *OMPForDirective::CreateEmpty(const ASTContext &C,
204 unsigned NumClauses,
205 unsigned CollapsedNum,
206 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000207 unsigned Size = llvm::alignTo(sizeof(OMPForDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000208 void *Mem =
209 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
210 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for));
211 return new (Mem) OMPForDirective(CollapsedNum, NumClauses);
212}
213
214OMPForSimdDirective *
215OMPForSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
216 SourceLocation EndLoc, unsigned CollapsedNum,
217 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
218 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000219 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000220 llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000221 void *Mem =
222 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
223 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
224 OMPForSimdDirective *Dir = new (Mem)
225 OMPForSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
226 Dir->setClauses(Clauses);
227 Dir->setAssociatedStmt(AssociatedStmt);
228 Dir->setIterationVariable(Exprs.IterationVarRef);
229 Dir->setLastIteration(Exprs.LastIteration);
230 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
231 Dir->setPreCond(Exprs.PreCond);
232 Dir->setCond(Exprs.Cond);
233 Dir->setInit(Exprs.Init);
234 Dir->setInc(Exprs.Inc);
235 Dir->setIsLastIterVariable(Exprs.IL);
236 Dir->setLowerBoundVariable(Exprs.LB);
237 Dir->setUpperBoundVariable(Exprs.UB);
238 Dir->setStrideVariable(Exprs.ST);
239 Dir->setEnsureUpperBound(Exprs.EUB);
240 Dir->setNextLowerBound(Exprs.NLB);
241 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000242 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000243 Dir->setCounters(Exprs.Counters);
244 Dir->setPrivateCounters(Exprs.PrivateCounters);
245 Dir->setInits(Exprs.Inits);
246 Dir->setUpdates(Exprs.Updates);
247 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +0000248 Dir->setDependentCounters(Exprs.DependentCounters);
249 Dir->setDependentInits(Exprs.DependentInits);
250 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000251 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000252 return Dir;
253}
254
255OMPForSimdDirective *OMPForSimdDirective::CreateEmpty(const ASTContext &C,
256 unsigned NumClauses,
257 unsigned CollapsedNum,
258 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000259 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000260 llvm::alignTo(sizeof(OMPForSimdDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000261 void *Mem =
262 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
263 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_for_simd));
264 return new (Mem) OMPForSimdDirective(CollapsedNum, NumClauses);
265}
266
267OMPSectionsDirective *OMPSectionsDirective::Create(
268 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
269 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000270 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000271 llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000272 void *Mem =
273 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
274 OMPSectionsDirective *Dir =
275 new (Mem) OMPSectionsDirective(StartLoc, EndLoc, Clauses.size());
276 Dir->setClauses(Clauses);
277 Dir->setAssociatedStmt(AssociatedStmt);
278 Dir->setHasCancel(HasCancel);
279 return Dir;
280}
281
282OMPSectionsDirective *OMPSectionsDirective::CreateEmpty(const ASTContext &C,
283 unsigned NumClauses,
284 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000285 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000286 llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000287 void *Mem =
288 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
289 return new (Mem) OMPSectionsDirective(NumClauses);
290}
291
292OMPSectionDirective *OMPSectionDirective::Create(const ASTContext &C,
293 SourceLocation StartLoc,
294 SourceLocation EndLoc,
295 Stmt *AssociatedStmt,
296 bool HasCancel) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000297 unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000298 void *Mem = C.Allocate(Size + sizeof(Stmt *));
299 OMPSectionDirective *Dir = new (Mem) OMPSectionDirective(StartLoc, EndLoc);
300 Dir->setAssociatedStmt(AssociatedStmt);
301 Dir->setHasCancel(HasCancel);
302 return Dir;
303}
304
305OMPSectionDirective *OMPSectionDirective::CreateEmpty(const ASTContext &C,
306 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000307 unsigned Size = llvm::alignTo(sizeof(OMPSectionDirective), alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000308 void *Mem = C.Allocate(Size + sizeof(Stmt *));
309 return new (Mem) OMPSectionDirective();
310}
311
312OMPSingleDirective *OMPSingleDirective::Create(const ASTContext &C,
313 SourceLocation StartLoc,
314 SourceLocation EndLoc,
315 ArrayRef<OMPClause *> Clauses,
316 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000317 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000318 llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000319 void *Mem =
320 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
321 OMPSingleDirective *Dir =
322 new (Mem) OMPSingleDirective(StartLoc, EndLoc, Clauses.size());
323 Dir->setClauses(Clauses);
324 Dir->setAssociatedStmt(AssociatedStmt);
325 return Dir;
326}
327
328OMPSingleDirective *OMPSingleDirective::CreateEmpty(const ASTContext &C,
329 unsigned NumClauses,
330 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000331 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000332 llvm::alignTo(sizeof(OMPSingleDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000333 void *Mem =
334 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
335 return new (Mem) OMPSingleDirective(NumClauses);
336}
337
338OMPMasterDirective *OMPMasterDirective::Create(const ASTContext &C,
339 SourceLocation StartLoc,
340 SourceLocation EndLoc,
341 Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000342 unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000343 void *Mem = C.Allocate(Size + sizeof(Stmt *));
344 OMPMasterDirective *Dir = new (Mem) OMPMasterDirective(StartLoc, EndLoc);
345 Dir->setAssociatedStmt(AssociatedStmt);
346 return Dir;
347}
348
349OMPMasterDirective *OMPMasterDirective::CreateEmpty(const ASTContext &C,
350 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000351 unsigned Size = llvm::alignTo(sizeof(OMPMasterDirective), alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000352 void *Mem = C.Allocate(Size + sizeof(Stmt *));
353 return new (Mem) OMPMasterDirective();
354}
355
356OMPCriticalDirective *OMPCriticalDirective::Create(
357 const ASTContext &C, const DeclarationNameInfo &Name,
Alexey Bataev28c75412015-12-15 08:19:24 +0000358 SourceLocation StartLoc, SourceLocation EndLoc,
359 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000360 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000361 llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
Alexey Bataev28c75412015-12-15 08:19:24 +0000362 void *Mem =
363 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000364 OMPCriticalDirective *Dir =
Alexey Bataev28c75412015-12-15 08:19:24 +0000365 new (Mem) OMPCriticalDirective(Name, StartLoc, EndLoc, Clauses.size());
366 Dir->setClauses(Clauses);
James Y Knightb8bfd962015-10-02 13:41:04 +0000367 Dir->setAssociatedStmt(AssociatedStmt);
368 return Dir;
369}
370
371OMPCriticalDirective *OMPCriticalDirective::CreateEmpty(const ASTContext &C,
Alexey Bataev28c75412015-12-15 08:19:24 +0000372 unsigned NumClauses,
James Y Knightb8bfd962015-10-02 13:41:04 +0000373 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000374 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000375 llvm::alignTo(sizeof(OMPCriticalDirective), alignof(OMPClause *));
Alexey Bataev28c75412015-12-15 08:19:24 +0000376 void *Mem =
377 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
378 return new (Mem) OMPCriticalDirective(NumClauses);
James Y Knightb8bfd962015-10-02 13:41:04 +0000379}
380
381OMPParallelForDirective *OMPParallelForDirective::Create(
382 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
383 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
384 const HelperExprs &Exprs, bool HasCancel) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000385 unsigned Size =
386 llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000387 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
388 sizeof(Stmt *) *
389 numLoopChildren(CollapsedNum, OMPD_parallel_for));
390 OMPParallelForDirective *Dir = new (Mem)
391 OMPParallelForDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
392 Dir->setClauses(Clauses);
393 Dir->setAssociatedStmt(AssociatedStmt);
394 Dir->setIterationVariable(Exprs.IterationVarRef);
395 Dir->setLastIteration(Exprs.LastIteration);
396 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
397 Dir->setPreCond(Exprs.PreCond);
398 Dir->setCond(Exprs.Cond);
399 Dir->setInit(Exprs.Init);
400 Dir->setInc(Exprs.Inc);
401 Dir->setIsLastIterVariable(Exprs.IL);
402 Dir->setLowerBoundVariable(Exprs.LB);
403 Dir->setUpperBoundVariable(Exprs.UB);
404 Dir->setStrideVariable(Exprs.ST);
405 Dir->setEnsureUpperBound(Exprs.EUB);
406 Dir->setNextLowerBound(Exprs.NLB);
407 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000408 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000409 Dir->setCounters(Exprs.Counters);
410 Dir->setPrivateCounters(Exprs.PrivateCounters);
411 Dir->setInits(Exprs.Inits);
412 Dir->setUpdates(Exprs.Updates);
413 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +0000414 Dir->setDependentCounters(Exprs.DependentCounters);
415 Dir->setDependentInits(Exprs.DependentInits);
416 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000417 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000418 Dir->setHasCancel(HasCancel);
419 return Dir;
420}
421
422OMPParallelForDirective *
423OMPParallelForDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
424 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000425 unsigned Size =
426 llvm::alignTo(sizeof(OMPParallelForDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000427 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
428 sizeof(Stmt *) *
429 numLoopChildren(CollapsedNum, OMPD_parallel_for));
430 return new (Mem) OMPParallelForDirective(CollapsedNum, NumClauses);
431}
432
433OMPParallelForSimdDirective *OMPParallelForSimdDirective::Create(
434 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
435 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
436 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000437 unsigned Size =
438 llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000439 void *Mem = C.Allocate(
440 Size + sizeof(OMPClause *) * Clauses.size() +
441 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
442 OMPParallelForSimdDirective *Dir = new (Mem) OMPParallelForSimdDirective(
443 StartLoc, EndLoc, CollapsedNum, Clauses.size());
444 Dir->setClauses(Clauses);
445 Dir->setAssociatedStmt(AssociatedStmt);
446 Dir->setIterationVariable(Exprs.IterationVarRef);
447 Dir->setLastIteration(Exprs.LastIteration);
448 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
449 Dir->setPreCond(Exprs.PreCond);
450 Dir->setCond(Exprs.Cond);
451 Dir->setInit(Exprs.Init);
452 Dir->setInc(Exprs.Inc);
453 Dir->setIsLastIterVariable(Exprs.IL);
454 Dir->setLowerBoundVariable(Exprs.LB);
455 Dir->setUpperBoundVariable(Exprs.UB);
456 Dir->setStrideVariable(Exprs.ST);
457 Dir->setEnsureUpperBound(Exprs.EUB);
458 Dir->setNextLowerBound(Exprs.NLB);
459 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000460 Dir->setNumIterations(Exprs.NumIterations);
James Y Knightb8bfd962015-10-02 13:41:04 +0000461 Dir->setCounters(Exprs.Counters);
462 Dir->setPrivateCounters(Exprs.PrivateCounters);
463 Dir->setInits(Exprs.Inits);
464 Dir->setUpdates(Exprs.Updates);
465 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +0000466 Dir->setDependentCounters(Exprs.DependentCounters);
467 Dir->setDependentInits(Exprs.DependentInits);
468 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000469 Dir->setPreInits(Exprs.PreInits);
James Y Knightb8bfd962015-10-02 13:41:04 +0000470 return Dir;
471}
472
473OMPParallelForSimdDirective *
474OMPParallelForSimdDirective::CreateEmpty(const ASTContext &C,
475 unsigned NumClauses,
476 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000477 unsigned Size =
478 llvm::alignTo(sizeof(OMPParallelForSimdDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000479 void *Mem = C.Allocate(
480 Size + sizeof(OMPClause *) * NumClauses +
481 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_parallel_for_simd));
482 return new (Mem) OMPParallelForSimdDirective(CollapsedNum, NumClauses);
483}
484
485OMPParallelSectionsDirective *OMPParallelSectionsDirective::Create(
486 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
487 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, bool HasCancel) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000488 unsigned Size =
489 llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000490 void *Mem =
491 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
492 OMPParallelSectionsDirective *Dir =
493 new (Mem) OMPParallelSectionsDirective(StartLoc, EndLoc, Clauses.size());
494 Dir->setClauses(Clauses);
495 Dir->setAssociatedStmt(AssociatedStmt);
496 Dir->setHasCancel(HasCancel);
497 return Dir;
498}
499
500OMPParallelSectionsDirective *
501OMPParallelSectionsDirective::CreateEmpty(const ASTContext &C,
502 unsigned NumClauses, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000503 unsigned Size =
504 llvm::alignTo(sizeof(OMPParallelSectionsDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000505 void *Mem =
506 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
507 return new (Mem) OMPParallelSectionsDirective(NumClauses);
508}
509
510OMPTaskDirective *
511OMPTaskDirective::Create(const ASTContext &C, SourceLocation StartLoc,
512 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
513 Stmt *AssociatedStmt, bool HasCancel) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000514 unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000515 void *Mem =
516 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
517 OMPTaskDirective *Dir =
518 new (Mem) OMPTaskDirective(StartLoc, EndLoc, Clauses.size());
519 Dir->setClauses(Clauses);
520 Dir->setAssociatedStmt(AssociatedStmt);
521 Dir->setHasCancel(HasCancel);
522 return Dir;
523}
524
525OMPTaskDirective *OMPTaskDirective::CreateEmpty(const ASTContext &C,
526 unsigned NumClauses,
527 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000528 unsigned Size = llvm::alignTo(sizeof(OMPTaskDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000529 void *Mem =
530 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
531 return new (Mem) OMPTaskDirective(NumClauses);
532}
533
534OMPTaskyieldDirective *OMPTaskyieldDirective::Create(const ASTContext &C,
535 SourceLocation StartLoc,
536 SourceLocation EndLoc) {
537 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
538 OMPTaskyieldDirective *Dir =
539 new (Mem) OMPTaskyieldDirective(StartLoc, EndLoc);
540 return Dir;
541}
542
543OMPTaskyieldDirective *OMPTaskyieldDirective::CreateEmpty(const ASTContext &C,
544 EmptyShell) {
545 void *Mem = C.Allocate(sizeof(OMPTaskyieldDirective));
546 return new (Mem) OMPTaskyieldDirective();
547}
548
549OMPBarrierDirective *OMPBarrierDirective::Create(const ASTContext &C,
550 SourceLocation StartLoc,
551 SourceLocation EndLoc) {
552 void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
553 OMPBarrierDirective *Dir = new (Mem) OMPBarrierDirective(StartLoc, EndLoc);
554 return Dir;
555}
556
557OMPBarrierDirective *OMPBarrierDirective::CreateEmpty(const ASTContext &C,
558 EmptyShell) {
559 void *Mem = C.Allocate(sizeof(OMPBarrierDirective));
560 return new (Mem) OMPBarrierDirective();
561}
562
563OMPTaskwaitDirective *OMPTaskwaitDirective::Create(const ASTContext &C,
564 SourceLocation StartLoc,
565 SourceLocation EndLoc) {
566 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
567 OMPTaskwaitDirective *Dir = new (Mem) OMPTaskwaitDirective(StartLoc, EndLoc);
568 return Dir;
569}
570
571OMPTaskwaitDirective *OMPTaskwaitDirective::CreateEmpty(const ASTContext &C,
572 EmptyShell) {
573 void *Mem = C.Allocate(sizeof(OMPTaskwaitDirective));
574 return new (Mem) OMPTaskwaitDirective();
575}
576
Alexey Bataev169d96a2017-07-18 20:17:46 +0000577OMPTaskgroupDirective *OMPTaskgroupDirective::Create(
578 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000579 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *ReductionRef) {
Alexey Bataev169d96a2017-07-18 20:17:46 +0000580 unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
581 sizeof(OMPClause *) * Clauses.size(),
582 alignof(Stmt *));
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000583 void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000584 OMPTaskgroupDirective *Dir =
Alexey Bataev169d96a2017-07-18 20:17:46 +0000585 new (Mem) OMPTaskgroupDirective(StartLoc, EndLoc, Clauses.size());
James Y Knightb8bfd962015-10-02 13:41:04 +0000586 Dir->setAssociatedStmt(AssociatedStmt);
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000587 Dir->setReductionRef(ReductionRef);
Alexey Bataev169d96a2017-07-18 20:17:46 +0000588 Dir->setClauses(Clauses);
James Y Knightb8bfd962015-10-02 13:41:04 +0000589 return Dir;
590}
591
592OMPTaskgroupDirective *OMPTaskgroupDirective::CreateEmpty(const ASTContext &C,
Alexey Bataev169d96a2017-07-18 20:17:46 +0000593 unsigned NumClauses,
James Y Knightb8bfd962015-10-02 13:41:04 +0000594 EmptyShell) {
Alexey Bataev169d96a2017-07-18 20:17:46 +0000595 unsigned Size = llvm::alignTo(sizeof(OMPTaskgroupDirective) +
596 sizeof(OMPClause *) * NumClauses,
597 alignof(Stmt *));
Alexey Bataev3b1b8952017-07-25 15:53:26 +0000598 void *Mem = C.Allocate(Size + sizeof(Stmt *) + sizeof(Expr *));
Alexey Bataev169d96a2017-07-18 20:17:46 +0000599 return new (Mem) OMPTaskgroupDirective(NumClauses);
James Y Knightb8bfd962015-10-02 13:41:04 +0000600}
601
602OMPCancellationPointDirective *OMPCancellationPointDirective::Create(
603 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
604 OpenMPDirectiveKind CancelRegion) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000605 unsigned Size =
606 llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000607 void *Mem = C.Allocate(Size);
608 OMPCancellationPointDirective *Dir =
609 new (Mem) OMPCancellationPointDirective(StartLoc, EndLoc);
610 Dir->setCancelRegion(CancelRegion);
611 return Dir;
612}
613
614OMPCancellationPointDirective *
615OMPCancellationPointDirective::CreateEmpty(const ASTContext &C, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000616 unsigned Size =
617 llvm::alignTo(sizeof(OMPCancellationPointDirective), alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000618 void *Mem = C.Allocate(Size);
619 return new (Mem) OMPCancellationPointDirective();
620}
621
622OMPCancelDirective *
623OMPCancelDirective::Create(const ASTContext &C, SourceLocation StartLoc,
624 SourceLocation EndLoc, ArrayRef<OMPClause *> Clauses,
625 OpenMPDirectiveKind CancelRegion) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000626 unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
627 sizeof(OMPClause *) * Clauses.size(),
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000628 alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000629 void *Mem = C.Allocate(Size);
630 OMPCancelDirective *Dir =
631 new (Mem) OMPCancelDirective(StartLoc, EndLoc, Clauses.size());
632 Dir->setClauses(Clauses);
633 Dir->setCancelRegion(CancelRegion);
634 return Dir;
635}
636
637OMPCancelDirective *OMPCancelDirective::CreateEmpty(const ASTContext &C,
638 unsigned NumClauses,
639 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000640 unsigned Size = llvm::alignTo(sizeof(OMPCancelDirective) +
641 sizeof(OMPClause *) * NumClauses,
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000642 alignof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000643 void *Mem = C.Allocate(Size);
644 return new (Mem) OMPCancelDirective(NumClauses);
645}
646
647OMPFlushDirective *OMPFlushDirective::Create(const ASTContext &C,
648 SourceLocation StartLoc,
649 SourceLocation EndLoc,
650 ArrayRef<OMPClause *> Clauses) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000651 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000652 llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000653 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size());
654 OMPFlushDirective *Dir =
655 new (Mem) OMPFlushDirective(StartLoc, EndLoc, Clauses.size());
656 Dir->setClauses(Clauses);
657 return Dir;
658}
659
660OMPFlushDirective *OMPFlushDirective::CreateEmpty(const ASTContext &C,
661 unsigned NumClauses,
662 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000663 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000664 llvm::alignTo(sizeof(OMPFlushDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000665 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses);
666 return new (Mem) OMPFlushDirective(NumClauses);
667}
668
669OMPOrderedDirective *OMPOrderedDirective::Create(const ASTContext &C,
670 SourceLocation StartLoc,
671 SourceLocation EndLoc,
672 ArrayRef<OMPClause *> Clauses,
673 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000674 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000675 llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000676 void *Mem =
677 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * Clauses.size());
678 OMPOrderedDirective *Dir =
679 new (Mem) OMPOrderedDirective(StartLoc, EndLoc, Clauses.size());
680 Dir->setClauses(Clauses);
681 Dir->setAssociatedStmt(AssociatedStmt);
682 return Dir;
683}
684
685OMPOrderedDirective *OMPOrderedDirective::CreateEmpty(const ASTContext &C,
686 unsigned NumClauses,
687 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000688 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000689 llvm::alignTo(sizeof(OMPOrderedDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000690 void *Mem =
691 C.Allocate(Size + sizeof(Stmt *) + sizeof(OMPClause *) * NumClauses);
692 return new (Mem) OMPOrderedDirective(NumClauses);
693}
694
695OMPAtomicDirective *OMPAtomicDirective::Create(
696 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
697 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
698 Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000699 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000700 llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000701 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
702 5 * sizeof(Stmt *));
703 OMPAtomicDirective *Dir =
704 new (Mem) OMPAtomicDirective(StartLoc, EndLoc, Clauses.size());
705 Dir->setClauses(Clauses);
706 Dir->setAssociatedStmt(AssociatedStmt);
707 Dir->setX(X);
708 Dir->setV(V);
709 Dir->setExpr(E);
710 Dir->setUpdateExpr(UE);
711 Dir->IsXLHSInRHSPart = IsXLHSInRHSPart;
712 Dir->IsPostfixUpdate = IsPostfixUpdate;
713 return Dir;
714}
715
716OMPAtomicDirective *OMPAtomicDirective::CreateEmpty(const ASTContext &C,
717 unsigned NumClauses,
718 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000719 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000720 llvm::alignTo(sizeof(OMPAtomicDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000721 void *Mem =
722 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + 5 * sizeof(Stmt *));
723 return new (Mem) OMPAtomicDirective(NumClauses);
724}
725
726OMPTargetDirective *OMPTargetDirective::Create(const ASTContext &C,
727 SourceLocation StartLoc,
728 SourceLocation EndLoc,
729 ArrayRef<OMPClause *> Clauses,
730 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000731 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000732 llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000733 void *Mem =
734 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
735 OMPTargetDirective *Dir =
736 new (Mem) OMPTargetDirective(StartLoc, EndLoc, Clauses.size());
737 Dir->setClauses(Clauses);
738 Dir->setAssociatedStmt(AssociatedStmt);
739 return Dir;
740}
741
742OMPTargetDirective *OMPTargetDirective::CreateEmpty(const ASTContext &C,
743 unsigned NumClauses,
744 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000745 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000746 llvm::alignTo(sizeof(OMPTargetDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000747 void *Mem =
748 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
749 return new (Mem) OMPTargetDirective(NumClauses);
750}
751
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000752OMPTargetParallelDirective *OMPTargetParallelDirective::Create(
753 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
754 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000755 unsigned Size =
756 llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000757 void *Mem =
758 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
759 OMPTargetParallelDirective *Dir =
760 new (Mem) OMPTargetParallelDirective(StartLoc, EndLoc, Clauses.size());
761 Dir->setClauses(Clauses);
762 Dir->setAssociatedStmt(AssociatedStmt);
763 return Dir;
764}
765
766OMPTargetParallelDirective *
767OMPTargetParallelDirective::CreateEmpty(const ASTContext &C,
768 unsigned NumClauses, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000769 unsigned Size =
770 llvm::alignTo(sizeof(OMPTargetParallelDirective), alignof(OMPClause *));
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000771 void *Mem =
772 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
773 return new (Mem) OMPTargetParallelDirective(NumClauses);
774}
775
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000776OMPTargetParallelForDirective *OMPTargetParallelForDirective::Create(
777 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
778 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
779 const HelperExprs &Exprs, bool HasCancel) {
780 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000781 alignof(OMPClause *));
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000782 void *Mem = C.Allocate(
783 Size + sizeof(OMPClause *) * Clauses.size() +
784 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
785 OMPTargetParallelForDirective *Dir = new (Mem) OMPTargetParallelForDirective(
786 StartLoc, EndLoc, CollapsedNum, Clauses.size());
787 Dir->setClauses(Clauses);
788 Dir->setAssociatedStmt(AssociatedStmt);
789 Dir->setIterationVariable(Exprs.IterationVarRef);
790 Dir->setLastIteration(Exprs.LastIteration);
791 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
792 Dir->setPreCond(Exprs.PreCond);
793 Dir->setCond(Exprs.Cond);
794 Dir->setInit(Exprs.Init);
795 Dir->setInc(Exprs.Inc);
796 Dir->setIsLastIterVariable(Exprs.IL);
797 Dir->setLowerBoundVariable(Exprs.LB);
798 Dir->setUpperBoundVariable(Exprs.UB);
799 Dir->setStrideVariable(Exprs.ST);
800 Dir->setEnsureUpperBound(Exprs.EUB);
801 Dir->setNextLowerBound(Exprs.NLB);
802 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000803 Dir->setNumIterations(Exprs.NumIterations);
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000804 Dir->setCounters(Exprs.Counters);
805 Dir->setPrivateCounters(Exprs.PrivateCounters);
806 Dir->setInits(Exprs.Inits);
807 Dir->setUpdates(Exprs.Updates);
808 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +0000809 Dir->setDependentCounters(Exprs.DependentCounters);
810 Dir->setDependentInits(Exprs.DependentInits);
811 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000812 Dir->setPreInits(Exprs.PreInits);
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000813 Dir->setHasCancel(HasCancel);
814 return Dir;
815}
816
817OMPTargetParallelForDirective *
818OMPTargetParallelForDirective::CreateEmpty(const ASTContext &C,
819 unsigned NumClauses,
820 unsigned CollapsedNum, EmptyShell) {
821 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000822 alignof(OMPClause *));
Arpith Chacko Jacob05bebb52016-02-03 15:46:42 +0000823 void *Mem = C.Allocate(
824 Size + sizeof(OMPClause *) * NumClauses +
825 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_target_parallel_for));
826 return new (Mem) OMPTargetParallelForDirective(CollapsedNum, NumClauses);
827}
828
James Y Knightb8bfd962015-10-02 13:41:04 +0000829OMPTargetDataDirective *OMPTargetDataDirective::Create(
830 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
831 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000832 void *Mem = C.Allocate(
833 llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
834 sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000835 OMPTargetDataDirective *Dir =
836 new (Mem) OMPTargetDataDirective(StartLoc, EndLoc, Clauses.size());
837 Dir->setClauses(Clauses);
838 Dir->setAssociatedStmt(AssociatedStmt);
839 return Dir;
840}
841
842OMPTargetDataDirective *OMPTargetDataDirective::CreateEmpty(const ASTContext &C,
843 unsigned N,
844 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000845 void *Mem = C.Allocate(
846 llvm::alignTo(sizeof(OMPTargetDataDirective), alignof(OMPClause *)) +
847 sizeof(OMPClause *) * N + sizeof(Stmt *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000848 return new (Mem) OMPTargetDataDirective(N);
849}
850
Samuel Antaodf67fc42016-01-19 19:15:56 +0000851OMPTargetEnterDataDirective *OMPTargetEnterDataDirective::Create(
852 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
Alexey Bataev7828b252017-11-21 17:08:48 +0000853 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000854 void *Mem = C.Allocate(
855 llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
Alexey Bataev7828b252017-11-21 17:08:48 +0000856 sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
Samuel Antaodf67fc42016-01-19 19:15:56 +0000857 OMPTargetEnterDataDirective *Dir =
858 new (Mem) OMPTargetEnterDataDirective(StartLoc, EndLoc, Clauses.size());
859 Dir->setClauses(Clauses);
Alexey Bataev7828b252017-11-21 17:08:48 +0000860 Dir->setAssociatedStmt(AssociatedStmt);
Samuel Antaodf67fc42016-01-19 19:15:56 +0000861 return Dir;
862}
863
864OMPTargetEnterDataDirective *
865OMPTargetEnterDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
866 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000867 void *Mem = C.Allocate(
868 llvm::alignTo(sizeof(OMPTargetEnterDataDirective), alignof(OMPClause *)) +
Alexey Bataev7828b252017-11-21 17:08:48 +0000869 sizeof(OMPClause *) * N + sizeof(Stmt *));
Samuel Antaodf67fc42016-01-19 19:15:56 +0000870 return new (Mem) OMPTargetEnterDataDirective(N);
871}
872
Alexey Bataev7828b252017-11-21 17:08:48 +0000873OMPTargetExitDataDirective *OMPTargetExitDataDirective::Create(
874 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
875 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000876 void *Mem = C.Allocate(
877 llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
Alexey Bataev7828b252017-11-21 17:08:48 +0000878 sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
Samuel Antao72590762016-01-19 20:04:50 +0000879 OMPTargetExitDataDirective *Dir =
880 new (Mem) OMPTargetExitDataDirective(StartLoc, EndLoc, Clauses.size());
881 Dir->setClauses(Clauses);
Alexey Bataev7828b252017-11-21 17:08:48 +0000882 Dir->setAssociatedStmt(AssociatedStmt);
Samuel Antao72590762016-01-19 20:04:50 +0000883 return Dir;
884}
885
886OMPTargetExitDataDirective *
887OMPTargetExitDataDirective::CreateEmpty(const ASTContext &C, unsigned N,
888 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000889 void *Mem = C.Allocate(
890 llvm::alignTo(sizeof(OMPTargetExitDataDirective), alignof(OMPClause *)) +
Alexey Bataev7828b252017-11-21 17:08:48 +0000891 sizeof(OMPClause *) * N + sizeof(Stmt *));
Samuel Antao72590762016-01-19 20:04:50 +0000892 return new (Mem) OMPTargetExitDataDirective(N);
893}
894
James Y Knightb8bfd962015-10-02 13:41:04 +0000895OMPTeamsDirective *OMPTeamsDirective::Create(const ASTContext &C,
896 SourceLocation StartLoc,
897 SourceLocation EndLoc,
898 ArrayRef<OMPClause *> Clauses,
899 Stmt *AssociatedStmt) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000900 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000901 llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000902 void *Mem =
903 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
904 OMPTeamsDirective *Dir =
905 new (Mem) OMPTeamsDirective(StartLoc, EndLoc, Clauses.size());
906 Dir->setClauses(Clauses);
907 Dir->setAssociatedStmt(AssociatedStmt);
908 return Dir;
909}
910
911OMPTeamsDirective *OMPTeamsDirective::CreateEmpty(const ASTContext &C,
912 unsigned NumClauses,
913 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000914 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000915 llvm::alignTo(sizeof(OMPTeamsDirective), alignof(OMPClause *));
James Y Knightb8bfd962015-10-02 13:41:04 +0000916 void *Mem =
917 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
918 return new (Mem) OMPTeamsDirective(NumClauses);
919}
Alexey Bataev49f6e782015-12-01 04:18:41 +0000920
921OMPTaskLoopDirective *OMPTaskLoopDirective::Create(
922 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
923 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
924 const HelperExprs &Exprs) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000925 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000926 llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
Alexey Bataev49f6e782015-12-01 04:18:41 +0000927 void *Mem =
928 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
929 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
930 OMPTaskLoopDirective *Dir = new (Mem)
931 OMPTaskLoopDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
932 Dir->setClauses(Clauses);
933 Dir->setAssociatedStmt(AssociatedStmt);
934 Dir->setIterationVariable(Exprs.IterationVarRef);
935 Dir->setLastIteration(Exprs.LastIteration);
936 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
937 Dir->setPreCond(Exprs.PreCond);
938 Dir->setCond(Exprs.Cond);
939 Dir->setInit(Exprs.Init);
940 Dir->setInc(Exprs.Inc);
941 Dir->setIsLastIterVariable(Exprs.IL);
942 Dir->setLowerBoundVariable(Exprs.LB);
943 Dir->setUpperBoundVariable(Exprs.UB);
944 Dir->setStrideVariable(Exprs.ST);
945 Dir->setEnsureUpperBound(Exprs.EUB);
946 Dir->setNextLowerBound(Exprs.NLB);
947 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +0000948 Dir->setNumIterations(Exprs.NumIterations);
Alexey Bataev49f6e782015-12-01 04:18:41 +0000949 Dir->setCounters(Exprs.Counters);
950 Dir->setPrivateCounters(Exprs.PrivateCounters);
951 Dir->setInits(Exprs.Inits);
952 Dir->setUpdates(Exprs.Updates);
953 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +0000954 Dir->setDependentCounters(Exprs.DependentCounters);
955 Dir->setDependentInits(Exprs.DependentInits);
956 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +0000957 Dir->setPreInits(Exprs.PreInits);
Alexey Bataev49f6e782015-12-01 04:18:41 +0000958 return Dir;
959}
960
961OMPTaskLoopDirective *OMPTaskLoopDirective::CreateEmpty(const ASTContext &C,
962 unsigned NumClauses,
963 unsigned CollapsedNum,
964 EmptyShell) {
Rui Ueyama83aa9792016-01-14 21:00:27 +0000965 unsigned Size =
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000966 llvm::alignTo(sizeof(OMPTaskLoopDirective), alignof(OMPClause *));
Alexey Bataev49f6e782015-12-01 04:18:41 +0000967 void *Mem =
968 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
969 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_taskloop));
970 return new (Mem) OMPTaskLoopDirective(CollapsedNum, NumClauses);
971}
972
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000973OMPTaskLoopSimdDirective *OMPTaskLoopSimdDirective::Create(
974 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
975 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
976 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +0000977 unsigned Size =
978 llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
Alexey Bataev0a6ed842015-12-03 09:40:15 +0000979 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
980 sizeof(Stmt *) *
981 numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
982 OMPTaskLoopSimdDirective *Dir = new (Mem)
983 OMPTaskLoopSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
984 Dir->setClauses(Clauses);
985 Dir->setAssociatedStmt(AssociatedStmt);
986 Dir->setIterationVariable(Exprs.IterationVarRef);
987 Dir->setLastIteration(Exprs.LastIteration);
988 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
989 Dir->setPreCond(Exprs.PreCond);
990 Dir->setCond(Exprs.Cond);
991 Dir->setInit(Exprs.Init);
992 Dir->setInc(Exprs.Inc);
993 Dir->setIsLastIterVariable(Exprs.IL);
994 Dir->setLowerBoundVariable(Exprs.LB);
995 Dir->setUpperBoundVariable(Exprs.UB);
996 Dir->setStrideVariable(Exprs.ST);
997 Dir->setEnsureUpperBound(Exprs.EUB);
998 Dir->setNextLowerBound(Exprs.NLB);
999 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +00001000 Dir->setNumIterations(Exprs.NumIterations);
Alexey Bataev0a6ed842015-12-03 09:40:15 +00001001 Dir->setCounters(Exprs.Counters);
1002 Dir->setPrivateCounters(Exprs.PrivateCounters);
1003 Dir->setInits(Exprs.Inits);
1004 Dir->setUpdates(Exprs.Updates);
1005 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001006 Dir->setDependentCounters(Exprs.DependentCounters);
1007 Dir->setDependentInits(Exprs.DependentInits);
1008 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +00001009 Dir->setPreInits(Exprs.PreInits);
Alexey Bataev0a6ed842015-12-03 09:40:15 +00001010 return Dir;
1011}
1012
1013OMPTaskLoopSimdDirective *
1014OMPTaskLoopSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1015 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001016 unsigned Size =
1017 llvm::alignTo(sizeof(OMPTaskLoopSimdDirective), alignof(OMPClause *));
Alexey Bataev0a6ed842015-12-03 09:40:15 +00001018 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1019 sizeof(Stmt *) *
1020 numLoopChildren(CollapsedNum, OMPD_taskloop_simd));
1021 return new (Mem) OMPTaskLoopSimdDirective(CollapsedNum, NumClauses);
1022}
1023
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001024OMPDistributeDirective *OMPDistributeDirective::Create(
1025 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1026 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1027 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001028 unsigned Size =
1029 llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001030 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1031 sizeof(Stmt *) *
1032 numLoopChildren(CollapsedNum, OMPD_distribute));
1033 OMPDistributeDirective *Dir = new (Mem)
1034 OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1035 Dir->setClauses(Clauses);
1036 Dir->setAssociatedStmt(AssociatedStmt);
1037 Dir->setIterationVariable(Exprs.IterationVarRef);
1038 Dir->setLastIteration(Exprs.LastIteration);
1039 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1040 Dir->setPreCond(Exprs.PreCond);
1041 Dir->setCond(Exprs.Cond);
1042 Dir->setInit(Exprs.Init);
1043 Dir->setInc(Exprs.Inc);
1044 Dir->setIsLastIterVariable(Exprs.IL);
1045 Dir->setLowerBoundVariable(Exprs.LB);
1046 Dir->setUpperBoundVariable(Exprs.UB);
1047 Dir->setStrideVariable(Exprs.ST);
1048 Dir->setEnsureUpperBound(Exprs.EUB);
1049 Dir->setNextLowerBound(Exprs.NLB);
1050 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +00001051 Dir->setNumIterations(Exprs.NumIterations);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001052 Dir->setCounters(Exprs.Counters);
1053 Dir->setPrivateCounters(Exprs.PrivateCounters);
1054 Dir->setInits(Exprs.Inits);
1055 Dir->setUpdates(Exprs.Updates);
1056 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001057 Dir->setDependentCounters(Exprs.DependentCounters);
1058 Dir->setDependentInits(Exprs.DependentInits);
1059 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +00001060 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001061 return Dir;
1062}
1063
1064OMPDistributeDirective *
1065OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1066 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001067 unsigned Size =
1068 llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001069 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1070 sizeof(Stmt *) *
1071 numLoopChildren(CollapsedNum, OMPD_distribute));
1072 return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1073}
Samuel Antao686c70c2016-05-26 17:30:50 +00001074
Alexey Bataev7828b252017-11-21 17:08:48 +00001075OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1076 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1077 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001078 unsigned Size =
1079 llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
Alexey Bataev7828b252017-11-21 17:08:48 +00001080 void *Mem =
1081 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
Samuel Antao686c70c2016-05-26 17:30:50 +00001082 OMPTargetUpdateDirective *Dir =
1083 new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1084 Dir->setClauses(Clauses);
Alexey Bataev7828b252017-11-21 17:08:48 +00001085 Dir->setAssociatedStmt(AssociatedStmt);
Samuel Antao686c70c2016-05-26 17:30:50 +00001086 return Dir;
1087}
1088
1089OMPTargetUpdateDirective *
1090OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1091 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001092 unsigned Size =
1093 llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
Alexey Bataev7828b252017-11-21 17:08:48 +00001094 void *Mem =
1095 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
Samuel Antao686c70c2016-05-26 17:30:50 +00001096 return new (Mem) OMPTargetUpdateDirective(NumClauses);
1097}
Carlo Bertolli9925f152016-06-27 14:55:37 +00001098
1099OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1100 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1101 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001102 const HelperExprs &Exprs, bool HasCancel) {
Carlo Bertolli9925f152016-06-27 14:55:37 +00001103 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001104 alignof(OMPClause *));
Carlo Bertolli9925f152016-06-27 14:55:37 +00001105 void *Mem = C.Allocate(
1106 Size + sizeof(OMPClause *) * Clauses.size() +
1107 sizeof(Stmt *) *
1108 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1109 OMPDistributeParallelForDirective *Dir =
1110 new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
1111 CollapsedNum, Clauses.size());
1112 Dir->setClauses(Clauses);
1113 Dir->setAssociatedStmt(AssociatedStmt);
1114 Dir->setIterationVariable(Exprs.IterationVarRef);
1115 Dir->setLastIteration(Exprs.LastIteration);
1116 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1117 Dir->setPreCond(Exprs.PreCond);
1118 Dir->setCond(Exprs.Cond);
1119 Dir->setInit(Exprs.Init);
1120 Dir->setInc(Exprs.Inc);
1121 Dir->setIsLastIterVariable(Exprs.IL);
1122 Dir->setLowerBoundVariable(Exprs.LB);
1123 Dir->setUpperBoundVariable(Exprs.UB);
1124 Dir->setStrideVariable(Exprs.ST);
1125 Dir->setEnsureUpperBound(Exprs.EUB);
1126 Dir->setNextLowerBound(Exprs.NLB);
1127 Dir->setNextUpperBound(Exprs.NUB);
1128 Dir->setNumIterations(Exprs.NumIterations);
1129 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1130 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001131 Dir->setDistInc(Exprs.DistInc);
1132 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Carlo Bertolli9925f152016-06-27 14:55:37 +00001133 Dir->setCounters(Exprs.Counters);
1134 Dir->setPrivateCounters(Exprs.PrivateCounters);
1135 Dir->setInits(Exprs.Inits);
1136 Dir->setUpdates(Exprs.Updates);
1137 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001138 Dir->setDependentCounters(Exprs.DependentCounters);
1139 Dir->setDependentInits(Exprs.DependentInits);
1140 Dir->setFinalsConditions(Exprs.FinalsConditions);
Carlo Bertolli9925f152016-06-27 14:55:37 +00001141 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001142 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1143 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1144 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1145 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1146 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1147 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1148 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001149 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1150 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001151 Dir->HasCancel = HasCancel;
Carlo Bertolli9925f152016-06-27 14:55:37 +00001152 return Dir;
1153}
1154
1155OMPDistributeParallelForDirective *
1156OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1157 unsigned NumClauses,
1158 unsigned CollapsedNum,
1159 EmptyShell) {
1160 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001161 alignof(OMPClause *));
Carlo Bertolli9925f152016-06-27 14:55:37 +00001162 void *Mem = C.Allocate(
1163 Size + sizeof(OMPClause *) * NumClauses +
1164 sizeof(Stmt *) *
1165 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1166 return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
1167}
Kelvin Li4a39add2016-07-05 05:00:15 +00001168
1169OMPDistributeParallelForSimdDirective *
1170OMPDistributeParallelForSimdDirective::Create(
1171 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1172 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1173 const HelperExprs &Exprs) {
1174 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001175 alignof(OMPClause *));
Kelvin Li4a39add2016-07-05 05:00:15 +00001176 void *Mem = C.Allocate(
1177 Size + sizeof(OMPClause *) * Clauses.size() +
1178 sizeof(Stmt *) *
1179 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1180 OMPDistributeParallelForSimdDirective *Dir = new (Mem)
1181 OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1182 Clauses.size());
1183 Dir->setClauses(Clauses);
1184 Dir->setAssociatedStmt(AssociatedStmt);
1185 Dir->setIterationVariable(Exprs.IterationVarRef);
1186 Dir->setLastIteration(Exprs.LastIteration);
1187 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1188 Dir->setPreCond(Exprs.PreCond);
1189 Dir->setCond(Exprs.Cond);
1190 Dir->setInit(Exprs.Init);
1191 Dir->setInc(Exprs.Inc);
1192 Dir->setIsLastIterVariable(Exprs.IL);
1193 Dir->setLowerBoundVariable(Exprs.LB);
1194 Dir->setUpperBoundVariable(Exprs.UB);
1195 Dir->setStrideVariable(Exprs.ST);
1196 Dir->setEnsureUpperBound(Exprs.EUB);
1197 Dir->setNextLowerBound(Exprs.NLB);
1198 Dir->setNextUpperBound(Exprs.NUB);
1199 Dir->setNumIterations(Exprs.NumIterations);
1200 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1201 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001202 Dir->setDistInc(Exprs.DistInc);
1203 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li4a39add2016-07-05 05:00:15 +00001204 Dir->setCounters(Exprs.Counters);
1205 Dir->setPrivateCounters(Exprs.PrivateCounters);
1206 Dir->setInits(Exprs.Inits);
1207 Dir->setUpdates(Exprs.Updates);
1208 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001209 Dir->setDependentCounters(Exprs.DependentCounters);
1210 Dir->setDependentInits(Exprs.DependentInits);
1211 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li4a39add2016-07-05 05:00:15 +00001212 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001213 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1214 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1215 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1216 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1217 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1218 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1219 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001220 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1221 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li4a39add2016-07-05 05:00:15 +00001222 return Dir;
1223}
1224
1225OMPDistributeParallelForSimdDirective *
1226OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1227 unsigned NumClauses,
1228 unsigned CollapsedNum,
1229 EmptyShell) {
1230 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001231 alignof(OMPClause *));
Kelvin Li4a39add2016-07-05 05:00:15 +00001232 void *Mem = C.Allocate(
1233 Size + sizeof(OMPClause *) * NumClauses +
1234 sizeof(Stmt *) *
1235 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1236 return new (Mem)
1237 OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1238}
Kelvin Li787f3fc2016-07-06 04:45:38 +00001239
1240OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1241 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1242 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1243 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001244 unsigned Size =
1245 llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
Kelvin Li787f3fc2016-07-06 04:45:38 +00001246 void *Mem = C.Allocate(
1247 Size + sizeof(OMPClause *) * Clauses.size() +
1248 sizeof(Stmt *) *
1249 numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1250 OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
1251 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1252 Dir->setClauses(Clauses);
1253 Dir->setAssociatedStmt(AssociatedStmt);
1254 Dir->setIterationVariable(Exprs.IterationVarRef);
1255 Dir->setLastIteration(Exprs.LastIteration);
1256 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1257 Dir->setPreCond(Exprs.PreCond);
1258 Dir->setCond(Exprs.Cond);
1259 Dir->setInit(Exprs.Init);
1260 Dir->setInc(Exprs.Inc);
1261 Dir->setIsLastIterVariable(Exprs.IL);
1262 Dir->setLowerBoundVariable(Exprs.LB);
1263 Dir->setUpperBoundVariable(Exprs.UB);
1264 Dir->setStrideVariable(Exprs.ST);
1265 Dir->setEnsureUpperBound(Exprs.EUB);
1266 Dir->setNextLowerBound(Exprs.NLB);
1267 Dir->setNextUpperBound(Exprs.NUB);
1268 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li787f3fc2016-07-06 04:45:38 +00001269 Dir->setCounters(Exprs.Counters);
1270 Dir->setPrivateCounters(Exprs.PrivateCounters);
1271 Dir->setInits(Exprs.Inits);
1272 Dir->setUpdates(Exprs.Updates);
1273 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001274 Dir->setDependentCounters(Exprs.DependentCounters);
1275 Dir->setDependentInits(Exprs.DependentInits);
1276 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li787f3fc2016-07-06 04:45:38 +00001277 Dir->setPreInits(Exprs.PreInits);
1278 return Dir;
1279}
1280
1281OMPDistributeSimdDirective *
1282OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1283 unsigned NumClauses,
1284 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001285 unsigned Size =
1286 llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
Kelvin Li787f3fc2016-07-06 04:45:38 +00001287 void *Mem = C.Allocate(
1288 Size + sizeof(OMPClause *) * NumClauses +
1289 sizeof(Stmt *) *
1290 numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1291 return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
1292}
Kelvin Lia579b912016-07-14 02:54:56 +00001293
1294OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1295 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1296 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1297 const HelperExprs &Exprs) {
1298 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001299 alignof(OMPClause *));
Kelvin Lia579b912016-07-14 02:54:56 +00001300 void *Mem = C.Allocate(
1301 Size + sizeof(OMPClause *) * Clauses.size() +
Fangrui Song6907ce22018-07-30 19:24:48 +00001302 sizeof(Stmt *) *
Kelvin Lia579b912016-07-14 02:54:56 +00001303 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
Fangrui Song6907ce22018-07-30 19:24:48 +00001304 OMPTargetParallelForSimdDirective *Dir =
Kelvin Lia579b912016-07-14 02:54:56 +00001305 new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
1306 CollapsedNum, Clauses.size());
1307 Dir->setClauses(Clauses);
1308 Dir->setAssociatedStmt(AssociatedStmt);
1309 Dir->setIterationVariable(Exprs.IterationVarRef);
1310 Dir->setLastIteration(Exprs.LastIteration);
1311 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1312 Dir->setPreCond(Exprs.PreCond);
1313 Dir->setCond(Exprs.Cond);
1314 Dir->setInit(Exprs.Init);
1315 Dir->setInc(Exprs.Inc);
1316 Dir->setIsLastIterVariable(Exprs.IL);
1317 Dir->setLowerBoundVariable(Exprs.LB);
1318 Dir->setUpperBoundVariable(Exprs.UB);
1319 Dir->setStrideVariable(Exprs.ST);
1320 Dir->setEnsureUpperBound(Exprs.EUB);
1321 Dir->setNextLowerBound(Exprs.NLB);
1322 Dir->setNextUpperBound(Exprs.NUB);
1323 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Lia579b912016-07-14 02:54:56 +00001324 Dir->setCounters(Exprs.Counters);
1325 Dir->setPrivateCounters(Exprs.PrivateCounters);
1326 Dir->setInits(Exprs.Inits);
1327 Dir->setUpdates(Exprs.Updates);
1328 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001329 Dir->setDependentCounters(Exprs.DependentCounters);
1330 Dir->setDependentInits(Exprs.DependentInits);
1331 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Lia579b912016-07-14 02:54:56 +00001332 Dir->setPreInits(Exprs.PreInits);
1333 return Dir;
1334}
1335
1336OMPTargetParallelForSimdDirective *
1337OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1338 unsigned NumClauses,
1339 unsigned CollapsedNum,
1340 EmptyShell) {
1341 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001342 alignof(OMPClause *));
Kelvin Lia579b912016-07-14 02:54:56 +00001343 void *Mem = C.Allocate(
1344 Size + sizeof(OMPClause *) * NumClauses +
Fangrui Song6907ce22018-07-30 19:24:48 +00001345 sizeof(Stmt *) *
Kelvin Lia579b912016-07-14 02:54:56 +00001346 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1347 return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
1348}
Kelvin Li986330c2016-07-20 22:57:10 +00001349
1350OMPTargetSimdDirective *
Fangrui Song6907ce22018-07-30 19:24:48 +00001351OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
Kelvin Li986330c2016-07-20 22:57:10 +00001352 SourceLocation EndLoc, unsigned CollapsedNum,
1353 ArrayRef<OMPClause *> Clauses,
1354 Stmt *AssociatedStmt, const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001355 unsigned Size =
1356 llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
Kelvin Li986330c2016-07-20 22:57:10 +00001357 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
Fangrui Song6907ce22018-07-30 19:24:48 +00001358 sizeof(Stmt *) *
Kelvin Li986330c2016-07-20 22:57:10 +00001359 numLoopChildren(CollapsedNum, OMPD_target_simd));
1360 OMPTargetSimdDirective *Dir = new (Mem)
1361 OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1362 Dir->setClauses(Clauses);
1363 Dir->setAssociatedStmt(AssociatedStmt);
1364 Dir->setIterationVariable(Exprs.IterationVarRef);
1365 Dir->setLastIteration(Exprs.LastIteration);
1366 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1367 Dir->setPreCond(Exprs.PreCond);
1368 Dir->setCond(Exprs.Cond);
1369 Dir->setInit(Exprs.Init);
1370 Dir->setInc(Exprs.Inc);
1371 Dir->setCounters(Exprs.Counters);
1372 Dir->setPrivateCounters(Exprs.PrivateCounters);
1373 Dir->setInits(Exprs.Inits);
1374 Dir->setUpdates(Exprs.Updates);
1375 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001376 Dir->setDependentCounters(Exprs.DependentCounters);
1377 Dir->setDependentInits(Exprs.DependentInits);
1378 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li986330c2016-07-20 22:57:10 +00001379 Dir->setPreInits(Exprs.PreInits);
1380 return Dir;
1381}
1382
1383OMPTargetSimdDirective *
1384OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1385 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001386 unsigned Size =
1387 llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
Kelvin Li986330c2016-07-20 22:57:10 +00001388 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
Fangrui Song6907ce22018-07-30 19:24:48 +00001389 sizeof(Stmt *) *
Kelvin Li986330c2016-07-20 22:57:10 +00001390 numLoopChildren(CollapsedNum, OMPD_target_simd));
1391 return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
1392}
Kelvin Li02532872016-08-05 14:37:37 +00001393
1394OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1395 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1396 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1397 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001398 unsigned Size =
1399 llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
Kelvin Li02532872016-08-05 14:37:37 +00001400 void *Mem = C.Allocate(
1401 Size + sizeof(OMPClause *) * Clauses.size() +
1402 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1403 OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
1404 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1405 Dir->setClauses(Clauses);
1406 Dir->setAssociatedStmt(AssociatedStmt);
1407 Dir->setIterationVariable(Exprs.IterationVarRef);
1408 Dir->setLastIteration(Exprs.LastIteration);
1409 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1410 Dir->setPreCond(Exprs.PreCond);
1411 Dir->setCond(Exprs.Cond);
1412 Dir->setInit(Exprs.Init);
1413 Dir->setInc(Exprs.Inc);
1414 Dir->setIsLastIterVariable(Exprs.IL);
1415 Dir->setLowerBoundVariable(Exprs.LB);
1416 Dir->setUpperBoundVariable(Exprs.UB);
1417 Dir->setStrideVariable(Exprs.ST);
1418 Dir->setEnsureUpperBound(Exprs.EUB);
1419 Dir->setNextLowerBound(Exprs.NLB);
1420 Dir->setNextUpperBound(Exprs.NUB);
1421 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li02532872016-08-05 14:37:37 +00001422 Dir->setCounters(Exprs.Counters);
1423 Dir->setPrivateCounters(Exprs.PrivateCounters);
1424 Dir->setInits(Exprs.Inits);
1425 Dir->setUpdates(Exprs.Updates);
1426 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001427 Dir->setDependentCounters(Exprs.DependentCounters);
1428 Dir->setDependentInits(Exprs.DependentInits);
1429 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li02532872016-08-05 14:37:37 +00001430 Dir->setPreInits(Exprs.PreInits);
1431 return Dir;
1432}
1433
1434OMPTeamsDistributeDirective *
1435OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1436 unsigned NumClauses,
1437 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001438 unsigned Size =
1439 llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
Kelvin Li02532872016-08-05 14:37:37 +00001440 void *Mem = C.Allocate(
1441 Size + sizeof(OMPClause *) * NumClauses +
1442 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1443 return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
1444}
Kelvin Li4e325f72016-10-25 12:50:55 +00001445
1446OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1447 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1448 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1449 const HelperExprs &Exprs) {
1450 unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1451 alignof(OMPClause *));
1452 void *Mem =
1453 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1454 sizeof(Stmt *) *
1455 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1456 OMPTeamsDistributeSimdDirective *Dir =
1457 new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1458 Clauses.size());
1459 Dir->setClauses(Clauses);
1460 Dir->setAssociatedStmt(AssociatedStmt);
1461 Dir->setIterationVariable(Exprs.IterationVarRef);
1462 Dir->setLastIteration(Exprs.LastIteration);
1463 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1464 Dir->setPreCond(Exprs.PreCond);
1465 Dir->setCond(Exprs.Cond);
1466 Dir->setInit(Exprs.Init);
1467 Dir->setInc(Exprs.Inc);
1468 Dir->setIsLastIterVariable(Exprs.IL);
1469 Dir->setLowerBoundVariable(Exprs.LB);
1470 Dir->setUpperBoundVariable(Exprs.UB);
1471 Dir->setStrideVariable(Exprs.ST);
1472 Dir->setEnsureUpperBound(Exprs.EUB);
1473 Dir->setNextLowerBound(Exprs.NLB);
1474 Dir->setNextUpperBound(Exprs.NUB);
1475 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li4e325f72016-10-25 12:50:55 +00001476 Dir->setCounters(Exprs.Counters);
1477 Dir->setPrivateCounters(Exprs.PrivateCounters);
1478 Dir->setInits(Exprs.Inits);
1479 Dir->setUpdates(Exprs.Updates);
1480 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001481 Dir->setDependentCounters(Exprs.DependentCounters);
1482 Dir->setDependentInits(Exprs.DependentInits);
1483 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li4e325f72016-10-25 12:50:55 +00001484 Dir->setPreInits(Exprs.PreInits);
1485 return Dir;
1486}
1487
1488OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1489 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1490 EmptyShell) {
1491 unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1492 alignof(OMPClause *));
1493 void *Mem =
1494 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1495 sizeof(Stmt *) *
1496 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1497 return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1498}
Kelvin Li579e41c2016-11-30 23:51:03 +00001499
1500OMPTeamsDistributeParallelForSimdDirective *
1501OMPTeamsDistributeParallelForSimdDirective::Create(
1502 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1503 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1504 const HelperExprs &Exprs) {
1505 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1506 alignof(OMPClause *));
1507 void *Mem =
1508 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1509 sizeof(Stmt *) *
1510 numLoopChildren(CollapsedNum,
1511 OMPD_teams_distribute_parallel_for_simd));
1512 OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
1513 OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1514 Clauses.size());
1515 Dir->setClauses(Clauses);
1516 Dir->setAssociatedStmt(AssociatedStmt);
1517 Dir->setIterationVariable(Exprs.IterationVarRef);
1518 Dir->setLastIteration(Exprs.LastIteration);
1519 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1520 Dir->setPreCond(Exprs.PreCond);
1521 Dir->setCond(Exprs.Cond);
1522 Dir->setInit(Exprs.Init);
1523 Dir->setInc(Exprs.Inc);
1524 Dir->setIsLastIterVariable(Exprs.IL);
1525 Dir->setLowerBoundVariable(Exprs.LB);
1526 Dir->setUpperBoundVariable(Exprs.UB);
1527 Dir->setStrideVariable(Exprs.ST);
1528 Dir->setEnsureUpperBound(Exprs.EUB);
1529 Dir->setNextLowerBound(Exprs.NLB);
1530 Dir->setNextUpperBound(Exprs.NUB);
1531 Dir->setNumIterations(Exprs.NumIterations);
1532 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1533 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001534 Dir->setDistInc(Exprs.DistInc);
1535 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li579e41c2016-11-30 23:51:03 +00001536 Dir->setCounters(Exprs.Counters);
1537 Dir->setPrivateCounters(Exprs.PrivateCounters);
1538 Dir->setInits(Exprs.Inits);
1539 Dir->setUpdates(Exprs.Updates);
1540 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001541 Dir->setDependentCounters(Exprs.DependentCounters);
1542 Dir->setDependentInits(Exprs.DependentInits);
1543 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li579e41c2016-11-30 23:51:03 +00001544 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001545 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1546 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1547 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1548 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1549 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1550 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1551 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001552 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1553 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li579e41c2016-11-30 23:51:03 +00001554 return Dir;
1555}
1556
1557OMPTeamsDistributeParallelForSimdDirective *
1558OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1559 unsigned NumClauses,
1560 unsigned CollapsedNum,
1561 EmptyShell) {
1562 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1563 alignof(OMPClause *));
1564 void *Mem =
1565 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1566 sizeof(Stmt *) *
1567 numLoopChildren(CollapsedNum,
1568 OMPD_teams_distribute_parallel_for_simd));
1569 return new (Mem)
1570 OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1571}
Kelvin Li7ade93f2016-12-09 03:24:30 +00001572
1573OMPTeamsDistributeParallelForDirective *
1574OMPTeamsDistributeParallelForDirective::Create(
1575 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1576 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001577 const HelperExprs &Exprs, bool HasCancel) {
Kelvin Li7ade93f2016-12-09 03:24:30 +00001578 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1579 alignof(OMPClause *));
1580 void *Mem = C.Allocate(
1581 Size + sizeof(OMPClause *) * Clauses.size() +
1582 sizeof(Stmt *) *
1583 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1584 OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
1585 OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
1586 Clauses.size());
1587 Dir->setClauses(Clauses);
1588 Dir->setAssociatedStmt(AssociatedStmt);
1589 Dir->setIterationVariable(Exprs.IterationVarRef);
1590 Dir->setLastIteration(Exprs.LastIteration);
1591 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1592 Dir->setPreCond(Exprs.PreCond);
1593 Dir->setCond(Exprs.Cond);
1594 Dir->setInit(Exprs.Init);
1595 Dir->setInc(Exprs.Inc);
1596 Dir->setIsLastIterVariable(Exprs.IL);
1597 Dir->setLowerBoundVariable(Exprs.LB);
1598 Dir->setUpperBoundVariable(Exprs.UB);
1599 Dir->setStrideVariable(Exprs.ST);
1600 Dir->setEnsureUpperBound(Exprs.EUB);
1601 Dir->setNextLowerBound(Exprs.NLB);
1602 Dir->setNextUpperBound(Exprs.NUB);
1603 Dir->setNumIterations(Exprs.NumIterations);
1604 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1605 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001606 Dir->setDistInc(Exprs.DistInc);
1607 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li7ade93f2016-12-09 03:24:30 +00001608 Dir->setCounters(Exprs.Counters);
1609 Dir->setPrivateCounters(Exprs.PrivateCounters);
1610 Dir->setInits(Exprs.Inits);
1611 Dir->setUpdates(Exprs.Updates);
1612 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001613 Dir->setDependentCounters(Exprs.DependentCounters);
1614 Dir->setDependentInits(Exprs.DependentInits);
1615 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li7ade93f2016-12-09 03:24:30 +00001616 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001617 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1618 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1619 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1620 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1621 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1622 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1623 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001624 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1625 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001626 Dir->HasCancel = HasCancel;
Kelvin Li7ade93f2016-12-09 03:24:30 +00001627 return Dir;
1628}
1629
1630OMPTeamsDistributeParallelForDirective *
1631OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1632 unsigned NumClauses,
1633 unsigned CollapsedNum,
1634 EmptyShell) {
1635 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1636 alignof(OMPClause *));
1637 void *Mem = C.Allocate(
1638 Size + sizeof(OMPClause *) * NumClauses +
1639 sizeof(Stmt *) *
1640 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1641 return new (Mem)
1642 OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1643}
1644
Kelvin Libf594a52016-12-17 05:48:59 +00001645OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
1646 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1647 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1648 auto Size =
1649 llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1650 void *Mem =
1651 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1652 OMPTargetTeamsDirective *Dir =
1653 new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
1654 Dir->setClauses(Clauses);
1655 Dir->setAssociatedStmt(AssociatedStmt);
1656 return Dir;
1657}
1658
1659OMPTargetTeamsDirective *
1660OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1661 EmptyShell) {
1662 auto Size =
1663 llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1664 void *Mem =
1665 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1666 return new (Mem) OMPTargetTeamsDirective(NumClauses);
1667}
Kelvin Li83c451e2016-12-25 04:52:54 +00001668
1669OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
1670 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1671 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1672 const HelperExprs &Exprs) {
1673 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1674 alignof(OMPClause *));
1675 void *Mem = C.Allocate(
1676 Size + sizeof(OMPClause *) * Clauses.size() +
1677 sizeof(Stmt *) *
1678 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1679 OMPTargetTeamsDistributeDirective *Dir =
1680 new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
1681 Clauses.size());
1682 Dir->setClauses(Clauses);
1683 Dir->setAssociatedStmt(AssociatedStmt);
1684 Dir->setIterationVariable(Exprs.IterationVarRef);
1685 Dir->setLastIteration(Exprs.LastIteration);
1686 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1687 Dir->setPreCond(Exprs.PreCond);
1688 Dir->setCond(Exprs.Cond);
1689 Dir->setInit(Exprs.Init);
1690 Dir->setInc(Exprs.Inc);
1691 Dir->setIsLastIterVariable(Exprs.IL);
1692 Dir->setLowerBoundVariable(Exprs.LB);
1693 Dir->setUpperBoundVariable(Exprs.UB);
1694 Dir->setStrideVariable(Exprs.ST);
1695 Dir->setEnsureUpperBound(Exprs.EUB);
1696 Dir->setNextLowerBound(Exprs.NLB);
1697 Dir->setNextUpperBound(Exprs.NUB);
1698 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li83c451e2016-12-25 04:52:54 +00001699 Dir->setCounters(Exprs.Counters);
1700 Dir->setPrivateCounters(Exprs.PrivateCounters);
1701 Dir->setInits(Exprs.Inits);
1702 Dir->setUpdates(Exprs.Updates);
1703 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001704 Dir->setDependentCounters(Exprs.DependentCounters);
1705 Dir->setDependentInits(Exprs.DependentInits);
1706 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li83c451e2016-12-25 04:52:54 +00001707 Dir->setPreInits(Exprs.PreInits);
1708 return Dir;
1709}
1710
1711OMPTargetTeamsDistributeDirective *
1712OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1713 unsigned NumClauses,
1714 unsigned CollapsedNum,
1715 EmptyShell) {
1716 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1717 alignof(OMPClause *));
1718 void *Mem = C.Allocate(
1719 Size + sizeof(OMPClause *) * NumClauses +
1720 sizeof(Stmt *) *
1721 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1722 return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
1723}
Kelvin Li80e8f562016-12-29 22:16:30 +00001724
1725OMPTargetTeamsDistributeParallelForDirective *
1726OMPTargetTeamsDistributeParallelForDirective::Create(
1727 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1728 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataev16e79882017-11-22 21:12:03 +00001729 const HelperExprs &Exprs, bool HasCancel) {
Kelvin Li80e8f562016-12-29 22:16:30 +00001730 auto Size =
1731 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1732 alignof(OMPClause *));
1733 void *Mem = C.Allocate(
1734 Size + sizeof(OMPClause *) * Clauses.size() +
1735 sizeof(Stmt *) *
1736 numLoopChildren(CollapsedNum,
1737 OMPD_target_teams_distribute_parallel_for));
1738 OMPTargetTeamsDistributeParallelForDirective *Dir =
1739 new (Mem) OMPTargetTeamsDistributeParallelForDirective(
1740 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1741 Dir->setClauses(Clauses);
1742 Dir->setAssociatedStmt(AssociatedStmt);
1743 Dir->setIterationVariable(Exprs.IterationVarRef);
1744 Dir->setLastIteration(Exprs.LastIteration);
1745 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1746 Dir->setPreCond(Exprs.PreCond);
1747 Dir->setCond(Exprs.Cond);
1748 Dir->setInit(Exprs.Init);
1749 Dir->setInc(Exprs.Inc);
1750 Dir->setIsLastIterVariable(Exprs.IL);
1751 Dir->setLowerBoundVariable(Exprs.LB);
1752 Dir->setUpperBoundVariable(Exprs.UB);
1753 Dir->setStrideVariable(Exprs.ST);
1754 Dir->setEnsureUpperBound(Exprs.EUB);
1755 Dir->setNextLowerBound(Exprs.NLB);
1756 Dir->setNextUpperBound(Exprs.NUB);
1757 Dir->setNumIterations(Exprs.NumIterations);
1758 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1759 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001760 Dir->setDistInc(Exprs.DistInc);
1761 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li80e8f562016-12-29 22:16:30 +00001762 Dir->setCounters(Exprs.Counters);
1763 Dir->setPrivateCounters(Exprs.PrivateCounters);
1764 Dir->setInits(Exprs.Inits);
1765 Dir->setUpdates(Exprs.Updates);
1766 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001767 Dir->setDependentCounters(Exprs.DependentCounters);
1768 Dir->setDependentInits(Exprs.DependentInits);
1769 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li80e8f562016-12-29 22:16:30 +00001770 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001771 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1772 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1773 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1774 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1775 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1776 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1777 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001778 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1779 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataev16e79882017-11-22 21:12:03 +00001780 Dir->HasCancel = HasCancel;
Kelvin Li80e8f562016-12-29 22:16:30 +00001781 return Dir;
1782}
1783
1784OMPTargetTeamsDistributeParallelForDirective *
1785OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1786 unsigned NumClauses,
1787 unsigned CollapsedNum,
1788 EmptyShell) {
1789 auto Size =
1790 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1791 alignof(OMPClause *));
1792 void *Mem = C.Allocate(
1793 Size + sizeof(OMPClause *) * NumClauses +
1794 sizeof(Stmt *) *
1795 numLoopChildren(CollapsedNum,
1796 OMPD_target_teams_distribute_parallel_for));
1797 return new (Mem)
1798 OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1799}
Kelvin Li1851df52017-01-03 05:23:48 +00001800
1801OMPTargetTeamsDistributeParallelForSimdDirective *
1802OMPTargetTeamsDistributeParallelForSimdDirective::Create(
1803 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1804 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1805 const HelperExprs &Exprs) {
1806 auto Size =
1807 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
1808 alignof(OMPClause *));
1809 void *Mem = C.Allocate(
1810 Size + sizeof(OMPClause *) * Clauses.size() +
1811 sizeof(Stmt *) *
1812 numLoopChildren(CollapsedNum,
1813 OMPD_target_teams_distribute_parallel_for_simd));
1814 OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
1815 new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
1816 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1817 Dir->setClauses(Clauses);
1818 Dir->setAssociatedStmt(AssociatedStmt);
1819 Dir->setIterationVariable(Exprs.IterationVarRef);
1820 Dir->setLastIteration(Exprs.LastIteration);
1821 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1822 Dir->setPreCond(Exprs.PreCond);
1823 Dir->setCond(Exprs.Cond);
1824 Dir->setInit(Exprs.Init);
1825 Dir->setInc(Exprs.Inc);
1826 Dir->setIsLastIterVariable(Exprs.IL);
1827 Dir->setLowerBoundVariable(Exprs.LB);
1828 Dir->setUpperBoundVariable(Exprs.UB);
1829 Dir->setStrideVariable(Exprs.ST);
1830 Dir->setEnsureUpperBound(Exprs.EUB);
1831 Dir->setNextLowerBound(Exprs.NLB);
1832 Dir->setNextUpperBound(Exprs.NUB);
1833 Dir->setNumIterations(Exprs.NumIterations);
1834 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1835 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001836 Dir->setDistInc(Exprs.DistInc);
1837 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li1851df52017-01-03 05:23:48 +00001838 Dir->setCounters(Exprs.Counters);
1839 Dir->setPrivateCounters(Exprs.PrivateCounters);
1840 Dir->setInits(Exprs.Inits);
1841 Dir->setUpdates(Exprs.Updates);
1842 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001843 Dir->setDependentCounters(Exprs.DependentCounters);
1844 Dir->setDependentInits(Exprs.DependentInits);
1845 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li1851df52017-01-03 05:23:48 +00001846 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001847 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1848 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1849 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1850 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1851 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1852 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1853 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001854 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1855 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li1851df52017-01-03 05:23:48 +00001856 return Dir;
1857}
1858
1859OMPTargetTeamsDistributeParallelForSimdDirective *
1860OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
1861 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1862 EmptyShell) {
1863 auto Size =
1864 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
1865 alignof(OMPClause *));
1866 void *Mem = C.Allocate(
1867 Size + sizeof(OMPClause *) * NumClauses +
1868 sizeof(Stmt *) *
1869 numLoopChildren(CollapsedNum,
1870 OMPD_target_teams_distribute_parallel_for_simd));
1871 return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
1872 CollapsedNum, NumClauses);
1873}
1874
Kelvin Lida681182017-01-10 18:08:18 +00001875OMPTargetTeamsDistributeSimdDirective *
1876OMPTargetTeamsDistributeSimdDirective::Create(
1877 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1878 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1879 const HelperExprs &Exprs) {
1880 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
1881 alignof(OMPClause *));
1882 void *Mem = C.Allocate(
1883 Size + sizeof(OMPClause *) * Clauses.size() +
1884 sizeof(Stmt *) *
1885 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
1886 OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
1887 OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1888 Clauses.size());
1889 Dir->setClauses(Clauses);
1890 Dir->setAssociatedStmt(AssociatedStmt);
1891 Dir->setIterationVariable(Exprs.IterationVarRef);
1892 Dir->setLastIteration(Exprs.LastIteration);
1893 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1894 Dir->setPreCond(Exprs.PreCond);
1895 Dir->setCond(Exprs.Cond);
1896 Dir->setInit(Exprs.Init);
1897 Dir->setInc(Exprs.Inc);
1898 Dir->setIsLastIterVariable(Exprs.IL);
1899 Dir->setLowerBoundVariable(Exprs.LB);
1900 Dir->setUpperBoundVariable(Exprs.UB);
1901 Dir->setStrideVariable(Exprs.ST);
1902 Dir->setEnsureUpperBound(Exprs.EUB);
1903 Dir->setNextLowerBound(Exprs.NLB);
1904 Dir->setNextUpperBound(Exprs.NUB);
1905 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Lida681182017-01-10 18:08:18 +00001906 Dir->setCounters(Exprs.Counters);
1907 Dir->setPrivateCounters(Exprs.PrivateCounters);
1908 Dir->setInits(Exprs.Inits);
1909 Dir->setUpdates(Exprs.Updates);
1910 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001911 Dir->setDependentCounters(Exprs.DependentCounters);
1912 Dir->setDependentInits(Exprs.DependentInits);
1913 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Lida681182017-01-10 18:08:18 +00001914 Dir->setPreInits(Exprs.PreInits);
1915 return Dir;
1916}
1917
1918OMPTargetTeamsDistributeSimdDirective *
1919OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1920 unsigned NumClauses,
1921 unsigned CollapsedNum,
1922 EmptyShell) {
1923 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
1924 alignof(OMPClause *));
1925 void *Mem = C.Allocate(
1926 Size + sizeof(OMPClause *) * NumClauses +
1927 sizeof(Stmt *) *
1928 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
1929 return new (Mem)
1930 OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1931}