blob: a61510bc545d66b9bf3830fe50f58149a3684319 [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
Alexey Bataev60e51c42019-10-10 20:13:02 +00001024OMPMasterTaskLoopDirective *OMPMasterTaskLoopDirective::Create(
1025 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1026 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1027 const HelperExprs &Exprs) {
1028 unsigned Size =
1029 llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
1030 void *Mem = C.Allocate(
1031 Size + sizeof(OMPClause *) * Clauses.size() +
1032 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
1033 OMPMasterTaskLoopDirective *Dir = new (Mem) OMPMasterTaskLoopDirective(
1034 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);
1051 Dir->setNumIterations(Exprs.NumIterations);
1052 Dir->setCounters(Exprs.Counters);
1053 Dir->setPrivateCounters(Exprs.PrivateCounters);
1054 Dir->setInits(Exprs.Inits);
1055 Dir->setUpdates(Exprs.Updates);
1056 Dir->setFinals(Exprs.Finals);
1057 Dir->setDependentCounters(Exprs.DependentCounters);
1058 Dir->setDependentInits(Exprs.DependentInits);
1059 Dir->setFinalsConditions(Exprs.FinalsConditions);
1060 Dir->setPreInits(Exprs.PreInits);
1061 return Dir;
1062}
1063
1064OMPMasterTaskLoopDirective *
1065OMPMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1066 unsigned NumClauses,
1067 unsigned CollapsedNum, EmptyShell) {
1068 unsigned Size =
1069 llvm::alignTo(sizeof(OMPMasterTaskLoopDirective), alignof(OMPClause *));
1070 void *Mem = C.Allocate(
1071 Size + sizeof(OMPClause *) * NumClauses +
1072 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_master_taskloop));
1073 return new (Mem) OMPMasterTaskLoopDirective(CollapsedNum, NumClauses);
1074}
1075
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001076OMPDistributeDirective *OMPDistributeDirective::Create(
1077 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1078 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1079 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001080 unsigned Size =
1081 llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001082 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1083 sizeof(Stmt *) *
1084 numLoopChildren(CollapsedNum, OMPD_distribute));
1085 OMPDistributeDirective *Dir = new (Mem)
1086 OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1087 Dir->setClauses(Clauses);
1088 Dir->setAssociatedStmt(AssociatedStmt);
1089 Dir->setIterationVariable(Exprs.IterationVarRef);
1090 Dir->setLastIteration(Exprs.LastIteration);
1091 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1092 Dir->setPreCond(Exprs.PreCond);
1093 Dir->setCond(Exprs.Cond);
1094 Dir->setInit(Exprs.Init);
1095 Dir->setInc(Exprs.Inc);
1096 Dir->setIsLastIterVariable(Exprs.IL);
1097 Dir->setLowerBoundVariable(Exprs.LB);
1098 Dir->setUpperBoundVariable(Exprs.UB);
1099 Dir->setStrideVariable(Exprs.ST);
1100 Dir->setEnsureUpperBound(Exprs.EUB);
1101 Dir->setNextLowerBound(Exprs.NLB);
1102 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +00001103 Dir->setNumIterations(Exprs.NumIterations);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001104 Dir->setCounters(Exprs.Counters);
1105 Dir->setPrivateCounters(Exprs.PrivateCounters);
1106 Dir->setInits(Exprs.Inits);
1107 Dir->setUpdates(Exprs.Updates);
1108 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001109 Dir->setDependentCounters(Exprs.DependentCounters);
1110 Dir->setDependentInits(Exprs.DependentInits);
1111 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +00001112 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001113 return Dir;
1114}
1115
1116OMPDistributeDirective *
1117OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1118 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001119 unsigned Size =
1120 llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001121 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1122 sizeof(Stmt *) *
1123 numLoopChildren(CollapsedNum, OMPD_distribute));
1124 return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1125}
Samuel Antao686c70c2016-05-26 17:30:50 +00001126
Alexey Bataev7828b252017-11-21 17:08:48 +00001127OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1128 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1129 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001130 unsigned Size =
1131 llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
Alexey Bataev7828b252017-11-21 17:08:48 +00001132 void *Mem =
1133 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
Samuel Antao686c70c2016-05-26 17:30:50 +00001134 OMPTargetUpdateDirective *Dir =
1135 new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1136 Dir->setClauses(Clauses);
Alexey Bataev7828b252017-11-21 17:08:48 +00001137 Dir->setAssociatedStmt(AssociatedStmt);
Samuel Antao686c70c2016-05-26 17:30:50 +00001138 return Dir;
1139}
1140
1141OMPTargetUpdateDirective *
1142OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1143 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001144 unsigned Size =
1145 llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
Alexey Bataev7828b252017-11-21 17:08:48 +00001146 void *Mem =
1147 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
Samuel Antao686c70c2016-05-26 17:30:50 +00001148 return new (Mem) OMPTargetUpdateDirective(NumClauses);
1149}
Carlo Bertolli9925f152016-06-27 14:55:37 +00001150
1151OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1152 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1153 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001154 const HelperExprs &Exprs, bool HasCancel) {
Carlo Bertolli9925f152016-06-27 14:55:37 +00001155 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001156 alignof(OMPClause *));
Carlo Bertolli9925f152016-06-27 14:55:37 +00001157 void *Mem = C.Allocate(
1158 Size + sizeof(OMPClause *) * Clauses.size() +
1159 sizeof(Stmt *) *
1160 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1161 OMPDistributeParallelForDirective *Dir =
1162 new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
1163 CollapsedNum, Clauses.size());
1164 Dir->setClauses(Clauses);
1165 Dir->setAssociatedStmt(AssociatedStmt);
1166 Dir->setIterationVariable(Exprs.IterationVarRef);
1167 Dir->setLastIteration(Exprs.LastIteration);
1168 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1169 Dir->setPreCond(Exprs.PreCond);
1170 Dir->setCond(Exprs.Cond);
1171 Dir->setInit(Exprs.Init);
1172 Dir->setInc(Exprs.Inc);
1173 Dir->setIsLastIterVariable(Exprs.IL);
1174 Dir->setLowerBoundVariable(Exprs.LB);
1175 Dir->setUpperBoundVariable(Exprs.UB);
1176 Dir->setStrideVariable(Exprs.ST);
1177 Dir->setEnsureUpperBound(Exprs.EUB);
1178 Dir->setNextLowerBound(Exprs.NLB);
1179 Dir->setNextUpperBound(Exprs.NUB);
1180 Dir->setNumIterations(Exprs.NumIterations);
1181 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1182 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001183 Dir->setDistInc(Exprs.DistInc);
1184 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Carlo Bertolli9925f152016-06-27 14:55:37 +00001185 Dir->setCounters(Exprs.Counters);
1186 Dir->setPrivateCounters(Exprs.PrivateCounters);
1187 Dir->setInits(Exprs.Inits);
1188 Dir->setUpdates(Exprs.Updates);
1189 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001190 Dir->setDependentCounters(Exprs.DependentCounters);
1191 Dir->setDependentInits(Exprs.DependentInits);
1192 Dir->setFinalsConditions(Exprs.FinalsConditions);
Carlo Bertolli9925f152016-06-27 14:55:37 +00001193 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001194 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1195 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1196 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1197 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1198 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1199 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1200 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001201 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1202 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001203 Dir->HasCancel = HasCancel;
Carlo Bertolli9925f152016-06-27 14:55:37 +00001204 return Dir;
1205}
1206
1207OMPDistributeParallelForDirective *
1208OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1209 unsigned NumClauses,
1210 unsigned CollapsedNum,
1211 EmptyShell) {
1212 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001213 alignof(OMPClause *));
Carlo Bertolli9925f152016-06-27 14:55:37 +00001214 void *Mem = C.Allocate(
1215 Size + sizeof(OMPClause *) * NumClauses +
1216 sizeof(Stmt *) *
1217 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1218 return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
1219}
Kelvin Li4a39add2016-07-05 05:00:15 +00001220
1221OMPDistributeParallelForSimdDirective *
1222OMPDistributeParallelForSimdDirective::Create(
1223 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1224 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1225 const HelperExprs &Exprs) {
1226 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001227 alignof(OMPClause *));
Kelvin Li4a39add2016-07-05 05:00:15 +00001228 void *Mem = C.Allocate(
1229 Size + sizeof(OMPClause *) * Clauses.size() +
1230 sizeof(Stmt *) *
1231 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1232 OMPDistributeParallelForSimdDirective *Dir = new (Mem)
1233 OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1234 Clauses.size());
1235 Dir->setClauses(Clauses);
1236 Dir->setAssociatedStmt(AssociatedStmt);
1237 Dir->setIterationVariable(Exprs.IterationVarRef);
1238 Dir->setLastIteration(Exprs.LastIteration);
1239 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1240 Dir->setPreCond(Exprs.PreCond);
1241 Dir->setCond(Exprs.Cond);
1242 Dir->setInit(Exprs.Init);
1243 Dir->setInc(Exprs.Inc);
1244 Dir->setIsLastIterVariable(Exprs.IL);
1245 Dir->setLowerBoundVariable(Exprs.LB);
1246 Dir->setUpperBoundVariable(Exprs.UB);
1247 Dir->setStrideVariable(Exprs.ST);
1248 Dir->setEnsureUpperBound(Exprs.EUB);
1249 Dir->setNextLowerBound(Exprs.NLB);
1250 Dir->setNextUpperBound(Exprs.NUB);
1251 Dir->setNumIterations(Exprs.NumIterations);
1252 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1253 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001254 Dir->setDistInc(Exprs.DistInc);
1255 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li4a39add2016-07-05 05:00:15 +00001256 Dir->setCounters(Exprs.Counters);
1257 Dir->setPrivateCounters(Exprs.PrivateCounters);
1258 Dir->setInits(Exprs.Inits);
1259 Dir->setUpdates(Exprs.Updates);
1260 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001261 Dir->setDependentCounters(Exprs.DependentCounters);
1262 Dir->setDependentInits(Exprs.DependentInits);
1263 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li4a39add2016-07-05 05:00:15 +00001264 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001265 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1266 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1267 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1268 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1269 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1270 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1271 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001272 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1273 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li4a39add2016-07-05 05:00:15 +00001274 return Dir;
1275}
1276
1277OMPDistributeParallelForSimdDirective *
1278OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1279 unsigned NumClauses,
1280 unsigned CollapsedNum,
1281 EmptyShell) {
1282 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001283 alignof(OMPClause *));
Kelvin Li4a39add2016-07-05 05:00:15 +00001284 void *Mem = C.Allocate(
1285 Size + sizeof(OMPClause *) * NumClauses +
1286 sizeof(Stmt *) *
1287 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1288 return new (Mem)
1289 OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1290}
Kelvin Li787f3fc2016-07-06 04:45:38 +00001291
1292OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1293 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1294 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1295 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001296 unsigned Size =
1297 llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
Kelvin Li787f3fc2016-07-06 04:45:38 +00001298 void *Mem = C.Allocate(
1299 Size + sizeof(OMPClause *) * Clauses.size() +
1300 sizeof(Stmt *) *
1301 numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1302 OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
1303 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1304 Dir->setClauses(Clauses);
1305 Dir->setAssociatedStmt(AssociatedStmt);
1306 Dir->setIterationVariable(Exprs.IterationVarRef);
1307 Dir->setLastIteration(Exprs.LastIteration);
1308 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1309 Dir->setPreCond(Exprs.PreCond);
1310 Dir->setCond(Exprs.Cond);
1311 Dir->setInit(Exprs.Init);
1312 Dir->setInc(Exprs.Inc);
1313 Dir->setIsLastIterVariable(Exprs.IL);
1314 Dir->setLowerBoundVariable(Exprs.LB);
1315 Dir->setUpperBoundVariable(Exprs.UB);
1316 Dir->setStrideVariable(Exprs.ST);
1317 Dir->setEnsureUpperBound(Exprs.EUB);
1318 Dir->setNextLowerBound(Exprs.NLB);
1319 Dir->setNextUpperBound(Exprs.NUB);
1320 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li787f3fc2016-07-06 04:45:38 +00001321 Dir->setCounters(Exprs.Counters);
1322 Dir->setPrivateCounters(Exprs.PrivateCounters);
1323 Dir->setInits(Exprs.Inits);
1324 Dir->setUpdates(Exprs.Updates);
1325 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001326 Dir->setDependentCounters(Exprs.DependentCounters);
1327 Dir->setDependentInits(Exprs.DependentInits);
1328 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li787f3fc2016-07-06 04:45:38 +00001329 Dir->setPreInits(Exprs.PreInits);
1330 return Dir;
1331}
1332
1333OMPDistributeSimdDirective *
1334OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1335 unsigned NumClauses,
1336 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001337 unsigned Size =
1338 llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
Kelvin Li787f3fc2016-07-06 04:45:38 +00001339 void *Mem = C.Allocate(
1340 Size + sizeof(OMPClause *) * NumClauses +
1341 sizeof(Stmt *) *
1342 numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1343 return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
1344}
Kelvin Lia579b912016-07-14 02:54:56 +00001345
1346OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1347 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1348 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1349 const HelperExprs &Exprs) {
1350 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001351 alignof(OMPClause *));
Kelvin Lia579b912016-07-14 02:54:56 +00001352 void *Mem = C.Allocate(
1353 Size + sizeof(OMPClause *) * Clauses.size() +
Fangrui Song6907ce22018-07-30 19:24:48 +00001354 sizeof(Stmt *) *
Kelvin Lia579b912016-07-14 02:54:56 +00001355 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
Fangrui Song6907ce22018-07-30 19:24:48 +00001356 OMPTargetParallelForSimdDirective *Dir =
Kelvin Lia579b912016-07-14 02:54:56 +00001357 new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
1358 CollapsedNum, Clauses.size());
1359 Dir->setClauses(Clauses);
1360 Dir->setAssociatedStmt(AssociatedStmt);
1361 Dir->setIterationVariable(Exprs.IterationVarRef);
1362 Dir->setLastIteration(Exprs.LastIteration);
1363 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1364 Dir->setPreCond(Exprs.PreCond);
1365 Dir->setCond(Exprs.Cond);
1366 Dir->setInit(Exprs.Init);
1367 Dir->setInc(Exprs.Inc);
1368 Dir->setIsLastIterVariable(Exprs.IL);
1369 Dir->setLowerBoundVariable(Exprs.LB);
1370 Dir->setUpperBoundVariable(Exprs.UB);
1371 Dir->setStrideVariable(Exprs.ST);
1372 Dir->setEnsureUpperBound(Exprs.EUB);
1373 Dir->setNextLowerBound(Exprs.NLB);
1374 Dir->setNextUpperBound(Exprs.NUB);
1375 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Lia579b912016-07-14 02:54:56 +00001376 Dir->setCounters(Exprs.Counters);
1377 Dir->setPrivateCounters(Exprs.PrivateCounters);
1378 Dir->setInits(Exprs.Inits);
1379 Dir->setUpdates(Exprs.Updates);
1380 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001381 Dir->setDependentCounters(Exprs.DependentCounters);
1382 Dir->setDependentInits(Exprs.DependentInits);
1383 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Lia579b912016-07-14 02:54:56 +00001384 Dir->setPreInits(Exprs.PreInits);
1385 return Dir;
1386}
1387
1388OMPTargetParallelForSimdDirective *
1389OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1390 unsigned NumClauses,
1391 unsigned CollapsedNum,
1392 EmptyShell) {
1393 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001394 alignof(OMPClause *));
Kelvin Lia579b912016-07-14 02:54:56 +00001395 void *Mem = C.Allocate(
1396 Size + sizeof(OMPClause *) * NumClauses +
Fangrui Song6907ce22018-07-30 19:24:48 +00001397 sizeof(Stmt *) *
Kelvin Lia579b912016-07-14 02:54:56 +00001398 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1399 return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
1400}
Kelvin Li986330c2016-07-20 22:57:10 +00001401
1402OMPTargetSimdDirective *
Fangrui Song6907ce22018-07-30 19:24:48 +00001403OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
Kelvin Li986330c2016-07-20 22:57:10 +00001404 SourceLocation EndLoc, unsigned CollapsedNum,
1405 ArrayRef<OMPClause *> Clauses,
1406 Stmt *AssociatedStmt, const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001407 unsigned Size =
1408 llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
Kelvin Li986330c2016-07-20 22:57:10 +00001409 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
Fangrui Song6907ce22018-07-30 19:24:48 +00001410 sizeof(Stmt *) *
Kelvin Li986330c2016-07-20 22:57:10 +00001411 numLoopChildren(CollapsedNum, OMPD_target_simd));
1412 OMPTargetSimdDirective *Dir = new (Mem)
1413 OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1414 Dir->setClauses(Clauses);
1415 Dir->setAssociatedStmt(AssociatedStmt);
1416 Dir->setIterationVariable(Exprs.IterationVarRef);
1417 Dir->setLastIteration(Exprs.LastIteration);
1418 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1419 Dir->setPreCond(Exprs.PreCond);
1420 Dir->setCond(Exprs.Cond);
1421 Dir->setInit(Exprs.Init);
1422 Dir->setInc(Exprs.Inc);
1423 Dir->setCounters(Exprs.Counters);
1424 Dir->setPrivateCounters(Exprs.PrivateCounters);
1425 Dir->setInits(Exprs.Inits);
1426 Dir->setUpdates(Exprs.Updates);
1427 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001428 Dir->setDependentCounters(Exprs.DependentCounters);
1429 Dir->setDependentInits(Exprs.DependentInits);
1430 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li986330c2016-07-20 22:57:10 +00001431 Dir->setPreInits(Exprs.PreInits);
1432 return Dir;
1433}
1434
1435OMPTargetSimdDirective *
1436OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1437 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001438 unsigned Size =
1439 llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
Kelvin Li986330c2016-07-20 22:57:10 +00001440 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
Fangrui Song6907ce22018-07-30 19:24:48 +00001441 sizeof(Stmt *) *
Kelvin Li986330c2016-07-20 22:57:10 +00001442 numLoopChildren(CollapsedNum, OMPD_target_simd));
1443 return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
1444}
Kelvin Li02532872016-08-05 14:37:37 +00001445
1446OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1447 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1448 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1449 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001450 unsigned Size =
1451 llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
Kelvin Li02532872016-08-05 14:37:37 +00001452 void *Mem = C.Allocate(
1453 Size + sizeof(OMPClause *) * Clauses.size() +
1454 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1455 OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
1456 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1457 Dir->setClauses(Clauses);
1458 Dir->setAssociatedStmt(AssociatedStmt);
1459 Dir->setIterationVariable(Exprs.IterationVarRef);
1460 Dir->setLastIteration(Exprs.LastIteration);
1461 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1462 Dir->setPreCond(Exprs.PreCond);
1463 Dir->setCond(Exprs.Cond);
1464 Dir->setInit(Exprs.Init);
1465 Dir->setInc(Exprs.Inc);
1466 Dir->setIsLastIterVariable(Exprs.IL);
1467 Dir->setLowerBoundVariable(Exprs.LB);
1468 Dir->setUpperBoundVariable(Exprs.UB);
1469 Dir->setStrideVariable(Exprs.ST);
1470 Dir->setEnsureUpperBound(Exprs.EUB);
1471 Dir->setNextLowerBound(Exprs.NLB);
1472 Dir->setNextUpperBound(Exprs.NUB);
1473 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li02532872016-08-05 14:37:37 +00001474 Dir->setCounters(Exprs.Counters);
1475 Dir->setPrivateCounters(Exprs.PrivateCounters);
1476 Dir->setInits(Exprs.Inits);
1477 Dir->setUpdates(Exprs.Updates);
1478 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001479 Dir->setDependentCounters(Exprs.DependentCounters);
1480 Dir->setDependentInits(Exprs.DependentInits);
1481 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li02532872016-08-05 14:37:37 +00001482 Dir->setPreInits(Exprs.PreInits);
1483 return Dir;
1484}
1485
1486OMPTeamsDistributeDirective *
1487OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1488 unsigned NumClauses,
1489 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001490 unsigned Size =
1491 llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
Kelvin Li02532872016-08-05 14:37:37 +00001492 void *Mem = C.Allocate(
1493 Size + sizeof(OMPClause *) * NumClauses +
1494 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1495 return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
1496}
Kelvin Li4e325f72016-10-25 12:50:55 +00001497
1498OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1499 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1500 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1501 const HelperExprs &Exprs) {
1502 unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1503 alignof(OMPClause *));
1504 void *Mem =
1505 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1506 sizeof(Stmt *) *
1507 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1508 OMPTeamsDistributeSimdDirective *Dir =
1509 new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1510 Clauses.size());
1511 Dir->setClauses(Clauses);
1512 Dir->setAssociatedStmt(AssociatedStmt);
1513 Dir->setIterationVariable(Exprs.IterationVarRef);
1514 Dir->setLastIteration(Exprs.LastIteration);
1515 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1516 Dir->setPreCond(Exprs.PreCond);
1517 Dir->setCond(Exprs.Cond);
1518 Dir->setInit(Exprs.Init);
1519 Dir->setInc(Exprs.Inc);
1520 Dir->setIsLastIterVariable(Exprs.IL);
1521 Dir->setLowerBoundVariable(Exprs.LB);
1522 Dir->setUpperBoundVariable(Exprs.UB);
1523 Dir->setStrideVariable(Exprs.ST);
1524 Dir->setEnsureUpperBound(Exprs.EUB);
1525 Dir->setNextLowerBound(Exprs.NLB);
1526 Dir->setNextUpperBound(Exprs.NUB);
1527 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li4e325f72016-10-25 12:50:55 +00001528 Dir->setCounters(Exprs.Counters);
1529 Dir->setPrivateCounters(Exprs.PrivateCounters);
1530 Dir->setInits(Exprs.Inits);
1531 Dir->setUpdates(Exprs.Updates);
1532 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001533 Dir->setDependentCounters(Exprs.DependentCounters);
1534 Dir->setDependentInits(Exprs.DependentInits);
1535 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li4e325f72016-10-25 12:50:55 +00001536 Dir->setPreInits(Exprs.PreInits);
1537 return Dir;
1538}
1539
1540OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1541 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1542 EmptyShell) {
1543 unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1544 alignof(OMPClause *));
1545 void *Mem =
1546 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1547 sizeof(Stmt *) *
1548 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1549 return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1550}
Kelvin Li579e41c2016-11-30 23:51:03 +00001551
1552OMPTeamsDistributeParallelForSimdDirective *
1553OMPTeamsDistributeParallelForSimdDirective::Create(
1554 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1555 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1556 const HelperExprs &Exprs) {
1557 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1558 alignof(OMPClause *));
1559 void *Mem =
1560 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1561 sizeof(Stmt *) *
1562 numLoopChildren(CollapsedNum,
1563 OMPD_teams_distribute_parallel_for_simd));
1564 OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
1565 OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1566 Clauses.size());
1567 Dir->setClauses(Clauses);
1568 Dir->setAssociatedStmt(AssociatedStmt);
1569 Dir->setIterationVariable(Exprs.IterationVarRef);
1570 Dir->setLastIteration(Exprs.LastIteration);
1571 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1572 Dir->setPreCond(Exprs.PreCond);
1573 Dir->setCond(Exprs.Cond);
1574 Dir->setInit(Exprs.Init);
1575 Dir->setInc(Exprs.Inc);
1576 Dir->setIsLastIterVariable(Exprs.IL);
1577 Dir->setLowerBoundVariable(Exprs.LB);
1578 Dir->setUpperBoundVariable(Exprs.UB);
1579 Dir->setStrideVariable(Exprs.ST);
1580 Dir->setEnsureUpperBound(Exprs.EUB);
1581 Dir->setNextLowerBound(Exprs.NLB);
1582 Dir->setNextUpperBound(Exprs.NUB);
1583 Dir->setNumIterations(Exprs.NumIterations);
1584 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1585 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001586 Dir->setDistInc(Exprs.DistInc);
1587 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li579e41c2016-11-30 23:51:03 +00001588 Dir->setCounters(Exprs.Counters);
1589 Dir->setPrivateCounters(Exprs.PrivateCounters);
1590 Dir->setInits(Exprs.Inits);
1591 Dir->setUpdates(Exprs.Updates);
1592 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001593 Dir->setDependentCounters(Exprs.DependentCounters);
1594 Dir->setDependentInits(Exprs.DependentInits);
1595 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li579e41c2016-11-30 23:51:03 +00001596 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001597 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1598 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1599 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1600 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1601 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1602 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1603 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001604 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1605 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li579e41c2016-11-30 23:51:03 +00001606 return Dir;
1607}
1608
1609OMPTeamsDistributeParallelForSimdDirective *
1610OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1611 unsigned NumClauses,
1612 unsigned CollapsedNum,
1613 EmptyShell) {
1614 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1615 alignof(OMPClause *));
1616 void *Mem =
1617 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1618 sizeof(Stmt *) *
1619 numLoopChildren(CollapsedNum,
1620 OMPD_teams_distribute_parallel_for_simd));
1621 return new (Mem)
1622 OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1623}
Kelvin Li7ade93f2016-12-09 03:24:30 +00001624
1625OMPTeamsDistributeParallelForDirective *
1626OMPTeamsDistributeParallelForDirective::Create(
1627 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1628 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001629 const HelperExprs &Exprs, bool HasCancel) {
Kelvin Li7ade93f2016-12-09 03:24:30 +00001630 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1631 alignof(OMPClause *));
1632 void *Mem = C.Allocate(
1633 Size + sizeof(OMPClause *) * Clauses.size() +
1634 sizeof(Stmt *) *
1635 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1636 OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
1637 OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
1638 Clauses.size());
1639 Dir->setClauses(Clauses);
1640 Dir->setAssociatedStmt(AssociatedStmt);
1641 Dir->setIterationVariable(Exprs.IterationVarRef);
1642 Dir->setLastIteration(Exprs.LastIteration);
1643 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1644 Dir->setPreCond(Exprs.PreCond);
1645 Dir->setCond(Exprs.Cond);
1646 Dir->setInit(Exprs.Init);
1647 Dir->setInc(Exprs.Inc);
1648 Dir->setIsLastIterVariable(Exprs.IL);
1649 Dir->setLowerBoundVariable(Exprs.LB);
1650 Dir->setUpperBoundVariable(Exprs.UB);
1651 Dir->setStrideVariable(Exprs.ST);
1652 Dir->setEnsureUpperBound(Exprs.EUB);
1653 Dir->setNextLowerBound(Exprs.NLB);
1654 Dir->setNextUpperBound(Exprs.NUB);
1655 Dir->setNumIterations(Exprs.NumIterations);
1656 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1657 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001658 Dir->setDistInc(Exprs.DistInc);
1659 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li7ade93f2016-12-09 03:24:30 +00001660 Dir->setCounters(Exprs.Counters);
1661 Dir->setPrivateCounters(Exprs.PrivateCounters);
1662 Dir->setInits(Exprs.Inits);
1663 Dir->setUpdates(Exprs.Updates);
1664 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001665 Dir->setDependentCounters(Exprs.DependentCounters);
1666 Dir->setDependentInits(Exprs.DependentInits);
1667 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li7ade93f2016-12-09 03:24:30 +00001668 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001669 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1670 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1671 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1672 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1673 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1674 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1675 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001676 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1677 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001678 Dir->HasCancel = HasCancel;
Kelvin Li7ade93f2016-12-09 03:24:30 +00001679 return Dir;
1680}
1681
1682OMPTeamsDistributeParallelForDirective *
1683OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1684 unsigned NumClauses,
1685 unsigned CollapsedNum,
1686 EmptyShell) {
1687 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1688 alignof(OMPClause *));
1689 void *Mem = C.Allocate(
1690 Size + sizeof(OMPClause *) * NumClauses +
1691 sizeof(Stmt *) *
1692 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1693 return new (Mem)
1694 OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1695}
1696
Kelvin Libf594a52016-12-17 05:48:59 +00001697OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
1698 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1699 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1700 auto Size =
1701 llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1702 void *Mem =
1703 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1704 OMPTargetTeamsDirective *Dir =
1705 new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
1706 Dir->setClauses(Clauses);
1707 Dir->setAssociatedStmt(AssociatedStmt);
1708 return Dir;
1709}
1710
1711OMPTargetTeamsDirective *
1712OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1713 EmptyShell) {
1714 auto Size =
1715 llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1716 void *Mem =
1717 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1718 return new (Mem) OMPTargetTeamsDirective(NumClauses);
1719}
Kelvin Li83c451e2016-12-25 04:52:54 +00001720
1721OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
1722 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1723 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1724 const HelperExprs &Exprs) {
1725 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1726 alignof(OMPClause *));
1727 void *Mem = C.Allocate(
1728 Size + sizeof(OMPClause *) * Clauses.size() +
1729 sizeof(Stmt *) *
1730 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1731 OMPTargetTeamsDistributeDirective *Dir =
1732 new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
1733 Clauses.size());
1734 Dir->setClauses(Clauses);
1735 Dir->setAssociatedStmt(AssociatedStmt);
1736 Dir->setIterationVariable(Exprs.IterationVarRef);
1737 Dir->setLastIteration(Exprs.LastIteration);
1738 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1739 Dir->setPreCond(Exprs.PreCond);
1740 Dir->setCond(Exprs.Cond);
1741 Dir->setInit(Exprs.Init);
1742 Dir->setInc(Exprs.Inc);
1743 Dir->setIsLastIterVariable(Exprs.IL);
1744 Dir->setLowerBoundVariable(Exprs.LB);
1745 Dir->setUpperBoundVariable(Exprs.UB);
1746 Dir->setStrideVariable(Exprs.ST);
1747 Dir->setEnsureUpperBound(Exprs.EUB);
1748 Dir->setNextLowerBound(Exprs.NLB);
1749 Dir->setNextUpperBound(Exprs.NUB);
1750 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li83c451e2016-12-25 04:52:54 +00001751 Dir->setCounters(Exprs.Counters);
1752 Dir->setPrivateCounters(Exprs.PrivateCounters);
1753 Dir->setInits(Exprs.Inits);
1754 Dir->setUpdates(Exprs.Updates);
1755 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001756 Dir->setDependentCounters(Exprs.DependentCounters);
1757 Dir->setDependentInits(Exprs.DependentInits);
1758 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li83c451e2016-12-25 04:52:54 +00001759 Dir->setPreInits(Exprs.PreInits);
1760 return Dir;
1761}
1762
1763OMPTargetTeamsDistributeDirective *
1764OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1765 unsigned NumClauses,
1766 unsigned CollapsedNum,
1767 EmptyShell) {
1768 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1769 alignof(OMPClause *));
1770 void *Mem = C.Allocate(
1771 Size + sizeof(OMPClause *) * NumClauses +
1772 sizeof(Stmt *) *
1773 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1774 return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
1775}
Kelvin Li80e8f562016-12-29 22:16:30 +00001776
1777OMPTargetTeamsDistributeParallelForDirective *
1778OMPTargetTeamsDistributeParallelForDirective::Create(
1779 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1780 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataev16e79882017-11-22 21:12:03 +00001781 const HelperExprs &Exprs, bool HasCancel) {
Kelvin Li80e8f562016-12-29 22:16:30 +00001782 auto Size =
1783 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1784 alignof(OMPClause *));
1785 void *Mem = C.Allocate(
1786 Size + sizeof(OMPClause *) * Clauses.size() +
1787 sizeof(Stmt *) *
1788 numLoopChildren(CollapsedNum,
1789 OMPD_target_teams_distribute_parallel_for));
1790 OMPTargetTeamsDistributeParallelForDirective *Dir =
1791 new (Mem) OMPTargetTeamsDistributeParallelForDirective(
1792 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1793 Dir->setClauses(Clauses);
1794 Dir->setAssociatedStmt(AssociatedStmt);
1795 Dir->setIterationVariable(Exprs.IterationVarRef);
1796 Dir->setLastIteration(Exprs.LastIteration);
1797 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1798 Dir->setPreCond(Exprs.PreCond);
1799 Dir->setCond(Exprs.Cond);
1800 Dir->setInit(Exprs.Init);
1801 Dir->setInc(Exprs.Inc);
1802 Dir->setIsLastIterVariable(Exprs.IL);
1803 Dir->setLowerBoundVariable(Exprs.LB);
1804 Dir->setUpperBoundVariable(Exprs.UB);
1805 Dir->setStrideVariable(Exprs.ST);
1806 Dir->setEnsureUpperBound(Exprs.EUB);
1807 Dir->setNextLowerBound(Exprs.NLB);
1808 Dir->setNextUpperBound(Exprs.NUB);
1809 Dir->setNumIterations(Exprs.NumIterations);
1810 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1811 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001812 Dir->setDistInc(Exprs.DistInc);
1813 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li80e8f562016-12-29 22:16:30 +00001814 Dir->setCounters(Exprs.Counters);
1815 Dir->setPrivateCounters(Exprs.PrivateCounters);
1816 Dir->setInits(Exprs.Inits);
1817 Dir->setUpdates(Exprs.Updates);
1818 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001819 Dir->setDependentCounters(Exprs.DependentCounters);
1820 Dir->setDependentInits(Exprs.DependentInits);
1821 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li80e8f562016-12-29 22:16:30 +00001822 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001823 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1824 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1825 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1826 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1827 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1828 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1829 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001830 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1831 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataev16e79882017-11-22 21:12:03 +00001832 Dir->HasCancel = HasCancel;
Kelvin Li80e8f562016-12-29 22:16:30 +00001833 return Dir;
1834}
1835
1836OMPTargetTeamsDistributeParallelForDirective *
1837OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1838 unsigned NumClauses,
1839 unsigned CollapsedNum,
1840 EmptyShell) {
1841 auto Size =
1842 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1843 alignof(OMPClause *));
1844 void *Mem = C.Allocate(
1845 Size + sizeof(OMPClause *) * NumClauses +
1846 sizeof(Stmt *) *
1847 numLoopChildren(CollapsedNum,
1848 OMPD_target_teams_distribute_parallel_for));
1849 return new (Mem)
1850 OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1851}
Kelvin Li1851df52017-01-03 05:23:48 +00001852
1853OMPTargetTeamsDistributeParallelForSimdDirective *
1854OMPTargetTeamsDistributeParallelForSimdDirective::Create(
1855 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1856 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1857 const HelperExprs &Exprs) {
1858 auto Size =
1859 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
1860 alignof(OMPClause *));
1861 void *Mem = C.Allocate(
1862 Size + sizeof(OMPClause *) * Clauses.size() +
1863 sizeof(Stmt *) *
1864 numLoopChildren(CollapsedNum,
1865 OMPD_target_teams_distribute_parallel_for_simd));
1866 OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
1867 new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
1868 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1869 Dir->setClauses(Clauses);
1870 Dir->setAssociatedStmt(AssociatedStmt);
1871 Dir->setIterationVariable(Exprs.IterationVarRef);
1872 Dir->setLastIteration(Exprs.LastIteration);
1873 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1874 Dir->setPreCond(Exprs.PreCond);
1875 Dir->setCond(Exprs.Cond);
1876 Dir->setInit(Exprs.Init);
1877 Dir->setInc(Exprs.Inc);
1878 Dir->setIsLastIterVariable(Exprs.IL);
1879 Dir->setLowerBoundVariable(Exprs.LB);
1880 Dir->setUpperBoundVariable(Exprs.UB);
1881 Dir->setStrideVariable(Exprs.ST);
1882 Dir->setEnsureUpperBound(Exprs.EUB);
1883 Dir->setNextLowerBound(Exprs.NLB);
1884 Dir->setNextUpperBound(Exprs.NUB);
1885 Dir->setNumIterations(Exprs.NumIterations);
1886 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1887 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001888 Dir->setDistInc(Exprs.DistInc);
1889 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li1851df52017-01-03 05:23:48 +00001890 Dir->setCounters(Exprs.Counters);
1891 Dir->setPrivateCounters(Exprs.PrivateCounters);
1892 Dir->setInits(Exprs.Inits);
1893 Dir->setUpdates(Exprs.Updates);
1894 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001895 Dir->setDependentCounters(Exprs.DependentCounters);
1896 Dir->setDependentInits(Exprs.DependentInits);
1897 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li1851df52017-01-03 05:23:48 +00001898 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001899 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1900 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1901 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1902 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1903 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1904 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1905 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001906 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1907 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li1851df52017-01-03 05:23:48 +00001908 return Dir;
1909}
1910
1911OMPTargetTeamsDistributeParallelForSimdDirective *
1912OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
1913 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1914 EmptyShell) {
1915 auto Size =
1916 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
1917 alignof(OMPClause *));
1918 void *Mem = C.Allocate(
1919 Size + sizeof(OMPClause *) * NumClauses +
1920 sizeof(Stmt *) *
1921 numLoopChildren(CollapsedNum,
1922 OMPD_target_teams_distribute_parallel_for_simd));
1923 return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
1924 CollapsedNum, NumClauses);
1925}
1926
Kelvin Lida681182017-01-10 18:08:18 +00001927OMPTargetTeamsDistributeSimdDirective *
1928OMPTargetTeamsDistributeSimdDirective::Create(
1929 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1930 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1931 const HelperExprs &Exprs) {
1932 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
1933 alignof(OMPClause *));
1934 void *Mem = C.Allocate(
1935 Size + sizeof(OMPClause *) * Clauses.size() +
1936 sizeof(Stmt *) *
1937 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
1938 OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
1939 OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1940 Clauses.size());
1941 Dir->setClauses(Clauses);
1942 Dir->setAssociatedStmt(AssociatedStmt);
1943 Dir->setIterationVariable(Exprs.IterationVarRef);
1944 Dir->setLastIteration(Exprs.LastIteration);
1945 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1946 Dir->setPreCond(Exprs.PreCond);
1947 Dir->setCond(Exprs.Cond);
1948 Dir->setInit(Exprs.Init);
1949 Dir->setInc(Exprs.Inc);
1950 Dir->setIsLastIterVariable(Exprs.IL);
1951 Dir->setLowerBoundVariable(Exprs.LB);
1952 Dir->setUpperBoundVariable(Exprs.UB);
1953 Dir->setStrideVariable(Exprs.ST);
1954 Dir->setEnsureUpperBound(Exprs.EUB);
1955 Dir->setNextLowerBound(Exprs.NLB);
1956 Dir->setNextUpperBound(Exprs.NUB);
1957 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Lida681182017-01-10 18:08:18 +00001958 Dir->setCounters(Exprs.Counters);
1959 Dir->setPrivateCounters(Exprs.PrivateCounters);
1960 Dir->setInits(Exprs.Inits);
1961 Dir->setUpdates(Exprs.Updates);
1962 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001963 Dir->setDependentCounters(Exprs.DependentCounters);
1964 Dir->setDependentInits(Exprs.DependentInits);
1965 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Lida681182017-01-10 18:08:18 +00001966 Dir->setPreInits(Exprs.PreInits);
1967 return Dir;
1968}
1969
1970OMPTargetTeamsDistributeSimdDirective *
1971OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1972 unsigned NumClauses,
1973 unsigned CollapsedNum,
1974 EmptyShell) {
1975 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
1976 alignof(OMPClause *));
1977 void *Mem = C.Allocate(
1978 Size + sizeof(OMPClause *) * NumClauses +
1979 sizeof(Stmt *) *
1980 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
1981 return new (Mem)
1982 OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1983}