clang  6.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 
184 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
185  assert(VL.size() == varlist_size() &&
186  "Number of private copies is not the same as the preallocated buffer");
187  std::copy(VL.begin(), VL.end(), varlist_end());
188 }
189 
192  SourceLocation LParenLoc, SourceLocation EndLoc,
193  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
194  // Allocate space for private variables and initializer expressions.
195  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
196  OMPPrivateClause *Clause =
197  new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
198  Clause->setVarRefs(VL);
199  Clause->setPrivateCopies(PrivateVL);
200  return Clause;
201 }
202 
204  unsigned N) {
205  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
206  return new (Mem) OMPPrivateClause(N);
207 }
208 
209 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
210  assert(VL.size() == varlist_size() &&
211  "Number of private copies is not the same as the preallocated buffer");
212  std::copy(VL.begin(), VL.end(), varlist_end());
213 }
214 
215 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
216  assert(VL.size() == varlist_size() &&
217  "Number of inits is not the same as the preallocated buffer");
218  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
219 }
220 
223  SourceLocation LParenLoc, SourceLocation EndLoc,
224  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
225  ArrayRef<Expr *> InitVL, Stmt *PreInit) {
226  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
227  OMPFirstprivateClause *Clause =
228  new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
229  Clause->setVarRefs(VL);
230  Clause->setPrivateCopies(PrivateVL);
231  Clause->setInits(InitVL);
232  Clause->setPreInitStmt(PreInit);
233  return Clause;
234 }
235 
237  unsigned N) {
238  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
239  return new (Mem) OMPFirstprivateClause(N);
240 }
241 
243  assert(PrivateCopies.size() == varlist_size() &&
244  "Number of private copies is not the same as the preallocated buffer");
245  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
246 }
247 
248 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
249  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
250  "not the same as the "
251  "preallocated buffer");
252  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
253 }
254 
255 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
256  assert(DstExprs.size() == varlist_size() && "Number of destination "
257  "expressions is not the same as "
258  "the preallocated buffer");
259  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
260 }
261 
262 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
263  assert(AssignmentOps.size() == varlist_size() &&
264  "Number of assignment expressions is not the same as the preallocated "
265  "buffer");
266  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
267  getDestinationExprs().end());
268 }
269 
271  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
272  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
273  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit,
274  Expr *PostUpdate) {
275  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
276  OMPLastprivateClause *Clause =
277  new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
278  Clause->setVarRefs(VL);
279  Clause->setSourceExprs(SrcExprs);
280  Clause->setDestinationExprs(DstExprs);
281  Clause->setAssignmentOps(AssignmentOps);
282  Clause->setPreInitStmt(PreInit);
283  Clause->setPostUpdateExpr(PostUpdate);
284  return Clause;
285 }
286 
288  unsigned N) {
289  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
290  return new (Mem) OMPLastprivateClause(N);
291 }
292 
294  SourceLocation StartLoc,
295  SourceLocation LParenLoc,
296  SourceLocation EndLoc,
297  ArrayRef<Expr *> VL) {
298  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
299  OMPSharedClause *Clause =
300  new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
301  Clause->setVarRefs(VL);
302  return Clause;
303 }
304 
306  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
307  return new (Mem) OMPSharedClause(N);
308 }
309 
311  assert(PL.size() == varlist_size() &&
312  "Number of privates is not the same as the preallocated buffer");
313  std::copy(PL.begin(), PL.end(), varlist_end());
314 }
315 
317  assert(IL.size() == varlist_size() &&
318  "Number of inits is not the same as the preallocated buffer");
319  std::copy(IL.begin(), IL.end(), getPrivates().end());
320 }
321 
323  assert(UL.size() == varlist_size() &&
324  "Number of updates is not the same as the preallocated buffer");
325  std::copy(UL.begin(), UL.end(), getInits().end());
326 }
327 
329  assert(FL.size() == varlist_size() &&
330  "Number of final updates is not the same as the preallocated buffer");
331  std::copy(FL.begin(), FL.end(), getUpdates().end());
332 }
333 
335  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
339  Stmt *PreInit, Expr *PostUpdate) {
340  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
341  // (Step and CalcStep).
342  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2));
343  OMPLinearClause *Clause = new (Mem) OMPLinearClause(
344  StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
345  Clause->setVarRefs(VL);
346  Clause->setPrivates(PL);
347  Clause->setInits(IL);
348  // Fill update and final expressions with zeroes, they are provided later,
349  // after the directive construction.
350  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
351  nullptr);
352  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
353  nullptr);
354  Clause->setStep(Step);
355  Clause->setCalcStep(CalcStep);
356  Clause->setPreInitStmt(PreInit);
357  Clause->setPostUpdateExpr(PostUpdate);
358  return Clause;
359 }
360 
362  unsigned NumVars) {
363  // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions
364  // (Step and CalcStep).
365  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2));
366  return new (Mem) OMPLinearClause(NumVars);
367 }
368 
371  SourceLocation LParenLoc, SourceLocation ColonLoc,
372  SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
373  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
374  OMPAlignedClause *Clause = new (Mem)
375  OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
376  Clause->setVarRefs(VL);
377  Clause->setAlignment(A);
378  return Clause;
379 }
380 
382  unsigned NumVars) {
383  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
384  return new (Mem) OMPAlignedClause(NumVars);
385 }
386 
387 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
388  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
389  "not the same as the "
390  "preallocated buffer");
391  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
392 }
393 
394 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
395  assert(DstExprs.size() == varlist_size() && "Number of destination "
396  "expressions is not the same as "
397  "the preallocated buffer");
398  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
399 }
400 
401 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
402  assert(AssignmentOps.size() == varlist_size() &&
403  "Number of assignment expressions is not the same as the preallocated "
404  "buffer");
405  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
406  getDestinationExprs().end());
407 }
408 
410  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
411  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
412  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
413  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
414  OMPCopyinClause *Clause =
415  new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
416  Clause->setVarRefs(VL);
417  Clause->setSourceExprs(SrcExprs);
418  Clause->setDestinationExprs(DstExprs);
419  Clause->setAssignmentOps(AssignmentOps);
420  return Clause;
421 }
422 
424  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
425  return new (Mem) OMPCopyinClause(N);
426 }
427 
428 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
429  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
430  "not the same as the "
431  "preallocated buffer");
432  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
433 }
434 
435 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
436  assert(DstExprs.size() == varlist_size() && "Number of destination "
437  "expressions is not the same as "
438  "the preallocated buffer");
439  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
440 }
441 
442 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
443  assert(AssignmentOps.size() == varlist_size() &&
444  "Number of assignment expressions is not the same as the preallocated "
445  "buffer");
446  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
447  getDestinationExprs().end());
448 }
449 
451  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
452  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
453  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
454  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
455  OMPCopyprivateClause *Clause =
456  new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
457  Clause->setVarRefs(VL);
458  Clause->setSourceExprs(SrcExprs);
459  Clause->setDestinationExprs(DstExprs);
460  Clause->setAssignmentOps(AssignmentOps);
461  return Clause;
462 }
463 
465  unsigned N) {
466  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
467  return new (Mem) OMPCopyprivateClause(N);
468 }
469 
470 void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
471  assert(Privates.size() == varlist_size() &&
472  "Number of private copies is not the same as the preallocated buffer");
473  std::copy(Privates.begin(), Privates.end(), varlist_end());
474 }
475 
476 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
477  assert(
478  LHSExprs.size() == varlist_size() &&
479  "Number of LHS expressions is not the same as the preallocated buffer");
480  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
481 }
482 
483 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
484  assert(
485  RHSExprs.size() == varlist_size() &&
486  "Number of RHS expressions is not the same as the preallocated buffer");
487  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
488 }
489 
490 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
491  assert(ReductionOps.size() == varlist_size() && "Number of reduction "
492  "expressions is not the same "
493  "as the preallocated buffer");
494  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
495 }
496 
498  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
499  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
500  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
502  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
503  Expr *PostUpdate) {
504  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
505  OMPReductionClause *Clause = new (Mem) OMPReductionClause(
506  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
507  Clause->setVarRefs(VL);
508  Clause->setPrivates(Privates);
509  Clause->setLHSExprs(LHSExprs);
510  Clause->setRHSExprs(RHSExprs);
511  Clause->setReductionOps(ReductionOps);
512  Clause->setPreInitStmt(PreInit);
513  Clause->setPostUpdateExpr(PostUpdate);
514  return Clause;
515 }
516 
518  unsigned N) {
519  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
520  return new (Mem) OMPReductionClause(N);
521 }
522 
523 void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
524  assert(Privates.size() == varlist_size() &&
525  "Number of private copies is not the same as the preallocated buffer");
526  std::copy(Privates.begin(), Privates.end(), varlist_end());
527 }
528 
529 void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
530  assert(
531  LHSExprs.size() == varlist_size() &&
532  "Number of LHS expressions is not the same as the preallocated buffer");
533  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
534 }
535 
536 void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
537  assert(
538  RHSExprs.size() == varlist_size() &&
539  "Number of RHS expressions is not the same as the preallocated buffer");
540  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
541 }
542 
543 void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
544  assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
545  "expressions is not the same "
546  "as the preallocated buffer");
547  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
548 }
549 
551  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
552  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
553  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
554  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
555  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
556  Expr *PostUpdate) {
557  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
559  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
560  Clause->setVarRefs(VL);
561  Clause->setPrivates(Privates);
562  Clause->setLHSExprs(LHSExprs);
563  Clause->setRHSExprs(RHSExprs);
564  Clause->setReductionOps(ReductionOps);
565  Clause->setPreInitStmt(PreInit);
566  Clause->setPostUpdateExpr(PostUpdate);
567  return Clause;
568 }
569 
571  unsigned N) {
572  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
573  return new (Mem) OMPTaskReductionClause(N);
574 }
575 
576 void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
577  assert(Privates.size() == varlist_size() &&
578  "Number of private copies is not the same as the preallocated buffer");
579  std::copy(Privates.begin(), Privates.end(), varlist_end());
580 }
581 
582 void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
583  assert(
584  LHSExprs.size() == varlist_size() &&
585  "Number of LHS expressions is not the same as the preallocated buffer");
586  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
587 }
588 
589 void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
590  assert(
591  RHSExprs.size() == varlist_size() &&
592  "Number of RHS expressions is not the same as the preallocated buffer");
593  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
594 }
595 
596 void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
597  assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
598  "expressions is not the same "
599  "as the preallocated buffer");
600  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
601 }
602 
603 void OMPInReductionClause::setTaskgroupDescriptors(
604  ArrayRef<Expr *> TaskgroupDescriptors) {
605  assert(TaskgroupDescriptors.size() == varlist_size() &&
606  "Number of in reduction descriptors is not the same as the "
607  "preallocated buffer");
608  std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
609  getReductionOps().end());
610 }
611 
613  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
614  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
615  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
616  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
617  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
618  ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
619  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
620  OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
621  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
622  Clause->setVarRefs(VL);
623  Clause->setPrivates(Privates);
624  Clause->setLHSExprs(LHSExprs);
625  Clause->setRHSExprs(RHSExprs);
626  Clause->setReductionOps(ReductionOps);
627  Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
628  Clause->setPreInitStmt(PreInit);
629  Clause->setPostUpdateExpr(PostUpdate);
630  return Clause;
631 }
632 
634  unsigned N) {
635  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
636  return new (Mem) OMPInReductionClause(N);
637 }
638 
640  SourceLocation StartLoc,
641  SourceLocation LParenLoc,
642  SourceLocation EndLoc,
643  ArrayRef<Expr *> VL) {
644  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
645  OMPFlushClause *Clause =
646  new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
647  Clause->setVarRefs(VL);
648  return Clause;
649 }
650 
652  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
653  return new (Mem) OMPFlushClause(N);
654 }
655 
657  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
658  SourceLocation EndLoc, OpenMPDependClauseKind DepKind,
659  SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL) {
660  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
661  OMPDependClause *Clause =
662  new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size());
663  Clause->setVarRefs(VL);
664  Clause->setDependencyKind(DepKind);
665  Clause->setDependencyLoc(DepLoc);
666  Clause->setColonLoc(ColonLoc);
667  Clause->setCounterValue(nullptr);
668  return Clause;
669 }
670 
672  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
673  return new (Mem) OMPDependClause(N);
674 }
675 
677  assert(getDependencyKind() == OMPC_DEPEND_sink ||
678  getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
679  *getVarRefs().end() = V;
680 }
681 
683  auto *V = *getVarRefs().end();
684  assert(getDependencyKind() == OMPC_DEPEND_sink ||
685  getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
686  return V;
687 }
688 
690  auto *V = *getVarRefs().end();
691  assert(getDependencyKind() == OMPC_DEPEND_sink ||
692  getDependencyKind() == OMPC_DEPEND_source || V == nullptr);
693  return V;
694 }
695 
697  MappableExprComponentListsRef ComponentLists) {
698  unsigned TotalNum = 0u;
699  for (auto &C : ComponentLists)
700  TotalNum += C.size();
701  return TotalNum;
702 }
703 
705  ArrayRef<ValueDecl *> Declarations) {
706  unsigned TotalNum = 0u;
707  llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
708  for (auto *D : Declarations) {
709  const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
710  if (Cache.count(VD))
711  continue;
712  ++TotalNum;
713  Cache.insert(VD);
714  }
715  return TotalNum;
716 }
717 
718 OMPMapClause *
720  SourceLocation LParenLoc, SourceLocation EndLoc,
721  ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
722  MappableExprComponentListsRef ComponentLists,
724  bool TypeIsImplicit, SourceLocation TypeLoc) {
725  unsigned NumVars = Vars.size();
726  unsigned NumUniqueDeclarations =
727  getUniqueDeclarationsTotalNumber(Declarations);
728  unsigned NumComponentLists = ComponentLists.size();
729  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
730 
731  // We need to allocate:
732  // NumVars x Expr* - we have an original list expression for each clause list
733  // entry.
734  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
735  // with each component list.
736  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
737  // number of lists for each unique declaration and the size of each component
738  // list.
739  // NumComponents x MappableComponent - the total of all the components in all
740  // the lists.
741  void *Mem = C.Allocate(
742  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
744  NumVars, NumUniqueDeclarations,
745  NumUniqueDeclarations + NumComponentLists, NumComponents));
746  OMPMapClause *Clause = new (Mem) OMPMapClause(
747  TypeModifier, Type, TypeIsImplicit, TypeLoc, StartLoc, LParenLoc, EndLoc,
748  NumVars, NumUniqueDeclarations, NumComponentLists, NumComponents);
749 
750  Clause->setVarRefs(Vars);
751  Clause->setClauseInfo(Declarations, ComponentLists);
752  Clause->setMapTypeModifier(TypeModifier);
753  Clause->setMapType(Type);
754  Clause->setMapLoc(TypeLoc);
755  return Clause;
756 }
757 
759  unsigned NumUniqueDeclarations,
760  unsigned NumComponentLists,
761  unsigned NumComponents) {
762  void *Mem = C.Allocate(
763  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
765  NumVars, NumUniqueDeclarations,
766  NumUniqueDeclarations + NumComponentLists, NumComponents));
767  return new (Mem) OMPMapClause(NumVars, NumUniqueDeclarations,
768  NumComponentLists, NumComponents);
769 }
770 
772  SourceLocation LParenLoc,
773  SourceLocation EndLoc, ArrayRef<Expr *> Vars,
774  ArrayRef<ValueDecl *> Declarations,
775  MappableExprComponentListsRef ComponentLists) {
776  unsigned NumVars = Vars.size();
777  unsigned NumUniqueDeclarations =
778  getUniqueDeclarationsTotalNumber(Declarations);
779  unsigned NumComponentLists = ComponentLists.size();
780  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
781 
782  // We need to allocate:
783  // NumVars x Expr* - we have an original list expression for each clause list
784  // entry.
785  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
786  // with each component list.
787  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
788  // number of lists for each unique declaration and the size of each component
789  // list.
790  // NumComponents x MappableComponent - the total of all the components in all
791  // the lists.
792  void *Mem = C.Allocate(
793  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
795  NumVars, NumUniqueDeclarations,
796  NumUniqueDeclarations + NumComponentLists, NumComponents));
797 
798  OMPToClause *Clause = new (Mem)
799  OMPToClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
800  NumComponentLists, NumComponents);
801 
802  Clause->setVarRefs(Vars);
803  Clause->setClauseInfo(Declarations, ComponentLists);
804  return Clause;
805 }
806 
807 OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C, unsigned NumVars,
808  unsigned NumUniqueDeclarations,
809  unsigned NumComponentLists,
810  unsigned NumComponents) {
811  void *Mem = C.Allocate(
812  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
814  NumVars, NumUniqueDeclarations,
815  NumUniqueDeclarations + NumComponentLists, NumComponents));
816  return new (Mem) OMPToClause(NumVars, NumUniqueDeclarations,
817  NumComponentLists, NumComponents);
818 }
819 
822  SourceLocation LParenLoc, SourceLocation EndLoc,
823  ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations,
824  MappableExprComponentListsRef ComponentLists) {
825  unsigned NumVars = Vars.size();
826  unsigned NumUniqueDeclarations =
827  getUniqueDeclarationsTotalNumber(Declarations);
828  unsigned NumComponentLists = ComponentLists.size();
829  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
830 
831  // We need to allocate:
832  // NumVars x Expr* - we have an original list expression for each clause list
833  // entry.
834  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
835  // with each component list.
836  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
837  // number of lists for each unique declaration and the size of each component
838  // list.
839  // NumComponents x MappableComponent - the total of all the components in all
840  // the lists.
841  void *Mem = C.Allocate(
842  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
844  NumVars, NumUniqueDeclarations,
845  NumUniqueDeclarations + NumComponentLists, NumComponents));
846 
847  OMPFromClause *Clause = new (Mem)
848  OMPFromClause(StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
849  NumComponentLists, NumComponents);
850 
851  Clause->setVarRefs(Vars);
852  Clause->setClauseInfo(Declarations, ComponentLists);
853  return Clause;
854 }
855 
857  unsigned NumUniqueDeclarations,
858  unsigned NumComponentLists,
859  unsigned NumComponents) {
860  void *Mem = C.Allocate(
861  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
863  NumVars, NumUniqueDeclarations,
864  NumUniqueDeclarations + NumComponentLists, NumComponents));
865  return new (Mem) OMPFromClause(NumVars, NumUniqueDeclarations,
866  NumComponentLists, NumComponents);
867 }
868 
869 void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
870  assert(VL.size() == varlist_size() &&
871  "Number of private copies is not the same as the preallocated buffer");
872  std::copy(VL.begin(), VL.end(), varlist_end());
873 }
874 
875 void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
876  assert(VL.size() == varlist_size() &&
877  "Number of inits is not the same as the preallocated buffer");
878  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
879 }
880 
882  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
883  SourceLocation EndLoc, ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars,
884  ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations,
885  MappableExprComponentListsRef ComponentLists) {
886  unsigned NumVars = Vars.size();
887  unsigned NumUniqueDeclarations =
888  getUniqueDeclarationsTotalNumber(Declarations);
889  unsigned NumComponentLists = ComponentLists.size();
890  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
891 
892  // We need to allocate:
893  // 3 x NumVars x Expr* - we have an original list expression for each clause
894  // list entry and an equal number of private copies and inits.
895  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
896  // with each component list.
897  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
898  // number of lists for each unique declaration and the size of each component
899  // list.
900  // NumComponents x MappableComponent - the total of all the components in all
901  // the lists.
902  void *Mem = C.Allocate(
903  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
905  3 * NumVars, NumUniqueDeclarations,
906  NumUniqueDeclarations + NumComponentLists, NumComponents));
907 
908  OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(
909  StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
910  NumComponentLists, NumComponents);
911 
912  Clause->setVarRefs(Vars);
913  Clause->setPrivateCopies(PrivateVars);
914  Clause->setInits(Inits);
915  Clause->setClauseInfo(Declarations, ComponentLists);
916  return Clause;
917 }
918 
920  const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
921  unsigned NumComponentLists, unsigned NumComponents) {
922  void *Mem = C.Allocate(
923  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
925  3 * NumVars, NumUniqueDeclarations,
926  NumUniqueDeclarations + NumComponentLists, NumComponents));
927  return new (Mem) OMPUseDevicePtrClause(NumVars, NumUniqueDeclarations,
928  NumComponentLists, NumComponents);
929 }
930 
933  SourceLocation LParenLoc, SourceLocation EndLoc,
934  ArrayRef<Expr *> Vars,
935  ArrayRef<ValueDecl *> Declarations,
936  MappableExprComponentListsRef ComponentLists) {
937  unsigned NumVars = Vars.size();
938  unsigned NumUniqueDeclarations =
939  getUniqueDeclarationsTotalNumber(Declarations);
940  unsigned NumComponentLists = ComponentLists.size();
941  unsigned NumComponents = getComponentsTotalNumber(ComponentLists);
942 
943  // We need to allocate:
944  // NumVars x Expr* - we have an original list expression for each clause list
945  // entry.
946  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
947  // with each component list.
948  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
949  // number of lists for each unique declaration and the size of each component
950  // list.
951  // NumComponents x MappableComponent - the total of all the components in all
952  // the lists.
953  void *Mem = C.Allocate(
954  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
956  NumVars, NumUniqueDeclarations,
957  NumUniqueDeclarations + NumComponentLists, NumComponents));
958 
959  OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(
960  StartLoc, LParenLoc, EndLoc, NumVars, NumUniqueDeclarations,
961  NumComponentLists, NumComponents);
962 
963  Clause->setVarRefs(Vars);
964  Clause->setClauseInfo(Declarations, ComponentLists);
965  return Clause;
966 }
967 
969  const ASTContext &C, unsigned NumVars, unsigned NumUniqueDeclarations,
970  unsigned NumComponentLists, unsigned NumComponents) {
971  void *Mem = C.Allocate(
972  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
974  NumVars, NumUniqueDeclarations,
975  NumUniqueDeclarations + NumComponentLists, NumComponents));
976  return new (Mem) OMPIsDevicePtrClause(NumVars, NumUniqueDeclarations,
977  NumComponentLists, NumComponents);
978 }
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.
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
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:3396
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.
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 for NumVars original expressions, NumUniqueDeclarations de...
The base class of the type hierarchy.
Definition: Type.h:1353
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.
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
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:137
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:137
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:149
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.
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.
Expr * getCounterValue()
Get the loop counter value.
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
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.
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:108
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 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 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.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:628
Expr - This represents one expression.
Definition: Expr.h:106
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
Inits[]
Definition: OpenMPClause.h:136
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.
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:87
static OMPSharedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
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:650
Dataflow Directional Tag Classes.
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< ValueDecl *> Declarations)
This represents &#39;device&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation ModifierLoc
Location of linear modifier if any.
Definition: OpenMPClause.h:90
void setCounterValue(Expr *V)
Set the loop counter value for the depend clauses with &#39;sink|source&#39; kind of dependency.
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.
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
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:136
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:93
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.