blob: da1364ebffc4c1a86844c923b13f4d72e60d1ea1 [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
Alexey Bataevb8552ab2019-10-18 16:47:35 +00001076OMPMasterTaskLoopSimdDirective *OMPMasterTaskLoopSimdDirective::Create(
1077 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1078 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1079 const HelperExprs &Exprs) {
1080 unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
1081 alignof(OMPClause *));
1082 void *Mem =
1083 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1084 sizeof(Stmt *) *
1085 numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
1086 auto *Dir = new (Mem) OMPMasterTaskLoopSimdDirective(
1087 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1088 Dir->setClauses(Clauses);
1089 Dir->setAssociatedStmt(AssociatedStmt);
1090 Dir->setIterationVariable(Exprs.IterationVarRef);
1091 Dir->setLastIteration(Exprs.LastIteration);
1092 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1093 Dir->setPreCond(Exprs.PreCond);
1094 Dir->setCond(Exprs.Cond);
1095 Dir->setInit(Exprs.Init);
1096 Dir->setInc(Exprs.Inc);
1097 Dir->setIsLastIterVariable(Exprs.IL);
1098 Dir->setLowerBoundVariable(Exprs.LB);
1099 Dir->setUpperBoundVariable(Exprs.UB);
1100 Dir->setStrideVariable(Exprs.ST);
1101 Dir->setEnsureUpperBound(Exprs.EUB);
1102 Dir->setNextLowerBound(Exprs.NLB);
1103 Dir->setNextUpperBound(Exprs.NUB);
1104 Dir->setNumIterations(Exprs.NumIterations);
1105 Dir->setCounters(Exprs.Counters);
1106 Dir->setPrivateCounters(Exprs.PrivateCounters);
1107 Dir->setInits(Exprs.Inits);
1108 Dir->setUpdates(Exprs.Updates);
1109 Dir->setFinals(Exprs.Finals);
1110 Dir->setDependentCounters(Exprs.DependentCounters);
1111 Dir->setDependentInits(Exprs.DependentInits);
1112 Dir->setFinalsConditions(Exprs.FinalsConditions);
1113 Dir->setPreInits(Exprs.PreInits);
1114 return Dir;
1115}
1116
1117OMPMasterTaskLoopSimdDirective *
1118OMPMasterTaskLoopSimdDirective::CreateEmpty(const ASTContext &C,
1119 unsigned NumClauses,
1120 unsigned CollapsedNum, EmptyShell) {
1121 unsigned Size = llvm::alignTo(sizeof(OMPMasterTaskLoopSimdDirective),
1122 alignof(OMPClause *));
1123 void *Mem =
1124 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1125 sizeof(Stmt *) *
1126 numLoopChildren(CollapsedNum, OMPD_master_taskloop_simd));
1127 return new (Mem) OMPMasterTaskLoopSimdDirective(CollapsedNum, NumClauses);
1128}
1129
Alexey Bataev5bbcead2019-10-14 17:17:41 +00001130OMPParallelMasterTaskLoopDirective *OMPParallelMasterTaskLoopDirective::Create(
1131 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1132 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1133 const HelperExprs &Exprs) {
1134 unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
1135 alignof(OMPClause *));
1136 void *Mem = C.Allocate(
1137 Size + sizeof(OMPClause *) * Clauses.size() +
1138 sizeof(Stmt *) *
1139 numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
1140 auto *Dir = new (Mem) OMPParallelMasterTaskLoopDirective(
1141 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1142 Dir->setClauses(Clauses);
1143 Dir->setAssociatedStmt(AssociatedStmt);
1144 Dir->setIterationVariable(Exprs.IterationVarRef);
1145 Dir->setLastIteration(Exprs.LastIteration);
1146 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1147 Dir->setPreCond(Exprs.PreCond);
1148 Dir->setCond(Exprs.Cond);
1149 Dir->setInit(Exprs.Init);
1150 Dir->setInc(Exprs.Inc);
1151 Dir->setIsLastIterVariable(Exprs.IL);
1152 Dir->setLowerBoundVariable(Exprs.LB);
1153 Dir->setUpperBoundVariable(Exprs.UB);
1154 Dir->setStrideVariable(Exprs.ST);
1155 Dir->setEnsureUpperBound(Exprs.EUB);
1156 Dir->setNextLowerBound(Exprs.NLB);
1157 Dir->setNextUpperBound(Exprs.NUB);
1158 Dir->setNumIterations(Exprs.NumIterations);
1159 Dir->setCounters(Exprs.Counters);
1160 Dir->setPrivateCounters(Exprs.PrivateCounters);
1161 Dir->setInits(Exprs.Inits);
1162 Dir->setUpdates(Exprs.Updates);
1163 Dir->setFinals(Exprs.Finals);
1164 Dir->setDependentCounters(Exprs.DependentCounters);
1165 Dir->setDependentInits(Exprs.DependentInits);
1166 Dir->setFinalsConditions(Exprs.FinalsConditions);
1167 Dir->setPreInits(Exprs.PreInits);
1168 return Dir;
1169}
1170
1171OMPParallelMasterTaskLoopDirective *
1172OMPParallelMasterTaskLoopDirective::CreateEmpty(const ASTContext &C,
1173 unsigned NumClauses,
1174 unsigned CollapsedNum,
1175 EmptyShell) {
1176 unsigned Size = llvm::alignTo(sizeof(OMPParallelMasterTaskLoopDirective),
1177 alignof(OMPClause *));
1178 void *Mem = C.Allocate(
1179 Size + sizeof(OMPClause *) * NumClauses +
1180 sizeof(Stmt *) *
1181 numLoopChildren(CollapsedNum, OMPD_parallel_master_taskloop));
1182 return new (Mem) OMPParallelMasterTaskLoopDirective(CollapsedNum, NumClauses);
1183}
1184
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001185OMPDistributeDirective *OMPDistributeDirective::Create(
1186 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1187 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1188 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001189 unsigned Size =
1190 llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001191 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1192 sizeof(Stmt *) *
1193 numLoopChildren(CollapsedNum, OMPD_distribute));
1194 OMPDistributeDirective *Dir = new (Mem)
1195 OMPDistributeDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1196 Dir->setClauses(Clauses);
1197 Dir->setAssociatedStmt(AssociatedStmt);
1198 Dir->setIterationVariable(Exprs.IterationVarRef);
1199 Dir->setLastIteration(Exprs.LastIteration);
1200 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1201 Dir->setPreCond(Exprs.PreCond);
1202 Dir->setCond(Exprs.Cond);
1203 Dir->setInit(Exprs.Init);
1204 Dir->setInc(Exprs.Inc);
1205 Dir->setIsLastIterVariable(Exprs.IL);
1206 Dir->setLowerBoundVariable(Exprs.LB);
1207 Dir->setUpperBoundVariable(Exprs.UB);
1208 Dir->setStrideVariable(Exprs.ST);
1209 Dir->setEnsureUpperBound(Exprs.EUB);
1210 Dir->setNextLowerBound(Exprs.NLB);
1211 Dir->setNextUpperBound(Exprs.NUB);
Alexey Bataev8b427062016-05-25 12:36:08 +00001212 Dir->setNumIterations(Exprs.NumIterations);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001213 Dir->setCounters(Exprs.Counters);
1214 Dir->setPrivateCounters(Exprs.PrivateCounters);
1215 Dir->setInits(Exprs.Inits);
1216 Dir->setUpdates(Exprs.Updates);
1217 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001218 Dir->setDependentCounters(Exprs.DependentCounters);
1219 Dir->setDependentInits(Exprs.DependentInits);
1220 Dir->setFinalsConditions(Exprs.FinalsConditions);
Alexey Bataev5a3af132016-03-29 08:58:54 +00001221 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001222 return Dir;
1223}
1224
1225OMPDistributeDirective *
1226OMPDistributeDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1227 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001228 unsigned Size =
1229 llvm::alignTo(sizeof(OMPDistributeDirective), alignof(OMPClause *));
Carlo Bertolli6200a3d2015-12-14 14:51:25 +00001230 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1231 sizeof(Stmt *) *
1232 numLoopChildren(CollapsedNum, OMPD_distribute));
1233 return new (Mem) OMPDistributeDirective(CollapsedNum, NumClauses);
1234}
Samuel Antao686c70c2016-05-26 17:30:50 +00001235
Alexey Bataev7828b252017-11-21 17:08:48 +00001236OMPTargetUpdateDirective *OMPTargetUpdateDirective::Create(
1237 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1238 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001239 unsigned Size =
1240 llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
Alexey Bataev7828b252017-11-21 17:08:48 +00001241 void *Mem =
1242 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
Samuel Antao686c70c2016-05-26 17:30:50 +00001243 OMPTargetUpdateDirective *Dir =
1244 new (Mem) OMPTargetUpdateDirective(StartLoc, EndLoc, Clauses.size());
1245 Dir->setClauses(Clauses);
Alexey Bataev7828b252017-11-21 17:08:48 +00001246 Dir->setAssociatedStmt(AssociatedStmt);
Samuel Antao686c70c2016-05-26 17:30:50 +00001247 return Dir;
1248}
1249
1250OMPTargetUpdateDirective *
1251OMPTargetUpdateDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1252 EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001253 unsigned Size =
1254 llvm::alignTo(sizeof(OMPTargetUpdateDirective), alignof(OMPClause *));
Alexey Bataev7828b252017-11-21 17:08:48 +00001255 void *Mem =
1256 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
Samuel Antao686c70c2016-05-26 17:30:50 +00001257 return new (Mem) OMPTargetUpdateDirective(NumClauses);
1258}
Carlo Bertolli9925f152016-06-27 14:55:37 +00001259
1260OMPDistributeParallelForDirective *OMPDistributeParallelForDirective::Create(
1261 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1262 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001263 const HelperExprs &Exprs, bool HasCancel) {
Carlo Bertolli9925f152016-06-27 14:55:37 +00001264 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001265 alignof(OMPClause *));
Carlo Bertolli9925f152016-06-27 14:55:37 +00001266 void *Mem = C.Allocate(
1267 Size + sizeof(OMPClause *) * Clauses.size() +
1268 sizeof(Stmt *) *
1269 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1270 OMPDistributeParallelForDirective *Dir =
1271 new (Mem) OMPDistributeParallelForDirective(StartLoc, EndLoc,
1272 CollapsedNum, Clauses.size());
1273 Dir->setClauses(Clauses);
1274 Dir->setAssociatedStmt(AssociatedStmt);
1275 Dir->setIterationVariable(Exprs.IterationVarRef);
1276 Dir->setLastIteration(Exprs.LastIteration);
1277 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1278 Dir->setPreCond(Exprs.PreCond);
1279 Dir->setCond(Exprs.Cond);
1280 Dir->setInit(Exprs.Init);
1281 Dir->setInc(Exprs.Inc);
1282 Dir->setIsLastIterVariable(Exprs.IL);
1283 Dir->setLowerBoundVariable(Exprs.LB);
1284 Dir->setUpperBoundVariable(Exprs.UB);
1285 Dir->setStrideVariable(Exprs.ST);
1286 Dir->setEnsureUpperBound(Exprs.EUB);
1287 Dir->setNextLowerBound(Exprs.NLB);
1288 Dir->setNextUpperBound(Exprs.NUB);
1289 Dir->setNumIterations(Exprs.NumIterations);
1290 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1291 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001292 Dir->setDistInc(Exprs.DistInc);
1293 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Carlo Bertolli9925f152016-06-27 14:55:37 +00001294 Dir->setCounters(Exprs.Counters);
1295 Dir->setPrivateCounters(Exprs.PrivateCounters);
1296 Dir->setInits(Exprs.Inits);
1297 Dir->setUpdates(Exprs.Updates);
1298 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001299 Dir->setDependentCounters(Exprs.DependentCounters);
1300 Dir->setDependentInits(Exprs.DependentInits);
1301 Dir->setFinalsConditions(Exprs.FinalsConditions);
Carlo Bertolli9925f152016-06-27 14:55:37 +00001302 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001303 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1304 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1305 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1306 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1307 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1308 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1309 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001310 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1311 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001312 Dir->HasCancel = HasCancel;
Carlo Bertolli9925f152016-06-27 14:55:37 +00001313 return Dir;
1314}
1315
1316OMPDistributeParallelForDirective *
1317OMPDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1318 unsigned NumClauses,
1319 unsigned CollapsedNum,
1320 EmptyShell) {
1321 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001322 alignof(OMPClause *));
Carlo Bertolli9925f152016-06-27 14:55:37 +00001323 void *Mem = C.Allocate(
1324 Size + sizeof(OMPClause *) * NumClauses +
1325 sizeof(Stmt *) *
1326 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for));
1327 return new (Mem) OMPDistributeParallelForDirective(CollapsedNum, NumClauses);
1328}
Kelvin Li4a39add2016-07-05 05:00:15 +00001329
1330OMPDistributeParallelForSimdDirective *
1331OMPDistributeParallelForSimdDirective::Create(
1332 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1333 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1334 const HelperExprs &Exprs) {
1335 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001336 alignof(OMPClause *));
Kelvin Li4a39add2016-07-05 05:00:15 +00001337 void *Mem = C.Allocate(
1338 Size + sizeof(OMPClause *) * Clauses.size() +
1339 sizeof(Stmt *) *
1340 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1341 OMPDistributeParallelForSimdDirective *Dir = new (Mem)
1342 OMPDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1343 Clauses.size());
1344 Dir->setClauses(Clauses);
1345 Dir->setAssociatedStmt(AssociatedStmt);
1346 Dir->setIterationVariable(Exprs.IterationVarRef);
1347 Dir->setLastIteration(Exprs.LastIteration);
1348 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1349 Dir->setPreCond(Exprs.PreCond);
1350 Dir->setCond(Exprs.Cond);
1351 Dir->setInit(Exprs.Init);
1352 Dir->setInc(Exprs.Inc);
1353 Dir->setIsLastIterVariable(Exprs.IL);
1354 Dir->setLowerBoundVariable(Exprs.LB);
1355 Dir->setUpperBoundVariable(Exprs.UB);
1356 Dir->setStrideVariable(Exprs.ST);
1357 Dir->setEnsureUpperBound(Exprs.EUB);
1358 Dir->setNextLowerBound(Exprs.NLB);
1359 Dir->setNextUpperBound(Exprs.NUB);
1360 Dir->setNumIterations(Exprs.NumIterations);
1361 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1362 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001363 Dir->setDistInc(Exprs.DistInc);
1364 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li4a39add2016-07-05 05:00:15 +00001365 Dir->setCounters(Exprs.Counters);
1366 Dir->setPrivateCounters(Exprs.PrivateCounters);
1367 Dir->setInits(Exprs.Inits);
1368 Dir->setUpdates(Exprs.Updates);
1369 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001370 Dir->setDependentCounters(Exprs.DependentCounters);
1371 Dir->setDependentInits(Exprs.DependentInits);
1372 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li4a39add2016-07-05 05:00:15 +00001373 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001374 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1375 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1376 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1377 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1378 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1379 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1380 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001381 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1382 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li4a39add2016-07-05 05:00:15 +00001383 return Dir;
1384}
1385
1386OMPDistributeParallelForSimdDirective *
1387OMPDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1388 unsigned NumClauses,
1389 unsigned CollapsedNum,
1390 EmptyShell) {
1391 unsigned Size = llvm::alignTo(sizeof(OMPDistributeParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001392 alignof(OMPClause *));
Kelvin Li4a39add2016-07-05 05:00:15 +00001393 void *Mem = C.Allocate(
1394 Size + sizeof(OMPClause *) * NumClauses +
1395 sizeof(Stmt *) *
1396 numLoopChildren(CollapsedNum, OMPD_distribute_parallel_for_simd));
1397 return new (Mem)
1398 OMPDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1399}
Kelvin Li787f3fc2016-07-06 04:45:38 +00001400
1401OMPDistributeSimdDirective *OMPDistributeSimdDirective::Create(
1402 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1403 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1404 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001405 unsigned Size =
1406 llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
Kelvin Li787f3fc2016-07-06 04:45:38 +00001407 void *Mem = C.Allocate(
1408 Size + sizeof(OMPClause *) * Clauses.size() +
1409 sizeof(Stmt *) *
1410 numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1411 OMPDistributeSimdDirective *Dir = new (Mem) OMPDistributeSimdDirective(
1412 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1413 Dir->setClauses(Clauses);
1414 Dir->setAssociatedStmt(AssociatedStmt);
1415 Dir->setIterationVariable(Exprs.IterationVarRef);
1416 Dir->setLastIteration(Exprs.LastIteration);
1417 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1418 Dir->setPreCond(Exprs.PreCond);
1419 Dir->setCond(Exprs.Cond);
1420 Dir->setInit(Exprs.Init);
1421 Dir->setInc(Exprs.Inc);
1422 Dir->setIsLastIterVariable(Exprs.IL);
1423 Dir->setLowerBoundVariable(Exprs.LB);
1424 Dir->setUpperBoundVariable(Exprs.UB);
1425 Dir->setStrideVariable(Exprs.ST);
1426 Dir->setEnsureUpperBound(Exprs.EUB);
1427 Dir->setNextLowerBound(Exprs.NLB);
1428 Dir->setNextUpperBound(Exprs.NUB);
1429 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li787f3fc2016-07-06 04:45:38 +00001430 Dir->setCounters(Exprs.Counters);
1431 Dir->setPrivateCounters(Exprs.PrivateCounters);
1432 Dir->setInits(Exprs.Inits);
1433 Dir->setUpdates(Exprs.Updates);
1434 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001435 Dir->setDependentCounters(Exprs.DependentCounters);
1436 Dir->setDependentInits(Exprs.DependentInits);
1437 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li787f3fc2016-07-06 04:45:38 +00001438 Dir->setPreInits(Exprs.PreInits);
1439 return Dir;
1440}
1441
1442OMPDistributeSimdDirective *
1443OMPDistributeSimdDirective::CreateEmpty(const ASTContext &C,
1444 unsigned NumClauses,
1445 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001446 unsigned Size =
1447 llvm::alignTo(sizeof(OMPDistributeSimdDirective), alignof(OMPClause *));
Kelvin Li787f3fc2016-07-06 04:45:38 +00001448 void *Mem = C.Allocate(
1449 Size + sizeof(OMPClause *) * NumClauses +
1450 sizeof(Stmt *) *
1451 numLoopChildren(CollapsedNum, OMPD_distribute_simd));
1452 return new (Mem) OMPDistributeSimdDirective(CollapsedNum, NumClauses);
1453}
Kelvin Lia579b912016-07-14 02:54:56 +00001454
1455OMPTargetParallelForSimdDirective *OMPTargetParallelForSimdDirective::Create(
1456 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1457 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1458 const HelperExprs &Exprs) {
1459 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001460 alignof(OMPClause *));
Kelvin Lia579b912016-07-14 02:54:56 +00001461 void *Mem = C.Allocate(
1462 Size + sizeof(OMPClause *) * Clauses.size() +
Fangrui Song6907ce22018-07-30 19:24:48 +00001463 sizeof(Stmt *) *
Kelvin Lia579b912016-07-14 02:54:56 +00001464 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
Fangrui Song6907ce22018-07-30 19:24:48 +00001465 OMPTargetParallelForSimdDirective *Dir =
Kelvin Lia579b912016-07-14 02:54:56 +00001466 new (Mem) OMPTargetParallelForSimdDirective(StartLoc, EndLoc,
1467 CollapsedNum, Clauses.size());
1468 Dir->setClauses(Clauses);
1469 Dir->setAssociatedStmt(AssociatedStmt);
1470 Dir->setIterationVariable(Exprs.IterationVarRef);
1471 Dir->setLastIteration(Exprs.LastIteration);
1472 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1473 Dir->setPreCond(Exprs.PreCond);
1474 Dir->setCond(Exprs.Cond);
1475 Dir->setInit(Exprs.Init);
1476 Dir->setInc(Exprs.Inc);
1477 Dir->setIsLastIterVariable(Exprs.IL);
1478 Dir->setLowerBoundVariable(Exprs.LB);
1479 Dir->setUpperBoundVariable(Exprs.UB);
1480 Dir->setStrideVariable(Exprs.ST);
1481 Dir->setEnsureUpperBound(Exprs.EUB);
1482 Dir->setNextLowerBound(Exprs.NLB);
1483 Dir->setNextUpperBound(Exprs.NUB);
1484 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Lia579b912016-07-14 02:54:56 +00001485 Dir->setCounters(Exprs.Counters);
1486 Dir->setPrivateCounters(Exprs.PrivateCounters);
1487 Dir->setInits(Exprs.Inits);
1488 Dir->setUpdates(Exprs.Updates);
1489 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001490 Dir->setDependentCounters(Exprs.DependentCounters);
1491 Dir->setDependentInits(Exprs.DependentInits);
1492 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Lia579b912016-07-14 02:54:56 +00001493 Dir->setPreInits(Exprs.PreInits);
1494 return Dir;
1495}
1496
1497OMPTargetParallelForSimdDirective *
1498OMPTargetParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1499 unsigned NumClauses,
1500 unsigned CollapsedNum,
1501 EmptyShell) {
1502 unsigned Size = llvm::alignTo(sizeof(OMPTargetParallelForSimdDirective),
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001503 alignof(OMPClause *));
Kelvin Lia579b912016-07-14 02:54:56 +00001504 void *Mem = C.Allocate(
1505 Size + sizeof(OMPClause *) * NumClauses +
Fangrui Song6907ce22018-07-30 19:24:48 +00001506 sizeof(Stmt *) *
Kelvin Lia579b912016-07-14 02:54:56 +00001507 numLoopChildren(CollapsedNum, OMPD_target_parallel_for_simd));
1508 return new (Mem) OMPTargetParallelForSimdDirective(CollapsedNum, NumClauses);
1509}
Kelvin Li986330c2016-07-20 22:57:10 +00001510
1511OMPTargetSimdDirective *
Fangrui Song6907ce22018-07-30 19:24:48 +00001512OMPTargetSimdDirective::Create(const ASTContext &C, SourceLocation StartLoc,
Kelvin Li986330c2016-07-20 22:57:10 +00001513 SourceLocation EndLoc, unsigned CollapsedNum,
1514 ArrayRef<OMPClause *> Clauses,
1515 Stmt *AssociatedStmt, const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001516 unsigned Size =
1517 llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
Kelvin Li986330c2016-07-20 22:57:10 +00001518 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
Fangrui Song6907ce22018-07-30 19:24:48 +00001519 sizeof(Stmt *) *
Kelvin Li986330c2016-07-20 22:57:10 +00001520 numLoopChildren(CollapsedNum, OMPD_target_simd));
1521 OMPTargetSimdDirective *Dir = new (Mem)
1522 OMPTargetSimdDirective(StartLoc, EndLoc, CollapsedNum, Clauses.size());
1523 Dir->setClauses(Clauses);
1524 Dir->setAssociatedStmt(AssociatedStmt);
1525 Dir->setIterationVariable(Exprs.IterationVarRef);
1526 Dir->setLastIteration(Exprs.LastIteration);
1527 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1528 Dir->setPreCond(Exprs.PreCond);
1529 Dir->setCond(Exprs.Cond);
1530 Dir->setInit(Exprs.Init);
1531 Dir->setInc(Exprs.Inc);
1532 Dir->setCounters(Exprs.Counters);
1533 Dir->setPrivateCounters(Exprs.PrivateCounters);
1534 Dir->setInits(Exprs.Inits);
1535 Dir->setUpdates(Exprs.Updates);
1536 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001537 Dir->setDependentCounters(Exprs.DependentCounters);
1538 Dir->setDependentInits(Exprs.DependentInits);
1539 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li986330c2016-07-20 22:57:10 +00001540 Dir->setPreInits(Exprs.PreInits);
1541 return Dir;
1542}
1543
1544OMPTargetSimdDirective *
1545OMPTargetSimdDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1546 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001547 unsigned Size =
1548 llvm::alignTo(sizeof(OMPTargetSimdDirective), alignof(OMPClause *));
Kelvin Li986330c2016-07-20 22:57:10 +00001549 void *Mem = C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
Fangrui Song6907ce22018-07-30 19:24:48 +00001550 sizeof(Stmt *) *
Kelvin Li986330c2016-07-20 22:57:10 +00001551 numLoopChildren(CollapsedNum, OMPD_target_simd));
1552 return new (Mem) OMPTargetSimdDirective(CollapsedNum, NumClauses);
1553}
Kelvin Li02532872016-08-05 14:37:37 +00001554
1555OMPTeamsDistributeDirective *OMPTeamsDistributeDirective::Create(
1556 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1557 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1558 const HelperExprs &Exprs) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001559 unsigned Size =
1560 llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
Kelvin Li02532872016-08-05 14:37:37 +00001561 void *Mem = C.Allocate(
1562 Size + sizeof(OMPClause *) * Clauses.size() +
1563 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1564 OMPTeamsDistributeDirective *Dir = new (Mem) OMPTeamsDistributeDirective(
1565 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1566 Dir->setClauses(Clauses);
1567 Dir->setAssociatedStmt(AssociatedStmt);
1568 Dir->setIterationVariable(Exprs.IterationVarRef);
1569 Dir->setLastIteration(Exprs.LastIteration);
1570 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1571 Dir->setPreCond(Exprs.PreCond);
1572 Dir->setCond(Exprs.Cond);
1573 Dir->setInit(Exprs.Init);
1574 Dir->setInc(Exprs.Inc);
1575 Dir->setIsLastIterVariable(Exprs.IL);
1576 Dir->setLowerBoundVariable(Exprs.LB);
1577 Dir->setUpperBoundVariable(Exprs.UB);
1578 Dir->setStrideVariable(Exprs.ST);
1579 Dir->setEnsureUpperBound(Exprs.EUB);
1580 Dir->setNextLowerBound(Exprs.NLB);
1581 Dir->setNextUpperBound(Exprs.NUB);
1582 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li02532872016-08-05 14:37:37 +00001583 Dir->setCounters(Exprs.Counters);
1584 Dir->setPrivateCounters(Exprs.PrivateCounters);
1585 Dir->setInits(Exprs.Inits);
1586 Dir->setUpdates(Exprs.Updates);
1587 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001588 Dir->setDependentCounters(Exprs.DependentCounters);
1589 Dir->setDependentInits(Exprs.DependentInits);
1590 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li02532872016-08-05 14:37:37 +00001591 Dir->setPreInits(Exprs.PreInits);
1592 return Dir;
1593}
1594
1595OMPTeamsDistributeDirective *
1596OMPTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1597 unsigned NumClauses,
1598 unsigned CollapsedNum, EmptyShell) {
Benjamin Kramerc3f89252016-10-20 14:27:22 +00001599 unsigned Size =
1600 llvm::alignTo(sizeof(OMPTeamsDistributeDirective), alignof(OMPClause *));
Kelvin Li02532872016-08-05 14:37:37 +00001601 void *Mem = C.Allocate(
1602 Size + sizeof(OMPClause *) * NumClauses +
1603 sizeof(Stmt *) * numLoopChildren(CollapsedNum, OMPD_teams_distribute));
1604 return new (Mem) OMPTeamsDistributeDirective(CollapsedNum, NumClauses);
1605}
Kelvin Li4e325f72016-10-25 12:50:55 +00001606
1607OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::Create(
1608 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1609 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1610 const HelperExprs &Exprs) {
1611 unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1612 alignof(OMPClause *));
1613 void *Mem =
1614 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1615 sizeof(Stmt *) *
1616 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1617 OMPTeamsDistributeSimdDirective *Dir =
1618 new (Mem) OMPTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
1619 Clauses.size());
1620 Dir->setClauses(Clauses);
1621 Dir->setAssociatedStmt(AssociatedStmt);
1622 Dir->setIterationVariable(Exprs.IterationVarRef);
1623 Dir->setLastIteration(Exprs.LastIteration);
1624 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1625 Dir->setPreCond(Exprs.PreCond);
1626 Dir->setCond(Exprs.Cond);
1627 Dir->setInit(Exprs.Init);
1628 Dir->setInc(Exprs.Inc);
1629 Dir->setIsLastIterVariable(Exprs.IL);
1630 Dir->setLowerBoundVariable(Exprs.LB);
1631 Dir->setUpperBoundVariable(Exprs.UB);
1632 Dir->setStrideVariable(Exprs.ST);
1633 Dir->setEnsureUpperBound(Exprs.EUB);
1634 Dir->setNextLowerBound(Exprs.NLB);
1635 Dir->setNextUpperBound(Exprs.NUB);
1636 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li4e325f72016-10-25 12:50:55 +00001637 Dir->setCounters(Exprs.Counters);
1638 Dir->setPrivateCounters(Exprs.PrivateCounters);
1639 Dir->setInits(Exprs.Inits);
1640 Dir->setUpdates(Exprs.Updates);
1641 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001642 Dir->setDependentCounters(Exprs.DependentCounters);
1643 Dir->setDependentInits(Exprs.DependentInits);
1644 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li4e325f72016-10-25 12:50:55 +00001645 Dir->setPreInits(Exprs.PreInits);
1646 return Dir;
1647}
1648
1649OMPTeamsDistributeSimdDirective *OMPTeamsDistributeSimdDirective::CreateEmpty(
1650 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
1651 EmptyShell) {
1652 unsigned Size = llvm::alignTo(sizeof(OMPTeamsDistributeSimdDirective),
1653 alignof(OMPClause *));
1654 void *Mem =
1655 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1656 sizeof(Stmt *) *
1657 numLoopChildren(CollapsedNum, OMPD_teams_distribute_simd));
1658 return new (Mem) OMPTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
1659}
Kelvin Li579e41c2016-11-30 23:51:03 +00001660
1661OMPTeamsDistributeParallelForSimdDirective *
1662OMPTeamsDistributeParallelForSimdDirective::Create(
1663 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1664 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1665 const HelperExprs &Exprs) {
1666 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1667 alignof(OMPClause *));
1668 void *Mem =
1669 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() +
1670 sizeof(Stmt *) *
1671 numLoopChildren(CollapsedNum,
1672 OMPD_teams_distribute_parallel_for_simd));
1673 OMPTeamsDistributeParallelForSimdDirective *Dir = new (Mem)
1674 OMPTeamsDistributeParallelForSimdDirective(StartLoc, EndLoc, CollapsedNum,
1675 Clauses.size());
1676 Dir->setClauses(Clauses);
1677 Dir->setAssociatedStmt(AssociatedStmt);
1678 Dir->setIterationVariable(Exprs.IterationVarRef);
1679 Dir->setLastIteration(Exprs.LastIteration);
1680 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1681 Dir->setPreCond(Exprs.PreCond);
1682 Dir->setCond(Exprs.Cond);
1683 Dir->setInit(Exprs.Init);
1684 Dir->setInc(Exprs.Inc);
1685 Dir->setIsLastIterVariable(Exprs.IL);
1686 Dir->setLowerBoundVariable(Exprs.LB);
1687 Dir->setUpperBoundVariable(Exprs.UB);
1688 Dir->setStrideVariable(Exprs.ST);
1689 Dir->setEnsureUpperBound(Exprs.EUB);
1690 Dir->setNextLowerBound(Exprs.NLB);
1691 Dir->setNextUpperBound(Exprs.NUB);
1692 Dir->setNumIterations(Exprs.NumIterations);
1693 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1694 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001695 Dir->setDistInc(Exprs.DistInc);
1696 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li579e41c2016-11-30 23:51:03 +00001697 Dir->setCounters(Exprs.Counters);
1698 Dir->setPrivateCounters(Exprs.PrivateCounters);
1699 Dir->setInits(Exprs.Inits);
1700 Dir->setUpdates(Exprs.Updates);
1701 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001702 Dir->setDependentCounters(Exprs.DependentCounters);
1703 Dir->setDependentInits(Exprs.DependentInits);
1704 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li579e41c2016-11-30 23:51:03 +00001705 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001706 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1707 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1708 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1709 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1710 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1711 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1712 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001713 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1714 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li579e41c2016-11-30 23:51:03 +00001715 return Dir;
1716}
1717
1718OMPTeamsDistributeParallelForSimdDirective *
1719OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(const ASTContext &C,
1720 unsigned NumClauses,
1721 unsigned CollapsedNum,
1722 EmptyShell) {
1723 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForSimdDirective),
1724 alignof(OMPClause *));
1725 void *Mem =
1726 C.Allocate(Size + sizeof(OMPClause *) * NumClauses +
1727 sizeof(Stmt *) *
1728 numLoopChildren(CollapsedNum,
1729 OMPD_teams_distribute_parallel_for_simd));
1730 return new (Mem)
1731 OMPTeamsDistributeParallelForSimdDirective(CollapsedNum, NumClauses);
1732}
Kelvin Li7ade93f2016-12-09 03:24:30 +00001733
1734OMPTeamsDistributeParallelForDirective *
1735OMPTeamsDistributeParallelForDirective::Create(
1736 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1737 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001738 const HelperExprs &Exprs, bool HasCancel) {
Kelvin Li7ade93f2016-12-09 03:24:30 +00001739 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1740 alignof(OMPClause *));
1741 void *Mem = C.Allocate(
1742 Size + sizeof(OMPClause *) * Clauses.size() +
1743 sizeof(Stmt *) *
1744 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1745 OMPTeamsDistributeParallelForDirective *Dir = new (Mem)
1746 OMPTeamsDistributeParallelForDirective(StartLoc, EndLoc, CollapsedNum,
1747 Clauses.size());
1748 Dir->setClauses(Clauses);
1749 Dir->setAssociatedStmt(AssociatedStmt);
1750 Dir->setIterationVariable(Exprs.IterationVarRef);
1751 Dir->setLastIteration(Exprs.LastIteration);
1752 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1753 Dir->setPreCond(Exprs.PreCond);
1754 Dir->setCond(Exprs.Cond);
1755 Dir->setInit(Exprs.Init);
1756 Dir->setInc(Exprs.Inc);
1757 Dir->setIsLastIterVariable(Exprs.IL);
1758 Dir->setLowerBoundVariable(Exprs.LB);
1759 Dir->setUpperBoundVariable(Exprs.UB);
1760 Dir->setStrideVariable(Exprs.ST);
1761 Dir->setEnsureUpperBound(Exprs.EUB);
1762 Dir->setNextLowerBound(Exprs.NLB);
1763 Dir->setNextUpperBound(Exprs.NUB);
1764 Dir->setNumIterations(Exprs.NumIterations);
1765 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1766 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001767 Dir->setDistInc(Exprs.DistInc);
1768 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li7ade93f2016-12-09 03:24:30 +00001769 Dir->setCounters(Exprs.Counters);
1770 Dir->setPrivateCounters(Exprs.PrivateCounters);
1771 Dir->setInits(Exprs.Inits);
1772 Dir->setUpdates(Exprs.Updates);
1773 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001774 Dir->setDependentCounters(Exprs.DependentCounters);
1775 Dir->setDependentInits(Exprs.DependentInits);
1776 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li7ade93f2016-12-09 03:24:30 +00001777 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001778 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1779 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1780 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1781 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1782 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1783 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1784 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001785 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1786 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataevdcb4b8fb2017-11-22 20:19:50 +00001787 Dir->HasCancel = HasCancel;
Kelvin Li7ade93f2016-12-09 03:24:30 +00001788 return Dir;
1789}
1790
1791OMPTeamsDistributeParallelForDirective *
1792OMPTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1793 unsigned NumClauses,
1794 unsigned CollapsedNum,
1795 EmptyShell) {
1796 auto Size = llvm::alignTo(sizeof(OMPTeamsDistributeParallelForDirective),
1797 alignof(OMPClause *));
1798 void *Mem = C.Allocate(
1799 Size + sizeof(OMPClause *) * NumClauses +
1800 sizeof(Stmt *) *
1801 numLoopChildren(CollapsedNum, OMPD_teams_distribute_parallel_for));
1802 return new (Mem)
1803 OMPTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1804}
1805
Kelvin Libf594a52016-12-17 05:48:59 +00001806OMPTargetTeamsDirective *OMPTargetTeamsDirective::Create(
1807 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1808 ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt) {
1809 auto Size =
1810 llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1811 void *Mem =
1812 C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));
1813 OMPTargetTeamsDirective *Dir =
1814 new (Mem) OMPTargetTeamsDirective(StartLoc, EndLoc, Clauses.size());
1815 Dir->setClauses(Clauses);
1816 Dir->setAssociatedStmt(AssociatedStmt);
1817 return Dir;
1818}
1819
1820OMPTargetTeamsDirective *
1821OMPTargetTeamsDirective::CreateEmpty(const ASTContext &C, unsigned NumClauses,
1822 EmptyShell) {
1823 auto Size =
1824 llvm::alignTo(sizeof(OMPTargetTeamsDirective), alignof(OMPClause *));
1825 void *Mem =
1826 C.Allocate(Size + sizeof(OMPClause *) * NumClauses + sizeof(Stmt *));
1827 return new (Mem) OMPTargetTeamsDirective(NumClauses);
1828}
Kelvin Li83c451e2016-12-25 04:52:54 +00001829
1830OMPTargetTeamsDistributeDirective *OMPTargetTeamsDistributeDirective::Create(
1831 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1832 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1833 const HelperExprs &Exprs) {
1834 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1835 alignof(OMPClause *));
1836 void *Mem = C.Allocate(
1837 Size + sizeof(OMPClause *) * Clauses.size() +
1838 sizeof(Stmt *) *
1839 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1840 OMPTargetTeamsDistributeDirective *Dir =
1841 new (Mem) OMPTargetTeamsDistributeDirective(StartLoc, EndLoc, CollapsedNum,
1842 Clauses.size());
1843 Dir->setClauses(Clauses);
1844 Dir->setAssociatedStmt(AssociatedStmt);
1845 Dir->setIterationVariable(Exprs.IterationVarRef);
1846 Dir->setLastIteration(Exprs.LastIteration);
1847 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1848 Dir->setPreCond(Exprs.PreCond);
1849 Dir->setCond(Exprs.Cond);
1850 Dir->setInit(Exprs.Init);
1851 Dir->setInc(Exprs.Inc);
1852 Dir->setIsLastIterVariable(Exprs.IL);
1853 Dir->setLowerBoundVariable(Exprs.LB);
1854 Dir->setUpperBoundVariable(Exprs.UB);
1855 Dir->setStrideVariable(Exprs.ST);
1856 Dir->setEnsureUpperBound(Exprs.EUB);
1857 Dir->setNextLowerBound(Exprs.NLB);
1858 Dir->setNextUpperBound(Exprs.NUB);
1859 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Li83c451e2016-12-25 04:52:54 +00001860 Dir->setCounters(Exprs.Counters);
1861 Dir->setPrivateCounters(Exprs.PrivateCounters);
1862 Dir->setInits(Exprs.Inits);
1863 Dir->setUpdates(Exprs.Updates);
1864 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001865 Dir->setDependentCounters(Exprs.DependentCounters);
1866 Dir->setDependentInits(Exprs.DependentInits);
1867 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li83c451e2016-12-25 04:52:54 +00001868 Dir->setPreInits(Exprs.PreInits);
1869 return Dir;
1870}
1871
1872OMPTargetTeamsDistributeDirective *
1873OMPTargetTeamsDistributeDirective::CreateEmpty(const ASTContext &C,
1874 unsigned NumClauses,
1875 unsigned CollapsedNum,
1876 EmptyShell) {
1877 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeDirective),
1878 alignof(OMPClause *));
1879 void *Mem = C.Allocate(
1880 Size + sizeof(OMPClause *) * NumClauses +
1881 sizeof(Stmt *) *
1882 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute));
1883 return new (Mem) OMPTargetTeamsDistributeDirective(CollapsedNum, NumClauses);
1884}
Kelvin Li80e8f562016-12-29 22:16:30 +00001885
1886OMPTargetTeamsDistributeParallelForDirective *
1887OMPTargetTeamsDistributeParallelForDirective::Create(
1888 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1889 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Alexey Bataev16e79882017-11-22 21:12:03 +00001890 const HelperExprs &Exprs, bool HasCancel) {
Kelvin Li80e8f562016-12-29 22:16:30 +00001891 auto Size =
1892 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1893 alignof(OMPClause *));
1894 void *Mem = C.Allocate(
1895 Size + sizeof(OMPClause *) * Clauses.size() +
1896 sizeof(Stmt *) *
1897 numLoopChildren(CollapsedNum,
1898 OMPD_target_teams_distribute_parallel_for));
1899 OMPTargetTeamsDistributeParallelForDirective *Dir =
1900 new (Mem) OMPTargetTeamsDistributeParallelForDirective(
1901 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1902 Dir->setClauses(Clauses);
1903 Dir->setAssociatedStmt(AssociatedStmt);
1904 Dir->setIterationVariable(Exprs.IterationVarRef);
1905 Dir->setLastIteration(Exprs.LastIteration);
1906 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1907 Dir->setPreCond(Exprs.PreCond);
1908 Dir->setCond(Exprs.Cond);
1909 Dir->setInit(Exprs.Init);
1910 Dir->setInc(Exprs.Inc);
1911 Dir->setIsLastIterVariable(Exprs.IL);
1912 Dir->setLowerBoundVariable(Exprs.LB);
1913 Dir->setUpperBoundVariable(Exprs.UB);
1914 Dir->setStrideVariable(Exprs.ST);
1915 Dir->setEnsureUpperBound(Exprs.EUB);
1916 Dir->setNextLowerBound(Exprs.NLB);
1917 Dir->setNextUpperBound(Exprs.NUB);
1918 Dir->setNumIterations(Exprs.NumIterations);
1919 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1920 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001921 Dir->setDistInc(Exprs.DistInc);
1922 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li80e8f562016-12-29 22:16:30 +00001923 Dir->setCounters(Exprs.Counters);
1924 Dir->setPrivateCounters(Exprs.PrivateCounters);
1925 Dir->setInits(Exprs.Inits);
1926 Dir->setUpdates(Exprs.Updates);
1927 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00001928 Dir->setDependentCounters(Exprs.DependentCounters);
1929 Dir->setDependentInits(Exprs.DependentInits);
1930 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li80e8f562016-12-29 22:16:30 +00001931 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00001932 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
1933 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
1934 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
1935 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
1936 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
1937 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
1938 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00001939 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
1940 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Alexey Bataev16e79882017-11-22 21:12:03 +00001941 Dir->HasCancel = HasCancel;
Kelvin Li80e8f562016-12-29 22:16:30 +00001942 return Dir;
1943}
1944
1945OMPTargetTeamsDistributeParallelForDirective *
1946OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(const ASTContext &C,
1947 unsigned NumClauses,
1948 unsigned CollapsedNum,
1949 EmptyShell) {
1950 auto Size =
1951 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForDirective),
1952 alignof(OMPClause *));
1953 void *Mem = C.Allocate(
1954 Size + sizeof(OMPClause *) * NumClauses +
1955 sizeof(Stmt *) *
1956 numLoopChildren(CollapsedNum,
1957 OMPD_target_teams_distribute_parallel_for));
1958 return new (Mem)
1959 OMPTargetTeamsDistributeParallelForDirective(CollapsedNum, NumClauses);
1960}
Kelvin Li1851df52017-01-03 05:23:48 +00001961
1962OMPTargetTeamsDistributeParallelForSimdDirective *
1963OMPTargetTeamsDistributeParallelForSimdDirective::Create(
1964 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
1965 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
1966 const HelperExprs &Exprs) {
1967 auto Size =
1968 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
1969 alignof(OMPClause *));
1970 void *Mem = C.Allocate(
1971 Size + sizeof(OMPClause *) * Clauses.size() +
1972 sizeof(Stmt *) *
1973 numLoopChildren(CollapsedNum,
1974 OMPD_target_teams_distribute_parallel_for_simd));
1975 OMPTargetTeamsDistributeParallelForSimdDirective *Dir =
1976 new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
1977 StartLoc, EndLoc, CollapsedNum, Clauses.size());
1978 Dir->setClauses(Clauses);
1979 Dir->setAssociatedStmt(AssociatedStmt);
1980 Dir->setIterationVariable(Exprs.IterationVarRef);
1981 Dir->setLastIteration(Exprs.LastIteration);
1982 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
1983 Dir->setPreCond(Exprs.PreCond);
1984 Dir->setCond(Exprs.Cond);
1985 Dir->setInit(Exprs.Init);
1986 Dir->setInc(Exprs.Inc);
1987 Dir->setIsLastIterVariable(Exprs.IL);
1988 Dir->setLowerBoundVariable(Exprs.LB);
1989 Dir->setUpperBoundVariable(Exprs.UB);
1990 Dir->setStrideVariable(Exprs.ST);
1991 Dir->setEnsureUpperBound(Exprs.EUB);
1992 Dir->setNextLowerBound(Exprs.NLB);
1993 Dir->setNextUpperBound(Exprs.NUB);
1994 Dir->setNumIterations(Exprs.NumIterations);
1995 Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
1996 Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
Carlo Bertolli8429d812017-02-17 21:29:13 +00001997 Dir->setDistInc(Exprs.DistInc);
1998 Dir->setPrevEnsureUpperBound(Exprs.PrevEUB);
Kelvin Li1851df52017-01-03 05:23:48 +00001999 Dir->setCounters(Exprs.Counters);
2000 Dir->setPrivateCounters(Exprs.PrivateCounters);
2001 Dir->setInits(Exprs.Inits);
2002 Dir->setUpdates(Exprs.Updates);
2003 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002004 Dir->setDependentCounters(Exprs.DependentCounters);
2005 Dir->setDependentInits(Exprs.DependentInits);
2006 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Li1851df52017-01-03 05:23:48 +00002007 Dir->setPreInits(Exprs.PreInits);
Carlo Bertolliffafe102017-04-20 00:39:39 +00002008 Dir->setCombinedLowerBoundVariable(Exprs.DistCombinedFields.LB);
2009 Dir->setCombinedUpperBoundVariable(Exprs.DistCombinedFields.UB);
2010 Dir->setCombinedEnsureUpperBound(Exprs.DistCombinedFields.EUB);
2011 Dir->setCombinedInit(Exprs.DistCombinedFields.Init);
2012 Dir->setCombinedCond(Exprs.DistCombinedFields.Cond);
2013 Dir->setCombinedNextLowerBound(Exprs.DistCombinedFields.NLB);
2014 Dir->setCombinedNextUpperBound(Exprs.DistCombinedFields.NUB);
Gheorghe-Teodor Berceae9256762018-10-29 15:45:47 +00002015 Dir->setCombinedDistCond(Exprs.DistCombinedFields.DistCond);
2016 Dir->setCombinedParForInDistCond(Exprs.DistCombinedFields.ParForInDistCond);
Kelvin Li1851df52017-01-03 05:23:48 +00002017 return Dir;
2018}
2019
2020OMPTargetTeamsDistributeParallelForSimdDirective *
2021OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
2022 const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
2023 EmptyShell) {
2024 auto Size =
2025 llvm::alignTo(sizeof(OMPTargetTeamsDistributeParallelForSimdDirective),
2026 alignof(OMPClause *));
2027 void *Mem = C.Allocate(
2028 Size + sizeof(OMPClause *) * NumClauses +
2029 sizeof(Stmt *) *
2030 numLoopChildren(CollapsedNum,
2031 OMPD_target_teams_distribute_parallel_for_simd));
2032 return new (Mem) OMPTargetTeamsDistributeParallelForSimdDirective(
2033 CollapsedNum, NumClauses);
2034}
2035
Kelvin Lida681182017-01-10 18:08:18 +00002036OMPTargetTeamsDistributeSimdDirective *
2037OMPTargetTeamsDistributeSimdDirective::Create(
2038 const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
2039 unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
2040 const HelperExprs &Exprs) {
2041 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
2042 alignof(OMPClause *));
2043 void *Mem = C.Allocate(
2044 Size + sizeof(OMPClause *) * Clauses.size() +
2045 sizeof(Stmt *) *
2046 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
2047 OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
2048 OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
2049 Clauses.size());
2050 Dir->setClauses(Clauses);
2051 Dir->setAssociatedStmt(AssociatedStmt);
2052 Dir->setIterationVariable(Exprs.IterationVarRef);
2053 Dir->setLastIteration(Exprs.LastIteration);
2054 Dir->setCalcLastIteration(Exprs.CalcLastIteration);
2055 Dir->setPreCond(Exprs.PreCond);
2056 Dir->setCond(Exprs.Cond);
2057 Dir->setInit(Exprs.Init);
2058 Dir->setInc(Exprs.Inc);
2059 Dir->setIsLastIterVariable(Exprs.IL);
2060 Dir->setLowerBoundVariable(Exprs.LB);
2061 Dir->setUpperBoundVariable(Exprs.UB);
2062 Dir->setStrideVariable(Exprs.ST);
2063 Dir->setEnsureUpperBound(Exprs.EUB);
2064 Dir->setNextLowerBound(Exprs.NLB);
2065 Dir->setNextUpperBound(Exprs.NUB);
2066 Dir->setNumIterations(Exprs.NumIterations);
Kelvin Lida681182017-01-10 18:08:18 +00002067 Dir->setCounters(Exprs.Counters);
2068 Dir->setPrivateCounters(Exprs.PrivateCounters);
2069 Dir->setInits(Exprs.Inits);
2070 Dir->setUpdates(Exprs.Updates);
2071 Dir->setFinals(Exprs.Finals);
Alexey Bataevf8be4762019-08-14 19:30:06 +00002072 Dir->setDependentCounters(Exprs.DependentCounters);
2073 Dir->setDependentInits(Exprs.DependentInits);
2074 Dir->setFinalsConditions(Exprs.FinalsConditions);
Kelvin Lida681182017-01-10 18:08:18 +00002075 Dir->setPreInits(Exprs.PreInits);
2076 return Dir;
2077}
2078
2079OMPTargetTeamsDistributeSimdDirective *
2080OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
2081 unsigned NumClauses,
2082 unsigned CollapsedNum,
2083 EmptyShell) {
2084 auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
2085 alignof(OMPClause *));
2086 void *Mem = C.Allocate(
2087 Size + sizeof(OMPClause *) * NumClauses +
2088 sizeof(Stmt *) *
2089 numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
2090 return new (Mem)
2091 OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
2092}