clang  12.0.0git
OpenMPClause.cpp
Go to the documentation of this file.
1 //===- OpenMPClause.cpp - Classes for OpenMP clauses ----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the subclesses of Stmt class declared in OpenMPClause.h
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/AST/OpenMPClause.h"
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/Attr.h"
16 #include "clang/AST/Decl.h"
17 #include "clang/AST/DeclOpenMP.h"
18 #include "clang/Basic/LLVM.h"
20 #include "llvm/ADT/SmallPtrSet.h"
21 #include "llvm/Support/Casting.h"
22 #include "llvm/Support/ErrorHandling.h"
23 #include <algorithm>
24 #include <cassert>
25 
26 using namespace clang;
27 using namespace llvm;
28 using namespace omp;
29 
31  switch (getClauseKind()) {
32  default:
33  break;
34 #define OMP_CLAUSE_CLASS(Enum, Str, Class) \
35  case Enum: \
36  return static_cast<Class *>(this)->children();
37 #include "llvm/Frontend/OpenMP/OMPKinds.def"
38  }
39  llvm_unreachable("unknown OMPClause");
40 }
41 
43  switch (getClauseKind()) {
44 #define OMP_CLAUSE_CLASS(Enum, Str, Class) \
45  case Enum: \
46  return static_cast<Class *>(this)->used_children();
47 #include "llvm/Frontend/OpenMP/OMPKinds.def"
48  case OMPC_threadprivate:
49  case OMPC_uniform:
50  case OMPC_device_type:
51  case OMPC_match:
52  case OMPC_unknown:
53  break;
54  default:
55  break;
56  }
57  llvm_unreachable("unknown OMPClause");
58 }
59 
61  auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
62  return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
63 }
64 
66  switch (C->getClauseKind()) {
67  case OMPC_schedule:
68  return static_cast<const OMPScheduleClause *>(C);
69  case OMPC_dist_schedule:
70  return static_cast<const OMPDistScheduleClause *>(C);
71  case OMPC_firstprivate:
72  return static_cast<const OMPFirstprivateClause *>(C);
73  case OMPC_lastprivate:
74  return static_cast<const OMPLastprivateClause *>(C);
75  case OMPC_reduction:
76  return static_cast<const OMPReductionClause *>(C);
77  case OMPC_task_reduction:
78  return static_cast<const OMPTaskReductionClause *>(C);
79  case OMPC_in_reduction:
80  return static_cast<const OMPInReductionClause *>(C);
81  case OMPC_linear:
82  return static_cast<const OMPLinearClause *>(C);
83  case OMPC_if:
84  return static_cast<const OMPIfClause *>(C);
85  case OMPC_num_threads:
86  return static_cast<const OMPNumThreadsClause *>(C);
87  case OMPC_num_teams:
88  return static_cast<const OMPNumTeamsClause *>(C);
89  case OMPC_thread_limit:
90  return static_cast<const OMPThreadLimitClause *>(C);
91  case OMPC_device:
92  return static_cast<const OMPDeviceClause *>(C);
93  case OMPC_grainsize:
94  return static_cast<const OMPGrainsizeClause *>(C);
95  case OMPC_num_tasks:
96  return static_cast<const OMPNumTasksClause *>(C);
97  case OMPC_final:
98  return static_cast<const OMPFinalClause *>(C);
99  case OMPC_priority:
100  return static_cast<const OMPPriorityClause *>(C);
101  case OMPC_default:
102  case OMPC_proc_bind:
103  case OMPC_safelen:
104  case OMPC_simdlen:
105  case OMPC_allocator:
106  case OMPC_allocate:
107  case OMPC_collapse:
108  case OMPC_private:
109  case OMPC_shared:
110  case OMPC_aligned:
111  case OMPC_copyin:
112  case OMPC_copyprivate:
113  case OMPC_ordered:
114  case OMPC_nowait:
115  case OMPC_untied:
116  case OMPC_mergeable:
117  case OMPC_threadprivate:
118  case OMPC_flush:
119  case OMPC_depobj:
120  case OMPC_read:
121  case OMPC_write:
122  case OMPC_update:
123  case OMPC_capture:
124  case OMPC_seq_cst:
125  case OMPC_acq_rel:
126  case OMPC_acquire:
127  case OMPC_release:
128  case OMPC_relaxed:
129  case OMPC_depend:
130  case OMPC_threads:
131  case OMPC_simd:
132  case OMPC_map:
133  case OMPC_nogroup:
134  case OMPC_hint:
135  case OMPC_defaultmap:
136  case OMPC_unknown:
137  case OMPC_uniform:
138  case OMPC_to:
139  case OMPC_from:
140  case OMPC_use_device_ptr:
141  case OMPC_use_device_addr:
142  case OMPC_is_device_ptr:
143  case OMPC_unified_address:
144  case OMPC_unified_shared_memory:
145  case OMPC_reverse_offload:
146  case OMPC_dynamic_allocators:
147  case OMPC_atomic_default_mem_order:
148  case OMPC_device_type:
149  case OMPC_match:
150  case OMPC_nontemporal:
151  case OMPC_order:
152  case OMPC_destroy:
153  case OMPC_detach:
154  case OMPC_inclusive:
155  case OMPC_exclusive:
156  case OMPC_uses_allocators:
157  case OMPC_affinity:
158  break;
159  default:
160  break;
161  }
162 
163  return nullptr;
164 }
165 
167  auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
168  return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
169 }
170 
172  switch (C->getClauseKind()) {
173  case OMPC_lastprivate:
174  return static_cast<const OMPLastprivateClause *>(C);
175  case OMPC_reduction:
176  return static_cast<const OMPReductionClause *>(C);
177  case OMPC_task_reduction:
178  return static_cast<const OMPTaskReductionClause *>(C);
179  case OMPC_in_reduction:
180  return static_cast<const OMPInReductionClause *>(C);
181  case OMPC_linear:
182  return static_cast<const OMPLinearClause *>(C);
183  case OMPC_schedule:
184  case OMPC_dist_schedule:
185  case OMPC_firstprivate:
186  case OMPC_default:
187  case OMPC_proc_bind:
188  case OMPC_if:
189  case OMPC_final:
190  case OMPC_num_threads:
191  case OMPC_safelen:
192  case OMPC_simdlen:
193  case OMPC_allocator:
194  case OMPC_allocate:
195  case OMPC_collapse:
196  case OMPC_private:
197  case OMPC_shared:
198  case OMPC_aligned:
199  case OMPC_copyin:
200  case OMPC_copyprivate:
201  case OMPC_ordered:
202  case OMPC_nowait:
203  case OMPC_untied:
204  case OMPC_mergeable:
205  case OMPC_threadprivate:
206  case OMPC_flush:
207  case OMPC_depobj:
208  case OMPC_read:
209  case OMPC_write:
210  case OMPC_update:
211  case OMPC_capture:
212  case OMPC_seq_cst:
213  case OMPC_acq_rel:
214  case OMPC_acquire:
215  case OMPC_release:
216  case OMPC_relaxed:
217  case OMPC_depend:
218  case OMPC_device:
219  case OMPC_threads:
220  case OMPC_simd:
221  case OMPC_map:
222  case OMPC_num_teams:
223  case OMPC_thread_limit:
224  case OMPC_priority:
225  case OMPC_grainsize:
226  case OMPC_nogroup:
227  case OMPC_num_tasks:
228  case OMPC_hint:
229  case OMPC_defaultmap:
230  case OMPC_unknown:
231  case OMPC_uniform:
232  case OMPC_to:
233  case OMPC_from:
234  case OMPC_use_device_ptr:
235  case OMPC_use_device_addr:
236  case OMPC_is_device_ptr:
237  case OMPC_unified_address:
238  case OMPC_unified_shared_memory:
239  case OMPC_reverse_offload:
240  case OMPC_dynamic_allocators:
241  case OMPC_atomic_default_mem_order:
242  case OMPC_device_type:
243  case OMPC_match:
244  case OMPC_nontemporal:
245  case OMPC_order:
246  case OMPC_destroy:
247  case OMPC_detach:
248  case OMPC_inclusive:
249  case OMPC_exclusive:
250  case OMPC_uses_allocators:
251  case OMPC_affinity:
252  break;
253  default:
254  break;
255  }
256 
257  return nullptr;
258 }
259 
260 /// Gets the address of the original, non-captured, expression used in the
261 /// clause as the preinitializer.
263  if (!S)
264  return nullptr;
265  if (auto *DS = dyn_cast<DeclStmt>(S)) {
266  assert(DS->isSingleDecl() && "Only single expression must be captured.");
267  if (auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
268  return OED->getInitAddress();
269  }
270  return nullptr;
271 }
272 
274  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
275  return child_range(C, C + 1);
276  return child_range(&Condition, &Condition + 1);
277 }
278 
280  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
281  return child_range(C, C + 1);
282  return child_range(&Grainsize, &Grainsize + 1);
283 }
284 
286  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
287  return child_range(C, C + 1);
288  return child_range(&NumTasks, &NumTasks + 1);
289 }
290 
292  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
293  return child_range(C, C + 1);
294  return child_range(&Condition, &Condition + 1);
295 }
296 
298  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
299  return child_range(C, C + 1);
300  return child_range(&Priority, &Priority + 1);
301 }
302 
304  unsigned NumLoops,
305  SourceLocation StartLoc,
306  SourceLocation LParenLoc,
307  SourceLocation EndLoc) {
308  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
309  auto *Clause =
310  new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc);
311  for (unsigned I = 0; I < NumLoops; ++I) {
312  Clause->setLoopNumIterations(I, nullptr);
313  Clause->setLoopCounter(I, nullptr);
314  }
315  return Clause;
316 }
317 
319  unsigned NumLoops) {
320  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
321  auto *Clause = new (Mem) OMPOrderedClause(NumLoops);
322  for (unsigned I = 0; I < NumLoops; ++I) {
323  Clause->setLoopNumIterations(I, nullptr);
324  Clause->setLoopCounter(I, nullptr);
325  }
326  return Clause;
327 }
328 
330  Expr *NumIterations) {
331  assert(NumLoop < NumberOfLoops && "out of loops number.");
332  getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
333 }
334 
336  return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
337 }
338 
339 void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) {
340  assert(NumLoop < NumberOfLoops && "out of loops number.");
341  getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
342 }
343 
345  assert(NumLoop < NumberOfLoops && "out of loops number.");
346  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
347 }
348 
349 const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const {
350  assert(NumLoop < NumberOfLoops && "out of loops number.");
351  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
352 }
353 
355  SourceLocation StartLoc,
356  SourceLocation EndLoc) {
357  return new (C) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/false);
358 }
359 
362  SourceLocation LParenLoc, SourceLocation ArgumentLoc,
364  void *Mem =
365  C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
366  alignof(OMPUpdateClause));
367  auto *Clause =
368  new (Mem) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/true);
369  Clause->setLParenLoc(LParenLoc);
370  Clause->setArgumentLoc(ArgumentLoc);
371  Clause->setDependencyKind(DK);
372  return Clause;
373 }
374 
376  bool IsExtended) {
377  if (!IsExtended)
378  return new (C) OMPUpdateClause(/*IsExtended=*/false);
379  void *Mem =
380  C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1),
381  alignof(OMPUpdateClause));
382  auto *Clause = new (Mem) OMPUpdateClause(/*IsExtended=*/true);
383  Clause->IsExtended = true;
384  return Clause;
385 }
386 
387 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
388  assert(VL.size() == varlist_size() &&
389  "Number of private copies is not the same as the preallocated buffer");
390  std::copy(VL.begin(), VL.end(), varlist_end());
391 }
392 
395  SourceLocation LParenLoc, SourceLocation EndLoc,
396  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
397  // Allocate space for private variables and initializer expressions.
398  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
399  OMPPrivateClause *Clause =
400  new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
401  Clause->setVarRefs(VL);
402  Clause->setPrivateCopies(PrivateVL);
403  return Clause;
404 }
405 
407  unsigned N) {
408  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
409  return new (Mem) OMPPrivateClause(N);
410 }
411 
412 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
413  assert(VL.size() == varlist_size() &&
414  "Number of private copies is not the same as the preallocated buffer");
415  std::copy(VL.begin(), VL.end(), varlist_end());
416 }
417 
418 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
419  assert(VL.size() == varlist_size() &&
420  "Number of inits is not the same as the preallocated buffer");
421  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
422 }
423 
426  SourceLocation LParenLoc, SourceLocation EndLoc,
427  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
428  ArrayRef<Expr *> InitVL, Stmt *PreInit) {
429  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
430  OMPFirstprivateClause *Clause =
431  new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
432  Clause->setVarRefs(VL);
433  Clause->setPrivateCopies(PrivateVL);
434  Clause->setInits(InitVL);
435  Clause->setPreInitStmt(PreInit);
436  return Clause;
437 }
438 
440  unsigned N) {
441  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
442  return new (Mem) OMPFirstprivateClause(N);
443 }
444 
446  assert(PrivateCopies.size() == varlist_size() &&
447  "Number of private copies is not the same as the preallocated buffer");
448  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
449 }
450 
451 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
452  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
453  "not the same as the "
454  "preallocated buffer");
455  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
456 }
457 
458 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
459  assert(DstExprs.size() == varlist_size() && "Number of destination "
460  "expressions is not the same as "
461  "the preallocated buffer");
462  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
463 }
464 
465 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
466  assert(AssignmentOps.size() == varlist_size() &&
467  "Number of assignment expressions is not the same as the preallocated "
468  "buffer");
469  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
470  getDestinationExprs().end());
471 }
472 
474  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
475  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
476  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
477  OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
478  SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate) {
479  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
480  OMPLastprivateClause *Clause = new (Mem) OMPLastprivateClause(
481  StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size());
482  Clause->setVarRefs(VL);
483  Clause->setSourceExprs(SrcExprs);
484  Clause->setDestinationExprs(DstExprs);
485  Clause->setAssignmentOps(AssignmentOps);
486  Clause->setPreInitStmt(PreInit);
487  Clause->setPostUpdateExpr(PostUpdate);
488  return Clause;
489 }
490 
492  unsigned N) {
493  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
494  return new (Mem) OMPLastprivateClause(N);
495 }
496 
498  SourceLocation StartLoc,
499  SourceLocation LParenLoc,
500  SourceLocation EndLoc,
501  ArrayRef<Expr *> VL) {
502  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
503  OMPSharedClause *Clause =
504  new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
505  Clause->setVarRefs(VL);
506  return Clause;
507 }
508 
510  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
511  return new (Mem) OMPSharedClause(N);
512 }
513 
515  assert(PL.size() == varlist_size() &&
516  "Number of privates is not the same as the preallocated buffer");
517  std::copy(PL.begin(), PL.end(), varlist_end());
518 }
519 
521  assert(IL.size() == varlist_size() &&
522  "Number of inits is not the same as the preallocated buffer");
523  std::copy(IL.begin(), IL.end(), getPrivates().end());
524 }
525 
527  assert(UL.size() == varlist_size() &&
528  "Number of updates is not the same as the preallocated buffer");
529  std::copy(UL.begin(), UL.end(), getInits().end());
530 }
531 
533  assert(FL.size() == varlist_size() &&
534  "Number of final updates is not the same as the preallocated buffer");
535  std::copy(FL.begin(), FL.end(), getUpdates().end());
536 }
537 
539  assert(
540  UE.size() == varlist_size() + 1 &&
541  "Number of used expressions is not the same as the preallocated buffer");
542  std::copy(UE.begin(), UE.end(), getFinals().end() + 2);
543 }
544 
546  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
550  Stmt *PreInit, Expr *PostUpdate) {
551  // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
552  // (Step and CalcStep), list of used expression + step.
553  void *Mem =
554  C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
555  OMPLinearClause *Clause = new (Mem) OMPLinearClause(
556  StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
557  Clause->setVarRefs(VL);
558  Clause->setPrivates(PL);
559  Clause->setInits(IL);
560  // Fill update and final expressions with zeroes, they are provided later,
561  // after the directive construction.
562  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
563  nullptr);
564  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
565  nullptr);
566  std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
567  nullptr);
568  Clause->setStep(Step);
569  Clause->setCalcStep(CalcStep);
570  Clause->setPreInitStmt(PreInit);
571  Clause->setPostUpdateExpr(PostUpdate);
572  return Clause;
573 }
574 
576  unsigned NumVars) {
577  // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
578  // (Step and CalcStep), list of used expression + step.
579  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
580  return new (Mem) OMPLinearClause(NumVars);
581 }
582 
584  // Range includes only non-nullptr elements.
585  return child_range(
586  reinterpret_cast<Stmt **>(getUsedExprs().begin()),
587  reinterpret_cast<Stmt **>(llvm::find(getUsedExprs(), nullptr)));
588 }
589 
592  SourceLocation LParenLoc, SourceLocation ColonLoc,
593  SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
594  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
595  OMPAlignedClause *Clause = new (Mem)
596  OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
597  Clause->setVarRefs(VL);
598  Clause->setAlignment(A);
599  return Clause;
600 }
601 
603  unsigned NumVars) {
604  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
605  return new (Mem) OMPAlignedClause(NumVars);
606 }
607 
608 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
609  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
610  "not the same as the "
611  "preallocated buffer");
612  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
613 }
614 
615 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
616  assert(DstExprs.size() == varlist_size() && "Number of destination "
617  "expressions is not the same as "
618  "the preallocated buffer");
619  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
620 }
621 
622 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
623  assert(AssignmentOps.size() == varlist_size() &&
624  "Number of assignment expressions is not the same as the preallocated "
625  "buffer");
626  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
627  getDestinationExprs().end());
628 }
629 
631  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
632  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
633  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
634  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
635  OMPCopyinClause *Clause =
636  new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
637  Clause->setVarRefs(VL);
638  Clause->setSourceExprs(SrcExprs);
639  Clause->setDestinationExprs(DstExprs);
640  Clause->setAssignmentOps(AssignmentOps);
641  return Clause;
642 }
643 
645  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
646  return new (Mem) OMPCopyinClause(N);
647 }
648 
649 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
650  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
651  "not the same as the "
652  "preallocated buffer");
653  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
654 }
655 
656 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
657  assert(DstExprs.size() == varlist_size() && "Number of destination "
658  "expressions is not the same as "
659  "the preallocated buffer");
660  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
661 }
662 
663 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
664  assert(AssignmentOps.size() == varlist_size() &&
665  "Number of assignment expressions is not the same as the preallocated "
666  "buffer");
667  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
668  getDestinationExprs().end());
669 }
670 
672  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
673  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
674  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
675  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
676  OMPCopyprivateClause *Clause =
677  new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
678  Clause->setVarRefs(VL);
679  Clause->setSourceExprs(SrcExprs);
680  Clause->setDestinationExprs(DstExprs);
681  Clause->setAssignmentOps(AssignmentOps);
682  return Clause;
683 }
684 
686  unsigned N) {
687  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
688  return new (Mem) OMPCopyprivateClause(N);
689 }
690 
691 void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
692  assert(Privates.size() == varlist_size() &&
693  "Number of private copies is not the same as the preallocated buffer");
694  std::copy(Privates.begin(), Privates.end(), varlist_end());
695 }
696 
697 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
698  assert(
699  LHSExprs.size() == varlist_size() &&
700  "Number of LHS expressions is not the same as the preallocated buffer");
701  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
702 }
703 
704 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
705  assert(
706  RHSExprs.size() == varlist_size() &&
707  "Number of RHS expressions is not the same as the preallocated buffer");
708  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
709 }
710 
711 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
712  assert(ReductionOps.size() == varlist_size() && "Number of reduction "
713  "expressions is not the same "
714  "as the preallocated buffer");
715  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
716 }
717 
718 void OMPReductionClause::setInscanCopyOps(ArrayRef<Expr *> Ops) {
719  assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
720  assert(Ops.size() == varlist_size() && "Number of copy "
721  "expressions is not the same "
722  "as the preallocated buffer");
723  llvm::copy(Ops, getReductionOps().end());
724 }
725 
726 void OMPReductionClause::setInscanCopyArrayTemps(
727  ArrayRef<Expr *> CopyArrayTemps) {
728  assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
729  assert(CopyArrayTemps.size() == varlist_size() &&
730  "Number of copy temp expressions is not the same as the preallocated "
731  "buffer");
732  llvm::copy(CopyArrayTemps, getInscanCopyOps().end());
733 }
734 
735 void OMPReductionClause::setInscanCopyArrayElems(
736  ArrayRef<Expr *> CopyArrayElems) {
737  assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction.");
738  assert(CopyArrayElems.size() == varlist_size() &&
739  "Number of copy temp expressions is not the same as the preallocated "
740  "buffer");
741  llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end());
742 }
743 
745  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
746  SourceLocation ModifierLoc, SourceLocation EndLoc, SourceLocation ColonLoc,
748  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
749  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
750  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
751  ArrayRef<Expr *> CopyOps, ArrayRef<Expr *> CopyArrayTemps,
752  ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate) {
753  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
754  (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * VL.size()));
755  auto *Clause = new (Mem)
756  OMPReductionClause(StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc,
757  Modifier, VL.size(), QualifierLoc, NameInfo);
758  Clause->setVarRefs(VL);
759  Clause->setPrivates(Privates);
760  Clause->setLHSExprs(LHSExprs);
761  Clause->setRHSExprs(RHSExprs);
762  Clause->setReductionOps(ReductionOps);
763  Clause->setPreInitStmt(PreInit);
764  Clause->setPostUpdateExpr(PostUpdate);
765  if (Modifier == OMPC_REDUCTION_inscan) {
766  Clause->setInscanCopyOps(CopyOps);
767  Clause->setInscanCopyArrayTemps(CopyArrayTemps);
768  Clause->setInscanCopyArrayElems(CopyArrayElems);
769  } else {
770  assert(CopyOps.empty() &&
771  "copy operations are expected in inscan reductions only.");
772  assert(CopyArrayTemps.empty() &&
773  "copy array temps are expected in inscan reductions only.");
774  assert(CopyArrayElems.empty() &&
775  "copy array temps are expected in inscan reductions only.");
776  }
777  return Clause;
778 }
779 
783  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(
784  (Modifier == OMPC_REDUCTION_inscan ? 8 : 5) * N));
785  auto *Clause = new (Mem) OMPReductionClause(N);
786  Clause->setModifier(Modifier);
787  return Clause;
788 }
789 
790 void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
791  assert(Privates.size() == varlist_size() &&
792  "Number of private copies is not the same as the preallocated buffer");
793  std::copy(Privates.begin(), Privates.end(), varlist_end());
794 }
795 
796 void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
797  assert(
798  LHSExprs.size() == varlist_size() &&
799  "Number of LHS expressions is not the same as the preallocated buffer");
800  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
801 }
802 
803 void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
804  assert(
805  RHSExprs.size() == varlist_size() &&
806  "Number of RHS expressions is not the same as the preallocated buffer");
807  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
808 }
809 
810 void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
811  assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
812  "expressions is not the same "
813  "as the preallocated buffer");
814  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
815 }
816 
818  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
819  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
820  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
821  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
822  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
823  Expr *PostUpdate) {
824  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
826  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
827  Clause->setVarRefs(VL);
828  Clause->setPrivates(Privates);
829  Clause->setLHSExprs(LHSExprs);
830  Clause->setRHSExprs(RHSExprs);
831  Clause->setReductionOps(ReductionOps);
832  Clause->setPreInitStmt(PreInit);
833  Clause->setPostUpdateExpr(PostUpdate);
834  return Clause;
835 }
836 
838  unsigned N) {
839  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
840  return new (Mem) OMPTaskReductionClause(N);
841 }
842 
843 void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
844  assert(Privates.size() == varlist_size() &&
845  "Number of private copies is not the same as the preallocated buffer");
846  std::copy(Privates.begin(), Privates.end(), varlist_end());
847 }
848 
849 void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
850  assert(
851  LHSExprs.size() == varlist_size() &&
852  "Number of LHS expressions is not the same as the preallocated buffer");
853  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
854 }
855 
856 void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
857  assert(
858  RHSExprs.size() == varlist_size() &&
859  "Number of RHS expressions is not the same as the preallocated buffer");
860  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
861 }
862 
863 void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
864  assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
865  "expressions is not the same "
866  "as the preallocated buffer");
867  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
868 }
869 
870 void OMPInReductionClause::setTaskgroupDescriptors(
871  ArrayRef<Expr *> TaskgroupDescriptors) {
872  assert(TaskgroupDescriptors.size() == varlist_size() &&
873  "Number of in reduction descriptors is not the same as the "
874  "preallocated buffer");
875  std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
876  getReductionOps().end());
877 }
878 
880  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
881  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
882  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
883  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
884  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
885  ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
886  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
887  OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
888  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
889  Clause->setVarRefs(VL);
890  Clause->setPrivates(Privates);
891  Clause->setLHSExprs(LHSExprs);
892  Clause->setRHSExprs(RHSExprs);
893  Clause->setReductionOps(ReductionOps);
894  Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
895  Clause->setPreInitStmt(PreInit);
896  Clause->setPostUpdateExpr(PostUpdate);
897  return Clause;
898 }
899 
901  unsigned N) {
902  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
903  return new (Mem) OMPInReductionClause(N);
904 }
905 
908  SourceLocation LParenLoc, Expr *Allocator,
909  SourceLocation ColonLoc, SourceLocation EndLoc,
910  ArrayRef<Expr *> VL) {
911  // Allocate space for private variables and initializer expressions.
912  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
913  auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator,
914  ColonLoc, EndLoc, VL.size());
915  Clause->setVarRefs(VL);
916  return Clause;
917 }
918 
920  unsigned N) {
921  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
922  return new (Mem) OMPAllocateClause(N);
923 }
924 
926  SourceLocation StartLoc,
927  SourceLocation LParenLoc,
928  SourceLocation EndLoc,
929  ArrayRef<Expr *> VL) {
930  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
931  OMPFlushClause *Clause =
932  new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
933  Clause->setVarRefs(VL);
934  return Clause;
935 }
936 
938  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
939  return new (Mem) OMPFlushClause(N);
940 }
941 
943  SourceLocation StartLoc,
944  SourceLocation LParenLoc,
945  SourceLocation RParenLoc,
946  Expr *Depobj) {
947  auto *Clause = new (C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc);
948  Clause->setDepobj(Depobj);
949  return Clause;
950 }
951 
953  return new (C) OMPDepobjClause();
954 }
955 
958  SourceLocation LParenLoc, SourceLocation EndLoc,
959  Expr *DepModifier, OpenMPDependClauseKind DepKind,
960  SourceLocation DepLoc, SourceLocation ColonLoc,
961  ArrayRef<Expr *> VL, unsigned NumLoops) {
962  void *Mem = C.Allocate(
963  totalSizeToAlloc<Expr *>(VL.size() + /*depend-modifier*/ 1 + NumLoops),
964  alignof(OMPDependClause));
965  OMPDependClause *Clause = new (Mem)
966  OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
967  Clause->setVarRefs(VL);
968  Clause->setDependencyKind(DepKind);
969  Clause->setDependencyLoc(DepLoc);
970  Clause->setColonLoc(ColonLoc);
971  Clause->setModifier(DepModifier);
972  for (unsigned I = 0 ; I < NumLoops; ++I)
973  Clause->setLoopData(I, nullptr);
974  return Clause;
975 }
976 
978  unsigned NumLoops) {
979  void *Mem =
980  C.Allocate(totalSizeToAlloc<Expr *>(N + /*depend-modifier*/ 1 + NumLoops),
981  alignof(OMPDependClause));
982  return new (Mem) OMPDependClause(N, NumLoops);
983 }
984 
985 void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) {
986  assert((getDependencyKind() == OMPC_DEPEND_sink ||
987  getDependencyKind() == OMPC_DEPEND_source) &&
988  NumLoop < NumLoops &&
989  "Expected sink or source depend + loop index must be less number of "
990  "loops.");
991  auto *It = std::next(getVarRefs().end(), NumLoop + 1);
992  *It = Cnt;
993 }
994 
995 Expr *OMPDependClause::getLoopData(unsigned NumLoop) {
996  assert((getDependencyKind() == OMPC_DEPEND_sink ||
997  getDependencyKind() == OMPC_DEPEND_source) &&
998  NumLoop < NumLoops &&
999  "Expected sink or source depend + loop index must be less number of "
1000  "loops.");
1001  auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1002  return *It;
1003 }
1004 
1005 const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const {
1006  assert((getDependencyKind() == OMPC_DEPEND_sink ||
1007  getDependencyKind() == OMPC_DEPEND_source) &&
1008  NumLoop < NumLoops &&
1009  "Expected sink or source depend + loop index must be less number of "
1010  "loops.");
1011  const auto *It = std::next(getVarRefs().end(), NumLoop + 1);
1012  return *It;
1013 }
1014 
1015 void OMPDependClause::setModifier(Expr *DepModifier) {
1016  *getVarRefs().end() = DepModifier;
1017 }
1018 Expr *OMPDependClause::getModifier() { return *getVarRefs().end(); }
1019 
1021  MappableExprComponentListsRef ComponentLists) {
1022  unsigned TotalNum = 0u;
1023  for (auto &C : ComponentLists)
1024  TotalNum += C.size();
1025  return TotalNum;
1026 }
1027 
1029  ArrayRef<const ValueDecl *> Declarations) {
1030  unsigned TotalNum = 0u;
1032  for (const ValueDecl *D : Declarations) {
1033  const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
1034  if (Cache.count(VD))
1035  continue;
1036  ++TotalNum;
1037  Cache.insert(VD);
1038  }
1039  return TotalNum;
1040 }
1041 
1043  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1044  ArrayRef<ValueDecl *> Declarations,
1045  MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1046  ArrayRef<OpenMPMapModifierKind> MapModifiers,
1047  ArrayRef<SourceLocation> MapModifiersLoc,
1048  NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
1049  OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc) {
1051  Sizes.NumVars = Vars.size();
1052  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1053  Sizes.NumComponentLists = ComponentLists.size();
1054  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1055 
1056  // We need to allocate:
1057  // 2 x NumVars x Expr* - we have an original list expression and an associated
1058  // user-defined mapper for each clause list entry.
1059  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1060  // with each component list.
1061  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1062  // number of lists for each unique declaration and the size of each component
1063  // list.
1064  // NumComponents x MappableComponent - the total of all the components in all
1065  // the lists.
1066  void *Mem = C.Allocate(
1067  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1069  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1071  Sizes.NumComponents));
1072  OMPMapClause *Clause = new (Mem)
1073  OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
1074  Type, TypeIsImplicit, TypeLoc, Locs, Sizes);
1075 
1076  Clause->setVarRefs(Vars);
1077  Clause->setUDMapperRefs(UDMapperRefs);
1078  Clause->setClauseInfo(Declarations, ComponentLists);
1079  Clause->setMapType(Type);
1080  Clause->setMapLoc(TypeLoc);
1081  return Clause;
1082 }
1083 
1084 OMPMapClause *
1086  const OMPMappableExprListSizeTy &Sizes) {
1087  void *Mem = C.Allocate(
1088  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1090  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1092  Sizes.NumComponents));
1093  return new (Mem) OMPMapClause(Sizes);
1094 }
1095 
1097  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1098  ArrayRef<ValueDecl *> Declarations,
1099  MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1100  NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
1102  Sizes.NumVars = Vars.size();
1103  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1104  Sizes.NumComponentLists = ComponentLists.size();
1105  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1106 
1107  // We need to allocate:
1108  // 2 x NumVars x Expr* - we have an original list expression and an associated
1109  // user-defined mapper for each clause list entry.
1110  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1111  // with each component list.
1112  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1113  // number of lists for each unique declaration and the size of each component
1114  // list.
1115  // NumComponents x MappableComponent - the total of all the components in all
1116  // the lists.
1117  void *Mem = C.Allocate(
1118  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1120  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1122  Sizes.NumComponents));
1123 
1124  auto *Clause = new (Mem) OMPToClause(UDMQualifierLoc, MapperId, Locs, Sizes);
1125 
1126  Clause->setVarRefs(Vars);
1127  Clause->setUDMapperRefs(UDMapperRefs);
1128  Clause->setClauseInfo(Declarations, ComponentLists);
1129  return Clause;
1130 }
1131 
1133  const OMPMappableExprListSizeTy &Sizes) {
1134  void *Mem = C.Allocate(
1135  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1137  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1139  Sizes.NumComponents));
1140  return new (Mem) OMPToClause(Sizes);
1141 }
1142 
1144  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1145  ArrayRef<ValueDecl *> Declarations,
1146  MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1147  NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
1149  Sizes.NumVars = Vars.size();
1150  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1151  Sizes.NumComponentLists = ComponentLists.size();
1152  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1153 
1154  // We need to allocate:
1155  // 2 x NumVars x Expr* - we have an original list expression and an associated
1156  // user-defined mapper for each clause list entry.
1157  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1158  // with each component list.
1159  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1160  // number of lists for each unique declaration and the size of each component
1161  // list.
1162  // NumComponents x MappableComponent - the total of all the components in all
1163  // the lists.
1164  void *Mem = C.Allocate(
1165  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1167  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1169  Sizes.NumComponents));
1170 
1171  auto *Clause =
1172  new (Mem) OMPFromClause(UDMQualifierLoc, MapperId, Locs, Sizes);
1173 
1174  Clause->setVarRefs(Vars);
1175  Clause->setUDMapperRefs(UDMapperRefs);
1176  Clause->setClauseInfo(Declarations, ComponentLists);
1177  return Clause;
1178 }
1179 
1180 OMPFromClause *
1182  const OMPMappableExprListSizeTy &Sizes) {
1183  void *Mem = C.Allocate(
1184  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1186  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1188  Sizes.NumComponents));
1189  return new (Mem) OMPFromClause(Sizes);
1190 }
1191 
1192 void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
1193  assert(VL.size() == varlist_size() &&
1194  "Number of private copies is not the same as the preallocated buffer");
1195  std::copy(VL.begin(), VL.end(), varlist_end());
1196 }
1197 
1198 void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
1199  assert(VL.size() == varlist_size() &&
1200  "Number of inits is not the same as the preallocated buffer");
1201  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
1202 }
1203 
1205  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1207  ArrayRef<ValueDecl *> Declarations,
1208  MappableExprComponentListsRef ComponentLists) {
1210  Sizes.NumVars = Vars.size();
1211  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1212  Sizes.NumComponentLists = ComponentLists.size();
1213  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1214 
1215  // We need to allocate:
1216  // NumVars x Expr* - we have an original list expression for each clause
1217  // list entry.
1218  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1219  // with each component list.
1220  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1221  // number of lists for each unique declaration and the size of each component
1222  // list.
1223  // NumComponents x MappableComponent - the total of all the components in all
1224  // the lists.
1225  void *Mem = C.Allocate(
1226  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1228  3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1230  Sizes.NumComponents));
1231 
1232  OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(Locs, Sizes);
1233 
1234  Clause->setVarRefs(Vars);
1235  Clause->setPrivateCopies(PrivateVars);
1236  Clause->setInits(Inits);
1237  Clause->setClauseInfo(Declarations, ComponentLists);
1238  return Clause;
1239 }
1240 
1243  const OMPMappableExprListSizeTy &Sizes) {
1244  void *Mem = C.Allocate(
1245  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1247  3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1249  Sizes.NumComponents));
1250  return new (Mem) OMPUseDevicePtrClause(Sizes);
1251 }
1252 
1255  ArrayRef<Expr *> Vars,
1256  ArrayRef<ValueDecl *> Declarations,
1257  MappableExprComponentListsRef ComponentLists) {
1259  Sizes.NumVars = Vars.size();
1260  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1261  Sizes.NumComponentLists = ComponentLists.size();
1262  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1263 
1264  // We need to allocate:
1265  // 3 x NumVars x Expr* - we have an original list expression for each clause
1266  // list entry and an equal number of private copies and inits.
1267  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1268  // with each component list.
1269  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1270  // number of lists for each unique declaration and the size of each component
1271  // list.
1272  // NumComponents x MappableComponent - the total of all the components in all
1273  // the lists.
1274  void *Mem = C.Allocate(
1275  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1277  Sizes.NumVars, Sizes.NumUniqueDeclarations,
1279  Sizes.NumComponents));
1280 
1281  auto *Clause = new (Mem) OMPUseDeviceAddrClause(Locs, Sizes);
1282 
1283  Clause->setVarRefs(Vars);
1284  Clause->setClauseInfo(Declarations, ComponentLists);
1285  return Clause;
1286 }
1287 
1290  const OMPMappableExprListSizeTy &Sizes) {
1291  void *Mem = C.Allocate(
1292  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1294  Sizes.NumVars, Sizes.NumUniqueDeclarations,
1296  Sizes.NumComponents));
1297  return new (Mem) OMPUseDeviceAddrClause(Sizes);
1298 }
1299 
1302  ArrayRef<Expr *> Vars,
1303  ArrayRef<ValueDecl *> Declarations,
1304  MappableExprComponentListsRef ComponentLists) {
1306  Sizes.NumVars = Vars.size();
1307  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1308  Sizes.NumComponentLists = ComponentLists.size();
1309  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1310 
1311  // We need to allocate:
1312  // NumVars x Expr* - we have an original list expression for each clause list
1313  // entry.
1314  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1315  // with each component list.
1316  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1317  // number of lists for each unique declaration and the size of each component
1318  // list.
1319  // NumComponents x MappableComponent - the total of all the components in all
1320  // the lists.
1321  void *Mem = C.Allocate(
1322  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1324  Sizes.NumVars, Sizes.NumUniqueDeclarations,
1326  Sizes.NumComponents));
1327 
1328  OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1329 
1330  Clause->setVarRefs(Vars);
1331  Clause->setClauseInfo(Declarations, ComponentLists);
1332  return Clause;
1333 }
1334 
1337  const OMPMappableExprListSizeTy &Sizes) {
1338  void *Mem = C.Allocate(
1339  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1341  Sizes.NumVars, Sizes.NumUniqueDeclarations,
1343  Sizes.NumComponents));
1344  return new (Mem) OMPIsDevicePtrClause(Sizes);
1345 }
1346 
1348  SourceLocation StartLoc,
1349  SourceLocation LParenLoc,
1350  SourceLocation EndLoc,
1351  ArrayRef<Expr *> VL) {
1352  // Allocate space for nontemporal variables + private references.
1353  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
1354  auto *Clause =
1355  new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size());
1356  Clause->setVarRefs(VL);
1357  return Clause;
1358 }
1359 
1361  unsigned N) {
1362  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
1363  return new (Mem) OMPNontemporalClause(N);
1364 }
1365 
1367  assert(VL.size() == varlist_size() && "Number of private references is not "
1368  "the same as the preallocated buffer");
1369  std::copy(VL.begin(), VL.end(), varlist_end());
1370 }
1371 
1373  SourceLocation StartLoc,
1374  SourceLocation LParenLoc,
1375  SourceLocation EndLoc,
1376  ArrayRef<Expr *> VL) {
1377  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1378  auto *Clause =
1379  new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1380  Clause->setVarRefs(VL);
1381  return Clause;
1382 }
1383 
1385  unsigned N) {
1386  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1387  return new (Mem) OMPInclusiveClause(N);
1388 }
1389 
1391  SourceLocation StartLoc,
1392  SourceLocation LParenLoc,
1393  SourceLocation EndLoc,
1394  ArrayRef<Expr *> VL) {
1395  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
1396  auto *Clause =
1397  new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size());
1398  Clause->setVarRefs(VL);
1399  return Clause;
1400 }
1401 
1403  unsigned N) {
1404  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
1405  return new (Mem) OMPExclusiveClause(N);
1406 }
1407 
1408 void OMPUsesAllocatorsClause::setAllocatorsData(
1410  assert(Data.size() == NumOfAllocators &&
1411  "Size of allocators data is not the same as the preallocated buffer.");
1412  for (unsigned I = 0, E = Data.size(); I < E; ++I) {
1413  const OMPUsesAllocatorsClause::Data &D = Data[I];
1414  getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1415  static_cast<int>(ExprOffsets::Allocator)] =
1416  D.Allocator;
1417  getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1418  static_cast<int>(
1419  ExprOffsets::AllocatorTraits)] =
1420  D.AllocatorTraits;
1421  getTrailingObjects<
1422  SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1423  static_cast<int>(ParenLocsOffsets::LParen)] =
1424  D.LParenLoc;
1425  getTrailingObjects<
1426  SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1427  static_cast<int>(ParenLocsOffsets::RParen)] =
1428  D.RParenLoc;
1429  }
1430 }
1431 
1435  Data.Allocator =
1436  getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1437  static_cast<int>(ExprOffsets::Allocator)];
1438  Data.AllocatorTraits =
1439  getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) +
1440  static_cast<int>(
1441  ExprOffsets::AllocatorTraits)];
1442  Data.LParenLoc = getTrailingObjects<
1443  SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1444  static_cast<int>(ParenLocsOffsets::LParen)];
1445  Data.RParenLoc = getTrailingObjects<
1446  SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) +
1447  static_cast<int>(ParenLocsOffsets::RParen)];
1448  return Data;
1449 }
1450 
1453  SourceLocation LParenLoc, SourceLocation EndLoc,
1455  void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1456  static_cast<int>(ExprOffsets::Total) * Data.size(),
1457  static_cast<int>(ParenLocsOffsets::Total) * Data.size()));
1458  auto *Clause = new (Mem)
1459  OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc, Data.size());
1460  Clause->setAllocatorsData(Data);
1461  return Clause;
1462 }
1463 
1466  void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>(
1467  static_cast<int>(ExprOffsets::Total) * N,
1468  static_cast<int>(ParenLocsOffsets::Total) * N));
1469  return new (Mem) OMPUsesAllocatorsClause(N);
1470 }
1471 
1474  SourceLocation LParenLoc, SourceLocation ColonLoc,
1475  SourceLocation EndLoc, Expr *Modifier,
1476  ArrayRef<Expr *> Locators) {
1477  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1));
1478  auto *Clause = new (Mem)
1479  OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size());
1480  Clause->setModifier(Modifier);
1481  Clause->setVarRefs(Locators);
1482  return Clause;
1483 }
1484 
1486  unsigned N) {
1487  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1));
1488  return new (Mem) OMPAffinityClause(N);
1489 }
1490 
1491 //===----------------------------------------------------------------------===//
1492 // OpenMP clauses printing methods
1493 //===----------------------------------------------------------------------===//
1494 
1495 void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
1496  OS << "if(";
1497  if (Node->getNameModifier() != OMPD_unknown)
1498  OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
1499  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1500  OS << ")";
1501 }
1502 
1503 void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
1504  OS << "final(";
1505  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1506  OS << ")";
1507 }
1508 
1509 void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
1510  OS << "num_threads(";
1511  Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);
1512  OS << ")";
1513 }
1514 
1515 void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
1516  OS << "safelen(";
1517  Node->getSafelen()->printPretty(OS, nullptr, Policy, 0);
1518  OS << ")";
1519 }
1520 
1521 void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) {
1522  OS << "simdlen(";
1523  Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0);
1524  OS << ")";
1525 }
1526 
1527 void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) {
1528  OS << "allocator(";
1529  Node->getAllocator()->printPretty(OS, nullptr, Policy, 0);
1530  OS << ")";
1531 }
1532 
1533 void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
1534  OS << "collapse(";
1535  Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0);
1536  OS << ")";
1537 }
1538 
1539 void OMPClausePrinter::VisitOMPDetachClause(OMPDetachClause *Node) {
1540  OS << "detach(";
1541  Node->getEventHandler()->printPretty(OS, nullptr, Policy, 0);
1542  OS << ")";
1543 }
1544 
1545 void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
1546  OS << "default("
1547  << getOpenMPSimpleClauseTypeName(OMPC_default,
1548  unsigned(Node->getDefaultKind()))
1549  << ")";
1550 }
1551 
1552 void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
1553  OS << "proc_bind("
1554  << getOpenMPSimpleClauseTypeName(OMPC_proc_bind,
1555  unsigned(Node->getProcBindKind()))
1556  << ")";
1557 }
1558 
1559 void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
1560  OS << "unified_address";
1561 }
1562 
1563 void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1565  OS << "unified_shared_memory";
1566 }
1567 
1568 void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
1569  OS << "reverse_offload";
1570 }
1571 
1572 void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1574  OS << "dynamic_allocators";
1575 }
1576 
1577 void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1579  OS << "atomic_default_mem_order("
1580  << getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order,
1582  << ")";
1583 }
1584 
1585 void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
1586  OS << "schedule(";
1588  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1589  Node->getFirstScheduleModifier());
1591  OS << ", ";
1592  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1593  Node->getSecondScheduleModifier());
1594  }
1595  OS << ": ";
1596  }
1597  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind());
1598  if (auto *E = Node->getChunkSize()) {
1599  OS << ", ";
1600  E->printPretty(OS, nullptr, Policy);
1601  }
1602  OS << ")";
1603 }
1604 
1605 void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
1606  OS << "ordered";
1607  if (auto *Num = Node->getNumForLoops()) {
1608  OS << "(";
1609  Num->printPretty(OS, nullptr, Policy, 0);
1610  OS << ")";
1611  }
1612 }
1613 
1614 void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
1615  OS << "nowait";
1616 }
1617 
1618 void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
1619  OS << "untied";
1620 }
1621 
1622 void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
1623  OS << "nogroup";
1624 }
1625 
1626 void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
1627  OS << "mergeable";
1628 }
1629 
1630 void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
1631 
1632 void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
1633 
1634 void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *Node) {
1635  OS << "update";
1636  if (Node->isExtended()) {
1637  OS << "(";
1639  Node->getDependencyKind());
1640  OS << ")";
1641  }
1642 }
1643 
1644 void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
1645  OS << "capture";
1646 }
1647 
1648 void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
1649  OS << "seq_cst";
1650 }
1651 
1652 void OMPClausePrinter::VisitOMPAcqRelClause(OMPAcqRelClause *) {
1653  OS << "acq_rel";
1654 }
1655 
1656 void OMPClausePrinter::VisitOMPAcquireClause(OMPAcquireClause *) {
1657  OS << "acquire";
1658 }
1659 
1660 void OMPClausePrinter::VisitOMPReleaseClause(OMPReleaseClause *) {
1661  OS << "release";
1662 }
1663 
1664 void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) {
1665  OS << "relaxed";
1666 }
1667 
1668 void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
1669  OS << "threads";
1670 }
1671 
1672 void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
1673 
1674 void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
1675  OS << "device(";
1677  if (Modifier != OMPC_DEVICE_unknown) {
1678  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier)
1679  << ": ";
1680  }
1681  Node->getDevice()->printPretty(OS, nullptr, Policy, 0);
1682  OS << ")";
1683 }
1684 
1685 void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
1686  OS << "num_teams(";
1687  Node->getNumTeams()->printPretty(OS, nullptr, Policy, 0);
1688  OS << ")";
1689 }
1690 
1691 void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
1692  OS << "thread_limit(";
1693  Node->getThreadLimit()->printPretty(OS, nullptr, Policy, 0);
1694  OS << ")";
1695 }
1696 
1697 void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
1698  OS << "priority(";
1699  Node->getPriority()->printPretty(OS, nullptr, Policy, 0);
1700  OS << ")";
1701 }
1702 
1703 void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
1704  OS << "grainsize(";
1705  Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0);
1706  OS << ")";
1707 }
1708 
1709 void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
1710  OS << "num_tasks(";
1711  Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0);
1712  OS << ")";
1713 }
1714 
1715 void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
1716  OS << "hint(";
1717  Node->getHint()->printPretty(OS, nullptr, Policy, 0);
1718  OS << ")";
1719 }
1720 
1721 void OMPClausePrinter::VisitOMPDestroyClause(OMPDestroyClause *) {
1722  OS << "destroy";
1723 }
1724 
1725 template<typename T>
1726 void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1727  for (typename T::varlist_iterator I = Node->varlist_begin(),
1728  E = Node->varlist_end();
1729  I != E; ++I) {
1730  assert(*I && "Expected non-null Stmt");
1731  OS << (I == Node->varlist_begin() ? StartSym : ',');
1732  if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1733  if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1734  DRE->printPretty(OS, nullptr, Policy, 0);
1735  else
1736  DRE->getDecl()->printQualifiedName(OS);
1737  } else
1738  (*I)->printPretty(OS, nullptr, Policy, 0);
1739  }
1740 }
1741 
1742 void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
1743  if (Node->varlist_empty())
1744  return;
1745  OS << "allocate";
1746  if (Expr *Allocator = Node->getAllocator()) {
1747  OS << "(";
1748  Allocator->printPretty(OS, nullptr, Policy, 0);
1749  OS << ":";
1750  VisitOMPClauseList(Node, ' ');
1751  } else {
1752  VisitOMPClauseList(Node, '(');
1753  }
1754  OS << ")";
1755 }
1756 
1757 void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
1758  if (!Node->varlist_empty()) {
1759  OS << "private";
1760  VisitOMPClauseList(Node, '(');
1761  OS << ")";
1762  }
1763 }
1764 
1765 void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
1766  if (!Node->varlist_empty()) {
1767  OS << "firstprivate";
1768  VisitOMPClauseList(Node, '(');
1769  OS << ")";
1770  }
1771 }
1772 
1773 void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
1774  if (!Node->varlist_empty()) {
1775  OS << "lastprivate";
1776  OpenMPLastprivateModifier LPKind = Node->getKind();
1777  if (LPKind != OMPC_LASTPRIVATE_unknown) {
1778  OS << "("
1779  << getOpenMPSimpleClauseTypeName(OMPC_lastprivate, Node->getKind())
1780  << ":";
1781  }
1782  VisitOMPClauseList(Node, LPKind == OMPC_LASTPRIVATE_unknown ? '(' : ' ');
1783  OS << ")";
1784  }
1785 }
1786 
1787 void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
1788  if (!Node->varlist_empty()) {
1789  OS << "shared";
1790  VisitOMPClauseList(Node, '(');
1791  OS << ")";
1792  }
1793 }
1794 
1795 void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
1796  if (!Node->varlist_empty()) {
1797  OS << "reduction(";
1798  if (Node->getModifierLoc().isValid())
1799  OS << getOpenMPSimpleClauseTypeName(OMPC_reduction, Node->getModifier())
1800  << ", ";
1801  NestedNameSpecifier *QualifierLoc =
1805  if (QualifierLoc == nullptr && OOK != OO_None) {
1806  // Print reduction identifier in C format
1807  OS << getOperatorSpelling(OOK);
1808  } else {
1809  // Use C++ format
1810  if (QualifierLoc != nullptr)
1811  QualifierLoc->print(OS, Policy);
1812  OS << Node->getNameInfo();
1813  }
1814  OS << ":";
1815  VisitOMPClauseList(Node, ' ');
1816  OS << ")";
1817  }
1818 }
1819 
1820 void OMPClausePrinter::VisitOMPTaskReductionClause(
1821  OMPTaskReductionClause *Node) {
1822  if (!Node->varlist_empty()) {
1823  OS << "task_reduction(";
1824  NestedNameSpecifier *QualifierLoc =
1828  if (QualifierLoc == nullptr && OOK != OO_None) {
1829  // Print reduction identifier in C format
1830  OS << getOperatorSpelling(OOK);
1831  } else {
1832  // Use C++ format
1833  if (QualifierLoc != nullptr)
1834  QualifierLoc->print(OS, Policy);
1835  OS << Node->getNameInfo();
1836  }
1837  OS << ":";
1838  VisitOMPClauseList(Node, ' ');
1839  OS << ")";
1840  }
1841 }
1842 
1843 void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
1844  if (!Node->varlist_empty()) {
1845  OS << "in_reduction(";
1846  NestedNameSpecifier *QualifierLoc =
1850  if (QualifierLoc == nullptr && OOK != OO_None) {
1851  // Print reduction identifier in C format
1852  OS << getOperatorSpelling(OOK);
1853  } else {
1854  // Use C++ format
1855  if (QualifierLoc != nullptr)
1856  QualifierLoc->print(OS, Policy);
1857  OS << Node->getNameInfo();
1858  }
1859  OS << ":";
1860  VisitOMPClauseList(Node, ' ');
1861  OS << ")";
1862  }
1863 }
1864 
1865 void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
1866  if (!Node->varlist_empty()) {
1867  OS << "linear";
1868  if (Node->getModifierLoc().isValid()) {
1869  OS << '('
1870  << getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier());
1871  }
1872  VisitOMPClauseList(Node, '(');
1873  if (Node->getModifierLoc().isValid())
1874  OS << ')';
1875  if (Node->getStep() != nullptr) {
1876  OS << ": ";
1877  Node->getStep()->printPretty(OS, nullptr, Policy, 0);
1878  }
1879  OS << ")";
1880  }
1881 }
1882 
1883 void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
1884  if (!Node->varlist_empty()) {
1885  OS << "aligned";
1886  VisitOMPClauseList(Node, '(');
1887  if (Node->getAlignment() != nullptr) {
1888  OS << ": ";
1889  Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
1890  }
1891  OS << ")";
1892  }
1893 }
1894 
1895 void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
1896  if (!Node->varlist_empty()) {
1897  OS << "copyin";
1898  VisitOMPClauseList(Node, '(');
1899  OS << ")";
1900  }
1901 }
1902 
1903 void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
1904  if (!Node->varlist_empty()) {
1905  OS << "copyprivate";
1906  VisitOMPClauseList(Node, '(');
1907  OS << ")";
1908  }
1909 }
1910 
1911 void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
1912  if (!Node->varlist_empty()) {
1913  VisitOMPClauseList(Node, '(');
1914  OS << ")";
1915  }
1916 }
1917 
1918 void OMPClausePrinter::VisitOMPDepobjClause(OMPDepobjClause *Node) {
1919  OS << "(";
1920  Node->getDepobj()->printPretty(OS, nullptr, Policy, 0);
1921  OS << ")";
1922 }
1923 
1924 void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
1925  OS << "depend(";
1926  if (Expr *DepModifier = Node->getModifier()) {
1927  DepModifier->printPretty(OS, nullptr, Policy);
1928  OS << ", ";
1929  }
1930  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
1931  Node->getDependencyKind());
1932  if (!Node->varlist_empty()) {
1933  OS << " :";
1934  VisitOMPClauseList(Node, ' ');
1935  }
1936  OS << ")";
1937 }
1938 
1939 void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
1940  if (!Node->varlist_empty()) {
1941  OS << "map(";
1942  if (Node->getMapType() != OMPC_MAP_unknown) {
1943  for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; ++I) {
1945  OS << getOpenMPSimpleClauseTypeName(OMPC_map,
1946  Node->getMapTypeModifier(I));
1947  if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper) {
1948  OS << '(';
1949  NestedNameSpecifier *MapperNNS =
1951  if (MapperNNS)
1952  MapperNNS->print(OS, Policy);
1953  OS << Node->getMapperIdInfo() << ')';
1954  }
1955  OS << ',';
1956  }
1957  }
1958  OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType());
1959  OS << ':';
1960  }
1961  VisitOMPClauseList(Node, ' ');
1962  OS << ")";
1963  }
1964 }
1965 
1966 void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
1967  if (!Node->varlist_empty()) {
1968  OS << "to";
1969  DeclarationNameInfo MapperId = Node->getMapperIdInfo();
1970  if (MapperId.getName() && !MapperId.getName().isEmpty()) {
1971  OS << '(';
1972  OS << "mapper(";
1973  NestedNameSpecifier *MapperNNS =
1975  if (MapperNNS)
1976  MapperNNS->print(OS, Policy);
1977  OS << MapperId << "):";
1978  VisitOMPClauseList(Node, ' ');
1979  } else {
1980  VisitOMPClauseList(Node, '(');
1981  }
1982  OS << ")";
1983  }
1984 }
1985 
1986 void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
1987  if (!Node->varlist_empty()) {
1988  OS << "from";
1989  DeclarationNameInfo MapperId = Node->getMapperIdInfo();
1990  if (MapperId.getName() && !MapperId.getName().isEmpty()) {
1991  OS << '(';
1992  OS << "mapper(";
1993  NestedNameSpecifier *MapperNNS =
1995  if (MapperNNS)
1996  MapperNNS->print(OS, Policy);
1997  OS << MapperId << "):";
1998  VisitOMPClauseList(Node, ' ');
1999  } else {
2000  VisitOMPClauseList(Node, '(');
2001  }
2002  OS << ")";
2003  }
2004 }
2005 
2006 void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
2007  OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName(
2008  OMPC_dist_schedule, Node->getDistScheduleKind());
2009  if (auto *E = Node->getChunkSize()) {
2010  OS << ", ";
2011  E->printPretty(OS, nullptr, Policy);
2012  }
2013  OS << ")";
2014 }
2015 
2016 void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
2017  OS << "defaultmap(";
2018  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
2019  Node->getDefaultmapModifier());
2020  if (Node->getDefaultmapKind() != OMPC_DEFAULTMAP_unknown) {
2021  OS << ": ";
2022  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
2023  Node->getDefaultmapKind());
2024  }
2025  OS << ")";
2026 }
2027 
2028 void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
2029  if (!Node->varlist_empty()) {
2030  OS << "use_device_ptr";
2031  VisitOMPClauseList(Node, '(');
2032  OS << ")";
2033  }
2034 }
2035 
2036 void OMPClausePrinter::VisitOMPUseDeviceAddrClause(
2037  OMPUseDeviceAddrClause *Node) {
2038  if (!Node->varlist_empty()) {
2039  OS << "use_device_addr";
2040  VisitOMPClauseList(Node, '(');
2041  OS << ")";
2042  }
2043 }
2044 
2045 void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
2046  if (!Node->varlist_empty()) {
2047  OS << "is_device_ptr";
2048  VisitOMPClauseList(Node, '(');
2049  OS << ")";
2050  }
2051 }
2052 
2053 void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) {
2054  if (!Node->varlist_empty()) {
2055  OS << "nontemporal";
2056  VisitOMPClauseList(Node, '(');
2057  OS << ")";
2058  }
2059 }
2060 
2061 void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) {
2062  OS << "order(" << getOpenMPSimpleClauseTypeName(OMPC_order, Node->getKind())
2063  << ")";
2064 }
2065 
2066 void OMPClausePrinter::VisitOMPInclusiveClause(OMPInclusiveClause *Node) {
2067  if (!Node->varlist_empty()) {
2068  OS << "inclusive";
2069  VisitOMPClauseList(Node, '(');
2070  OS << ")";
2071  }
2072 }
2073 
2074 void OMPClausePrinter::VisitOMPExclusiveClause(OMPExclusiveClause *Node) {
2075  if (!Node->varlist_empty()) {
2076  OS << "exclusive";
2077  VisitOMPClauseList(Node, '(');
2078  OS << ")";
2079  }
2080 }
2081 
2082 void OMPClausePrinter::VisitOMPUsesAllocatorsClause(
2083  OMPUsesAllocatorsClause *Node) {
2084  if (Node->getNumberOfAllocators() == 0)
2085  return;
2086  OS << "uses_allocators(";
2087  for (unsigned I = 0, E = Node->getNumberOfAllocators(); I < E; ++I) {
2089  Data.Allocator->printPretty(OS, nullptr, Policy);
2090  if (Data.AllocatorTraits) {
2091  OS << "(";
2092  Data.AllocatorTraits->printPretty(OS, nullptr, Policy);
2093  OS << ")";
2094  }
2095  if (I < E - 1)
2096  OS << ",";
2097  }
2098  OS << ")";
2099 }
2100 
2101 void OMPClausePrinter::VisitOMPAffinityClause(OMPAffinityClause *Node) {
2102  if (Node->varlist_empty())
2103  return;
2104  OS << "affinity";
2105  char StartSym = '(';
2106  if (Expr *Modifier = Node->getModifier()) {
2107  OS << "(";
2108  Modifier->printPretty(OS, nullptr, Policy);
2109  OS << " :";
2110  StartSym = ' ';
2111  }
2112  VisitOMPClauseList(Node, StartSym);
2113  OS << ")";
2114 }
2115 
2117  VariantMatchInfo &VMI) const {
2118  for (const OMPTraitSet &Set : Sets) {
2119  for (const OMPTraitSelector &Selector : Set.Selectors) {
2120 
2121  // User conditions are special as we evaluate the condition here.
2122  if (Selector.Kind == TraitSelector::user_condition) {
2123  assert(Selector.ScoreOrCondition &&
2124  "Ill-formed user condition, expected condition expression!");
2125  assert(Selector.Properties.size() == 1 &&
2126  Selector.Properties.front().Kind ==
2127  TraitProperty::user_condition_unknown &&
2128  "Ill-formed user condition, expected unknown trait property!");
2129 
2130  llvm::APSInt CondVal;
2131  if (Selector.ScoreOrCondition->isIntegerConstantExpr(CondVal, ASTCtx))
2132  VMI.addTrait(CondVal.isNullValue()
2133  ? TraitProperty::user_condition_false
2134  : TraitProperty::user_condition_true);
2135  else
2136  VMI.addTrait(TraitProperty::user_condition_false);
2137  continue;
2138  }
2139 
2140  llvm::APSInt Score;
2141  llvm::APInt *ScorePtr = nullptr;
2142  if (Selector.ScoreOrCondition) {
2143  if (Selector.ScoreOrCondition->isIntegerConstantExpr(Score, ASTCtx))
2144  ScorePtr = &Score;
2145  else
2146  VMI.addTrait(TraitProperty::user_condition_false);
2147  }
2148 
2149  for (const OMPTraitProperty &Property : Selector.Properties)
2150  VMI.addTrait(Set.Kind, Property.Kind, ScorePtr);
2151 
2152  if (Set.Kind != TraitSet::construct)
2153  continue;
2154 
2155  // TODO: This might not hold once we implement SIMD properly.
2156  assert(Selector.Properties.size() == 1 &&
2157  Selector.Properties.front().Kind ==
2158  getOpenMPContextTraitPropertyForSelector(
2159  Selector.Kind) &&
2160  "Ill-formed construct selector!");
2161 
2162  VMI.ConstructTraits.push_back(Selector.Properties.front().Kind);
2163  }
2164  }
2165 }
2166 
2167 void OMPTraitInfo::print(llvm::raw_ostream &OS,
2168  const PrintingPolicy &Policy) const {
2169  bool FirstSet = true;
2170  for (const OMPTraitSet &Set : Sets) {
2171  if (!FirstSet)
2172  OS << ", ";
2173  FirstSet = false;
2174  OS << getOpenMPContextTraitSetName(Set.Kind) << "={";
2175 
2176  bool FirstSelector = true;
2177  for (const OMPTraitSelector &Selector : Set.Selectors) {
2178  if (!FirstSelector)
2179  OS << ", ";
2180  FirstSelector = false;
2181  OS << getOpenMPContextTraitSelectorName(Selector.Kind);
2182 
2183  bool AllowsTraitScore = false;
2184  bool RequiresProperty = false;
2185  isValidTraitSelectorForTraitSet(
2186  Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2187 
2188  if (!RequiresProperty)
2189  continue;
2190 
2191  OS << "(";
2192  if (Selector.Kind == TraitSelector::user_condition) {
2193  Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
2194  } else {
2195 
2196  if (Selector.ScoreOrCondition) {
2197  OS << "score(";
2198  Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy);
2199  OS << "): ";
2200  }
2201 
2202  bool FirstProperty = true;
2203  for (const OMPTraitProperty &Property : Selector.Properties) {
2204  if (!FirstProperty)
2205  OS << ", ";
2206  FirstProperty = false;
2207  OS << getOpenMPContextTraitPropertyName(Property.Kind);
2208  }
2209  }
2210  OS << ")";
2211  }
2212  OS << "}";
2213  }
2214 }
2215 
2216 std::string OMPTraitInfo::getMangledName() const {
2217  std::string MangledName;
2218  llvm::raw_string_ostream OS(MangledName);
2219  for (const OMPTraitSet &Set : Sets) {
2220  OS << '$' << 'S' << unsigned(Set.Kind);
2221  for (const OMPTraitSelector &Selector : Set.Selectors) {
2222 
2223  bool AllowsTraitScore = false;
2224  bool RequiresProperty = false;
2225  isValidTraitSelectorForTraitSet(
2226  Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty);
2227  OS << '$' << 's' << unsigned(Selector.Kind);
2228 
2229  if (!RequiresProperty ||
2230  Selector.Kind == TraitSelector::user_condition)
2231  continue;
2232 
2233  for (const OMPTraitProperty &Property : Selector.Properties)
2234  OS << '$' << 'P' << getOpenMPContextTraitPropertyName(Property.Kind);
2235  }
2236  }
2237  return OS.str();
2238 }
2239 
2240 OMPTraitInfo::OMPTraitInfo(StringRef MangledName) {
2241  unsigned long U;
2242  do {
2243  if (!MangledName.consume_front("$S"))
2244  break;
2245  if (MangledName.consumeInteger(10, U))
2246  break;
2247  Sets.push_back(OMPTraitSet());
2248  OMPTraitSet &Set = Sets.back();
2249  Set.Kind = TraitSet(U);
2250  do {
2251  if (!MangledName.consume_front("$s"))
2252  break;
2253  if (MangledName.consumeInteger(10, U))
2254  break;
2255  Set.Selectors.push_back(OMPTraitSelector());
2256  OMPTraitSelector &Selector = Set.Selectors.back();
2257  Selector.Kind = TraitSelector(U);
2258  do {
2259  if (!MangledName.consume_front("$P"))
2260  break;
2261  Selector.Properties.push_back(OMPTraitProperty());
2262  OMPTraitProperty &Property = Selector.Properties.back();
2263  std::pair<StringRef, StringRef> PropRestPair = MangledName.split('$');
2264  Property.Kind =
2265  getOpenMPContextTraitPropertyKind(Set.Kind, PropRestPair.first);
2266  MangledName = PropRestPair.second;
2267  } while (true);
2268  } while (true);
2269  } while (true);
2270 }
2271 
2272 llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
2273  const OMPTraitInfo &TI) {
2274  LangOptions LO;
2275  PrintingPolicy Policy(LO);
2276  TI.print(OS, Policy);
2277  return OS;
2278 }
2279 llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
2280  const OMPTraitInfo *TI) {
2281  return TI ? OS << *TI : OS;
2282 }
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.
static OMPToClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr *> UDMapperRefs, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
This represents &#39;thread_limit&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents clause &#39;affinity&#39; in the &#39;#pragma omp task&#39;-based directives.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Smart pointer class that efficiently represents Objective-C method names.
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
bool varlist_empty() const
Definition: OpenMPClause.h:231
llvm::omp::ProcBindKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:999
OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const
Returns data for the specified allocator.
This represents clause &#39;use_device_addr&#39; in the &#39;#pragma omp ...&#39; directives.
This represents &#39;atomic_default_mem_order&#39; clause in the &#39;#pragma omp requires&#39; directive.
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.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Definition: Dominators.h:30
TypePropertyCache< Private > Cache
Definition: Type.cpp:3747
static OMPClauseWithPreInit * get(OMPClause *C)
Stmt - This represents one statement.
Definition: Stmt.h:68
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:109
Expr * getAllocator() const
Returns allocator.
Definition: OpenMPClause.h:303
child_range used_children()
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents &#39;grainsize&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;if&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:427
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
llvm::omp::TraitProperty Kind
This represents implicit clause &#39;depobj&#39; for the &#39;#pragma omp depobj&#39; directive.
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
The base class of the type hierarchy.
Definition: Type.h:1472
MutableArrayRef< Expr * > getUsedExprs()
Gets the list of used expressions for linear variables.
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
void setUsedExprs(ArrayRef< Expr *> UE)
Sets the list of used expressions for the linear clause.
unsigned getNumberOfAllocators() const
Returns number of allocators associated with the clause.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:570
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
bool isEmpty() const
Evaluates true when this declaration name is empty.
static OMPUseDeviceAddrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:496
Expr * getAlignment()
Returns alignment.
Expr * getNumForLoops() const
Return the number of associated for-loops.
OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY
Fetches the map-type-modifier at &#39;Cnt&#39; index of array of modifiers.
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
This represents &#39;read&#39; clause in the &#39;#pragma omp atomic&#39; directive.
static OMPUseDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< Expr *> PrivateVars, ArrayRef< Expr *> Inits, 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:597
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
Expr * getEventHandler() const
Returns event-handler expression.
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.
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:49
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
This represents &#39;reverse_offload&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Expr * getGrainsize() const
Return safe iteration space distance.
This represents &#39;nogroup&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents &#39;allocator&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:267
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:674
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:58
CalcStep
Step
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:174
A C++ nested-name-specifier augmented with source location information.
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents &#39;simd&#39; clause in the &#39;#pragma omp ...&#39; directive.
OpenMPLinearClauseKind
OpenMP attributes for &#39;linear&#39; clause.
Definition: OpenMPKinds.h:61
This represents clause &#39;lastprivate&#39; in the &#39;#pragma omp ...&#39; directives.
This represents clause &#39;allocate&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:330
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
Expr * getModifier()
Return optional depend modifier.
Expr * getChunkSize()
Get chunk size.
This represents clause &#39;map&#39; in the &#39;#pragma omp ...&#39; directives.
void setPrivateRefs(ArrayRef< Expr *> VL)
Sets the list of references to private copies created in private clauses.
This represents clause &#39;to&#39; in the &#39;#pragma omp ...&#39; directives.
OpenMPReductionClauseModifier
OpenMP modifiers for &#39;reduction&#39; clause.
Definition: OpenMPKinds.h:167
Defines some OpenMP-specific enums and functions.
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:709
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:54
Expr * getNumTeams()
Return NumTeams number.
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier, ArrayRef< Expr *> VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr *> Privates, ArrayRef< Expr *> LHSExprs, ArrayRef< Expr *> RHSExprs, ArrayRef< Expr *> ReductionOps, ArrayRef< Expr *> CopyOps, ArrayRef< Expr *> CopyArrayTemps, ArrayRef< Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
OpenMPDeviceClauseModifier getModifier() const
Gets modifier.
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
static OMPInclusiveClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
static OMPUsesAllocatorsClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< OMPUsesAllocatorsClause::Data > Data)
Creates clause with a list of allocators Data.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
llvm::omp::DefaultKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:917
child_range used_children()
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...
This represents &#39;destroy&#39; clause in the &#39;#pragma omp depobj&#39; directive.
This represents &#39;order&#39; clause in the &#39;#pragma omp ...&#39; directive.
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
Class that handles post-update expression for some clauses, like &#39;lastprivate&#39;, &#39;reduction&#39; etc...
Definition: OpenMPClause.h:147
This represents &#39;default&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:869
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:528
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents clause &#39;inclusive&#39; in the &#39;#pragma omp scan&#39; directive.
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
Expr * getModifier()
Gets affinity modifier.
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.
Expr * AllocatorTraits
Allocator traits.
unsigned NumVars
Number of expressions listed.
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
child_range used_children()
Get the iterator range for the expressions used in the clauses.
static OMPMapClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr *> UDMapperRefs, ArrayRef< OpenMPMapModifierKind > MapModifiers, ArrayRef< SourceLocation > MapModifiersLoc, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId, OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc)
Creates clause with a list of variables VL.
void print(raw_ostream &OS, const PrintingPolicy &Policy, bool ResolveTemplateArguments=false) const
Print this nested name specifier to the given output stream.
llvm::SmallVector< OMPTraitSelector, 2 > Selectors
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.
static OMPIsDevicePtrClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists)
Creates clause with a list of variables Vars.
This represents clause &#39;uses_allocators&#39; in the &#39;#pragma omp target&#39;-based directives.
child_range children()
This represents &#39;acq_rel&#39; clause in the &#39;#pragma omp atomic|flush&#39; directives.
This represents &#39;dynamic_allocators&#39; clause in the &#39;#pragma omp requires&#39; directive.
bool isExtended() const
Checks if the clause is the extended clauses for &#39;depobj&#39; directive.
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.
This represents &#39;threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
NestedNameSpecifierLoc getMapperQualifierLoc() const
Gets the nested name specifier for associated user-defined mapper.
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:775
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:80
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
static OMPDepobjClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *Depobj)
Creates clause.
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.
static OMPExclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
OpenMPLastprivateModifier
OpenMP &#39;lastprivate&#39; clause modifier.
Definition: OpenMPKinds.h:146
OpenMPLastprivateModifier getKind() const
Lastprivate kind.
SourceLocation getModifierLoc() const
Returns modifier location.
This represents &#39;proc_bind&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:950
This represents &#39;capture&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:619
This represents one expression.
Definition: Expr.h:110
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:740
MutableArrayRef< Expr * > getUpdates()
Sets the list of update expressions for linear variables.
Expr * getNumTasks() const
Return safe iteration space distance.
unsigned NumComponentLists
Number of component lists.
DynTypedNode Node
Inits[]
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
Expr * getAllocator() const
Returns the allocator expression or nullptr, if no allocator is specified.
Definition: OpenMPClause.h:387
static Stmt ** getAddrOfExprAsWritten(Stmt *S)
Gets the address of the original, non-captured, expression used in the clause as the preinitializer...
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static constexpr unsigned NumberOfOMPMapClauseModifiers
Number of allowed map-type-modifiers.
Definition: OpenMPKinds.h:86
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
This represents &#39;relaxed&#39; clause in the &#39;#pragma omp atomic&#39; directives.
Expr * getDevice()
Return device number.
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
This represents &#39;collapse&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:806
This represents clause &#39;firstprivate&#39; in the &#39;#pragma omp ...&#39; directives.
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
void getAsVariantMatchInfo(ASTContext &ASTCtx, llvm::omp::VariantMatchInfo &VMI) const
Create a variant match info object from this trait info object.
llvm::SmallVector< OMPTraitProperty, 1 > Properties
This file defines OpenMP AST classes for clauses.
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=llvm::omp::OMPD_unknown)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:125
ArrayRef< Expr * > getLoopNumIterations() const
Get number of iterations for all the loops.
This represents &#39;seq_cst&#39; clause in the &#39;#pragma omp atomic&#39; directive.
This represents &#39;untied&#39; clause in the &#39;#pragma omp ...&#39; directive.
static OMPAffinityClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr *> Locators)
Creates clause with a modifier a list of locator items.
This represents &#39;unified_address&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:159
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
llvm::iterator_range< child_iterator > child_range
Definition: OpenMPClause.h:86
static OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, Expr *DepModifier, OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr *> VL, unsigned NumLoops)
Creates clause with a list of variables VL.
Encodes a location in the source.
This represents &#39;hint&#39; clause in the &#39;#pragma omp ...&#39; directive.
OpenMPDependClauseKind
OpenMP attributes for &#39;depend&#39; clause.
Definition: OpenMPKinds.h:53
MutableArrayRef< Expr * > getInits()
llvm::APSInt APSInt
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N, OpenMPReductionClauseModifier Modifier)
Creates an empty clause with the place for N variables.
This represents &#39;release&#39; clause in the &#39;#pragma omp atomic|flush&#39; directives.
This structure contains all sizes needed for by an OMPMappableExprListClause.
DeclarationName getName() const
getName - Returns the embedded declaration name.
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
Expr * getPriority()
Return Priority number.
OpenMPLinearClauseKind Modifier
Modifier of &#39;linear&#39; clause.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
OpenMPMapClauseKind getMapType() const LLVM_READONLY
Fetches mapping kind for the clause.
This file defines OpenMP nodes for declarative directives.
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:52
OpenMPDependClauseKind getDependencyKind() const
Gets the dependence kind in clause for &#39;depobj&#39; directive.
This represents &#39;detach&#39; clause in the &#39;#pragma omp task&#39; directive.
void setVarRefs(ArrayRef< Expr *> VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:217
llvm::APInt APInt
Definition: Integral.h:27
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:842
static OMPUpdateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc)
Creates clause for &#39;atomic&#39; directive.
child_range used_children()
OpenMPOrderClauseKind getKind() const
Returns kind of the clause.
static OMPUseDeviceAddrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
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.
OpenMPReductionClauseModifier getModifier() const
Returns modifier.
static OMPInclusiveClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
static OMPAffinityClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N locator items.
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:626
void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Print a human readable representation into OS.
Dataflow Directional Tag Classes.
This represents &#39;device&#39; clause in the &#39;#pragma omp ...&#39; directive.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
SourceLocation ModifierLoc
Location of linear modifier if any.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
This represents &#39;unified_shared_memory&#39; clause in the &#39;#pragma omp requires&#39; directive.
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
OpenMPDefaultmapClauseModifier getDefaultmapModifier() const
Get the modifier of the clause.
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.
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> SrcExprs, ArrayRef< Expr *> DstExprs, ArrayRef< Expr *> AssignmentOps, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
unsigned NumUniqueDeclarations
Number of unique base declarations.
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
static OMPUsesAllocatorsClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N allocators.
Class that represents a component of a mappable expression.
Not an overloaded operator.
Definition: OperatorKinds.h:22
static unsigned getUniqueDeclarationsTotalNumber(ArrayRef< const ValueDecl *> Declarations)
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:499
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
child_range used_children()
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
void setUDMapperRefs(ArrayRef< Expr *> DMDs)
Set the user-defined mappers that are in the trailing objects of the class.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
static OMPUpdateClause * CreateEmpty(const ASTContext &C, bool IsExtended)
Creates an empty clause with the place for N variables.
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
This represents &#39;write&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Expr * getDepobj()
Returns depobj expression associated with the clause.
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with &#39;sink|source&#39; kind of dependency.
SourceLocation LParenLoc
Locations of &#39;(&#39; and &#39;)&#39; symbols.
void setClauseInfo(ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists...
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
OpenMPScheduleClauseModifier getSecondScheduleModifier() const
Get the second modifier of the clause.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
static OMPNontemporalClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
child_range used_children()
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
This represents &#39;num_tasks&#39; clause in the &#39;#pragma omp ...&#39; directive.
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
This represents clause &#39;exclusive&#39; in the &#39;#pragma omp scan&#39; directive.
static OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
Privates[]
Gets the list of initial values for linear variables.
int Priority
Definition: Format.cpp:2022
OpenMPMapClauseKind
OpenMP mapping kind for &#39;map&#39; clause.
Definition: OpenMPKinds.h:69
Expr * getThreadLimit()
Return ThreadLimit number.
This represents &#39;acquire&#39; clause in the &#39;#pragma omp atomic|flush&#39; directives.
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
OpenMPDeviceClauseModifier
OpenMP modifiers for &#39;device&#39; clause.
Definition: OpenMPKinds.h:46
std::string getMangledName() const
Return a string representation identifying this context selector.
This represents &#39;dist_schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Expr * getHint() const
Returns number of threads.
static OMPAllocateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, Expr *Allocator, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
void setInits(ArrayRef< Expr *> IL)
Sets the list of the initial values for linear variables.
Data for list of allocators.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
Expr * getChunkSize()
Get chunk size.
static OMPFlushClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL)
Creates clause with a list of variables VL.
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:642
This structure contains most locations needed for by an OMPVarListClause.
Definition: OpenMPClause.h:173
llvm::omp::TraitSelector Kind
static OMPExclusiveClause * 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 OMPFromClause * Create(const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef< Expr *> Vars, ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists, ArrayRef< Expr *> UDMapperRefs, NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId)
Creates clause with a list of variables Vars.
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const
Returns kind of the clause.
const DeclarationNameInfo & getMapperIdInfo() const
Gets the name info for associated user-defined mapper.
static OMPDepobjClause * CreateEmpty(const ASTContext &C)
Creates an empty clause.
SourceLocation ColonLoc
Location of &#39;:&#39;.
unsigned NumComponents
Total number of expression components.
This represents clause &#39;nontemporal&#39; in the &#39;#pragma omp ...&#39; directives.
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
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.
llvm::omp::TraitSet Kind