clang  5.0.0
OpenMPClause.cpp
Go to the documentation of this file.
1 //===--- OpenMPClause.cpp - Classes for OpenMP clauses --------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the subclesses of Stmt class declared in OpenMPClause.h
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/AST/OpenMPClause.h"
15 
16 #include "clang/AST/ASTContext.h"
17 
18 using namespace clang;
19 
21  switch (getClauseKind()) {
22  default:
23  break;
24 #define OPENMP_CLAUSE(Name, Class) \
25  case OMPC_##Name: \
26  return static_cast<Class *>(this)->children();
27 #include "clang/Basic/OpenMPKinds.def"
28  }
29  llvm_unreachable("unknown OMPClause");
30 }
31 
33  auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
34  return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
35 }
36 
38  switch (C->getClauseKind()) {
39  case OMPC_schedule:
40  return static_cast<const OMPScheduleClause *>(C);
41  case OMPC_dist_schedule:
42  return static_cast<const OMPDistScheduleClause *>(C);
43  case OMPC_firstprivate:
44  return static_cast<const OMPFirstprivateClause *>(C);
45  case OMPC_lastprivate:
46  return static_cast<const OMPLastprivateClause *>(C);
47  case OMPC_reduction:
48  return static_cast<const OMPReductionClause *>(C);
49  case OMPC_task_reduction:
50  return static_cast<const OMPTaskReductionClause *>(C);
51  case OMPC_linear:
52  return static_cast<const OMPLinearClause *>(C);
53  case OMPC_if:
54  return static_cast<const OMPIfClause *>(C);
55  case OMPC_num_threads:
56  return static_cast<const OMPNumThreadsClause *>(C);
57  case OMPC_num_teams:
58  return static_cast<const OMPNumTeamsClause *>(C);
59  case OMPC_thread_limit:
60  return static_cast<const OMPThreadLimitClause *>(C);
61  case OMPC_default:
62  case OMPC_proc_bind:
63  case OMPC_final:
64  case OMPC_safelen:
65  case OMPC_simdlen:
66  case OMPC_collapse:
67  case OMPC_private:
68  case OMPC_shared:
69  case OMPC_aligned:
70  case OMPC_copyin:
71  case OMPC_copyprivate:
72  case OMPC_ordered:
73  case OMPC_nowait:
74  case OMPC_untied:
75  case OMPC_mergeable:
76  case OMPC_threadprivate:
77  case OMPC_flush:
78  case OMPC_read:
79  case OMPC_write:
80  case OMPC_update:
81  case OMPC_capture:
82  case OMPC_seq_cst:
83  case OMPC_depend:
84  case OMPC_device:
85  case OMPC_threads:
86  case OMPC_simd:
87  case OMPC_map:
88  case OMPC_priority:
89  case OMPC_grainsize:
90  case OMPC_nogroup:
91  case OMPC_num_tasks:
92  case OMPC_hint:
93  case OMPC_defaultmap:
94  case OMPC_unknown:
95  case OMPC_uniform:
96  case OMPC_to:
97  case OMPC_from:
98  case OMPC_use_device_ptr:
99  case OMPC_is_device_ptr:
100  break;
101  }
102 
103  return nullptr;
104 }
105 
107  auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
108  return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
109 }
110 
112  switch (C->getClauseKind()) {
113  case OMPC_lastprivate:
114  return static_cast<const OMPLastprivateClause *>(C);
115  case OMPC_reduction:
116  return static_cast<const OMPReductionClause *>(C);
117  case OMPC_task_reduction:
118  return static_cast<const OMPTaskReductionClause *>(C);
119  case OMPC_linear:
120  return static_cast<const OMPLinearClause *>(C);
121  case OMPC_schedule:
122  case OMPC_dist_schedule:
123  case OMPC_firstprivate:
124  case OMPC_default:
125  case OMPC_proc_bind:
126  case OMPC_if:
127  case OMPC_final:
128  case OMPC_num_threads:
129  case OMPC_safelen:
130  case OMPC_simdlen:
131  case OMPC_collapse:
132  case OMPC_private:
133  case OMPC_shared:
134  case OMPC_aligned:
135  case OMPC_copyin:
136  case OMPC_copyprivate:
137  case OMPC_ordered:
138  case OMPC_nowait:
139  case OMPC_untied:
140  case OMPC_mergeable:
141  case OMPC_threadprivate:
142  case OMPC_flush:
143  case OMPC_read:
144  case OMPC_write:
145  case OMPC_update:
146  case OMPC_capture:
147  case OMPC_seq_cst:
148  case OMPC_depend:
149  case OMPC_device:
150  case OMPC_threads:
151  case OMPC_simd:
152  case OMPC_map:
153  case OMPC_num_teams:
154  case OMPC_thread_limit:
155  case OMPC_priority:
156  case OMPC_grainsize:
157  case OMPC_nogroup:
158  case OMPC_num_tasks:
159  case OMPC_hint:
160  case OMPC_defaultmap:
161  case OMPC_unknown:
162  case OMPC_uniform:
163  case OMPC_to:
164  case OMPC_from:
165  case OMPC_use_device_ptr:
166  case OMPC_is_device_ptr:
167  break;
168  }
169 
170  return nullptr;
171 }
172 
173 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
174  assert(VL.size() == varlist_size() &&
175  "Number of private copies is not the same as the preallocated buffer");
176  std::copy(VL.begin(), VL.end(), varlist_end());
177 }
178 
181  SourceLocation LParenLoc, SourceLocation EndLoc,
182  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
183  // Allocate space for private variables and initializer expressions.
184  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
185  OMPPrivateClause *Clause =
186  new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
187  Clause->setVarRefs(VL);
188  Clause->setPrivateCopies(PrivateVL);
189  return Clause;
190 }
191 
193  unsigned N) {
194  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
195  return new (Mem) OMPPrivateClause(N);
196 }
197 
198 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
199  assert(VL.size() == varlist_size() &&
200  "Number of private copies is not the same as the preallocated buffer");
201  std::copy(VL.begin(), VL.end(), varlist_end());
202 }
203 
204 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
205  assert(VL.size() == varlist_size() &&
206  "Number of inits is not the same as the preallocated buffer");
207  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
208 }
209 
212  SourceLocation LParenLoc, SourceLocation EndLoc,
213  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
214  ArrayRef<Expr *> InitVL, Stmt *PreInit) {
215  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
216  OMPFirstprivateClause *Clause =
217  new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
218  Clause->setVarRefs(VL);
219  Clause->setPrivateCopies(PrivateVL);
220  Clause->setInits(InitVL);
221  Clause->setPreInitStmt(PreInit);
222  return Clause;
223 }
224 
226  unsigned N) {
227  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
228  return new (Mem) OMPFirstprivateClause(N);
229 }
230 
232  assert(PrivateCopies.size() == varlist_size() &&
233  "Number of private copies is not the same as the preallocated buffer");
234  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
235 }
236 
237 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
238  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
239  "not the same as the "
240  "preallocated buffer");
241  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
242 }
243 
244 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
245  assert(DstExprs.size() == varlist_size() && "Number of destination "
246  "expressions is not the same as "
247  "the preallocated buffer");
248  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
249 }
250 
251 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
252  assert(AssignmentOps.size() == varlist_size() &&
253  "Number of assignment expressions is not the same as the preallocated "
254  "buffer");
255  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
256  getDestinationExprs().end());
257 }
258 
260  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
261  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
262  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit,
263  Expr *PostUpdate) {
264  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
265  OMPLastprivateClause *Clause =
266  new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
267  Clause->setVarRefs(VL);
268  Clause->setSourceExprs(SrcExprs);
269  Clause->setDestinationExprs(DstExprs);
270  Clause->setAssignmentOps(AssignmentOps);
271  Clause->setPreInitStmt(PreInit);
272  Clause->setPostUpdateExpr(PostUpdate);
273  return Clause;
274 }
275 
277  unsigned N) {
278  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
279  return new (Mem) OMPLastprivateClause(N);
280 }
281 
283  SourceLocation StartLoc,
284  SourceLocation LParenLoc,
285  SourceLocation EndLoc,
286  ArrayRef<Expr *> VL) {
287  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
288  OMPSharedClause *Clause =
289  new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
290  Clause->setVarRefs(VL);
291  return Clause;
292 }
293 
295  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
296  return new (Mem) OMPSharedClause(N);
297 }
298 
300  assert(PL.size() == varlist_size() &&
301  "Number of privates is not the same as the preallocated buffer");
302  std::copy(PL.begin(), PL.end(), varlist_end());
303 }
304 
306  assert(IL.size() == varlist_size() &&
307  "Number of inits is not the same as the preallocated buffer");
308  std::copy(IL.begin(), IL.end(), getPrivates().end());
309 }
310 
312  assert(UL.size() == varlist_size() &&
313  "Number of updates is not the same as the preallocated buffer");
314  std::copy(UL.begin(), UL.end(), getInits().end());
315 }
316 
318  assert(FL.size() == varlist_size() &&
319  "Number of final updates is not the same as the preallocated buffer");
320  std::copy(FL.begin(), FL.end(), getUpdates().end());
321 }
322 
324  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
328  Stmt *PreInit, Expr *PostUpdate) {
329  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
330  // (Step and CalcStep).
331  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
332  OMPLinearClause *Clause = new (Mem) OMPLinearClause(
333  StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
334  Clause->setVarRefs(VL);
335  Clause->setPrivates(PL);
336  Clause->setInits(IL);
337  // Fill update and final expressions with zeroes, they are provided later,
338  // after the directive construction.
339  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
340  nullptr);
341  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
342  nullptr);
343  Clause->setStep(Step);
344  Clause->setCalcStep(CalcStep);
345  Clause->setPreInitStmt(PreInit);
346  Clause->setPostUpdateExpr(PostUpdate);
347  return Clause;
348 }
349 
351  unsigned NumVars) {
352  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
353  // (Step and CalcStep).
354  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
355  return new (Mem) OMPLinearClause(NumVars);
356 }
357 
360  SourceLocation LParenLoc, SourceLocation ColonLoc,
361  SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
362  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
363  OMPAlignedClause *Clause = new (Mem)
364  OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
365  Clause->setVarRefs(VL);
366  Clause->setAlignment(A);
367  return Clause;
368 }
369 
371  unsigned NumVars) {
372  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
373  return new (Mem) OMPAlignedClause(NumVars);
374 }
375 
376 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
377  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
378  "not the same as the "
379  "preallocated buffer");
380  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
381 }
382 
383 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
384  assert(DstExprs.size() == varlist_size() && "Number of destination "
385  "expressions is not the same as "
386  "the preallocated buffer");
387  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
388 }
389 
390 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
391  assert(AssignmentOps.size() == varlist_size() &&
392  "Number of assignment expressions is not the same as the preallocated "
393  "buffer");
394  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
395  getDestinationExprs().end());
396 }
397 
399  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
400  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
401  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
402  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
403  OMPCopyinClause *Clause =
404  new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
405  Clause->setVarRefs(VL);
406  Clause->setSourceExprs(SrcExprs);
407  Clause->setDestinationExprs(DstExprs);
408  Clause->setAssignmentOps(AssignmentOps);
409  return Clause;
410 }
411 
413  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
414  return new (Mem) OMPCopyinClause(N);
415 }
416 
417 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
418  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
419  "not the same as the "
420  "preallocated buffer");
421  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
422 }
423 
424 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
425  assert(DstExprs.size() == varlist_size() && "Number of destination "
426  "expressions is not the same as "
427  "the preallocated buffer");
428  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
429 }
430 
431 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
432  assert(AssignmentOps.size() == varlist_size() &&
433  "Number of assignment expressions is not the same as the preallocated "
434  "buffer");
435  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
436  getDestinationExprs().end());
437 }
438 
440  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
441  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
442  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
443  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
444  OMPCopyprivateClause *Clause =
445  new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
446  Clause->setVarRefs(VL);
447  Clause->setSourceExprs(SrcExprs);
448  Clause->setDestinationExprs(DstExprs);
449  Clause->setAssignmentOps(AssignmentOps);
450  return Clause;
451 }
452 
454  unsigned N) {
455  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
456  return new (Mem) OMPCopyprivateClause(N);
457 }
458 
459 void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
460  assert(Privates.size() == varlist_size() &&
461  "Number of private copies is not the same as the preallocated buffer");
462  std::copy(Privates.begin(), Privates.end(), varlist_end());
463 }
464 
465 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
466  assert(
467  LHSExprs.size() == varlist_size() &&
468  "Number of LHS expressions is not the same as the preallocated buffer");
469  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
470 }
471 
472 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
473  assert(
474  RHSExprs.size() == varlist_size() &&
475  "Number of RHS expressions is not the same as the preallocated buffer");
476  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
477 }
478 
479 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
480  assert(ReductionOps.size() == varlist_size() && "Number of reduction "
481  "expressions is not the same "
482  "as the preallocated buffer");
483  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
484 }
485 
487  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
488  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
489  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
490  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
491  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
492  Expr *PostUpdate) {
493  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
494  OMPReductionClause *Clause = new (Mem) OMPReductionClause(
495  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
496  Clause->setVarRefs(VL);
497  Clause->setPrivates(Privates);
498  Clause->setLHSExprs(LHSExprs);
499  Clause->setRHSExprs(RHSExprs);
500  Clause->setReductionOps(ReductionOps);
501  Clause->setPreInitStmt(PreInit);
502  Clause->setPostUpdateExpr(PostUpdate);
503  return Clause;
504 }
505 
507  unsigned N) {
508  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
509  return new (Mem) OMPReductionClause(N);
510 }
511 
512 void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
513  assert(Privates.size() == varlist_size() &&
514  "Number of private copies is not the same as the preallocated buffer");
515  std::copy(Privates.begin(), Privates.end(), varlist_end());
516 }
517 
518 void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
519  assert(
520  LHSExprs.size() == varlist_size() &&
521  "Number of LHS expressions is not the same as the preallocated buffer");
522  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
523 }
524 
525 void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
526  assert(
527  RHSExprs.size() == varlist_size() &&
528  "Number of RHS expressions is not the same as the preallocated buffer");
529  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
530 }
531 
532 void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
533  assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
534  "expressions is not the same "
535  "as the preallocated buffer");
536  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
537 }
538 
540  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
541  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
542  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
543  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
544  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
545  Expr *PostUpdate) {
546  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
548  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
549  Clause->setVarRefs(VL);
550  Clause->setPrivates(Privates);
551  Clause->setLHSExprs(LHSExprs);
552  Clause->setRHSExprs(RHSExprs);
553  Clause->setReductionOps(ReductionOps);
554  Clause->setPreInitStmt(PreInit);
555  Clause->setPostUpdateExpr(PostUpdate);
556  return Clause;
557 }
558 
560  unsigned N) {
561  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
562  return new (Mem) OMPTaskReductionClause(N);
563 }
564 
566  SourceLocation StartLoc,
567  SourceLocation LParenLoc,
568  SourceLocation EndLoc,
569  ArrayRef<Expr *> VL) {
570  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
571  OMPFlushClause *Clause =
572  new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
573  Clause->setVarRefs(VL);
574  return Clause;
575 }
576 
578  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
579  return new (Mem) OMPFlushClause(N);
580 }
581 
583  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
584  SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
585  SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
586  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
587  OMPDependClause *Clause =
588  new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
589  Clause->setVarRefs(VL);
590  Clause->setDependencyKind(DepKind);
591  Clause->setDependencyLoc(DepLoc);
592  Clause->setColonLoc(ColonLoc);
593  Clause->setCounterValue(nullptr);
594  return Clause;
595 }
596 
598  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
599  return new (Mem) OMPDependClause(N);
600 }
601 
603  assert(getDependencyKind() == OMPC_DEPEND_sink ||
604  getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
605  *getVarRefs().end() = V;
606 }
607 
609  auto *V = *getVarRefs().end();
610  assert(getDependencyKind() == OMPC_DEPEND_sink ||
611  getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
612  return V;
613 }
614 
616  auto *V = *getVarRefs().end();
617  assert(getDependencyKind() == OMPC_DEPEND_sink ||
618  getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
619  return V;
620 }
621 
623  MappableExprComponentListsRef ComponentLists) {
624  unsigned TotalNum = 0u;
625  for (auto &C : ComponentLists)
626  TotalNum += C.size();
627  return TotalNum;
628 }
629 
631  ArrayRef<ValueDecl *> Declarations) {
632  unsigned TotalNum = 0u;
633  llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
634  for (auto *D : Declarations) {
635  const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
636  if (Cache.count(VD))
637  continue;
638  ++TotalNum;
639  Cache.insert(VD);
640  }
641  return TotalNum;
642 }
643 
644 OMPMapClause *
646  SourceLocation LParenLoc, SourceLocation EndLoc,
647  ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
648  MappableExprComponentListsRef ComponentLists,
650  bool TypeIsImplicit, SourceLocation TypeLoc) {
651 
652  unsigned NumVars = Vars.size();
653  unsigned NumUniqueDeclarations =
654  getUniqueDeclarationsTotalNumber(Declarations);
655  unsigned NumComponentLists = ComponentLists.size();
656  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
657 
658  // We need to allocate:
659  // NumVars x Expr* - we have an original list expression for each clause list
660  // entry.
661  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
662  // with each component list.
663  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
664  // number of lists for each unique declaration and the size of each component
665  // list.
666  // NumComponents x MappableComponent - the total of all the components in all
667  // the lists.
668  void *Mem = C.Allocate(
669  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
671  NumVars, NumUniqueDeclarations,
672  NumUniqueDeclarations + NumComponentLists, NumComponents));
673  OMPMapClause *Clause = new (Mem) OMPMapClause(
674  TypeModifier, Type, TypeIsImplicit, TypeLoc, StartLoc, LParenLoc, EndLoc,
675  NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents);
676 
677  Clause->setVarRefs(Vars);
678  Clause->setClauseInfo(Declarations, ComponentLists);
679  Clause->setMapTypeModifier(TypeModifier);
680  Clause->setMapType(Type);
681  Clause->setMapLoc(TypeLoc);
682  return Clause;
683 }
684 
686  unsigned NumUniqueDeclarations,
687  unsigned NumComponentLists,
688  unsigned NumComponents) {
689  void *Mem = C.Allocate(
690  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
692  NumVars, NumUniqueDeclarations,
693  NumUniqueDeclarations + NumComponentLists, NumComponents));
694  return new (Mem) OMPMapClause(NumVars, NumUniqueDeclarations,
695  NumComponentLists, NumComponents);
696 }
697 
699  SourceLocation LParenLoc,
700  SourceLocation EndLoc, ArrayRef<Expr *> Vars,
701  ArrayRef<ValueDecl *> Declarations,
702  MappableExprComponentListsRef ComponentLists) {
703  unsigned NumVars = Vars.size();
704  unsigned NumUniqueDeclarations =
705  getUniqueDeclarationsTotalNumber(Declarations);
706  unsigned NumComponentLists = ComponentLists.size();
707  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
708 
709  // We need to allocate:
710  // NumVars x Expr* - we have an original list expression for each clause list
711  // entry.
712  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
713  // with each component list.
714  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
715  // number of lists for each unique declaration and the size of each component
716  // list.
717  // NumComponents x MappableComponent - the total of all the components in all
718  // the lists.
719  void *Mem = C.Allocate(
720  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
722  NumVars, NumUniqueDeclarations,
723  NumUniqueDeclarations + NumComponentLists, NumComponents));
724 
725  OMPToClause *Clause = new (Mem)
726  OMPToClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
727  NumComponentLists, NumComponents);
728 
729  Clause->setVarRefs(Vars);
730  Clause->setClauseInfo(Declarations, ComponentLists);
731  return Clause;
732 }
733 
734 OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
735  unsigned NumUniqueDeclarations,
736  unsigned NumComponentLists,
737  unsigned NumComponents) {
738  void *Mem = C.Allocate(
739  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
741  NumVars, NumUniqueDeclarations,
742  NumUniqueDeclarations + NumComponentLists, NumComponents));
743  return new (Mem) OMPToClause(NumVars, NumUniqueDeclarations,
744  NumComponentLists, NumComponents);
745 }
746 
749  SourceLocation LParenLoc, SourceLocation EndLoc,
750  ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
751  MappableExprComponentListsRef ComponentLists) {
752  unsigned NumVars = Vars.size();
753  unsigned NumUniqueDeclarations =
754  getUniqueDeclarationsTotalNumber(Declarations);
755  unsigned NumComponentLists = ComponentLists.size();
756  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
757 
758  // We need to allocate:
759  // NumVars x Expr* - we have an original list expression for each clause list
760  // entry.
761  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
762  // with each component list.
763  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
764  // number of lists for each unique declaration and the size of each component
765  // list.
766  // NumComponents x MappableComponent - the total of all the components in all
767  // the lists.
768  void *Mem = C.Allocate(
769  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
771  NumVars, NumUniqueDeclarations,
772  NumUniqueDeclarations + NumComponentLists, NumComponents));
773 
774  OMPFromClause *Clause = new (Mem)
775  OMPFromClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
776  NumComponentLists, NumComponents);
777 
778  Clause->setVarRefs(Vars);
779  Clause->setClauseInfo(Declarations, ComponentLists);
780  return Clause;
781 }
782 
784  unsigned NumUniqueDeclarations,
785  unsigned NumComponentLists,
786  unsigned NumComponents) {
787  void *Mem = C.Allocate(
788  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
790  NumVars, NumUniqueDeclarations,
791  NumUniqueDeclarations + NumComponentLists, NumComponents));
792  return new (Mem) OMPFromClause(NumVars, NumUniqueDeclarations,
793  NumComponentLists, NumComponents);
794 }
795 
796 void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
797  assert(VL.size() == varlist_size() &&
798  "Number of private copies is not the same as the preallocated buffer");
799  std::copy(VL.begin(), VL.end(), varlist_end());
800 }
801 
802 void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
803  assert(VL.size() == varlist_size() &&
804  "Number of inits is not the same as the preallocated buffer");
805  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
806 }
807 
809  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
810  SourceLocation EndLoc, ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
811  ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
812  MappableExprComponentListsRef ComponentLists) {
813  unsigned NumVars = Vars.size();
814  unsigned NumUniqueDeclarations =
815  getUniqueDeclarationsTotalNumber(Declarations);
816  unsigned NumComponentLists = ComponentLists.size();
817  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
818 
819  // We need to allocate:
820  // 3 x NumVars x Expr* - we have an original list expression for each clause
821  // list entry and an equal number of private copies and inits.
822  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
823  // with each component list.
824  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
825  // number of lists for each unique declaration and the size of each component
826  // list.
827  // NumComponents x MappableComponent - the total of all the components in all
828  // the lists.
829  void *Mem = C.Allocate(
830  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
832  3 * NumVars, NumUniqueDeclarations,
833  NumUniqueDeclarations + NumComponentLists, NumComponents));
834 
835  OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(
836  StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
837  NumComponentLists, NumComponents);
838 
839  Clause->setVarRefs(Vars);
840  Clause->setPrivateCopies(PrivateVars);
841  Clause->setInits(Inits);
842  Clause->setClauseInfo(Declarations, ComponentLists);
843  return Clause;
844 }
845 
847  const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
848  unsigned NumComponentLists, unsigned NumComponents) {
849  void *Mem = C.Allocate(
850  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
852  3 * NumVars, NumUniqueDeclarations,
853  NumUniqueDeclarations + NumComponentLists, NumComponents));
854  return new (Mem) OMPUseDevicePtrClause(NumVars, NumUniqueDeclarations,
855  NumComponentLists, NumComponents);
856 }
857 
860  SourceLocation LParenLoc, SourceLocation EndLoc,
861  ArrayRef<Expr *> Vars,
862  ArrayRef<ValueDecl *> Declarations,
863  MappableExprComponentListsRef ComponentLists) {
864  unsigned NumVars = Vars.size();
865  unsigned NumUniqueDeclarations =
866  getUniqueDeclarationsTotalNumber(Declarations);
867  unsigned NumComponentLists = ComponentLists.size();
868  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
869 
870  // We need to allocate:
871  // NumVars x Expr* - we have an original list expression for each clause list
872  // entry.
873  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
874  // with each component list.
875  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
876  // number of lists for each unique declaration and the size of each component
877  // list.
878  // NumComponents x MappableComponent - the total of all the components in all
879  // the lists.
880  void *Mem = C.Allocate(
881  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
883  NumVars, NumUniqueDeclarations,
884  NumUniqueDeclarations + NumComponentLists, NumComponents));
885 
886  OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(
887  StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
888  NumComponentLists, NumComponents);
889 
890  Clause->setVarRefs(Vars);
891  Clause->setClauseInfo(Declarations, ComponentLists);
892  return Clause;
893 }
894 
896  const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
897  unsigned NumComponentLists, unsigned NumComponents) {
898  void *Mem = C.Allocate(
899  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
901  NumVars, NumUniqueDeclarations,
902  NumUniqueDeclarations + NumComponentLists, NumComponents));
903  return new (Mem) OMPIsDevicePtrClause(NumVars, NumUniqueDeclarations,
904  NumComponentLists, NumComponents);
905 }
static OMPPrivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL)
Creates clause with a list of variables VL.
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Defines the clang::ASTContext interface.
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents 'thread_limit' clause in the '#pragma omp ...' directive.
static OMPToClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents clause 'copyin' in the '#pragma omp ...' directives.
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
static OMPClauseWithPreInit * get(OMPClause *C)
Stmt - This represents one statement.
Definition: Stmt.h:60
Class that handles pre-initialization statement for some clauses, like 'shedule', 'firstprivate' etc...
Definition: OpenMPClause.h:76
static OMPCopyprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
llvm::iterator_range< child_iterator > child_range
Definition: OpenMPClause.h:63
This represents 'if' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:207
static OMPCopyinClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps)
Creates clause with a list of variables VL.
static OMPMapClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for for NumVars original expressions, NumUniqueDeclarations de...
TypePropertyCache< Private > Cache
Definition: Type.cpp:3326
The base class of the type hierarchy.
Definition: Type.h:1303
static OMPIsDevicePtrClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents clause 'private' in the '#pragma omp ...' directives.
This represents 'num_threads' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:349
This represents implicit clause 'flush' for the '#pragma omp flush' directive.
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
void setClauseInfo(ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists...
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:40
CalcStep
Definition: OpenMPClause.h:137
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
Step
Definition: OpenMPClause.h:137
clang::OMPLinearClause OMPVarListClause, OMPClauseWithPostUpdate, llvm::TrailingObjects getPrivates()
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
A C++ nested-name-specifier augmented with source location information.
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition: OpenMPKinds.h:84
This represents clause 'lastprivate' in the '#pragma omp ...' directives.
void setUpdates(ArrayRef< Expr * > UL)
Sets the list of update expressions for linear variables.
This represents clause 'map' in the '#pragma omp ...' directives.
This represents clause 'to' in the '#pragma omp ...' directives.
Expr * getCounterValue()
Get the loop counter value.
This represents clause 'copyprivate' in the '#pragma omp ...' directives.
void setFinals(ArrayRef< Expr * > FL)
Sets the list of final update expressions for linear variables.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
static OMPToClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
Class that handles post-update expression for some clauses, like 'lastprivate', 'reduction' etc...
Definition: OpenMPClause.h:107
This represents clause 'reduction' in the '#pragma omp ...' directives.
This represents clause 'is_device_ptr' in the '#pragma omp ...' directives.
static OMPTaskReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr * > Privates, ArrayRef< Expr * > LHSExprs, ArrayRef< Expr * > RHSExprs, ArrayRef< Expr * > ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
This represents clause 'from' in the '#pragma omp ...' directives.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:57
child_range children()
This represents clause 'aligned' in the '#pragma omp ...' directives.
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
This represents clause 'task_reduction' in the '#pragma omp taskgroup' directives.
This represents implicit clause 'depend' for the '#pragma omp task' directive.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:580
Expr - This represents one expression.
Definition: Expr.h:105
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
Inits[]
Definition: OpenMPClause.h:136
void setInits(ArrayRef< Expr * > IL)
Sets the list of the initial values for linear variables.
static OMPUseDevicePtrClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Vars, ArrayRef< Expr * > PrivateVars, ArrayRef< Expr * > Inits, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
void setPrivateCopies(ArrayRef< Expr * > PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents clause 'firstprivate' in the '#pragma omp ...' directives.
static OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VL)
Creates clause with a list of variables VL.
This file defines OpenMP AST classes for clauses.
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:113
This represents 'num_teams' clause in the '#pragma omp ...' directive.
static OMPFirstprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PrivateVL, ArrayRef< Expr * > InitVL, Stmt *PreInit)
Creates clause with a list of variables VL.
Encodes a location in the source.
OpenMPDependClauseKind
OpenMP attributes for 'depend' clause.
Definition: OpenMPKinds.h:76
MutableArrayRef< Expr * > getInits()
void setVarRefs(ArrayRef< Expr * > VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:146
This represents 'schedule' clause in the '#pragma omp ...' directive.
Definition: OpenMPClause.h:722
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
This represents clause 'shared' in the '#pragma omp ...' directives.
OpenMPLinearClauseKind Modifier
Modifier of 'linear' clause.
Definition: OpenMPClause.h:86
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:33
static OMPFromClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
static OMPAlignedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, Expr *A)
Creates clause with a list of variables VL and alignment A.
SourceLocation ModifierLoc
Location of linear modifier if any.
Definition: OpenMPClause.h:88
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
void setCounterValue(Expr *V)
Set the loop counter value for the depend clauses with 'sink|source' kind of dependency.
This represents clause 'linear' in the '#pragma omp ...' directives.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > SrcExprs, ArrayRef< Expr * > DstExprs, ArrayRef< Expr * > AssignmentOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< ValueDecl * > Declarations)
Privates[]
Gets the list of initial values for linear variables.
Definition: OpenMPClause.h:136
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition: OpenMPKinds.h:92
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:623
static OMPMapClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr * > Vars, ArrayRef< ValueDecl * > Declarations, MappableExprComponentListsRef ComponentLists, OpenMPMapClauseKind TypeModifier, OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc)
Creates clause with a list of variables VL.
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=OMPD_unknown)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:85
This represents 'dist_schedule' clause in the '#pragma omp ...' directive.
void setPrivates(ArrayRef< Expr * > PL)
Sets the list of the copies of original linear variables.
static OMPFromClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
static OMPClauseWithPostUpdate * get(OMPClause *C)
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
SourceLocation ColonLoc
Location of ':'.
Definition: OpenMPClause.h:90
This represents clause 'use_device_ptr' in the '#pragma omp ...' directives.