clang  10.0.0svn
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/Decl.h"
16 #include "clang/AST/DeclOpenMP.h"
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/SmallPtrSet.h"
19 #include "llvm/Support/Casting.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include <algorithm>
22 #include <cassert>
23 
24 using namespace clang;
25 
27  switch (getClauseKind()) {
28  default:
29  break;
30 #define OPENMP_CLAUSE(Name, Class) \
31  case OMPC_##Name: \
32  return static_cast<Class *>(this)->children();
33 #include "clang/Basic/OpenMPKinds.def"
34  }
35  llvm_unreachable("unknown OMPClause");
36 }
37 
39  switch (getClauseKind()) {
40 #define OPENMP_CLAUSE(Name, Class) \
41  case OMPC_##Name: \
42  return static_cast<Class *>(this)->used_children();
43 #include "clang/Basic/OpenMPKinds.def"
44  case OMPC_threadprivate:
45  case OMPC_uniform:
46  case OMPC_device_type:
47  case OMPC_match:
48  case OMPC_unknown:
49  break;
50  }
51  llvm_unreachable("unknown OMPClause");
52 }
53 
55  auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C));
56  return Res ? const_cast<OMPClauseWithPreInit *>(Res) : nullptr;
57 }
58 
60  switch (C->getClauseKind()) {
61  case OMPC_schedule:
62  return static_cast<const OMPScheduleClause *>(C);
63  case OMPC_dist_schedule:
64  return static_cast<const OMPDistScheduleClause *>(C);
65  case OMPC_firstprivate:
66  return static_cast<const OMPFirstprivateClause *>(C);
67  case OMPC_lastprivate:
68  return static_cast<const OMPLastprivateClause *>(C);
69  case OMPC_reduction:
70  return static_cast<const OMPReductionClause *>(C);
71  case OMPC_task_reduction:
72  return static_cast<const OMPTaskReductionClause *>(C);
73  case OMPC_in_reduction:
74  return static_cast<const OMPInReductionClause *>(C);
75  case OMPC_linear:
76  return static_cast<const OMPLinearClause *>(C);
77  case OMPC_if:
78  return static_cast<const OMPIfClause *>(C);
79  case OMPC_num_threads:
80  return static_cast<const OMPNumThreadsClause *>(C);
81  case OMPC_num_teams:
82  return static_cast<const OMPNumTeamsClause *>(C);
83  case OMPC_thread_limit:
84  return static_cast<const OMPThreadLimitClause *>(C);
85  case OMPC_device:
86  return static_cast<const OMPDeviceClause *>(C);
87  case OMPC_grainsize:
88  return static_cast<const OMPGrainsizeClause *>(C);
89  case OMPC_num_tasks:
90  return static_cast<const OMPNumTasksClause *>(C);
91  case OMPC_final:
92  return static_cast<const OMPFinalClause *>(C);
93  case OMPC_priority:
94  return static_cast<const OMPPriorityClause *>(C);
95  case OMPC_default:
96  case OMPC_proc_bind:
97  case OMPC_safelen:
98  case OMPC_simdlen:
99  case OMPC_allocator:
100  case OMPC_allocate:
101  case OMPC_collapse:
102  case OMPC_private:
103  case OMPC_shared:
104  case OMPC_aligned:
105  case OMPC_copyin:
106  case OMPC_copyprivate:
107  case OMPC_ordered:
108  case OMPC_nowait:
109  case OMPC_untied:
110  case OMPC_mergeable:
111  case OMPC_threadprivate:
112  case OMPC_flush:
113  case OMPC_read:
114  case OMPC_write:
115  case OMPC_update:
116  case OMPC_capture:
117  case OMPC_seq_cst:
118  case OMPC_depend:
119  case OMPC_threads:
120  case OMPC_simd:
121  case OMPC_map:
122  case OMPC_nogroup:
123  case OMPC_hint:
124  case OMPC_defaultmap:
125  case OMPC_unknown:
126  case OMPC_uniform:
127  case OMPC_to:
128  case OMPC_from:
129  case OMPC_use_device_ptr:
130  case OMPC_is_device_ptr:
131  case OMPC_unified_address:
132  case OMPC_unified_shared_memory:
133  case OMPC_reverse_offload:
134  case OMPC_dynamic_allocators:
135  case OMPC_atomic_default_mem_order:
136  case OMPC_device_type:
137  case OMPC_match:
138  break;
139  }
140 
141  return nullptr;
142 }
143 
145  auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C));
146  return Res ? const_cast<OMPClauseWithPostUpdate *>(Res) : nullptr;
147 }
148 
150  switch (C->getClauseKind()) {
151  case OMPC_lastprivate:
152  return static_cast<const OMPLastprivateClause *>(C);
153  case OMPC_reduction:
154  return static_cast<const OMPReductionClause *>(C);
155  case OMPC_task_reduction:
156  return static_cast<const OMPTaskReductionClause *>(C);
157  case OMPC_in_reduction:
158  return static_cast<const OMPInReductionClause *>(C);
159  case OMPC_linear:
160  return static_cast<const OMPLinearClause *>(C);
161  case OMPC_schedule:
162  case OMPC_dist_schedule:
163  case OMPC_firstprivate:
164  case OMPC_default:
165  case OMPC_proc_bind:
166  case OMPC_if:
167  case OMPC_final:
168  case OMPC_num_threads:
169  case OMPC_safelen:
170  case OMPC_simdlen:
171  case OMPC_allocator:
172  case OMPC_allocate:
173  case OMPC_collapse:
174  case OMPC_private:
175  case OMPC_shared:
176  case OMPC_aligned:
177  case OMPC_copyin:
178  case OMPC_copyprivate:
179  case OMPC_ordered:
180  case OMPC_nowait:
181  case OMPC_untied:
182  case OMPC_mergeable:
183  case OMPC_threadprivate:
184  case OMPC_flush:
185  case OMPC_read:
186  case OMPC_write:
187  case OMPC_update:
188  case OMPC_capture:
189  case OMPC_seq_cst:
190  case OMPC_depend:
191  case OMPC_device:
192  case OMPC_threads:
193  case OMPC_simd:
194  case OMPC_map:
195  case OMPC_num_teams:
196  case OMPC_thread_limit:
197  case OMPC_priority:
198  case OMPC_grainsize:
199  case OMPC_nogroup:
200  case OMPC_num_tasks:
201  case OMPC_hint:
202  case OMPC_defaultmap:
203  case OMPC_unknown:
204  case OMPC_uniform:
205  case OMPC_to:
206  case OMPC_from:
207  case OMPC_use_device_ptr:
208  case OMPC_is_device_ptr:
209  case OMPC_unified_address:
210  case OMPC_unified_shared_memory:
211  case OMPC_reverse_offload:
212  case OMPC_dynamic_allocators:
213  case OMPC_atomic_default_mem_order:
214  case OMPC_device_type:
215  case OMPC_match:
216  break;
217  }
218 
219  return nullptr;
220 }
221 
222 /// Gets the address of the original, non-captured, expression used in the
223 /// clause as the preinitializer.
225  if (!S)
226  return nullptr;
227  if (auto *DS = dyn_cast<DeclStmt>(S)) {
228  assert(DS->isSingleDecl() && "Only single expression must be captured.");
229  if (auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl()))
230  return OED->getInitAddress();
231  }
232  return nullptr;
233 }
234 
236  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
237  return child_range(C, C + 1);
238  return child_range(&Condition, &Condition + 1);
239 }
240 
242  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
243  return child_range(C, C + 1);
244  return child_range(&Grainsize, &Grainsize + 1);
245 }
246 
248  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
249  return child_range(C, C + 1);
250  return child_range(&NumTasks, &NumTasks + 1);
251 }
252 
254  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
255  return child_range(C, C + 1);
256  return child_range(&Condition, &Condition + 1);
257 }
258 
260  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
261  return child_range(C, C + 1);
262  return child_range(&Priority, &Priority + 1);
263 }
264 
266  unsigned NumLoops,
267  SourceLocation StartLoc,
268  SourceLocation LParenLoc,
269  SourceLocation EndLoc) {
270  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
271  auto *Clause =
272  new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc);
273  for (unsigned I = 0; I < NumLoops; ++I) {
274  Clause->setLoopNumIterations(I, nullptr);
275  Clause->setLoopCounter(I, nullptr);
276  }
277  return Clause;
278 }
279 
281  unsigned NumLoops) {
282  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops));
283  auto *Clause = new (Mem) OMPOrderedClause(NumLoops);
284  for (unsigned I = 0; I < NumLoops; ++I) {
285  Clause->setLoopNumIterations(I, nullptr);
286  Clause->setLoopCounter(I, nullptr);
287  }
288  return Clause;
289 }
290 
292  Expr *NumIterations) {
293  assert(NumLoop < NumberOfLoops && "out of loops number.");
294  getTrailingObjects<Expr *>()[NumLoop] = NumIterations;
295 }
296 
298  return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops);
299 }
300 
301 void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) {
302  assert(NumLoop < NumberOfLoops && "out of loops number.");
303  getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter;
304 }
305 
307  assert(NumLoop < NumberOfLoops && "out of loops number.");
308  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
309 }
310 
311 const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const {
312  assert(NumLoop < NumberOfLoops && "out of loops number.");
313  return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop];
314 }
315 
316 void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
317  assert(VL.size() == varlist_size() &&
318  "Number of private copies is not the same as the preallocated buffer");
319  std::copy(VL.begin(), VL.end(), varlist_end());
320 }
321 
324  SourceLocation LParenLoc, SourceLocation EndLoc,
325  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) {
326  // Allocate space for private variables and initializer expressions.
327  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size()));
328  OMPPrivateClause *Clause =
329  new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
330  Clause->setVarRefs(VL);
331  Clause->setPrivateCopies(PrivateVL);
332  return Clause;
333 }
334 
336  unsigned N) {
337  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N));
338  return new (Mem) OMPPrivateClause(N);
339 }
340 
341 void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
342  assert(VL.size() == varlist_size() &&
343  "Number of private copies is not the same as the preallocated buffer");
344  std::copy(VL.begin(), VL.end(), varlist_end());
345 }
346 
347 void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
348  assert(VL.size() == varlist_size() &&
349  "Number of inits is not the same as the preallocated buffer");
350  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
351 }
352 
355  SourceLocation LParenLoc, SourceLocation EndLoc,
356  ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL,
357  ArrayRef<Expr *> InitVL, Stmt *PreInit) {
358  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size()));
359  OMPFirstprivateClause *Clause =
360  new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
361  Clause->setVarRefs(VL);
362  Clause->setPrivateCopies(PrivateVL);
363  Clause->setInits(InitVL);
364  Clause->setPreInitStmt(PreInit);
365  return Clause;
366 }
367 
369  unsigned N) {
370  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N));
371  return new (Mem) OMPFirstprivateClause(N);
372 }
373 
375  assert(PrivateCopies.size() == varlist_size() &&
376  "Number of private copies is not the same as the preallocated buffer");
377  std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end());
378 }
379 
380 void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
381  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
382  "not the same as the "
383  "preallocated buffer");
384  std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end());
385 }
386 
387 void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
388  assert(DstExprs.size() == varlist_size() && "Number of destination "
389  "expressions is not the same as "
390  "the preallocated buffer");
391  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
392 }
393 
394 void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
395  assert(AssignmentOps.size() == varlist_size() &&
396  "Number of assignment expressions is not the same as the preallocated "
397  "buffer");
398  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
399  getDestinationExprs().end());
400 }
401 
403  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
404  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
405  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, Stmt *PreInit,
406  Expr *PostUpdate) {
407  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
408  OMPLastprivateClause *Clause =
409  new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
410  Clause->setVarRefs(VL);
411  Clause->setSourceExprs(SrcExprs);
412  Clause->setDestinationExprs(DstExprs);
413  Clause->setAssignmentOps(AssignmentOps);
414  Clause->setPreInitStmt(PreInit);
415  Clause->setPostUpdateExpr(PostUpdate);
416  return Clause;
417 }
418 
420  unsigned N) {
421  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
422  return new (Mem) OMPLastprivateClause(N);
423 }
424 
426  SourceLocation StartLoc,
427  SourceLocation LParenLoc,
428  SourceLocation EndLoc,
429  ArrayRef<Expr *> VL) {
430  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
431  OMPSharedClause *Clause =
432  new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size());
433  Clause->setVarRefs(VL);
434  return Clause;
435 }
436 
438  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
439  return new (Mem) OMPSharedClause(N);
440 }
441 
443  assert(PL.size() == varlist_size() &&
444  "Number of privates is not the same as the preallocated buffer");
445  std::copy(PL.begin(), PL.end(), varlist_end());
446 }
447 
449  assert(IL.size() == varlist_size() &&
450  "Number of inits is not the same as the preallocated buffer");
451  std::copy(IL.begin(), IL.end(), getPrivates().end());
452 }
453 
455  assert(UL.size() == varlist_size() &&
456  "Number of updates is not the same as the preallocated buffer");
457  std::copy(UL.begin(), UL.end(), getInits().end());
458 }
459 
461  assert(FL.size() == varlist_size() &&
462  "Number of final updates is not the same as the preallocated buffer");
463  std::copy(FL.begin(), FL.end(), getUpdates().end());
464 }
465 
467  assert(
468  UE.size() == varlist_size() + 1 &&
469  "Number of used expressions is not the same as the preallocated buffer");
470  std::copy(UE.begin(), UE.end(), getFinals().end() + 2);
471 }
472 
474  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
478  Stmt *PreInit, Expr *PostUpdate) {
479  // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
480  // (Step and CalcStep), list of used expression + step.
481  void *Mem =
482  C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1));
483  OMPLinearClause *Clause = new (Mem) OMPLinearClause(
484  StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size());
485  Clause->setVarRefs(VL);
486  Clause->setPrivates(PL);
487  Clause->setInits(IL);
488  // Fill update and final expressions with zeroes, they are provided later,
489  // after the directive construction.
490  std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(),
491  nullptr);
492  std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(),
493  nullptr);
494  std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(),
495  nullptr);
496  Clause->setStep(Step);
497  Clause->setCalcStep(CalcStep);
498  Clause->setPreInitStmt(PreInit);
499  Clause->setPostUpdateExpr(PostUpdate);
500  return Clause;
501 }
502 
504  unsigned NumVars) {
505  // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions
506  // (Step and CalcStep), list of used expression + step.
507  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1));
508  return new (Mem) OMPLinearClause(NumVars);
509 }
510 
512  // Range includes only non-nullptr elements.
513  return child_range(
514  reinterpret_cast<Stmt **>(getUsedExprs().begin()),
515  reinterpret_cast<Stmt **>(llvm::find(getUsedExprs(), nullptr)));
516 }
517 
520  SourceLocation LParenLoc, SourceLocation ColonLoc,
521  SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) {
522  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
523  OMPAlignedClause *Clause = new (Mem)
524  OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size());
525  Clause->setVarRefs(VL);
526  Clause->setAlignment(A);
527  return Clause;
528 }
529 
531  unsigned NumVars) {
532  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1));
533  return new (Mem) OMPAlignedClause(NumVars);
534 }
535 
536 void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
537  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
538  "not the same as the "
539  "preallocated buffer");
540  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
541 }
542 
543 void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
544  assert(DstExprs.size() == varlist_size() && "Number of destination "
545  "expressions is not the same as "
546  "the preallocated buffer");
547  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
548 }
549 
550 void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
551  assert(AssignmentOps.size() == varlist_size() &&
552  "Number of assignment expressions is not the same as the preallocated "
553  "buffer");
554  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
555  getDestinationExprs().end());
556 }
557 
559  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
560  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
561  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
562  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
563  OMPCopyinClause *Clause =
564  new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size());
565  Clause->setVarRefs(VL);
566  Clause->setSourceExprs(SrcExprs);
567  Clause->setDestinationExprs(DstExprs);
568  Clause->setAssignmentOps(AssignmentOps);
569  return Clause;
570 }
571 
573  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
574  return new (Mem) OMPCopyinClause(N);
575 }
576 
577 void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
578  assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
579  "not the same as the "
580  "preallocated buffer");
581  std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end());
582 }
583 
584 void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
585  assert(DstExprs.size() == varlist_size() && "Number of destination "
586  "expressions is not the same as "
587  "the preallocated buffer");
588  std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end());
589 }
590 
591 void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
592  assert(AssignmentOps.size() == varlist_size() &&
593  "Number of assignment expressions is not the same as the preallocated "
594  "buffer");
595  std::copy(AssignmentOps.begin(), AssignmentOps.end(),
596  getDestinationExprs().end());
597 }
598 
600  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
601  SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
602  ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) {
603  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size()));
604  OMPCopyprivateClause *Clause =
605  new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size());
606  Clause->setVarRefs(VL);
607  Clause->setSourceExprs(SrcExprs);
608  Clause->setDestinationExprs(DstExprs);
609  Clause->setAssignmentOps(AssignmentOps);
610  return Clause;
611 }
612 
614  unsigned N) {
615  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N));
616  return new (Mem) OMPCopyprivateClause(N);
617 }
618 
619 void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
620  assert(Privates.size() == varlist_size() &&
621  "Number of private copies is not the same as the preallocated buffer");
622  std::copy(Privates.begin(), Privates.end(), varlist_end());
623 }
624 
625 void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
626  assert(
627  LHSExprs.size() == varlist_size() &&
628  "Number of LHS expressions is not the same as the preallocated buffer");
629  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
630 }
631 
632 void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
633  assert(
634  RHSExprs.size() == varlist_size() &&
635  "Number of RHS expressions is not the same as the preallocated buffer");
636  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
637 }
638 
639 void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
640  assert(ReductionOps.size() == varlist_size() && "Number of reduction "
641  "expressions is not the same "
642  "as the preallocated buffer");
643  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
644 }
645 
647  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
648  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
649  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
651  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
652  Expr *PostUpdate) {
653  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
654  OMPReductionClause *Clause = new (Mem) OMPReductionClause(
655  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
656  Clause->setVarRefs(VL);
657  Clause->setPrivates(Privates);
658  Clause->setLHSExprs(LHSExprs);
659  Clause->setRHSExprs(RHSExprs);
660  Clause->setReductionOps(ReductionOps);
661  Clause->setPreInitStmt(PreInit);
662  Clause->setPostUpdateExpr(PostUpdate);
663  return Clause;
664 }
665 
667  unsigned N) {
668  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
669  return new (Mem) OMPReductionClause(N);
670 }
671 
672 void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
673  assert(Privates.size() == varlist_size() &&
674  "Number of private copies is not the same as the preallocated buffer");
675  std::copy(Privates.begin(), Privates.end(), varlist_end());
676 }
677 
678 void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
679  assert(
680  LHSExprs.size() == varlist_size() &&
681  "Number of LHS expressions is not the same as the preallocated buffer");
682  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
683 }
684 
685 void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
686  assert(
687  RHSExprs.size() == varlist_size() &&
688  "Number of RHS expressions is not the same as the preallocated buffer");
689  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
690 }
691 
692 void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
693  assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
694  "expressions is not the same "
695  "as the preallocated buffer");
696  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
697 }
698 
700  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
701  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
702  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
703  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
704  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit,
705  Expr *PostUpdate) {
706  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size()));
708  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
709  Clause->setVarRefs(VL);
710  Clause->setPrivates(Privates);
711  Clause->setLHSExprs(LHSExprs);
712  Clause->setRHSExprs(RHSExprs);
713  Clause->setReductionOps(ReductionOps);
714  Clause->setPreInitStmt(PreInit);
715  Clause->setPostUpdateExpr(PostUpdate);
716  return Clause;
717 }
718 
720  unsigned N) {
721  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N));
722  return new (Mem) OMPTaskReductionClause(N);
723 }
724 
725 void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
726  assert(Privates.size() == varlist_size() &&
727  "Number of private copies is not the same as the preallocated buffer");
728  std::copy(Privates.begin(), Privates.end(), varlist_end());
729 }
730 
731 void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
732  assert(
733  LHSExprs.size() == varlist_size() &&
734  "Number of LHS expressions is not the same as the preallocated buffer");
735  std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end());
736 }
737 
738 void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
739  assert(
740  RHSExprs.size() == varlist_size() &&
741  "Number of RHS expressions is not the same as the preallocated buffer");
742  std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end());
743 }
744 
745 void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
746  assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
747  "expressions is not the same "
748  "as the preallocated buffer");
749  std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end());
750 }
751 
752 void OMPInReductionClause::setTaskgroupDescriptors(
753  ArrayRef<Expr *> TaskgroupDescriptors) {
754  assert(TaskgroupDescriptors.size() == varlist_size() &&
755  "Number of in reduction descriptors is not the same as the "
756  "preallocated buffer");
757  std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(),
758  getReductionOps().end());
759 }
760 
762  const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
763  SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL,
764  NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo,
765  ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs,
766  ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps,
767  ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) {
768  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size()));
769  OMPInReductionClause *Clause = new (Mem) OMPInReductionClause(
770  StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo);
771  Clause->setVarRefs(VL);
772  Clause->setPrivates(Privates);
773  Clause->setLHSExprs(LHSExprs);
774  Clause->setRHSExprs(RHSExprs);
775  Clause->setReductionOps(ReductionOps);
776  Clause->setTaskgroupDescriptors(TaskgroupDescriptors);
777  Clause->setPreInitStmt(PreInit);
778  Clause->setPostUpdateExpr(PostUpdate);
779  return Clause;
780 }
781 
783  unsigned N) {
784  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N));
785  return new (Mem) OMPInReductionClause(N);
786 }
787 
790  SourceLocation LParenLoc, Expr *Allocator,
791  SourceLocation ColonLoc, SourceLocation EndLoc,
792  ArrayRef<Expr *> VL) {
793  // Allocate space for private variables and initializer expressions.
794  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size()));
795  auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator,
796  ColonLoc, EndLoc, VL.size());
797  Clause->setVarRefs(VL);
798  return Clause;
799 }
800 
802  unsigned N) {
803  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
804  return new (Mem) OMPAllocateClause(N);
805 }
806 
808  SourceLocation StartLoc,
809  SourceLocation LParenLoc,
810  SourceLocation EndLoc,
811  ArrayRef<Expr *> VL) {
812  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1));
813  OMPFlushClause *Clause =
814  new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size());
815  Clause->setVarRefs(VL);
816  return Clause;
817 }
818 
820  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N));
821  return new (Mem) OMPFlushClause(N);
822 }
823 
826  SourceLocation LParenLoc, SourceLocation EndLoc,
827  OpenMPDependClauseKind DepKind, SourceLocation DepLoc,
828  SourceLocation ColonLoc, ArrayRef<Expr *> VL,
829  unsigned NumLoops) {
830  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + NumLoops));
831  OMPDependClause *Clause = new (Mem)
832  OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops);
833  Clause->setVarRefs(VL);
834  Clause->setDependencyKind(DepKind);
835  Clause->setDependencyLoc(DepLoc);
836  Clause->setColonLoc(ColonLoc);
837  for (unsigned I = 0 ; I < NumLoops; ++I)
838  Clause->setLoopData(I, nullptr);
839  return Clause;
840 }
841 
843  unsigned NumLoops) {
844  void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + NumLoops));
845  return new (Mem) OMPDependClause(N, NumLoops);
846 }
847 
848 void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) {
849  assert((getDependencyKind() == OMPC_DEPEND_sink ||
850  getDependencyKind() == OMPC_DEPEND_source) &&
851  NumLoop < NumLoops &&
852  "Expected sink or source depend + loop index must be less number of "
853  "loops.");
854  auto It = std::next(getVarRefs().end(), NumLoop);
855  *It = Cnt;
856 }
857 
858 Expr *OMPDependClause::getLoopData(unsigned NumLoop) {
859  assert((getDependencyKind() == OMPC_DEPEND_sink ||
860  getDependencyKind() == OMPC_DEPEND_source) &&
861  NumLoop < NumLoops &&
862  "Expected sink or source depend + loop index must be less number of "
863  "loops.");
864  auto It = std::next(getVarRefs().end(), NumLoop);
865  return *It;
866 }
867 
868 const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const {
869  assert((getDependencyKind() == OMPC_DEPEND_sink ||
870  getDependencyKind() == OMPC_DEPEND_source) &&
871  NumLoop < NumLoops &&
872  "Expected sink or source depend + loop index must be less number of "
873  "loops.");
874  auto It = std::next(getVarRefs().end(), NumLoop);
875  return *It;
876 }
877 
879  MappableExprComponentListsRef ComponentLists) {
880  unsigned TotalNum = 0u;
881  for (auto &C : ComponentLists)
882  TotalNum += C.size();
883  return TotalNum;
884 }
885 
887  ArrayRef<const ValueDecl *> Declarations) {
888  unsigned TotalNum = 0u;
889  llvm::SmallPtrSet<const ValueDecl *, 8> Cache;
890  for (const ValueDecl *D : Declarations) {
891  const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl()) : nullptr;
892  if (Cache.count(VD))
893  continue;
894  ++TotalNum;
895  Cache.insert(VD);
896  }
897  return TotalNum;
898 }
899 
901  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
902  ArrayRef<ValueDecl *> Declarations,
903  MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
904  ArrayRef<OpenMPMapModifierKind> MapModifiers,
905  ArrayRef<SourceLocation> MapModifiersLoc,
906  NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId,
907  OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc) {
909  Sizes.NumVars = Vars.size();
910  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
911  Sizes.NumComponentLists = ComponentLists.size();
912  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
913 
914  // We need to allocate:
915  // 2 x NumVars x Expr* - we have an original list expression and an associated
916  // user-defined mapper for each clause list entry.
917  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
918  // with each component list.
919  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
920  // number of lists for each unique declaration and the size of each component
921  // list.
922  // NumComponents x MappableComponent - the total of all the components in all
923  // the lists.
924  void *Mem = C.Allocate(
925  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
927  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
929  Sizes.NumComponents));
930  OMPMapClause *Clause = new (Mem)
931  OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId,
932  Type, TypeIsImplicit, TypeLoc, Locs, Sizes);
933 
934  Clause->setVarRefs(Vars);
935  Clause->setUDMapperRefs(UDMapperRefs);
936  Clause->setClauseInfo(Declarations, ComponentLists);
937  Clause->setMapType(Type);
938  Clause->setMapLoc(TypeLoc);
939  return Clause;
940 }
941 
942 OMPMapClause *
944  const OMPMappableExprListSizeTy &Sizes) {
945  void *Mem = C.Allocate(
946  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
948  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
950  Sizes.NumComponents));
951  return new (Mem) OMPMapClause(Sizes);
952 }
953 
955  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
956  ArrayRef<ValueDecl *> Declarations,
957  MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
958  NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
960  Sizes.NumVars = Vars.size();
961  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
962  Sizes.NumComponentLists = ComponentLists.size();
963  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
964 
965  // We need to allocate:
966  // 2 x NumVars x Expr* - we have an original list expression and an associated
967  // user-defined mapper for each clause list entry.
968  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
969  // with each component list.
970  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
971  // number of lists for each unique declaration and the size of each component
972  // list.
973  // NumComponents x MappableComponent - the total of all the components in all
974  // the lists.
975  void *Mem = C.Allocate(
976  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
978  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
980  Sizes.NumComponents));
981 
982  auto *Clause = new (Mem) OMPToClause(UDMQualifierLoc, MapperId, Locs, Sizes);
983 
984  Clause->setVarRefs(Vars);
985  Clause->setUDMapperRefs(UDMapperRefs);
986  Clause->setClauseInfo(Declarations, ComponentLists);
987  return Clause;
988 }
989 
991  const OMPMappableExprListSizeTy &Sizes) {
992  void *Mem = C.Allocate(
993  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
995  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
997  Sizes.NumComponents));
998  return new (Mem) OMPToClause(Sizes);
999 }
1000 
1002  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1003  ArrayRef<ValueDecl *> Declarations,
1004  MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs,
1005  NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) {
1007  Sizes.NumVars = Vars.size();
1008  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1009  Sizes.NumComponentLists = ComponentLists.size();
1010  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1011 
1012  // We need to allocate:
1013  // 2 x NumVars x Expr* - we have an original list expression and an associated
1014  // user-defined mapper for each clause list entry.
1015  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1016  // with each component list.
1017  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1018  // number of lists for each unique declaration and the size of each component
1019  // list.
1020  // NumComponents x MappableComponent - the total of all the components in all
1021  // the lists.
1022  void *Mem = C.Allocate(
1023  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1025  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1027  Sizes.NumComponents));
1028 
1029  auto *Clause =
1030  new (Mem) OMPFromClause(UDMQualifierLoc, MapperId, Locs, Sizes);
1031 
1032  Clause->setVarRefs(Vars);
1033  Clause->setUDMapperRefs(UDMapperRefs);
1034  Clause->setClauseInfo(Declarations, ComponentLists);
1035  return Clause;
1036 }
1037 
1038 OMPFromClause *
1040  const OMPMappableExprListSizeTy &Sizes) {
1041  void *Mem = C.Allocate(
1042  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1044  2 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1046  Sizes.NumComponents));
1047  return new (Mem) OMPFromClause(Sizes);
1048 }
1049 
1050 void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
1051  assert(VL.size() == varlist_size() &&
1052  "Number of private copies is not the same as the preallocated buffer");
1053  std::copy(VL.begin(), VL.end(), varlist_end());
1054 }
1055 
1056 void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
1057  assert(VL.size() == varlist_size() &&
1058  "Number of inits is not the same as the preallocated buffer");
1059  std::copy(VL.begin(), VL.end(), getPrivateCopies().end());
1060 }
1061 
1063  const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars,
1064  ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits,
1065  ArrayRef<ValueDecl *> Declarations,
1066  MappableExprComponentListsRef ComponentLists) {
1068  Sizes.NumVars = Vars.size();
1069  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1070  Sizes.NumComponentLists = ComponentLists.size();
1071  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1072 
1073  // We need to allocate:
1074  // 3 x NumVars x Expr* - we have an original list expression for each clause
1075  // list entry and an equal number of private copies and inits.
1076  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1077  // with each component list.
1078  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1079  // number of lists for each unique declaration and the size of each component
1080  // list.
1081  // NumComponents x MappableComponent - the total of all the components in all
1082  // the lists.
1083  void *Mem = C.Allocate(
1084  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1086  3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1088  Sizes.NumComponents));
1089 
1090  OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(Locs, Sizes);
1091 
1092  Clause->setVarRefs(Vars);
1093  Clause->setPrivateCopies(PrivateVars);
1094  Clause->setInits(Inits);
1095  Clause->setClauseInfo(Declarations, ComponentLists);
1096  return Clause;
1097 }
1098 
1101  const OMPMappableExprListSizeTy &Sizes) {
1102  void *Mem = C.Allocate(
1103  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1105  3 * Sizes.NumVars, Sizes.NumUniqueDeclarations,
1107  Sizes.NumComponents));
1108  return new (Mem) OMPUseDevicePtrClause(Sizes);
1109 }
1110 
1113  ArrayRef<Expr *> Vars,
1114  ArrayRef<ValueDecl *> Declarations,
1115  MappableExprComponentListsRef ComponentLists) {
1117  Sizes.NumVars = Vars.size();
1118  Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations);
1119  Sizes.NumComponentLists = ComponentLists.size();
1120  Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
1121 
1122  // We need to allocate:
1123  // NumVars x Expr* - we have an original list expression for each clause list
1124  // entry.
1125  // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
1126  // with each component list.
1127  // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the
1128  // number of lists for each unique declaration and the size of each component
1129  // list.
1130  // NumComponents x MappableComponent - the total of all the components in all
1131  // the lists.
1132  void *Mem = C.Allocate(
1133  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1135  Sizes.NumVars, Sizes.NumUniqueDeclarations,
1137  Sizes.NumComponents));
1138 
1139  OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(Locs, Sizes);
1140 
1141  Clause->setVarRefs(Vars);
1142  Clause->setClauseInfo(Declarations, ComponentLists);
1143  return Clause;
1144 }
1145 
1148  const OMPMappableExprListSizeTy &Sizes) {
1149  void *Mem = C.Allocate(
1150  totalSizeToAlloc<Expr *, ValueDecl *, unsigned,
1152  Sizes.NumVars, Sizes.NumUniqueDeclarations,
1154  Sizes.NumComponents));
1155  return new (Mem) OMPIsDevicePtrClause(Sizes);
1156 }
1157 
1158 //===----------------------------------------------------------------------===//
1159 // OpenMP clauses printing methods
1160 //===----------------------------------------------------------------------===//
1161 
1162 void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) {
1163  OS << "if(";
1164  if (Node->getNameModifier() != OMPD_unknown)
1165  OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": ";
1166  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1167  OS << ")";
1168 }
1169 
1170 void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) {
1171  OS << "final(";
1172  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
1173  OS << ")";
1174 }
1175 
1176 void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) {
1177  OS << "num_threads(";
1178  Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0);
1179  OS << ")";
1180 }
1181 
1182 void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) {
1183  OS << "safelen(";
1184  Node->getSafelen()->printPretty(OS, nullptr, Policy, 0);
1185  OS << ")";
1186 }
1187 
1188 void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) {
1189  OS << "simdlen(";
1190  Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0);
1191  OS << ")";
1192 }
1193 
1194 void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) {
1195  OS << "allocator(";
1196  Node->getAllocator()->printPretty(OS, nullptr, Policy, 0);
1197  OS << ")";
1198 }
1199 
1200 void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) {
1201  OS << "collapse(";
1202  Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0);
1203  OS << ")";
1204 }
1205 
1206 void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) {
1207  OS << "default("
1208  << getOpenMPSimpleClauseTypeName(OMPC_default, Node->getDefaultKind())
1209  << ")";
1210 }
1211 
1212 void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) {
1213  OS << "proc_bind("
1214  << getOpenMPSimpleClauseTypeName(OMPC_proc_bind, Node->getProcBindKind())
1215  << ")";
1216 }
1217 
1218 void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {
1219  OS << "unified_address";
1220 }
1221 
1222 void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause(
1224  OS << "unified_shared_memory";
1225 }
1226 
1227 void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {
1228  OS << "reverse_offload";
1229 }
1230 
1231 void OMPClausePrinter::VisitOMPDynamicAllocatorsClause(
1233  OS << "dynamic_allocators";
1234 }
1235 
1236 void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause(
1238  OS << "atomic_default_mem_order("
1239  << getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order,
1241  << ")";
1242 }
1243 
1244 void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) {
1245  OS << "schedule(";
1247  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1248  Node->getFirstScheduleModifier());
1250  OS << ", ";
1251  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule,
1252  Node->getSecondScheduleModifier());
1253  }
1254  OS << ": ";
1255  }
1256  OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind());
1257  if (auto *E = Node->getChunkSize()) {
1258  OS << ", ";
1259  E->printPretty(OS, nullptr, Policy);
1260  }
1261  OS << ")";
1262 }
1263 
1264 void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) {
1265  OS << "ordered";
1266  if (auto *Num = Node->getNumForLoops()) {
1267  OS << "(";
1268  Num->printPretty(OS, nullptr, Policy, 0);
1269  OS << ")";
1270  }
1271 }
1272 
1273 void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) {
1274  OS << "nowait";
1275 }
1276 
1277 void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) {
1278  OS << "untied";
1279 }
1280 
1281 void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) {
1282  OS << "nogroup";
1283 }
1284 
1285 void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) {
1286  OS << "mergeable";
1287 }
1288 
1289 void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; }
1290 
1291 void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; }
1292 
1293 void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *) {
1294  OS << "update";
1295 }
1296 
1297 void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) {
1298  OS << "capture";
1299 }
1300 
1301 void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
1302  OS << "seq_cst";
1303 }
1304 
1305 void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) {
1306  OS << "threads";
1307 }
1308 
1309 void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; }
1310 
1311 void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) {
1312  OS << "device(";
1313  Node->getDevice()->printPretty(OS, nullptr, Policy, 0);
1314  OS << ")";
1315 }
1316 
1317 void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) {
1318  OS << "num_teams(";
1319  Node->getNumTeams()->printPretty(OS, nullptr, Policy, 0);
1320  OS << ")";
1321 }
1322 
1323 void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) {
1324  OS << "thread_limit(";
1325  Node->getThreadLimit()->printPretty(OS, nullptr, Policy, 0);
1326  OS << ")";
1327 }
1328 
1329 void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) {
1330  OS << "priority(";
1331  Node->getPriority()->printPretty(OS, nullptr, Policy, 0);
1332  OS << ")";
1333 }
1334 
1335 void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) {
1336  OS << "grainsize(";
1337  Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0);
1338  OS << ")";
1339 }
1340 
1341 void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) {
1342  OS << "num_tasks(";
1343  Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0);
1344  OS << ")";
1345 }
1346 
1347 void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) {
1348  OS << "hint(";
1349  Node->getHint()->printPretty(OS, nullptr, Policy, 0);
1350  OS << ")";
1351 }
1352 
1353 template<typename T>
1354 void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) {
1355  for (typename T::varlist_iterator I = Node->varlist_begin(),
1356  E = Node->varlist_end();
1357  I != E; ++I) {
1358  assert(*I && "Expected non-null Stmt");
1359  OS << (I == Node->varlist_begin() ? StartSym : ',');
1360  if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) {
1361  if (isa<OMPCapturedExprDecl>(DRE->getDecl()))
1362  DRE->printPretty(OS, nullptr, Policy, 0);
1363  else
1364  DRE->getDecl()->printQualifiedName(OS);
1365  } else
1366  (*I)->printPretty(OS, nullptr, Policy, 0);
1367  }
1368 }
1369 
1370 void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) {
1371  if (Node->varlist_empty())
1372  return;
1373  OS << "allocate";
1374  if (Expr *Allocator = Node->getAllocator()) {
1375  OS << "(";
1376  Allocator->printPretty(OS, nullptr, Policy, 0);
1377  OS << ":";
1378  VisitOMPClauseList(Node, ' ');
1379  } else {
1380  VisitOMPClauseList(Node, '(');
1381  }
1382  OS << ")";
1383 }
1384 
1385 void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) {
1386  if (!Node->varlist_empty()) {
1387  OS << "private";
1388  VisitOMPClauseList(Node, '(');
1389  OS << ")";
1390  }
1391 }
1392 
1393 void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) {
1394  if (!Node->varlist_empty()) {
1395  OS << "firstprivate";
1396  VisitOMPClauseList(Node, '(');
1397  OS << ")";
1398  }
1399 }
1400 
1401 void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) {
1402  if (!Node->varlist_empty()) {
1403  OS << "lastprivate";
1404  VisitOMPClauseList(Node, '(');
1405  OS << ")";
1406  }
1407 }
1408 
1409 void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) {
1410  if (!Node->varlist_empty()) {
1411  OS << "shared";
1412  VisitOMPClauseList(Node, '(');
1413  OS << ")";
1414  }
1415 }
1416 
1417 void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) {
1418  if (!Node->varlist_empty()) {
1419  OS << "reduction(";
1420  NestedNameSpecifier *QualifierLoc =
1424  if (QualifierLoc == nullptr && OOK != OO_None) {
1425  // Print reduction identifier in C format
1426  OS << getOperatorSpelling(OOK);
1427  } else {
1428  // Use C++ format
1429  if (QualifierLoc != nullptr)
1430  QualifierLoc->print(OS, Policy);
1431  OS << Node->getNameInfo();
1432  }
1433  OS << ":";
1434  VisitOMPClauseList(Node, ' ');
1435  OS << ")";
1436  }
1437 }
1438 
1439 void OMPClausePrinter::VisitOMPTaskReductionClause(
1440  OMPTaskReductionClause *Node) {
1441  if (!Node->varlist_empty()) {
1442  OS << "task_reduction(";
1443  NestedNameSpecifier *QualifierLoc =
1447  if (QualifierLoc == nullptr && OOK != OO_None) {
1448  // Print reduction identifier in C format
1449  OS << getOperatorSpelling(OOK);
1450  } else {
1451  // Use C++ format
1452  if (QualifierLoc != nullptr)
1453  QualifierLoc->print(OS, Policy);
1454  OS << Node->getNameInfo();
1455  }
1456  OS << ":";
1457  VisitOMPClauseList(Node, ' ');
1458  OS << ")";
1459  }
1460 }
1461 
1462 void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) {
1463  if (!Node->varlist_empty()) {
1464  OS << "in_reduction(";
1465  NestedNameSpecifier *QualifierLoc =
1469  if (QualifierLoc == nullptr && OOK != OO_None) {
1470  // Print reduction identifier in C format
1471  OS << getOperatorSpelling(OOK);
1472  } else {
1473  // Use C++ format
1474  if (QualifierLoc != nullptr)
1475  QualifierLoc->print(OS, Policy);
1476  OS << Node->getNameInfo();
1477  }
1478  OS << ":";
1479  VisitOMPClauseList(Node, ' ');
1480  OS << ")";
1481  }
1482 }
1483 
1484 void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) {
1485  if (!Node->varlist_empty()) {
1486  OS << "linear";
1487  if (Node->getModifierLoc().isValid()) {
1488  OS << '('
1489  << getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier());
1490  }
1491  VisitOMPClauseList(Node, '(');
1492  if (Node->getModifierLoc().isValid())
1493  OS << ')';
1494  if (Node->getStep() != nullptr) {
1495  OS << ": ";
1496  Node->getStep()->printPretty(OS, nullptr, Policy, 0);
1497  }
1498  OS << ")";
1499  }
1500 }
1501 
1502 void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) {
1503  if (!Node->varlist_empty()) {
1504  OS << "aligned";
1505  VisitOMPClauseList(Node, '(');
1506  if (Node->getAlignment() != nullptr) {
1507  OS << ": ";
1508  Node->getAlignment()->printPretty(OS, nullptr, Policy, 0);
1509  }
1510  OS << ")";
1511  }
1512 }
1513 
1514 void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) {
1515  if (!Node->varlist_empty()) {
1516  OS << "copyin";
1517  VisitOMPClauseList(Node, '(');
1518  OS << ")";
1519  }
1520 }
1521 
1522 void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) {
1523  if (!Node->varlist_empty()) {
1524  OS << "copyprivate";
1525  VisitOMPClauseList(Node, '(');
1526  OS << ")";
1527  }
1528 }
1529 
1530 void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) {
1531  if (!Node->varlist_empty()) {
1532  VisitOMPClauseList(Node, '(');
1533  OS << ")";
1534  }
1535 }
1536 
1537 void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) {
1538  OS << "depend(";
1539  OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(),
1540  Node->getDependencyKind());
1541  if (!Node->varlist_empty()) {
1542  OS << " :";
1543  VisitOMPClauseList(Node, ' ');
1544  }
1545  OS << ")";
1546 }
1547 
1548 void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) {
1549  if (!Node->varlist_empty()) {
1550  OS << "map(";
1551  if (Node->getMapType() != OMPC_MAP_unknown) {
1552  for (unsigned I = 0; I < OMPMapClause::NumberOfModifiers; ++I) {
1554  OS << getOpenMPSimpleClauseTypeName(OMPC_map,
1555  Node->getMapTypeModifier(I));
1556  if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper) {
1557  OS << '(';
1558  NestedNameSpecifier *MapperNNS =
1560  if (MapperNNS)
1561  MapperNNS->print(OS, Policy);
1562  OS << Node->getMapperIdInfo() << ')';
1563  }
1564  OS << ',';
1565  }
1566  }
1567  OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType());
1568  OS << ':';
1569  }
1570  VisitOMPClauseList(Node, ' ');
1571  OS << ")";
1572  }
1573 }
1574 
1575 void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) {
1576  if (!Node->varlist_empty()) {
1577  OS << "to";
1578  DeclarationNameInfo MapperId = Node->getMapperIdInfo();
1579  if (MapperId.getName() && !MapperId.getName().isEmpty()) {
1580  OS << '(';
1581  OS << "mapper(";
1582  NestedNameSpecifier *MapperNNS =
1584  if (MapperNNS)
1585  MapperNNS->print(OS, Policy);
1586  OS << MapperId << "):";
1587  VisitOMPClauseList(Node, ' ');
1588  } else {
1589  VisitOMPClauseList(Node, '(');
1590  }
1591  OS << ")";
1592  }
1593 }
1594 
1595 void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) {
1596  if (!Node->varlist_empty()) {
1597  OS << "from";
1598  DeclarationNameInfo MapperId = Node->getMapperIdInfo();
1599  if (MapperId.getName() && !MapperId.getName().isEmpty()) {
1600  OS << '(';
1601  OS << "mapper(";
1602  NestedNameSpecifier *MapperNNS =
1604  if (MapperNNS)
1605  MapperNNS->print(OS, Policy);
1606  OS << MapperId << "):";
1607  VisitOMPClauseList(Node, ' ');
1608  } else {
1609  VisitOMPClauseList(Node, '(');
1610  }
1611  OS << ")";
1612  }
1613 }
1614 
1615 void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) {
1616  OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName(
1617  OMPC_dist_schedule, Node->getDistScheduleKind());
1618  if (auto *E = Node->getChunkSize()) {
1619  OS << ", ";
1620  E->printPretty(OS, nullptr, Policy);
1621  }
1622  OS << ")";
1623 }
1624 
1625 void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) {
1626  OS << "defaultmap(";
1627  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
1628  Node->getDefaultmapModifier());
1629  OS << ": ";
1630  OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap,
1631  Node->getDefaultmapKind());
1632  OS << ")";
1633 }
1634 
1635 void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) {
1636  if (!Node->varlist_empty()) {
1637  OS << "use_device_ptr";
1638  VisitOMPClauseList(Node, '(');
1639  OS << ")";
1640  }
1641 }
1642 
1643 void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) {
1644  if (!Node->varlist_empty()) {
1645  OS << "is_device_ptr";
1646  VisitOMPClauseList(Node, '(');
1647  OS << ")";
1648  }
1649 }
1650 
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.
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
bool varlist_empty() const
Definition: OpenMPClause.h:227
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.
TypePropertyCache< Private > Cache
Definition: Type.cpp:3622
static OMPClauseWithPreInit * get(OMPClause *C)
Stmt - This represents one statement.
Definition: Stmt.h:66
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
Expr * getLoopData(unsigned NumLoop)
Get the loop data.
Class that handles pre-initialization statement for some clauses, like &#39;shedule&#39;, &#39;firstprivate&#39; etc...
Definition: OpenMPClause.h:107
Expr * getAllocator() const
Returns allocator.
Definition: OpenMPClause.h:298
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.
static constexpr unsigned NumberOfModifiers
Number of allowed map-type-modifiers.
This represents &#39;if&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:422
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
The base class of the type hierarchy.
Definition: Type.h:1436
MutableArrayRef< Expr * > getUsedExprs()
Gets the list of used expressions for linear variables.
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:564
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.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:490
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 OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
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:591
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
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.
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:263
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:667
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:56
static OMPReductionClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef< Expr *> Privates, ArrayRef< Expr *> LHSExprs, ArrayRef< Expr *> RHSExprs, ArrayRef< Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
CalcStep
Definition: OpenMPClause.h:151
Step
Definition: OpenMPClause.h:151
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:160
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:85
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:325
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
Expr * getChunkSize()
Get chunk size.
This represents clause &#39;map&#39; in the &#39;#pragma omp ...&#39; directives.
This represents clause &#39;to&#39; in the &#39;#pragma omp ...&#39; directives.
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:701
Expr * getNumTeams()
Return NumTeams number.
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
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...
static OMPLastprivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> SrcExprs, ArrayRef< Expr *> DstExprs, ArrayRef< Expr *> AssignmentOps, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL.
static unsigned getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists)
Class that handles post-update expression for some clauses, like &#39;lastprivate&#39;, &#39;reduction&#39; etc...
Definition: OpenMPClause.h:143
This represents &#39;default&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:859
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:522
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
MutableArrayRef< Expr * > getFinals()
Sets the list of final update expressions for linear variables.
OpenMPDependClauseKind getDependencyKind() const
Get dependency type.
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.
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.
void setFinals(ArrayRef< Expr *> FL)
Sets the list of final update expressions for linear variables.
static OMPCopyinClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> SrcExprs, ArrayRef< Expr *> DstExprs, ArrayRef< Expr *> AssignmentOps)
Creates clause with a list of variables VL.
static OMPDependClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr *> VL, unsigned NumLoops)
Creates clause with a list of variables VL.
This represents clause &#39;from&#39; in the &#39;#pragma omp ...&#39; directives.
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.
child_range children()
This represents &#39;dynamic_allocators&#39; clause in the &#39;#pragma omp requires&#39; directive.
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:906
OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, unsigned NumVars)
Build &#39;linear&#39; clause with given number of variables NumVars.
Definition: OpenMPClause.h:122
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:766
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:78
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
static OMPOrderedClause * Create(const ASTContext &C, Expr *Num, unsigned NumLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build &#39;ordered&#39; clause.
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
OpenMPProcBindClauseKind getProcBindKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:987
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
This represents &#39;proc_bind&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:939
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:644
This represents one expression.
Definition: Expr.h:108
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:732
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.
Inits[]
Definition: OpenMPClause.h:150
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:382
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 OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
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:797
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.
This file defines OpenMP AST classes for clauses.
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.
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:155
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
llvm::iterator_range< child_iterator > child_range
Definition: OpenMPClause.h:84
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:77
MutableArrayRef< Expr * > getInits()
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.
Definition: OpenMPClause.h:101
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:50
void setVarRefs(ArrayRef< Expr *> VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:213
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:832
child_range used_children()
static OMPAlignedClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, Expr *A)
Creates clause with a list of variables VL and alignment A.
static OMPPrivateClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PrivateVL)
Creates clause with a list of variables VL.
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:685
ast_type_traits::DynTypedNode Node
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.
OpenMPDefaultmapClauseKind getDefaultmapKind() const
Get kind of the clause.
SourceLocation ModifierLoc
Location of linear modifier if any.
Definition: OpenMPClause.h:104
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.
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.
ArrayRef< MappableExprComponentList > MappableExprComponentListsRef
unsigned NumUniqueDeclarations
Number of unique base declarations.
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
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:493
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.
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.
const char * getOpenMPDirectiveName(OpenMPDirectiveKind Kind)
Definition: OpenMPKinds.cpp:30
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with &#39;sink|source&#39; kind of dependency.
void setClauseInfo(ArrayRef< ValueDecl *> Declarations, MappableExprComponentListsRef ComponentLists)
Fill the clause information from the list of declarations and associated component lists...
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
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.
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.
Definition: OpenMPClause.h:150
int Priority
Definition: Format.cpp:1811
OpenMPMapClauseKind
OpenMP mapping kind for &#39;map&#39; clause.
Definition: OpenMPKinds.h:93
Expr * getThreadLimit()
Return ThreadLimit number.
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=OMPD_unknown)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:122
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.
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:635
This structure contains most locations needed for by an OMPVarListClause.
Definition: OpenMPClause.h:169
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.
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:107
unsigned NumComponents
Total number of expression components.
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.
void setUsedExprs(ArrayRef< Expr *> UE)
Sets the list of used expressions for the linear clause.