/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/OpenMPClause.cpp
Line | Count | Source (jump to first uncovered line) |
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" |
19 | | #include "clang/Basic/OpenMPKinds.h" |
20 | | #include "clang/Basic/TargetInfo.h" |
21 | | #include "llvm/ADT/SmallPtrSet.h" |
22 | | #include "llvm/Support/Casting.h" |
23 | | #include "llvm/Support/ErrorHandling.h" |
24 | | #include <algorithm> |
25 | | #include <cassert> |
26 | | |
27 | | using namespace clang; |
28 | | using namespace llvm; |
29 | | using namespace omp; |
30 | | |
31 | 93.7k | OMPClause::child_range OMPClause::children() { |
32 | 93.7k | switch (getClauseKind()) { |
33 | 0 | default: |
34 | 0 | break; |
35 | 0 | #define GEN_CLANG_CLAUSE_CLASS |
36 | 0 | #define CLAUSE_CLASS(Enum, Str, Class) \ |
37 | 93.7k | case Enum: \ |
38 | 93.7k | return static_cast<Class *>(this)->children(); |
39 | 93.7k | #include "llvm/Frontend/OpenMP/OMP.inc"0 |
40 | 93.7k | } |
41 | 0 | llvm_unreachable("unknown OMPClause"); |
42 | 0 | } |
43 | | |
44 | 106k | OMPClause::child_range OMPClause::used_children() { |
45 | 106k | switch (getClauseKind()) { |
46 | 0 | #define GEN_CLANG_CLAUSE_CLASS |
47 | 0 | #define CLAUSE_CLASS(Enum, Str, Class) \ |
48 | 106k | case Enum: \ |
49 | 106k | return static_cast<Class *>(this)->used_children(); |
50 | 0 | #define CLAUSE_NO_CLASS(Enum, Str) \ |
51 | 0 | case Enum: \ |
52 | 0 | break; |
53 | 106k | #include "llvm/Frontend/OpenMP/OMP.inc"0 |
54 | 106k | } |
55 | 0 | llvm_unreachable("unknown OMPClause"); |
56 | 0 | } |
57 | | |
58 | 89.6k | OMPClauseWithPreInit *OMPClauseWithPreInit::get(OMPClause *C) { |
59 | 89.6k | auto *Res = OMPClauseWithPreInit::get(const_cast<const OMPClause *>(C)); |
60 | 89.6k | return Res ? const_cast<OMPClauseWithPreInit *>(Res)25.6k : nullptr63.9k ; |
61 | 89.6k | } |
62 | | |
63 | 263k | const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) { |
64 | 263k | switch (C->getClauseKind()) { |
65 | 8.72k | case OMPC_schedule: |
66 | 8.72k | return static_cast<const OMPScheduleClause *>(C); |
67 | 4.67k | case OMPC_dist_schedule: |
68 | 4.67k | return static_cast<const OMPDistScheduleClause *>(C); |
69 | 69.2k | case OMPC_firstprivate: |
70 | 69.2k | return static_cast<const OMPFirstprivateClause *>(C); |
71 | 7.59k | case OMPC_lastprivate: |
72 | 7.59k | return static_cast<const OMPLastprivateClause *>(C); |
73 | 29.8k | case OMPC_reduction: |
74 | 29.8k | return static_cast<const OMPReductionClause *>(C); |
75 | 3.23k | case OMPC_task_reduction: |
76 | 3.23k | return static_cast<const OMPTaskReductionClause *>(C); |
77 | 2.33k | case OMPC_in_reduction: |
78 | 2.33k | return static_cast<const OMPInReductionClause *>(C); |
79 | 3.79k | case OMPC_linear: |
80 | 3.79k | return static_cast<const OMPLinearClause *>(C); |
81 | 30.7k | case OMPC_if: |
82 | 30.7k | return static_cast<const OMPIfClause *>(C); |
83 | 5.00k | case OMPC_num_threads: |
84 | 5.00k | return static_cast<const OMPNumThreadsClause *>(C); |
85 | 4.95k | case OMPC_num_teams: |
86 | 4.95k | return static_cast<const OMPNumTeamsClause *>(C); |
87 | 3.93k | case OMPC_thread_limit: |
88 | 3.93k | return static_cast<const OMPThreadLimitClause *>(C); |
89 | 3.40k | case OMPC_device: |
90 | 3.40k | return static_cast<const OMPDeviceClause *>(C); |
91 | 1.50k | case OMPC_grainsize: |
92 | 1.50k | return static_cast<const OMPGrainsizeClause *>(C); |
93 | 1.63k | case OMPC_num_tasks: |
94 | 1.63k | return static_cast<const OMPNumTasksClause *>(C); |
95 | 1.75k | case OMPC_final: |
96 | 1.75k | return static_cast<const OMPFinalClause *>(C); |
97 | 2.19k | case OMPC_priority: |
98 | 2.19k | return static_cast<const OMPPriorityClause *>(C); |
99 | 20 | case OMPC_novariants: |
100 | 20 | return static_cast<const OMPNovariantsClause *>(C); |
101 | 20 | case OMPC_nocontext: |
102 | 20 | return static_cast<const OMPNocontextClause *>(C); |
103 | 495 | case OMPC_filter: |
104 | 495 | return static_cast<const OMPFilterClause *>(C); |
105 | 2.13k | case OMPC_default: |
106 | 3.03k | case OMPC_proc_bind: |
107 | 5.93k | case OMPC_safelen: |
108 | 7.90k | case OMPC_simdlen: |
109 | 7.90k | case OMPC_sizes: |
110 | 7.90k | case OMPC_allocator: |
111 | 9.77k | case OMPC_allocate: |
112 | 14.7k | case OMPC_collapse: |
113 | 15.5k | case OMPC_private: |
114 | 19.3k | case OMPC_shared: |
115 | 20.8k | case OMPC_aligned: |
116 | 21.1k | case OMPC_copyin: |
117 | 21.2k | case OMPC_copyprivate: |
118 | 21.9k | case OMPC_ordered: |
119 | 24.5k | case OMPC_nowait: |
120 | 24.8k | case OMPC_untied: |
121 | 25.1k | case OMPC_mergeable: |
122 | 25.1k | case OMPC_threadprivate: |
123 | 25.1k | case OMPC_flush: |
124 | 25.1k | case OMPC_depobj: |
125 | 25.1k | case OMPC_read: |
126 | 25.1k | case OMPC_write: |
127 | 25.1k | case OMPC_update: |
128 | 25.1k | case OMPC_capture: |
129 | 25.1k | case OMPC_compare: |
130 | 25.1k | case OMPC_seq_cst: |
131 | 25.1k | case OMPC_acq_rel: |
132 | 25.1k | case OMPC_acquire: |
133 | 25.1k | case OMPC_release: |
134 | 25.1k | case OMPC_relaxed: |
135 | 29.1k | case OMPC_depend: |
136 | 29.1k | case OMPC_threads: |
137 | 29.1k | case OMPC_simd: |
138 | 64.9k | case OMPC_map: |
139 | 65.3k | case OMPC_nogroup: |
140 | 65.3k | case OMPC_hint: |
141 | 68.3k | case OMPC_defaultmap: |
142 | 68.3k | case OMPC_unknown: |
143 | 68.3k | case OMPC_uniform: |
144 | 71.5k | case OMPC_to: |
145 | 73.0k | case OMPC_from: |
146 | 73.2k | case OMPC_use_device_ptr: |
147 | 73.2k | case OMPC_use_device_addr: |
148 | 76.4k | case OMPC_is_device_ptr: |
149 | 76.7k | case OMPC_has_device_addr: |
150 | 76.7k | case OMPC_unified_address: |
151 | 76.7k | case OMPC_unified_shared_memory: |
152 | 76.7k | case OMPC_reverse_offload: |
153 | 76.7k | case OMPC_dynamic_allocators: |
154 | 76.7k | case OMPC_atomic_default_mem_order: |
155 | 76.7k | case OMPC_device_type: |
156 | 76.7k | case OMPC_match: |
157 | 77.1k | case OMPC_nontemporal: |
158 | 77.3k | case OMPC_order: |
159 | 77.3k | case OMPC_destroy: |
160 | 77.4k | case OMPC_detach: |
161 | 77.4k | case OMPC_inclusive: |
162 | 77.4k | case OMPC_exclusive: |
163 | 77.7k | case OMPC_uses_allocators: |
164 | 77.7k | case OMPC_affinity: |
165 | 77.7k | case OMPC_when: |
166 | 77.9k | case OMPC_bind: |
167 | 77.9k | break; |
168 | 0 | default: |
169 | 0 | break; |
170 | 263k | } |
171 | | |
172 | 77.9k | return nullptr; |
173 | 263k | } |
174 | | |
175 | 89.6k | OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(OMPClause *C) { |
176 | 89.6k | auto *Res = OMPClauseWithPostUpdate::get(const_cast<const OMPClause *>(C)); |
177 | 89.6k | return Res ? const_cast<OMPClauseWithPostUpdate *>(Res)0 : nullptr; |
178 | 89.6k | } |
179 | | |
180 | 134k | const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C) { |
181 | 134k | switch (C->getClauseKind()) { |
182 | 6.99k | case OMPC_lastprivate: |
183 | 6.99k | return static_cast<const OMPLastprivateClause *>(C); |
184 | 28.8k | case OMPC_reduction: |
185 | 28.8k | return static_cast<const OMPReductionClause *>(C); |
186 | 3.17k | case OMPC_task_reduction: |
187 | 3.17k | return static_cast<const OMPTaskReductionClause *>(C); |
188 | 2.24k | case OMPC_in_reduction: |
189 | 2.24k | return static_cast<const OMPInReductionClause *>(C); |
190 | 3.23k | case OMPC_linear: |
191 | 3.23k | return static_cast<const OMPLinearClause *>(C); |
192 | 2.86k | case OMPC_schedule: |
193 | 4.30k | case OMPC_dist_schedule: |
194 | 4.30k | case OMPC_firstprivate: |
195 | 6.38k | case OMPC_default: |
196 | 7.17k | case OMPC_proc_bind: |
197 | 18.7k | case OMPC_if: |
198 | 19.5k | case OMPC_final: |
199 | 21.5k | case OMPC_num_threads: |
200 | 24.2k | case OMPC_safelen: |
201 | 26.0k | case OMPC_simdlen: |
202 | 26.0k | case OMPC_sizes: |
203 | 26.0k | case OMPC_allocator: |
204 | 27.8k | case OMPC_allocate: |
205 | 32.2k | case OMPC_collapse: |
206 | 32.2k | case OMPC_private: |
207 | 35.8k | case OMPC_shared: |
208 | 36.9k | case OMPC_aligned: |
209 | 37.2k | case OMPC_copyin: |
210 | 37.2k | case OMPC_copyprivate: |
211 | 37.8k | case OMPC_ordered: |
212 | 39.8k | case OMPC_nowait: |
213 | 40.1k | case OMPC_untied: |
214 | 40.4k | case OMPC_mergeable: |
215 | 40.4k | case OMPC_threadprivate: |
216 | 40.4k | case OMPC_flush: |
217 | 40.4k | case OMPC_depobj: |
218 | 40.4k | case OMPC_read: |
219 | 40.4k | case OMPC_write: |
220 | 40.4k | case OMPC_update: |
221 | 40.4k | case OMPC_capture: |
222 | 40.4k | case OMPC_compare: |
223 | 40.4k | case OMPC_seq_cst: |
224 | 40.4k | case OMPC_acq_rel: |
225 | 40.4k | case OMPC_acquire: |
226 | 40.4k | case OMPC_release: |
227 | 40.4k | case OMPC_relaxed: |
228 | 43.4k | case OMPC_depend: |
229 | 44.5k | case OMPC_device: |
230 | 44.5k | case OMPC_threads: |
231 | 44.5k | case OMPC_simd: |
232 | 72.2k | case OMPC_map: |
233 | 74.0k | case OMPC_num_teams: |
234 | 75.5k | case OMPC_thread_limit: |
235 | 76.5k | case OMPC_priority: |
236 | 77.1k | case OMPC_grainsize: |
237 | 77.5k | case OMPC_nogroup: |
238 | 78.2k | case OMPC_num_tasks: |
239 | 78.2k | case OMPC_hint: |
240 | 80.9k | case OMPC_defaultmap: |
241 | 80.9k | case OMPC_unknown: |
242 | 80.9k | case OMPC_uniform: |
243 | 83.8k | case OMPC_to: |
244 | 85.1k | case OMPC_from: |
245 | 85.1k | case OMPC_use_device_ptr: |
246 | 85.1k | case OMPC_use_device_addr: |
247 | 88.1k | case OMPC_is_device_ptr: |
248 | 88.4k | case OMPC_has_device_addr: |
249 | 88.4k | case OMPC_unified_address: |
250 | 88.4k | case OMPC_unified_shared_memory: |
251 | 88.4k | case OMPC_reverse_offload: |
252 | 88.4k | case OMPC_dynamic_allocators: |
253 | 88.4k | case OMPC_atomic_default_mem_order: |
254 | 88.4k | case OMPC_device_type: |
255 | 88.4k | case OMPC_match: |
256 | 88.7k | case OMPC_nontemporal: |
257 | 88.9k | case OMPC_order: |
258 | 88.9k | case OMPC_destroy: |
259 | 88.9k | case OMPC_novariants: |
260 | 88.9k | case OMPC_nocontext: |
261 | 89.0k | case OMPC_detach: |
262 | 89.0k | case OMPC_inclusive: |
263 | 89.0k | case OMPC_exclusive: |
264 | 89.2k | case OMPC_uses_allocators: |
265 | 89.3k | case OMPC_affinity: |
266 | 89.3k | case OMPC_when: |
267 | 89.4k | case OMPC_bind: |
268 | 89.4k | break; |
269 | 168 | default: |
270 | 168 | break; |
271 | 134k | } |
272 | | |
273 | 89.6k | return nullptr; |
274 | 134k | } |
275 | | |
276 | | /// Gets the address of the original, non-captured, expression used in the |
277 | | /// clause as the preinitializer. |
278 | 14.3k | static Stmt **getAddrOfExprAsWritten(Stmt *S) { |
279 | 14.3k | if (!S) |
280 | 10.8k | return nullptr; |
281 | 3.44k | if (auto *DS = dyn_cast<DeclStmt>(S)) { |
282 | 3.44k | assert(DS->isSingleDecl() && "Only single expression must be captured."); |
283 | 3.44k | if (auto *OED = dyn_cast<OMPCapturedExprDecl>(DS->getSingleDecl())) |
284 | 3.44k | return OED->getInitAddress(); |
285 | 3.44k | } |
286 | 0 | return nullptr; |
287 | 3.44k | } |
288 | | |
289 | 11.3k | OMPClause::child_range OMPIfClause::used_children() { |
290 | 11.3k | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
291 | 2.91k | return child_range(C, C + 1); |
292 | 8.46k | return child_range(&Condition, &Condition + 1); |
293 | 11.3k | } |
294 | | |
295 | 552 | OMPClause::child_range OMPGrainsizeClause::used_children() { |
296 | 552 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
297 | 24 | return child_range(C, C + 1); |
298 | 528 | return child_range(&Grainsize, &Grainsize + 1); |
299 | 552 | } |
300 | | |
301 | 696 | OMPClause::child_range OMPNumTasksClause::used_children() { |
302 | 696 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
303 | 48 | return child_range(C, C + 1); |
304 | 648 | return child_range(&NumTasks, &NumTasks + 1); |
305 | 696 | } |
306 | | |
307 | 576 | OMPClause::child_range OMPFinalClause::used_children() { |
308 | 576 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
309 | 240 | return child_range(C, C + 1); |
310 | 336 | return child_range(&Condition, &Condition + 1); |
311 | 576 | } |
312 | | |
313 | 1.12k | OMPClause::child_range OMPPriorityClause::used_children() { |
314 | 1.12k | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
315 | 216 | return child_range(C, C + 1); |
316 | 912 | return child_range(&Priority, &Priority + 1); |
317 | 1.12k | } |
318 | | |
319 | 0 | OMPClause::child_range OMPNovariantsClause::used_children() { |
320 | 0 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
321 | 0 | return child_range(C, C + 1); |
322 | 0 | return child_range(&Condition, &Condition + 1); |
323 | 0 | } |
324 | | |
325 | 0 | OMPClause::child_range OMPNocontextClause::used_children() { |
326 | 0 | if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt())) |
327 | 0 | return child_range(C, C + 1); |
328 | 0 | return child_range(&Condition, &Condition + 1); |
329 | 0 | } |
330 | | |
331 | | OMPOrderedClause *OMPOrderedClause::Create(const ASTContext &C, Expr *Num, |
332 | | unsigned NumLoops, |
333 | | SourceLocation StartLoc, |
334 | | SourceLocation LParenLoc, |
335 | 1.19k | SourceLocation EndLoc) { |
336 | 1.19k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops)); |
337 | 1.19k | auto *Clause = |
338 | 1.19k | new (Mem) OMPOrderedClause(Num, NumLoops, StartLoc, LParenLoc, EndLoc); |
339 | 2.18k | for (unsigned I = 0; I < NumLoops; ++I987 ) { |
340 | 987 | Clause->setLoopNumIterations(I, nullptr); |
341 | 987 | Clause->setLoopCounter(I, nullptr); |
342 | 987 | } |
343 | 1.19k | return Clause; |
344 | 1.19k | } |
345 | | |
346 | | OMPOrderedClause *OMPOrderedClause::CreateEmpty(const ASTContext &C, |
347 | 89 | unsigned NumLoops) { |
348 | 89 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * NumLoops)); |
349 | 89 | auto *Clause = new (Mem) OMPOrderedClause(NumLoops); |
350 | 126 | for (unsigned I = 0; I < NumLoops; ++I37 ) { |
351 | 37 | Clause->setLoopNumIterations(I, nullptr); |
352 | 37 | Clause->setLoopCounter(I, nullptr); |
353 | 37 | } |
354 | 89 | return Clause; |
355 | 89 | } |
356 | | |
357 | | void OMPOrderedClause::setLoopNumIterations(unsigned NumLoop, |
358 | 1.46k | Expr *NumIterations) { |
359 | 1.46k | assert(NumLoop < NumberOfLoops && "out of loops number."); |
360 | 0 | getTrailingObjects<Expr *>()[NumLoop] = NumIterations; |
361 | 1.46k | } |
362 | | |
363 | 778 | ArrayRef<Expr *> OMPOrderedClause::getLoopNumIterations() const { |
364 | 778 | return llvm::makeArrayRef(getTrailingObjects<Expr *>(), NumberOfLoops); |
365 | 778 | } |
366 | | |
367 | 1.46k | void OMPOrderedClause::setLoopCounter(unsigned NumLoop, Expr *Counter) { |
368 | 1.46k | assert(NumLoop < NumberOfLoops && "out of loops number."); |
369 | 0 | getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop] = Counter; |
370 | 1.46k | } |
371 | | |
372 | 37 | Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) { |
373 | 37 | assert(NumLoop < NumberOfLoops && "out of loops number."); |
374 | 0 | return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop]; |
375 | 37 | } |
376 | | |
377 | 16 | const Expr *OMPOrderedClause::getLoopCounter(unsigned NumLoop) const { |
378 | 16 | assert(NumLoop < NumberOfLoops && "out of loops number."); |
379 | 0 | return getTrailingObjects<Expr *>()[NumberOfLoops + NumLoop]; |
380 | 16 | } |
381 | | |
382 | | OMPUpdateClause *OMPUpdateClause::Create(const ASTContext &C, |
383 | | SourceLocation StartLoc, |
384 | 609 | SourceLocation EndLoc) { |
385 | 609 | return new (C) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/false); |
386 | 609 | } |
387 | | |
388 | | OMPUpdateClause * |
389 | | OMPUpdateClause::Create(const ASTContext &C, SourceLocation StartLoc, |
390 | | SourceLocation LParenLoc, SourceLocation ArgumentLoc, |
391 | 40 | OpenMPDependClauseKind DK, SourceLocation EndLoc) { |
392 | 40 | void *Mem = |
393 | 40 | C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1), |
394 | 40 | alignof(OMPUpdateClause)); |
395 | 40 | auto *Clause = |
396 | 40 | new (Mem) OMPUpdateClause(StartLoc, EndLoc, /*IsExtended=*/true); |
397 | 40 | Clause->setLParenLoc(LParenLoc); |
398 | 40 | Clause->setArgumentLoc(ArgumentLoc); |
399 | 40 | Clause->setDependencyKind(DK); |
400 | 40 | return Clause; |
401 | 40 | } |
402 | | |
403 | | OMPUpdateClause *OMPUpdateClause::CreateEmpty(const ASTContext &C, |
404 | 116 | bool IsExtended) { |
405 | 116 | if (!IsExtended) |
406 | 108 | return new (C) OMPUpdateClause(/*IsExtended=*/false); |
407 | 8 | void *Mem = |
408 | 8 | C.Allocate(totalSizeToAlloc<SourceLocation, OpenMPDependClauseKind>(2, 1), |
409 | 8 | alignof(OMPUpdateClause)); |
410 | 8 | auto *Clause = new (Mem) OMPUpdateClause(/*IsExtended=*/true); |
411 | 8 | Clause->IsExtended = true; |
412 | 8 | return Clause; |
413 | 116 | } |
414 | | |
415 | 16.0k | void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { |
416 | 16.0k | assert(VL.size() == varlist_size() && |
417 | 16.0k | "Number of private copies is not the same as the preallocated buffer"); |
418 | 0 | std::copy(VL.begin(), VL.end(), varlist_end()); |
419 | 16.0k | } |
420 | | |
421 | | OMPPrivateClause * |
422 | | OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc, |
423 | | SourceLocation LParenLoc, SourceLocation EndLoc, |
424 | 14.5k | ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) { |
425 | | // Allocate space for private variables and initializer expressions. |
426 | 14.5k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size())); |
427 | 14.5k | OMPPrivateClause *Clause = |
428 | 14.5k | new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
429 | 14.5k | Clause->setVarRefs(VL); |
430 | 14.5k | Clause->setPrivateCopies(PrivateVL); |
431 | 14.5k | return Clause; |
432 | 14.5k | } |
433 | | |
434 | | OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C, |
435 | 1.47k | unsigned N) { |
436 | 1.47k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N)); |
437 | 1.47k | return new (Mem) OMPPrivateClause(N); |
438 | 1.47k | } |
439 | | |
440 | 58.3k | void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { |
441 | 58.3k | assert(VL.size() == varlist_size() && |
442 | 58.3k | "Number of private copies is not the same as the preallocated buffer"); |
443 | 0 | std::copy(VL.begin(), VL.end(), varlist_end()); |
444 | 58.3k | } |
445 | | |
446 | 58.3k | void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) { |
447 | 58.3k | assert(VL.size() == varlist_size() && |
448 | 58.3k | "Number of inits is not the same as the preallocated buffer"); |
449 | 0 | std::copy(VL.begin(), VL.end(), getPrivateCopies().end()); |
450 | 58.3k | } |
451 | | |
452 | | OMPFirstprivateClause * |
453 | | OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc, |
454 | | SourceLocation LParenLoc, SourceLocation EndLoc, |
455 | | ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL, |
456 | 54.0k | ArrayRef<Expr *> InitVL, Stmt *PreInit) { |
457 | 54.0k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size())); |
458 | 54.0k | OMPFirstprivateClause *Clause = |
459 | 54.0k | new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
460 | 54.0k | Clause->setVarRefs(VL); |
461 | 54.0k | Clause->setPrivateCopies(PrivateVL); |
462 | 54.0k | Clause->setInits(InitVL); |
463 | 54.0k | Clause->setPreInitStmt(PreInit); |
464 | 54.0k | return Clause; |
465 | 54.0k | } |
466 | | |
467 | | OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C, |
468 | 4.34k | unsigned N) { |
469 | 4.34k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N)); |
470 | 4.34k | return new (Mem) OMPFirstprivateClause(N); |
471 | 4.34k | } |
472 | | |
473 | 6.97k | void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) { |
474 | 6.97k | assert(PrivateCopies.size() == varlist_size() && |
475 | 6.97k | "Number of private copies is not the same as the preallocated buffer"); |
476 | 0 | std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end()); |
477 | 6.97k | } |
478 | | |
479 | 6.99k | void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { |
480 | 6.99k | assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " |
481 | 6.99k | "not the same as the " |
482 | 6.99k | "preallocated buffer"); |
483 | 0 | std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end()); |
484 | 6.99k | } |
485 | | |
486 | 6.99k | void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { |
487 | 6.99k | assert(DstExprs.size() == varlist_size() && "Number of destination " |
488 | 6.99k | "expressions is not the same as " |
489 | 6.99k | "the preallocated buffer"); |
490 | 0 | std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); |
491 | 6.99k | } |
492 | | |
493 | 6.99k | void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { |
494 | 6.99k | assert(AssignmentOps.size() == varlist_size() && |
495 | 6.99k | "Number of assignment expressions is not the same as the preallocated " |
496 | 6.99k | "buffer"); |
497 | 0 | std::copy(AssignmentOps.begin(), AssignmentOps.end(), |
498 | 6.99k | getDestinationExprs().end()); |
499 | 6.99k | } |
500 | | |
501 | | OMPLastprivateClause *OMPLastprivateClause::Create( |
502 | | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
503 | | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
504 | | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, |
505 | | OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, |
506 | 6.56k | SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate) { |
507 | 6.56k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); |
508 | 6.56k | OMPLastprivateClause *Clause = new (Mem) OMPLastprivateClause( |
509 | 6.56k | StartLoc, LParenLoc, EndLoc, LPKind, LPKindLoc, ColonLoc, VL.size()); |
510 | 6.56k | Clause->setVarRefs(VL); |
511 | 6.56k | Clause->setSourceExprs(SrcExprs); |
512 | 6.56k | Clause->setDestinationExprs(DstExprs); |
513 | 6.56k | Clause->setAssignmentOps(AssignmentOps); |
514 | 6.56k | Clause->setPreInitStmt(PreInit); |
515 | 6.56k | Clause->setPostUpdateExpr(PostUpdate); |
516 | 6.56k | return Clause; |
517 | 6.56k | } |
518 | | |
519 | | OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C, |
520 | 430 | unsigned N) { |
521 | 430 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); |
522 | 430 | return new (Mem) OMPLastprivateClause(N); |
523 | 430 | } |
524 | | |
525 | | OMPSharedClause *OMPSharedClause::Create(const ASTContext &C, |
526 | | SourceLocation StartLoc, |
527 | | SourceLocation LParenLoc, |
528 | | SourceLocation EndLoc, |
529 | 4.52k | ArrayRef<Expr *> VL) { |
530 | 4.52k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); |
531 | 4.52k | OMPSharedClause *Clause = |
532 | 4.52k | new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
533 | 4.52k | Clause->setVarRefs(VL); |
534 | 4.52k | return Clause; |
535 | 4.52k | } |
536 | | |
537 | 473 | OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) { |
538 | 473 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
539 | 473 | return new (Mem) OMPSharedClause(N); |
540 | 473 | } |
541 | | |
542 | 3.23k | void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) { |
543 | 3.23k | assert(PL.size() == varlist_size() && |
544 | 3.23k | "Number of privates is not the same as the preallocated buffer"); |
545 | 0 | std::copy(PL.begin(), PL.end(), varlist_end()); |
546 | 3.23k | } |
547 | | |
548 | 3.23k | void OMPLinearClause::setInits(ArrayRef<Expr *> IL) { |
549 | 3.23k | assert(IL.size() == varlist_size() && |
550 | 3.23k | "Number of inits is not the same as the preallocated buffer"); |
551 | 0 | std::copy(IL.begin(), IL.end(), getPrivates().end()); |
552 | 3.23k | } |
553 | | |
554 | 2.54k | void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) { |
555 | 2.54k | assert(UL.size() == varlist_size() && |
556 | 2.54k | "Number of updates is not the same as the preallocated buffer"); |
557 | 0 | std::copy(UL.begin(), UL.end(), getInits().end()); |
558 | 2.54k | } |
559 | | |
560 | 2.54k | void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) { |
561 | 2.54k | assert(FL.size() == varlist_size() && |
562 | 2.54k | "Number of final updates is not the same as the preallocated buffer"); |
563 | 0 | std::copy(FL.begin(), FL.end(), getUpdates().end()); |
564 | 2.54k | } |
565 | | |
566 | 2.54k | void OMPLinearClause::setUsedExprs(ArrayRef<Expr *> UE) { |
567 | 2.54k | assert( |
568 | 2.54k | UE.size() == varlist_size() + 1 && |
569 | 2.54k | "Number of used expressions is not the same as the preallocated buffer"); |
570 | 0 | std::copy(UE.begin(), UE.end(), getFinals().end() + 2); |
571 | 2.54k | } |
572 | | |
573 | | OMPLinearClause *OMPLinearClause::Create( |
574 | | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
575 | | OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, |
576 | | SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, |
577 | | ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, |
578 | 2.85k | Stmt *PreInit, Expr *PostUpdate) { |
579 | | // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions |
580 | | // (Step and CalcStep), list of used expression + step. |
581 | 2.85k | void *Mem = |
582 | 2.85k | C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2 + VL.size() + 1)); |
583 | 2.85k | OMPLinearClause *Clause = new (Mem) OMPLinearClause( |
584 | 2.85k | StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size()); |
585 | 2.85k | Clause->setVarRefs(VL); |
586 | 2.85k | Clause->setPrivates(PL); |
587 | 2.85k | Clause->setInits(IL); |
588 | | // Fill update and final expressions with zeroes, they are provided later, |
589 | | // after the directive construction. |
590 | 2.85k | std::fill(Clause->getInits().end(), Clause->getInits().end() + VL.size(), |
591 | 2.85k | nullptr); |
592 | 2.85k | std::fill(Clause->getUpdates().end(), Clause->getUpdates().end() + VL.size(), |
593 | 2.85k | nullptr); |
594 | 2.85k | std::fill(Clause->getUsedExprs().begin(), Clause->getUsedExprs().end(), |
595 | 2.85k | nullptr); |
596 | 2.85k | Clause->setStep(Step); |
597 | 2.85k | Clause->setCalcStep(CalcStep); |
598 | 2.85k | Clause->setPreInitStmt(PreInit); |
599 | 2.85k | Clause->setPostUpdateExpr(PostUpdate); |
600 | 2.85k | return Clause; |
601 | 2.85k | } |
602 | | |
603 | | OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C, |
604 | 386 | unsigned NumVars) { |
605 | | // Allocate space for 5 lists (Vars, Inits, Updates, Finals), 2 expressions |
606 | | // (Step and CalcStep), list of used expression + step. |
607 | 386 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2 + NumVars +1)); |
608 | 386 | return new (Mem) OMPLinearClause(NumVars); |
609 | 386 | } |
610 | | |
611 | 2.19k | OMPClause::child_range OMPLinearClause::used_children() { |
612 | | // Range includes only non-nullptr elements. |
613 | 2.19k | return child_range( |
614 | 2.19k | reinterpret_cast<Stmt **>(getUsedExprs().begin()), |
615 | 2.19k | reinterpret_cast<Stmt **>(llvm::find(getUsedExprs(), nullptr))); |
616 | 2.19k | } |
617 | | |
618 | | OMPAlignedClause * |
619 | | OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc, |
620 | | SourceLocation LParenLoc, SourceLocation ColonLoc, |
621 | 1.83k | SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) { |
622 | 1.83k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1)); |
623 | 1.83k | OMPAlignedClause *Clause = new (Mem) |
624 | 1.83k | OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size()); |
625 | 1.83k | Clause->setVarRefs(VL); |
626 | 1.83k | Clause->setAlignment(A); |
627 | 1.83k | return Clause; |
628 | 1.83k | } |
629 | | |
630 | | OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C, |
631 | 262 | unsigned NumVars) { |
632 | 262 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1)); |
633 | 262 | return new (Mem) OMPAlignedClause(NumVars); |
634 | 262 | } |
635 | | |
636 | | OMPAlignClause *OMPAlignClause::Create(const ASTContext &C, Expr *A, |
637 | | SourceLocation StartLoc, |
638 | | SourceLocation LParenLoc, |
639 | 77 | SourceLocation EndLoc) { |
640 | 77 | return new (C) OMPAlignClause(A, StartLoc, LParenLoc, EndLoc); |
641 | 77 | } |
642 | | |
643 | 532 | void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { |
644 | 532 | assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " |
645 | 532 | "not the same as the " |
646 | 532 | "preallocated buffer"); |
647 | 0 | std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); |
648 | 532 | } |
649 | | |
650 | 532 | void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { |
651 | 532 | assert(DstExprs.size() == varlist_size() && "Number of destination " |
652 | 532 | "expressions is not the same as " |
653 | 532 | "the preallocated buffer"); |
654 | 0 | std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); |
655 | 532 | } |
656 | | |
657 | 532 | void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { |
658 | 532 | assert(AssignmentOps.size() == varlist_size() && |
659 | 532 | "Number of assignment expressions is not the same as the preallocated " |
660 | 532 | "buffer"); |
661 | 0 | std::copy(AssignmentOps.begin(), AssignmentOps.end(), |
662 | 532 | getDestinationExprs().end()); |
663 | 532 | } |
664 | | |
665 | | OMPCopyinClause *OMPCopyinClause::Create( |
666 | | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
667 | | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
668 | 450 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { |
669 | 450 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); |
670 | 450 | OMPCopyinClause *Clause = |
671 | 450 | new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
672 | 450 | Clause->setVarRefs(VL); |
673 | 450 | Clause->setSourceExprs(SrcExprs); |
674 | 450 | Clause->setDestinationExprs(DstExprs); |
675 | 450 | Clause->setAssignmentOps(AssignmentOps); |
676 | 450 | return Clause; |
677 | 450 | } |
678 | | |
679 | 82 | OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) { |
680 | 82 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); |
681 | 82 | return new (Mem) OMPCopyinClause(N); |
682 | 82 | } |
683 | | |
684 | 181 | void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { |
685 | 181 | assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " |
686 | 181 | "not the same as the " |
687 | 181 | "preallocated buffer"); |
688 | 0 | std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); |
689 | 181 | } |
690 | | |
691 | 181 | void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { |
692 | 181 | assert(DstExprs.size() == varlist_size() && "Number of destination " |
693 | 181 | "expressions is not the same as " |
694 | 181 | "the preallocated buffer"); |
695 | 0 | std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); |
696 | 181 | } |
697 | | |
698 | 181 | void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { |
699 | 181 | assert(AssignmentOps.size() == varlist_size() && |
700 | 181 | "Number of assignment expressions is not the same as the preallocated " |
701 | 181 | "buffer"); |
702 | 0 | std::copy(AssignmentOps.begin(), AssignmentOps.end(), |
703 | 181 | getDestinationExprs().end()); |
704 | 181 | } |
705 | | |
706 | | OMPCopyprivateClause *OMPCopyprivateClause::Create( |
707 | | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
708 | | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
709 | 158 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { |
710 | 158 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); |
711 | 158 | OMPCopyprivateClause *Clause = |
712 | 158 | new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
713 | 158 | Clause->setVarRefs(VL); |
714 | 158 | Clause->setSourceExprs(SrcExprs); |
715 | 158 | Clause->setDestinationExprs(DstExprs); |
716 | 158 | Clause->setAssignmentOps(AssignmentOps); |
717 | 158 | return Clause; |
718 | 158 | } |
719 | | |
720 | | OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C, |
721 | 23 | unsigned N) { |
722 | 23 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); |
723 | 23 | return new (Mem) OMPCopyprivateClause(N); |
724 | 23 | } |
725 | | |
726 | 28.8k | void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) { |
727 | 28.8k | assert(Privates.size() == varlist_size() && |
728 | 28.8k | "Number of private copies is not the same as the preallocated buffer"); |
729 | 0 | std::copy(Privates.begin(), Privates.end(), varlist_end()); |
730 | 28.8k | } |
731 | | |
732 | 28.8k | void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { |
733 | 28.8k | assert( |
734 | 28.8k | LHSExprs.size() == varlist_size() && |
735 | 28.8k | "Number of LHS expressions is not the same as the preallocated buffer"); |
736 | 0 | std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); |
737 | 28.8k | } |
738 | | |
739 | 28.8k | void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { |
740 | 28.8k | assert( |
741 | 28.8k | RHSExprs.size() == varlist_size() && |
742 | 28.8k | "Number of RHS expressions is not the same as the preallocated buffer"); |
743 | 0 | std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); |
744 | 28.8k | } |
745 | | |
746 | 28.8k | void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { |
747 | 28.8k | assert(ReductionOps.size() == varlist_size() && "Number of reduction " |
748 | 28.8k | "expressions is not the same " |
749 | 28.8k | "as the preallocated buffer"); |
750 | 0 | std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); |
751 | 28.8k | } |
752 | | |
753 | 162 | void OMPReductionClause::setInscanCopyOps(ArrayRef<Expr *> Ops) { |
754 | 162 | assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction."); |
755 | 0 | assert(Ops.size() == varlist_size() && "Number of copy " |
756 | 162 | "expressions is not the same " |
757 | 162 | "as the preallocated buffer"); |
758 | 0 | llvm::copy(Ops, getReductionOps().end()); |
759 | 162 | } |
760 | | |
761 | | void OMPReductionClause::setInscanCopyArrayTemps( |
762 | 162 | ArrayRef<Expr *> CopyArrayTemps) { |
763 | 162 | assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction."); |
764 | 0 | assert(CopyArrayTemps.size() == varlist_size() && |
765 | 162 | "Number of copy temp expressions is not the same as the preallocated " |
766 | 162 | "buffer"); |
767 | 0 | llvm::copy(CopyArrayTemps, getInscanCopyOps().end()); |
768 | 162 | } |
769 | | |
770 | | void OMPReductionClause::setInscanCopyArrayElems( |
771 | 162 | ArrayRef<Expr *> CopyArrayElems) { |
772 | 162 | assert(Modifier == OMPC_REDUCTION_inscan && "Expected inscan reduction."); |
773 | 0 | assert(CopyArrayElems.size() == varlist_size() && |
774 | 162 | "Number of copy temp expressions is not the same as the preallocated " |
775 | 162 | "buffer"); |
776 | 0 | llvm::copy(CopyArrayElems, getInscanCopyArrayTemps().end()); |
777 | 162 | } |
778 | | |
779 | | OMPReductionClause *OMPReductionClause::Create( |
780 | | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
781 | | SourceLocation ModifierLoc, SourceLocation EndLoc, SourceLocation ColonLoc, |
782 | | OpenMPReductionClauseModifier Modifier, ArrayRef<Expr *> VL, |
783 | | NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, |
784 | | ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, |
785 | | ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, |
786 | | ArrayRef<Expr *> CopyOps, ArrayRef<Expr *> CopyArrayTemps, |
787 | 27.8k | ArrayRef<Expr *> CopyArrayElems, Stmt *PreInit, Expr *PostUpdate) { |
788 | 27.8k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>( |
789 | 27.8k | (Modifier == OMPC_REDUCTION_inscan ? 8138 : 527.7k ) * VL.size())); |
790 | 27.8k | auto *Clause = new (Mem) |
791 | 27.8k | OMPReductionClause(StartLoc, LParenLoc, ModifierLoc, EndLoc, ColonLoc, |
792 | 27.8k | Modifier, VL.size(), QualifierLoc, NameInfo); |
793 | 27.8k | Clause->setVarRefs(VL); |
794 | 27.8k | Clause->setPrivates(Privates); |
795 | 27.8k | Clause->setLHSExprs(LHSExprs); |
796 | 27.8k | Clause->setRHSExprs(RHSExprs); |
797 | 27.8k | Clause->setReductionOps(ReductionOps); |
798 | 27.8k | Clause->setPreInitStmt(PreInit); |
799 | 27.8k | Clause->setPostUpdateExpr(PostUpdate); |
800 | 27.8k | if (Modifier == OMPC_REDUCTION_inscan) { |
801 | 138 | Clause->setInscanCopyOps(CopyOps); |
802 | 138 | Clause->setInscanCopyArrayTemps(CopyArrayTemps); |
803 | 138 | Clause->setInscanCopyArrayElems(CopyArrayElems); |
804 | 27.7k | } else { |
805 | 27.7k | assert(CopyOps.empty() && |
806 | 27.7k | "copy operations are expected in inscan reductions only."); |
807 | 0 | assert(CopyArrayTemps.empty() && |
808 | 27.7k | "copy array temps are expected in inscan reductions only."); |
809 | 0 | assert(CopyArrayElems.empty() && |
810 | 27.7k | "copy array temps are expected in inscan reductions only."); |
811 | 27.7k | } |
812 | 0 | return Clause; |
813 | 27.8k | } |
814 | | |
815 | | OMPReductionClause * |
816 | | OMPReductionClause::CreateEmpty(const ASTContext &C, unsigned N, |
817 | 1.00k | OpenMPReductionClauseModifier Modifier) { |
818 | 1.00k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>( |
819 | 1.00k | (Modifier == OMPC_REDUCTION_inscan ? 824 : 5977 ) * N)); |
820 | 1.00k | auto *Clause = new (Mem) OMPReductionClause(N); |
821 | 1.00k | Clause->setModifier(Modifier); |
822 | 1.00k | return Clause; |
823 | 1.00k | } |
824 | | |
825 | 3.17k | void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) { |
826 | 3.17k | assert(Privates.size() == varlist_size() && |
827 | 3.17k | "Number of private copies is not the same as the preallocated buffer"); |
828 | 0 | std::copy(Privates.begin(), Privates.end(), varlist_end()); |
829 | 3.17k | } |
830 | | |
831 | 3.17k | void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { |
832 | 3.17k | assert( |
833 | 3.17k | LHSExprs.size() == varlist_size() && |
834 | 3.17k | "Number of LHS expressions is not the same as the preallocated buffer"); |
835 | 0 | std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); |
836 | 3.17k | } |
837 | | |
838 | 3.17k | void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { |
839 | 3.17k | assert( |
840 | 3.17k | RHSExprs.size() == varlist_size() && |
841 | 3.17k | "Number of RHS expressions is not the same as the preallocated buffer"); |
842 | 0 | std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); |
843 | 3.17k | } |
844 | | |
845 | 3.17k | void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { |
846 | 3.17k | assert(ReductionOps.size() == varlist_size() && "Number of task reduction " |
847 | 3.17k | "expressions is not the same " |
848 | 3.17k | "as the preallocated buffer"); |
849 | 0 | std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); |
850 | 3.17k | } |
851 | | |
852 | | OMPTaskReductionClause *OMPTaskReductionClause::Create( |
853 | | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
854 | | SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL, |
855 | | NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, |
856 | | ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, |
857 | | ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, Stmt *PreInit, |
858 | 3.06k | Expr *PostUpdate) { |
859 | 3.06k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); |
860 | 3.06k | OMPTaskReductionClause *Clause = new (Mem) OMPTaskReductionClause( |
861 | 3.06k | StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo); |
862 | 3.06k | Clause->setVarRefs(VL); |
863 | 3.06k | Clause->setPrivates(Privates); |
864 | 3.06k | Clause->setLHSExprs(LHSExprs); |
865 | 3.06k | Clause->setRHSExprs(RHSExprs); |
866 | 3.06k | Clause->setReductionOps(ReductionOps); |
867 | 3.06k | Clause->setPreInitStmt(PreInit); |
868 | 3.06k | Clause->setPostUpdateExpr(PostUpdate); |
869 | 3.06k | return Clause; |
870 | 3.06k | } |
871 | | |
872 | | OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(const ASTContext &C, |
873 | 112 | unsigned N) { |
874 | 112 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); |
875 | 112 | return new (Mem) OMPTaskReductionClause(N); |
876 | 112 | } |
877 | | |
878 | 2.24k | void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) { |
879 | 2.24k | assert(Privates.size() == varlist_size() && |
880 | 2.24k | "Number of private copies is not the same as the preallocated buffer"); |
881 | 0 | std::copy(Privates.begin(), Privates.end(), varlist_end()); |
882 | 2.24k | } |
883 | | |
884 | 2.24k | void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { |
885 | 2.24k | assert( |
886 | 2.24k | LHSExprs.size() == varlist_size() && |
887 | 2.24k | "Number of LHS expressions is not the same as the preallocated buffer"); |
888 | 0 | std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); |
889 | 2.24k | } |
890 | | |
891 | 2.24k | void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { |
892 | 2.24k | assert( |
893 | 2.24k | RHSExprs.size() == varlist_size() && |
894 | 2.24k | "Number of RHS expressions is not the same as the preallocated buffer"); |
895 | 0 | std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); |
896 | 2.24k | } |
897 | | |
898 | 2.24k | void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { |
899 | 2.24k | assert(ReductionOps.size() == varlist_size() && "Number of in reduction " |
900 | 2.24k | "expressions is not the same " |
901 | 2.24k | "as the preallocated buffer"); |
902 | 0 | std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); |
903 | 2.24k | } |
904 | | |
905 | | void OMPInReductionClause::setTaskgroupDescriptors( |
906 | 2.24k | ArrayRef<Expr *> TaskgroupDescriptors) { |
907 | 2.24k | assert(TaskgroupDescriptors.size() == varlist_size() && |
908 | 2.24k | "Number of in reduction descriptors is not the same as the " |
909 | 2.24k | "preallocated buffer"); |
910 | 0 | std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(), |
911 | 2.24k | getReductionOps().end()); |
912 | 2.24k | } |
913 | | |
914 | | OMPInReductionClause *OMPInReductionClause::Create( |
915 | | const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
916 | | SourceLocation EndLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL, |
917 | | NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, |
918 | | ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, |
919 | | ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps, |
920 | 2.15k | ArrayRef<Expr *> TaskgroupDescriptors, Stmt *PreInit, Expr *PostUpdate) { |
921 | 2.15k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * VL.size())); |
922 | 2.15k | OMPInReductionClause *Clause = new (Mem) OMPInReductionClause( |
923 | 2.15k | StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo); |
924 | 2.15k | Clause->setVarRefs(VL); |
925 | 2.15k | Clause->setPrivates(Privates); |
926 | 2.15k | Clause->setLHSExprs(LHSExprs); |
927 | 2.15k | Clause->setRHSExprs(RHSExprs); |
928 | 2.15k | Clause->setReductionOps(ReductionOps); |
929 | 2.15k | Clause->setTaskgroupDescriptors(TaskgroupDescriptors); |
930 | 2.15k | Clause->setPreInitStmt(PreInit); |
931 | 2.15k | Clause->setPostUpdateExpr(PostUpdate); |
932 | 2.15k | return Clause; |
933 | 2.15k | } |
934 | | |
935 | | OMPInReductionClause *OMPInReductionClause::CreateEmpty(const ASTContext &C, |
936 | 91 | unsigned N) { |
937 | 91 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(6 * N)); |
938 | 91 | return new (Mem) OMPInReductionClause(N); |
939 | 91 | } |
940 | | |
941 | | OMPSizesClause *OMPSizesClause::Create(const ASTContext &C, |
942 | | SourceLocation StartLoc, |
943 | | SourceLocation LParenLoc, |
944 | | SourceLocation EndLoc, |
945 | 80 | ArrayRef<Expr *> Sizes) { |
946 | 80 | OMPSizesClause *Clause = CreateEmpty(C, Sizes.size()); |
947 | 80 | Clause->setLocStart(StartLoc); |
948 | 80 | Clause->setLParenLoc(LParenLoc); |
949 | 80 | Clause->setLocEnd(EndLoc); |
950 | 80 | Clause->setSizesRefs(Sizes); |
951 | 80 | return Clause; |
952 | 80 | } |
953 | | |
954 | | OMPSizesClause *OMPSizesClause::CreateEmpty(const ASTContext &C, |
955 | 106 | unsigned NumSizes) { |
956 | 106 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumSizes)); |
957 | 106 | return new (Mem) OMPSizesClause(NumSizes); |
958 | 106 | } |
959 | | |
960 | | OMPFullClause *OMPFullClause::Create(const ASTContext &C, |
961 | | SourceLocation StartLoc, |
962 | 15 | SourceLocation EndLoc) { |
963 | 15 | OMPFullClause *Clause = CreateEmpty(C); |
964 | 15 | Clause->setLocStart(StartLoc); |
965 | 15 | Clause->setLocEnd(EndLoc); |
966 | 15 | return Clause; |
967 | 15 | } |
968 | | |
969 | 18 | OMPFullClause *OMPFullClause::CreateEmpty(const ASTContext &C) { |
970 | 18 | return new (C) OMPFullClause(); |
971 | 18 | } |
972 | | |
973 | | OMPPartialClause *OMPPartialClause::Create(const ASTContext &C, |
974 | | SourceLocation StartLoc, |
975 | | SourceLocation LParenLoc, |
976 | | SourceLocation EndLoc, |
977 | 69 | Expr *Factor) { |
978 | 69 | OMPPartialClause *Clause = CreateEmpty(C); |
979 | 69 | Clause->setLocStart(StartLoc); |
980 | 69 | Clause->setLParenLoc(LParenLoc); |
981 | 69 | Clause->setLocEnd(EndLoc); |
982 | 69 | Clause->setFactor(Factor); |
983 | 69 | return Clause; |
984 | 69 | } |
985 | | |
986 | 89 | OMPPartialClause *OMPPartialClause::CreateEmpty(const ASTContext &C) { |
987 | 89 | return new (C) OMPPartialClause(); |
988 | 89 | } |
989 | | |
990 | | OMPAllocateClause * |
991 | | OMPAllocateClause::Create(const ASTContext &C, SourceLocation StartLoc, |
992 | | SourceLocation LParenLoc, Expr *Allocator, |
993 | | SourceLocation ColonLoc, SourceLocation EndLoc, |
994 | 2.16k | ArrayRef<Expr *> VL) { |
995 | | // Allocate space for private variables and initializer expressions. |
996 | 2.16k | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); |
997 | 2.16k | auto *Clause = new (Mem) OMPAllocateClause(StartLoc, LParenLoc, Allocator, |
998 | 2.16k | ColonLoc, EndLoc, VL.size()); |
999 | 2.16k | Clause->setVarRefs(VL); |
1000 | 2.16k | return Clause; |
1001 | 2.16k | } |
1002 | | |
1003 | | OMPAllocateClause *OMPAllocateClause::CreateEmpty(const ASTContext &C, |
1004 | 278 | unsigned N) { |
1005 | 278 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
1006 | 278 | return new (Mem) OMPAllocateClause(N); |
1007 | 278 | } |
1008 | | |
1009 | | OMPFlushClause *OMPFlushClause::Create(const ASTContext &C, |
1010 | | SourceLocation StartLoc, |
1011 | | SourceLocation LParenLoc, |
1012 | | SourceLocation EndLoc, |
1013 | 86 | ArrayRef<Expr *> VL) { |
1014 | 86 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1)); |
1015 | 86 | OMPFlushClause *Clause = |
1016 | 86 | new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
1017 | 86 | Clause->setVarRefs(VL); |
1018 | 86 | return Clause; |
1019 | 86 | } |
1020 | | |
1021 | 10 | OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) { |
1022 | 10 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
1023 | 10 | return new (Mem) OMPFlushClause(N); |
1024 | 10 | } |
1025 | | |
1026 | | OMPDepobjClause *OMPDepobjClause::Create(const ASTContext &C, |
1027 | | SourceLocation StartLoc, |
1028 | | SourceLocation LParenLoc, |
1029 | | SourceLocation RParenLoc, |
1030 | 412 | Expr *Depobj) { |
1031 | 412 | auto *Clause = new (C) OMPDepobjClause(StartLoc, LParenLoc, RParenLoc); |
1032 | 412 | Clause->setDepobj(Depobj); |
1033 | 412 | return Clause; |
1034 | 412 | } |
1035 | | |
1036 | 28 | OMPDepobjClause *OMPDepobjClause::CreateEmpty(const ASTContext &C) { |
1037 | 28 | return new (C) OMPDepobjClause(); |
1038 | 28 | } |
1039 | | |
1040 | | OMPDependClause * |
1041 | | OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc, |
1042 | | SourceLocation LParenLoc, SourceLocation EndLoc, |
1043 | | DependDataTy Data, Expr *DepModifier, |
1044 | 3.88k | ArrayRef<Expr *> VL, unsigned NumLoops) { |
1045 | 3.88k | void *Mem = C.Allocate( |
1046 | 3.88k | totalSizeToAlloc<Expr *>(VL.size() + /*depend-modifier*/ 1 + NumLoops), |
1047 | 3.88k | alignof(OMPDependClause)); |
1048 | 3.88k | OMPDependClause *Clause = new (Mem) |
1049 | 3.88k | OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size(), NumLoops); |
1050 | 3.88k | Clause->setDependencyKind(Data.DepKind); |
1051 | 3.88k | Clause->setDependencyLoc(Data.DepLoc); |
1052 | 3.88k | Clause->setColonLoc(Data.ColonLoc); |
1053 | 3.88k | Clause->setOmpAllMemoryLoc(Data.OmpAllMemoryLoc); |
1054 | 3.88k | Clause->setModifier(DepModifier); |
1055 | 3.88k | Clause->setVarRefs(VL); |
1056 | 4.77k | for (unsigned I = 0 ; I < NumLoops; ++I889 ) |
1057 | 889 | Clause->setLoopData(I, nullptr); |
1058 | 3.88k | return Clause; |
1059 | 3.88k | } |
1060 | | |
1061 | | OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N, |
1062 | 743 | unsigned NumLoops) { |
1063 | 743 | void *Mem = |
1064 | 743 | C.Allocate(totalSizeToAlloc<Expr *>(N + /*depend-modifier*/ 1 + NumLoops), |
1065 | 743 | alignof(OMPDependClause)); |
1066 | 743 | return new (Mem) OMPDependClause(N, NumLoops); |
1067 | 743 | } |
1068 | | |
1069 | 1.49k | void OMPDependClause::setLoopData(unsigned NumLoop, Expr *Cnt) { |
1070 | 1.49k | assert((getDependencyKind() == OMPC_DEPEND_sink || |
1071 | 1.49k | getDependencyKind() == OMPC_DEPEND_source) && |
1072 | 1.49k | NumLoop < NumLoops && |
1073 | 1.49k | "Expected sink or source depend + loop index must be less number of " |
1074 | 1.49k | "loops."); |
1075 | 0 | auto *It = std::next(getVarRefs().end(), NumLoop + 1); |
1076 | 1.49k | *It = Cnt; |
1077 | 1.49k | } |
1078 | | |
1079 | 44 | Expr *OMPDependClause::getLoopData(unsigned NumLoop) { |
1080 | 44 | assert((getDependencyKind() == OMPC_DEPEND_sink || |
1081 | 44 | getDependencyKind() == OMPC_DEPEND_source) && |
1082 | 44 | NumLoop < NumLoops && |
1083 | 44 | "Expected sink or source depend + loop index must be less number of " |
1084 | 44 | "loops."); |
1085 | 0 | auto *It = std::next(getVarRefs().end(), NumLoop + 1); |
1086 | 44 | return *It; |
1087 | 44 | } |
1088 | | |
1089 | 48 | const Expr *OMPDependClause::getLoopData(unsigned NumLoop) const { |
1090 | 48 | assert((getDependencyKind() == OMPC_DEPEND_sink || |
1091 | 48 | getDependencyKind() == OMPC_DEPEND_source) && |
1092 | 48 | NumLoop < NumLoops && |
1093 | 48 | "Expected sink or source depend + loop index must be less number of " |
1094 | 48 | "loops."); |
1095 | 0 | const auto *It = std::next(getVarRefs().end(), NumLoop + 1); |
1096 | 48 | return *It; |
1097 | 48 | } |
1098 | | |
1099 | 4.63k | void OMPDependClause::setModifier(Expr *DepModifier) { |
1100 | 4.63k | *getVarRefs().end() = DepModifier; |
1101 | 4.63k | } |
1102 | 2.89k | Expr *OMPDependClause::getModifier() { return *getVarRefs().end(); } |
1103 | | |
1104 | | unsigned OMPClauseMappableExprCommon::getComponentsTotalNumber( |
1105 | 104k | MappableExprComponentListsRef ComponentLists) { |
1106 | 104k | unsigned TotalNum = 0u; |
1107 | 104k | for (auto &C : ComponentLists) |
1108 | 104k | TotalNum += C.size(); |
1109 | 104k | return TotalNum; |
1110 | 104k | } |
1111 | | |
1112 | | unsigned OMPClauseMappableExprCommon::getUniqueDeclarationsTotalNumber( |
1113 | 104k | ArrayRef<const ValueDecl *> Declarations) { |
1114 | 104k | unsigned TotalNum = 0u; |
1115 | 104k | llvm::SmallPtrSet<const ValueDecl *, 8> Cache; |
1116 | 104k | for (const ValueDecl *D : Declarations) { |
1117 | 104k | const ValueDecl *VD = D ? cast<ValueDecl>(D->getCanonicalDecl())96.2k : nullptr7.97k ; |
1118 | 104k | if (Cache.count(VD)) |
1119 | 1.87k | continue; |
1120 | 102k | ++TotalNum; |
1121 | 102k | Cache.insert(VD); |
1122 | 102k | } |
1123 | 104k | return TotalNum; |
1124 | 104k | } |
1125 | | |
1126 | | OMPMapClause *OMPMapClause::Create( |
1127 | | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
1128 | | ArrayRef<ValueDecl *> Declarations, |
1129 | | MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs, |
1130 | | ArrayRef<OpenMPMapModifierKind> MapModifiers, |
1131 | | ArrayRef<SourceLocation> MapModifiersLoc, |
1132 | | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId, |
1133 | 44.2k | OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc) { |
1134 | 44.2k | OMPMappableExprListSizeTy Sizes; |
1135 | 44.2k | Sizes.NumVars = Vars.size(); |
1136 | 44.2k | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
1137 | 44.2k | Sizes.NumComponentLists = ComponentLists.size(); |
1138 | 44.2k | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
1139 | | |
1140 | | // We need to allocate: |
1141 | | // 2 x NumVars x Expr* - we have an original list expression and an associated |
1142 | | // user-defined mapper for each clause list entry. |
1143 | | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
1144 | | // with each component list. |
1145 | | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
1146 | | // number of lists for each unique declaration and the size of each component |
1147 | | // list. |
1148 | | // NumComponents x MappableComponent - the total of all the components in all |
1149 | | // the lists. |
1150 | 44.2k | void *Mem = C.Allocate( |
1151 | 44.2k | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1152 | 44.2k | OMPClauseMappableExprCommon::MappableComponent>( |
1153 | 44.2k | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1154 | 44.2k | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1155 | 44.2k | Sizes.NumComponents)); |
1156 | 44.2k | OMPMapClause *Clause = new (Mem) |
1157 | 44.2k | OMPMapClause(MapModifiers, MapModifiersLoc, UDMQualifierLoc, MapperId, |
1158 | 44.2k | Type, TypeIsImplicit, TypeLoc, Locs, Sizes); |
1159 | | |
1160 | 44.2k | Clause->setVarRefs(Vars); |
1161 | 44.2k | Clause->setUDMapperRefs(UDMapperRefs); |
1162 | 44.2k | Clause->setClauseInfo(Declarations, ComponentLists); |
1163 | 44.2k | Clause->setMapType(Type); |
1164 | 44.2k | Clause->setMapLoc(TypeLoc); |
1165 | 44.2k | return Clause; |
1166 | 44.2k | } |
1167 | | |
1168 | | OMPMapClause * |
1169 | | OMPMapClause::CreateEmpty(const ASTContext &C, |
1170 | 4.23k | const OMPMappableExprListSizeTy &Sizes) { |
1171 | 4.23k | void *Mem = C.Allocate( |
1172 | 4.23k | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1173 | 4.23k | OMPClauseMappableExprCommon::MappableComponent>( |
1174 | 4.23k | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1175 | 4.23k | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1176 | 4.23k | Sizes.NumComponents)); |
1177 | 4.23k | return new (Mem) OMPMapClause(Sizes); |
1178 | 4.23k | } |
1179 | | |
1180 | | OMPToClause *OMPToClause::Create( |
1181 | | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
1182 | | ArrayRef<ValueDecl *> Declarations, |
1183 | | MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs, |
1184 | | ArrayRef<OpenMPMotionModifierKind> MotionModifiers, |
1185 | | ArrayRef<SourceLocation> MotionModifiersLoc, |
1186 | 2.93k | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) { |
1187 | 2.93k | OMPMappableExprListSizeTy Sizes; |
1188 | 2.93k | Sizes.NumVars = Vars.size(); |
1189 | 2.93k | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
1190 | 2.93k | Sizes.NumComponentLists = ComponentLists.size(); |
1191 | 2.93k | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
1192 | | |
1193 | | // We need to allocate: |
1194 | | // 2 x NumVars x Expr* - we have an original list expression and an associated |
1195 | | // user-defined mapper for each clause list entry. |
1196 | | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
1197 | | // with each component list. |
1198 | | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
1199 | | // number of lists for each unique declaration and the size of each component |
1200 | | // list. |
1201 | | // NumComponents x MappableComponent - the total of all the components in all |
1202 | | // the lists. |
1203 | 2.93k | void *Mem = C.Allocate( |
1204 | 2.93k | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1205 | 2.93k | OMPClauseMappableExprCommon::MappableComponent>( |
1206 | 2.93k | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1207 | 2.93k | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1208 | 2.93k | Sizes.NumComponents)); |
1209 | | |
1210 | 2.93k | auto *Clause = new (Mem) OMPToClause(MotionModifiers, MotionModifiersLoc, |
1211 | 2.93k | UDMQualifierLoc, MapperId, Locs, Sizes); |
1212 | | |
1213 | 2.93k | Clause->setVarRefs(Vars); |
1214 | 2.93k | Clause->setUDMapperRefs(UDMapperRefs); |
1215 | 2.93k | Clause->setClauseInfo(Declarations, ComponentLists); |
1216 | 2.93k | return Clause; |
1217 | 2.93k | } |
1218 | | |
1219 | | OMPToClause *OMPToClause::CreateEmpty(const ASTContext &C, |
1220 | 216 | const OMPMappableExprListSizeTy &Sizes) { |
1221 | 216 | void *Mem = C.Allocate( |
1222 | 216 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1223 | 216 | OMPClauseMappableExprCommon::MappableComponent>( |
1224 | 216 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1225 | 216 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1226 | 216 | Sizes.NumComponents)); |
1227 | 216 | return new (Mem) OMPToClause(Sizes); |
1228 | 216 | } |
1229 | | |
1230 | | OMPFromClause *OMPFromClause::Create( |
1231 | | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
1232 | | ArrayRef<ValueDecl *> Declarations, |
1233 | | MappableExprComponentListsRef ComponentLists, ArrayRef<Expr *> UDMapperRefs, |
1234 | | ArrayRef<OpenMPMotionModifierKind> MotionModifiers, |
1235 | | ArrayRef<SourceLocation> MotionModifiersLoc, |
1236 | 1.33k | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId) { |
1237 | 1.33k | OMPMappableExprListSizeTy Sizes; |
1238 | 1.33k | Sizes.NumVars = Vars.size(); |
1239 | 1.33k | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
1240 | 1.33k | Sizes.NumComponentLists = ComponentLists.size(); |
1241 | 1.33k | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
1242 | | |
1243 | | // We need to allocate: |
1244 | | // 2 x NumVars x Expr* - we have an original list expression and an associated |
1245 | | // user-defined mapper for each clause list entry. |
1246 | | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
1247 | | // with each component list. |
1248 | | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
1249 | | // number of lists for each unique declaration and the size of each component |
1250 | | // list. |
1251 | | // NumComponents x MappableComponent - the total of all the components in all |
1252 | | // the lists. |
1253 | 1.33k | void *Mem = C.Allocate( |
1254 | 1.33k | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1255 | 1.33k | OMPClauseMappableExprCommon::MappableComponent>( |
1256 | 1.33k | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1257 | 1.33k | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1258 | 1.33k | Sizes.NumComponents)); |
1259 | | |
1260 | 1.33k | auto *Clause = |
1261 | 1.33k | new (Mem) OMPFromClause(MotionModifiers, MotionModifiersLoc, |
1262 | 1.33k | UDMQualifierLoc, MapperId, Locs, Sizes); |
1263 | | |
1264 | 1.33k | Clause->setVarRefs(Vars); |
1265 | 1.33k | Clause->setUDMapperRefs(UDMapperRefs); |
1266 | 1.33k | Clause->setClauseInfo(Declarations, ComponentLists); |
1267 | 1.33k | return Clause; |
1268 | 1.33k | } |
1269 | | |
1270 | | OMPFromClause * |
1271 | | OMPFromClause::CreateEmpty(const ASTContext &C, |
1272 | 196 | const OMPMappableExprListSizeTy &Sizes) { |
1273 | 196 | void *Mem = C.Allocate( |
1274 | 196 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1275 | 196 | OMPClauseMappableExprCommon::MappableComponent>( |
1276 | 196 | 2 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1277 | 196 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1278 | 196 | Sizes.NumComponents)); |
1279 | 196 | return new (Mem) OMPFromClause(Sizes); |
1280 | 196 | } |
1281 | | |
1282 | 502 | void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) { |
1283 | 502 | assert(VL.size() == varlist_size() && |
1284 | 502 | "Number of private copies is not the same as the preallocated buffer"); |
1285 | 0 | std::copy(VL.begin(), VL.end(), varlist_end()); |
1286 | 502 | } |
1287 | | |
1288 | 502 | void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) { |
1289 | 502 | assert(VL.size() == varlist_size() && |
1290 | 502 | "Number of inits is not the same as the preallocated buffer"); |
1291 | 0 | std::copy(VL.begin(), VL.end(), getPrivateCopies().end()); |
1292 | 502 | } |
1293 | | |
1294 | | OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create( |
1295 | | const ASTContext &C, const OMPVarListLocTy &Locs, ArrayRef<Expr *> Vars, |
1296 | | ArrayRef<Expr *> PrivateVars, ArrayRef<Expr *> Inits, |
1297 | | ArrayRef<ValueDecl *> Declarations, |
1298 | 412 | MappableExprComponentListsRef ComponentLists) { |
1299 | 412 | OMPMappableExprListSizeTy Sizes; |
1300 | 412 | Sizes.NumVars = Vars.size(); |
1301 | 412 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
1302 | 412 | Sizes.NumComponentLists = ComponentLists.size(); |
1303 | 412 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
1304 | | |
1305 | | // We need to allocate: |
1306 | | // NumVars x Expr* - we have an original list expression for each clause |
1307 | | // list entry. |
1308 | | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
1309 | | // with each component list. |
1310 | | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
1311 | | // number of lists for each unique declaration and the size of each component |
1312 | | // list. |
1313 | | // NumComponents x MappableComponent - the total of all the components in all |
1314 | | // the lists. |
1315 | 412 | void *Mem = C.Allocate( |
1316 | 412 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1317 | 412 | OMPClauseMappableExprCommon::MappableComponent>( |
1318 | 412 | 3 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1319 | 412 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1320 | 412 | Sizes.NumComponents)); |
1321 | | |
1322 | 412 | OMPUseDevicePtrClause *Clause = new (Mem) OMPUseDevicePtrClause(Locs, Sizes); |
1323 | | |
1324 | 412 | Clause->setVarRefs(Vars); |
1325 | 412 | Clause->setPrivateCopies(PrivateVars); |
1326 | 412 | Clause->setInits(Inits); |
1327 | 412 | Clause->setClauseInfo(Declarations, ComponentLists); |
1328 | 412 | return Clause; |
1329 | 412 | } |
1330 | | |
1331 | | OMPUseDevicePtrClause * |
1332 | | OMPUseDevicePtrClause::CreateEmpty(const ASTContext &C, |
1333 | 90 | const OMPMappableExprListSizeTy &Sizes) { |
1334 | 90 | void *Mem = C.Allocate( |
1335 | 90 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1336 | 90 | OMPClauseMappableExprCommon::MappableComponent>( |
1337 | 90 | 3 * Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1338 | 90 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1339 | 90 | Sizes.NumComponents)); |
1340 | 90 | return new (Mem) OMPUseDevicePtrClause(Sizes); |
1341 | 90 | } |
1342 | | |
1343 | | OMPUseDeviceAddrClause * |
1344 | | OMPUseDeviceAddrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
1345 | | ArrayRef<Expr *> Vars, |
1346 | | ArrayRef<ValueDecl *> Declarations, |
1347 | 116 | MappableExprComponentListsRef ComponentLists) { |
1348 | 116 | OMPMappableExprListSizeTy Sizes; |
1349 | 116 | Sizes.NumVars = Vars.size(); |
1350 | 116 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
1351 | 116 | Sizes.NumComponentLists = ComponentLists.size(); |
1352 | 116 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
1353 | | |
1354 | | // We need to allocate: |
1355 | | // 3 x NumVars x Expr* - we have an original list expression for each clause |
1356 | | // list entry and an equal number of private copies and inits. |
1357 | | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
1358 | | // with each component list. |
1359 | | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
1360 | | // number of lists for each unique declaration and the size of each component |
1361 | | // list. |
1362 | | // NumComponents x MappableComponent - the total of all the components in all |
1363 | | // the lists. |
1364 | 116 | void *Mem = C.Allocate( |
1365 | 116 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1366 | 116 | OMPClauseMappableExprCommon::MappableComponent>( |
1367 | 116 | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1368 | 116 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1369 | 116 | Sizes.NumComponents)); |
1370 | | |
1371 | 116 | auto *Clause = new (Mem) OMPUseDeviceAddrClause(Locs, Sizes); |
1372 | | |
1373 | 116 | Clause->setVarRefs(Vars); |
1374 | 116 | Clause->setClauseInfo(Declarations, ComponentLists); |
1375 | 116 | return Clause; |
1376 | 116 | } |
1377 | | |
1378 | | OMPUseDeviceAddrClause * |
1379 | | OMPUseDeviceAddrClause::CreateEmpty(const ASTContext &C, |
1380 | 14 | const OMPMappableExprListSizeTy &Sizes) { |
1381 | 14 | void *Mem = C.Allocate( |
1382 | 14 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1383 | 14 | OMPClauseMappableExprCommon::MappableComponent>( |
1384 | 14 | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1385 | 14 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1386 | 14 | Sizes.NumComponents)); |
1387 | 14 | return new (Mem) OMPUseDeviceAddrClause(Sizes); |
1388 | 14 | } |
1389 | | |
1390 | | OMPIsDevicePtrClause * |
1391 | | OMPIsDevicePtrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
1392 | | ArrayRef<Expr *> Vars, |
1393 | | ArrayRef<ValueDecl *> Declarations, |
1394 | 3.00k | MappableExprComponentListsRef ComponentLists) { |
1395 | 3.00k | OMPMappableExprListSizeTy Sizes; |
1396 | 3.00k | Sizes.NumVars = Vars.size(); |
1397 | 3.00k | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
1398 | 3.00k | Sizes.NumComponentLists = ComponentLists.size(); |
1399 | 3.00k | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
1400 | | |
1401 | | // We need to allocate: |
1402 | | // NumVars x Expr* - we have an original list expression for each clause list |
1403 | | // entry. |
1404 | | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
1405 | | // with each component list. |
1406 | | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
1407 | | // number of lists for each unique declaration and the size of each component |
1408 | | // list. |
1409 | | // NumComponents x MappableComponent - the total of all the components in all |
1410 | | // the lists. |
1411 | 3.00k | void *Mem = C.Allocate( |
1412 | 3.00k | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1413 | 3.00k | OMPClauseMappableExprCommon::MappableComponent>( |
1414 | 3.00k | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1415 | 3.00k | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1416 | 3.00k | Sizes.NumComponents)); |
1417 | | |
1418 | 3.00k | OMPIsDevicePtrClause *Clause = new (Mem) OMPIsDevicePtrClause(Locs, Sizes); |
1419 | | |
1420 | 3.00k | Clause->setVarRefs(Vars); |
1421 | 3.00k | Clause->setClauseInfo(Declarations, ComponentLists); |
1422 | 3.00k | return Clause; |
1423 | 3.00k | } |
1424 | | |
1425 | | OMPIsDevicePtrClause * |
1426 | | OMPIsDevicePtrClause::CreateEmpty(const ASTContext &C, |
1427 | 446 | const OMPMappableExprListSizeTy &Sizes) { |
1428 | 446 | void *Mem = C.Allocate( |
1429 | 446 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1430 | 446 | OMPClauseMappableExprCommon::MappableComponent>( |
1431 | 446 | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1432 | 446 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1433 | 446 | Sizes.NumComponents)); |
1434 | 446 | return new (Mem) OMPIsDevicePtrClause(Sizes); |
1435 | 446 | } |
1436 | | |
1437 | | OMPHasDeviceAddrClause * |
1438 | | OMPHasDeviceAddrClause::Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
1439 | | ArrayRef<Expr *> Vars, |
1440 | | ArrayRef<ValueDecl *> Declarations, |
1441 | 292 | MappableExprComponentListsRef ComponentLists) { |
1442 | 292 | OMPMappableExprListSizeTy Sizes; |
1443 | 292 | Sizes.NumVars = Vars.size(); |
1444 | 292 | Sizes.NumUniqueDeclarations = getUniqueDeclarationsTotalNumber(Declarations); |
1445 | 292 | Sizes.NumComponentLists = ComponentLists.size(); |
1446 | 292 | Sizes.NumComponents = getComponentsTotalNumber(ComponentLists); |
1447 | | |
1448 | | // We need to allocate: |
1449 | | // NumVars x Expr* - we have an original list expression for each clause list |
1450 | | // entry. |
1451 | | // NumUniqueDeclarations x ValueDecl* - unique base declarations associated |
1452 | | // with each component list. |
1453 | | // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the |
1454 | | // number of lists for each unique declaration and the size of each component |
1455 | | // list. |
1456 | | // NumComponents x MappableComponent - the total of all the components in all |
1457 | | // the lists. |
1458 | 292 | void *Mem = C.Allocate( |
1459 | 292 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1460 | 292 | OMPClauseMappableExprCommon::MappableComponent>( |
1461 | 292 | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1462 | 292 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1463 | 292 | Sizes.NumComponents)); |
1464 | | |
1465 | 292 | auto *Clause = new (Mem) OMPHasDeviceAddrClause(Locs, Sizes); |
1466 | | |
1467 | 292 | Clause->setVarRefs(Vars); |
1468 | 292 | Clause->setClauseInfo(Declarations, ComponentLists); |
1469 | 292 | return Clause; |
1470 | 292 | } |
1471 | | |
1472 | | OMPHasDeviceAddrClause * |
1473 | | OMPHasDeviceAddrClause::CreateEmpty(const ASTContext &C, |
1474 | 46 | const OMPMappableExprListSizeTy &Sizes) { |
1475 | 46 | void *Mem = C.Allocate( |
1476 | 46 | totalSizeToAlloc<Expr *, ValueDecl *, unsigned, |
1477 | 46 | OMPClauseMappableExprCommon::MappableComponent>( |
1478 | 46 | Sizes.NumVars, Sizes.NumUniqueDeclarations, |
1479 | 46 | Sizes.NumUniqueDeclarations + Sizes.NumComponentLists, |
1480 | 46 | Sizes.NumComponents)); |
1481 | 46 | return new (Mem) OMPHasDeviceAddrClause(Sizes); |
1482 | 46 | } |
1483 | | |
1484 | | OMPNontemporalClause *OMPNontemporalClause::Create(const ASTContext &C, |
1485 | | SourceLocation StartLoc, |
1486 | | SourceLocation LParenLoc, |
1487 | | SourceLocation EndLoc, |
1488 | 454 | ArrayRef<Expr *> VL) { |
1489 | | // Allocate space for nontemporal variables + private references. |
1490 | 454 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size())); |
1491 | 454 | auto *Clause = |
1492 | 454 | new (Mem) OMPNontemporalClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
1493 | 454 | Clause->setVarRefs(VL); |
1494 | 454 | return Clause; |
1495 | 454 | } |
1496 | | |
1497 | | OMPNontemporalClause *OMPNontemporalClause::CreateEmpty(const ASTContext &C, |
1498 | 98 | unsigned N) { |
1499 | 98 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N)); |
1500 | 98 | return new (Mem) OMPNontemporalClause(N); |
1501 | 98 | } |
1502 | | |
1503 | 552 | void OMPNontemporalClause::setPrivateRefs(ArrayRef<Expr *> VL) { |
1504 | 552 | assert(VL.size() == varlist_size() && "Number of private references is not " |
1505 | 552 | "the same as the preallocated buffer"); |
1506 | 0 | std::copy(VL.begin(), VL.end(), varlist_end()); |
1507 | 552 | } |
1508 | | |
1509 | | OMPInclusiveClause *OMPInclusiveClause::Create(const ASTContext &C, |
1510 | | SourceLocation StartLoc, |
1511 | | SourceLocation LParenLoc, |
1512 | | SourceLocation EndLoc, |
1513 | 104 | ArrayRef<Expr *> VL) { |
1514 | 104 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); |
1515 | 104 | auto *Clause = |
1516 | 104 | new (Mem) OMPInclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
1517 | 104 | Clause->setVarRefs(VL); |
1518 | 104 | return Clause; |
1519 | 104 | } |
1520 | | |
1521 | | OMPInclusiveClause *OMPInclusiveClause::CreateEmpty(const ASTContext &C, |
1522 | 12 | unsigned N) { |
1523 | 12 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
1524 | 12 | return new (Mem) OMPInclusiveClause(N); |
1525 | 12 | } |
1526 | | |
1527 | | OMPExclusiveClause *OMPExclusiveClause::Create(const ASTContext &C, |
1528 | | SourceLocation StartLoc, |
1529 | | SourceLocation LParenLoc, |
1530 | | SourceLocation EndLoc, |
1531 | 70 | ArrayRef<Expr *> VL) { |
1532 | 70 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); |
1533 | 70 | auto *Clause = |
1534 | 70 | new (Mem) OMPExclusiveClause(StartLoc, LParenLoc, EndLoc, VL.size()); |
1535 | 70 | Clause->setVarRefs(VL); |
1536 | 70 | return Clause; |
1537 | 70 | } |
1538 | | |
1539 | | OMPExclusiveClause *OMPExclusiveClause::CreateEmpty(const ASTContext &C, |
1540 | 12 | unsigned N) { |
1541 | 12 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
1542 | 12 | return new (Mem) OMPExclusiveClause(N); |
1543 | 12 | } |
1544 | | |
1545 | | void OMPUsesAllocatorsClause::setAllocatorsData( |
1546 | 290 | ArrayRef<OMPUsesAllocatorsClause::Data> Data) { |
1547 | 290 | assert(Data.size() == NumOfAllocators && |
1548 | 290 | "Size of allocators data is not the same as the preallocated buffer."); |
1549 | 646 | for (unsigned I = 0, E = Data.size(); I < E; ++I356 ) { |
1550 | 356 | const OMPUsesAllocatorsClause::Data &D = Data[I]; |
1551 | 356 | getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) + |
1552 | 356 | static_cast<int>(ExprOffsets::Allocator)] = |
1553 | 356 | D.Allocator; |
1554 | 356 | getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) + |
1555 | 356 | static_cast<int>( |
1556 | 356 | ExprOffsets::AllocatorTraits)] = |
1557 | 356 | D.AllocatorTraits; |
1558 | 356 | getTrailingObjects< |
1559 | 356 | SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) + |
1560 | 356 | static_cast<int>(ParenLocsOffsets::LParen)] = |
1561 | 356 | D.LParenLoc; |
1562 | 356 | getTrailingObjects< |
1563 | 356 | SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) + |
1564 | 356 | static_cast<int>(ParenLocsOffsets::RParen)] = |
1565 | 356 | D.RParenLoc; |
1566 | 356 | } |
1567 | 290 | } |
1568 | | |
1569 | | OMPUsesAllocatorsClause::Data |
1570 | 962 | OMPUsesAllocatorsClause::getAllocatorData(unsigned I) const { |
1571 | 962 | OMPUsesAllocatorsClause::Data Data; |
1572 | 962 | Data.Allocator = |
1573 | 962 | getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) + |
1574 | 962 | static_cast<int>(ExprOffsets::Allocator)]; |
1575 | 962 | Data.AllocatorTraits = |
1576 | 962 | getTrailingObjects<Expr *>()[I * static_cast<int>(ExprOffsets::Total) + |
1577 | 962 | static_cast<int>( |
1578 | 962 | ExprOffsets::AllocatorTraits)]; |
1579 | 962 | Data.LParenLoc = getTrailingObjects< |
1580 | 962 | SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) + |
1581 | 962 | static_cast<int>(ParenLocsOffsets::LParen)]; |
1582 | 962 | Data.RParenLoc = getTrailingObjects< |
1583 | 962 | SourceLocation>()[I * static_cast<int>(ParenLocsOffsets::Total) + |
1584 | 962 | static_cast<int>(ParenLocsOffsets::RParen)]; |
1585 | 962 | return Data; |
1586 | 962 | } |
1587 | | |
1588 | | OMPUsesAllocatorsClause * |
1589 | | OMPUsesAllocatorsClause::Create(const ASTContext &C, SourceLocation StartLoc, |
1590 | | SourceLocation LParenLoc, SourceLocation EndLoc, |
1591 | 256 | ArrayRef<OMPUsesAllocatorsClause::Data> Data) { |
1592 | 256 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>( |
1593 | 256 | static_cast<int>(ExprOffsets::Total) * Data.size(), |
1594 | 256 | static_cast<int>(ParenLocsOffsets::Total) * Data.size())); |
1595 | 256 | auto *Clause = new (Mem) |
1596 | 256 | OMPUsesAllocatorsClause(StartLoc, LParenLoc, EndLoc, Data.size()); |
1597 | 256 | Clause->setAllocatorsData(Data); |
1598 | 256 | return Clause; |
1599 | 256 | } |
1600 | | |
1601 | | OMPUsesAllocatorsClause * |
1602 | 34 | OMPUsesAllocatorsClause::CreateEmpty(const ASTContext &C, unsigned N) { |
1603 | 34 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *, SourceLocation>( |
1604 | 34 | static_cast<int>(ExprOffsets::Total) * N, |
1605 | 34 | static_cast<int>(ParenLocsOffsets::Total) * N)); |
1606 | 34 | return new (Mem) OMPUsesAllocatorsClause(N); |
1607 | 34 | } |
1608 | | |
1609 | | OMPAffinityClause * |
1610 | | OMPAffinityClause::Create(const ASTContext &C, SourceLocation StartLoc, |
1611 | | SourceLocation LParenLoc, SourceLocation ColonLoc, |
1612 | | SourceLocation EndLoc, Expr *Modifier, |
1613 | 62 | ArrayRef<Expr *> Locators) { |
1614 | 62 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Locators.size() + 1)); |
1615 | 62 | auto *Clause = new (Mem) |
1616 | 62 | OMPAffinityClause(StartLoc, LParenLoc, ColonLoc, EndLoc, Locators.size()); |
1617 | 62 | Clause->setModifier(Modifier); |
1618 | 62 | Clause->setVarRefs(Locators); |
1619 | 62 | return Clause; |
1620 | 62 | } |
1621 | | |
1622 | | OMPAffinityClause *OMPAffinityClause::CreateEmpty(const ASTContext &C, |
1623 | 10 | unsigned N) { |
1624 | 10 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N + 1)); |
1625 | 10 | return new (Mem) OMPAffinityClause(N); |
1626 | 10 | } |
1627 | | |
1628 | | OMPInitClause *OMPInitClause::Create(const ASTContext &C, Expr *InteropVar, |
1629 | | ArrayRef<Expr *> PrefExprs, bool IsTarget, |
1630 | | bool IsTargetSync, SourceLocation StartLoc, |
1631 | | SourceLocation LParenLoc, |
1632 | | SourceLocation VarLoc, |
1633 | 87 | SourceLocation EndLoc) { |
1634 | | |
1635 | 87 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(PrefExprs.size() + 1)); |
1636 | 87 | auto *Clause = |
1637 | 87 | new (Mem) OMPInitClause(IsTarget, IsTargetSync, StartLoc, LParenLoc, |
1638 | 87 | VarLoc, EndLoc, PrefExprs.size() + 1); |
1639 | 87 | Clause->setInteropVar(InteropVar); |
1640 | 87 | llvm::copy(PrefExprs, Clause->getTrailingObjects<Expr *>() + 1); |
1641 | 87 | return Clause; |
1642 | 87 | } |
1643 | | |
1644 | 26 | OMPInitClause *OMPInitClause::CreateEmpty(const ASTContext &C, unsigned N) { |
1645 | 26 | void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); |
1646 | 26 | return new (Mem) OMPInitClause(N); |
1647 | 26 | } |
1648 | | |
1649 | | OMPBindClause * |
1650 | | OMPBindClause::Create(const ASTContext &C, OpenMPBindClauseKind K, |
1651 | | SourceLocation KLoc, SourceLocation StartLoc, |
1652 | 177 | SourceLocation LParenLoc, SourceLocation EndLoc) { |
1653 | 177 | return new (C) OMPBindClause(K, KLoc, StartLoc, LParenLoc, EndLoc); |
1654 | 177 | } |
1655 | | |
1656 | 24 | OMPBindClause *OMPBindClause::CreateEmpty(const ASTContext &C) { |
1657 | 24 | return new (C) OMPBindClause(); |
1658 | 24 | } |
1659 | | //===----------------------------------------------------------------------===// |
1660 | | // OpenMP clauses printing methods |
1661 | | //===----------------------------------------------------------------------===// |
1662 | | |
1663 | 2.19k | void OMPClausePrinter::VisitOMPIfClause(OMPIfClause *Node) { |
1664 | 2.19k | OS << "if("; |
1665 | 2.19k | if (Node->getNameModifier() != OMPD_unknown) |
1666 | 1.05k | OS << getOpenMPDirectiveName(Node->getNameModifier()) << ": "; |
1667 | 2.19k | Node->getCondition()->printPretty(OS, nullptr, Policy, 0); |
1668 | 2.19k | OS << ")"; |
1669 | 2.19k | } |
1670 | | |
1671 | 256 | void OMPClausePrinter::VisitOMPFinalClause(OMPFinalClause *Node) { |
1672 | 256 | OS << "final("; |
1673 | 256 | Node->getCondition()->printPretty(OS, nullptr, Policy, 0); |
1674 | 256 | OS << ")"; |
1675 | 256 | } |
1676 | | |
1677 | 408 | void OMPClausePrinter::VisitOMPNumThreadsClause(OMPNumThreadsClause *Node) { |
1678 | 408 | OS << "num_threads("; |
1679 | 408 | Node->getNumThreads()->printPretty(OS, nullptr, Policy, 0); |
1680 | 408 | OS << ")"; |
1681 | 408 | } |
1682 | | |
1683 | 8 | void OMPClausePrinter::VisitOMPAlignClause(OMPAlignClause *Node) { |
1684 | 8 | OS << "align("; |
1685 | 8 | Node->getAlignment()->printPretty(OS, nullptr, Policy, 0); |
1686 | 8 | OS << ")"; |
1687 | 8 | } |
1688 | | |
1689 | 440 | void OMPClausePrinter::VisitOMPSafelenClause(OMPSafelenClause *Node) { |
1690 | 440 | OS << "safelen("; |
1691 | 440 | Node->getSafelen()->printPretty(OS, nullptr, Policy, 0); |
1692 | 440 | OS << ")"; |
1693 | 440 | } |
1694 | | |
1695 | 440 | void OMPClausePrinter::VisitOMPSimdlenClause(OMPSimdlenClause *Node) { |
1696 | 440 | OS << "simdlen("; |
1697 | 440 | Node->getSimdlen()->printPretty(OS, nullptr, Policy, 0); |
1698 | 440 | OS << ")"; |
1699 | 440 | } |
1700 | | |
1701 | 18 | void OMPClausePrinter::VisitOMPSizesClause(OMPSizesClause *Node) { |
1702 | 18 | OS << "sizes("; |
1703 | 18 | bool First = true; |
1704 | 24 | for (auto Size : Node->getSizesRefs()) { |
1705 | 24 | if (!First) |
1706 | 6 | OS << ", "; |
1707 | 24 | Size->printPretty(OS, nullptr, Policy, 0); |
1708 | 24 | First = false; |
1709 | 24 | } |
1710 | 18 | OS << ")"; |
1711 | 18 | } |
1712 | | |
1713 | 2 | void OMPClausePrinter::VisitOMPFullClause(OMPFullClause *Node) { OS << "full"; } |
1714 | | |
1715 | 14 | void OMPClausePrinter::VisitOMPPartialClause(OMPPartialClause *Node) { |
1716 | 14 | OS << "partial"; |
1717 | | |
1718 | 14 | if (Expr *Factor = Node->getFactor()) { |
1719 | 12 | OS << '('; |
1720 | 12 | Factor->printPretty(OS, nullptr, Policy, 0); |
1721 | 12 | OS << ')'; |
1722 | 12 | } |
1723 | 14 | } |
1724 | | |
1725 | 90 | void OMPClausePrinter::VisitOMPAllocatorClause(OMPAllocatorClause *Node) { |
1726 | 90 | OS << "allocator("; |
1727 | 90 | Node->getAllocator()->printPretty(OS, nullptr, Policy, 0); |
1728 | 90 | OS << ")"; |
1729 | 90 | } |
1730 | | |
1731 | 626 | void OMPClausePrinter::VisitOMPCollapseClause(OMPCollapseClause *Node) { |
1732 | 626 | OS << "collapse("; |
1733 | 626 | Node->getNumForLoops()->printPretty(OS, nullptr, Policy, 0); |
1734 | 626 | OS << ")"; |
1735 | 626 | } |
1736 | | |
1737 | 24 | void OMPClausePrinter::VisitOMPDetachClause(OMPDetachClause *Node) { |
1738 | 24 | OS << "detach("; |
1739 | 24 | Node->getEventHandler()->printPretty(OS, nullptr, Policy, 0); |
1740 | 24 | OS << ")"; |
1741 | 24 | } |
1742 | | |
1743 | 874 | void OMPClausePrinter::VisitOMPDefaultClause(OMPDefaultClause *Node) { |
1744 | 874 | OS << "default(" |
1745 | 874 | << getOpenMPSimpleClauseTypeName(OMPC_default, |
1746 | 874 | unsigned(Node->getDefaultKind())) |
1747 | 874 | << ")"; |
1748 | 874 | } |
1749 | | |
1750 | 276 | void OMPClausePrinter::VisitOMPProcBindClause(OMPProcBindClause *Node) { |
1751 | 276 | OS << "proc_bind(" |
1752 | 276 | << getOpenMPSimpleClauseTypeName(OMPC_proc_bind, |
1753 | 276 | unsigned(Node->getProcBindKind())) |
1754 | 276 | << ")"; |
1755 | 276 | } |
1756 | | |
1757 | 8 | void OMPClausePrinter::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) { |
1758 | 8 | OS << "unified_address"; |
1759 | 8 | } |
1760 | | |
1761 | | void OMPClausePrinter::VisitOMPUnifiedSharedMemoryClause( |
1762 | 8 | OMPUnifiedSharedMemoryClause *) { |
1763 | 8 | OS << "unified_shared_memory"; |
1764 | 8 | } |
1765 | | |
1766 | 8 | void OMPClausePrinter::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) { |
1767 | 8 | OS << "reverse_offload"; |
1768 | 8 | } |
1769 | | |
1770 | | void OMPClausePrinter::VisitOMPDynamicAllocatorsClause( |
1771 | 8 | OMPDynamicAllocatorsClause *) { |
1772 | 8 | OS << "dynamic_allocators"; |
1773 | 8 | } |
1774 | | |
1775 | | void OMPClausePrinter::VisitOMPAtomicDefaultMemOrderClause( |
1776 | 16 | OMPAtomicDefaultMemOrderClause *Node) { |
1777 | 16 | OS << "atomic_default_mem_order(" |
1778 | 16 | << getOpenMPSimpleClauseTypeName(OMPC_atomic_default_mem_order, |
1779 | 16 | Node->getAtomicDefaultMemOrderKind()) |
1780 | 16 | << ")"; |
1781 | 16 | } |
1782 | | |
1783 | 416 | void OMPClausePrinter::VisitOMPScheduleClause(OMPScheduleClause *Node) { |
1784 | 416 | OS << "schedule("; |
1785 | 416 | if (Node->getFirstScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) { |
1786 | 120 | OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, |
1787 | 120 | Node->getFirstScheduleModifier()); |
1788 | 120 | if (Node->getSecondScheduleModifier() != OMPC_SCHEDULE_MODIFIER_unknown) { |
1789 | 0 | OS << ", "; |
1790 | 0 | OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, |
1791 | 0 | Node->getSecondScheduleModifier()); |
1792 | 0 | } |
1793 | 120 | OS << ": "; |
1794 | 120 | } |
1795 | 416 | OS << getOpenMPSimpleClauseTypeName(OMPC_schedule, Node->getScheduleKind()); |
1796 | 416 | if (auto *E = Node->getChunkSize()) { |
1797 | 144 | OS << ", "; |
1798 | 144 | E->printPretty(OS, nullptr, Policy); |
1799 | 144 | } |
1800 | 416 | OS << ")"; |
1801 | 416 | } |
1802 | | |
1803 | 137 | void OMPClausePrinter::VisitOMPOrderedClause(OMPOrderedClause *Node) { |
1804 | 137 | OS << "ordered"; |
1805 | 137 | if (auto *Num = Node->getNumForLoops()) { |
1806 | 48 | OS << "("; |
1807 | 48 | Num->printPretty(OS, nullptr, Policy, 0); |
1808 | 48 | OS << ")"; |
1809 | 48 | } |
1810 | 137 | } |
1811 | | |
1812 | 1.27k | void OMPClausePrinter::VisitOMPNowaitClause(OMPNowaitClause *) { |
1813 | 1.27k | OS << "nowait"; |
1814 | 1.27k | } |
1815 | | |
1816 | 196 | void OMPClausePrinter::VisitOMPUntiedClause(OMPUntiedClause *) { |
1817 | 196 | OS << "untied"; |
1818 | 196 | } |
1819 | | |
1820 | 180 | void OMPClausePrinter::VisitOMPNogroupClause(OMPNogroupClause *) { |
1821 | 180 | OS << "nogroup"; |
1822 | 180 | } |
1823 | | |
1824 | 256 | void OMPClausePrinter::VisitOMPMergeableClause(OMPMergeableClause *) { |
1825 | 256 | OS << "mergeable"; |
1826 | 256 | } |
1827 | | |
1828 | 169 | void OMPClausePrinter::VisitOMPReadClause(OMPReadClause *) { OS << "read"; } |
1829 | | |
1830 | 168 | void OMPClausePrinter::VisitOMPWriteClause(OMPWriteClause *) { OS << "write"; } |
1831 | | |
1832 | 180 | void OMPClausePrinter::VisitOMPUpdateClause(OMPUpdateClause *Node) { |
1833 | 180 | OS << "update"; |
1834 | 180 | if (Node->isExtended()) { |
1835 | 12 | OS << "("; |
1836 | 12 | OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), |
1837 | 12 | Node->getDependencyKind()); |
1838 | 12 | OS << ")"; |
1839 | 12 | } |
1840 | 180 | } |
1841 | | |
1842 | 588 | void OMPClausePrinter::VisitOMPCaptureClause(OMPCaptureClause *) { |
1843 | 588 | OS << "capture"; |
1844 | 588 | } |
1845 | | |
1846 | 504 | void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) { |
1847 | 504 | OS << "compare"; |
1848 | 504 | } |
1849 | | |
1850 | 216 | void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) { |
1851 | 216 | OS << "seq_cst"; |
1852 | 216 | } |
1853 | | |
1854 | 136 | void OMPClausePrinter::VisitOMPAcqRelClause(OMPAcqRelClause *) { |
1855 | 136 | OS << "acq_rel"; |
1856 | 136 | } |
1857 | | |
1858 | 160 | void OMPClausePrinter::VisitOMPAcquireClause(OMPAcquireClause *) { |
1859 | 160 | OS << "acquire"; |
1860 | 160 | } |
1861 | | |
1862 | 208 | void OMPClausePrinter::VisitOMPReleaseClause(OMPReleaseClause *) { |
1863 | 208 | OS << "release"; |
1864 | 208 | } |
1865 | | |
1866 | 192 | void OMPClausePrinter::VisitOMPRelaxedClause(OMPRelaxedClause *) { |
1867 | 192 | OS << "relaxed"; |
1868 | 192 | } |
1869 | | |
1870 | 12 | void OMPClausePrinter::VisitOMPThreadsClause(OMPThreadsClause *) { |
1871 | 12 | OS << "threads"; |
1872 | 12 | } |
1873 | | |
1874 | 36 | void OMPClausePrinter::VisitOMPSIMDClause(OMPSIMDClause *) { OS << "simd"; } |
1875 | | |
1876 | 153 | void OMPClausePrinter::VisitOMPDeviceClause(OMPDeviceClause *Node) { |
1877 | 153 | OS << "device("; |
1878 | 153 | OpenMPDeviceClauseModifier Modifier = Node->getModifier(); |
1879 | 153 | if (Modifier != OMPC_DEVICE_unknown) { |
1880 | 36 | OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), Modifier) |
1881 | 36 | << ": "; |
1882 | 36 | } |
1883 | 153 | Node->getDevice()->printPretty(OS, nullptr, Policy, 0); |
1884 | 153 | OS << ")"; |
1885 | 153 | } |
1886 | | |
1887 | 228 | void OMPClausePrinter::VisitOMPNumTeamsClause(OMPNumTeamsClause *Node) { |
1888 | 228 | OS << "num_teams("; |
1889 | 228 | Node->getNumTeams()->printPretty(OS, nullptr, Policy, 0); |
1890 | 228 | OS << ")"; |
1891 | 228 | } |
1892 | | |
1893 | 220 | void OMPClausePrinter::VisitOMPThreadLimitClause(OMPThreadLimitClause *Node) { |
1894 | 220 | OS << "thread_limit("; |
1895 | 220 | Node->getThreadLimit()->printPretty(OS, nullptr, Policy, 0); |
1896 | 220 | OS << ")"; |
1897 | 220 | } |
1898 | | |
1899 | 512 | void OMPClausePrinter::VisitOMPPriorityClause(OMPPriorityClause *Node) { |
1900 | 512 | OS << "priority("; |
1901 | 512 | Node->getPriority()->printPretty(OS, nullptr, Policy, 0); |
1902 | 512 | OS << ")"; |
1903 | 512 | } |
1904 | | |
1905 | 240 | void OMPClausePrinter::VisitOMPGrainsizeClause(OMPGrainsizeClause *Node) { |
1906 | 240 | OS << "grainsize("; |
1907 | 240 | Node->getGrainsize()->printPretty(OS, nullptr, Policy, 0); |
1908 | 240 | OS << ")"; |
1909 | 240 | } |
1910 | | |
1911 | 240 | void OMPClausePrinter::VisitOMPNumTasksClause(OMPNumTasksClause *Node) { |
1912 | 240 | OS << "num_tasks("; |
1913 | 240 | Node->getNumTasks()->printPretty(OS, nullptr, Policy, 0); |
1914 | 240 | OS << ")"; |
1915 | 240 | } |
1916 | | |
1917 | 228 | void OMPClausePrinter::VisitOMPHintClause(OMPHintClause *Node) { |
1918 | 228 | OS << "hint("; |
1919 | 228 | Node->getHint()->printPretty(OS, nullptr, Policy, 0); |
1920 | 228 | OS << ")"; |
1921 | 228 | } |
1922 | | |
1923 | 30 | void OMPClausePrinter::VisitOMPInitClause(OMPInitClause *Node) { |
1924 | 30 | OS << "init("; |
1925 | 30 | bool First = true; |
1926 | 58 | for (const Expr *E : Node->prefs()) { |
1927 | 58 | if (First) |
1928 | 16 | OS << "prefer_type("; |
1929 | 42 | else |
1930 | 42 | OS << ","; |
1931 | 58 | E->printPretty(OS, nullptr, Policy); |
1932 | 58 | First = false; |
1933 | 58 | } |
1934 | 30 | if (!First) |
1935 | 16 | OS << "), "; |
1936 | 30 | if (Node->getIsTarget()) |
1937 | 18 | OS << "target"; |
1938 | 30 | if (Node->getIsTargetSync()) { |
1939 | 12 | if (Node->getIsTarget()) |
1940 | 0 | OS << ", "; |
1941 | 12 | OS << "targetsync"; |
1942 | 12 | } |
1943 | 30 | OS << " : "; |
1944 | 30 | Node->getInteropVar()->printPretty(OS, nullptr, Policy); |
1945 | 30 | OS << ")"; |
1946 | 30 | } |
1947 | | |
1948 | 20 | void OMPClausePrinter::VisitOMPUseClause(OMPUseClause *Node) { |
1949 | 20 | OS << "use("; |
1950 | 20 | Node->getInteropVar()->printPretty(OS, nullptr, Policy); |
1951 | 20 | OS << ")"; |
1952 | 20 | } |
1953 | | |
1954 | 30 | void OMPClausePrinter::VisitOMPDestroyClause(OMPDestroyClause *Node) { |
1955 | 30 | OS << "destroy"; |
1956 | 30 | if (Expr *E = Node->getInteropVar()) { |
1957 | 18 | OS << "("; |
1958 | 18 | E->printPretty(OS, nullptr, Policy); |
1959 | 18 | OS << ")"; |
1960 | 18 | } |
1961 | 30 | } |
1962 | | |
1963 | 4 | void OMPClausePrinter::VisitOMPNovariantsClause(OMPNovariantsClause *Node) { |
1964 | 4 | OS << "novariants"; |
1965 | 4 | if (Expr *E = Node->getCondition()) { |
1966 | 4 | OS << "("; |
1967 | 4 | E->printPretty(OS, nullptr, Policy, 0); |
1968 | 4 | OS << ")"; |
1969 | 4 | } |
1970 | 4 | } |
1971 | | |
1972 | 4 | void OMPClausePrinter::VisitOMPNocontextClause(OMPNocontextClause *Node) { |
1973 | 4 | OS << "nocontext"; |
1974 | 4 | if (Expr *E = Node->getCondition()) { |
1975 | 4 | OS << "("; |
1976 | 4 | E->printPretty(OS, nullptr, Policy, 0); |
1977 | 4 | OS << ")"; |
1978 | 4 | } |
1979 | 4 | } |
1980 | | |
1981 | | template<typename T> |
1982 | 17.4k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { |
1983 | 17.4k | for (typename T::varlist_iterator I = Node->varlist_begin(), |
1984 | 17.4k | E = Node->varlist_end(); |
1985 | 39.7k | I != E; ++I22.3k ) { |
1986 | 22.3k | assert(*I && "Expected non-null Stmt"); |
1987 | 22.3k | OS << (I == Node->varlist_begin() ? StartSym17.3k : ','4.97k ); |
1988 | 22.3k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { |
1989 | 17.5k | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) |
1990 | 1.46k | DRE->printPretty(OS, nullptr, Policy, 0); |
1991 | 16.0k | else |
1992 | 16.0k | DRE->getDecl()->printQualifiedName(OS); |
1993 | 17.5k | } else |
1994 | 4.85k | (*I)->printPretty(OS, nullptr, Policy, 0); |
1995 | 22.3k | } |
1996 | 17.4k | } void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPAllocateClause>(clang::OMPAllocateClause*, char) Line | Count | Source | 1982 | 1.01k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 1.01k | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 1.01k | E = Node->varlist_end(); | 1985 | 2.02k | I != E; ++I1.01k ) { | 1986 | 1.01k | assert(*I && "Expected non-null Stmt"); | 1987 | 1.01k | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 1.01k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 964 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 24 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 940 | else | 1992 | 940 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 964 | } else | 1994 | 48 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 1.01k | } | 1996 | 1.01k | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPPrivateClause>(clang::OMPPrivateClause*, char) Line | Count | Source | 1982 | 2.97k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 2.97k | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 2.97k | E = Node->varlist_end(); | 1985 | 6.80k | I != E; ++I3.83k ) { | 1986 | 3.83k | assert(*I && "Expected non-null Stmt"); | 1987 | 3.83k | OS << (I == Node->varlist_begin() ? StartSym2.97k : ','864 ); | 1988 | 3.83k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 3.15k | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 1.09k | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 2.06k | else | 1992 | 2.06k | DRE->getDecl()->printQualifiedName(OS); | 1993 | 3.15k | } else | 1994 | 680 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 3.83k | } | 1996 | 2.97k | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPFirstprivateClause>(clang::OMPFirstprivateClause*, char) Line | Count | Source | 1982 | 1.37k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 1.37k | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 1.37k | E = Node->varlist_end(); | 1985 | 3.35k | I != E; ++I1.97k ) { | 1986 | 1.97k | assert(*I && "Expected non-null Stmt"); | 1987 | 1.97k | OS << (I == Node->varlist_begin() ? StartSym1.37k : ','596 ); | 1988 | 1.97k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 1.89k | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 152 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 1.73k | else | 1992 | 1.73k | DRE->getDecl()->printQualifiedName(OS); | 1993 | 1.89k | } else | 1994 | 84 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 1.97k | } | 1996 | 1.37k | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPLastprivateClause>(clang::OMPLastprivateClause*, char) Line | Count | Source | 1982 | 626 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 626 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 626 | E = Node->varlist_end(); | 1985 | 1.70k | I != E; ++I1.08k ) { | 1986 | 1.08k | assert(*I && "Expected non-null Stmt"); | 1987 | 1.08k | OS << (I == Node->varlist_begin() ? StartSym626 : ','456 ); | 1988 | 1.08k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 1.06k | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 32 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 1.03k | else | 1992 | 1.03k | DRE->getDecl()->printQualifiedName(OS); | 1993 | 1.06k | } else | 1994 | 20 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 1.08k | } | 1996 | 626 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPSharedClause>(clang::OMPSharedClause*, char) Line | Count | Source | 1982 | 1.03k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 1.03k | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 1.03k | E = Node->varlist_end(); | 1985 | 2.11k | I != E; ++I1.08k ) { | 1986 | 1.08k | assert(*I && "Expected non-null Stmt"); | 1987 | 1.08k | OS << (I == Node->varlist_begin() ? StartSym1.03k : ','52 ); | 1988 | 1.08k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 874 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 874 | else | 1992 | 874 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 874 | } else | 1994 | 208 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 1.08k | } | 1996 | 1.03k | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPReductionClause>(clang::OMPReductionClause*, char) Line | Count | Source | 1982 | 1.97k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 1.97k | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 1.97k | E = Node->varlist_end(); | 1985 | 4.67k | I != E; ++I2.69k ) { | 1986 | 2.69k | assert(*I && "Expected non-null Stmt"); | 1987 | 2.69k | OS << (I == Node->varlist_begin() ? StartSym1.97k : ','724 ); | 1988 | 2.69k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 2.13k | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 48 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 2.08k | else | 1992 | 2.08k | DRE->getDecl()->printQualifiedName(OS); | 1993 | 2.13k | } else | 1994 | 560 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 2.69k | } | 1996 | 1.97k | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPTaskReductionClause>(clang::OMPTaskReductionClause*, char) Line | Count | Source | 1982 | 312 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 312 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 312 | E = Node->varlist_end(); | 1985 | 624 | I != E; ++I312 ) { | 1986 | 312 | assert(*I && "Expected non-null Stmt"); | 1987 | 312 | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 312 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 280 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 16 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 264 | else | 1992 | 264 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 280 | } else | 1994 | 32 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 312 | } | 1996 | 312 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPInReductionClause>(clang::OMPInReductionClause*, char) Line | Count | Source | 1982 | 176 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 176 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 176 | E = Node->varlist_end(); | 1985 | 352 | I != E; ++I176 ) { | 1986 | 176 | assert(*I && "Expected non-null Stmt"); | 1987 | 176 | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 176 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 172 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 4 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 168 | else | 1992 | 168 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 172 | } else | 1994 | 4 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 176 | } | 1996 | 176 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPLinearClause>(clang::OMPLinearClause*, char) Line | Count | Source | 1982 | 459 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 459 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 459 | E = Node->varlist_end(); | 1985 | 966 | I != E; ++I507 ) { | 1986 | 507 | assert(*I && "Expected non-null Stmt"); | 1987 | 507 | OS << (I == Node->varlist_begin() ? StartSym459 : ','48 ); | 1988 | 507 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 499 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 12 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 487 | else | 1992 | 487 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 499 | } else | 1994 | 8 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 507 | } | 1996 | 459 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPAlignedClause>(clang::OMPAlignedClause*, char) Line | Count | Source | 1982 | 448 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 448 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 448 | E = Node->varlist_end(); | 1985 | 896 | I != E; ++I448 ) { | 1986 | 448 | assert(*I && "Expected non-null Stmt"); | 1987 | 448 | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 448 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 248 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 248 | else | 1992 | 248 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 248 | } else | 1994 | 200 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 448 | } | 1996 | 448 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPCopyinClause>(clang::OMPCopyinClause*, char) Line | Count | Source | 1982 | 196 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 196 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 196 | E = Node->varlist_end(); | 1985 | 452 | I != E; ++I256 ) { | 1986 | 256 | assert(*I && "Expected non-null Stmt"); | 1987 | 256 | OS << (I == Node->varlist_begin() ? StartSym196 : ','60 ); | 1988 | 256 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 232 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 232 | else | 1992 | 232 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 232 | } else | 1994 | 24 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 256 | } | 1996 | 196 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPCopyprivateClause>(clang::OMPCopyprivateClause*, char) Line | Count | Source | 1982 | 32 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 32 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 32 | E = Node->varlist_end(); | 1985 | 72 | I != E; ++I40 ) { | 1986 | 40 | assert(*I && "Expected non-null Stmt"); | 1987 | 40 | OS << (I == Node->varlist_begin() ? StartSym32 : ','8 ); | 1988 | 40 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 36 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 20 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 16 | else | 1992 | 16 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 36 | } else | 1994 | 4 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 40 | } | 1996 | 32 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPFlushClause>(clang::OMPFlushClause*, char) Line | Count | Source | 1982 | 16 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 16 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 16 | E = Node->varlist_end(); | 1985 | 32 | I != E; ++I16 ) { | 1986 | 16 | assert(*I && "Expected non-null Stmt"); | 1987 | 16 | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 16 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 16 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 16 | else | 1992 | 16 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 16 | } else | 1994 | 0 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 16 | } | 1996 | 16 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPDependClause>(clang::OMPDependClause*, char) Line | Count | Source | 1982 | 849 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 849 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 849 | E = Node->varlist_end(); | 1985 | 3.08k | I != E; ++I2.23k ) { | 1986 | 2.23k | assert(*I && "Expected non-null Stmt"); | 1987 | 2.23k | OS << (I == Node->varlist_begin() ? StartSym833 : ','1.40k ); | 1988 | 2.23k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 829 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 829 | else | 1992 | 829 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 829 | } else | 1994 | 1.40k | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 2.23k | } | 1996 | 849 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPMapClause>(clang::OMPMapClause*, char) Line | Count | Source | 1982 | 3.71k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 3.71k | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 3.71k | E = Node->varlist_end(); | 1985 | 7.89k | I != E; ++I4.18k ) { | 1986 | 4.18k | assert(*I && "Expected non-null Stmt"); | 1987 | 4.18k | OS << (I == Node->varlist_begin() ? StartSym3.71k : ','464 ); | 1988 | 4.18k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 3.53k | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 3.53k | else | 1992 | 3.53k | DRE->getDecl()->printQualifiedName(OS); | 1993 | 3.53k | } else | 1994 | 648 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 4.18k | } | 1996 | 3.71k | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPToClause>(clang::OMPToClause*, char) Line | Count | Source | 1982 | 353 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 353 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 353 | E = Node->varlist_end(); | 1985 | 730 | I != E; ++I377 ) { | 1986 | 377 | assert(*I && "Expected non-null Stmt"); | 1987 | 377 | OS << (I == Node->varlist_begin() ? StartSym353 : ','24 ); | 1988 | 377 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 65 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 65 | else | 1992 | 65 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 65 | } else | 1994 | 312 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 377 | } | 1996 | 353 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPFromClause>(clang::OMPFromClause*, char) Line | Count | Source | 1982 | 352 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 352 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 352 | E = Node->varlist_end(); | 1985 | 744 | I != E; ++I392 ) { | 1986 | 392 | assert(*I && "Expected non-null Stmt"); | 1987 | 392 | OS << (I == Node->varlist_begin() ? StartSym352 : ','40 ); | 1988 | 392 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 64 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 64 | else | 1992 | 64 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 64 | } else | 1994 | 328 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 392 | } | 1996 | 352 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPUseDevicePtrClause>(clang::OMPUseDevicePtrClause*, char) Line | Count | Source | 1982 | 40 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 40 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 40 | E = Node->varlist_end(); | 1985 | 80 | I != E; ++I40 ) { | 1986 | 40 | assert(*I && "Expected non-null Stmt"); | 1987 | 40 | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 40 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 40 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 8 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 32 | else | 1992 | 32 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 40 | } else | 1994 | 0 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 40 | } | 1996 | 40 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPUseDeviceAddrClause>(clang::OMPUseDeviceAddrClause*, char) Line | Count | Source | 1982 | 16 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 16 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 16 | E = Node->varlist_end(); | 1985 | 52 | I != E; ++I36 ) { | 1986 | 36 | assert(*I && "Expected non-null Stmt"); | 1987 | 36 | OS << (I == Node->varlist_begin() ? StartSym16 : ','20 ); | 1988 | 36 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 32 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 16 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 16 | else | 1992 | 16 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 32 | } else | 1994 | 4 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 36 | } | 1996 | 16 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPIsDevicePtrClause>(clang::OMPIsDevicePtrClause*, char) Line | Count | Source | 1982 | 1.17k | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 1.17k | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 1.17k | E = Node->varlist_end(); | 1985 | 2.35k | I != E; ++I1.17k ) { | 1986 | 1.17k | assert(*I && "Expected non-null Stmt"); | 1987 | 1.17k | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 1.17k | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 954 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 954 | else | 1992 | 954 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 954 | } else | 1994 | 224 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 1.17k | } | 1996 | 1.17k | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPHasDeviceAddrClause>(clang::OMPHasDeviceAddrClause*, char) Line | Count | Source | 1982 | 157 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 157 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 157 | E = Node->varlist_end(); | 1985 | 314 | I != E; ++I157 ) { | 1986 | 157 | assert(*I && "Expected non-null Stmt"); | 1987 | 157 | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 157 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 149 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 33 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 116 | else | 1992 | 116 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 149 | } else | 1994 | 8 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 157 | } | 1996 | 157 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPNontemporalClause>(clang::OMPNontemporalClause*, char) Line | Count | Source | 1982 | 84 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 84 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 84 | E = Node->varlist_end(); | 1985 | 332 | I != E; ++I248 ) { | 1986 | 248 | assert(*I && "Expected non-null Stmt"); | 1987 | 248 | OS << (I == Node->varlist_begin() ? StartSym84 : ','164 ); | 1988 | 248 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 248 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 248 | else | 1992 | 248 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 248 | } else | 1994 | 0 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 248 | } | 1996 | 84 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPInclusiveClause>(clang::OMPInclusiveClause*, char) Line | Count | Source | 1982 | 12 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 12 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 12 | E = Node->varlist_end(); | 1985 | 24 | I != E; ++I12 ) { | 1986 | 12 | assert(*I && "Expected non-null Stmt"); | 1987 | 12 | OS << (I == Node->varlist_begin() ? StartSym : ','0 ); | 1988 | 12 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 12 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 12 | else | 1992 | 12 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 12 | } else | 1994 | 0 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 12 | } | 1996 | 12 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPExclusiveClause>(clang::OMPExclusiveClause*, char) Line | Count | Source | 1982 | 4 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 4 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 4 | E = Node->varlist_end(); | 1985 | 12 | I != E; ++I8 ) { | 1986 | 8 | assert(*I && "Expected non-null Stmt"); | 1987 | 8 | OS << (I == Node->varlist_begin() ? StartSym4 : ','4 ); | 1988 | 8 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 8 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 8 | else | 1992 | 8 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 8 | } else | 1994 | 0 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 8 | } | 1996 | 4 | } |
void clang::OMPClausePrinter::VisitOMPClauseList<clang::OMPAffinityClause>(clang::OMPAffinityClause*, char) Line | Count | Source | 1982 | 20 | void OMPClausePrinter::VisitOMPClauseList(T *Node, char StartSym) { | 1983 | 20 | for (typename T::varlist_iterator I = Node->varlist_begin(), | 1984 | 20 | E = Node->varlist_end(); | 1985 | 84 | I != E; ++I64 ) { | 1986 | 64 | assert(*I && "Expected non-null Stmt"); | 1987 | 64 | OS << (I == Node->varlist_begin() ? StartSym20 : ','44 ); | 1988 | 64 | if (auto *DRE = dyn_cast<DeclRefExpr>(*I)) { | 1989 | 12 | if (isa<OMPCapturedExprDecl>(DRE->getDecl())) | 1990 | 0 | DRE->printPretty(OS, nullptr, Policy, 0); | 1991 | 12 | else | 1992 | 12 | DRE->getDecl()->printQualifiedName(OS); | 1993 | 12 | } else | 1994 | 52 | (*I)->printPretty(OS, nullptr, Policy, 0); | 1995 | 64 | } | 1996 | 20 | } |
|
1997 | | |
1998 | 1.01k | void OMPClausePrinter::VisitOMPAllocateClause(OMPAllocateClause *Node) { |
1999 | 1.01k | if (Node->varlist_empty()) |
2000 | 0 | return; |
2001 | 1.01k | OS << "allocate"; |
2002 | 1.01k | if (Expr *Allocator = Node->getAllocator()) { |
2003 | 94 | OS << "("; |
2004 | 94 | Allocator->printPretty(OS, nullptr, Policy, 0); |
2005 | 94 | OS << ":"; |
2006 | 94 | VisitOMPClauseList(Node, ' '); |
2007 | 918 | } else { |
2008 | 918 | VisitOMPClauseList(Node, '('); |
2009 | 918 | } |
2010 | 1.01k | OS << ")"; |
2011 | 1.01k | } |
2012 | | |
2013 | 2.97k | void OMPClausePrinter::VisitOMPPrivateClause(OMPPrivateClause *Node) { |
2014 | 2.97k | if (!Node->varlist_empty()) { |
2015 | 2.97k | OS << "private"; |
2016 | 2.97k | VisitOMPClauseList(Node, '('); |
2017 | 2.97k | OS << ")"; |
2018 | 2.97k | } |
2019 | 2.97k | } |
2020 | | |
2021 | 1.37k | void OMPClausePrinter::VisitOMPFirstprivateClause(OMPFirstprivateClause *Node) { |
2022 | 1.37k | if (!Node->varlist_empty()) { |
2023 | 1.37k | OS << "firstprivate"; |
2024 | 1.37k | VisitOMPClauseList(Node, '('); |
2025 | 1.37k | OS << ")"; |
2026 | 1.37k | } |
2027 | 1.37k | } |
2028 | | |
2029 | 626 | void OMPClausePrinter::VisitOMPLastprivateClause(OMPLastprivateClause *Node) { |
2030 | 626 | if (!Node->varlist_empty()) { |
2031 | 626 | OS << "lastprivate"; |
2032 | 626 | OpenMPLastprivateModifier LPKind = Node->getKind(); |
2033 | 626 | if (LPKind != OMPC_LASTPRIVATE_unknown) { |
2034 | 24 | OS << "(" |
2035 | 24 | << getOpenMPSimpleClauseTypeName(OMPC_lastprivate, Node->getKind()) |
2036 | 24 | << ":"; |
2037 | 24 | } |
2038 | 626 | VisitOMPClauseList(Node, LPKind == OMPC_LASTPRIVATE_unknown ? '('602 : ' '24 ); |
2039 | 626 | OS << ")"; |
2040 | 626 | } |
2041 | 626 | } |
2042 | | |
2043 | 1.03k | void OMPClausePrinter::VisitOMPSharedClause(OMPSharedClause *Node) { |
2044 | 1.03k | if (!Node->varlist_empty()) { |
2045 | 1.03k | OS << "shared"; |
2046 | 1.03k | VisitOMPClauseList(Node, '('); |
2047 | 1.03k | OS << ")"; |
2048 | 1.03k | } |
2049 | 1.03k | } |
2050 | | |
2051 | 1.97k | void OMPClausePrinter::VisitOMPReductionClause(OMPReductionClause *Node) { |
2052 | 1.97k | if (!Node->varlist_empty()) { |
2053 | 1.97k | OS << "reduction("; |
2054 | 1.97k | if (Node->getModifierLoc().isValid()) |
2055 | 164 | OS << getOpenMPSimpleClauseTypeName(OMPC_reduction, Node->getModifier()) |
2056 | 164 | << ", "; |
2057 | 1.97k | NestedNameSpecifier *QualifierLoc = |
2058 | 1.97k | Node->getQualifierLoc().getNestedNameSpecifier(); |
2059 | 1.97k | OverloadedOperatorKind OOK = |
2060 | 1.97k | Node->getNameInfo().getName().getCXXOverloadedOperator(); |
2061 | 1.97k | if (QualifierLoc == nullptr && OOK != OO_None) { |
2062 | | // Print reduction identifier in C format |
2063 | 1.55k | OS << getOperatorSpelling(OOK); |
2064 | 1.55k | } else { |
2065 | | // Use C++ format |
2066 | 420 | if (QualifierLoc != nullptr) |
2067 | 0 | QualifierLoc->print(OS, Policy); |
2068 | 420 | OS << Node->getNameInfo(); |
2069 | 420 | } |
2070 | 1.97k | OS << ":"; |
2071 | 1.97k | VisitOMPClauseList(Node, ' '); |
2072 | 1.97k | OS << ")"; |
2073 | 1.97k | } |
2074 | 1.97k | } |
2075 | | |
2076 | | void OMPClausePrinter::VisitOMPTaskReductionClause( |
2077 | 312 | OMPTaskReductionClause *Node) { |
2078 | 312 | if (!Node->varlist_empty()) { |
2079 | 312 | OS << "task_reduction("; |
2080 | 312 | NestedNameSpecifier *QualifierLoc = |
2081 | 312 | Node->getQualifierLoc().getNestedNameSpecifier(); |
2082 | 312 | OverloadedOperatorKind OOK = |
2083 | 312 | Node->getNameInfo().getName().getCXXOverloadedOperator(); |
2084 | 312 | if (QualifierLoc == nullptr && OOK != OO_None) { |
2085 | | // Print reduction identifier in C format |
2086 | 300 | OS << getOperatorSpelling(OOK); |
2087 | 300 | } else { |
2088 | | // Use C++ format |
2089 | 12 | if (QualifierLoc != nullptr) |
2090 | 0 | QualifierLoc->print(OS, Policy); |
2091 | 12 | OS << Node->getNameInfo(); |
2092 | 12 | } |
2093 | 312 | OS << ":"; |
2094 | 312 | VisitOMPClauseList(Node, ' '); |
2095 | 312 | OS << ")"; |
2096 | 312 | } |
2097 | 312 | } |
2098 | | |
2099 | 176 | void OMPClausePrinter::VisitOMPInReductionClause(OMPInReductionClause *Node) { |
2100 | 176 | if (!Node->varlist_empty()) { |
2101 | 176 | OS << "in_reduction("; |
2102 | 176 | NestedNameSpecifier *QualifierLoc = |
2103 | 176 | Node->getQualifierLoc().getNestedNameSpecifier(); |
2104 | 176 | OverloadedOperatorKind OOK = |
2105 | 176 | Node->getNameInfo().getName().getCXXOverloadedOperator(); |
2106 | 176 | if (QualifierLoc == nullptr && OOK != OO_None) { |
2107 | | // Print reduction identifier in C format |
2108 | 168 | OS << getOperatorSpelling(OOK); |
2109 | 168 | } else { |
2110 | | // Use C++ format |
2111 | 8 | if (QualifierLoc != nullptr) |
2112 | 0 | QualifierLoc->print(OS, Policy); |
2113 | 8 | OS << Node->getNameInfo(); |
2114 | 8 | } |
2115 | 176 | OS << ":"; |
2116 | 176 | VisitOMPClauseList(Node, ' '); |
2117 | 176 | OS << ")"; |
2118 | 176 | } |
2119 | 176 | } |
2120 | | |
2121 | 459 | void OMPClausePrinter::VisitOMPLinearClause(OMPLinearClause *Node) { |
2122 | 459 | if (!Node->varlist_empty()) { |
2123 | 459 | OS << "linear"; |
2124 | 459 | if (Node->getModifierLoc().isValid()) { |
2125 | 40 | OS << '(' |
2126 | 40 | << getOpenMPSimpleClauseTypeName(OMPC_linear, Node->getModifier()); |
2127 | 40 | } |
2128 | 459 | VisitOMPClauseList(Node, '('); |
2129 | 459 | if (Node->getModifierLoc().isValid()) |
2130 | 40 | OS << ')'; |
2131 | 459 | if (Node->getStep() != nullptr) { |
2132 | 175 | OS << ": "; |
2133 | 175 | Node->getStep()->printPretty(OS, nullptr, Policy, 0); |
2134 | 175 | } |
2135 | 459 | OS << ")"; |
2136 | 459 | } |
2137 | 459 | } |
2138 | | |
2139 | 448 | void OMPClausePrinter::VisitOMPAlignedClause(OMPAlignedClause *Node) { |
2140 | 448 | if (!Node->varlist_empty()) { |
2141 | 448 | OS << "aligned"; |
2142 | 448 | VisitOMPClauseList(Node, '('); |
2143 | 448 | if (Node->getAlignment() != nullptr) { |
2144 | 304 | OS << ": "; |
2145 | 304 | Node->getAlignment()->printPretty(OS, nullptr, Policy, 0); |
2146 | 304 | } |
2147 | 448 | OS << ")"; |
2148 | 448 | } |
2149 | 448 | } |
2150 | | |
2151 | 196 | void OMPClausePrinter::VisitOMPCopyinClause(OMPCopyinClause *Node) { |
2152 | 196 | if (!Node->varlist_empty()) { |
2153 | 196 | OS << "copyin"; |
2154 | 196 | VisitOMPClauseList(Node, '('); |
2155 | 196 | OS << ")"; |
2156 | 196 | } |
2157 | 196 | } |
2158 | | |
2159 | 32 | void OMPClausePrinter::VisitOMPCopyprivateClause(OMPCopyprivateClause *Node) { |
2160 | 32 | if (!Node->varlist_empty()) { |
2161 | 32 | OS << "copyprivate"; |
2162 | 32 | VisitOMPClauseList(Node, '('); |
2163 | 32 | OS << ")"; |
2164 | 32 | } |
2165 | 32 | } |
2166 | | |
2167 | 16 | void OMPClausePrinter::VisitOMPFlushClause(OMPFlushClause *Node) { |
2168 | 16 | if (!Node->varlist_empty()) { |
2169 | 16 | VisitOMPClauseList(Node, '('); |
2170 | 16 | OS << ")"; |
2171 | 16 | } |
2172 | 16 | } |
2173 | | |
2174 | 44 | void OMPClausePrinter::VisitOMPDepobjClause(OMPDepobjClause *Node) { |
2175 | 44 | OS << "("; |
2176 | 44 | Node->getDepobj()->printPretty(OS, nullptr, Policy, 0); |
2177 | 44 | OS << ")"; |
2178 | 44 | } |
2179 | | |
2180 | 849 | void OMPClausePrinter::VisitOMPDependClause(OMPDependClause *Node) { |
2181 | 849 | OS << "depend("; |
2182 | 849 | if (Expr *DepModifier = Node->getModifier()) { |
2183 | 24 | DepModifier->printPretty(OS, nullptr, Policy); |
2184 | 24 | OS << ", "; |
2185 | 24 | } |
2186 | 849 | OpenMPDependClauseKind DepKind = Node->getDependencyKind(); |
2187 | 849 | OpenMPDependClauseKind PrintKind = DepKind; |
2188 | 849 | bool IsOmpAllMemory = false; |
2189 | 849 | if (PrintKind == OMPC_DEPEND_outallmemory) { |
2190 | 4 | PrintKind = OMPC_DEPEND_out; |
2191 | 4 | IsOmpAllMemory = true; |
2192 | 845 | } else if (PrintKind == OMPC_DEPEND_inoutallmemory) { |
2193 | 8 | PrintKind = OMPC_DEPEND_inout; |
2194 | 8 | IsOmpAllMemory = true; |
2195 | 8 | } |
2196 | 849 | OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), PrintKind); |
2197 | 849 | if (!Node->varlist_empty() || IsOmpAllMemory16 ) |
2198 | 837 | OS << " :"; |
2199 | 849 | VisitOMPClauseList(Node, ' '); |
2200 | 849 | if (IsOmpAllMemory) { |
2201 | 12 | OS << (Node->varlist_empty() ? " "4 : ","8 ); |
2202 | 12 | OS << "omp_all_memory"; |
2203 | 12 | } |
2204 | 849 | OS << ")"; |
2205 | 849 | } |
2206 | | |
2207 | | template <typename T> |
2208 | | static void PrintMapper(raw_ostream &OS, T *Node, |
2209 | 128 | const PrintingPolicy &Policy) { |
2210 | 128 | OS << '('; |
2211 | 128 | NestedNameSpecifier *MapperNNS = |
2212 | 128 | Node->getMapperQualifierLoc().getNestedNameSpecifier(); |
2213 | 128 | if (MapperNNS) |
2214 | 28 | MapperNNS->print(OS, Policy); |
2215 | 128 | OS << Node->getMapperIdInfo() << ')'; |
2216 | 128 | } OpenMPClause.cpp:void PrintMapper<clang::OMPMapClause>(llvm::raw_ostream&, clang::OMPMapClause*, clang::PrintingPolicy const&) Line | Count | Source | 2209 | 48 | const PrintingPolicy &Policy) { | 2210 | 48 | OS << '('; | 2211 | 48 | NestedNameSpecifier *MapperNNS = | 2212 | 48 | Node->getMapperQualifierLoc().getNestedNameSpecifier(); | 2213 | 48 | if (MapperNNS) | 2214 | 12 | MapperNNS->print(OS, Policy); | 2215 | 48 | OS << Node->getMapperIdInfo() << ')'; | 2216 | 48 | } |
OpenMPClause.cpp:void PrintMapper<clang::OMPToClause>(llvm::raw_ostream&, clang::OMPToClause*, clang::PrintingPolicy const&) Line | Count | Source | 2209 | 40 | const PrintingPolicy &Policy) { | 2210 | 40 | OS << '('; | 2211 | 40 | NestedNameSpecifier *MapperNNS = | 2212 | 40 | Node->getMapperQualifierLoc().getNestedNameSpecifier(); | 2213 | 40 | if (MapperNNS) | 2214 | 8 | MapperNNS->print(OS, Policy); | 2215 | 40 | OS << Node->getMapperIdInfo() << ')'; | 2216 | 40 | } |
OpenMPClause.cpp:void PrintMapper<clang::OMPFromClause>(llvm::raw_ostream&, clang::OMPFromClause*, clang::PrintingPolicy const&) Line | Count | Source | 2209 | 40 | const PrintingPolicy &Policy) { | 2210 | 40 | OS << '('; | 2211 | 40 | NestedNameSpecifier *MapperNNS = | 2212 | 40 | Node->getMapperQualifierLoc().getNestedNameSpecifier(); | 2213 | 40 | if (MapperNNS) | 2214 | 8 | MapperNNS->print(OS, Policy); | 2215 | 40 | OS << Node->getMapperIdInfo() << ')'; | 2216 | 40 | } |
|
2217 | | |
2218 | 3.71k | void OMPClausePrinter::VisitOMPMapClause(OMPMapClause *Node) { |
2219 | 3.71k | if (!Node->varlist_empty()) { |
2220 | 3.71k | OS << "map("; |
2221 | 3.71k | if (Node->getMapType() != OMPC_MAP_unknown) { |
2222 | 22.3k | for (unsigned I = 0; I < NumberOfOMPMapClauseModifiers; ++I18.5k ) { |
2223 | 18.5k | if (Node->getMapTypeModifier(I) != OMPC_MAP_MODIFIER_unknown) { |
2224 | 768 | OS << getOpenMPSimpleClauseTypeName(OMPC_map, |
2225 | 768 | Node->getMapTypeModifier(I)); |
2226 | 768 | if (Node->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_mapper) |
2227 | 48 | PrintMapper(OS, Node, Policy); |
2228 | 768 | OS << ','; |
2229 | 768 | } |
2230 | 18.5k | } |
2231 | 3.71k | OS << getOpenMPSimpleClauseTypeName(OMPC_map, Node->getMapType()); |
2232 | 3.71k | OS << ':'; |
2233 | 3.71k | } |
2234 | 3.71k | VisitOMPClauseList(Node, ' '); |
2235 | 3.71k | OS << ")"; |
2236 | 3.71k | } |
2237 | 3.71k | } |
2238 | | |
2239 | 705 | template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) { |
2240 | 705 | if (Node->varlist_empty()) |
2241 | 0 | return; |
2242 | 705 | OS << getOpenMPClauseName(Node->getClauseKind()); |
2243 | 705 | unsigned ModifierCount = 0; |
2244 | 2.11k | for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I1.41k ) { |
2245 | 1.41k | if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) |
2246 | 124 | ++ModifierCount; |
2247 | 1.41k | } |
2248 | 705 | if (ModifierCount) { |
2249 | 108 | OS << '('; |
2250 | 324 | for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I216 ) { |
2251 | 216 | if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) { |
2252 | 124 | OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), |
2253 | 124 | Node->getMotionModifier(I)); |
2254 | 124 | if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper) |
2255 | 80 | PrintMapper(OS, Node, Policy); |
2256 | 124 | if (I < ModifierCount - 1) |
2257 | 16 | OS << ", "; |
2258 | 124 | } |
2259 | 216 | } |
2260 | 108 | OS << ':'; |
2261 | 108 | VisitOMPClauseList(Node, ' '); |
2262 | 597 | } else { |
2263 | 597 | VisitOMPClauseList(Node, '('); |
2264 | 597 | } |
2265 | 705 | OS << ")"; |
2266 | 705 | } void clang::OMPClausePrinter::VisitOMPMotionClause<clang::OMPToClause>(clang::OMPToClause*) Line | Count | Source | 2239 | 353 | template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) { | 2240 | 353 | if (Node->varlist_empty()) | 2241 | 0 | return; | 2242 | 353 | OS << getOpenMPClauseName(Node->getClauseKind()); | 2243 | 353 | unsigned ModifierCount = 0; | 2244 | 1.05k | for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I706 ) { | 2245 | 706 | if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) | 2246 | 64 | ++ModifierCount; | 2247 | 706 | } | 2248 | 353 | if (ModifierCount) { | 2249 | 56 | OS << '('; | 2250 | 168 | for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I112 ) { | 2251 | 112 | if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) { | 2252 | 64 | OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), | 2253 | 64 | Node->getMotionModifier(I)); | 2254 | 64 | if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper) | 2255 | 40 | PrintMapper(OS, Node, Policy); | 2256 | 64 | if (I < ModifierCount - 1) | 2257 | 8 | OS << ", "; | 2258 | 64 | } | 2259 | 112 | } | 2260 | 56 | OS << ':'; | 2261 | 56 | VisitOMPClauseList(Node, ' '); | 2262 | 297 | } else { | 2263 | 297 | VisitOMPClauseList(Node, '('); | 2264 | 297 | } | 2265 | 353 | OS << ")"; | 2266 | 353 | } |
void clang::OMPClausePrinter::VisitOMPMotionClause<clang::OMPFromClause>(clang::OMPFromClause*) Line | Count | Source | 2239 | 352 | template <typename T> void OMPClausePrinter::VisitOMPMotionClause(T *Node) { | 2240 | 352 | if (Node->varlist_empty()) | 2241 | 0 | return; | 2242 | 352 | OS << getOpenMPClauseName(Node->getClauseKind()); | 2243 | 352 | unsigned ModifierCount = 0; | 2244 | 1.05k | for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I704 ) { | 2245 | 704 | if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) | 2246 | 60 | ++ModifierCount; | 2247 | 704 | } | 2248 | 352 | if (ModifierCount) { | 2249 | 52 | OS << '('; | 2250 | 156 | for (unsigned I = 0; I < NumberOfOMPMotionModifiers; ++I104 ) { | 2251 | 104 | if (Node->getMotionModifier(I) != OMPC_MOTION_MODIFIER_unknown) { | 2252 | 60 | OS << getOpenMPSimpleClauseTypeName(Node->getClauseKind(), | 2253 | 60 | Node->getMotionModifier(I)); | 2254 | 60 | if (Node->getMotionModifier(I) == OMPC_MOTION_MODIFIER_mapper) | 2255 | 40 | PrintMapper(OS, Node, Policy); | 2256 | 60 | if (I < ModifierCount - 1) | 2257 | 8 | OS << ", "; | 2258 | 60 | } | 2259 | 104 | } | 2260 | 52 | OS << ':'; | 2261 | 52 | VisitOMPClauseList(Node, ' '); | 2262 | 300 | } else { | 2263 | 300 | VisitOMPClauseList(Node, '('); | 2264 | 300 | } | 2265 | 352 | OS << ")"; | 2266 | 352 | } |
|
2267 | | |
2268 | 353 | void OMPClausePrinter::VisitOMPToClause(OMPToClause *Node) { |
2269 | 353 | VisitOMPMotionClause(Node); |
2270 | 353 | } |
2271 | | |
2272 | 352 | void OMPClausePrinter::VisitOMPFromClause(OMPFromClause *Node) { |
2273 | 352 | VisitOMPMotionClause(Node); |
2274 | 352 | } |
2275 | | |
2276 | 272 | void OMPClausePrinter::VisitOMPDistScheduleClause(OMPDistScheduleClause *Node) { |
2277 | 272 | OS << "dist_schedule(" << getOpenMPSimpleClauseTypeName( |
2278 | 272 | OMPC_dist_schedule, Node->getDistScheduleKind()); |
2279 | 272 | if (auto *E = Node->getChunkSize()) { |
2280 | 272 | OS << ", "; |
2281 | 272 | E->printPretty(OS, nullptr, Policy); |
2282 | 272 | } |
2283 | 272 | OS << ")"; |
2284 | 272 | } |
2285 | | |
2286 | 1.40k | void OMPClausePrinter::VisitOMPDefaultmapClause(OMPDefaultmapClause *Node) { |
2287 | 1.40k | OS << "defaultmap("; |
2288 | 1.40k | OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap, |
2289 | 1.40k | Node->getDefaultmapModifier()); |
2290 | 1.40k | if (Node->getDefaultmapKind() != OMPC_DEFAULTMAP_unknown) { |
2291 | 1.39k | OS << ": "; |
2292 | 1.39k | OS << getOpenMPSimpleClauseTypeName(OMPC_defaultmap, |
2293 | 1.39k | Node->getDefaultmapKind()); |
2294 | 1.39k | } |
2295 | 1.40k | OS << ")"; |
2296 | 1.40k | } |
2297 | | |
2298 | 40 | void OMPClausePrinter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *Node) { |
2299 | 40 | if (!Node->varlist_empty()) { |
2300 | 40 | OS << "use_device_ptr"; |
2301 | 40 | VisitOMPClauseList(Node, '('); |
2302 | 40 | OS << ")"; |
2303 | 40 | } |
2304 | 40 | } |
2305 | | |
2306 | | void OMPClausePrinter::VisitOMPUseDeviceAddrClause( |
2307 | 16 | OMPUseDeviceAddrClause *Node) { |
2308 | 16 | if (!Node->varlist_empty()) { |
2309 | 16 | OS << "use_device_addr"; |
2310 | 16 | VisitOMPClauseList(Node, '('); |
2311 | 16 | OS << ")"; |
2312 | 16 | } |
2313 | 16 | } |
2314 | | |
2315 | 1.17k | void OMPClausePrinter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *Node) { |
2316 | 1.17k | if (!Node->varlist_empty()) { |
2317 | 1.17k | OS << "is_device_ptr"; |
2318 | 1.17k | VisitOMPClauseList(Node, '('); |
2319 | 1.17k | OS << ")"; |
2320 | 1.17k | } |
2321 | 1.17k | } |
2322 | | |
2323 | 157 | void OMPClausePrinter::VisitOMPHasDeviceAddrClause(OMPHasDeviceAddrClause *Node) { |
2324 | 157 | if (!Node->varlist_empty()) { |
2325 | 157 | OS << "has_device_addr"; |
2326 | 157 | VisitOMPClauseList(Node, '('); |
2327 | 157 | OS << ")"; |
2328 | 157 | } |
2329 | 157 | } |
2330 | | |
2331 | 84 | void OMPClausePrinter::VisitOMPNontemporalClause(OMPNontemporalClause *Node) { |
2332 | 84 | if (!Node->varlist_empty()) { |
2333 | 84 | OS << "nontemporal"; |
2334 | 84 | VisitOMPClauseList(Node, '('); |
2335 | 84 | OS << ")"; |
2336 | 84 | } |
2337 | 84 | } |
2338 | | |
2339 | 138 | void OMPClausePrinter::VisitOMPOrderClause(OMPOrderClause *Node) { |
2340 | 138 | OS << "order(" << getOpenMPSimpleClauseTypeName(OMPC_order, Node->getKind()) |
2341 | 138 | << ")"; |
2342 | 138 | } |
2343 | | |
2344 | 12 | void OMPClausePrinter::VisitOMPInclusiveClause(OMPInclusiveClause *Node) { |
2345 | 12 | if (!Node->varlist_empty()) { |
2346 | 12 | OS << "inclusive"; |
2347 | 12 | VisitOMPClauseList(Node, '('); |
2348 | 12 | OS << ")"; |
2349 | 12 | } |
2350 | 12 | } |
2351 | | |
2352 | 4 | void OMPClausePrinter::VisitOMPExclusiveClause(OMPExclusiveClause *Node) { |
2353 | 4 | if (!Node->varlist_empty()) { |
2354 | 4 | OS << "exclusive"; |
2355 | 4 | VisitOMPClauseList(Node, '('); |
2356 | 4 | OS << ")"; |
2357 | 4 | } |
2358 | 4 | } |
2359 | | |
2360 | | void OMPClausePrinter::VisitOMPUsesAllocatorsClause( |
2361 | 76 | OMPUsesAllocatorsClause *Node) { |
2362 | 76 | if (Node->getNumberOfAllocators() == 0) |
2363 | 0 | return; |
2364 | 76 | OS << "uses_allocators("; |
2365 | 160 | for (unsigned I = 0, E = Node->getNumberOfAllocators(); I < E; ++I84 ) { |
2366 | 84 | OMPUsesAllocatorsClause::Data Data = Node->getAllocatorData(I); |
2367 | 84 | Data.Allocator->printPretty(OS, nullptr, Policy); |
2368 | 84 | if (Data.AllocatorTraits) { |
2369 | 12 | OS << "("; |
2370 | 12 | Data.AllocatorTraits->printPretty(OS, nullptr, Policy); |
2371 | 12 | OS << ")"; |
2372 | 12 | } |
2373 | 84 | if (I < E - 1) |
2374 | 8 | OS << ","; |
2375 | 84 | } |
2376 | 76 | OS << ")"; |
2377 | 76 | } |
2378 | | |
2379 | 20 | void OMPClausePrinter::VisitOMPAffinityClause(OMPAffinityClause *Node) { |
2380 | 20 | if (Node->varlist_empty()) |
2381 | 0 | return; |
2382 | 20 | OS << "affinity"; |
2383 | 20 | char StartSym = '('; |
2384 | 20 | if (Expr *Modifier = Node->getModifier()) { |
2385 | 8 | OS << "("; |
2386 | 8 | Modifier->printPretty(OS, nullptr, Policy); |
2387 | 8 | OS << " :"; |
2388 | 8 | StartSym = ' '; |
2389 | 8 | } |
2390 | 20 | VisitOMPClauseList(Node, StartSym); |
2391 | 20 | OS << ")"; |
2392 | 20 | } |
2393 | | |
2394 | 104 | void OMPClausePrinter::VisitOMPFilterClause(OMPFilterClause *Node) { |
2395 | 104 | OS << "filter("; |
2396 | 104 | Node->getThreadID()->printPretty(OS, nullptr, Policy, 0); |
2397 | 104 | OS << ")"; |
2398 | 104 | } |
2399 | | |
2400 | 50 | void OMPClausePrinter::VisitOMPBindClause(OMPBindClause *Node) { |
2401 | 50 | OS << "bind(" |
2402 | 50 | << getOpenMPSimpleClauseTypeName(OMPC_bind, unsigned(Node->getBindKind())) |
2403 | 50 | << ")"; |
2404 | 50 | } |
2405 | | |
2406 | | void OMPTraitInfo::getAsVariantMatchInfo(ASTContext &ASTCtx, |
2407 | 3.54k | VariantMatchInfo &VMI) const { |
2408 | 4.75k | for (const OMPTraitSet &Set : Sets) { |
2409 | 5.03k | for (const OMPTraitSelector &Selector : Set.Selectors) { |
2410 | | |
2411 | | // User conditions are special as we evaluate the condition here. |
2412 | 5.03k | if (Selector.Kind == TraitSelector::user_condition) { |
2413 | 52 | assert(Selector.ScoreOrCondition && |
2414 | 52 | "Ill-formed user condition, expected condition expression!"); |
2415 | 0 | assert(Selector.Properties.size() == 1 && |
2416 | 52 | Selector.Properties.front().Kind == |
2417 | 52 | TraitProperty::user_condition_unknown && |
2418 | 52 | "Ill-formed user condition, expected unknown trait property!"); |
2419 | | |
2420 | 52 | if (Optional<APSInt> CondVal = |
2421 | 52 | Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx)) |
2422 | 48 | VMI.addTrait(CondVal->isZero() ? TraitProperty::user_condition_false6 |
2423 | 48 | : TraitProperty::user_condition_true42 , |
2424 | 48 | "<condition>"); |
2425 | 4 | else |
2426 | 4 | VMI.addTrait(TraitProperty::user_condition_false, "<condition>"); |
2427 | 52 | continue; |
2428 | 52 | } |
2429 | | |
2430 | 4.98k | Optional<llvm::APSInt> Score; |
2431 | 4.98k | llvm::APInt *ScorePtr = nullptr; |
2432 | 4.98k | if (Selector.ScoreOrCondition) { |
2433 | 121 | if ((Score = Selector.ScoreOrCondition->getIntegerConstantExpr(ASTCtx))) |
2434 | 115 | ScorePtr = &*Score; |
2435 | 6 | else |
2436 | 6 | VMI.addTrait(TraitProperty::user_condition_false, |
2437 | 6 | "<non-constant-score>"); |
2438 | 121 | } |
2439 | | |
2440 | 4.98k | for (const OMPTraitProperty &Property : Selector.Properties) |
2441 | 6.47k | VMI.addTrait(Set.Kind, Property.Kind, Property.RawString, ScorePtr); |
2442 | | |
2443 | 4.98k | if (Set.Kind != TraitSet::construct) |
2444 | 4.25k | continue; |
2445 | | |
2446 | | // TODO: This might not hold once we implement SIMD properly. |
2447 | 733 | assert(Selector.Properties.size() == 1 && |
2448 | 733 | Selector.Properties.front().Kind == |
2449 | 733 | getOpenMPContextTraitPropertyForSelector( |
2450 | 733 | Selector.Kind) && |
2451 | 733 | "Ill-formed construct selector!"); |
2452 | 733 | } |
2453 | 4.75k | } |
2454 | 3.54k | } |
2455 | | |
2456 | | void OMPTraitInfo::print(llvm::raw_ostream &OS, |
2457 | 770 | const PrintingPolicy &Policy) const { |
2458 | 770 | bool FirstSet = true; |
2459 | 954 | for (const OMPTraitSet &Set : Sets) { |
2460 | 954 | if (!FirstSet) |
2461 | 184 | OS << ", "; |
2462 | 954 | FirstSet = false; |
2463 | 954 | OS << getOpenMPContextTraitSetName(Set.Kind) << "={"; |
2464 | | |
2465 | 954 | bool FirstSelector = true; |
2466 | 1.00k | for (const OMPTraitSelector &Selector : Set.Selectors) { |
2467 | 1.00k | if (!FirstSelector) |
2468 | 52 | OS << ", "; |
2469 | 1.00k | FirstSelector = false; |
2470 | 1.00k | OS << getOpenMPContextTraitSelectorName(Selector.Kind); |
2471 | | |
2472 | 1.00k | bool AllowsTraitScore = false; |
2473 | 1.00k | bool RequiresProperty = false; |
2474 | 1.00k | isValidTraitSelectorForTraitSet( |
2475 | 1.00k | Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty); |
2476 | | |
2477 | 1.00k | if (!RequiresProperty) |
2478 | 126 | continue; |
2479 | | |
2480 | 880 | OS << "("; |
2481 | 880 | if (Selector.Kind == TraitSelector::user_condition) { |
2482 | 56 | if (Selector.ScoreOrCondition) |
2483 | 28 | Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy); |
2484 | 28 | else |
2485 | 28 | OS << "..."; |
2486 | 824 | } else { |
2487 | | |
2488 | 824 | if (Selector.ScoreOrCondition) { |
2489 | 55 | OS << "score("; |
2490 | 55 | Selector.ScoreOrCondition->printPretty(OS, nullptr, Policy); |
2491 | 55 | OS << "): "; |
2492 | 55 | } |
2493 | | |
2494 | 824 | bool FirstProperty = true; |
2495 | 928 | for (const OMPTraitProperty &Property : Selector.Properties) { |
2496 | 928 | if (!FirstProperty) |
2497 | 104 | OS << ", "; |
2498 | 928 | FirstProperty = false; |
2499 | 928 | OS << getOpenMPContextTraitPropertyName(Property.Kind, |
2500 | 928 | Property.RawString); |
2501 | 928 | } |
2502 | 824 | } |
2503 | 880 | OS << ")"; |
2504 | 880 | } |
2505 | 954 | OS << "}"; |
2506 | 954 | } |
2507 | 770 | } |
2508 | | |
2509 | 247 | std::string OMPTraitInfo::getMangledName() const { |
2510 | 247 | std::string MangledName; |
2511 | 247 | llvm::raw_string_ostream OS(MangledName); |
2512 | 255 | for (const OMPTraitSet &Set : Sets) { |
2513 | 255 | OS << '$' << 'S' << unsigned(Set.Kind); |
2514 | 271 | for (const OMPTraitSelector &Selector : Set.Selectors) { |
2515 | | |
2516 | 271 | bool AllowsTraitScore = false; |
2517 | 271 | bool RequiresProperty = false; |
2518 | 271 | isValidTraitSelectorForTraitSet( |
2519 | 271 | Selector.Kind, Set.Kind, AllowsTraitScore, RequiresProperty); |
2520 | 271 | OS << '$' << 's' << unsigned(Selector.Kind); |
2521 | | |
2522 | 271 | if (!RequiresProperty || |
2523 | 271 | Selector.Kind == TraitSelector::user_condition269 ) |
2524 | 17 | continue; |
2525 | | |
2526 | 254 | for (const OMPTraitProperty &Property : Selector.Properties) |
2527 | 317 | OS << '$' << 'P' |
2528 | 317 | << getOpenMPContextTraitPropertyName(Property.Kind, |
2529 | 317 | Property.RawString); |
2530 | 254 | } |
2531 | 255 | } |
2532 | 247 | return MangledName; |
2533 | 247 | } |
2534 | | |
2535 | 400 | OMPTraitInfo::OMPTraitInfo(StringRef MangledName) { |
2536 | 400 | unsigned long U; |
2537 | 840 | do { |
2538 | 840 | if (!MangledName.consume_front("$S")) |
2539 | 400 | break; |
2540 | 440 | if (MangledName.consumeInteger(10, U)) |
2541 | 0 | break; |
2542 | 440 | Sets.push_back(OMPTraitSet()); |
2543 | 440 | OMPTraitSet &Set = Sets.back(); |
2544 | 440 | Set.Kind = TraitSet(U); |
2545 | 908 | do { |
2546 | 908 | if (!MangledName.consume_front("$s")) |
2547 | 440 | break; |
2548 | 468 | if (MangledName.consumeInteger(10, U)) |
2549 | 0 | break; |
2550 | 468 | Set.Selectors.push_back(OMPTraitSelector()); |
2551 | 468 | OMPTraitSelector &Selector = Set.Selectors.back(); |
2552 | 468 | Selector.Kind = TraitSelector(U); |
2553 | 934 | do { |
2554 | 934 | if (!MangledName.consume_front("$P")) |
2555 | 468 | break; |
2556 | 466 | Selector.Properties.push_back(OMPTraitProperty()); |
2557 | 466 | OMPTraitProperty &Property = Selector.Properties.back(); |
2558 | 466 | std::pair<StringRef, StringRef> PropRestPair = MangledName.split('$'); |
2559 | 466 | Property.RawString = PropRestPair.first; |
2560 | 466 | Property.Kind = getOpenMPContextTraitPropertyKind( |
2561 | 466 | Set.Kind, Selector.Kind, PropRestPair.first); |
2562 | 466 | MangledName = MangledName.drop_front(PropRestPair.first.size()); |
2563 | 466 | } while (true); |
2564 | 468 | } while (true); |
2565 | 440 | } while (true); |
2566 | 400 | } |
2567 | | |
2568 | | llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS, |
2569 | 770 | const OMPTraitInfo &TI) { |
2570 | 770 | LangOptions LO; |
2571 | 770 | PrintingPolicy Policy(LO); |
2572 | 770 | TI.print(OS, Policy); |
2573 | 770 | return OS; |
2574 | 770 | } |
2575 | | llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS, |
2576 | 370 | const OMPTraitInfo *TI) { |
2577 | 370 | return TI ? OS << *TI : OS0 ; |
2578 | 370 | } |
2579 | | |
2580 | | TargetOMPContext::TargetOMPContext( |
2581 | | ASTContext &ASTCtx, std::function<void(StringRef)> &&DiagUnknownTrait, |
2582 | | const FunctionDecl *CurrentFunctionDecl, |
2583 | | ArrayRef<llvm::omp::TraitProperty> ConstructTraits) |
2584 | | : OMPContext(ASTCtx.getLangOpts().OpenMPIsDevice, |
2585 | | ASTCtx.getTargetInfo().getTriple()), |
2586 | 17 | FeatureValidityCheck([&](StringRef FeatureName) { |
2587 | 17 | return ASTCtx.getTargetInfo().isValidFeatureName(FeatureName); |
2588 | 17 | }), |
2589 | 2.91k | DiagUnknownTrait(std::move(DiagUnknownTrait)) { |
2590 | 2.91k | ASTCtx.getFunctionFeatureMap(FeatureMap, CurrentFunctionDecl); |
2591 | | |
2592 | 2.91k | for (llvm::omp::TraitProperty Property : ConstructTraits) |
2593 | 438 | addTrait(Property); |
2594 | 2.91k | } |
2595 | | |
2596 | 48 | bool TargetOMPContext::matchesISATrait(StringRef RawString) const { |
2597 | 48 | auto It = FeatureMap.find(RawString); |
2598 | 48 | if (It != FeatureMap.end()) |
2599 | 31 | return It->second; |
2600 | 17 | if (!FeatureValidityCheck(RawString)) |
2601 | 11 | DiagUnknownTrait(RawString); |
2602 | 17 | return false; |
2603 | 48 | } |