clang  8.0.0svn
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 #include "clang/AST/ASTContext.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/SmallPtrSet.h"
19 #include "llvm/Support/Casting.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include <algorithm>
22 #include <cassert>
23 
24 using namespace clang;
25 
27  switch (getClauseKind()) {
28  default:
29  break;
30 #define OPENMP_CLAUSE(Name, Class) \
31  case OMPC_##Name: \
32  return static_cast<Class *>(this)->children();
33 #include "clang/Basic/OpenMPKinds.def"
34  }
35  llvm_unreachable("unknown OMPClause");
36 }
37 
39  auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
40  return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
41 }
42 
44  switch (C->getClauseKind()) {
45  case OMPC_schedule:
46  return static_cast<const OMPScheduleClause *>(C);
47  case OMPC_dist_schedule:
48  return static_cast<const OMPDistScheduleClause *>(C);
49  case OMPC_firstprivate:
50  return static_cast<const OMPFirstprivateClause *>(C);
51  case OMPC_lastprivate:
52  return static_cast<const OMPLastprivateClause *>(C);
53  case OMPC_reduction:
54  return static_cast<const OMPReductionClause *>(C);
55  case OMPC_task_reduction:
56  return static_cast<const OMPTaskReductionClause *>(C);
57  case OMPC_in_reduction:
58  return static_cast<const OMPInReductionClause *>(C);
59  case OMPC_linear:
60  return static_cast<const OMPLinearClause *>(C);
61  case OMPC_if:
62  return static_cast<const OMPIfClause *>(C);
63  case OMPC_num_threads:
64  return static_cast<const OMPNumThreadsClause *>(C);
65  case OMPC_num_teams:
66  return static_cast<const OMPNumTeamsClause *>(C);
67  case OMPC_thread_limit:
68  return static_cast<const OMPThreadLimitClause *>(C);
69  case OMPC_device:
70  return static_cast<const OMPDeviceClause *>(C);
71  case OMPC_default:
72  case OMPC_proc_bind:
73  case OMPC_final:
74  case OMPC_safelen:
75  case OMPC_simdlen:
76  case OMPC_collapse:
77  case OMPC_private:
78  case OMPC_shared:
79  case OMPC_aligned:
80  case OMPC_copyin:
81  case OMPC_copyprivate:
82  case OMPC_ordered:
83  case OMPC_nowait:
84  case OMPC_untied:
85  case OMPC_mergeable:
86  case OMPC_threadprivate:
87  case OMPC_flush:
88  case OMPC_read:
89  case OMPC_write:
90  case OMPC_update:
91  case OMPC_capture:
92  case OMPC_seq_cst:
93  case OMPC_depend:
94  case OMPC_threads:
95  case OMPC_simd:
96  case OMPC_map:
97  case OMPC_priority:
98  case OMPC_grainsize:
99  case OMPC_nogroup:
100  case OMPC_num_tasks:
101  case OMPC_hint:
102  case OMPC_defaultmap:
103  case OMPC_unknown:
104  case OMPC_uniform:
105  case OMPC_to:
106  case OMPC_from:
107  case OMPC_use_device_ptr:
108  case OMPC_is_device_ptr:
109  break;
110  }
111 
112  return nullptr;
113 }
114 
116  auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
117  return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
118 }
119 
121  switch (C->getClauseKind()) {
122  case OMPC_lastprivate:
123  return static_cast<const OMPLastprivateClause *>(C);
124  case OMPC_reduction:
125  return static_cast<const OMPReductionClause *>(C);
126  case OMPC_task_reduction:
127  return static_cast<const OMPTaskReductionClause *>(C);
128  case OMPC_in_reduction:
129  return static_cast<const OMPInReductionClause *>(C);
130  case OMPC_linear:
131  return static_cast<const OMPLinearClause *>(C);
132  case OMPC_schedule:
133  case OMPC_dist_schedule:
134  case OMPC_firstprivate:
135  case OMPC_default:
136  case OMPC_proc_bind:
137  case OMPC_if:
138  case OMPC_final:
139  case OMPC_num_threads:
140  case OMPC_safelen:
141  case OMPC_simdlen:
142  case OMPC_collapse:
143  case OMPC_private:
144  case OMPC_shared:
145  case OMPC_aligned:
146  case OMPC_copyin:
147  case OMPC_copyprivate:
148  case OMPC_ordered:
149  case OMPC_nowait:
150  case OMPC_untied:
151  case OMPC_mergeable:
152  case OMPC_threadprivate:
153  case OMPC_flush:
154  case OMPC_read:
155  case OMPC_write:
156  case OMPC_update:
157  case OMPC_capture:
158  case OMPC_seq_cst:
159  case OMPC_depend:
160  case OMPC_device:
161  case OMPC_threads:
162  case OMPC_simd:
163  case OMPC_map:
164  case OMPC_num_teams:
165  case OMPC_thread_limit:
166  case OMPC_priority:
167  case OMPC_grainsize:
168  case OMPC_nogroup:
169  case OMPC_num_tasks:
170  case OMPC_hint:
171  case OMPC_defaultmap:
172  case OMPC_unknown:
173  case OMPC_uniform:
174  case OMPC_to:
175  case OMPC_from:
176  case OMPC_use_device_ptr:
177  case OMPC_is_device_ptr:
178  break;
179  }
180 
181  return nullptr;
182 }
183 
185  unsigned NumLoops,
186  SourceLocation StartLoc,
187  SourceLocation LParenLoc,
188  SourceLocation EndLoc) {
189  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
190  auto *Clause =
191  new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc);
192  for (unsigned I = 0; I < NumLoops; ++I) {
193  Clause->setLoopNumIterations(I, nullptr);
194  Clause->setLoopCounter(I, nullptr);
195  }
196  return Clause;
197 }
198 
200  unsigned NumLoops) {
201  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
202  auto *Clause = new (Mem) OMPOrderedClause(NumLoops);
203  for (unsigned I = 0; I < NumLoops; ++I) {
204  Clause->setLoopNumIterations(I, nullptr);
205  Clause->setLoopCounter(I, nullptr);
206  }
207  return Clause;
208 }
209 
211  Expr *NumIterations) {
212  assert(NumLoop < NumberOfLoops && "out of loops number.");
213  getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
214 }
215 
217  return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
218 }
219 
220 void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) {
221  assert(NumLoop < NumberOfLoops && "out of loops number.");
222  getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
223 }
224 
226  assert(NumLoop < NumberOfLoops && "out of loops number.");
227  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
228 }
229 
230 const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const {
231  assert(NumLoop < NumberOfLoops && "out of loops number.");
232  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
233 }
234 
235 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
236  assert(VL.size() == varlist_size() &&
237  "Number of private copies is not the same as the preallocated buffer");
238  std::copy(VL.begin(), VL.end(), varlist_end());
239 }
240 
243  SourceLocation LParenLoc, SourceLocation EndLoc,
244  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
245  // Allocate space for private variables and initializer expressions.
246  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
247  OMPPrivateClause *Clause =
248  new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
249  Clause->setVarRefs(VL);
250  Clause->setPrivateCopies(PrivateVL);
251  return Clause;
252 }
253 
255  unsigned N) {
256  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
257  return new (Mem) OMPPrivateClause(N);
258 }
259 
260 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
261  assert(VL.size() == varlist_size() &&
262  "Number of private copies is not the same as the preallocated buffer");
263  std::copy(VL.begin(), VL.end(), varlist_end());
264 }
265 
266 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
267  assert(VL.size() == varlist_size() &&
268  "Number of inits is not the same as the preallocated buffer");
269  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
270 }
271 
274  SourceLocation LParenLoc, SourceLocation EndLoc,
275  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
276  ArrayRef<Expr *> InitVL, Stmt *PreInit) {
277  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
278  OMPFirstprivateClause *Clause =
279  new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
280  Clause->setVarRefs(VL);
281  Clause->setPrivateCopies(PrivateVL);
282  Clause->setInits(InitVL);
283  Clause->setPreInitStmt(PreInit);
284  return Clause;
285 }
286 
288  unsigned N) {
289  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
290  return new (Mem) OMPFirstprivateClause(N);
291 }
292 
294  assert(PrivateCopies.size() == varlist_size() &&
295  "Number of private copies is not the same as the preallocated buffer");
296  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
297 }
298 
299 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
300  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
301  "not the same as the "
302  "preallocated buffer");
303  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
304 }
305 
306 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
307  assert(DstExprs.size() == varlist_size() && "Number of destination "
308  "expressions is not the same as "
309  "the preallocated buffer");
310  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
311 }
312 
313 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
314  assert(AssignmentOps.size() == varlist_size() &&
315  "Number of assignment expressions is not the same as the preallocated "
316  "buffer");
317  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
318  getDestinationExprs().end());
319 }
320 
322  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
323  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
324  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit,
325  Expr *PostUpdate) {
326  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
327  OMPLastprivateClause *Clause =
328  new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
329  Clause->setVarRefs(VL);
330  Clause->setSourceExprs(SrcExprs);
331  Clause->setDestinationExprs(DstExprs);
332  Clause->setAssignmentOps(AssignmentOps);
333  Clause->setPreInitStmt(PreInit);
334  Clause->setPostUpdateExpr(PostUpdate);
335  return Clause;
336 }
337 
339  unsigned N) {
340  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
341  return new (Mem) OMPLastprivateClause(N);
342 }
343 
345  SourceLocation StartLoc,
346  SourceLocation LParenLoc,
347  SourceLocation EndLoc,
348  ArrayRef<Expr *> VL) {
349  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
350  OMPSharedClause *Clause =
351  new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
352  Clause->setVarRefs(VL);
353  return Clause;
354 }
355 
357  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
358  return new (Mem) OMPSharedClause(N);
359 }
360 
362  assert(PL.size() == varlist_size() &&
363  "Number of privates is not the same as the preallocated buffer");
364  std::copy(PL.begin(), PL.end(), varlist_end());
365 }
366 
368  assert(IL.size() == varlist_size() &&
369  "Number of inits is not the same as the preallocated buffer");
370  std::copy(IL.begin(), IL.end(), getPrivates().end());
371 }
372 
374  assert(UL.size() == varlist_size() &&
375  "Number of updates is not the same as the preallocated buffer");
376  std::copy(UL.begin(), UL.end(), getInits().end());
377 }
378 
380  assert(FL.size() == varlist_size() &&
381  "Number of final updates is not the same as the preallocated buffer");
382  std::copy(FL.begin(), FL.end(), getUpdates().end());
383 }
384 
386  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
390  Stmt *PreInit, Expr *PostUpdate) {
391  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
392  // (Step and CalcStep).
393  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
394  OMPLinearClause *Clause = new (Mem) OMPLinearClause(
395  StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
396  Clause->setVarRefs(VL);
397  Clause->setPrivates(PL);
398  Clause->setInits(IL);
399  // Fill update and final expressions with zeroes, they are provided later,
400  // after the directive construction.
401  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
402  nullptr);
403  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
404  nullptr);
405  Clause->setStep(Step);
406  Clause->setCalcStep(CalcStep);
407  Clause->setPreInitStmt(PreInit);
408  Clause->setPostUpdateExpr(PostUpdate);
409  return Clause;
410 }
411 
413  unsigned NumVars) {
414  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
415  // (Step and CalcStep).
416  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
417  return new (Mem) OMPLinearClause(NumVars);
418 }
419 
422  SourceLocation LParenLoc, SourceLocation ColonLoc,
423  SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
424  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
425  OMPAlignedClause *Clause = new (Mem)
426  OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
427  Clause->setVarRefs(VL);
428  Clause->setAlignment(A);
429  return Clause;
430 }
431 
433  unsigned NumVars) {
434  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
435  return new (Mem) OMPAlignedClause(NumVars);
436 }
437 
438 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
439  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
440  "not the same as the "
441  "preallocated buffer");
442  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
443 }
444 
445 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
446  assert(DstExprs.size() == varlist_size() && "Number of destination "
447  "expressions is not the same as "
448  "the preallocated buffer");
449  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
450 }
451 
452 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
453  assert(AssignmentOps.size() == varlist_size() &&
454  "Number of assignment expressions is not the same as the preallocated "
455  "buffer");
456  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
457  getDestinationExprs().end());
458 }
459 
461  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
462  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
463  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
464  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
465  OMPCopyinClause *Clause =
466  new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
467  Clause->setVarRefs(VL);
468  Clause->setSourceExprs(SrcExprs);
469  Clause->setDestinationExprs(DstExprs);
470  Clause->setAssignmentOps(AssignmentOps);
471  return Clause;
472 }
473 
475  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
476  return new (Mem) OMPCopyinClause(N);
477 }
478 
479 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
480  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
481  "not the same as the "
482  "preallocated buffer");
483  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
484 }
485 
486 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
487  assert(DstExprs.size() == varlist_size() && "Number of destination "
488  "expressions is not the same as "
489  "the preallocated buffer");
490  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
491 }
492 
493 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
494  assert(AssignmentOps.size() == varlist_size() &&
495  "Number of assignment expressions is not the same as the preallocated "
496  "buffer");
497  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
498  getDestinationExprs().end());
499 }
500 
502  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
503  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
504  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
505  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
506  OMPCopyprivateClause *Clause =
507  new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
508  Clause->setVarRefs(VL);
509  Clause->setSourceExprs(SrcExprs);
510  Clause->setDestinationExprs(DstExprs);
511  Clause->setAssignmentOps(AssignmentOps);
512  return Clause;
513 }
514 
516  unsigned N) {
517  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
518  return new (Mem) OMPCopyprivateClause(N);
519 }
520 
521 void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
522  assert(Privates.size() == varlist_size() &&
523  "Number of private copies is not the same as the preallocated buffer");
524  std::copy(Privates.begin(), Privates.end(), varlist_end());
525 }
526 
527 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
528  assert(
529  LHSExprs.size() == varlist_size() &&
530  "Number of LHS expressions is not the same as the preallocated buffer");
531  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
532 }
533 
534 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
535  assert(
536  RHSExprs.size() == varlist_size() &&
537  "Number of RHS expressions is not the same as the preallocated buffer");
538  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
539 }
540 
541 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
542  assert(ReductionOps.size() == varlist_size() && "Number of reduction "
543  "expressions is not the same "
544  "as the preallocated buffer");
545  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
546 }
547 
549  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
550  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
551  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
553  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
554  Expr *PostUpdate) {
555  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
556  OMPReductionClause *Clause = new (Mem) OMPReductionClause(
557  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
558  Clause->setVarRefs(VL);
559  Clause->setPrivates(Privates);
560  Clause->setLHSExprs(LHSExprs);
561  Clause->setRHSExprs(RHSExprs);
562  Clause->setReductionOps(ReductionOps);
563  Clause->setPreInitStmt(PreInit);
564  Clause->setPostUpdateExpr(PostUpdate);
565  return Clause;
566 }
567 
569  unsigned N) {
570  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
571  return new (Mem) OMPReductionClause(N);
572 }
573 
574 void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
575  assert(Privates.size() == varlist_size() &&
576  "Number of private copies is not the same as the preallocated buffer");
577  std::copy(Privates.begin(), Privates.end(), varlist_end());
578 }
579 
580 void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
581  assert(
582  LHSExprs.size() == varlist_size() &&
583  "Number of LHS expressions is not the same as the preallocated buffer");
584  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
585 }
586 
587 void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
588  assert(
589  RHSExprs.size() == varlist_size() &&
590  "Number of RHS expressions is not the same as the preallocated buffer");
591  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
592 }
593 
594 void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
595  assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
596  "expressions is not the same "
597  "as the preallocated buffer");
598  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
599 }
600 
602  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
603  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
604  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
605  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
606  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
607  Expr *PostUpdate) {
608  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
610  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
611  Clause->setVarRefs(VL);
612  Clause->setPrivates(Privates);
613  Clause->setLHSExprs(LHSExprs);
614  Clause->setRHSExprs(RHSExprs);
615  Clause->setReductionOps(ReductionOps);
616  Clause->setPreInitStmt(PreInit);
617  Clause->setPostUpdateExpr(PostUpdate);
618  return Clause;
619 }
620 
622  unsigned N) {
623  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
624  return new (Mem) OMPTaskReductionClause(N);
625 }
626 
627 void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
628  assert(Privates.size() == varlist_size() &&
629  "Number of private copies is not the same as the preallocated buffer");
630  std::copy(Privates.begin(), Privates.end(), varlist_end());
631 }
632 
633 void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
634  assert(
635  LHSExprs.size() == varlist_size() &&
636  "Number of LHS expressions is not the same as the preallocated buffer");
637  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
638 }
639 
640 void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
641  assert(
642  RHSExprs.size() == varlist_size() &&
643  "Number of RHS expressions is not the same as the preallocated buffer");
644  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
645 }
646 
647 void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
648  assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
649  "expressions is not the same "
650  "as the preallocated buffer");
651  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
652 }
653 
654 void OMPInReductionClause::setTaskgroupDescriptors(
655  ArrayRef<Expr *> TaskgroupDescriptors) {
656  assert(TaskgroupDescriptors.size() == varlist_size() &&
657  "Number of in reduction descriptors is not the same as the "
658  "preallocated buffer");
659  std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
660  getReductionOps().end());
661 }
662 
664  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
665  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
666  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
667  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
668  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
669  ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
670  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
671  OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
672  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
673  Clause->setVarRefs(VL);
674  Clause->setPrivates(Privates);
675  Clause->setLHSExprs(LHSExprs);
676  Clause->setRHSExprs(RHSExprs);
677  Clause->setReductionOps(ReductionOps);
678  Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
679  Clause->setPreInitStmt(PreInit);
680  Clause->setPostUpdateExpr(PostUpdate);
681  return Clause;
682 }
683 
685  unsigned N) {
686  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
687  return new (Mem) OMPInReductionClause(N);
688 }
689 
691  SourceLocation StartLoc,
692  SourceLocation LParenLoc,
693  SourceLocation EndLoc,
694  ArrayRef<Expr *> VL) {
695  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
696  OMPFlushClause *Clause =
697  new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
698  Clause->setVarRefs(VL);
699  return Clause;
700 }
701 
703  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
704  return new (Mem) OMPFlushClause(N);
705 }
706 
709  SourceLocation LParenLoc, SourceLocation EndLoc,
710  OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
711  SourceLocation ColonLoc, ArrayRef<Expr *> VL,
712  unsigned NumLoops) {
713  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops));
714  OMPDependClause *Clause = new (Mem)
715  OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
716  Clause->setVarRefs(VL);
717  Clause->setDependencyKind(DepKind);
718  Clause->setDependencyLoc(DepLoc);
719  Clause->setColonLoc(ColonLoc);
720  for (unsigned I = 0 ; I < NumLoops; ++I)
721  Clause->setLoopData(I, nullptr);
722  return Clause;
723 }
724 
726  unsigned NumLoops) {
727  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops));
728  return new (Mem) OMPDependClause(N, NumLoops);
729 }
730 
731 void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) {
732  assert((getDependencyKind() == OMPC_DEPEND_sink ||
733  getDependencyKind() == OMPC_DEPEND_source) &&
734  NumLoop < NumLoops &&
735  "Expected sink or source depend + loop index must be less number of "
736  "loops.");
737  auto It = std::next(getVarRefs().end(), NumLoop);
738  *It = Cnt;
739 }
740 
741 Expr *OMPDependClause::getLoopData(unsigned NumLoop) {
742  assert((getDependencyKind() == OMPC_DEPEND_sink ||
743  getDependencyKind() == OMPC_DEPEND_source) &&
744  NumLoop < NumLoops &&
745  "Expected sink or source depend + loop index must be less number of "
746  "loops.");
747  auto It = std::next(getVarRefs().end(), NumLoop);
748  return *It;
749 }
750 
751 const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const {
752  assert((getDependencyKind() == OMPC_DEPEND_sink ||
753  getDependencyKind() == OMPC_DEPEND_source) &&
754  NumLoop < NumLoops &&
755  "Expected sink or source depend + loop index must be less number of "
756  "loops.");
757  auto It = std::next(getVarRefs().end(), NumLoop);
758  return *It;
759 }
760 
762  MappableExprComponentListsRef ComponentLists) {
763  unsigned TotalNum = 0u;
764  for (auto &C : ComponentLists)
765  TotalNum += C.size();
766  return TotalNum;
767 }
768 
770  ArrayRef<const ValueDecl *> Declarations) {
771  unsigned TotalNum = 0u;
772  llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
773  for (const ValueDecl *D : Declarations) {
774  const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
775  if (Cache.count(VD))
776  continue;
777  ++TotalNum;
778  Cache.insert(VD);
779  }
780  return TotalNum;
781 }
782 
783 OMPMapClause *
785  SourceLocation LParenLoc, SourceLocation EndLoc,
786  ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
787  MappableExprComponentListsRef ComponentLists,
789  bool TypeIsImplicit, SourceLocation TypeLoc) {
790  unsigned NumVars = Vars.size();
791  unsigned NumUniqueDeclarations =
792  getUniqueDeclarationsTotalNumber(Declarations);
793  unsigned NumComponentLists = ComponentLists.size();
794  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
795 
796  // We need to allocate:
797  // NumVars x Expr* - we have an original list expression for each clause list
798  // entry.
799  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
800  // with each component list.
801  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
802  // number of lists for each unique declaration and the size of each component
803  // list.
804  // NumComponents x MappableComponent - the total of all the components in all
805  // the lists.
806  void *Mem = C.Allocate(
807  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
809  NumVars, NumUniqueDeclarations,
810  NumUniqueDeclarations + NumComponentLists, NumComponents));
811  OMPMapClause *Clause = new (Mem) OMPMapClause(
812  TypeModifier, Type, TypeIsImplicit, TypeLoc, StartLoc, LParenLoc, EndLoc,
813  NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents);
814 
815  Clause->setVarRefs(Vars);
816  Clause->setClauseInfo(Declarations, ComponentLists);
817  Clause->setMapTypeModifier(TypeModifier);
818  Clause->setMapType(Type);
819  Clause->setMapLoc(TypeLoc);
820  return Clause;
821 }
822 
824  unsigned NumUniqueDeclarations,
825  unsigned NumComponentLists,
826  unsigned NumComponents) {
827  void *Mem = C.Allocate(
828  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
830  NumVars, NumUniqueDeclarations,
831  NumUniqueDeclarations + NumComponentLists, NumComponents));
832  return new (Mem) OMPMapClause(NumVars, NumUniqueDeclarations,
833  NumComponentLists, NumComponents);
834 }
835 
837  SourceLocation LParenLoc,
838  SourceLocation EndLoc, ArrayRef<Expr *> Vars,
839  ArrayRef<ValueDecl *> Declarations,
840  MappableExprComponentListsRef ComponentLists) {
841  unsigned NumVars = Vars.size();
842  unsigned NumUniqueDeclarations =
843  getUniqueDeclarationsTotalNumber(Declarations);
844  unsigned NumComponentLists = ComponentLists.size();
845  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
846 
847  // We need to allocate:
848  // NumVars x Expr* - we have an original list expression for each clause list
849  // entry.
850  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
851  // with each component list.
852  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
853  // number of lists for each unique declaration and the size of each component
854  // list.
855  // NumComponents x MappableComponent - the total of all the components in all
856  // the lists.
857  void *Mem = C.Allocate(
858  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
860  NumVars, NumUniqueDeclarations,
861  NumUniqueDeclarations + NumComponentLists, NumComponents));
862 
863  OMPToClause *Clause = new (Mem)
864  OMPToClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
865  NumComponentLists, NumComponents);
866 
867  Clause->setVarRefs(Vars);
868  Clause->setClauseInfo(Declarations, ComponentLists);
869  return Clause;
870 }
871 
872 OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
873  unsigned NumUniqueDeclarations,
874  unsigned NumComponentLists,
875  unsigned NumComponents) {
876  void *Mem = C.Allocate(
877  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
879  NumVars, NumUniqueDeclarations,
880  NumUniqueDeclarations + NumComponentLists, NumComponents));
881  return new (Mem) OMPToClause(NumVars, NumUniqueDeclarations,
882  NumComponentLists, NumComponents);
883 }
884 
887  SourceLocation LParenLoc, SourceLocation EndLoc,
888  ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
889  MappableExprComponentListsRef ComponentLists) {
890  unsigned NumVars = Vars.size();
891  unsigned NumUniqueDeclarations =
892  getUniqueDeclarationsTotalNumber(Declarations);
893  unsigned NumComponentLists = ComponentLists.size();
894  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
895 
896  // We need to allocate:
897  // NumVars x Expr* - we have an original list expression for each clause list
898  // entry.
899  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
900  // with each component list.
901  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
902  // number of lists for each unique declaration and the size of each component
903  // list.
904  // NumComponents x MappableComponent - the total of all the components in all
905  // the lists.
906  void *Mem = C.Allocate(
907  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
909  NumVars, NumUniqueDeclarations,
910  NumUniqueDeclarations + NumComponentLists, NumComponents));
911 
912  OMPFromClause *Clause = new (Mem)
913  OMPFromClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
914  NumComponentLists, NumComponents);
915 
916  Clause->setVarRefs(Vars);
917  Clause->setClauseInfo(Declarations, ComponentLists);
918  return Clause;
919 }
920 
922  unsigned NumUniqueDeclarations,
923  unsigned NumComponentLists,
924  unsigned NumComponents) {
925  void *Mem = C.Allocate(
926  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
928  NumVars, NumUniqueDeclarations,
929  NumUniqueDeclarations + NumComponentLists, NumComponents));
930  return new (Mem) OMPFromClause(NumVars, NumUniqueDeclarations,
931  NumComponentLists, NumComponents);
932 }
933 
934 void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
935  assert(VL.size() == varlist_size() &&
936  "Number of private copies is not the same as the preallocated buffer");
937  std::copy(VL.begin(), VL.end(), varlist_end());
938 }
939 
940 void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
941  assert(VL.size() == varlist_size() &&
942  "Number of inits is not the same as the preallocated buffer");
943  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
944 }
945 
947  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
948  SourceLocation EndLoc, ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
949  ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
950  MappableExprComponentListsRef ComponentLists) {
951  unsigned NumVars = Vars.size();
952  unsigned NumUniqueDeclarations =
953  getUniqueDeclarationsTotalNumber(Declarations);
954  unsigned NumComponentLists = ComponentLists.size();
955  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
956 
957  // We need to allocate:
958  // 3 x NumVars x Expr* - we have an original list expression for each clause
959  // list entry and an equal number of private copies and inits.
960  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
961  // with each component list.
962  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
963  // number of lists for each unique declaration and the size of each component
964  // list.
965  // NumComponents x MappableComponent - the total of all the components in all
966  // the lists.
967  void *Mem = C.Allocate(
968  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
970  3 * NumVars, NumUniqueDeclarations,
971  NumUniqueDeclarations + NumComponentLists, NumComponents));
972 
973  OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(
974  StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
975  NumComponentLists, NumComponents);
976 
977  Clause->setVarRefs(Vars);
978  Clause->setPrivateCopies(PrivateVars);
979  Clause->setInits(Inits);
980  Clause->setClauseInfo(Declarations, ComponentLists);
981  return Clause;
982 }
983 
985  const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
986  unsigned NumComponentLists, unsigned NumComponents) {
987  void *Mem = C.Allocate(
988  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
990  3 * NumVars, NumUniqueDeclarations,
991  NumUniqueDeclarations + NumComponentLists, NumComponents));
992  return new (Mem) OMPUseDevicePtrClause(NumVars, NumUniqueDeclarations,
993  NumComponentLists, NumComponents);
994 }
995 
998  SourceLocation LParenLoc, SourceLocation EndLoc,
999  ArrayRef<Expr *> Vars,
1000  ArrayRef<ValueDecl *> Declarations,
1001  MappableExprComponentListsRef ComponentLists) {
1002  unsigned NumVars = Vars.size();
1003  unsigned NumUniqueDeclarations =
1004  getUniqueDeclarationsTotalNumber(Declarations);
1005  unsigned NumComponentLists = ComponentLists.size();
1006  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
1007 
1008  // We need to allocate:
1009  // NumVars x Expr* - we have an original list expression for each clause list
1010  // entry.
1011  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1012  // with each component list.
1013  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1014  // number of lists for each unique declaration and the size of each component
1015  // list.
1016  // NumComponents x MappableComponent - the total of all the components in all
1017  // the lists.
1018  void *Mem = C.Allocate(
1019  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1021  NumVars, NumUniqueDeclarations,
1022  NumUniqueDeclarations + NumComponentLists, NumComponents));
1023 
1024  OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(
1025  StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
1026  NumComponentLists, NumComponents);
1027 
1028  Clause->setVarRefs(Vars);
1029  Clause->setClauseInfo(Declarations, ComponentLists);
1030  return Clause;
1031 }
1032 
1034  const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
1035  unsigned NumComponentLists, unsigned NumComponents) {
1036  void *Mem = C.Allocate(
1037  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1039  NumVars, NumUniqueDeclarations,
1040  NumUniqueDeclarations + NumComponentLists, NumComponents));
1041  return new (Mem) OMPIsDevicePtrClause(NumVars, NumUniqueDeclarations,
1042  NumComponentLists, NumComponents);
1043 }
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.
Defines the clang::ASTContext interface.
This represents &#39;thread_limit&#39; clause in the &#39;#pragma omp ...&#39; directive.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; 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 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.
TypePropertyCache< Private > Cache
Definition: Type.cpp:3455
static OMPClauseWithPreInit * get(OMPClause *C)
Stmt - This represents one statement.
Definition: Stmt.h:66
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
Class that handles pre-initialization statement for some clauses, like &#39;shedule&#39;, &#39;firstprivate&#39; etc...
Definition: OpenMPClause.h:99
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N 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.
This represents &#39;if&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:240
static OMPMapClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
The base class of the type hierarchy.
Definition: Type.h:1415
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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.
This represents clause &#39;private&#39; in the &#39;#pragma omp ...&#39; directives.
This represents &#39;num_threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:382
void setUpdates(ArrayRef< Expr *> UL)
Sets the list of update expressions for linear variables.
This represents implicit clause &#39;flush&#39; for the &#39;#pragma omp flush&#39; directive.
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:57
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.
CalcStep
Definition: OpenMPClause.h:152
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.
Step
Definition: OpenMPClause.h:152
static OMPInReductionClause * 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, ArrayRef< Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
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:154
A C++ nested-name-specifier augmented with source location information.
OpenMPLinearClauseKind
OpenMP attributes for &#39;linear&#39; clause.
Definition: OpenMPKinds.h:84
This represents clause &#39;lastprivate&#39; in the &#39;#pragma omp ...&#39; directives.
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
This represents clause &#39;map&#39; in the &#39;#pragma omp ...&#39; directives.
This represents clause &#39;to&#39; in the &#39;#pragma omp ...&#39; directives.
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
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 OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
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 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 &#39;lastprivate&#39;, &#39;reduction&#39; etc...
Definition: OpenMPClause.h:135
This represents clause &#39;reduction&#39; in the &#39;#pragma omp ...&#39; directives.
void setPrivates(ArrayRef< Expr *> PL)
Sets the list of the copies of original linear variables.
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
void setFinals(ArrayRef< Expr *> FL)
Sets the list of final update expressions for linear variables.
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 OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr *> VL, unsigned NumLoops)
Creates clause with a list of variables VL.
This represents clause &#39;from&#39; in the &#39;#pragma omp ...&#39; directives.
child_range children()
OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, unsigned NumVars)
Build &#39;linear&#39; clause with given number of variables NumVars.
Definition: OpenMPClause.h:123
This represents clause &#39;aligned&#39; in the &#39;#pragma omp ...&#39; directives.
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:79
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
static OMPOrderedClause * Create(const ASTContext &C, Expr *Num, unsigned NumLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build &#39;ordered&#39; clause.
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:636
This represents one expression.
Definition: Expr.h:105
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
Inits[]
Definition: OpenMPClause.h:151
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:925
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.
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents clause &#39;firstprivate&#39; in the &#39;#pragma omp ...&#39; directives.
This file defines OpenMP AST classes for clauses.
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:147
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
llvm::iterator_range< child_iterator > child_range
Definition: OpenMPClause.h:85
Encodes a location in the source.
OpenMPDependClauseKind
OpenMP attributes for &#39;depend&#39; clause.
Definition: OpenMPKinds.h:76
MutableArrayRef< Expr * > getInits()
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.
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:744
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
OpenMPLinearClauseKind Modifier
Modifier of &#39;linear&#39; clause.
Definition: OpenMPClause.h:102
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
Expr * getLoopCounter(unsigned NumLoop)
Get loops counter for the specified loop.
void setPrivateCopies(ArrayRef< Expr *> PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
void setVarRefs(ArrayRef< Expr *> VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:191
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.
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.
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:678
Dataflow Directional Tag Classes.
This represents &#39;device&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation ModifierLoc
Location of linear modifier if any.
Definition: OpenMPClause.h:105
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
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.
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
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.
Class that represents a component of a mappable expression.
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl *> Declarations)
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with &#39;sink|source&#39; kind of dependency.
void setClauseInfo(ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists...
Privates[]
Gets the list of initial values for linear variables.
Definition: OpenMPClause.h:151
OpenMPMapClauseKind
OpenMP mapping kind for &#39;map&#39; clause.
Definition: OpenMPKinds.h:92
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=OMPD_unknown)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:114
This represents &#39;dist_schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
static OMPFromClause * CreateEmpty(const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations, unsigned NumComponentLists, unsigned NumComponents)
Creates an empty clause with the place for NumVars variables.
void setInits(ArrayRef< Expr *> IL)
Sets the list of the initial values for linear variables.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
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 &#39;:&#39;.
Definition: OpenMPClause.h:108
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
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.