Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===- OpenMPClause.h - Classes for OpenMP clauses --------------*- C++ -*-===// |
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 | /// \file |
||
10 | /// This file defines OpenMP AST classes for clauses. |
||
11 | /// There are clauses for executable directives, clauses for declarative |
||
12 | /// directives and clauses which can be used in both kinds of directives. |
||
13 | // |
||
14 | //===----------------------------------------------------------------------===// |
||
15 | |||
16 | #ifndef LLVM_CLANG_AST_OPENMPCLAUSE_H |
||
17 | #define LLVM_CLANG_AST_OPENMPCLAUSE_H |
||
18 | |||
19 | #include "clang/AST/ASTFwd.h" |
||
20 | #include "clang/AST/Decl.h" |
||
21 | #include "clang/AST/DeclarationName.h" |
||
22 | #include "clang/AST/Expr.h" |
||
23 | #include "clang/AST/NestedNameSpecifier.h" |
||
24 | #include "clang/AST/Stmt.h" |
||
25 | #include "clang/AST/StmtIterator.h" |
||
26 | #include "clang/Basic/LLVM.h" |
||
27 | #include "clang/Basic/OpenMPKinds.h" |
||
28 | #include "clang/Basic/SourceLocation.h" |
||
29 | #include "llvm/ADT/ArrayRef.h" |
||
30 | #include "llvm/ADT/MapVector.h" |
||
31 | #include "llvm/ADT/PointerIntPair.h" |
||
32 | #include "llvm/ADT/SmallVector.h" |
||
33 | #include "llvm/ADT/iterator.h" |
||
34 | #include "llvm/ADT/iterator_range.h" |
||
35 | #include "llvm/Frontend/OpenMP/OMPAssume.h" |
||
36 | #include "llvm/Frontend/OpenMP/OMPConstants.h" |
||
37 | #include "llvm/Frontend/OpenMP/OMPContext.h" |
||
38 | #include "llvm/Support/Casting.h" |
||
39 | #include "llvm/Support/Compiler.h" |
||
40 | #include "llvm/Support/TrailingObjects.h" |
||
41 | #include <cassert> |
||
42 | #include <cstddef> |
||
43 | #include <iterator> |
||
44 | #include <utility> |
||
45 | |||
46 | namespace clang { |
||
47 | |||
48 | class ASTContext; |
||
49 | |||
50 | //===----------------------------------------------------------------------===// |
||
51 | // AST classes for clauses. |
||
52 | //===----------------------------------------------------------------------===// |
||
53 | |||
54 | /// This is a basic class for representing single OpenMP clause. |
||
55 | class OMPClause { |
||
56 | /// Starting location of the clause (the clause keyword). |
||
57 | SourceLocation StartLoc; |
||
58 | |||
59 | /// Ending location of the clause. |
||
60 | SourceLocation EndLoc; |
||
61 | |||
62 | /// Kind of the clause. |
||
63 | OpenMPClauseKind Kind; |
||
64 | |||
65 | protected: |
||
66 | OMPClause(OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation EndLoc) |
||
67 | : StartLoc(StartLoc), EndLoc(EndLoc), Kind(K) {} |
||
68 | |||
69 | public: |
||
70 | /// Returns the starting location of the clause. |
||
71 | SourceLocation getBeginLoc() const { return StartLoc; } |
||
72 | |||
73 | /// Returns the ending location of the clause. |
||
74 | SourceLocation getEndLoc() const { return EndLoc; } |
||
75 | |||
76 | /// Sets the starting location of the clause. |
||
77 | void setLocStart(SourceLocation Loc) { StartLoc = Loc; } |
||
78 | |||
79 | /// Sets the ending location of the clause. |
||
80 | void setLocEnd(SourceLocation Loc) { EndLoc = Loc; } |
||
81 | |||
82 | /// Returns kind of OpenMP clause (private, shared, reduction, etc.). |
||
83 | OpenMPClauseKind getClauseKind() const { return Kind; } |
||
84 | |||
85 | bool isImplicit() const { return StartLoc.isInvalid(); } |
||
86 | |||
87 | using child_iterator = StmtIterator; |
||
88 | using const_child_iterator = ConstStmtIterator; |
||
89 | using child_range = llvm::iterator_range<child_iterator>; |
||
90 | using const_child_range = llvm::iterator_range<const_child_iterator>; |
||
91 | |||
92 | child_range children(); |
||
93 | const_child_range children() const { |
||
94 | auto Children = const_cast<OMPClause *>(this)->children(); |
||
95 | return const_child_range(Children.begin(), Children.end()); |
||
96 | } |
||
97 | |||
98 | /// Get the iterator range for the expressions used in the clauses. Used |
||
99 | /// expressions include only the children that must be evaluated at the |
||
100 | /// runtime before entering the construct. |
||
101 | child_range used_children(); |
||
102 | const_child_range used_children() const { |
||
103 | auto Children = const_cast<OMPClause *>(this)->children(); |
||
104 | return const_child_range(Children.begin(), Children.end()); |
||
105 | } |
||
106 | |||
107 | static bool classof(const OMPClause *) { return true; } |
||
108 | }; |
||
109 | |||
110 | template <OpenMPClauseKind ClauseKind> |
||
111 | struct OMPNoChildClause : public OMPClause { |
||
112 | /// Build '\p ClauseKind' clause. |
||
113 | /// |
||
114 | /// \param StartLoc Starting location of the clause. |
||
115 | /// \param EndLoc Ending location of the clause. |
||
116 | OMPNoChildClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
117 | : OMPClause(ClauseKind, StartLoc, EndLoc) {} |
||
118 | |||
119 | /// Build an empty clause. |
||
120 | OMPNoChildClause() |
||
121 | : OMPClause(ClauseKind, SourceLocation(), SourceLocation()) {} |
||
122 | |||
123 | child_range children() { |
||
124 | return child_range(child_iterator(), child_iterator()); |
||
125 | } |
||
126 | |||
127 | const_child_range children() const { |
||
128 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
129 | } |
||
130 | |||
131 | child_range used_children() { |
||
132 | return child_range(child_iterator(), child_iterator()); |
||
133 | } |
||
134 | const_child_range used_children() const { |
||
135 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
136 | } |
||
137 | |||
138 | static bool classof(const OMPClause *T) { |
||
139 | return T->getClauseKind() == ClauseKind; |
||
140 | } |
||
141 | }; |
||
142 | |||
143 | template <OpenMPClauseKind ClauseKind, class Base> |
||
144 | class OMPOneStmtClause : public Base { |
||
145 | |||
146 | /// Location of '('. |
||
147 | SourceLocation LParenLoc; |
||
148 | |||
149 | /// Sub-expression. |
||
150 | Stmt *S = nullptr; |
||
151 | |||
152 | protected: |
||
153 | void setStmt(Stmt *S) { this->S = S; } |
||
154 | |||
155 | public: |
||
156 | OMPOneStmtClause(Stmt *S, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
157 | SourceLocation EndLoc) |
||
158 | : Base(ClauseKind, StartLoc, EndLoc), LParenLoc(LParenLoc), S(S) {} |
||
159 | |||
160 | OMPOneStmtClause() : Base(ClauseKind, SourceLocation(), SourceLocation()) {} |
||
161 | |||
162 | /// Return the associated statement, potentially casted to \p T. |
||
163 | template <typename T> T *getStmtAs() const { return cast_or_null<T>(S); } |
||
164 | |||
165 | /// Sets the location of '('. |
||
166 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
167 | |||
168 | /// Returns the location of '('. |
||
169 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
170 | |||
171 | using child_iterator = StmtIterator; |
||
172 | using const_child_iterator = ConstStmtIterator; |
||
173 | using child_range = llvm::iterator_range<child_iterator>; |
||
174 | using const_child_range = llvm::iterator_range<const_child_iterator>; |
||
175 | |||
176 | child_range children() { return child_range(&S, &S + 1); } |
||
177 | |||
178 | const_child_range children() const { return const_child_range(&S, &S + 1); } |
||
179 | |||
180 | // TODO: Consider making the getAddrOfExprAsWritten version the default. |
||
181 | child_range used_children() { |
||
182 | return child_range(child_iterator(), child_iterator()); |
||
183 | } |
||
184 | const_child_range used_children() const { |
||
185 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
186 | } |
||
187 | |||
188 | static bool classof(const OMPClause *T) { |
||
189 | return T->getClauseKind() == ClauseKind; |
||
190 | } |
||
191 | }; |
||
192 | |||
193 | /// Class that handles pre-initialization statement for some clauses, like |
||
194 | /// 'shedule', 'firstprivate' etc. |
||
195 | class OMPClauseWithPreInit { |
||
196 | friend class OMPClauseReader; |
||
197 | |||
198 | /// Pre-initialization statement for the clause. |
||
199 | Stmt *PreInit = nullptr; |
||
200 | |||
201 | /// Region that captures the associated stmt. |
||
202 | OpenMPDirectiveKind CaptureRegion = llvm::omp::OMPD_unknown; |
||
203 | |||
204 | protected: |
||
205 | OMPClauseWithPreInit(const OMPClause *This) { |
||
206 | assert(get(This) && "get is not tuned for pre-init."); |
||
207 | } |
||
208 | |||
209 | /// Set pre-initialization statement for the clause. |
||
210 | void |
||
211 | setPreInitStmt(Stmt *S, |
||
212 | OpenMPDirectiveKind ThisRegion = llvm::omp::OMPD_unknown) { |
||
213 | PreInit = S; |
||
214 | CaptureRegion = ThisRegion; |
||
215 | } |
||
216 | |||
217 | public: |
||
218 | /// Get pre-initialization statement for the clause. |
||
219 | const Stmt *getPreInitStmt() const { return PreInit; } |
||
220 | |||
221 | /// Get pre-initialization statement for the clause. |
||
222 | Stmt *getPreInitStmt() { return PreInit; } |
||
223 | |||
224 | /// Get capture region for the stmt in the clause. |
||
225 | OpenMPDirectiveKind getCaptureRegion() const { return CaptureRegion; } |
||
226 | |||
227 | static OMPClauseWithPreInit *get(OMPClause *C); |
||
228 | static const OMPClauseWithPreInit *get(const OMPClause *C); |
||
229 | }; |
||
230 | |||
231 | /// Class that handles post-update expression for some clauses, like |
||
232 | /// 'lastprivate', 'reduction' etc. |
||
233 | class OMPClauseWithPostUpdate : public OMPClauseWithPreInit { |
||
234 | friend class OMPClauseReader; |
||
235 | |||
236 | /// Post-update expression for the clause. |
||
237 | Expr *PostUpdate = nullptr; |
||
238 | |||
239 | protected: |
||
240 | OMPClauseWithPostUpdate(const OMPClause *This) : OMPClauseWithPreInit(This) { |
||
241 | assert(get(This) && "get is not tuned for post-update."); |
||
242 | } |
||
243 | |||
244 | /// Set pre-initialization statement for the clause. |
||
245 | void setPostUpdateExpr(Expr *S) { PostUpdate = S; } |
||
246 | |||
247 | public: |
||
248 | /// Get post-update expression for the clause. |
||
249 | const Expr *getPostUpdateExpr() const { return PostUpdate; } |
||
250 | |||
251 | /// Get post-update expression for the clause. |
||
252 | Expr *getPostUpdateExpr() { return PostUpdate; } |
||
253 | |||
254 | static OMPClauseWithPostUpdate *get(OMPClause *C); |
||
255 | static const OMPClauseWithPostUpdate *get(const OMPClause *C); |
||
256 | }; |
||
257 | |||
258 | /// This structure contains most locations needed for by an OMPVarListClause. |
||
259 | struct OMPVarListLocTy { |
||
260 | /// Starting location of the clause (the clause keyword). |
||
261 | SourceLocation StartLoc; |
||
262 | /// Location of '('. |
||
263 | SourceLocation LParenLoc; |
||
264 | /// Ending location of the clause. |
||
265 | SourceLocation EndLoc; |
||
266 | OMPVarListLocTy() = default; |
||
267 | OMPVarListLocTy(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
268 | SourceLocation EndLoc) |
||
269 | : StartLoc(StartLoc), LParenLoc(LParenLoc), EndLoc(EndLoc) {} |
||
270 | }; |
||
271 | |||
272 | /// This represents clauses with the list of variables like 'private', |
||
273 | /// 'firstprivate', 'copyin', 'shared', or 'reduction' clauses in the |
||
274 | /// '#pragma omp ...' directives. |
||
275 | template <class T> class OMPVarListClause : public OMPClause { |
||
276 | friend class OMPClauseReader; |
||
277 | |||
278 | /// Location of '('. |
||
279 | SourceLocation LParenLoc; |
||
280 | |||
281 | /// Number of variables in the list. |
||
282 | unsigned NumVars; |
||
283 | |||
284 | protected: |
||
285 | /// Build a clause with \a N variables |
||
286 | /// |
||
287 | /// \param K Kind of the clause. |
||
288 | /// \param StartLoc Starting location of the clause (the clause keyword). |
||
289 | /// \param LParenLoc Location of '('. |
||
290 | /// \param EndLoc Ending location of the clause. |
||
291 | /// \param N Number of the variables in the clause. |
||
292 | OMPVarListClause(OpenMPClauseKind K, SourceLocation StartLoc, |
||
293 | SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N) |
||
294 | : OMPClause(K, StartLoc, EndLoc), LParenLoc(LParenLoc), NumVars(N) {} |
||
295 | |||
296 | /// Fetches list of variables associated with this clause. |
||
297 | MutableArrayRef<Expr *> getVarRefs() { |
||
298 | return MutableArrayRef<Expr *>( |
||
299 | static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars); |
||
300 | } |
||
301 | |||
302 | /// Sets the list of variables for this clause. |
||
303 | void setVarRefs(ArrayRef<Expr *> VL) { |
||
304 | assert(VL.size() == NumVars && |
||
305 | "Number of variables is not the same as the preallocated buffer"); |
||
306 | std::copy(VL.begin(), VL.end(), |
||
307 | static_cast<T *>(this)->template getTrailingObjects<Expr *>()); |
||
308 | } |
||
309 | |||
310 | public: |
||
311 | using varlist_iterator = MutableArrayRef<Expr *>::iterator; |
||
312 | using varlist_const_iterator = ArrayRef<const Expr *>::iterator; |
||
313 | using varlist_range = llvm::iterator_range<varlist_iterator>; |
||
314 | using varlist_const_range = llvm::iterator_range<varlist_const_iterator>; |
||
315 | |||
316 | unsigned varlist_size() const { return NumVars; } |
||
317 | bool varlist_empty() const { return NumVars == 0; } |
||
318 | |||
319 | varlist_range varlists() { |
||
320 | return varlist_range(varlist_begin(), varlist_end()); |
||
321 | } |
||
322 | varlist_const_range varlists() const { |
||
323 | return varlist_const_range(varlist_begin(), varlist_end()); |
||
324 | } |
||
325 | |||
326 | varlist_iterator varlist_begin() { return getVarRefs().begin(); } |
||
327 | varlist_iterator varlist_end() { return getVarRefs().end(); } |
||
328 | varlist_const_iterator varlist_begin() const { return getVarRefs().begin(); } |
||
329 | varlist_const_iterator varlist_end() const { return getVarRefs().end(); } |
||
330 | |||
331 | /// Sets the location of '('. |
||
332 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
333 | |||
334 | /// Returns the location of '('. |
||
335 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
336 | |||
337 | /// Fetches list of all variables in the clause. |
||
338 | ArrayRef<const Expr *> getVarRefs() const { |
||
339 | return llvm::ArrayRef( |
||
340 | static_cast<const T *>(this)->template getTrailingObjects<Expr *>(), |
||
341 | NumVars); |
||
342 | } |
||
343 | }; |
||
344 | |||
345 | /// This represents 'allocator' clause in the '#pragma omp ...' |
||
346 | /// directive. |
||
347 | /// |
||
348 | /// \code |
||
349 | /// #pragma omp allocate(a) allocator(omp_default_mem_alloc) |
||
350 | /// \endcode |
||
351 | /// In this example directive '#pragma omp allocate' has simple 'allocator' |
||
352 | /// clause with the allocator 'omp_default_mem_alloc'. |
||
353 | class OMPAllocatorClause final |
||
354 | : public OMPOneStmtClause<llvm::omp::OMPC_allocator, OMPClause> { |
||
355 | friend class OMPClauseReader; |
||
356 | |||
357 | /// Set allocator. |
||
358 | void setAllocator(Expr *A) { setStmt(A); } |
||
359 | |||
360 | public: |
||
361 | /// Build 'allocator' clause with the given allocator. |
||
362 | /// |
||
363 | /// \param A Allocator. |
||
364 | /// \param StartLoc Starting location of the clause. |
||
365 | /// \param LParenLoc Location of '('. |
||
366 | /// \param EndLoc Ending location of the clause. |
||
367 | OMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
368 | SourceLocation EndLoc) |
||
369 | : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {} |
||
370 | |||
371 | /// Build an empty clause. |
||
372 | OMPAllocatorClause() : OMPOneStmtClause() {} |
||
373 | |||
374 | /// Returns allocator. |
||
375 | Expr *getAllocator() const { return getStmtAs<Expr>(); } |
||
376 | }; |
||
377 | |||
378 | /// This represents the 'align' clause in the '#pragma omp allocate' |
||
379 | /// directive. |
||
380 | /// |
||
381 | /// \code |
||
382 | /// #pragma omp allocate(a) allocator(omp_default_mem_alloc) align(8) |
||
383 | /// \endcode |
||
384 | /// In this example directive '#pragma omp allocate' has simple 'allocator' |
||
385 | /// clause with the allocator 'omp_default_mem_alloc' and align clause with |
||
386 | /// value of 8. |
||
387 | class OMPAlignClause final |
||
388 | : public OMPOneStmtClause<llvm::omp::OMPC_align, OMPClause> { |
||
389 | friend class OMPClauseReader; |
||
390 | |||
391 | /// Set alignment value. |
||
392 | void setAlignment(Expr *A) { setStmt(A); } |
||
393 | |||
394 | /// Build 'align' clause with the given alignment |
||
395 | /// |
||
396 | /// \param A Alignment value. |
||
397 | /// \param StartLoc Starting location of the clause. |
||
398 | /// \param LParenLoc Location of '('. |
||
399 | /// \param EndLoc Ending location of the clause. |
||
400 | OMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
401 | SourceLocation EndLoc) |
||
402 | : OMPOneStmtClause(A, StartLoc, LParenLoc, EndLoc) {} |
||
403 | |||
404 | /// Build an empty clause. |
||
405 | OMPAlignClause() : OMPOneStmtClause() {} |
||
406 | |||
407 | public: |
||
408 | /// Build 'align' clause with the given alignment |
||
409 | /// |
||
410 | /// \param A Alignment value. |
||
411 | /// \param StartLoc Starting location of the clause. |
||
412 | /// \param LParenLoc Location of '('. |
||
413 | /// \param EndLoc Ending location of the clause. |
||
414 | static OMPAlignClause *Create(const ASTContext &C, Expr *A, |
||
415 | SourceLocation StartLoc, |
||
416 | SourceLocation LParenLoc, |
||
417 | SourceLocation EndLoc); |
||
418 | |||
419 | /// Returns alignment |
||
420 | Expr *getAlignment() const { return getStmtAs<Expr>(); } |
||
421 | }; |
||
422 | |||
423 | /// This represents clause 'allocate' in the '#pragma omp ...' directives. |
||
424 | /// |
||
425 | /// \code |
||
426 | /// #pragma omp parallel private(a) allocate(omp_default_mem_alloc :a) |
||
427 | /// \endcode |
||
428 | /// In this example directive '#pragma omp parallel' has clause 'private' |
||
429 | /// and clause 'allocate' for the variable 'a'. |
||
430 | class OMPAllocateClause final |
||
431 | : public OMPVarListClause<OMPAllocateClause>, |
||
432 | private llvm::TrailingObjects<OMPAllocateClause, Expr *> { |
||
433 | friend class OMPClauseReader; |
||
434 | friend OMPVarListClause; |
||
435 | friend TrailingObjects; |
||
436 | |||
437 | /// Allocator specified in the clause, or 'nullptr' if the default one is |
||
438 | /// used. |
||
439 | Expr *Allocator = nullptr; |
||
440 | /// Position of the ':' delimiter in the clause; |
||
441 | SourceLocation ColonLoc; |
||
442 | |||
443 | /// Build clause with number of variables \a N. |
||
444 | /// |
||
445 | /// \param StartLoc Starting location of the clause. |
||
446 | /// \param LParenLoc Location of '('. |
||
447 | /// \param Allocator Allocator expression. |
||
448 | /// \param ColonLoc Location of ':' delimiter. |
||
449 | /// \param EndLoc Ending location of the clause. |
||
450 | /// \param N Number of the variables in the clause. |
||
451 | OMPAllocateClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
452 | Expr *Allocator, SourceLocation ColonLoc, |
||
453 | SourceLocation EndLoc, unsigned N) |
||
454 | : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, StartLoc, |
||
455 | LParenLoc, EndLoc, N), |
||
456 | Allocator(Allocator), ColonLoc(ColonLoc) {} |
||
457 | |||
458 | /// Build an empty clause. |
||
459 | /// |
||
460 | /// \param N Number of variables. |
||
461 | explicit OMPAllocateClause(unsigned N) |
||
462 | : OMPVarListClause<OMPAllocateClause>(llvm::omp::OMPC_allocate, |
||
463 | SourceLocation(), SourceLocation(), |
||
464 | SourceLocation(), N) {} |
||
465 | |||
466 | /// Sets location of ':' symbol in clause. |
||
467 | void setColonLoc(SourceLocation CL) { ColonLoc = CL; } |
||
468 | |||
469 | void setAllocator(Expr *A) { Allocator = A; } |
||
470 | |||
471 | public: |
||
472 | /// Creates clause with a list of variables \a VL. |
||
473 | /// |
||
474 | /// \param C AST context. |
||
475 | /// \param StartLoc Starting location of the clause. |
||
476 | /// \param LParenLoc Location of '('. |
||
477 | /// \param Allocator Allocator expression. |
||
478 | /// \param ColonLoc Location of ':' delimiter. |
||
479 | /// \param EndLoc Ending location of the clause. |
||
480 | /// \param VL List of references to the variables. |
||
481 | static OMPAllocateClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
482 | SourceLocation LParenLoc, Expr *Allocator, |
||
483 | SourceLocation ColonLoc, |
||
484 | SourceLocation EndLoc, ArrayRef<Expr *> VL); |
||
485 | |||
486 | /// Returns the allocator expression or nullptr, if no allocator is specified. |
||
487 | Expr *getAllocator() const { return Allocator; } |
||
488 | |||
489 | /// Returns the location of the ':' delimiter. |
||
490 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
491 | |||
492 | /// Creates an empty clause with the place for \a N variables. |
||
493 | /// |
||
494 | /// \param C AST context. |
||
495 | /// \param N The number of variables. |
||
496 | static OMPAllocateClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
497 | |||
498 | child_range children() { |
||
499 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
500 | reinterpret_cast<Stmt **>(varlist_end())); |
||
501 | } |
||
502 | |||
503 | const_child_range children() const { |
||
504 | auto Children = const_cast<OMPAllocateClause *>(this)->children(); |
||
505 | return const_child_range(Children.begin(), Children.end()); |
||
506 | } |
||
507 | |||
508 | child_range used_children() { |
||
509 | return child_range(child_iterator(), child_iterator()); |
||
510 | } |
||
511 | const_child_range used_children() const { |
||
512 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
513 | } |
||
514 | |||
515 | static bool classof(const OMPClause *T) { |
||
516 | return T->getClauseKind() == llvm::omp::OMPC_allocate; |
||
517 | } |
||
518 | }; |
||
519 | |||
520 | /// This represents 'if' clause in the '#pragma omp ...' directive. |
||
521 | /// |
||
522 | /// \code |
||
523 | /// #pragma omp parallel if(parallel:a > 5) |
||
524 | /// \endcode |
||
525 | /// In this example directive '#pragma omp parallel' has simple 'if' clause with |
||
526 | /// condition 'a > 5' and directive name modifier 'parallel'. |
||
527 | class OMPIfClause : public OMPClause, public OMPClauseWithPreInit { |
||
528 | friend class OMPClauseReader; |
||
529 | |||
530 | /// Location of '('. |
||
531 | SourceLocation LParenLoc; |
||
532 | |||
533 | /// Condition of the 'if' clause. |
||
534 | Stmt *Condition = nullptr; |
||
535 | |||
536 | /// Location of ':' (if any). |
||
537 | SourceLocation ColonLoc; |
||
538 | |||
539 | /// Directive name modifier for the clause. |
||
540 | OpenMPDirectiveKind NameModifier = llvm::omp::OMPD_unknown; |
||
541 | |||
542 | /// Name modifier location. |
||
543 | SourceLocation NameModifierLoc; |
||
544 | |||
545 | /// Set condition. |
||
546 | void setCondition(Expr *Cond) { Condition = Cond; } |
||
547 | |||
548 | /// Set directive name modifier for the clause. |
||
549 | void setNameModifier(OpenMPDirectiveKind NM) { NameModifier = NM; } |
||
550 | |||
551 | /// Set location of directive name modifier for the clause. |
||
552 | void setNameModifierLoc(SourceLocation Loc) { NameModifierLoc = Loc; } |
||
553 | |||
554 | /// Set location of ':'. |
||
555 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
556 | |||
557 | public: |
||
558 | /// Build 'if' clause with condition \a Cond. |
||
559 | /// |
||
560 | /// \param NameModifier [OpenMP 4.1] Directive name modifier of clause. |
||
561 | /// \param Cond Condition of the clause. |
||
562 | /// \param HelperCond Helper condition for the clause. |
||
563 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
564 | /// clause must be captured. |
||
565 | /// \param StartLoc Starting location of the clause. |
||
566 | /// \param LParenLoc Location of '('. |
||
567 | /// \param NameModifierLoc Location of directive name modifier. |
||
568 | /// \param ColonLoc [OpenMP 4.1] Location of ':'. |
||
569 | /// \param EndLoc Ending location of the clause. |
||
570 | OMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Cond, Stmt *HelperCond, |
||
571 | OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, |
||
572 | SourceLocation LParenLoc, SourceLocation NameModifierLoc, |
||
573 | SourceLocation ColonLoc, SourceLocation EndLoc) |
||
574 | : OMPClause(llvm::omp::OMPC_if, StartLoc, EndLoc), |
||
575 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond), |
||
576 | ColonLoc(ColonLoc), NameModifier(NameModifier), |
||
577 | NameModifierLoc(NameModifierLoc) { |
||
578 | setPreInitStmt(HelperCond, CaptureRegion); |
||
579 | } |
||
580 | |||
581 | /// Build an empty clause. |
||
582 | OMPIfClause() |
||
583 | : OMPClause(llvm::omp::OMPC_if, SourceLocation(), SourceLocation()), |
||
584 | OMPClauseWithPreInit(this) {} |
||
585 | |||
586 | /// Sets the location of '('. |
||
587 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
588 | |||
589 | /// Returns the location of '('. |
||
590 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
591 | |||
592 | /// Return the location of ':'. |
||
593 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
594 | |||
595 | /// Returns condition. |
||
596 | Expr *getCondition() const { return cast_or_null<Expr>(Condition); } |
||
597 | |||
598 | /// Return directive name modifier associated with the clause. |
||
599 | OpenMPDirectiveKind getNameModifier() const { return NameModifier; } |
||
600 | |||
601 | /// Return the location of directive name modifier. |
||
602 | SourceLocation getNameModifierLoc() const { return NameModifierLoc; } |
||
603 | |||
604 | child_range children() { return child_range(&Condition, &Condition + 1); } |
||
605 | |||
606 | const_child_range children() const { |
||
607 | return const_child_range(&Condition, &Condition + 1); |
||
608 | } |
||
609 | |||
610 | child_range used_children(); |
||
611 | const_child_range used_children() const { |
||
612 | auto Children = const_cast<OMPIfClause *>(this)->used_children(); |
||
613 | return const_child_range(Children.begin(), Children.end()); |
||
614 | } |
||
615 | |||
616 | static bool classof(const OMPClause *T) { |
||
617 | return T->getClauseKind() == llvm::omp::OMPC_if; |
||
618 | } |
||
619 | }; |
||
620 | |||
621 | /// This represents 'final' clause in the '#pragma omp ...' directive. |
||
622 | /// |
||
623 | /// \code |
||
624 | /// #pragma omp task final(a > 5) |
||
625 | /// \endcode |
||
626 | /// In this example directive '#pragma omp task' has simple 'final' |
||
627 | /// clause with condition 'a > 5'. |
||
628 | class OMPFinalClause final |
||
629 | : public OMPOneStmtClause<llvm::omp::OMPC_final, OMPClause>, |
||
630 | public OMPClauseWithPreInit { |
||
631 | friend class OMPClauseReader; |
||
632 | |||
633 | /// Set condition. |
||
634 | void setCondition(Expr *Cond) { setStmt(Cond); } |
||
635 | |||
636 | public: |
||
637 | /// Build 'final' clause with condition \a Cond. |
||
638 | /// |
||
639 | /// \param Cond Condition of the clause. |
||
640 | /// \param HelperCond Helper condition for the construct. |
||
641 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
642 | /// clause must be captured. |
||
643 | /// \param StartLoc Starting location of the clause. |
||
644 | /// \param LParenLoc Location of '('. |
||
645 | /// \param EndLoc Ending location of the clause. |
||
646 | OMPFinalClause(Expr *Cond, Stmt *HelperCond, |
||
647 | OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, |
||
648 | SourceLocation LParenLoc, SourceLocation EndLoc) |
||
649 | : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc), |
||
650 | OMPClauseWithPreInit(this) { |
||
651 | setPreInitStmt(HelperCond, CaptureRegion); |
||
652 | } |
||
653 | |||
654 | /// Build an empty clause. |
||
655 | OMPFinalClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {} |
||
656 | |||
657 | /// Returns condition. |
||
658 | Expr *getCondition() const { return getStmtAs<Expr>(); } |
||
659 | |||
660 | child_range used_children(); |
||
661 | const_child_range used_children() const { |
||
662 | auto Children = const_cast<OMPFinalClause *>(this)->used_children(); |
||
663 | return const_child_range(Children.begin(), Children.end()); |
||
664 | } |
||
665 | }; |
||
666 | /// This represents 'num_threads' clause in the '#pragma omp ...' |
||
667 | /// directive. |
||
668 | /// |
||
669 | /// \code |
||
670 | /// #pragma omp parallel num_threads(6) |
||
671 | /// \endcode |
||
672 | /// In this example directive '#pragma omp parallel' has simple 'num_threads' |
||
673 | /// clause with number of threads '6'. |
||
674 | class OMPNumThreadsClause final |
||
675 | : public OMPOneStmtClause<llvm::omp::OMPC_num_threads, OMPClause>, |
||
676 | public OMPClauseWithPreInit { |
||
677 | friend class OMPClauseReader; |
||
678 | |||
679 | /// Set condition. |
||
680 | void setNumThreads(Expr *NThreads) { setStmt(NThreads); } |
||
681 | |||
682 | public: |
||
683 | /// Build 'num_threads' clause with condition \a NumThreads. |
||
684 | /// |
||
685 | /// \param NumThreads Number of threads for the construct. |
||
686 | /// \param HelperNumThreads Helper Number of threads for the construct. |
||
687 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
688 | /// clause must be captured. |
||
689 | /// \param StartLoc Starting location of the clause. |
||
690 | /// \param LParenLoc Location of '('. |
||
691 | /// \param EndLoc Ending location of the clause. |
||
692 | OMPNumThreadsClause(Expr *NumThreads, Stmt *HelperNumThreads, |
||
693 | OpenMPDirectiveKind CaptureRegion, |
||
694 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
695 | SourceLocation EndLoc) |
||
696 | : OMPOneStmtClause(NumThreads, StartLoc, LParenLoc, EndLoc), |
||
697 | OMPClauseWithPreInit(this) { |
||
698 | setPreInitStmt(HelperNumThreads, CaptureRegion); |
||
699 | } |
||
700 | |||
701 | /// Build an empty clause. |
||
702 | OMPNumThreadsClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {} |
||
703 | |||
704 | /// Returns number of threads. |
||
705 | Expr *getNumThreads() const { return getStmtAs<Expr>(); } |
||
706 | }; |
||
707 | |||
708 | /// This represents 'safelen' clause in the '#pragma omp ...' |
||
709 | /// directive. |
||
710 | /// |
||
711 | /// \code |
||
712 | /// #pragma omp simd safelen(4) |
||
713 | /// \endcode |
||
714 | /// In this example directive '#pragma omp simd' has clause 'safelen' |
||
715 | /// with single expression '4'. |
||
716 | /// If the safelen clause is used then no two iterations executed |
||
717 | /// concurrently with SIMD instructions can have a greater distance |
||
718 | /// in the logical iteration space than its value. The parameter of |
||
719 | /// the safelen clause must be a constant positive integer expression. |
||
720 | class OMPSafelenClause final |
||
721 | : public OMPOneStmtClause<llvm::omp::OMPC_safelen, OMPClause> { |
||
722 | friend class OMPClauseReader; |
||
723 | |||
724 | /// Set safelen. |
||
725 | void setSafelen(Expr *Len) { setStmt(Len); } |
||
726 | |||
727 | public: |
||
728 | /// Build 'safelen' clause. |
||
729 | /// |
||
730 | /// \param Len Expression associated with this clause. |
||
731 | /// \param StartLoc Starting location of the clause. |
||
732 | /// \param EndLoc Ending location of the clause. |
||
733 | OMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
734 | SourceLocation EndLoc) |
||
735 | : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {} |
||
736 | |||
737 | /// Build an empty clause. |
||
738 | explicit OMPSafelenClause() : OMPOneStmtClause() {} |
||
739 | |||
740 | /// Return safe iteration space distance. |
||
741 | Expr *getSafelen() const { return getStmtAs<Expr>(); } |
||
742 | }; |
||
743 | |||
744 | /// This represents 'simdlen' clause in the '#pragma omp ...' |
||
745 | /// directive. |
||
746 | /// |
||
747 | /// \code |
||
748 | /// #pragma omp simd simdlen(4) |
||
749 | /// \endcode |
||
750 | /// In this example directive '#pragma omp simd' has clause 'simdlen' |
||
751 | /// with single expression '4'. |
||
752 | /// If the 'simdlen' clause is used then it specifies the preferred number of |
||
753 | /// iterations to be executed concurrently. The parameter of the 'simdlen' |
||
754 | /// clause must be a constant positive integer expression. |
||
755 | class OMPSimdlenClause final |
||
756 | : public OMPOneStmtClause<llvm::omp::OMPC_simdlen, OMPClause> { |
||
757 | friend class OMPClauseReader; |
||
758 | |||
759 | /// Set simdlen. |
||
760 | void setSimdlen(Expr *Len) { setStmt(Len); } |
||
761 | |||
762 | public: |
||
763 | /// Build 'simdlen' clause. |
||
764 | /// |
||
765 | /// \param Len Expression associated with this clause. |
||
766 | /// \param StartLoc Starting location of the clause. |
||
767 | /// \param EndLoc Ending location of the clause. |
||
768 | OMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
769 | SourceLocation EndLoc) |
||
770 | : OMPOneStmtClause(Len, StartLoc, LParenLoc, EndLoc) {} |
||
771 | |||
772 | /// Build an empty clause. |
||
773 | explicit OMPSimdlenClause() : OMPOneStmtClause() {} |
||
774 | |||
775 | /// Return safe iteration space distance. |
||
776 | Expr *getSimdlen() const { return getStmtAs<Expr>(); } |
||
777 | }; |
||
778 | |||
779 | /// This represents the 'sizes' clause in the '#pragma omp tile' directive. |
||
780 | /// |
||
781 | /// \code |
||
782 | /// #pragma omp tile sizes(5,5) |
||
783 | /// for (int i = 0; i < 64; ++i) |
||
784 | /// for (int j = 0; j < 64; ++j) |
||
785 | /// \endcode |
||
786 | class OMPSizesClause final |
||
787 | : public OMPClause, |
||
788 | private llvm::TrailingObjects<OMPSizesClause, Expr *> { |
||
789 | friend class OMPClauseReader; |
||
790 | friend class llvm::TrailingObjects<OMPSizesClause, Expr *>; |
||
791 | |||
792 | /// Location of '('. |
||
793 | SourceLocation LParenLoc; |
||
794 | |||
795 | /// Number of tile sizes in the clause. |
||
796 | unsigned NumSizes; |
||
797 | |||
798 | /// Build an empty clause. |
||
799 | explicit OMPSizesClause(int NumSizes) |
||
800 | : OMPClause(llvm::omp::OMPC_sizes, SourceLocation(), SourceLocation()), |
||
801 | NumSizes(NumSizes) {} |
||
802 | |||
803 | public: |
||
804 | /// Build a 'sizes' AST node. |
||
805 | /// |
||
806 | /// \param C Context of the AST. |
||
807 | /// \param StartLoc Location of the 'sizes' identifier. |
||
808 | /// \param LParenLoc Location of '('. |
||
809 | /// \param EndLoc Location of ')'. |
||
810 | /// \param Sizes Content of the clause. |
||
811 | static OMPSizesClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
812 | SourceLocation LParenLoc, SourceLocation EndLoc, |
||
813 | ArrayRef<Expr *> Sizes); |
||
814 | |||
815 | /// Build an empty 'sizes' AST node for deserialization. |
||
816 | /// |
||
817 | /// \param C Context of the AST. |
||
818 | /// \param NumSizes Number of items in the clause. |
||
819 | static OMPSizesClause *CreateEmpty(const ASTContext &C, unsigned NumSizes); |
||
820 | |||
821 | /// Sets the location of '('. |
||
822 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
823 | |||
824 | /// Returns the location of '('. |
||
825 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
826 | |||
827 | /// Returns the number of list items. |
||
828 | unsigned getNumSizes() const { return NumSizes; } |
||
829 | |||
830 | /// Returns the tile size expressions. |
||
831 | MutableArrayRef<Expr *> getSizesRefs() { |
||
832 | return MutableArrayRef<Expr *>(static_cast<OMPSizesClause *>(this) |
||
833 | ->template getTrailingObjects<Expr *>(), |
||
834 | NumSizes); |
||
835 | } |
||
836 | ArrayRef<Expr *> getSizesRefs() const { |
||
837 | return ArrayRef<Expr *>(static_cast<const OMPSizesClause *>(this) |
||
838 | ->template getTrailingObjects<Expr *>(), |
||
839 | NumSizes); |
||
840 | } |
||
841 | |||
842 | /// Sets the tile size expressions. |
||
843 | void setSizesRefs(ArrayRef<Expr *> VL) { |
||
844 | assert(VL.size() == NumSizes); |
||
845 | std::copy(VL.begin(), VL.end(), |
||
846 | static_cast<OMPSizesClause *>(this) |
||
847 | ->template getTrailingObjects<Expr *>()); |
||
848 | } |
||
849 | |||
850 | child_range children() { |
||
851 | MutableArrayRef<Expr *> Sizes = getSizesRefs(); |
||
852 | return child_range(reinterpret_cast<Stmt **>(Sizes.begin()), |
||
853 | reinterpret_cast<Stmt **>(Sizes.end())); |
||
854 | } |
||
855 | const_child_range children() const { |
||
856 | ArrayRef<Expr *> Sizes = getSizesRefs(); |
||
857 | return const_child_range(reinterpret_cast<Stmt *const *>(Sizes.begin()), |
||
858 | reinterpret_cast<Stmt *const *>(Sizes.end())); |
||
859 | } |
||
860 | |||
861 | child_range used_children() { |
||
862 | return child_range(child_iterator(), child_iterator()); |
||
863 | } |
||
864 | const_child_range used_children() const { |
||
865 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
866 | } |
||
867 | |||
868 | static bool classof(const OMPClause *T) { |
||
869 | return T->getClauseKind() == llvm::omp::OMPC_sizes; |
||
870 | } |
||
871 | }; |
||
872 | |||
873 | /// Representation of the 'full' clause of the '#pragma omp unroll' directive. |
||
874 | /// |
||
875 | /// \code |
||
876 | /// #pragma omp unroll full |
||
877 | /// for (int i = 0; i < 64; ++i) |
||
878 | /// \endcode |
||
879 | class OMPFullClause final : public OMPNoChildClause<llvm::omp::OMPC_full> { |
||
880 | friend class OMPClauseReader; |
||
881 | |||
882 | /// Build an empty clause. |
||
883 | explicit OMPFullClause() : OMPNoChildClause() {} |
||
884 | |||
885 | public: |
||
886 | /// Build an AST node for a 'full' clause. |
||
887 | /// |
||
888 | /// \param C Context of the AST. |
||
889 | /// \param StartLoc Starting location of the clause. |
||
890 | /// \param EndLoc Ending location of the clause. |
||
891 | static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
892 | SourceLocation EndLoc); |
||
893 | |||
894 | /// Build an empty 'full' AST node for deserialization. |
||
895 | /// |
||
896 | /// \param C Context of the AST. |
||
897 | static OMPFullClause *CreateEmpty(const ASTContext &C); |
||
898 | }; |
||
899 | |||
900 | /// Representation of the 'partial' clause of the '#pragma omp unroll' |
||
901 | /// directive. |
||
902 | /// |
||
903 | /// \code |
||
904 | /// #pragma omp unroll partial(4) |
||
905 | /// for (int i = start; i < end; ++i) |
||
906 | /// \endcode |
||
907 | class OMPPartialClause final : public OMPClause { |
||
908 | friend class OMPClauseReader; |
||
909 | |||
910 | /// Location of '('. |
||
911 | SourceLocation LParenLoc; |
||
912 | |||
913 | /// Optional argument to the clause (unroll factor). |
||
914 | Stmt *Factor; |
||
915 | |||
916 | /// Build an empty clause. |
||
917 | explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {} |
||
918 | |||
919 | /// Set the unroll factor. |
||
920 | void setFactor(Expr *E) { Factor = E; } |
||
921 | |||
922 | /// Sets the location of '('. |
||
923 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
924 | |||
925 | public: |
||
926 | /// Build an AST node for a 'partial' clause. |
||
927 | /// |
||
928 | /// \param C Context of the AST. |
||
929 | /// \param StartLoc Location of the 'partial' identifier. |
||
930 | /// \param LParenLoc Location of '('. |
||
931 | /// \param EndLoc Location of ')'. |
||
932 | /// \param Factor Clause argument. |
||
933 | static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
934 | SourceLocation LParenLoc, |
||
935 | SourceLocation EndLoc, Expr *Factor); |
||
936 | |||
937 | /// Build an empty 'partial' AST node for deserialization. |
||
938 | /// |
||
939 | /// \param C Context of the AST. |
||
940 | static OMPPartialClause *CreateEmpty(const ASTContext &C); |
||
941 | |||
942 | /// Returns the location of '('. |
||
943 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
944 | |||
945 | /// Returns the argument of the clause or nullptr if not set. |
||
946 | Expr *getFactor() const { return cast_or_null<Expr>(Factor); } |
||
947 | |||
948 | child_range children() { return child_range(&Factor, &Factor + 1); } |
||
949 | const_child_range children() const { |
||
950 | return const_child_range(&Factor, &Factor + 1); |
||
951 | } |
||
952 | |||
953 | child_range used_children() { |
||
954 | return child_range(child_iterator(), child_iterator()); |
||
955 | } |
||
956 | const_child_range used_children() const { |
||
957 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
958 | } |
||
959 | |||
960 | static bool classof(const OMPClause *T) { |
||
961 | return T->getClauseKind() == llvm::omp::OMPC_partial; |
||
962 | } |
||
963 | }; |
||
964 | |||
965 | /// This represents 'collapse' clause in the '#pragma omp ...' |
||
966 | /// directive. |
||
967 | /// |
||
968 | /// \code |
||
969 | /// #pragma omp simd collapse(3) |
||
970 | /// \endcode |
||
971 | /// In this example directive '#pragma omp simd' has clause 'collapse' |
||
972 | /// with single expression '3'. |
||
973 | /// The parameter must be a constant positive integer expression, it specifies |
||
974 | /// the number of nested loops that should be collapsed into a single iteration |
||
975 | /// space. |
||
976 | class OMPCollapseClause final |
||
977 | : public OMPOneStmtClause<llvm::omp::OMPC_collapse, OMPClause> { |
||
978 | friend class OMPClauseReader; |
||
979 | |||
980 | /// Set the number of associated for-loops. |
||
981 | void setNumForLoops(Expr *Num) { setStmt(Num); } |
||
982 | |||
983 | public: |
||
984 | /// Build 'collapse' clause. |
||
985 | /// |
||
986 | /// \param Num Expression associated with this clause. |
||
987 | /// \param StartLoc Starting location of the clause. |
||
988 | /// \param LParenLoc Location of '('. |
||
989 | /// \param EndLoc Ending location of the clause. |
||
990 | OMPCollapseClause(Expr *Num, SourceLocation StartLoc, |
||
991 | SourceLocation LParenLoc, SourceLocation EndLoc) |
||
992 | : OMPOneStmtClause(Num, StartLoc, LParenLoc, EndLoc) {} |
||
993 | |||
994 | /// Build an empty clause. |
||
995 | explicit OMPCollapseClause() : OMPOneStmtClause() {} |
||
996 | |||
997 | /// Return the number of associated for-loops. |
||
998 | Expr *getNumForLoops() const { return getStmtAs<Expr>(); } |
||
999 | }; |
||
1000 | |||
1001 | /// This represents 'default' clause in the '#pragma omp ...' directive. |
||
1002 | /// |
||
1003 | /// \code |
||
1004 | /// #pragma omp parallel default(shared) |
||
1005 | /// \endcode |
||
1006 | /// In this example directive '#pragma omp parallel' has simple 'default' |
||
1007 | /// clause with kind 'shared'. |
||
1008 | class OMPDefaultClause : public OMPClause { |
||
1009 | friend class OMPClauseReader; |
||
1010 | |||
1011 | /// Location of '('. |
||
1012 | SourceLocation LParenLoc; |
||
1013 | |||
1014 | /// A kind of the 'default' clause. |
||
1015 | llvm::omp::DefaultKind Kind = llvm::omp::OMP_DEFAULT_unknown; |
||
1016 | |||
1017 | /// Start location of the kind in source code. |
||
1018 | SourceLocation KindKwLoc; |
||
1019 | |||
1020 | /// Set kind of the clauses. |
||
1021 | /// |
||
1022 | /// \param K Argument of clause. |
||
1023 | void setDefaultKind(llvm::omp::DefaultKind K) { Kind = K; } |
||
1024 | |||
1025 | /// Set argument location. |
||
1026 | /// |
||
1027 | /// \param KLoc Argument location. |
||
1028 | void setDefaultKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; } |
||
1029 | |||
1030 | public: |
||
1031 | /// Build 'default' clause with argument \a A ('none' or 'shared'). |
||
1032 | /// |
||
1033 | /// \param A Argument of the clause ('none' or 'shared'). |
||
1034 | /// \param ALoc Starting location of the argument. |
||
1035 | /// \param StartLoc Starting location of the clause. |
||
1036 | /// \param LParenLoc Location of '('. |
||
1037 | /// \param EndLoc Ending location of the clause. |
||
1038 | OMPDefaultClause(llvm::omp::DefaultKind A, SourceLocation ALoc, |
||
1039 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
1040 | SourceLocation EndLoc) |
||
1041 | : OMPClause(llvm::omp::OMPC_default, StartLoc, EndLoc), |
||
1042 | LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {} |
||
1043 | |||
1044 | /// Build an empty clause. |
||
1045 | OMPDefaultClause() |
||
1046 | : OMPClause(llvm::omp::OMPC_default, SourceLocation(), SourceLocation()) { |
||
1047 | } |
||
1048 | |||
1049 | /// Sets the location of '('. |
||
1050 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1051 | |||
1052 | /// Returns the location of '('. |
||
1053 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
1054 | |||
1055 | /// Returns kind of the clause. |
||
1056 | llvm::omp::DefaultKind getDefaultKind() const { return Kind; } |
||
1057 | |||
1058 | /// Returns location of clause kind. |
||
1059 | SourceLocation getDefaultKindKwLoc() const { return KindKwLoc; } |
||
1060 | |||
1061 | child_range children() { |
||
1062 | return child_range(child_iterator(), child_iterator()); |
||
1063 | } |
||
1064 | |||
1065 | const_child_range children() const { |
||
1066 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1067 | } |
||
1068 | |||
1069 | child_range used_children() { |
||
1070 | return child_range(child_iterator(), child_iterator()); |
||
1071 | } |
||
1072 | const_child_range used_children() const { |
||
1073 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1074 | } |
||
1075 | |||
1076 | static bool classof(const OMPClause *T) { |
||
1077 | return T->getClauseKind() == llvm::omp::OMPC_default; |
||
1078 | } |
||
1079 | }; |
||
1080 | |||
1081 | /// This represents 'proc_bind' clause in the '#pragma omp ...' |
||
1082 | /// directive. |
||
1083 | /// |
||
1084 | /// \code |
||
1085 | /// #pragma omp parallel proc_bind(master) |
||
1086 | /// \endcode |
||
1087 | /// In this example directive '#pragma omp parallel' has simple 'proc_bind' |
||
1088 | /// clause with kind 'master'. |
||
1089 | class OMPProcBindClause : public OMPClause { |
||
1090 | friend class OMPClauseReader; |
||
1091 | |||
1092 | /// Location of '('. |
||
1093 | SourceLocation LParenLoc; |
||
1094 | |||
1095 | /// A kind of the 'proc_bind' clause. |
||
1096 | llvm::omp::ProcBindKind Kind = llvm::omp::OMP_PROC_BIND_unknown; |
||
1097 | |||
1098 | /// Start location of the kind in source code. |
||
1099 | SourceLocation KindKwLoc; |
||
1100 | |||
1101 | /// Set kind of the clause. |
||
1102 | /// |
||
1103 | /// \param K Kind of clause. |
||
1104 | void setProcBindKind(llvm::omp::ProcBindKind K) { Kind = K; } |
||
1105 | |||
1106 | /// Set clause kind location. |
||
1107 | /// |
||
1108 | /// \param KLoc Kind location. |
||
1109 | void setProcBindKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; } |
||
1110 | |||
1111 | public: |
||
1112 | /// Build 'proc_bind' clause with argument \a A ('master', 'close' or |
||
1113 | /// 'spread'). |
||
1114 | /// |
||
1115 | /// \param A Argument of the clause ('master', 'close' or 'spread'). |
||
1116 | /// \param ALoc Starting location of the argument. |
||
1117 | /// \param StartLoc Starting location of the clause. |
||
1118 | /// \param LParenLoc Location of '('. |
||
1119 | /// \param EndLoc Ending location of the clause. |
||
1120 | OMPProcBindClause(llvm::omp::ProcBindKind A, SourceLocation ALoc, |
||
1121 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
1122 | SourceLocation EndLoc) |
||
1123 | : OMPClause(llvm::omp::OMPC_proc_bind, StartLoc, EndLoc), |
||
1124 | LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {} |
||
1125 | |||
1126 | /// Build an empty clause. |
||
1127 | OMPProcBindClause() |
||
1128 | : OMPClause(llvm::omp::OMPC_proc_bind, SourceLocation(), |
||
1129 | SourceLocation()) {} |
||
1130 | |||
1131 | /// Sets the location of '('. |
||
1132 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1133 | |||
1134 | /// Returns the location of '('. |
||
1135 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
1136 | |||
1137 | /// Returns kind of the clause. |
||
1138 | llvm::omp::ProcBindKind getProcBindKind() const { return Kind; } |
||
1139 | |||
1140 | /// Returns location of clause kind. |
||
1141 | SourceLocation getProcBindKindKwLoc() const { return KindKwLoc; } |
||
1142 | |||
1143 | child_range children() { |
||
1144 | return child_range(child_iterator(), child_iterator()); |
||
1145 | } |
||
1146 | |||
1147 | const_child_range children() const { |
||
1148 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1149 | } |
||
1150 | |||
1151 | child_range used_children() { |
||
1152 | return child_range(child_iterator(), child_iterator()); |
||
1153 | } |
||
1154 | const_child_range used_children() const { |
||
1155 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1156 | } |
||
1157 | |||
1158 | static bool classof(const OMPClause *T) { |
||
1159 | return T->getClauseKind() == llvm::omp::OMPC_proc_bind; |
||
1160 | } |
||
1161 | }; |
||
1162 | |||
1163 | /// This represents 'unified_address' clause in the '#pragma omp requires' |
||
1164 | /// directive. |
||
1165 | /// |
||
1166 | /// \code |
||
1167 | /// #pragma omp requires unified_address |
||
1168 | /// \endcode |
||
1169 | /// In this example directive '#pragma omp requires' has 'unified_address' |
||
1170 | /// clause. |
||
1171 | class OMPUnifiedAddressClause final |
||
1172 | : public OMPNoChildClause<llvm::omp::OMPC_unified_address> { |
||
1173 | public: |
||
1174 | friend class OMPClauseReader; |
||
1175 | /// Build 'unified_address' clause. |
||
1176 | /// |
||
1177 | /// \param StartLoc Starting location of the clause. |
||
1178 | /// \param EndLoc Ending location of the clause. |
||
1179 | OMPUnifiedAddressClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
1180 | : OMPNoChildClause(StartLoc, EndLoc) {} |
||
1181 | |||
1182 | /// Build an empty clause. |
||
1183 | OMPUnifiedAddressClause() : OMPNoChildClause() {} |
||
1184 | }; |
||
1185 | |||
1186 | /// This represents 'unified_shared_memory' clause in the '#pragma omp requires' |
||
1187 | /// directive. |
||
1188 | /// |
||
1189 | /// \code |
||
1190 | /// #pragma omp requires unified_shared_memory |
||
1191 | /// \endcode |
||
1192 | /// In this example directive '#pragma omp requires' has 'unified_shared_memory' |
||
1193 | /// clause. |
||
1194 | class OMPUnifiedSharedMemoryClause final : public OMPClause { |
||
1195 | public: |
||
1196 | friend class OMPClauseReader; |
||
1197 | /// Build 'unified_shared_memory' clause. |
||
1198 | /// |
||
1199 | /// \param StartLoc Starting location of the clause. |
||
1200 | /// \param EndLoc Ending location of the clause. |
||
1201 | OMPUnifiedSharedMemoryClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
1202 | : OMPClause(llvm::omp::OMPC_unified_shared_memory, StartLoc, EndLoc) {} |
||
1203 | |||
1204 | /// Build an empty clause. |
||
1205 | OMPUnifiedSharedMemoryClause() |
||
1206 | : OMPClause(llvm::omp::OMPC_unified_shared_memory, SourceLocation(), |
||
1207 | SourceLocation()) {} |
||
1208 | |||
1209 | child_range children() { |
||
1210 | return child_range(child_iterator(), child_iterator()); |
||
1211 | } |
||
1212 | |||
1213 | const_child_range children() const { |
||
1214 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1215 | } |
||
1216 | |||
1217 | child_range used_children() { |
||
1218 | return child_range(child_iterator(), child_iterator()); |
||
1219 | } |
||
1220 | const_child_range used_children() const { |
||
1221 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1222 | } |
||
1223 | |||
1224 | static bool classof(const OMPClause *T) { |
||
1225 | return T->getClauseKind() == llvm::omp::OMPC_unified_shared_memory; |
||
1226 | } |
||
1227 | }; |
||
1228 | |||
1229 | /// This represents 'reverse_offload' clause in the '#pragma omp requires' |
||
1230 | /// directive. |
||
1231 | /// |
||
1232 | /// \code |
||
1233 | /// #pragma omp requires reverse_offload |
||
1234 | /// \endcode |
||
1235 | /// In this example directive '#pragma omp requires' has 'reverse_offload' |
||
1236 | /// clause. |
||
1237 | class OMPReverseOffloadClause final : public OMPClause { |
||
1238 | public: |
||
1239 | friend class OMPClauseReader; |
||
1240 | /// Build 'reverse_offload' clause. |
||
1241 | /// |
||
1242 | /// \param StartLoc Starting location of the clause. |
||
1243 | /// \param EndLoc Ending location of the clause. |
||
1244 | OMPReverseOffloadClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
1245 | : OMPClause(llvm::omp::OMPC_reverse_offload, StartLoc, EndLoc) {} |
||
1246 | |||
1247 | /// Build an empty clause. |
||
1248 | OMPReverseOffloadClause() |
||
1249 | : OMPClause(llvm::omp::OMPC_reverse_offload, SourceLocation(), |
||
1250 | SourceLocation()) {} |
||
1251 | |||
1252 | child_range children() { |
||
1253 | return child_range(child_iterator(), child_iterator()); |
||
1254 | } |
||
1255 | |||
1256 | const_child_range children() const { |
||
1257 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1258 | } |
||
1259 | |||
1260 | child_range used_children() { |
||
1261 | return child_range(child_iterator(), child_iterator()); |
||
1262 | } |
||
1263 | const_child_range used_children() const { |
||
1264 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1265 | } |
||
1266 | |||
1267 | static bool classof(const OMPClause *T) { |
||
1268 | return T->getClauseKind() == llvm::omp::OMPC_reverse_offload; |
||
1269 | } |
||
1270 | }; |
||
1271 | |||
1272 | /// This represents 'dynamic_allocators' clause in the '#pragma omp requires' |
||
1273 | /// directive. |
||
1274 | /// |
||
1275 | /// \code |
||
1276 | /// #pragma omp requires dynamic_allocators |
||
1277 | /// \endcode |
||
1278 | /// In this example directive '#pragma omp requires' has 'dynamic_allocators' |
||
1279 | /// clause. |
||
1280 | class OMPDynamicAllocatorsClause final : public OMPClause { |
||
1281 | public: |
||
1282 | friend class OMPClauseReader; |
||
1283 | /// Build 'dynamic_allocators' clause. |
||
1284 | /// |
||
1285 | /// \param StartLoc Starting location of the clause. |
||
1286 | /// \param EndLoc Ending location of the clause. |
||
1287 | OMPDynamicAllocatorsClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
1288 | : OMPClause(llvm::omp::OMPC_dynamic_allocators, StartLoc, EndLoc) {} |
||
1289 | |||
1290 | /// Build an empty clause. |
||
1291 | OMPDynamicAllocatorsClause() |
||
1292 | : OMPClause(llvm::omp::OMPC_dynamic_allocators, SourceLocation(), |
||
1293 | SourceLocation()) {} |
||
1294 | |||
1295 | child_range children() { |
||
1296 | return child_range(child_iterator(), child_iterator()); |
||
1297 | } |
||
1298 | |||
1299 | const_child_range children() const { |
||
1300 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1301 | } |
||
1302 | |||
1303 | child_range used_children() { |
||
1304 | return child_range(child_iterator(), child_iterator()); |
||
1305 | } |
||
1306 | const_child_range used_children() const { |
||
1307 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1308 | } |
||
1309 | |||
1310 | static bool classof(const OMPClause *T) { |
||
1311 | return T->getClauseKind() == llvm::omp::OMPC_dynamic_allocators; |
||
1312 | } |
||
1313 | }; |
||
1314 | |||
1315 | /// This represents 'atomic_default_mem_order' clause in the '#pragma omp |
||
1316 | /// requires' directive. |
||
1317 | /// |
||
1318 | /// \code |
||
1319 | /// #pragma omp requires atomic_default_mem_order(seq_cst) |
||
1320 | /// \endcode |
||
1321 | /// In this example directive '#pragma omp requires' has simple |
||
1322 | /// atomic_default_mem_order' clause with kind 'seq_cst'. |
||
1323 | class OMPAtomicDefaultMemOrderClause final : public OMPClause { |
||
1324 | friend class OMPClauseReader; |
||
1325 | |||
1326 | /// Location of '(' |
||
1327 | SourceLocation LParenLoc; |
||
1328 | |||
1329 | /// A kind of the 'atomic_default_mem_order' clause. |
||
1330 | OpenMPAtomicDefaultMemOrderClauseKind Kind = |
||
1331 | OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown; |
||
1332 | |||
1333 | /// Start location of the kind in source code. |
||
1334 | SourceLocation KindKwLoc; |
||
1335 | |||
1336 | /// Set kind of the clause. |
||
1337 | /// |
||
1338 | /// \param K Kind of clause. |
||
1339 | void setAtomicDefaultMemOrderKind(OpenMPAtomicDefaultMemOrderClauseKind K) { |
||
1340 | Kind = K; |
||
1341 | } |
||
1342 | |||
1343 | /// Set clause kind location. |
||
1344 | /// |
||
1345 | /// \param KLoc Kind location. |
||
1346 | void setAtomicDefaultMemOrderKindKwLoc(SourceLocation KLoc) { |
||
1347 | KindKwLoc = KLoc; |
||
1348 | } |
||
1349 | |||
1350 | public: |
||
1351 | /// Build 'atomic_default_mem_order' clause with argument \a A ('seq_cst', |
||
1352 | /// 'acq_rel' or 'relaxed'). |
||
1353 | /// |
||
1354 | /// \param A Argument of the clause ('seq_cst', 'acq_rel' or 'relaxed'). |
||
1355 | /// \param ALoc Starting location of the argument. |
||
1356 | /// \param StartLoc Starting location of the clause. |
||
1357 | /// \param LParenLoc Location of '('. |
||
1358 | /// \param EndLoc Ending location of the clause. |
||
1359 | OMPAtomicDefaultMemOrderClause(OpenMPAtomicDefaultMemOrderClauseKind A, |
||
1360 | SourceLocation ALoc, SourceLocation StartLoc, |
||
1361 | SourceLocation LParenLoc, |
||
1362 | SourceLocation EndLoc) |
||
1363 | : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, StartLoc, EndLoc), |
||
1364 | LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {} |
||
1365 | |||
1366 | /// Build an empty clause. |
||
1367 | OMPAtomicDefaultMemOrderClause() |
||
1368 | : OMPClause(llvm::omp::OMPC_atomic_default_mem_order, SourceLocation(), |
||
1369 | SourceLocation()) {} |
||
1370 | |||
1371 | /// Sets the location of '('. |
||
1372 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1373 | |||
1374 | /// Returns the locaiton of '('. |
||
1375 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
1376 | |||
1377 | /// Returns kind of the clause. |
||
1378 | OpenMPAtomicDefaultMemOrderClauseKind getAtomicDefaultMemOrderKind() const { |
||
1379 | return Kind; |
||
1380 | } |
||
1381 | |||
1382 | /// Returns location of clause kind. |
||
1383 | SourceLocation getAtomicDefaultMemOrderKindKwLoc() const { return KindKwLoc; } |
||
1384 | |||
1385 | child_range children() { |
||
1386 | return child_range(child_iterator(), child_iterator()); |
||
1387 | } |
||
1388 | |||
1389 | const_child_range children() const { |
||
1390 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1391 | } |
||
1392 | |||
1393 | child_range used_children() { |
||
1394 | return child_range(child_iterator(), child_iterator()); |
||
1395 | } |
||
1396 | const_child_range used_children() const { |
||
1397 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1398 | } |
||
1399 | |||
1400 | static bool classof(const OMPClause *T) { |
||
1401 | return T->getClauseKind() == llvm::omp::OMPC_atomic_default_mem_order; |
||
1402 | } |
||
1403 | }; |
||
1404 | |||
1405 | /// This represents 'at' clause in the '#pragma omp error' directive |
||
1406 | /// |
||
1407 | /// \code |
||
1408 | /// #pragma omp error at(compilation) |
||
1409 | /// \endcode |
||
1410 | /// In this example directive '#pragma omp error' has simple |
||
1411 | /// 'at' clause with kind 'complilation'. |
||
1412 | class OMPAtClause final : public OMPClause { |
||
1413 | friend class OMPClauseReader; |
||
1414 | |||
1415 | /// Location of '(' |
||
1416 | SourceLocation LParenLoc; |
||
1417 | |||
1418 | /// A kind of the 'at' clause. |
||
1419 | OpenMPAtClauseKind Kind = OMPC_AT_unknown; |
||
1420 | |||
1421 | /// Start location of the kind in source code. |
||
1422 | SourceLocation KindKwLoc; |
||
1423 | |||
1424 | /// Set kind of the clause. |
||
1425 | /// |
||
1426 | /// \param K Kind of clause. |
||
1427 | void setAtKind(OpenMPAtClauseKind K) { Kind = K; } |
||
1428 | |||
1429 | /// Set clause kind location. |
||
1430 | /// |
||
1431 | /// \param KLoc Kind location. |
||
1432 | void setAtKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; } |
||
1433 | |||
1434 | /// Sets the location of '('. |
||
1435 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1436 | |||
1437 | public: |
||
1438 | /// Build 'at' clause with argument \a A ('compilation' or 'execution'). |
||
1439 | /// |
||
1440 | /// \param A Argument of the clause ('compilation' or 'execution'). |
||
1441 | /// \param ALoc Starting location of the argument. |
||
1442 | /// \param StartLoc Starting location of the clause. |
||
1443 | /// \param LParenLoc Location of '('. |
||
1444 | /// \param EndLoc Ending location of the clause. |
||
1445 | OMPAtClause(OpenMPAtClauseKind A, SourceLocation ALoc, |
||
1446 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
1447 | SourceLocation EndLoc) |
||
1448 | : OMPClause(llvm::omp::OMPC_at, StartLoc, EndLoc), LParenLoc(LParenLoc), |
||
1449 | Kind(A), KindKwLoc(ALoc) {} |
||
1450 | |||
1451 | /// Build an empty clause. |
||
1452 | OMPAtClause() |
||
1453 | : OMPClause(llvm::omp::OMPC_at, SourceLocation(), SourceLocation()) {} |
||
1454 | |||
1455 | /// Returns the locaiton of '('. |
||
1456 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
1457 | |||
1458 | /// Returns kind of the clause. |
||
1459 | OpenMPAtClauseKind getAtKind() const { return Kind; } |
||
1460 | |||
1461 | /// Returns location of clause kind. |
||
1462 | SourceLocation getAtKindKwLoc() const { return KindKwLoc; } |
||
1463 | |||
1464 | child_range children() { |
||
1465 | return child_range(child_iterator(), child_iterator()); |
||
1466 | } |
||
1467 | |||
1468 | const_child_range children() const { |
||
1469 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1470 | } |
||
1471 | |||
1472 | child_range used_children() { |
||
1473 | return child_range(child_iterator(), child_iterator()); |
||
1474 | } |
||
1475 | const_child_range used_children() const { |
||
1476 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1477 | } |
||
1478 | |||
1479 | static bool classof(const OMPClause *T) { |
||
1480 | return T->getClauseKind() == llvm::omp::OMPC_at; |
||
1481 | } |
||
1482 | }; |
||
1483 | |||
1484 | /// This represents 'severity' clause in the '#pragma omp error' directive |
||
1485 | /// |
||
1486 | /// \code |
||
1487 | /// #pragma omp error severity(fatal) |
||
1488 | /// \endcode |
||
1489 | /// In this example directive '#pragma omp error' has simple |
||
1490 | /// 'severity' clause with kind 'fatal'. |
||
1491 | class OMPSeverityClause final : public OMPClause { |
||
1492 | friend class OMPClauseReader; |
||
1493 | |||
1494 | /// Location of '(' |
||
1495 | SourceLocation LParenLoc; |
||
1496 | |||
1497 | /// A kind of the 'severity' clause. |
||
1498 | OpenMPSeverityClauseKind Kind = OMPC_SEVERITY_unknown; |
||
1499 | |||
1500 | /// Start location of the kind in source code. |
||
1501 | SourceLocation KindKwLoc; |
||
1502 | |||
1503 | /// Set kind of the clause. |
||
1504 | /// |
||
1505 | /// \param K Kind of clause. |
||
1506 | void setSeverityKind(OpenMPSeverityClauseKind K) { Kind = K; } |
||
1507 | |||
1508 | /// Set clause kind location. |
||
1509 | /// |
||
1510 | /// \param KLoc Kind location. |
||
1511 | void setSeverityKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; } |
||
1512 | |||
1513 | /// Sets the location of '('. |
||
1514 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1515 | |||
1516 | public: |
||
1517 | /// Build 'severity' clause with argument \a A ('fatal' or 'warning'). |
||
1518 | /// |
||
1519 | /// \param A Argument of the clause ('fatal' or 'warning'). |
||
1520 | /// \param ALoc Starting location of the argument. |
||
1521 | /// \param StartLoc Starting location of the clause. |
||
1522 | /// \param LParenLoc Location of '('. |
||
1523 | /// \param EndLoc Ending location of the clause. |
||
1524 | OMPSeverityClause(OpenMPSeverityClauseKind A, SourceLocation ALoc, |
||
1525 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
1526 | SourceLocation EndLoc) |
||
1527 | : OMPClause(llvm::omp::OMPC_severity, StartLoc, EndLoc), |
||
1528 | LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc) {} |
||
1529 | |||
1530 | /// Build an empty clause. |
||
1531 | OMPSeverityClause() |
||
1532 | : OMPClause(llvm::omp::OMPC_severity, SourceLocation(), |
||
1533 | SourceLocation()) {} |
||
1534 | |||
1535 | /// Returns the locaiton of '('. |
||
1536 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
1537 | |||
1538 | /// Returns kind of the clause. |
||
1539 | OpenMPSeverityClauseKind getSeverityKind() const { return Kind; } |
||
1540 | |||
1541 | /// Returns location of clause kind. |
||
1542 | SourceLocation getSeverityKindKwLoc() const { return KindKwLoc; } |
||
1543 | |||
1544 | child_range children() { |
||
1545 | return child_range(child_iterator(), child_iterator()); |
||
1546 | } |
||
1547 | |||
1548 | const_child_range children() const { |
||
1549 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1550 | } |
||
1551 | |||
1552 | child_range used_children() { |
||
1553 | return child_range(child_iterator(), child_iterator()); |
||
1554 | } |
||
1555 | const_child_range used_children() const { |
||
1556 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1557 | } |
||
1558 | |||
1559 | static bool classof(const OMPClause *T) { |
||
1560 | return T->getClauseKind() == llvm::omp::OMPC_severity; |
||
1561 | } |
||
1562 | }; |
||
1563 | |||
1564 | /// This represents 'message' clause in the '#pragma omp error' directive |
||
1565 | /// |
||
1566 | /// \code |
||
1567 | /// #pragma omp error message("GNU compiler required.") |
||
1568 | /// \endcode |
||
1569 | /// In this example directive '#pragma omp error' has simple |
||
1570 | /// 'message' clause with user error message of "GNU compiler required.". |
||
1571 | class OMPMessageClause final : public OMPClause { |
||
1572 | friend class OMPClauseReader; |
||
1573 | |||
1574 | /// Location of '(' |
||
1575 | SourceLocation LParenLoc; |
||
1576 | |||
1577 | // Expression of the 'message' clause. |
||
1578 | Stmt *MessageString = nullptr; |
||
1579 | |||
1580 | /// Set message string of the clause. |
||
1581 | void setMessageString(Expr *MS) { MessageString = MS; } |
||
1582 | |||
1583 | /// Sets the location of '('. |
||
1584 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1585 | |||
1586 | public: |
||
1587 | /// Build 'message' clause with message string argument |
||
1588 | /// |
||
1589 | /// \param MS Argument of the clause (message string). |
||
1590 | /// \param StartLoc Starting location of the clause. |
||
1591 | /// \param LParenLoc Location of '('. |
||
1592 | /// \param EndLoc Ending location of the clause. |
||
1593 | OMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
1594 | SourceLocation EndLoc) |
||
1595 | : OMPClause(llvm::omp::OMPC_message, StartLoc, EndLoc), |
||
1596 | LParenLoc(LParenLoc), MessageString(MS) {} |
||
1597 | |||
1598 | /// Build an empty clause. |
||
1599 | OMPMessageClause() |
||
1600 | : OMPClause(llvm::omp::OMPC_message, SourceLocation(), SourceLocation()) { |
||
1601 | } |
||
1602 | |||
1603 | /// Returns the locaiton of '('. |
||
1604 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
1605 | |||
1606 | /// Returns message string of the clause. |
||
1607 | Expr *getMessageString() const { return cast_or_null<Expr>(MessageString); } |
||
1608 | |||
1609 | child_range children() { |
||
1610 | return child_range(&MessageString, &MessageString + 1); |
||
1611 | } |
||
1612 | |||
1613 | const_child_range children() const { |
||
1614 | return const_child_range(&MessageString, &MessageString + 1); |
||
1615 | } |
||
1616 | |||
1617 | child_range used_children() { |
||
1618 | return child_range(child_iterator(), child_iterator()); |
||
1619 | } |
||
1620 | |||
1621 | const_child_range used_children() const { |
||
1622 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1623 | } |
||
1624 | |||
1625 | static bool classof(const OMPClause *T) { |
||
1626 | return T->getClauseKind() == llvm::omp::OMPC_message; |
||
1627 | } |
||
1628 | }; |
||
1629 | |||
1630 | /// This represents 'schedule' clause in the '#pragma omp ...' directive. |
||
1631 | /// |
||
1632 | /// \code |
||
1633 | /// #pragma omp for schedule(static, 3) |
||
1634 | /// \endcode |
||
1635 | /// In this example directive '#pragma omp for' has 'schedule' clause with |
||
1636 | /// arguments 'static' and '3'. |
||
1637 | class OMPScheduleClause : public OMPClause, public OMPClauseWithPreInit { |
||
1638 | friend class OMPClauseReader; |
||
1639 | |||
1640 | /// Location of '('. |
||
1641 | SourceLocation LParenLoc; |
||
1642 | |||
1643 | /// A kind of the 'schedule' clause. |
||
1644 | OpenMPScheduleClauseKind Kind = OMPC_SCHEDULE_unknown; |
||
1645 | |||
1646 | /// Modifiers for 'schedule' clause. |
||
1647 | enum {FIRST, SECOND, NUM_MODIFIERS}; |
||
1648 | OpenMPScheduleClauseModifier Modifiers[NUM_MODIFIERS]; |
||
1649 | |||
1650 | /// Locations of modifiers. |
||
1651 | SourceLocation ModifiersLoc[NUM_MODIFIERS]; |
||
1652 | |||
1653 | /// Start location of the schedule ind in source code. |
||
1654 | SourceLocation KindLoc; |
||
1655 | |||
1656 | /// Location of ',' (if any). |
||
1657 | SourceLocation CommaLoc; |
||
1658 | |||
1659 | /// Chunk size. |
||
1660 | Expr *ChunkSize = nullptr; |
||
1661 | |||
1662 | /// Set schedule kind. |
||
1663 | /// |
||
1664 | /// \param K Schedule kind. |
||
1665 | void setScheduleKind(OpenMPScheduleClauseKind K) { Kind = K; } |
||
1666 | |||
1667 | /// Set the first schedule modifier. |
||
1668 | /// |
||
1669 | /// \param M Schedule modifier. |
||
1670 | void setFirstScheduleModifier(OpenMPScheduleClauseModifier M) { |
||
1671 | Modifiers[FIRST] = M; |
||
1672 | } |
||
1673 | |||
1674 | /// Set the second schedule modifier. |
||
1675 | /// |
||
1676 | /// \param M Schedule modifier. |
||
1677 | void setSecondScheduleModifier(OpenMPScheduleClauseModifier M) { |
||
1678 | Modifiers[SECOND] = M; |
||
1679 | } |
||
1680 | |||
1681 | /// Set location of the first schedule modifier. |
||
1682 | void setFirstScheduleModifierLoc(SourceLocation Loc) { |
||
1683 | ModifiersLoc[FIRST] = Loc; |
||
1684 | } |
||
1685 | |||
1686 | /// Set location of the second schedule modifier. |
||
1687 | void setSecondScheduleModifierLoc(SourceLocation Loc) { |
||
1688 | ModifiersLoc[SECOND] = Loc; |
||
1689 | } |
||
1690 | |||
1691 | /// Set schedule modifier location. |
||
1692 | /// |
||
1693 | /// \param M Schedule modifier location. |
||
1694 | void setScheduleModifer(OpenMPScheduleClauseModifier M) { |
||
1695 | if (Modifiers[FIRST] == OMPC_SCHEDULE_MODIFIER_unknown) |
||
1696 | Modifiers[FIRST] = M; |
||
1697 | else { |
||
1698 | assert(Modifiers[SECOND] == OMPC_SCHEDULE_MODIFIER_unknown); |
||
1699 | Modifiers[SECOND] = M; |
||
1700 | } |
||
1701 | } |
||
1702 | |||
1703 | /// Sets the location of '('. |
||
1704 | /// |
||
1705 | /// \param Loc Location of '('. |
||
1706 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1707 | |||
1708 | /// Set schedule kind start location. |
||
1709 | /// |
||
1710 | /// \param KLoc Schedule kind location. |
||
1711 | void setScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; } |
||
1712 | |||
1713 | /// Set location of ','. |
||
1714 | /// |
||
1715 | /// \param Loc Location of ','. |
||
1716 | void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; } |
||
1717 | |||
1718 | /// Set chunk size. |
||
1719 | /// |
||
1720 | /// \param E Chunk size. |
||
1721 | void setChunkSize(Expr *E) { ChunkSize = E; } |
||
1722 | |||
1723 | public: |
||
1724 | /// Build 'schedule' clause with schedule kind \a Kind and chunk size |
||
1725 | /// expression \a ChunkSize. |
||
1726 | /// |
||
1727 | /// \param StartLoc Starting location of the clause. |
||
1728 | /// \param LParenLoc Location of '('. |
||
1729 | /// \param KLoc Starting location of the argument. |
||
1730 | /// \param CommaLoc Location of ','. |
||
1731 | /// \param EndLoc Ending location of the clause. |
||
1732 | /// \param Kind Schedule kind. |
||
1733 | /// \param ChunkSize Chunk size. |
||
1734 | /// \param HelperChunkSize Helper chunk size for combined directives. |
||
1735 | /// \param M1 The first modifier applied to 'schedule' clause. |
||
1736 | /// \param M1Loc Location of the first modifier |
||
1737 | /// \param M2 The second modifier applied to 'schedule' clause. |
||
1738 | /// \param M2Loc Location of the second modifier |
||
1739 | OMPScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
1740 | SourceLocation KLoc, SourceLocation CommaLoc, |
||
1741 | SourceLocation EndLoc, OpenMPScheduleClauseKind Kind, |
||
1742 | Expr *ChunkSize, Stmt *HelperChunkSize, |
||
1743 | OpenMPScheduleClauseModifier M1, SourceLocation M1Loc, |
||
1744 | OpenMPScheduleClauseModifier M2, SourceLocation M2Loc) |
||
1745 | : OMPClause(llvm::omp::OMPC_schedule, StartLoc, EndLoc), |
||
1746 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind), |
||
1747 | KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) { |
||
1748 | setPreInitStmt(HelperChunkSize); |
||
1749 | Modifiers[FIRST] = M1; |
||
1750 | Modifiers[SECOND] = M2; |
||
1751 | ModifiersLoc[FIRST] = M1Loc; |
||
1752 | ModifiersLoc[SECOND] = M2Loc; |
||
1753 | } |
||
1754 | |||
1755 | /// Build an empty clause. |
||
1756 | explicit OMPScheduleClause() |
||
1757 | : OMPClause(llvm::omp::OMPC_schedule, SourceLocation(), SourceLocation()), |
||
1758 | OMPClauseWithPreInit(this) { |
||
1759 | Modifiers[FIRST] = OMPC_SCHEDULE_MODIFIER_unknown; |
||
1760 | Modifiers[SECOND] = OMPC_SCHEDULE_MODIFIER_unknown; |
||
1761 | } |
||
1762 | |||
1763 | /// Get kind of the clause. |
||
1764 | OpenMPScheduleClauseKind getScheduleKind() const { return Kind; } |
||
1765 | |||
1766 | /// Get the first modifier of the clause. |
||
1767 | OpenMPScheduleClauseModifier getFirstScheduleModifier() const { |
||
1768 | return Modifiers[FIRST]; |
||
1769 | } |
||
1770 | |||
1771 | /// Get the second modifier of the clause. |
||
1772 | OpenMPScheduleClauseModifier getSecondScheduleModifier() const { |
||
1773 | return Modifiers[SECOND]; |
||
1774 | } |
||
1775 | |||
1776 | /// Get location of '('. |
||
1777 | SourceLocation getLParenLoc() { return LParenLoc; } |
||
1778 | |||
1779 | /// Get kind location. |
||
1780 | SourceLocation getScheduleKindLoc() { return KindLoc; } |
||
1781 | |||
1782 | /// Get the first modifier location. |
||
1783 | SourceLocation getFirstScheduleModifierLoc() const { |
||
1784 | return ModifiersLoc[FIRST]; |
||
1785 | } |
||
1786 | |||
1787 | /// Get the second modifier location. |
||
1788 | SourceLocation getSecondScheduleModifierLoc() const { |
||
1789 | return ModifiersLoc[SECOND]; |
||
1790 | } |
||
1791 | |||
1792 | /// Get location of ','. |
||
1793 | SourceLocation getCommaLoc() { return CommaLoc; } |
||
1794 | |||
1795 | /// Get chunk size. |
||
1796 | Expr *getChunkSize() { return ChunkSize; } |
||
1797 | |||
1798 | /// Get chunk size. |
||
1799 | const Expr *getChunkSize() const { return ChunkSize; } |
||
1800 | |||
1801 | child_range children() { |
||
1802 | return child_range(reinterpret_cast<Stmt **>(&ChunkSize), |
||
1803 | reinterpret_cast<Stmt **>(&ChunkSize) + 1); |
||
1804 | } |
||
1805 | |||
1806 | const_child_range children() const { |
||
1807 | auto Children = const_cast<OMPScheduleClause *>(this)->children(); |
||
1808 | return const_child_range(Children.begin(), Children.end()); |
||
1809 | } |
||
1810 | |||
1811 | child_range used_children() { |
||
1812 | return child_range(child_iterator(), child_iterator()); |
||
1813 | } |
||
1814 | const_child_range used_children() const { |
||
1815 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1816 | } |
||
1817 | |||
1818 | static bool classof(const OMPClause *T) { |
||
1819 | return T->getClauseKind() == llvm::omp::OMPC_schedule; |
||
1820 | } |
||
1821 | }; |
||
1822 | |||
1823 | /// This represents 'ordered' clause in the '#pragma omp ...' directive. |
||
1824 | /// |
||
1825 | /// \code |
||
1826 | /// #pragma omp for ordered (2) |
||
1827 | /// \endcode |
||
1828 | /// In this example directive '#pragma omp for' has 'ordered' clause with |
||
1829 | /// parameter 2. |
||
1830 | class OMPOrderedClause final |
||
1831 | : public OMPClause, |
||
1832 | private llvm::TrailingObjects<OMPOrderedClause, Expr *> { |
||
1833 | friend class OMPClauseReader; |
||
1834 | friend TrailingObjects; |
||
1835 | |||
1836 | /// Location of '('. |
||
1837 | SourceLocation LParenLoc; |
||
1838 | |||
1839 | /// Number of for-loops. |
||
1840 | Stmt *NumForLoops = nullptr; |
||
1841 | |||
1842 | /// Real number of loops. |
||
1843 | unsigned NumberOfLoops = 0; |
||
1844 | |||
1845 | /// Build 'ordered' clause. |
||
1846 | /// |
||
1847 | /// \param Num Expression, possibly associated with this clause. |
||
1848 | /// \param NumLoops Number of loops, associated with this clause. |
||
1849 | /// \param StartLoc Starting location of the clause. |
||
1850 | /// \param LParenLoc Location of '('. |
||
1851 | /// \param EndLoc Ending location of the clause. |
||
1852 | OMPOrderedClause(Expr *Num, unsigned NumLoops, SourceLocation StartLoc, |
||
1853 | SourceLocation LParenLoc, SourceLocation EndLoc) |
||
1854 | : OMPClause(llvm::omp::OMPC_ordered, StartLoc, EndLoc), |
||
1855 | LParenLoc(LParenLoc), NumForLoops(Num), NumberOfLoops(NumLoops) {} |
||
1856 | |||
1857 | /// Build an empty clause. |
||
1858 | explicit OMPOrderedClause(unsigned NumLoops) |
||
1859 | : OMPClause(llvm::omp::OMPC_ordered, SourceLocation(), SourceLocation()), |
||
1860 | NumberOfLoops(NumLoops) {} |
||
1861 | |||
1862 | /// Set the number of associated for-loops. |
||
1863 | void setNumForLoops(Expr *Num) { NumForLoops = Num; } |
||
1864 | |||
1865 | public: |
||
1866 | /// Build 'ordered' clause. |
||
1867 | /// |
||
1868 | /// \param Num Expression, possibly associated with this clause. |
||
1869 | /// \param NumLoops Number of loops, associated with this clause. |
||
1870 | /// \param StartLoc Starting location of the clause. |
||
1871 | /// \param LParenLoc Location of '('. |
||
1872 | /// \param EndLoc Ending location of the clause. |
||
1873 | static OMPOrderedClause *Create(const ASTContext &C, Expr *Num, |
||
1874 | unsigned NumLoops, SourceLocation StartLoc, |
||
1875 | SourceLocation LParenLoc, |
||
1876 | SourceLocation EndLoc); |
||
1877 | |||
1878 | /// Build an empty clause. |
||
1879 | static OMPOrderedClause* CreateEmpty(const ASTContext &C, unsigned NumLoops); |
||
1880 | |||
1881 | /// Sets the location of '('. |
||
1882 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
1883 | |||
1884 | /// Returns the location of '('. |
||
1885 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
1886 | |||
1887 | /// Return the number of associated for-loops. |
||
1888 | Expr *getNumForLoops() const { return cast_or_null<Expr>(NumForLoops); } |
||
1889 | |||
1890 | /// Set number of iterations for the specified loop. |
||
1891 | void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations); |
||
1892 | /// Get number of iterations for all the loops. |
||
1893 | ArrayRef<Expr *> getLoopNumIterations() const; |
||
1894 | |||
1895 | /// Set loop counter for the specified loop. |
||
1896 | void setLoopCounter(unsigned NumLoop, Expr *Counter); |
||
1897 | /// Get loops counter for the specified loop. |
||
1898 | Expr *getLoopCounter(unsigned NumLoop); |
||
1899 | const Expr *getLoopCounter(unsigned NumLoop) const; |
||
1900 | |||
1901 | child_range children() { return child_range(&NumForLoops, &NumForLoops + 1); } |
||
1902 | |||
1903 | const_child_range children() const { |
||
1904 | return const_child_range(&NumForLoops, &NumForLoops + 1); |
||
1905 | } |
||
1906 | |||
1907 | child_range used_children() { |
||
1908 | return child_range(child_iterator(), child_iterator()); |
||
1909 | } |
||
1910 | const_child_range used_children() const { |
||
1911 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1912 | } |
||
1913 | |||
1914 | static bool classof(const OMPClause *T) { |
||
1915 | return T->getClauseKind() == llvm::omp::OMPC_ordered; |
||
1916 | } |
||
1917 | }; |
||
1918 | |||
1919 | /// This represents 'nowait' clause in the '#pragma omp ...' directive. |
||
1920 | /// |
||
1921 | /// \code |
||
1922 | /// #pragma omp for nowait |
||
1923 | /// \endcode |
||
1924 | /// In this example directive '#pragma omp for' has 'nowait' clause. |
||
1925 | class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> { |
||
1926 | public: |
||
1927 | /// Build 'nowait' clause. |
||
1928 | /// |
||
1929 | /// \param StartLoc Starting location of the clause. |
||
1930 | /// \param EndLoc Ending location of the clause. |
||
1931 | OMPNowaitClause(SourceLocation StartLoc = SourceLocation(), |
||
1932 | SourceLocation EndLoc = SourceLocation()) |
||
1933 | : OMPNoChildClause(StartLoc, EndLoc) {} |
||
1934 | }; |
||
1935 | |||
1936 | /// This represents 'untied' clause in the '#pragma omp ...' directive. |
||
1937 | /// |
||
1938 | /// \code |
||
1939 | /// #pragma omp task untied |
||
1940 | /// \endcode |
||
1941 | /// In this example directive '#pragma omp task' has 'untied' clause. |
||
1942 | class OMPUntiedClause : public OMPClause { |
||
1943 | public: |
||
1944 | /// Build 'untied' clause. |
||
1945 | /// |
||
1946 | /// \param StartLoc Starting location of the clause. |
||
1947 | /// \param EndLoc Ending location of the clause. |
||
1948 | OMPUntiedClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
1949 | : OMPClause(llvm::omp::OMPC_untied, StartLoc, EndLoc) {} |
||
1950 | |||
1951 | /// Build an empty clause. |
||
1952 | OMPUntiedClause() |
||
1953 | : OMPClause(llvm::omp::OMPC_untied, SourceLocation(), SourceLocation()) {} |
||
1954 | |||
1955 | child_range children() { |
||
1956 | return child_range(child_iterator(), child_iterator()); |
||
1957 | } |
||
1958 | |||
1959 | const_child_range children() const { |
||
1960 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1961 | } |
||
1962 | |||
1963 | child_range used_children() { |
||
1964 | return child_range(child_iterator(), child_iterator()); |
||
1965 | } |
||
1966 | const_child_range used_children() const { |
||
1967 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
1968 | } |
||
1969 | |||
1970 | static bool classof(const OMPClause *T) { |
||
1971 | return T->getClauseKind() == llvm::omp::OMPC_untied; |
||
1972 | } |
||
1973 | }; |
||
1974 | |||
1975 | /// This represents 'mergeable' clause in the '#pragma omp ...' |
||
1976 | /// directive. |
||
1977 | /// |
||
1978 | /// \code |
||
1979 | /// #pragma omp task mergeable |
||
1980 | /// \endcode |
||
1981 | /// In this example directive '#pragma omp task' has 'mergeable' clause. |
||
1982 | class OMPMergeableClause : public OMPClause { |
||
1983 | public: |
||
1984 | /// Build 'mergeable' clause. |
||
1985 | /// |
||
1986 | /// \param StartLoc Starting location of the clause. |
||
1987 | /// \param EndLoc Ending location of the clause. |
||
1988 | OMPMergeableClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
1989 | : OMPClause(llvm::omp::OMPC_mergeable, StartLoc, EndLoc) {} |
||
1990 | |||
1991 | /// Build an empty clause. |
||
1992 | OMPMergeableClause() |
||
1993 | : OMPClause(llvm::omp::OMPC_mergeable, SourceLocation(), |
||
1994 | SourceLocation()) {} |
||
1995 | |||
1996 | child_range children() { |
||
1997 | return child_range(child_iterator(), child_iterator()); |
||
1998 | } |
||
1999 | |||
2000 | const_child_range children() const { |
||
2001 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2002 | } |
||
2003 | |||
2004 | child_range used_children() { |
||
2005 | return child_range(child_iterator(), child_iterator()); |
||
2006 | } |
||
2007 | const_child_range used_children() const { |
||
2008 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2009 | } |
||
2010 | |||
2011 | static bool classof(const OMPClause *T) { |
||
2012 | return T->getClauseKind() == llvm::omp::OMPC_mergeable; |
||
2013 | } |
||
2014 | }; |
||
2015 | |||
2016 | /// This represents 'read' clause in the '#pragma omp atomic' directive. |
||
2017 | /// |
||
2018 | /// \code |
||
2019 | /// #pragma omp atomic read |
||
2020 | /// \endcode |
||
2021 | /// In this example directive '#pragma omp atomic' has 'read' clause. |
||
2022 | class OMPReadClause : public OMPClause { |
||
2023 | public: |
||
2024 | /// Build 'read' clause. |
||
2025 | /// |
||
2026 | /// \param StartLoc Starting location of the clause. |
||
2027 | /// \param EndLoc Ending location of the clause. |
||
2028 | OMPReadClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2029 | : OMPClause(llvm::omp::OMPC_read, StartLoc, EndLoc) {} |
||
2030 | |||
2031 | /// Build an empty clause. |
||
2032 | OMPReadClause() |
||
2033 | : OMPClause(llvm::omp::OMPC_read, SourceLocation(), SourceLocation()) {} |
||
2034 | |||
2035 | child_range children() { |
||
2036 | return child_range(child_iterator(), child_iterator()); |
||
2037 | } |
||
2038 | |||
2039 | const_child_range children() const { |
||
2040 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2041 | } |
||
2042 | |||
2043 | child_range used_children() { |
||
2044 | return child_range(child_iterator(), child_iterator()); |
||
2045 | } |
||
2046 | const_child_range used_children() const { |
||
2047 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2048 | } |
||
2049 | |||
2050 | static bool classof(const OMPClause *T) { |
||
2051 | return T->getClauseKind() == llvm::omp::OMPC_read; |
||
2052 | } |
||
2053 | }; |
||
2054 | |||
2055 | /// This represents 'write' clause in the '#pragma omp atomic' directive. |
||
2056 | /// |
||
2057 | /// \code |
||
2058 | /// #pragma omp atomic write |
||
2059 | /// \endcode |
||
2060 | /// In this example directive '#pragma omp atomic' has 'write' clause. |
||
2061 | class OMPWriteClause : public OMPClause { |
||
2062 | public: |
||
2063 | /// Build 'write' clause. |
||
2064 | /// |
||
2065 | /// \param StartLoc Starting location of the clause. |
||
2066 | /// \param EndLoc Ending location of the clause. |
||
2067 | OMPWriteClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2068 | : OMPClause(llvm::omp::OMPC_write, StartLoc, EndLoc) {} |
||
2069 | |||
2070 | /// Build an empty clause. |
||
2071 | OMPWriteClause() |
||
2072 | : OMPClause(llvm::omp::OMPC_write, SourceLocation(), SourceLocation()) {} |
||
2073 | |||
2074 | child_range children() { |
||
2075 | return child_range(child_iterator(), child_iterator()); |
||
2076 | } |
||
2077 | |||
2078 | const_child_range children() const { |
||
2079 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2080 | } |
||
2081 | |||
2082 | child_range used_children() { |
||
2083 | return child_range(child_iterator(), child_iterator()); |
||
2084 | } |
||
2085 | const_child_range used_children() const { |
||
2086 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2087 | } |
||
2088 | |||
2089 | static bool classof(const OMPClause *T) { |
||
2090 | return T->getClauseKind() == llvm::omp::OMPC_write; |
||
2091 | } |
||
2092 | }; |
||
2093 | |||
2094 | /// This represents 'update' clause in the '#pragma omp atomic' |
||
2095 | /// directive. |
||
2096 | /// |
||
2097 | /// \code |
||
2098 | /// #pragma omp atomic update |
||
2099 | /// \endcode |
||
2100 | /// In this example directive '#pragma omp atomic' has 'update' clause. |
||
2101 | /// Also, this class represents 'update' clause in '#pragma omp depobj' |
||
2102 | /// directive. |
||
2103 | /// |
||
2104 | /// \code |
||
2105 | /// #pragma omp depobj(a) update(in) |
||
2106 | /// \endcode |
||
2107 | /// In this example directive '#pragma omp depobj' has 'update' clause with 'in' |
||
2108 | /// dependence kind. |
||
2109 | class OMPUpdateClause final |
||
2110 | : public OMPClause, |
||
2111 | private llvm::TrailingObjects<OMPUpdateClause, SourceLocation, |
||
2112 | OpenMPDependClauseKind> { |
||
2113 | friend class OMPClauseReader; |
||
2114 | friend TrailingObjects; |
||
2115 | |||
2116 | /// true if extended version of the clause for 'depobj' directive. |
||
2117 | bool IsExtended = false; |
||
2118 | |||
2119 | /// Define the sizes of each trailing object array except the last one. This |
||
2120 | /// is required for TrailingObjects to work properly. |
||
2121 | size_t numTrailingObjects(OverloadToken<SourceLocation>) const { |
||
2122 | // 2 locations: for '(' and argument location. |
||
2123 | return IsExtended ? 2 : 0; |
||
2124 | } |
||
2125 | |||
2126 | /// Sets the location of '(' in clause for 'depobj' directive. |
||
2127 | void setLParenLoc(SourceLocation Loc) { |
||
2128 | assert(IsExtended && "Expected extended clause."); |
||
2129 | *getTrailingObjects<SourceLocation>() = Loc; |
||
2130 | } |
||
2131 | |||
2132 | /// Sets the location of '(' in clause for 'depobj' directive. |
||
2133 | void setArgumentLoc(SourceLocation Loc) { |
||
2134 | assert(IsExtended && "Expected extended clause."); |
||
2135 | *std::next(getTrailingObjects<SourceLocation>(), 1) = Loc; |
||
2136 | } |
||
2137 | |||
2138 | /// Sets the dependence kind for the clause for 'depobj' directive. |
||
2139 | void setDependencyKind(OpenMPDependClauseKind DK) { |
||
2140 | assert(IsExtended && "Expected extended clause."); |
||
2141 | *getTrailingObjects<OpenMPDependClauseKind>() = DK; |
||
2142 | } |
||
2143 | |||
2144 | /// Build 'update' clause. |
||
2145 | /// |
||
2146 | /// \param StartLoc Starting location of the clause. |
||
2147 | /// \param EndLoc Ending location of the clause. |
||
2148 | OMPUpdateClause(SourceLocation StartLoc, SourceLocation EndLoc, |
||
2149 | bool IsExtended) |
||
2150 | : OMPClause(llvm::omp::OMPC_update, StartLoc, EndLoc), |
||
2151 | IsExtended(IsExtended) {} |
||
2152 | |||
2153 | /// Build an empty clause. |
||
2154 | OMPUpdateClause(bool IsExtended) |
||
2155 | : OMPClause(llvm::omp::OMPC_update, SourceLocation(), SourceLocation()), |
||
2156 | IsExtended(IsExtended) {} |
||
2157 | |||
2158 | public: |
||
2159 | /// Creates clause for 'atomic' directive. |
||
2160 | /// |
||
2161 | /// \param C AST context. |
||
2162 | /// \param StartLoc Starting location of the clause. |
||
2163 | /// \param EndLoc Ending location of the clause. |
||
2164 | static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
2165 | SourceLocation EndLoc); |
||
2166 | |||
2167 | /// Creates clause for 'depobj' directive. |
||
2168 | /// |
||
2169 | /// \param C AST context. |
||
2170 | /// \param StartLoc Starting location of the clause. |
||
2171 | /// \param LParenLoc Location of '('. |
||
2172 | /// \param ArgumentLoc Location of the argument. |
||
2173 | /// \param DK Dependence kind. |
||
2174 | /// \param EndLoc Ending location of the clause. |
||
2175 | static OMPUpdateClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
2176 | SourceLocation LParenLoc, |
||
2177 | SourceLocation ArgumentLoc, |
||
2178 | OpenMPDependClauseKind DK, |
||
2179 | SourceLocation EndLoc); |
||
2180 | |||
2181 | /// Creates an empty clause with the place for \a N variables. |
||
2182 | /// |
||
2183 | /// \param C AST context. |
||
2184 | /// \param IsExtended true if extended clause for 'depobj' directive must be |
||
2185 | /// created. |
||
2186 | static OMPUpdateClause *CreateEmpty(const ASTContext &C, bool IsExtended); |
||
2187 | |||
2188 | /// Checks if the clause is the extended clauses for 'depobj' directive. |
||
2189 | bool isExtended() const { return IsExtended; } |
||
2190 | |||
2191 | child_range children() { |
||
2192 | return child_range(child_iterator(), child_iterator()); |
||
2193 | } |
||
2194 | |||
2195 | const_child_range children() const { |
||
2196 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2197 | } |
||
2198 | |||
2199 | child_range used_children() { |
||
2200 | return child_range(child_iterator(), child_iterator()); |
||
2201 | } |
||
2202 | const_child_range used_children() const { |
||
2203 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2204 | } |
||
2205 | |||
2206 | /// Gets the location of '(' in clause for 'depobj' directive. |
||
2207 | SourceLocation getLParenLoc() const { |
||
2208 | assert(IsExtended && "Expected extended clause."); |
||
2209 | return *getTrailingObjects<SourceLocation>(); |
||
2210 | } |
||
2211 | |||
2212 | /// Gets the location of argument in clause for 'depobj' directive. |
||
2213 | SourceLocation getArgumentLoc() const { |
||
2214 | assert(IsExtended && "Expected extended clause."); |
||
2215 | return *std::next(getTrailingObjects<SourceLocation>(), 1); |
||
2216 | } |
||
2217 | |||
2218 | /// Gets the dependence kind in clause for 'depobj' directive. |
||
2219 | OpenMPDependClauseKind getDependencyKind() const { |
||
2220 | assert(IsExtended && "Expected extended clause."); |
||
2221 | return *getTrailingObjects<OpenMPDependClauseKind>(); |
||
2222 | } |
||
2223 | |||
2224 | static bool classof(const OMPClause *T) { |
||
2225 | return T->getClauseKind() == llvm::omp::OMPC_update; |
||
2226 | } |
||
2227 | }; |
||
2228 | |||
2229 | /// This represents 'capture' clause in the '#pragma omp atomic' |
||
2230 | /// directive. |
||
2231 | /// |
||
2232 | /// \code |
||
2233 | /// #pragma omp atomic capture |
||
2234 | /// \endcode |
||
2235 | /// In this example directive '#pragma omp atomic' has 'capture' clause. |
||
2236 | class OMPCaptureClause : public OMPClause { |
||
2237 | public: |
||
2238 | /// Build 'capture' clause. |
||
2239 | /// |
||
2240 | /// \param StartLoc Starting location of the clause. |
||
2241 | /// \param EndLoc Ending location of the clause. |
||
2242 | OMPCaptureClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2243 | : OMPClause(llvm::omp::OMPC_capture, StartLoc, EndLoc) {} |
||
2244 | |||
2245 | /// Build an empty clause. |
||
2246 | OMPCaptureClause() |
||
2247 | : OMPClause(llvm::omp::OMPC_capture, SourceLocation(), SourceLocation()) { |
||
2248 | } |
||
2249 | |||
2250 | child_range children() { |
||
2251 | return child_range(child_iterator(), child_iterator()); |
||
2252 | } |
||
2253 | |||
2254 | const_child_range children() const { |
||
2255 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2256 | } |
||
2257 | |||
2258 | child_range used_children() { |
||
2259 | return child_range(child_iterator(), child_iterator()); |
||
2260 | } |
||
2261 | const_child_range used_children() const { |
||
2262 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2263 | } |
||
2264 | |||
2265 | static bool classof(const OMPClause *T) { |
||
2266 | return T->getClauseKind() == llvm::omp::OMPC_capture; |
||
2267 | } |
||
2268 | }; |
||
2269 | |||
2270 | /// This represents 'compare' clause in the '#pragma omp atomic' |
||
2271 | /// directive. |
||
2272 | /// |
||
2273 | /// \code |
||
2274 | /// #pragma omp atomic compare |
||
2275 | /// \endcode |
||
2276 | /// In this example directive '#pragma omp atomic' has 'compare' clause. |
||
2277 | class OMPCompareClause final : public OMPClause { |
||
2278 | public: |
||
2279 | /// Build 'compare' clause. |
||
2280 | /// |
||
2281 | /// \param StartLoc Starting location of the clause. |
||
2282 | /// \param EndLoc Ending location of the clause. |
||
2283 | OMPCompareClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2284 | : OMPClause(llvm::omp::OMPC_compare, StartLoc, EndLoc) {} |
||
2285 | |||
2286 | /// Build an empty clause. |
||
2287 | OMPCompareClause() |
||
2288 | : OMPClause(llvm::omp::OMPC_compare, SourceLocation(), SourceLocation()) { |
||
2289 | } |
||
2290 | |||
2291 | child_range children() { |
||
2292 | return child_range(child_iterator(), child_iterator()); |
||
2293 | } |
||
2294 | |||
2295 | const_child_range children() const { |
||
2296 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2297 | } |
||
2298 | |||
2299 | child_range used_children() { |
||
2300 | return child_range(child_iterator(), child_iterator()); |
||
2301 | } |
||
2302 | const_child_range used_children() const { |
||
2303 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2304 | } |
||
2305 | |||
2306 | static bool classof(const OMPClause *T) { |
||
2307 | return T->getClauseKind() == llvm::omp::OMPC_compare; |
||
2308 | } |
||
2309 | }; |
||
2310 | |||
2311 | /// This represents 'seq_cst' clause in the '#pragma omp atomic' |
||
2312 | /// directive. |
||
2313 | /// |
||
2314 | /// \code |
||
2315 | /// #pragma omp atomic seq_cst |
||
2316 | /// \endcode |
||
2317 | /// In this example directive '#pragma omp atomic' has 'seq_cst' clause. |
||
2318 | class OMPSeqCstClause : public OMPClause { |
||
2319 | public: |
||
2320 | /// Build 'seq_cst' clause. |
||
2321 | /// |
||
2322 | /// \param StartLoc Starting location of the clause. |
||
2323 | /// \param EndLoc Ending location of the clause. |
||
2324 | OMPSeqCstClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2325 | : OMPClause(llvm::omp::OMPC_seq_cst, StartLoc, EndLoc) {} |
||
2326 | |||
2327 | /// Build an empty clause. |
||
2328 | OMPSeqCstClause() |
||
2329 | : OMPClause(llvm::omp::OMPC_seq_cst, SourceLocation(), SourceLocation()) { |
||
2330 | } |
||
2331 | |||
2332 | child_range children() { |
||
2333 | return child_range(child_iterator(), child_iterator()); |
||
2334 | } |
||
2335 | |||
2336 | const_child_range children() const { |
||
2337 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2338 | } |
||
2339 | |||
2340 | child_range used_children() { |
||
2341 | return child_range(child_iterator(), child_iterator()); |
||
2342 | } |
||
2343 | const_child_range used_children() const { |
||
2344 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2345 | } |
||
2346 | |||
2347 | static bool classof(const OMPClause *T) { |
||
2348 | return T->getClauseKind() == llvm::omp::OMPC_seq_cst; |
||
2349 | } |
||
2350 | }; |
||
2351 | |||
2352 | /// This represents 'acq_rel' clause in the '#pragma omp atomic|flush' |
||
2353 | /// directives. |
||
2354 | /// |
||
2355 | /// \code |
||
2356 | /// #pragma omp flush acq_rel |
||
2357 | /// \endcode |
||
2358 | /// In this example directive '#pragma omp flush' has 'acq_rel' clause. |
||
2359 | class OMPAcqRelClause final : public OMPClause { |
||
2360 | public: |
||
2361 | /// Build 'ack_rel' clause. |
||
2362 | /// |
||
2363 | /// \param StartLoc Starting location of the clause. |
||
2364 | /// \param EndLoc Ending location of the clause. |
||
2365 | OMPAcqRelClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2366 | : OMPClause(llvm::omp::OMPC_acq_rel, StartLoc, EndLoc) {} |
||
2367 | |||
2368 | /// Build an empty clause. |
||
2369 | OMPAcqRelClause() |
||
2370 | : OMPClause(llvm::omp::OMPC_acq_rel, SourceLocation(), SourceLocation()) { |
||
2371 | } |
||
2372 | |||
2373 | child_range children() { |
||
2374 | return child_range(child_iterator(), child_iterator()); |
||
2375 | } |
||
2376 | |||
2377 | const_child_range children() const { |
||
2378 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2379 | } |
||
2380 | |||
2381 | child_range used_children() { |
||
2382 | return child_range(child_iterator(), child_iterator()); |
||
2383 | } |
||
2384 | const_child_range used_children() const { |
||
2385 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2386 | } |
||
2387 | |||
2388 | static bool classof(const OMPClause *T) { |
||
2389 | return T->getClauseKind() == llvm::omp::OMPC_acq_rel; |
||
2390 | } |
||
2391 | }; |
||
2392 | |||
2393 | /// This represents 'acquire' clause in the '#pragma omp atomic|flush' |
||
2394 | /// directives. |
||
2395 | /// |
||
2396 | /// \code |
||
2397 | /// #pragma omp flush acquire |
||
2398 | /// \endcode |
||
2399 | /// In this example directive '#pragma omp flush' has 'acquire' clause. |
||
2400 | class OMPAcquireClause final : public OMPClause { |
||
2401 | public: |
||
2402 | /// Build 'acquire' clause. |
||
2403 | /// |
||
2404 | /// \param StartLoc Starting location of the clause. |
||
2405 | /// \param EndLoc Ending location of the clause. |
||
2406 | OMPAcquireClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2407 | : OMPClause(llvm::omp::OMPC_acquire, StartLoc, EndLoc) {} |
||
2408 | |||
2409 | /// Build an empty clause. |
||
2410 | OMPAcquireClause() |
||
2411 | : OMPClause(llvm::omp::OMPC_acquire, SourceLocation(), SourceLocation()) { |
||
2412 | } |
||
2413 | |||
2414 | child_range children() { |
||
2415 | return child_range(child_iterator(), child_iterator()); |
||
2416 | } |
||
2417 | |||
2418 | const_child_range children() const { |
||
2419 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2420 | } |
||
2421 | |||
2422 | child_range used_children() { |
||
2423 | return child_range(child_iterator(), child_iterator()); |
||
2424 | } |
||
2425 | const_child_range used_children() const { |
||
2426 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2427 | } |
||
2428 | |||
2429 | static bool classof(const OMPClause *T) { |
||
2430 | return T->getClauseKind() == llvm::omp::OMPC_acquire; |
||
2431 | } |
||
2432 | }; |
||
2433 | |||
2434 | /// This represents 'release' clause in the '#pragma omp atomic|flush' |
||
2435 | /// directives. |
||
2436 | /// |
||
2437 | /// \code |
||
2438 | /// #pragma omp flush release |
||
2439 | /// \endcode |
||
2440 | /// In this example directive '#pragma omp flush' has 'release' clause. |
||
2441 | class OMPReleaseClause final : public OMPClause { |
||
2442 | public: |
||
2443 | /// Build 'release' clause. |
||
2444 | /// |
||
2445 | /// \param StartLoc Starting location of the clause. |
||
2446 | /// \param EndLoc Ending location of the clause. |
||
2447 | OMPReleaseClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2448 | : OMPClause(llvm::omp::OMPC_release, StartLoc, EndLoc) {} |
||
2449 | |||
2450 | /// Build an empty clause. |
||
2451 | OMPReleaseClause() |
||
2452 | : OMPClause(llvm::omp::OMPC_release, SourceLocation(), SourceLocation()) { |
||
2453 | } |
||
2454 | |||
2455 | child_range children() { |
||
2456 | return child_range(child_iterator(), child_iterator()); |
||
2457 | } |
||
2458 | |||
2459 | const_child_range children() const { |
||
2460 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2461 | } |
||
2462 | |||
2463 | child_range used_children() { |
||
2464 | return child_range(child_iterator(), child_iterator()); |
||
2465 | } |
||
2466 | const_child_range used_children() const { |
||
2467 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2468 | } |
||
2469 | |||
2470 | static bool classof(const OMPClause *T) { |
||
2471 | return T->getClauseKind() == llvm::omp::OMPC_release; |
||
2472 | } |
||
2473 | }; |
||
2474 | |||
2475 | /// This represents 'relaxed' clause in the '#pragma omp atomic' |
||
2476 | /// directives. |
||
2477 | /// |
||
2478 | /// \code |
||
2479 | /// #pragma omp atomic relaxed |
||
2480 | /// \endcode |
||
2481 | /// In this example directive '#pragma omp atomic' has 'relaxed' clause. |
||
2482 | class OMPRelaxedClause final : public OMPClause { |
||
2483 | public: |
||
2484 | /// Build 'relaxed' clause. |
||
2485 | /// |
||
2486 | /// \param StartLoc Starting location of the clause. |
||
2487 | /// \param EndLoc Ending location of the clause. |
||
2488 | OMPRelaxedClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
2489 | : OMPClause(llvm::omp::OMPC_relaxed, StartLoc, EndLoc) {} |
||
2490 | |||
2491 | /// Build an empty clause. |
||
2492 | OMPRelaxedClause() |
||
2493 | : OMPClause(llvm::omp::OMPC_relaxed, SourceLocation(), SourceLocation()) { |
||
2494 | } |
||
2495 | |||
2496 | child_range children() { |
||
2497 | return child_range(child_iterator(), child_iterator()); |
||
2498 | } |
||
2499 | |||
2500 | const_child_range children() const { |
||
2501 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2502 | } |
||
2503 | |||
2504 | child_range used_children() { |
||
2505 | return child_range(child_iterator(), child_iterator()); |
||
2506 | } |
||
2507 | const_child_range used_children() const { |
||
2508 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2509 | } |
||
2510 | |||
2511 | static bool classof(const OMPClause *T) { |
||
2512 | return T->getClauseKind() == llvm::omp::OMPC_relaxed; |
||
2513 | } |
||
2514 | }; |
||
2515 | |||
2516 | /// This represents clause 'private' in the '#pragma omp ...' directives. |
||
2517 | /// |
||
2518 | /// \code |
||
2519 | /// #pragma omp parallel private(a,b) |
||
2520 | /// \endcode |
||
2521 | /// In this example directive '#pragma omp parallel' has clause 'private' |
||
2522 | /// with the variables 'a' and 'b'. |
||
2523 | class OMPPrivateClause final |
||
2524 | : public OMPVarListClause<OMPPrivateClause>, |
||
2525 | private llvm::TrailingObjects<OMPPrivateClause, Expr *> { |
||
2526 | friend class OMPClauseReader; |
||
2527 | friend OMPVarListClause; |
||
2528 | friend TrailingObjects; |
||
2529 | |||
2530 | /// Build clause with number of variables \a N. |
||
2531 | /// |
||
2532 | /// \param StartLoc Starting location of the clause. |
||
2533 | /// \param LParenLoc Location of '('. |
||
2534 | /// \param EndLoc Ending location of the clause. |
||
2535 | /// \param N Number of the variables in the clause. |
||
2536 | OMPPrivateClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
2537 | SourceLocation EndLoc, unsigned N) |
||
2538 | : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, StartLoc, |
||
2539 | LParenLoc, EndLoc, N) {} |
||
2540 | |||
2541 | /// Build an empty clause. |
||
2542 | /// |
||
2543 | /// \param N Number of variables. |
||
2544 | explicit OMPPrivateClause(unsigned N) |
||
2545 | : OMPVarListClause<OMPPrivateClause>(llvm::omp::OMPC_private, |
||
2546 | SourceLocation(), SourceLocation(), |
||
2547 | SourceLocation(), N) {} |
||
2548 | |||
2549 | /// Sets the list of references to private copies with initializers for |
||
2550 | /// new private variables. |
||
2551 | /// \param VL List of references. |
||
2552 | void setPrivateCopies(ArrayRef<Expr *> VL); |
||
2553 | |||
2554 | /// Gets the list of references to private copies with initializers for |
||
2555 | /// new private variables. |
||
2556 | MutableArrayRef<Expr *> getPrivateCopies() { |
||
2557 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
2558 | } |
||
2559 | ArrayRef<const Expr *> getPrivateCopies() const { |
||
2560 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
2561 | } |
||
2562 | |||
2563 | public: |
||
2564 | /// Creates clause with a list of variables \a VL. |
||
2565 | /// |
||
2566 | /// \param C AST context. |
||
2567 | /// \param StartLoc Starting location of the clause. |
||
2568 | /// \param LParenLoc Location of '('. |
||
2569 | /// \param EndLoc Ending location of the clause. |
||
2570 | /// \param VL List of references to the variables. |
||
2571 | /// \param PrivateVL List of references to private copies with initializers. |
||
2572 | static OMPPrivateClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
2573 | SourceLocation LParenLoc, |
||
2574 | SourceLocation EndLoc, ArrayRef<Expr *> VL, |
||
2575 | ArrayRef<Expr *> PrivateVL); |
||
2576 | |||
2577 | /// Creates an empty clause with the place for \a N variables. |
||
2578 | /// |
||
2579 | /// \param C AST context. |
||
2580 | /// \param N The number of variables. |
||
2581 | static OMPPrivateClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
2582 | |||
2583 | using private_copies_iterator = MutableArrayRef<Expr *>::iterator; |
||
2584 | using private_copies_const_iterator = ArrayRef<const Expr *>::iterator; |
||
2585 | using private_copies_range = llvm::iterator_range<private_copies_iterator>; |
||
2586 | using private_copies_const_range = |
||
2587 | llvm::iterator_range<private_copies_const_iterator>; |
||
2588 | |||
2589 | private_copies_range private_copies() { |
||
2590 | return private_copies_range(getPrivateCopies().begin(), |
||
2591 | getPrivateCopies().end()); |
||
2592 | } |
||
2593 | |||
2594 | private_copies_const_range private_copies() const { |
||
2595 | return private_copies_const_range(getPrivateCopies().begin(), |
||
2596 | getPrivateCopies().end()); |
||
2597 | } |
||
2598 | |||
2599 | child_range children() { |
||
2600 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
2601 | reinterpret_cast<Stmt **>(varlist_end())); |
||
2602 | } |
||
2603 | |||
2604 | const_child_range children() const { |
||
2605 | auto Children = const_cast<OMPPrivateClause *>(this)->children(); |
||
2606 | return const_child_range(Children.begin(), Children.end()); |
||
2607 | } |
||
2608 | |||
2609 | child_range used_children() { |
||
2610 | return child_range(child_iterator(), child_iterator()); |
||
2611 | } |
||
2612 | const_child_range used_children() const { |
||
2613 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2614 | } |
||
2615 | |||
2616 | static bool classof(const OMPClause *T) { |
||
2617 | return T->getClauseKind() == llvm::omp::OMPC_private; |
||
2618 | } |
||
2619 | }; |
||
2620 | |||
2621 | /// This represents clause 'firstprivate' in the '#pragma omp ...' |
||
2622 | /// directives. |
||
2623 | /// |
||
2624 | /// \code |
||
2625 | /// #pragma omp parallel firstprivate(a,b) |
||
2626 | /// \endcode |
||
2627 | /// In this example directive '#pragma omp parallel' has clause 'firstprivate' |
||
2628 | /// with the variables 'a' and 'b'. |
||
2629 | class OMPFirstprivateClause final |
||
2630 | : public OMPVarListClause<OMPFirstprivateClause>, |
||
2631 | public OMPClauseWithPreInit, |
||
2632 | private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> { |
||
2633 | friend class OMPClauseReader; |
||
2634 | friend OMPVarListClause; |
||
2635 | friend TrailingObjects; |
||
2636 | |||
2637 | /// Build clause with number of variables \a N. |
||
2638 | /// |
||
2639 | /// \param StartLoc Starting location of the clause. |
||
2640 | /// \param LParenLoc Location of '('. |
||
2641 | /// \param EndLoc Ending location of the clause. |
||
2642 | /// \param N Number of the variables in the clause. |
||
2643 | OMPFirstprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
2644 | SourceLocation EndLoc, unsigned N) |
||
2645 | : OMPVarListClause<OMPFirstprivateClause>(llvm::omp::OMPC_firstprivate, |
||
2646 | StartLoc, LParenLoc, EndLoc, N), |
||
2647 | OMPClauseWithPreInit(this) {} |
||
2648 | |||
2649 | /// Build an empty clause. |
||
2650 | /// |
||
2651 | /// \param N Number of variables. |
||
2652 | explicit OMPFirstprivateClause(unsigned N) |
||
2653 | : OMPVarListClause<OMPFirstprivateClause>( |
||
2654 | llvm::omp::OMPC_firstprivate, SourceLocation(), SourceLocation(), |
||
2655 | SourceLocation(), N), |
||
2656 | OMPClauseWithPreInit(this) {} |
||
2657 | |||
2658 | /// Sets the list of references to private copies with initializers for |
||
2659 | /// new private variables. |
||
2660 | /// \param VL List of references. |
||
2661 | void setPrivateCopies(ArrayRef<Expr *> VL); |
||
2662 | |||
2663 | /// Gets the list of references to private copies with initializers for |
||
2664 | /// new private variables. |
||
2665 | MutableArrayRef<Expr *> getPrivateCopies() { |
||
2666 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
2667 | } |
||
2668 | ArrayRef<const Expr *> getPrivateCopies() const { |
||
2669 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
2670 | } |
||
2671 | |||
2672 | /// Sets the list of references to initializer variables for new |
||
2673 | /// private variables. |
||
2674 | /// \param VL List of references. |
||
2675 | void setInits(ArrayRef<Expr *> VL); |
||
2676 | |||
2677 | /// Gets the list of references to initializer variables for new |
||
2678 | /// private variables. |
||
2679 | MutableArrayRef<Expr *> getInits() { |
||
2680 | return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size()); |
||
2681 | } |
||
2682 | ArrayRef<const Expr *> getInits() const { |
||
2683 | return llvm::ArrayRef(getPrivateCopies().end(), varlist_size()); |
||
2684 | } |
||
2685 | |||
2686 | public: |
||
2687 | /// Creates clause with a list of variables \a VL. |
||
2688 | /// |
||
2689 | /// \param C AST context. |
||
2690 | /// \param StartLoc Starting location of the clause. |
||
2691 | /// \param LParenLoc Location of '('. |
||
2692 | /// \param EndLoc Ending location of the clause. |
||
2693 | /// \param VL List of references to the original variables. |
||
2694 | /// \param PrivateVL List of references to private copies with initializers. |
||
2695 | /// \param InitVL List of references to auto generated variables used for |
||
2696 | /// initialization of a single array element. Used if firstprivate variable is |
||
2697 | /// of array type. |
||
2698 | /// \param PreInit Statement that must be executed before entering the OpenMP |
||
2699 | /// region with this clause. |
||
2700 | static OMPFirstprivateClause * |
||
2701 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
2702 | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL, |
||
2703 | ArrayRef<Expr *> InitVL, Stmt *PreInit); |
||
2704 | |||
2705 | /// Creates an empty clause with the place for \a N variables. |
||
2706 | /// |
||
2707 | /// \param C AST context. |
||
2708 | /// \param N The number of variables. |
||
2709 | static OMPFirstprivateClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
2710 | |||
2711 | using private_copies_iterator = MutableArrayRef<Expr *>::iterator; |
||
2712 | using private_copies_const_iterator = ArrayRef<const Expr *>::iterator; |
||
2713 | using private_copies_range = llvm::iterator_range<private_copies_iterator>; |
||
2714 | using private_copies_const_range = |
||
2715 | llvm::iterator_range<private_copies_const_iterator>; |
||
2716 | |||
2717 | private_copies_range private_copies() { |
||
2718 | return private_copies_range(getPrivateCopies().begin(), |
||
2719 | getPrivateCopies().end()); |
||
2720 | } |
||
2721 | private_copies_const_range private_copies() const { |
||
2722 | return private_copies_const_range(getPrivateCopies().begin(), |
||
2723 | getPrivateCopies().end()); |
||
2724 | } |
||
2725 | |||
2726 | using inits_iterator = MutableArrayRef<Expr *>::iterator; |
||
2727 | using inits_const_iterator = ArrayRef<const Expr *>::iterator; |
||
2728 | using inits_range = llvm::iterator_range<inits_iterator>; |
||
2729 | using inits_const_range = llvm::iterator_range<inits_const_iterator>; |
||
2730 | |||
2731 | inits_range inits() { |
||
2732 | return inits_range(getInits().begin(), getInits().end()); |
||
2733 | } |
||
2734 | inits_const_range inits() const { |
||
2735 | return inits_const_range(getInits().begin(), getInits().end()); |
||
2736 | } |
||
2737 | |||
2738 | child_range children() { |
||
2739 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
2740 | reinterpret_cast<Stmt **>(varlist_end())); |
||
2741 | } |
||
2742 | |||
2743 | const_child_range children() const { |
||
2744 | auto Children = const_cast<OMPFirstprivateClause *>(this)->children(); |
||
2745 | return const_child_range(Children.begin(), Children.end()); |
||
2746 | } |
||
2747 | |||
2748 | child_range used_children() { |
||
2749 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
2750 | reinterpret_cast<Stmt **>(varlist_end())); |
||
2751 | } |
||
2752 | const_child_range used_children() const { |
||
2753 | auto Children = const_cast<OMPFirstprivateClause *>(this)->used_children(); |
||
2754 | return const_child_range(Children.begin(), Children.end()); |
||
2755 | } |
||
2756 | |||
2757 | static bool classof(const OMPClause *T) { |
||
2758 | return T->getClauseKind() == llvm::omp::OMPC_firstprivate; |
||
2759 | } |
||
2760 | }; |
||
2761 | |||
2762 | /// This represents clause 'lastprivate' in the '#pragma omp ...' |
||
2763 | /// directives. |
||
2764 | /// |
||
2765 | /// \code |
||
2766 | /// #pragma omp simd lastprivate(a,b) |
||
2767 | /// \endcode |
||
2768 | /// In this example directive '#pragma omp simd' has clause 'lastprivate' |
||
2769 | /// with the variables 'a' and 'b'. |
||
2770 | class OMPLastprivateClause final |
||
2771 | : public OMPVarListClause<OMPLastprivateClause>, |
||
2772 | public OMPClauseWithPostUpdate, |
||
2773 | private llvm::TrailingObjects<OMPLastprivateClause, Expr *> { |
||
2774 | // There are 4 additional tail-allocated arrays at the end of the class: |
||
2775 | // 1. Contains list of pseudo variables with the default initialization for |
||
2776 | // each non-firstprivate variables. Used in codegen for initialization of |
||
2777 | // lastprivate copies. |
||
2778 | // 2. List of helper expressions for proper generation of assignment operation |
||
2779 | // required for lastprivate clause. This list represents private variables |
||
2780 | // (for arrays, single array element). |
||
2781 | // 3. List of helper expressions for proper generation of assignment operation |
||
2782 | // required for lastprivate clause. This list represents original variables |
||
2783 | // (for arrays, single array element). |
||
2784 | // 4. List of helper expressions that represents assignment operation: |
||
2785 | // \code |
||
2786 | // DstExprs = SrcExprs; |
||
2787 | // \endcode |
||
2788 | // Required for proper codegen of final assignment performed by the |
||
2789 | // lastprivate clause. |
||
2790 | friend class OMPClauseReader; |
||
2791 | friend OMPVarListClause; |
||
2792 | friend TrailingObjects; |
||
2793 | |||
2794 | /// Optional lastprivate kind, e.g. 'conditional', if specified by user. |
||
2795 | OpenMPLastprivateModifier LPKind; |
||
2796 | /// Optional location of the lasptrivate kind, if specified by user. |
||
2797 | SourceLocation LPKindLoc; |
||
2798 | /// Optional colon location, if specified by user. |
||
2799 | SourceLocation ColonLoc; |
||
2800 | |||
2801 | /// Build clause with number of variables \a N. |
||
2802 | /// |
||
2803 | /// \param StartLoc Starting location of the clause. |
||
2804 | /// \param LParenLoc Location of '('. |
||
2805 | /// \param EndLoc Ending location of the clause. |
||
2806 | /// \param N Number of the variables in the clause. |
||
2807 | OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
2808 | SourceLocation EndLoc, OpenMPLastprivateModifier LPKind, |
||
2809 | SourceLocation LPKindLoc, SourceLocation ColonLoc, |
||
2810 | unsigned N) |
||
2811 | : OMPVarListClause<OMPLastprivateClause>(llvm::omp::OMPC_lastprivate, |
||
2812 | StartLoc, LParenLoc, EndLoc, N), |
||
2813 | OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc), |
||
2814 | ColonLoc(ColonLoc) {} |
||
2815 | |||
2816 | /// Build an empty clause. |
||
2817 | /// |
||
2818 | /// \param N Number of variables. |
||
2819 | explicit OMPLastprivateClause(unsigned N) |
||
2820 | : OMPVarListClause<OMPLastprivateClause>( |
||
2821 | llvm::omp::OMPC_lastprivate, SourceLocation(), SourceLocation(), |
||
2822 | SourceLocation(), N), |
||
2823 | OMPClauseWithPostUpdate(this) {} |
||
2824 | |||
2825 | /// Get the list of helper expressions for initialization of private |
||
2826 | /// copies for lastprivate variables. |
||
2827 | MutableArrayRef<Expr *> getPrivateCopies() { |
||
2828 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
2829 | } |
||
2830 | ArrayRef<const Expr *> getPrivateCopies() const { |
||
2831 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
2832 | } |
||
2833 | |||
2834 | /// Set list of helper expressions, required for proper codegen of the |
||
2835 | /// clause. These expressions represent private variables (for arrays, single |
||
2836 | /// array element) in the final assignment statement performed by the |
||
2837 | /// lastprivate clause. |
||
2838 | void setSourceExprs(ArrayRef<Expr *> SrcExprs); |
||
2839 | |||
2840 | /// Get the list of helper source expressions. |
||
2841 | MutableArrayRef<Expr *> getSourceExprs() { |
||
2842 | return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size()); |
||
2843 | } |
||
2844 | ArrayRef<const Expr *> getSourceExprs() const { |
||
2845 | return llvm::ArrayRef(getPrivateCopies().end(), varlist_size()); |
||
2846 | } |
||
2847 | |||
2848 | /// Set list of helper expressions, required for proper codegen of the |
||
2849 | /// clause. These expressions represent original variables (for arrays, single |
||
2850 | /// array element) in the final assignment statement performed by the |
||
2851 | /// lastprivate clause. |
||
2852 | void setDestinationExprs(ArrayRef<Expr *> DstExprs); |
||
2853 | |||
2854 | /// Get the list of helper destination expressions. |
||
2855 | MutableArrayRef<Expr *> getDestinationExprs() { |
||
2856 | return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size()); |
||
2857 | } |
||
2858 | ArrayRef<const Expr *> getDestinationExprs() const { |
||
2859 | return llvm::ArrayRef(getSourceExprs().end(), varlist_size()); |
||
2860 | } |
||
2861 | |||
2862 | /// Set list of helper assignment expressions, required for proper |
||
2863 | /// codegen of the clause. These expressions are assignment expressions that |
||
2864 | /// assign private copy of the variable to original variable. |
||
2865 | void setAssignmentOps(ArrayRef<Expr *> AssignmentOps); |
||
2866 | |||
2867 | /// Get the list of helper assignment expressions. |
||
2868 | MutableArrayRef<Expr *> getAssignmentOps() { |
||
2869 | return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size()); |
||
2870 | } |
||
2871 | ArrayRef<const Expr *> getAssignmentOps() const { |
||
2872 | return llvm::ArrayRef(getDestinationExprs().end(), varlist_size()); |
||
2873 | } |
||
2874 | |||
2875 | /// Sets lastprivate kind. |
||
2876 | void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; } |
||
2877 | /// Sets location of the lastprivate kind. |
||
2878 | void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; } |
||
2879 | /// Sets colon symbol location. |
||
2880 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
2881 | |||
2882 | public: |
||
2883 | /// Creates clause with a list of variables \a VL. |
||
2884 | /// |
||
2885 | /// \param C AST context. |
||
2886 | /// \param StartLoc Starting location of the clause. |
||
2887 | /// \param LParenLoc Location of '('. |
||
2888 | /// \param EndLoc Ending location of the clause. |
||
2889 | /// \param VL List of references to the variables. |
||
2890 | /// \param SrcExprs List of helper expressions for proper generation of |
||
2891 | /// assignment operation required for lastprivate clause. This list represents |
||
2892 | /// private variables (for arrays, single array element). |
||
2893 | /// \param DstExprs List of helper expressions for proper generation of |
||
2894 | /// assignment operation required for lastprivate clause. This list represents |
||
2895 | /// original variables (for arrays, single array element). |
||
2896 | /// \param AssignmentOps List of helper expressions that represents assignment |
||
2897 | /// operation: |
||
2898 | /// \code |
||
2899 | /// DstExprs = SrcExprs; |
||
2900 | /// \endcode |
||
2901 | /// Required for proper codegen of final assignment performed by the |
||
2902 | /// lastprivate clause. |
||
2903 | /// \param LPKind Lastprivate kind, e.g. 'conditional'. |
||
2904 | /// \param LPKindLoc Location of the lastprivate kind. |
||
2905 | /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used. |
||
2906 | /// \param PreInit Statement that must be executed before entering the OpenMP |
||
2907 | /// region with this clause. |
||
2908 | /// \param PostUpdate Expression that must be executed after exit from the |
||
2909 | /// OpenMP region with this clause. |
||
2910 | static OMPLastprivateClause * |
||
2911 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
2912 | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
||
2913 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps, |
||
2914 | OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, |
||
2915 | SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate); |
||
2916 | |||
2917 | /// Creates an empty clause with the place for \a N variables. |
||
2918 | /// |
||
2919 | /// \param C AST context. |
||
2920 | /// \param N The number of variables. |
||
2921 | static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
2922 | |||
2923 | /// Lastprivate kind. |
||
2924 | OpenMPLastprivateModifier getKind() const { return LPKind; } |
||
2925 | /// Returns the location of the lastprivate kind. |
||
2926 | SourceLocation getKindLoc() const { return LPKindLoc; } |
||
2927 | /// Returns the location of the ':' symbol, if any. |
||
2928 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
2929 | |||
2930 | using helper_expr_iterator = MutableArrayRef<Expr *>::iterator; |
||
2931 | using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator; |
||
2932 | using helper_expr_range = llvm::iterator_range<helper_expr_iterator>; |
||
2933 | using helper_expr_const_range = |
||
2934 | llvm::iterator_range<helper_expr_const_iterator>; |
||
2935 | |||
2936 | /// Set list of helper expressions, required for generation of private |
||
2937 | /// copies of original lastprivate variables. |
||
2938 | void setPrivateCopies(ArrayRef<Expr *> PrivateCopies); |
||
2939 | |||
2940 | helper_expr_const_range private_copies() const { |
||
2941 | return helper_expr_const_range(getPrivateCopies().begin(), |
||
2942 | getPrivateCopies().end()); |
||
2943 | } |
||
2944 | |||
2945 | helper_expr_range private_copies() { |
||
2946 | return helper_expr_range(getPrivateCopies().begin(), |
||
2947 | getPrivateCopies().end()); |
||
2948 | } |
||
2949 | |||
2950 | helper_expr_const_range source_exprs() const { |
||
2951 | return helper_expr_const_range(getSourceExprs().begin(), |
||
2952 | getSourceExprs().end()); |
||
2953 | } |
||
2954 | |||
2955 | helper_expr_range source_exprs() { |
||
2956 | return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end()); |
||
2957 | } |
||
2958 | |||
2959 | helper_expr_const_range destination_exprs() const { |
||
2960 | return helper_expr_const_range(getDestinationExprs().begin(), |
||
2961 | getDestinationExprs().end()); |
||
2962 | } |
||
2963 | |||
2964 | helper_expr_range destination_exprs() { |
||
2965 | return helper_expr_range(getDestinationExprs().begin(), |
||
2966 | getDestinationExprs().end()); |
||
2967 | } |
||
2968 | |||
2969 | helper_expr_const_range assignment_ops() const { |
||
2970 | return helper_expr_const_range(getAssignmentOps().begin(), |
||
2971 | getAssignmentOps().end()); |
||
2972 | } |
||
2973 | |||
2974 | helper_expr_range assignment_ops() { |
||
2975 | return helper_expr_range(getAssignmentOps().begin(), |
||
2976 | getAssignmentOps().end()); |
||
2977 | } |
||
2978 | |||
2979 | child_range children() { |
||
2980 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
2981 | reinterpret_cast<Stmt **>(varlist_end())); |
||
2982 | } |
||
2983 | |||
2984 | const_child_range children() const { |
||
2985 | auto Children = const_cast<OMPLastprivateClause *>(this)->children(); |
||
2986 | return const_child_range(Children.begin(), Children.end()); |
||
2987 | } |
||
2988 | |||
2989 | child_range used_children() { |
||
2990 | return child_range(child_iterator(), child_iterator()); |
||
2991 | } |
||
2992 | const_child_range used_children() const { |
||
2993 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
2994 | } |
||
2995 | |||
2996 | static bool classof(const OMPClause *T) { |
||
2997 | return T->getClauseKind() == llvm::omp::OMPC_lastprivate; |
||
2998 | } |
||
2999 | }; |
||
3000 | |||
3001 | /// This represents clause 'shared' in the '#pragma omp ...' directives. |
||
3002 | /// |
||
3003 | /// \code |
||
3004 | /// #pragma omp parallel shared(a,b) |
||
3005 | /// \endcode |
||
3006 | /// In this example directive '#pragma omp parallel' has clause 'shared' |
||
3007 | /// with the variables 'a' and 'b'. |
||
3008 | class OMPSharedClause final |
||
3009 | : public OMPVarListClause<OMPSharedClause>, |
||
3010 | private llvm::TrailingObjects<OMPSharedClause, Expr *> { |
||
3011 | friend OMPVarListClause; |
||
3012 | friend TrailingObjects; |
||
3013 | |||
3014 | /// Build clause with number of variables \a N. |
||
3015 | /// |
||
3016 | /// \param StartLoc Starting location of the clause. |
||
3017 | /// \param LParenLoc Location of '('. |
||
3018 | /// \param EndLoc Ending location of the clause. |
||
3019 | /// \param N Number of the variables in the clause. |
||
3020 | OMPSharedClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3021 | SourceLocation EndLoc, unsigned N) |
||
3022 | : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, StartLoc, |
||
3023 | LParenLoc, EndLoc, N) {} |
||
3024 | |||
3025 | /// Build an empty clause. |
||
3026 | /// |
||
3027 | /// \param N Number of variables. |
||
3028 | explicit OMPSharedClause(unsigned N) |
||
3029 | : OMPVarListClause<OMPSharedClause>(llvm::omp::OMPC_shared, |
||
3030 | SourceLocation(), SourceLocation(), |
||
3031 | SourceLocation(), N) {} |
||
3032 | |||
3033 | public: |
||
3034 | /// Creates clause with a list of variables \a VL. |
||
3035 | /// |
||
3036 | /// \param C AST context. |
||
3037 | /// \param StartLoc Starting location of the clause. |
||
3038 | /// \param LParenLoc Location of '('. |
||
3039 | /// \param EndLoc Ending location of the clause. |
||
3040 | /// \param VL List of references to the variables. |
||
3041 | static OMPSharedClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
3042 | SourceLocation LParenLoc, |
||
3043 | SourceLocation EndLoc, ArrayRef<Expr *> VL); |
||
3044 | |||
3045 | /// Creates an empty clause with \a N variables. |
||
3046 | /// |
||
3047 | /// \param C AST context. |
||
3048 | /// \param N The number of variables. |
||
3049 | static OMPSharedClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
3050 | |||
3051 | child_range children() { |
||
3052 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
3053 | reinterpret_cast<Stmt **>(varlist_end())); |
||
3054 | } |
||
3055 | |||
3056 | const_child_range children() const { |
||
3057 | auto Children = const_cast<OMPSharedClause *>(this)->children(); |
||
3058 | return const_child_range(Children.begin(), Children.end()); |
||
3059 | } |
||
3060 | |||
3061 | child_range used_children() { |
||
3062 | return child_range(child_iterator(), child_iterator()); |
||
3063 | } |
||
3064 | const_child_range used_children() const { |
||
3065 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
3066 | } |
||
3067 | |||
3068 | static bool classof(const OMPClause *T) { |
||
3069 | return T->getClauseKind() == llvm::omp::OMPC_shared; |
||
3070 | } |
||
3071 | }; |
||
3072 | |||
3073 | /// This represents clause 'reduction' in the '#pragma omp ...' |
||
3074 | /// directives. |
||
3075 | /// |
||
3076 | /// \code |
||
3077 | /// #pragma omp parallel reduction(+:a,b) |
||
3078 | /// \endcode |
||
3079 | /// In this example directive '#pragma omp parallel' has clause 'reduction' |
||
3080 | /// with operator '+' and the variables 'a' and 'b'. |
||
3081 | class OMPReductionClause final |
||
3082 | : public OMPVarListClause<OMPReductionClause>, |
||
3083 | public OMPClauseWithPostUpdate, |
||
3084 | private llvm::TrailingObjects<OMPReductionClause, Expr *> { |
||
3085 | friend class OMPClauseReader; |
||
3086 | friend OMPVarListClause; |
||
3087 | friend TrailingObjects; |
||
3088 | |||
3089 | /// Reduction modifier. |
||
3090 | OpenMPReductionClauseModifier Modifier = OMPC_REDUCTION_unknown; |
||
3091 | |||
3092 | /// Reduction modifier location. |
||
3093 | SourceLocation ModifierLoc; |
||
3094 | |||
3095 | /// Location of ':'. |
||
3096 | SourceLocation ColonLoc; |
||
3097 | |||
3098 | /// Nested name specifier for C++. |
||
3099 | NestedNameSpecifierLoc QualifierLoc; |
||
3100 | |||
3101 | /// Name of custom operator. |
||
3102 | DeclarationNameInfo NameInfo; |
||
3103 | |||
3104 | /// Build clause with number of variables \a N. |
||
3105 | /// |
||
3106 | /// \param StartLoc Starting location of the clause. |
||
3107 | /// \param LParenLoc Location of '('. |
||
3108 | /// \param ModifierLoc Modifier location. |
||
3109 | /// \param ColonLoc Location of ':'. |
||
3110 | /// \param EndLoc Ending location of the clause. |
||
3111 | /// \param N Number of the variables in the clause. |
||
3112 | /// \param QualifierLoc The nested-name qualifier with location information |
||
3113 | /// \param NameInfo The full name info for reduction identifier. |
||
3114 | OMPReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3115 | SourceLocation ModifierLoc, SourceLocation ColonLoc, |
||
3116 | SourceLocation EndLoc, |
||
3117 | OpenMPReductionClauseModifier Modifier, unsigned N, |
||
3118 | NestedNameSpecifierLoc QualifierLoc, |
||
3119 | const DeclarationNameInfo &NameInfo) |
||
3120 | : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction, |
||
3121 | StartLoc, LParenLoc, EndLoc, N), |
||
3122 | OMPClauseWithPostUpdate(this), Modifier(Modifier), |
||
3123 | ModifierLoc(ModifierLoc), ColonLoc(ColonLoc), |
||
3124 | QualifierLoc(QualifierLoc), NameInfo(NameInfo) {} |
||
3125 | |||
3126 | /// Build an empty clause. |
||
3127 | /// |
||
3128 | /// \param N Number of variables. |
||
3129 | explicit OMPReductionClause(unsigned N) |
||
3130 | : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction, |
||
3131 | SourceLocation(), SourceLocation(), |
||
3132 | SourceLocation(), N), |
||
3133 | OMPClauseWithPostUpdate(this) {} |
||
3134 | |||
3135 | /// Sets reduction modifier. |
||
3136 | void setModifier(OpenMPReductionClauseModifier M) { Modifier = M; } |
||
3137 | |||
3138 | /// Sets location of the modifier. |
||
3139 | void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; } |
||
3140 | |||
3141 | /// Sets location of ':' symbol in clause. |
||
3142 | void setColonLoc(SourceLocation CL) { ColonLoc = CL; } |
||
3143 | |||
3144 | /// Sets the name info for specified reduction identifier. |
||
3145 | void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; } |
||
3146 | |||
3147 | /// Sets the nested name specifier. |
||
3148 | void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; } |
||
3149 | |||
3150 | /// Set list of helper expressions, required for proper codegen of the |
||
3151 | /// clause. These expressions represent private copy of the reduction |
||
3152 | /// variable. |
||
3153 | void setPrivates(ArrayRef<Expr *> Privates); |
||
3154 | |||
3155 | /// Get the list of helper privates. |
||
3156 | MutableArrayRef<Expr *> getPrivates() { |
||
3157 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
3158 | } |
||
3159 | ArrayRef<const Expr *> getPrivates() const { |
||
3160 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
3161 | } |
||
3162 | |||
3163 | /// Set list of helper expressions, required for proper codegen of the |
||
3164 | /// clause. These expressions represent LHS expression in the final |
||
3165 | /// reduction expression performed by the reduction clause. |
||
3166 | void setLHSExprs(ArrayRef<Expr *> LHSExprs); |
||
3167 | |||
3168 | /// Get the list of helper LHS expressions. |
||
3169 | MutableArrayRef<Expr *> getLHSExprs() { |
||
3170 | return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size()); |
||
3171 | } |
||
3172 | ArrayRef<const Expr *> getLHSExprs() const { |
||
3173 | return llvm::ArrayRef(getPrivates().end(), varlist_size()); |
||
3174 | } |
||
3175 | |||
3176 | /// Set list of helper expressions, required for proper codegen of the |
||
3177 | /// clause. These expressions represent RHS expression in the final |
||
3178 | /// reduction expression performed by the reduction clause. |
||
3179 | /// Also, variables in these expressions are used for proper initialization of |
||
3180 | /// reduction copies. |
||
3181 | void setRHSExprs(ArrayRef<Expr *> RHSExprs); |
||
3182 | |||
3183 | /// Get the list of helper destination expressions. |
||
3184 | MutableArrayRef<Expr *> getRHSExprs() { |
||
3185 | return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size()); |
||
3186 | } |
||
3187 | ArrayRef<const Expr *> getRHSExprs() const { |
||
3188 | return llvm::ArrayRef(getLHSExprs().end(), varlist_size()); |
||
3189 | } |
||
3190 | |||
3191 | /// Set list of helper reduction expressions, required for proper |
||
3192 | /// codegen of the clause. These expressions are binary expressions or |
||
3193 | /// operator/custom reduction call that calculates new value from source |
||
3194 | /// helper expressions to destination helper expressions. |
||
3195 | void setReductionOps(ArrayRef<Expr *> ReductionOps); |
||
3196 | |||
3197 | /// Get the list of helper reduction expressions. |
||
3198 | MutableArrayRef<Expr *> getReductionOps() { |
||
3199 | return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size()); |
||
3200 | } |
||
3201 | ArrayRef<const Expr *> getReductionOps() const { |
||
3202 | return llvm::ArrayRef(getRHSExprs().end(), varlist_size()); |
||
3203 | } |
||
3204 | |||
3205 | /// Set list of helper copy operations for inscan reductions. |
||
3206 | /// The form is: Temps[i] = LHS[i]; |
||
3207 | void setInscanCopyOps(ArrayRef<Expr *> Ops); |
||
3208 | |||
3209 | /// Get the list of helper inscan copy operations. |
||
3210 | MutableArrayRef<Expr *> getInscanCopyOps() { |
||
3211 | return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size()); |
||
3212 | } |
||
3213 | ArrayRef<const Expr *> getInscanCopyOps() const { |
||
3214 | return llvm::ArrayRef(getReductionOps().end(), varlist_size()); |
||
3215 | } |
||
3216 | |||
3217 | /// Set list of helper temp vars for inscan copy array operations. |
||
3218 | void setInscanCopyArrayTemps(ArrayRef<Expr *> CopyArrayTemps); |
||
3219 | |||
3220 | /// Get the list of helper inscan copy temps. |
||
3221 | MutableArrayRef<Expr *> getInscanCopyArrayTemps() { |
||
3222 | return MutableArrayRef<Expr *>(getInscanCopyOps().end(), varlist_size()); |
||
3223 | } |
||
3224 | ArrayRef<const Expr *> getInscanCopyArrayTemps() const { |
||
3225 | return llvm::ArrayRef(getInscanCopyOps().end(), varlist_size()); |
||
3226 | } |
||
3227 | |||
3228 | /// Set list of helper temp elements vars for inscan copy array operations. |
||
3229 | void setInscanCopyArrayElems(ArrayRef<Expr *> CopyArrayElems); |
||
3230 | |||
3231 | /// Get the list of helper inscan copy temps. |
||
3232 | MutableArrayRef<Expr *> getInscanCopyArrayElems() { |
||
3233 | return MutableArrayRef<Expr *>(getInscanCopyArrayTemps().end(), |
||
3234 | varlist_size()); |
||
3235 | } |
||
3236 | ArrayRef<const Expr *> getInscanCopyArrayElems() const { |
||
3237 | return llvm::ArrayRef(getInscanCopyArrayTemps().end(), varlist_size()); |
||
3238 | } |
||
3239 | |||
3240 | public: |
||
3241 | /// Creates clause with a list of variables \a VL. |
||
3242 | /// |
||
3243 | /// \param StartLoc Starting location of the clause. |
||
3244 | /// \param LParenLoc Location of '('. |
||
3245 | /// \param ModifierLoc Modifier location. |
||
3246 | /// \param ColonLoc Location of ':'. |
||
3247 | /// \param EndLoc Ending location of the clause. |
||
3248 | /// \param VL The variables in the clause. |
||
3249 | /// \param QualifierLoc The nested-name qualifier with location information |
||
3250 | /// \param NameInfo The full name info for reduction identifier. |
||
3251 | /// \param Privates List of helper expressions for proper generation of |
||
3252 | /// private copies. |
||
3253 | /// \param LHSExprs List of helper expressions for proper generation of |
||
3254 | /// assignment operation required for copyprivate clause. This list represents |
||
3255 | /// LHSs of the reduction expressions. |
||
3256 | /// \param RHSExprs List of helper expressions for proper generation of |
||
3257 | /// assignment operation required for copyprivate clause. This list represents |
||
3258 | /// RHSs of the reduction expressions. |
||
3259 | /// Also, variables in these expressions are used for proper initialization of |
||
3260 | /// reduction copies. |
||
3261 | /// \param ReductionOps List of helper expressions that represents reduction |
||
3262 | /// expressions: |
||
3263 | /// \code |
||
3264 | /// LHSExprs binop RHSExprs; |
||
3265 | /// operator binop(LHSExpr, RHSExpr); |
||
3266 | /// <CutomReduction>(LHSExpr, RHSExpr); |
||
3267 | /// \endcode |
||
3268 | /// Required for proper codegen of final reduction operation performed by the |
||
3269 | /// reduction clause. |
||
3270 | /// \param CopyOps List of copy operations for inscan reductions: |
||
3271 | /// \code |
||
3272 | /// TempExprs = LHSExprs; |
||
3273 | /// \endcode |
||
3274 | /// \param CopyArrayTemps Temp arrays for prefix sums. |
||
3275 | /// \param CopyArrayElems Temp arrays for prefix sums. |
||
3276 | /// \param PreInit Statement that must be executed before entering the OpenMP |
||
3277 | /// region with this clause. |
||
3278 | /// \param PostUpdate Expression that must be executed after exit from the |
||
3279 | /// OpenMP region with this clause. |
||
3280 | static OMPReductionClause * |
||
3281 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3282 | SourceLocation ModifierLoc, SourceLocation ColonLoc, |
||
3283 | SourceLocation EndLoc, OpenMPReductionClauseModifier Modifier, |
||
3284 | ArrayRef<Expr *> VL, NestedNameSpecifierLoc QualifierLoc, |
||
3285 | const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates, |
||
3286 | ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs, |
||
3287 | ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps, |
||
3288 | ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems, |
||
3289 | Stmt *PreInit, Expr *PostUpdate); |
||
3290 | |||
3291 | /// Creates an empty clause with the place for \a N variables. |
||
3292 | /// |
||
3293 | /// \param C AST context. |
||
3294 | /// \param N The number of variables. |
||
3295 | /// \param Modifier Reduction modifier. |
||
3296 | static OMPReductionClause * |
||
3297 | CreateEmpty(const ASTContext &C, unsigned N, |
||
3298 | OpenMPReductionClauseModifier Modifier); |
||
3299 | |||
3300 | /// Returns modifier. |
||
3301 | OpenMPReductionClauseModifier getModifier() const { return Modifier; } |
||
3302 | |||
3303 | /// Returns modifier location. |
||
3304 | SourceLocation getModifierLoc() const { return ModifierLoc; } |
||
3305 | |||
3306 | /// Gets location of ':' symbol in clause. |
||
3307 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
3308 | |||
3309 | /// Gets the name info for specified reduction identifier. |
||
3310 | const DeclarationNameInfo &getNameInfo() const { return NameInfo; } |
||
3311 | |||
3312 | /// Gets the nested name specifier. |
||
3313 | NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } |
||
3314 | |||
3315 | using helper_expr_iterator = MutableArrayRef<Expr *>::iterator; |
||
3316 | using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator; |
||
3317 | using helper_expr_range = llvm::iterator_range<helper_expr_iterator>; |
||
3318 | using helper_expr_const_range = |
||
3319 | llvm::iterator_range<helper_expr_const_iterator>; |
||
3320 | |||
3321 | helper_expr_const_range privates() const { |
||
3322 | return helper_expr_const_range(getPrivates().begin(), getPrivates().end()); |
||
3323 | } |
||
3324 | |||
3325 | helper_expr_range privates() { |
||
3326 | return helper_expr_range(getPrivates().begin(), getPrivates().end()); |
||
3327 | } |
||
3328 | |||
3329 | helper_expr_const_range lhs_exprs() const { |
||
3330 | return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end()); |
||
3331 | } |
||
3332 | |||
3333 | helper_expr_range lhs_exprs() { |
||
3334 | return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end()); |
||
3335 | } |
||
3336 | |||
3337 | helper_expr_const_range rhs_exprs() const { |
||
3338 | return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end()); |
||
3339 | } |
||
3340 | |||
3341 | helper_expr_range rhs_exprs() { |
||
3342 | return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end()); |
||
3343 | } |
||
3344 | |||
3345 | helper_expr_const_range reduction_ops() const { |
||
3346 | return helper_expr_const_range(getReductionOps().begin(), |
||
3347 | getReductionOps().end()); |
||
3348 | } |
||
3349 | |||
3350 | helper_expr_range reduction_ops() { |
||
3351 | return helper_expr_range(getReductionOps().begin(), |
||
3352 | getReductionOps().end()); |
||
3353 | } |
||
3354 | |||
3355 | helper_expr_const_range copy_ops() const { |
||
3356 | return helper_expr_const_range(getInscanCopyOps().begin(), |
||
3357 | getInscanCopyOps().end()); |
||
3358 | } |
||
3359 | |||
3360 | helper_expr_range copy_ops() { |
||
3361 | return helper_expr_range(getInscanCopyOps().begin(), |
||
3362 | getInscanCopyOps().end()); |
||
3363 | } |
||
3364 | |||
3365 | helper_expr_const_range copy_array_temps() const { |
||
3366 | return helper_expr_const_range(getInscanCopyArrayTemps().begin(), |
||
3367 | getInscanCopyArrayTemps().end()); |
||
3368 | } |
||
3369 | |||
3370 | helper_expr_range copy_array_temps() { |
||
3371 | return helper_expr_range(getInscanCopyArrayTemps().begin(), |
||
3372 | getInscanCopyArrayTemps().end()); |
||
3373 | } |
||
3374 | |||
3375 | helper_expr_const_range copy_array_elems() const { |
||
3376 | return helper_expr_const_range(getInscanCopyArrayElems().begin(), |
||
3377 | getInscanCopyArrayElems().end()); |
||
3378 | } |
||
3379 | |||
3380 | helper_expr_range copy_array_elems() { |
||
3381 | return helper_expr_range(getInscanCopyArrayElems().begin(), |
||
3382 | getInscanCopyArrayElems().end()); |
||
3383 | } |
||
3384 | |||
3385 | child_range children() { |
||
3386 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
3387 | reinterpret_cast<Stmt **>(varlist_end())); |
||
3388 | } |
||
3389 | |||
3390 | const_child_range children() const { |
||
3391 | auto Children = const_cast<OMPReductionClause *>(this)->children(); |
||
3392 | return const_child_range(Children.begin(), Children.end()); |
||
3393 | } |
||
3394 | |||
3395 | child_range used_children() { |
||
3396 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
3397 | reinterpret_cast<Stmt **>(varlist_end())); |
||
3398 | } |
||
3399 | const_child_range used_children() const { |
||
3400 | auto Children = const_cast<OMPReductionClause *>(this)->used_children(); |
||
3401 | return const_child_range(Children.begin(), Children.end()); |
||
3402 | } |
||
3403 | |||
3404 | static bool classof(const OMPClause *T) { |
||
3405 | return T->getClauseKind() == llvm::omp::OMPC_reduction; |
||
3406 | } |
||
3407 | }; |
||
3408 | |||
3409 | /// This represents clause 'task_reduction' in the '#pragma omp taskgroup' |
||
3410 | /// directives. |
||
3411 | /// |
||
3412 | /// \code |
||
3413 | /// #pragma omp taskgroup task_reduction(+:a,b) |
||
3414 | /// \endcode |
||
3415 | /// In this example directive '#pragma omp taskgroup' has clause |
||
3416 | /// 'task_reduction' with operator '+' and the variables 'a' and 'b'. |
||
3417 | class OMPTaskReductionClause final |
||
3418 | : public OMPVarListClause<OMPTaskReductionClause>, |
||
3419 | public OMPClauseWithPostUpdate, |
||
3420 | private llvm::TrailingObjects<OMPTaskReductionClause, Expr *> { |
||
3421 | friend class OMPClauseReader; |
||
3422 | friend OMPVarListClause; |
||
3423 | friend TrailingObjects; |
||
3424 | |||
3425 | /// Location of ':'. |
||
3426 | SourceLocation ColonLoc; |
||
3427 | |||
3428 | /// Nested name specifier for C++. |
||
3429 | NestedNameSpecifierLoc QualifierLoc; |
||
3430 | |||
3431 | /// Name of custom operator. |
||
3432 | DeclarationNameInfo NameInfo; |
||
3433 | |||
3434 | /// Build clause with number of variables \a N. |
||
3435 | /// |
||
3436 | /// \param StartLoc Starting location of the clause. |
||
3437 | /// \param LParenLoc Location of '('. |
||
3438 | /// \param EndLoc Ending location of the clause. |
||
3439 | /// \param ColonLoc Location of ':'. |
||
3440 | /// \param N Number of the variables in the clause. |
||
3441 | /// \param QualifierLoc The nested-name qualifier with location information |
||
3442 | /// \param NameInfo The full name info for reduction identifier. |
||
3443 | OMPTaskReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3444 | SourceLocation ColonLoc, SourceLocation EndLoc, |
||
3445 | unsigned N, NestedNameSpecifierLoc QualifierLoc, |
||
3446 | const DeclarationNameInfo &NameInfo) |
||
3447 | : OMPVarListClause<OMPTaskReductionClause>( |
||
3448 | llvm::omp::OMPC_task_reduction, StartLoc, LParenLoc, EndLoc, N), |
||
3449 | OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc), |
||
3450 | QualifierLoc(QualifierLoc), NameInfo(NameInfo) {} |
||
3451 | |||
3452 | /// Build an empty clause. |
||
3453 | /// |
||
3454 | /// \param N Number of variables. |
||
3455 | explicit OMPTaskReductionClause(unsigned N) |
||
3456 | : OMPVarListClause<OMPTaskReductionClause>( |
||
3457 | llvm::omp::OMPC_task_reduction, SourceLocation(), SourceLocation(), |
||
3458 | SourceLocation(), N), |
||
3459 | OMPClauseWithPostUpdate(this) {} |
||
3460 | |||
3461 | /// Sets location of ':' symbol in clause. |
||
3462 | void setColonLoc(SourceLocation CL) { ColonLoc = CL; } |
||
3463 | |||
3464 | /// Sets the name info for specified reduction identifier. |
||
3465 | void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; } |
||
3466 | |||
3467 | /// Sets the nested name specifier. |
||
3468 | void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; } |
||
3469 | |||
3470 | /// Set list of helper expressions, required for proper codegen of the clause. |
||
3471 | /// These expressions represent private copy of the reduction variable. |
||
3472 | void setPrivates(ArrayRef<Expr *> Privates); |
||
3473 | |||
3474 | /// Get the list of helper privates. |
||
3475 | MutableArrayRef<Expr *> getPrivates() { |
||
3476 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
3477 | } |
||
3478 | ArrayRef<const Expr *> getPrivates() const { |
||
3479 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
3480 | } |
||
3481 | |||
3482 | /// Set list of helper expressions, required for proper codegen of the clause. |
||
3483 | /// These expressions represent LHS expression in the final reduction |
||
3484 | /// expression performed by the reduction clause. |
||
3485 | void setLHSExprs(ArrayRef<Expr *> LHSExprs); |
||
3486 | |||
3487 | /// Get the list of helper LHS expressions. |
||
3488 | MutableArrayRef<Expr *> getLHSExprs() { |
||
3489 | return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size()); |
||
3490 | } |
||
3491 | ArrayRef<const Expr *> getLHSExprs() const { |
||
3492 | return llvm::ArrayRef(getPrivates().end(), varlist_size()); |
||
3493 | } |
||
3494 | |||
3495 | /// Set list of helper expressions, required for proper codegen of the clause. |
||
3496 | /// These expressions represent RHS expression in the final reduction |
||
3497 | /// expression performed by the reduction clause. Also, variables in these |
||
3498 | /// expressions are used for proper initialization of reduction copies. |
||
3499 | void setRHSExprs(ArrayRef<Expr *> RHSExprs); |
||
3500 | |||
3501 | /// Get the list of helper destination expressions. |
||
3502 | MutableArrayRef<Expr *> getRHSExprs() { |
||
3503 | return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size()); |
||
3504 | } |
||
3505 | ArrayRef<const Expr *> getRHSExprs() const { |
||
3506 | return llvm::ArrayRef(getLHSExprs().end(), varlist_size()); |
||
3507 | } |
||
3508 | |||
3509 | /// Set list of helper reduction expressions, required for proper |
||
3510 | /// codegen of the clause. These expressions are binary expressions or |
||
3511 | /// operator/custom reduction call that calculates new value from source |
||
3512 | /// helper expressions to destination helper expressions. |
||
3513 | void setReductionOps(ArrayRef<Expr *> ReductionOps); |
||
3514 | |||
3515 | /// Get the list of helper reduction expressions. |
||
3516 | MutableArrayRef<Expr *> getReductionOps() { |
||
3517 | return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size()); |
||
3518 | } |
||
3519 | ArrayRef<const Expr *> getReductionOps() const { |
||
3520 | return llvm::ArrayRef(getRHSExprs().end(), varlist_size()); |
||
3521 | } |
||
3522 | |||
3523 | public: |
||
3524 | /// Creates clause with a list of variables \a VL. |
||
3525 | /// |
||
3526 | /// \param StartLoc Starting location of the clause. |
||
3527 | /// \param LParenLoc Location of '('. |
||
3528 | /// \param ColonLoc Location of ':'. |
||
3529 | /// \param EndLoc Ending location of the clause. |
||
3530 | /// \param VL The variables in the clause. |
||
3531 | /// \param QualifierLoc The nested-name qualifier with location information |
||
3532 | /// \param NameInfo The full name info for reduction identifier. |
||
3533 | /// \param Privates List of helper expressions for proper generation of |
||
3534 | /// private copies. |
||
3535 | /// \param LHSExprs List of helper expressions for proper generation of |
||
3536 | /// assignment operation required for copyprivate clause. This list represents |
||
3537 | /// LHSs of the reduction expressions. |
||
3538 | /// \param RHSExprs List of helper expressions for proper generation of |
||
3539 | /// assignment operation required for copyprivate clause. This list represents |
||
3540 | /// RHSs of the reduction expressions. |
||
3541 | /// Also, variables in these expressions are used for proper initialization of |
||
3542 | /// reduction copies. |
||
3543 | /// \param ReductionOps List of helper expressions that represents reduction |
||
3544 | /// expressions: |
||
3545 | /// \code |
||
3546 | /// LHSExprs binop RHSExprs; |
||
3547 | /// operator binop(LHSExpr, RHSExpr); |
||
3548 | /// <CutomReduction>(LHSExpr, RHSExpr); |
||
3549 | /// \endcode |
||
3550 | /// Required for proper codegen of final reduction operation performed by the |
||
3551 | /// reduction clause. |
||
3552 | /// \param PreInit Statement that must be executed before entering the OpenMP |
||
3553 | /// region with this clause. |
||
3554 | /// \param PostUpdate Expression that must be executed after exit from the |
||
3555 | /// OpenMP region with this clause. |
||
3556 | static OMPTaskReductionClause * |
||
3557 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3558 | SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, |
||
3559 | NestedNameSpecifierLoc QualifierLoc, |
||
3560 | const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates, |
||
3561 | ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs, |
||
3562 | ArrayRef<Expr *> ReductionOps, Stmt *PreInit, Expr *PostUpdate); |
||
3563 | |||
3564 | /// Creates an empty clause with the place for \a N variables. |
||
3565 | /// |
||
3566 | /// \param C AST context. |
||
3567 | /// \param N The number of variables. |
||
3568 | static OMPTaskReductionClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
3569 | |||
3570 | /// Gets location of ':' symbol in clause. |
||
3571 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
3572 | |||
3573 | /// Gets the name info for specified reduction identifier. |
||
3574 | const DeclarationNameInfo &getNameInfo() const { return NameInfo; } |
||
3575 | |||
3576 | /// Gets the nested name specifier. |
||
3577 | NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } |
||
3578 | |||
3579 | using helper_expr_iterator = MutableArrayRef<Expr *>::iterator; |
||
3580 | using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator; |
||
3581 | using helper_expr_range = llvm::iterator_range<helper_expr_iterator>; |
||
3582 | using helper_expr_const_range = |
||
3583 | llvm::iterator_range<helper_expr_const_iterator>; |
||
3584 | |||
3585 | helper_expr_const_range privates() const { |
||
3586 | return helper_expr_const_range(getPrivates().begin(), getPrivates().end()); |
||
3587 | } |
||
3588 | |||
3589 | helper_expr_range privates() { |
||
3590 | return helper_expr_range(getPrivates().begin(), getPrivates().end()); |
||
3591 | } |
||
3592 | |||
3593 | helper_expr_const_range lhs_exprs() const { |
||
3594 | return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end()); |
||
3595 | } |
||
3596 | |||
3597 | helper_expr_range lhs_exprs() { |
||
3598 | return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end()); |
||
3599 | } |
||
3600 | |||
3601 | helper_expr_const_range rhs_exprs() const { |
||
3602 | return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end()); |
||
3603 | } |
||
3604 | |||
3605 | helper_expr_range rhs_exprs() { |
||
3606 | return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end()); |
||
3607 | } |
||
3608 | |||
3609 | helper_expr_const_range reduction_ops() const { |
||
3610 | return helper_expr_const_range(getReductionOps().begin(), |
||
3611 | getReductionOps().end()); |
||
3612 | } |
||
3613 | |||
3614 | helper_expr_range reduction_ops() { |
||
3615 | return helper_expr_range(getReductionOps().begin(), |
||
3616 | getReductionOps().end()); |
||
3617 | } |
||
3618 | |||
3619 | child_range children() { |
||
3620 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
3621 | reinterpret_cast<Stmt **>(varlist_end())); |
||
3622 | } |
||
3623 | |||
3624 | const_child_range children() const { |
||
3625 | auto Children = const_cast<OMPTaskReductionClause *>(this)->children(); |
||
3626 | return const_child_range(Children.begin(), Children.end()); |
||
3627 | } |
||
3628 | |||
3629 | child_range used_children() { |
||
3630 | return child_range(child_iterator(), child_iterator()); |
||
3631 | } |
||
3632 | const_child_range used_children() const { |
||
3633 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
3634 | } |
||
3635 | |||
3636 | static bool classof(const OMPClause *T) { |
||
3637 | return T->getClauseKind() == llvm::omp::OMPC_task_reduction; |
||
3638 | } |
||
3639 | }; |
||
3640 | |||
3641 | /// This represents clause 'in_reduction' in the '#pragma omp task' directives. |
||
3642 | /// |
||
3643 | /// \code |
||
3644 | /// #pragma omp task in_reduction(+:a,b) |
||
3645 | /// \endcode |
||
3646 | /// In this example directive '#pragma omp task' has clause 'in_reduction' with |
||
3647 | /// operator '+' and the variables 'a' and 'b'. |
||
3648 | class OMPInReductionClause final |
||
3649 | : public OMPVarListClause<OMPInReductionClause>, |
||
3650 | public OMPClauseWithPostUpdate, |
||
3651 | private llvm::TrailingObjects<OMPInReductionClause, Expr *> { |
||
3652 | friend class OMPClauseReader; |
||
3653 | friend OMPVarListClause; |
||
3654 | friend TrailingObjects; |
||
3655 | |||
3656 | /// Location of ':'. |
||
3657 | SourceLocation ColonLoc; |
||
3658 | |||
3659 | /// Nested name specifier for C++. |
||
3660 | NestedNameSpecifierLoc QualifierLoc; |
||
3661 | |||
3662 | /// Name of custom operator. |
||
3663 | DeclarationNameInfo NameInfo; |
||
3664 | |||
3665 | /// Build clause with number of variables \a N. |
||
3666 | /// |
||
3667 | /// \param StartLoc Starting location of the clause. |
||
3668 | /// \param LParenLoc Location of '('. |
||
3669 | /// \param EndLoc Ending location of the clause. |
||
3670 | /// \param ColonLoc Location of ':'. |
||
3671 | /// \param N Number of the variables in the clause. |
||
3672 | /// \param QualifierLoc The nested-name qualifier with location information |
||
3673 | /// \param NameInfo The full name info for reduction identifier. |
||
3674 | OMPInReductionClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3675 | SourceLocation ColonLoc, SourceLocation EndLoc, |
||
3676 | unsigned N, NestedNameSpecifierLoc QualifierLoc, |
||
3677 | const DeclarationNameInfo &NameInfo) |
||
3678 | : OMPVarListClause<OMPInReductionClause>(llvm::omp::OMPC_in_reduction, |
||
3679 | StartLoc, LParenLoc, EndLoc, N), |
||
3680 | OMPClauseWithPostUpdate(this), ColonLoc(ColonLoc), |
||
3681 | QualifierLoc(QualifierLoc), NameInfo(NameInfo) {} |
||
3682 | |||
3683 | /// Build an empty clause. |
||
3684 | /// |
||
3685 | /// \param N Number of variables. |
||
3686 | explicit OMPInReductionClause(unsigned N) |
||
3687 | : OMPVarListClause<OMPInReductionClause>( |
||
3688 | llvm::omp::OMPC_in_reduction, SourceLocation(), SourceLocation(), |
||
3689 | SourceLocation(), N), |
||
3690 | OMPClauseWithPostUpdate(this) {} |
||
3691 | |||
3692 | /// Sets location of ':' symbol in clause. |
||
3693 | void setColonLoc(SourceLocation CL) { ColonLoc = CL; } |
||
3694 | |||
3695 | /// Sets the name info for specified reduction identifier. |
||
3696 | void setNameInfo(DeclarationNameInfo DNI) { NameInfo = DNI; } |
||
3697 | |||
3698 | /// Sets the nested name specifier. |
||
3699 | void setQualifierLoc(NestedNameSpecifierLoc NSL) { QualifierLoc = NSL; } |
||
3700 | |||
3701 | /// Set list of helper expressions, required for proper codegen of the clause. |
||
3702 | /// These expressions represent private copy of the reduction variable. |
||
3703 | void setPrivates(ArrayRef<Expr *> Privates); |
||
3704 | |||
3705 | /// Get the list of helper privates. |
||
3706 | MutableArrayRef<Expr *> getPrivates() { |
||
3707 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
3708 | } |
||
3709 | ArrayRef<const Expr *> getPrivates() const { |
||
3710 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
3711 | } |
||
3712 | |||
3713 | /// Set list of helper expressions, required for proper codegen of the clause. |
||
3714 | /// These expressions represent LHS expression in the final reduction |
||
3715 | /// expression performed by the reduction clause. |
||
3716 | void setLHSExprs(ArrayRef<Expr *> LHSExprs); |
||
3717 | |||
3718 | /// Get the list of helper LHS expressions. |
||
3719 | MutableArrayRef<Expr *> getLHSExprs() { |
||
3720 | return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size()); |
||
3721 | } |
||
3722 | ArrayRef<const Expr *> getLHSExprs() const { |
||
3723 | return llvm::ArrayRef(getPrivates().end(), varlist_size()); |
||
3724 | } |
||
3725 | |||
3726 | /// Set list of helper expressions, required for proper codegen of the clause. |
||
3727 | /// These expressions represent RHS expression in the final reduction |
||
3728 | /// expression performed by the reduction clause. Also, variables in these |
||
3729 | /// expressions are used for proper initialization of reduction copies. |
||
3730 | void setRHSExprs(ArrayRef<Expr *> RHSExprs); |
||
3731 | |||
3732 | /// Get the list of helper destination expressions. |
||
3733 | MutableArrayRef<Expr *> getRHSExprs() { |
||
3734 | return MutableArrayRef<Expr *>(getLHSExprs().end(), varlist_size()); |
||
3735 | } |
||
3736 | ArrayRef<const Expr *> getRHSExprs() const { |
||
3737 | return llvm::ArrayRef(getLHSExprs().end(), varlist_size()); |
||
3738 | } |
||
3739 | |||
3740 | /// Set list of helper reduction expressions, required for proper |
||
3741 | /// codegen of the clause. These expressions are binary expressions or |
||
3742 | /// operator/custom reduction call that calculates new value from source |
||
3743 | /// helper expressions to destination helper expressions. |
||
3744 | void setReductionOps(ArrayRef<Expr *> ReductionOps); |
||
3745 | |||
3746 | /// Get the list of helper reduction expressions. |
||
3747 | MutableArrayRef<Expr *> getReductionOps() { |
||
3748 | return MutableArrayRef<Expr *>(getRHSExprs().end(), varlist_size()); |
||
3749 | } |
||
3750 | ArrayRef<const Expr *> getReductionOps() const { |
||
3751 | return llvm::ArrayRef(getRHSExprs().end(), varlist_size()); |
||
3752 | } |
||
3753 | |||
3754 | /// Set list of helper reduction taskgroup descriptors. |
||
3755 | void setTaskgroupDescriptors(ArrayRef<Expr *> ReductionOps); |
||
3756 | |||
3757 | /// Get the list of helper reduction taskgroup descriptors. |
||
3758 | MutableArrayRef<Expr *> getTaskgroupDescriptors() { |
||
3759 | return MutableArrayRef<Expr *>(getReductionOps().end(), varlist_size()); |
||
3760 | } |
||
3761 | ArrayRef<const Expr *> getTaskgroupDescriptors() const { |
||
3762 | return llvm::ArrayRef(getReductionOps().end(), varlist_size()); |
||
3763 | } |
||
3764 | |||
3765 | public: |
||
3766 | /// Creates clause with a list of variables \a VL. |
||
3767 | /// |
||
3768 | /// \param StartLoc Starting location of the clause. |
||
3769 | /// \param LParenLoc Location of '('. |
||
3770 | /// \param ColonLoc Location of ':'. |
||
3771 | /// \param EndLoc Ending location of the clause. |
||
3772 | /// \param VL The variables in the clause. |
||
3773 | /// \param QualifierLoc The nested-name qualifier with location information |
||
3774 | /// \param NameInfo The full name info for reduction identifier. |
||
3775 | /// \param Privates List of helper expressions for proper generation of |
||
3776 | /// private copies. |
||
3777 | /// \param LHSExprs List of helper expressions for proper generation of |
||
3778 | /// assignment operation required for copyprivate clause. This list represents |
||
3779 | /// LHSs of the reduction expressions. |
||
3780 | /// \param RHSExprs List of helper expressions for proper generation of |
||
3781 | /// assignment operation required for copyprivate clause. This list represents |
||
3782 | /// RHSs of the reduction expressions. |
||
3783 | /// Also, variables in these expressions are used for proper initialization of |
||
3784 | /// reduction copies. |
||
3785 | /// \param ReductionOps List of helper expressions that represents reduction |
||
3786 | /// expressions: |
||
3787 | /// \code |
||
3788 | /// LHSExprs binop RHSExprs; |
||
3789 | /// operator binop(LHSExpr, RHSExpr); |
||
3790 | /// <CutomReduction>(LHSExpr, RHSExpr); |
||
3791 | /// \endcode |
||
3792 | /// Required for proper codegen of final reduction operation performed by the |
||
3793 | /// reduction clause. |
||
3794 | /// \param TaskgroupDescriptors List of helper taskgroup descriptors for |
||
3795 | /// corresponding items in parent taskgroup task_reduction clause. |
||
3796 | /// \param PreInit Statement that must be executed before entering the OpenMP |
||
3797 | /// region with this clause. |
||
3798 | /// \param PostUpdate Expression that must be executed after exit from the |
||
3799 | /// OpenMP region with this clause. |
||
3800 | static OMPInReductionClause * |
||
3801 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3802 | SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, |
||
3803 | NestedNameSpecifierLoc QualifierLoc, |
||
3804 | const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates, |
||
3805 | ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs, |
||
3806 | ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> TaskgroupDescriptors, |
||
3807 | Stmt *PreInit, Expr *PostUpdate); |
||
3808 | |||
3809 | /// Creates an empty clause with the place for \a N variables. |
||
3810 | /// |
||
3811 | /// \param C AST context. |
||
3812 | /// \param N The number of variables. |
||
3813 | static OMPInReductionClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
3814 | |||
3815 | /// Gets location of ':' symbol in clause. |
||
3816 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
3817 | |||
3818 | /// Gets the name info for specified reduction identifier. |
||
3819 | const DeclarationNameInfo &getNameInfo() const { return NameInfo; } |
||
3820 | |||
3821 | /// Gets the nested name specifier. |
||
3822 | NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } |
||
3823 | |||
3824 | using helper_expr_iterator = MutableArrayRef<Expr *>::iterator; |
||
3825 | using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator; |
||
3826 | using helper_expr_range = llvm::iterator_range<helper_expr_iterator>; |
||
3827 | using helper_expr_const_range = |
||
3828 | llvm::iterator_range<helper_expr_const_iterator>; |
||
3829 | |||
3830 | helper_expr_const_range privates() const { |
||
3831 | return helper_expr_const_range(getPrivates().begin(), getPrivates().end()); |
||
3832 | } |
||
3833 | |||
3834 | helper_expr_range privates() { |
||
3835 | return helper_expr_range(getPrivates().begin(), getPrivates().end()); |
||
3836 | } |
||
3837 | |||
3838 | helper_expr_const_range lhs_exprs() const { |
||
3839 | return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end()); |
||
3840 | } |
||
3841 | |||
3842 | helper_expr_range lhs_exprs() { |
||
3843 | return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end()); |
||
3844 | } |
||
3845 | |||
3846 | helper_expr_const_range rhs_exprs() const { |
||
3847 | return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end()); |
||
3848 | } |
||
3849 | |||
3850 | helper_expr_range rhs_exprs() { |
||
3851 | return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end()); |
||
3852 | } |
||
3853 | |||
3854 | helper_expr_const_range reduction_ops() const { |
||
3855 | return helper_expr_const_range(getReductionOps().begin(), |
||
3856 | getReductionOps().end()); |
||
3857 | } |
||
3858 | |||
3859 | helper_expr_range reduction_ops() { |
||
3860 | return helper_expr_range(getReductionOps().begin(), |
||
3861 | getReductionOps().end()); |
||
3862 | } |
||
3863 | |||
3864 | helper_expr_const_range taskgroup_descriptors() const { |
||
3865 | return helper_expr_const_range(getTaskgroupDescriptors().begin(), |
||
3866 | getTaskgroupDescriptors().end()); |
||
3867 | } |
||
3868 | |||
3869 | helper_expr_range taskgroup_descriptors() { |
||
3870 | return helper_expr_range(getTaskgroupDescriptors().begin(), |
||
3871 | getTaskgroupDescriptors().end()); |
||
3872 | } |
||
3873 | |||
3874 | child_range children() { |
||
3875 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
3876 | reinterpret_cast<Stmt **>(varlist_end())); |
||
3877 | } |
||
3878 | |||
3879 | const_child_range children() const { |
||
3880 | auto Children = const_cast<OMPInReductionClause *>(this)->children(); |
||
3881 | return const_child_range(Children.begin(), Children.end()); |
||
3882 | } |
||
3883 | |||
3884 | child_range used_children() { |
||
3885 | return child_range(child_iterator(), child_iterator()); |
||
3886 | } |
||
3887 | const_child_range used_children() const { |
||
3888 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
3889 | } |
||
3890 | |||
3891 | static bool classof(const OMPClause *T) { |
||
3892 | return T->getClauseKind() == llvm::omp::OMPC_in_reduction; |
||
3893 | } |
||
3894 | }; |
||
3895 | |||
3896 | /// This represents clause 'linear' in the '#pragma omp ...' |
||
3897 | /// directives. |
||
3898 | /// |
||
3899 | /// \code |
||
3900 | /// #pragma omp simd linear(a,b : 2) |
||
3901 | /// \endcode |
||
3902 | /// In this example directive '#pragma omp simd' has clause 'linear' |
||
3903 | /// with variables 'a', 'b' and linear step '2'. |
||
3904 | class OMPLinearClause final |
||
3905 | : public OMPVarListClause<OMPLinearClause>, |
||
3906 | public OMPClauseWithPostUpdate, |
||
3907 | private llvm::TrailingObjects<OMPLinearClause, Expr *> { |
||
3908 | friend class OMPClauseReader; |
||
3909 | friend OMPVarListClause; |
||
3910 | friend TrailingObjects; |
||
3911 | |||
3912 | /// Modifier of 'linear' clause. |
||
3913 | OpenMPLinearClauseKind Modifier = OMPC_LINEAR_val; |
||
3914 | |||
3915 | /// Location of linear modifier if any. |
||
3916 | SourceLocation ModifierLoc; |
||
3917 | |||
3918 | /// Location of ':'. |
||
3919 | SourceLocation ColonLoc; |
||
3920 | |||
3921 | /// Sets the linear step for clause. |
||
3922 | void setStep(Expr *Step) { *(getFinals().end()) = Step; } |
||
3923 | |||
3924 | /// Sets the expression to calculate linear step for clause. |
||
3925 | void setCalcStep(Expr *CalcStep) { *(getFinals().end() + 1) = CalcStep; } |
||
3926 | |||
3927 | /// Build 'linear' clause with given number of variables \a NumVars. |
||
3928 | /// |
||
3929 | /// \param StartLoc Starting location of the clause. |
||
3930 | /// \param LParenLoc Location of '('. |
||
3931 | /// \param ColonLoc Location of ':'. |
||
3932 | /// \param EndLoc Ending location of the clause. |
||
3933 | /// \param NumVars Number of variables. |
||
3934 | OMPLinearClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
3935 | OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, |
||
3936 | SourceLocation ColonLoc, SourceLocation EndLoc, |
||
3937 | unsigned NumVars) |
||
3938 | : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, StartLoc, |
||
3939 | LParenLoc, EndLoc, NumVars), |
||
3940 | OMPClauseWithPostUpdate(this), Modifier(Modifier), |
||
3941 | ModifierLoc(ModifierLoc), ColonLoc(ColonLoc) {} |
||
3942 | |||
3943 | /// Build an empty clause. |
||
3944 | /// |
||
3945 | /// \param NumVars Number of variables. |
||
3946 | explicit OMPLinearClause(unsigned NumVars) |
||
3947 | : OMPVarListClause<OMPLinearClause>(llvm::omp::OMPC_linear, |
||
3948 | SourceLocation(), SourceLocation(), |
||
3949 | SourceLocation(), NumVars), |
||
3950 | OMPClauseWithPostUpdate(this) {} |
||
3951 | |||
3952 | /// Gets the list of initial values for linear variables. |
||
3953 | /// |
||
3954 | /// There are NumVars expressions with initial values allocated after the |
||
3955 | /// varlist, they are followed by NumVars update expressions (used to update |
||
3956 | /// the linear variable's value on current iteration) and they are followed by |
||
3957 | /// NumVars final expressions (used to calculate the linear variable's |
||
3958 | /// value after the loop body). After these lists, there are 2 helper |
||
3959 | /// expressions - linear step and a helper to calculate it before the |
||
3960 | /// loop body (used when the linear step is not constant): |
||
3961 | /// |
||
3962 | /// { Vars[] /* in OMPVarListClause */; Privates[]; Inits[]; Updates[]; |
||
3963 | /// Finals[]; Step; CalcStep; } |
||
3964 | MutableArrayRef<Expr *> getPrivates() { |
||
3965 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
3966 | } |
||
3967 | ArrayRef<const Expr *> getPrivates() const { |
||
3968 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
3969 | } |
||
3970 | |||
3971 | MutableArrayRef<Expr *> getInits() { |
||
3972 | return MutableArrayRef<Expr *>(getPrivates().end(), varlist_size()); |
||
3973 | } |
||
3974 | ArrayRef<const Expr *> getInits() const { |
||
3975 | return llvm::ArrayRef(getPrivates().end(), varlist_size()); |
||
3976 | } |
||
3977 | |||
3978 | /// Sets the list of update expressions for linear variables. |
||
3979 | MutableArrayRef<Expr *> getUpdates() { |
||
3980 | return MutableArrayRef<Expr *>(getInits().end(), varlist_size()); |
||
3981 | } |
||
3982 | ArrayRef<const Expr *> getUpdates() const { |
||
3983 | return llvm::ArrayRef(getInits().end(), varlist_size()); |
||
3984 | } |
||
3985 | |||
3986 | /// Sets the list of final update expressions for linear variables. |
||
3987 | MutableArrayRef<Expr *> getFinals() { |
||
3988 | return MutableArrayRef<Expr *>(getUpdates().end(), varlist_size()); |
||
3989 | } |
||
3990 | ArrayRef<const Expr *> getFinals() const { |
||
3991 | return llvm::ArrayRef(getUpdates().end(), varlist_size()); |
||
3992 | } |
||
3993 | |||
3994 | /// Gets the list of used expressions for linear variables. |
||
3995 | MutableArrayRef<Expr *> getUsedExprs() { |
||
3996 | return MutableArrayRef<Expr *>(getFinals().end() + 2, varlist_size() + 1); |
||
3997 | } |
||
3998 | ArrayRef<const Expr *> getUsedExprs() const { |
||
3999 | return llvm::ArrayRef(getFinals().end() + 2, varlist_size() + 1); |
||
4000 | } |
||
4001 | |||
4002 | /// Sets the list of the copies of original linear variables. |
||
4003 | /// \param PL List of expressions. |
||
4004 | void setPrivates(ArrayRef<Expr *> PL); |
||
4005 | |||
4006 | /// Sets the list of the initial values for linear variables. |
||
4007 | /// \param IL List of expressions. |
||
4008 | void setInits(ArrayRef<Expr *> IL); |
||
4009 | |||
4010 | public: |
||
4011 | /// Creates clause with a list of variables \a VL and a linear step |
||
4012 | /// \a Step. |
||
4013 | /// |
||
4014 | /// \param C AST Context. |
||
4015 | /// \param StartLoc Starting location of the clause. |
||
4016 | /// \param LParenLoc Location of '('. |
||
4017 | /// \param Modifier Modifier of 'linear' clause. |
||
4018 | /// \param ModifierLoc Modifier location. |
||
4019 | /// \param ColonLoc Location of ':'. |
||
4020 | /// \param EndLoc Ending location of the clause. |
||
4021 | /// \param VL List of references to the variables. |
||
4022 | /// \param PL List of private copies of original variables. |
||
4023 | /// \param IL List of initial values for the variables. |
||
4024 | /// \param Step Linear step. |
||
4025 | /// \param CalcStep Calculation of the linear step. |
||
4026 | /// \param PreInit Statement that must be executed before entering the OpenMP |
||
4027 | /// region with this clause. |
||
4028 | /// \param PostUpdate Expression that must be executed after exit from the |
||
4029 | /// OpenMP region with this clause. |
||
4030 | static OMPLinearClause * |
||
4031 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4032 | OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, |
||
4033 | SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, |
||
4034 | ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep, |
||
4035 | Stmt *PreInit, Expr *PostUpdate); |
||
4036 | |||
4037 | /// Creates an empty clause with the place for \a NumVars variables. |
||
4038 | /// |
||
4039 | /// \param C AST context. |
||
4040 | /// \param NumVars Number of variables. |
||
4041 | static OMPLinearClause *CreateEmpty(const ASTContext &C, unsigned NumVars); |
||
4042 | |||
4043 | /// Set modifier. |
||
4044 | void setModifier(OpenMPLinearClauseKind Kind) { Modifier = Kind; } |
||
4045 | |||
4046 | /// Return modifier. |
||
4047 | OpenMPLinearClauseKind getModifier() const { return Modifier; } |
||
4048 | |||
4049 | /// Set modifier location. |
||
4050 | void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; } |
||
4051 | |||
4052 | /// Return modifier location. |
||
4053 | SourceLocation getModifierLoc() const { return ModifierLoc; } |
||
4054 | |||
4055 | /// Sets the location of ':'. |
||
4056 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
4057 | |||
4058 | /// Returns the location of ':'. |
||
4059 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
4060 | |||
4061 | /// Returns linear step. |
||
4062 | Expr *getStep() { return *(getFinals().end()); } |
||
4063 | |||
4064 | /// Returns linear step. |
||
4065 | const Expr *getStep() const { return *(getFinals().end()); } |
||
4066 | |||
4067 | /// Returns expression to calculate linear step. |
||
4068 | Expr *getCalcStep() { return *(getFinals().end() + 1); } |
||
4069 | |||
4070 | /// Returns expression to calculate linear step. |
||
4071 | const Expr *getCalcStep() const { return *(getFinals().end() + 1); } |
||
4072 | |||
4073 | /// Sets the list of update expressions for linear variables. |
||
4074 | /// \param UL List of expressions. |
||
4075 | void setUpdates(ArrayRef<Expr *> UL); |
||
4076 | |||
4077 | /// Sets the list of final update expressions for linear variables. |
||
4078 | /// \param FL List of expressions. |
||
4079 | void setFinals(ArrayRef<Expr *> FL); |
||
4080 | |||
4081 | /// Sets the list of used expressions for the linear clause. |
||
4082 | void setUsedExprs(ArrayRef<Expr *> UE); |
||
4083 | |||
4084 | using privates_iterator = MutableArrayRef<Expr *>::iterator; |
||
4085 | using privates_const_iterator = ArrayRef<const Expr *>::iterator; |
||
4086 | using privates_range = llvm::iterator_range<privates_iterator>; |
||
4087 | using privates_const_range = llvm::iterator_range<privates_const_iterator>; |
||
4088 | |||
4089 | privates_range privates() { |
||
4090 | return privates_range(getPrivates().begin(), getPrivates().end()); |
||
4091 | } |
||
4092 | |||
4093 | privates_const_range privates() const { |
||
4094 | return privates_const_range(getPrivates().begin(), getPrivates().end()); |
||
4095 | } |
||
4096 | |||
4097 | using inits_iterator = MutableArrayRef<Expr *>::iterator; |
||
4098 | using inits_const_iterator = ArrayRef<const Expr *>::iterator; |
||
4099 | using inits_range = llvm::iterator_range<inits_iterator>; |
||
4100 | using inits_const_range = llvm::iterator_range<inits_const_iterator>; |
||
4101 | |||
4102 | inits_range inits() { |
||
4103 | return inits_range(getInits().begin(), getInits().end()); |
||
4104 | } |
||
4105 | |||
4106 | inits_const_range inits() const { |
||
4107 | return inits_const_range(getInits().begin(), getInits().end()); |
||
4108 | } |
||
4109 | |||
4110 | using updates_iterator = MutableArrayRef<Expr *>::iterator; |
||
4111 | using updates_const_iterator = ArrayRef<const Expr *>::iterator; |
||
4112 | using updates_range = llvm::iterator_range<updates_iterator>; |
||
4113 | using updates_const_range = llvm::iterator_range<updates_const_iterator>; |
||
4114 | |||
4115 | updates_range updates() { |
||
4116 | return updates_range(getUpdates().begin(), getUpdates().end()); |
||
4117 | } |
||
4118 | |||
4119 | updates_const_range updates() const { |
||
4120 | return updates_const_range(getUpdates().begin(), getUpdates().end()); |
||
4121 | } |
||
4122 | |||
4123 | using finals_iterator = MutableArrayRef<Expr *>::iterator; |
||
4124 | using finals_const_iterator = ArrayRef<const Expr *>::iterator; |
||
4125 | using finals_range = llvm::iterator_range<finals_iterator>; |
||
4126 | using finals_const_range = llvm::iterator_range<finals_const_iterator>; |
||
4127 | |||
4128 | finals_range finals() { |
||
4129 | return finals_range(getFinals().begin(), getFinals().end()); |
||
4130 | } |
||
4131 | |||
4132 | finals_const_range finals() const { |
||
4133 | return finals_const_range(getFinals().begin(), getFinals().end()); |
||
4134 | } |
||
4135 | |||
4136 | using used_expressions_iterator = MutableArrayRef<Expr *>::iterator; |
||
4137 | using used_expressions_const_iterator = ArrayRef<const Expr *>::iterator; |
||
4138 | using used_expressions_range = |
||
4139 | llvm::iterator_range<used_expressions_iterator>; |
||
4140 | using used_expressions_const_range = |
||
4141 | llvm::iterator_range<used_expressions_const_iterator>; |
||
4142 | |||
4143 | used_expressions_range used_expressions() { |
||
4144 | return finals_range(getUsedExprs().begin(), getUsedExprs().end()); |
||
4145 | } |
||
4146 | |||
4147 | used_expressions_const_range used_expressions() const { |
||
4148 | return finals_const_range(getUsedExprs().begin(), getUsedExprs().end()); |
||
4149 | } |
||
4150 | |||
4151 | child_range children() { |
||
4152 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
4153 | reinterpret_cast<Stmt **>(varlist_end())); |
||
4154 | } |
||
4155 | |||
4156 | const_child_range children() const { |
||
4157 | auto Children = const_cast<OMPLinearClause *>(this)->children(); |
||
4158 | return const_child_range(Children.begin(), Children.end()); |
||
4159 | } |
||
4160 | |||
4161 | child_range used_children(); |
||
4162 | |||
4163 | const_child_range used_children() const { |
||
4164 | auto Children = const_cast<OMPLinearClause *>(this)->used_children(); |
||
4165 | return const_child_range(Children.begin(), Children.end()); |
||
4166 | } |
||
4167 | |||
4168 | static bool classof(const OMPClause *T) { |
||
4169 | return T->getClauseKind() == llvm::omp::OMPC_linear; |
||
4170 | } |
||
4171 | }; |
||
4172 | |||
4173 | /// This represents clause 'aligned' in the '#pragma omp ...' |
||
4174 | /// directives. |
||
4175 | /// |
||
4176 | /// \code |
||
4177 | /// #pragma omp simd aligned(a,b : 8) |
||
4178 | /// \endcode |
||
4179 | /// In this example directive '#pragma omp simd' has clause 'aligned' |
||
4180 | /// with variables 'a', 'b' and alignment '8'. |
||
4181 | class OMPAlignedClause final |
||
4182 | : public OMPVarListClause<OMPAlignedClause>, |
||
4183 | private llvm::TrailingObjects<OMPAlignedClause, Expr *> { |
||
4184 | friend class OMPClauseReader; |
||
4185 | friend OMPVarListClause; |
||
4186 | friend TrailingObjects; |
||
4187 | |||
4188 | /// Location of ':'. |
||
4189 | SourceLocation ColonLoc; |
||
4190 | |||
4191 | /// Sets the alignment for clause. |
||
4192 | void setAlignment(Expr *A) { *varlist_end() = A; } |
||
4193 | |||
4194 | /// Build 'aligned' clause with given number of variables \a NumVars. |
||
4195 | /// |
||
4196 | /// \param StartLoc Starting location of the clause. |
||
4197 | /// \param LParenLoc Location of '('. |
||
4198 | /// \param ColonLoc Location of ':'. |
||
4199 | /// \param EndLoc Ending location of the clause. |
||
4200 | /// \param NumVars Number of variables. |
||
4201 | OMPAlignedClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4202 | SourceLocation ColonLoc, SourceLocation EndLoc, |
||
4203 | unsigned NumVars) |
||
4204 | : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, StartLoc, |
||
4205 | LParenLoc, EndLoc, NumVars), |
||
4206 | ColonLoc(ColonLoc) {} |
||
4207 | |||
4208 | /// Build an empty clause. |
||
4209 | /// |
||
4210 | /// \param NumVars Number of variables. |
||
4211 | explicit OMPAlignedClause(unsigned NumVars) |
||
4212 | : OMPVarListClause<OMPAlignedClause>(llvm::omp::OMPC_aligned, |
||
4213 | SourceLocation(), SourceLocation(), |
||
4214 | SourceLocation(), NumVars) {} |
||
4215 | |||
4216 | public: |
||
4217 | /// Creates clause with a list of variables \a VL and alignment \a A. |
||
4218 | /// |
||
4219 | /// \param C AST Context. |
||
4220 | /// \param StartLoc Starting location of the clause. |
||
4221 | /// \param LParenLoc Location of '('. |
||
4222 | /// \param ColonLoc Location of ':'. |
||
4223 | /// \param EndLoc Ending location of the clause. |
||
4224 | /// \param VL List of references to the variables. |
||
4225 | /// \param A Alignment. |
||
4226 | static OMPAlignedClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
4227 | SourceLocation LParenLoc, |
||
4228 | SourceLocation ColonLoc, |
||
4229 | SourceLocation EndLoc, ArrayRef<Expr *> VL, |
||
4230 | Expr *A); |
||
4231 | |||
4232 | /// Creates an empty clause with the place for \a NumVars variables. |
||
4233 | /// |
||
4234 | /// \param C AST context. |
||
4235 | /// \param NumVars Number of variables. |
||
4236 | static OMPAlignedClause *CreateEmpty(const ASTContext &C, unsigned NumVars); |
||
4237 | |||
4238 | /// Sets the location of ':'. |
||
4239 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
4240 | |||
4241 | /// Returns the location of ':'. |
||
4242 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
4243 | |||
4244 | /// Returns alignment. |
||
4245 | Expr *getAlignment() { return *varlist_end(); } |
||
4246 | |||
4247 | /// Returns alignment. |
||
4248 | const Expr *getAlignment() const { return *varlist_end(); } |
||
4249 | |||
4250 | child_range children() { |
||
4251 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
4252 | reinterpret_cast<Stmt **>(varlist_end())); |
||
4253 | } |
||
4254 | |||
4255 | const_child_range children() const { |
||
4256 | auto Children = const_cast<OMPAlignedClause *>(this)->children(); |
||
4257 | return const_child_range(Children.begin(), Children.end()); |
||
4258 | } |
||
4259 | |||
4260 | child_range used_children() { |
||
4261 | return child_range(child_iterator(), child_iterator()); |
||
4262 | } |
||
4263 | const_child_range used_children() const { |
||
4264 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
4265 | } |
||
4266 | |||
4267 | static bool classof(const OMPClause *T) { |
||
4268 | return T->getClauseKind() == llvm::omp::OMPC_aligned; |
||
4269 | } |
||
4270 | }; |
||
4271 | |||
4272 | /// This represents clause 'copyin' in the '#pragma omp ...' directives. |
||
4273 | /// |
||
4274 | /// \code |
||
4275 | /// #pragma omp parallel copyin(a,b) |
||
4276 | /// \endcode |
||
4277 | /// In this example directive '#pragma omp parallel' has clause 'copyin' |
||
4278 | /// with the variables 'a' and 'b'. |
||
4279 | class OMPCopyinClause final |
||
4280 | : public OMPVarListClause<OMPCopyinClause>, |
||
4281 | private llvm::TrailingObjects<OMPCopyinClause, Expr *> { |
||
4282 | // Class has 3 additional tail allocated arrays: |
||
4283 | // 1. List of helper expressions for proper generation of assignment operation |
||
4284 | // required for copyin clause. This list represents sources. |
||
4285 | // 2. List of helper expressions for proper generation of assignment operation |
||
4286 | // required for copyin clause. This list represents destinations. |
||
4287 | // 3. List of helper expressions that represents assignment operation: |
||
4288 | // \code |
||
4289 | // DstExprs = SrcExprs; |
||
4290 | // \endcode |
||
4291 | // Required for proper codegen of propagation of master's thread values of |
||
4292 | // threadprivate variables to local instances of that variables in other |
||
4293 | // implicit threads. |
||
4294 | |||
4295 | friend class OMPClauseReader; |
||
4296 | friend OMPVarListClause; |
||
4297 | friend TrailingObjects; |
||
4298 | |||
4299 | /// Build clause with number of variables \a N. |
||
4300 | /// |
||
4301 | /// \param StartLoc Starting location of the clause. |
||
4302 | /// \param LParenLoc Location of '('. |
||
4303 | /// \param EndLoc Ending location of the clause. |
||
4304 | /// \param N Number of the variables in the clause. |
||
4305 | OMPCopyinClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4306 | SourceLocation EndLoc, unsigned N) |
||
4307 | : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, StartLoc, |
||
4308 | LParenLoc, EndLoc, N) {} |
||
4309 | |||
4310 | /// Build an empty clause. |
||
4311 | /// |
||
4312 | /// \param N Number of variables. |
||
4313 | explicit OMPCopyinClause(unsigned N) |
||
4314 | : OMPVarListClause<OMPCopyinClause>(llvm::omp::OMPC_copyin, |
||
4315 | SourceLocation(), SourceLocation(), |
||
4316 | SourceLocation(), N) {} |
||
4317 | |||
4318 | /// Set list of helper expressions, required for proper codegen of the |
||
4319 | /// clause. These expressions represent source expression in the final |
||
4320 | /// assignment statement performed by the copyin clause. |
||
4321 | void setSourceExprs(ArrayRef<Expr *> SrcExprs); |
||
4322 | |||
4323 | /// Get the list of helper source expressions. |
||
4324 | MutableArrayRef<Expr *> getSourceExprs() { |
||
4325 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
4326 | } |
||
4327 | ArrayRef<const Expr *> getSourceExprs() const { |
||
4328 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
4329 | } |
||
4330 | |||
4331 | /// Set list of helper expressions, required for proper codegen of the |
||
4332 | /// clause. These expressions represent destination expression in the final |
||
4333 | /// assignment statement performed by the copyin clause. |
||
4334 | void setDestinationExprs(ArrayRef<Expr *> DstExprs); |
||
4335 | |||
4336 | /// Get the list of helper destination expressions. |
||
4337 | MutableArrayRef<Expr *> getDestinationExprs() { |
||
4338 | return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size()); |
||
4339 | } |
||
4340 | ArrayRef<const Expr *> getDestinationExprs() const { |
||
4341 | return llvm::ArrayRef(getSourceExprs().end(), varlist_size()); |
||
4342 | } |
||
4343 | |||
4344 | /// Set list of helper assignment expressions, required for proper |
||
4345 | /// codegen of the clause. These expressions are assignment expressions that |
||
4346 | /// assign source helper expressions to destination helper expressions |
||
4347 | /// correspondingly. |
||
4348 | void setAssignmentOps(ArrayRef<Expr *> AssignmentOps); |
||
4349 | |||
4350 | /// Get the list of helper assignment expressions. |
||
4351 | MutableArrayRef<Expr *> getAssignmentOps() { |
||
4352 | return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size()); |
||
4353 | } |
||
4354 | ArrayRef<const Expr *> getAssignmentOps() const { |
||
4355 | return llvm::ArrayRef(getDestinationExprs().end(), varlist_size()); |
||
4356 | } |
||
4357 | |||
4358 | public: |
||
4359 | /// Creates clause with a list of variables \a VL. |
||
4360 | /// |
||
4361 | /// \param C AST context. |
||
4362 | /// \param StartLoc Starting location of the clause. |
||
4363 | /// \param LParenLoc Location of '('. |
||
4364 | /// \param EndLoc Ending location of the clause. |
||
4365 | /// \param VL List of references to the variables. |
||
4366 | /// \param SrcExprs List of helper expressions for proper generation of |
||
4367 | /// assignment operation required for copyin clause. This list represents |
||
4368 | /// sources. |
||
4369 | /// \param DstExprs List of helper expressions for proper generation of |
||
4370 | /// assignment operation required for copyin clause. This list represents |
||
4371 | /// destinations. |
||
4372 | /// \param AssignmentOps List of helper expressions that represents assignment |
||
4373 | /// operation: |
||
4374 | /// \code |
||
4375 | /// DstExprs = SrcExprs; |
||
4376 | /// \endcode |
||
4377 | /// Required for proper codegen of propagation of master's thread values of |
||
4378 | /// threadprivate variables to local instances of that variables in other |
||
4379 | /// implicit threads. |
||
4380 | static OMPCopyinClause * |
||
4381 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4382 | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
||
4383 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps); |
||
4384 | |||
4385 | /// Creates an empty clause with \a N variables. |
||
4386 | /// |
||
4387 | /// \param C AST context. |
||
4388 | /// \param N The number of variables. |
||
4389 | static OMPCopyinClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
4390 | |||
4391 | using helper_expr_iterator = MutableArrayRef<Expr *>::iterator; |
||
4392 | using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator; |
||
4393 | using helper_expr_range = llvm::iterator_range<helper_expr_iterator>; |
||
4394 | using helper_expr_const_range = |
||
4395 | llvm::iterator_range<helper_expr_const_iterator>; |
||
4396 | |||
4397 | helper_expr_const_range source_exprs() const { |
||
4398 | return helper_expr_const_range(getSourceExprs().begin(), |
||
4399 | getSourceExprs().end()); |
||
4400 | } |
||
4401 | |||
4402 | helper_expr_range source_exprs() { |
||
4403 | return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end()); |
||
4404 | } |
||
4405 | |||
4406 | helper_expr_const_range destination_exprs() const { |
||
4407 | return helper_expr_const_range(getDestinationExprs().begin(), |
||
4408 | getDestinationExprs().end()); |
||
4409 | } |
||
4410 | |||
4411 | helper_expr_range destination_exprs() { |
||
4412 | return helper_expr_range(getDestinationExprs().begin(), |
||
4413 | getDestinationExprs().end()); |
||
4414 | } |
||
4415 | |||
4416 | helper_expr_const_range assignment_ops() const { |
||
4417 | return helper_expr_const_range(getAssignmentOps().begin(), |
||
4418 | getAssignmentOps().end()); |
||
4419 | } |
||
4420 | |||
4421 | helper_expr_range assignment_ops() { |
||
4422 | return helper_expr_range(getAssignmentOps().begin(), |
||
4423 | getAssignmentOps().end()); |
||
4424 | } |
||
4425 | |||
4426 | child_range children() { |
||
4427 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
4428 | reinterpret_cast<Stmt **>(varlist_end())); |
||
4429 | } |
||
4430 | |||
4431 | const_child_range children() const { |
||
4432 | auto Children = const_cast<OMPCopyinClause *>(this)->children(); |
||
4433 | return const_child_range(Children.begin(), Children.end()); |
||
4434 | } |
||
4435 | |||
4436 | child_range used_children() { |
||
4437 | return child_range(child_iterator(), child_iterator()); |
||
4438 | } |
||
4439 | const_child_range used_children() const { |
||
4440 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
4441 | } |
||
4442 | |||
4443 | static bool classof(const OMPClause *T) { |
||
4444 | return T->getClauseKind() == llvm::omp::OMPC_copyin; |
||
4445 | } |
||
4446 | }; |
||
4447 | |||
4448 | /// This represents clause 'copyprivate' in the '#pragma omp ...' |
||
4449 | /// directives. |
||
4450 | /// |
||
4451 | /// \code |
||
4452 | /// #pragma omp single copyprivate(a,b) |
||
4453 | /// \endcode |
||
4454 | /// In this example directive '#pragma omp single' has clause 'copyprivate' |
||
4455 | /// with the variables 'a' and 'b'. |
||
4456 | class OMPCopyprivateClause final |
||
4457 | : public OMPVarListClause<OMPCopyprivateClause>, |
||
4458 | private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> { |
||
4459 | friend class OMPClauseReader; |
||
4460 | friend OMPVarListClause; |
||
4461 | friend TrailingObjects; |
||
4462 | |||
4463 | /// Build clause with number of variables \a N. |
||
4464 | /// |
||
4465 | /// \param StartLoc Starting location of the clause. |
||
4466 | /// \param LParenLoc Location of '('. |
||
4467 | /// \param EndLoc Ending location of the clause. |
||
4468 | /// \param N Number of the variables in the clause. |
||
4469 | OMPCopyprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4470 | SourceLocation EndLoc, unsigned N) |
||
4471 | : OMPVarListClause<OMPCopyprivateClause>(llvm::omp::OMPC_copyprivate, |
||
4472 | StartLoc, LParenLoc, EndLoc, N) { |
||
4473 | } |
||
4474 | |||
4475 | /// Build an empty clause. |
||
4476 | /// |
||
4477 | /// \param N Number of variables. |
||
4478 | explicit OMPCopyprivateClause(unsigned N) |
||
4479 | : OMPVarListClause<OMPCopyprivateClause>( |
||
4480 | llvm::omp::OMPC_copyprivate, SourceLocation(), SourceLocation(), |
||
4481 | SourceLocation(), N) {} |
||
4482 | |||
4483 | /// Set list of helper expressions, required for proper codegen of the |
||
4484 | /// clause. These expressions represent source expression in the final |
||
4485 | /// assignment statement performed by the copyprivate clause. |
||
4486 | void setSourceExprs(ArrayRef<Expr *> SrcExprs); |
||
4487 | |||
4488 | /// Get the list of helper source expressions. |
||
4489 | MutableArrayRef<Expr *> getSourceExprs() { |
||
4490 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
4491 | } |
||
4492 | ArrayRef<const Expr *> getSourceExprs() const { |
||
4493 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
4494 | } |
||
4495 | |||
4496 | /// Set list of helper expressions, required for proper codegen of the |
||
4497 | /// clause. These expressions represent destination expression in the final |
||
4498 | /// assignment statement performed by the copyprivate clause. |
||
4499 | void setDestinationExprs(ArrayRef<Expr *> DstExprs); |
||
4500 | |||
4501 | /// Get the list of helper destination expressions. |
||
4502 | MutableArrayRef<Expr *> getDestinationExprs() { |
||
4503 | return MutableArrayRef<Expr *>(getSourceExprs().end(), varlist_size()); |
||
4504 | } |
||
4505 | ArrayRef<const Expr *> getDestinationExprs() const { |
||
4506 | return llvm::ArrayRef(getSourceExprs().end(), varlist_size()); |
||
4507 | } |
||
4508 | |||
4509 | /// Set list of helper assignment expressions, required for proper |
||
4510 | /// codegen of the clause. These expressions are assignment expressions that |
||
4511 | /// assign source helper expressions to destination helper expressions |
||
4512 | /// correspondingly. |
||
4513 | void setAssignmentOps(ArrayRef<Expr *> AssignmentOps); |
||
4514 | |||
4515 | /// Get the list of helper assignment expressions. |
||
4516 | MutableArrayRef<Expr *> getAssignmentOps() { |
||
4517 | return MutableArrayRef<Expr *>(getDestinationExprs().end(), varlist_size()); |
||
4518 | } |
||
4519 | ArrayRef<const Expr *> getAssignmentOps() const { |
||
4520 | return llvm::ArrayRef(getDestinationExprs().end(), varlist_size()); |
||
4521 | } |
||
4522 | |||
4523 | public: |
||
4524 | /// Creates clause with a list of variables \a VL. |
||
4525 | /// |
||
4526 | /// \param C AST context. |
||
4527 | /// \param StartLoc Starting location of the clause. |
||
4528 | /// \param LParenLoc Location of '('. |
||
4529 | /// \param EndLoc Ending location of the clause. |
||
4530 | /// \param VL List of references to the variables. |
||
4531 | /// \param SrcExprs List of helper expressions for proper generation of |
||
4532 | /// assignment operation required for copyprivate clause. This list represents |
||
4533 | /// sources. |
||
4534 | /// \param DstExprs List of helper expressions for proper generation of |
||
4535 | /// assignment operation required for copyprivate clause. This list represents |
||
4536 | /// destinations. |
||
4537 | /// \param AssignmentOps List of helper expressions that represents assignment |
||
4538 | /// operation: |
||
4539 | /// \code |
||
4540 | /// DstExprs = SrcExprs; |
||
4541 | /// \endcode |
||
4542 | /// Required for proper codegen of final assignment performed by the |
||
4543 | /// copyprivate clause. |
||
4544 | static OMPCopyprivateClause * |
||
4545 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4546 | SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, |
||
4547 | ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps); |
||
4548 | |||
4549 | /// Creates an empty clause with \a N variables. |
||
4550 | /// |
||
4551 | /// \param C AST context. |
||
4552 | /// \param N The number of variables. |
||
4553 | static OMPCopyprivateClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
4554 | |||
4555 | using helper_expr_iterator = MutableArrayRef<Expr *>::iterator; |
||
4556 | using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator; |
||
4557 | using helper_expr_range = llvm::iterator_range<helper_expr_iterator>; |
||
4558 | using helper_expr_const_range = |
||
4559 | llvm::iterator_range<helper_expr_const_iterator>; |
||
4560 | |||
4561 | helper_expr_const_range source_exprs() const { |
||
4562 | return helper_expr_const_range(getSourceExprs().begin(), |
||
4563 | getSourceExprs().end()); |
||
4564 | } |
||
4565 | |||
4566 | helper_expr_range source_exprs() { |
||
4567 | return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end()); |
||
4568 | } |
||
4569 | |||
4570 | helper_expr_const_range destination_exprs() const { |
||
4571 | return helper_expr_const_range(getDestinationExprs().begin(), |
||
4572 | getDestinationExprs().end()); |
||
4573 | } |
||
4574 | |||
4575 | helper_expr_range destination_exprs() { |
||
4576 | return helper_expr_range(getDestinationExprs().begin(), |
||
4577 | getDestinationExprs().end()); |
||
4578 | } |
||
4579 | |||
4580 | helper_expr_const_range assignment_ops() const { |
||
4581 | return helper_expr_const_range(getAssignmentOps().begin(), |
||
4582 | getAssignmentOps().end()); |
||
4583 | } |
||
4584 | |||
4585 | helper_expr_range assignment_ops() { |
||
4586 | return helper_expr_range(getAssignmentOps().begin(), |
||
4587 | getAssignmentOps().end()); |
||
4588 | } |
||
4589 | |||
4590 | child_range children() { |
||
4591 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
4592 | reinterpret_cast<Stmt **>(varlist_end())); |
||
4593 | } |
||
4594 | |||
4595 | const_child_range children() const { |
||
4596 | auto Children = const_cast<OMPCopyprivateClause *>(this)->children(); |
||
4597 | return const_child_range(Children.begin(), Children.end()); |
||
4598 | } |
||
4599 | |||
4600 | child_range used_children() { |
||
4601 | return child_range(child_iterator(), child_iterator()); |
||
4602 | } |
||
4603 | const_child_range used_children() const { |
||
4604 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
4605 | } |
||
4606 | |||
4607 | static bool classof(const OMPClause *T) { |
||
4608 | return T->getClauseKind() == llvm::omp::OMPC_copyprivate; |
||
4609 | } |
||
4610 | }; |
||
4611 | |||
4612 | /// This represents implicit clause 'flush' for the '#pragma omp flush' |
||
4613 | /// directive. |
||
4614 | /// This clause does not exist by itself, it can be only as a part of 'omp |
||
4615 | /// flush' directive. This clause is introduced to keep the original structure |
||
4616 | /// of \a OMPExecutableDirective class and its derivatives and to use the |
||
4617 | /// existing infrastructure of clauses with the list of variables. |
||
4618 | /// |
||
4619 | /// \code |
||
4620 | /// #pragma omp flush(a,b) |
||
4621 | /// \endcode |
||
4622 | /// In this example directive '#pragma omp flush' has implicit clause 'flush' |
||
4623 | /// with the variables 'a' and 'b'. |
||
4624 | class OMPFlushClause final |
||
4625 | : public OMPVarListClause<OMPFlushClause>, |
||
4626 | private llvm::TrailingObjects<OMPFlushClause, Expr *> { |
||
4627 | friend OMPVarListClause; |
||
4628 | friend TrailingObjects; |
||
4629 | |||
4630 | /// Build clause with number of variables \a N. |
||
4631 | /// |
||
4632 | /// \param StartLoc Starting location of the clause. |
||
4633 | /// \param LParenLoc Location of '('. |
||
4634 | /// \param EndLoc Ending location of the clause. |
||
4635 | /// \param N Number of the variables in the clause. |
||
4636 | OMPFlushClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4637 | SourceLocation EndLoc, unsigned N) |
||
4638 | : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, StartLoc, |
||
4639 | LParenLoc, EndLoc, N) {} |
||
4640 | |||
4641 | /// Build an empty clause. |
||
4642 | /// |
||
4643 | /// \param N Number of variables. |
||
4644 | explicit OMPFlushClause(unsigned N) |
||
4645 | : OMPVarListClause<OMPFlushClause>(llvm::omp::OMPC_flush, |
||
4646 | SourceLocation(), SourceLocation(), |
||
4647 | SourceLocation(), N) {} |
||
4648 | |||
4649 | public: |
||
4650 | /// Creates clause with a list of variables \a VL. |
||
4651 | /// |
||
4652 | /// \param C AST context. |
||
4653 | /// \param StartLoc Starting location of the clause. |
||
4654 | /// \param LParenLoc Location of '('. |
||
4655 | /// \param EndLoc Ending location of the clause. |
||
4656 | /// \param VL List of references to the variables. |
||
4657 | static OMPFlushClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
4658 | SourceLocation LParenLoc, SourceLocation EndLoc, |
||
4659 | ArrayRef<Expr *> VL); |
||
4660 | |||
4661 | /// Creates an empty clause with \a N variables. |
||
4662 | /// |
||
4663 | /// \param C AST context. |
||
4664 | /// \param N The number of variables. |
||
4665 | static OMPFlushClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
4666 | |||
4667 | child_range children() { |
||
4668 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
4669 | reinterpret_cast<Stmt **>(varlist_end())); |
||
4670 | } |
||
4671 | |||
4672 | const_child_range children() const { |
||
4673 | auto Children = const_cast<OMPFlushClause *>(this)->children(); |
||
4674 | return const_child_range(Children.begin(), Children.end()); |
||
4675 | } |
||
4676 | |||
4677 | child_range used_children() { |
||
4678 | return child_range(child_iterator(), child_iterator()); |
||
4679 | } |
||
4680 | const_child_range used_children() const { |
||
4681 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
4682 | } |
||
4683 | |||
4684 | static bool classof(const OMPClause *T) { |
||
4685 | return T->getClauseKind() == llvm::omp::OMPC_flush; |
||
4686 | } |
||
4687 | }; |
||
4688 | |||
4689 | /// This represents implicit clause 'depobj' for the '#pragma omp depobj' |
||
4690 | /// directive. |
||
4691 | /// This clause does not exist by itself, it can be only as a part of 'omp |
||
4692 | /// depobj' directive. This clause is introduced to keep the original structure |
||
4693 | /// of \a OMPExecutableDirective class and its derivatives and to use the |
||
4694 | /// existing infrastructure of clauses with the list of variables. |
||
4695 | /// |
||
4696 | /// \code |
||
4697 | /// #pragma omp depobj(a) destroy |
||
4698 | /// \endcode |
||
4699 | /// In this example directive '#pragma omp depobj' has implicit clause 'depobj' |
||
4700 | /// with the depobj 'a'. |
||
4701 | class OMPDepobjClause final : public OMPClause { |
||
4702 | friend class OMPClauseReader; |
||
4703 | |||
4704 | /// Location of '('. |
||
4705 | SourceLocation LParenLoc; |
||
4706 | |||
4707 | /// Chunk size. |
||
4708 | Expr *Depobj = nullptr; |
||
4709 | |||
4710 | /// Build clause with number of variables \a N. |
||
4711 | /// |
||
4712 | /// \param StartLoc Starting location of the clause. |
||
4713 | /// \param LParenLoc Location of '('. |
||
4714 | /// \param EndLoc Ending location of the clause. |
||
4715 | OMPDepobjClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4716 | SourceLocation EndLoc) |
||
4717 | : OMPClause(llvm::omp::OMPC_depobj, StartLoc, EndLoc), |
||
4718 | LParenLoc(LParenLoc) {} |
||
4719 | |||
4720 | /// Build an empty clause. |
||
4721 | /// |
||
4722 | explicit OMPDepobjClause() |
||
4723 | : OMPClause(llvm::omp::OMPC_depobj, SourceLocation(), SourceLocation()) {} |
||
4724 | |||
4725 | void setDepobj(Expr *E) { Depobj = E; } |
||
4726 | |||
4727 | /// Sets the location of '('. |
||
4728 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
4729 | |||
4730 | public: |
||
4731 | /// Creates clause. |
||
4732 | /// |
||
4733 | /// \param C AST context. |
||
4734 | /// \param StartLoc Starting location of the clause. |
||
4735 | /// \param LParenLoc Location of '('. |
||
4736 | /// \param EndLoc Ending location of the clause. |
||
4737 | /// \param Depobj depobj expression associated with the 'depobj' directive. |
||
4738 | static OMPDepobjClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
4739 | SourceLocation LParenLoc, |
||
4740 | SourceLocation EndLoc, Expr *Depobj); |
||
4741 | |||
4742 | /// Creates an empty clause. |
||
4743 | /// |
||
4744 | /// \param C AST context. |
||
4745 | static OMPDepobjClause *CreateEmpty(const ASTContext &C); |
||
4746 | |||
4747 | /// Returns depobj expression associated with the clause. |
||
4748 | Expr *getDepobj() { return Depobj; } |
||
4749 | const Expr *getDepobj() const { return Depobj; } |
||
4750 | |||
4751 | /// Returns the location of '('. |
||
4752 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
4753 | |||
4754 | child_range children() { |
||
4755 | return child_range(reinterpret_cast<Stmt **>(&Depobj), |
||
4756 | reinterpret_cast<Stmt **>(&Depobj) + 1); |
||
4757 | } |
||
4758 | |||
4759 | const_child_range children() const { |
||
4760 | auto Children = const_cast<OMPDepobjClause *>(this)->children(); |
||
4761 | return const_child_range(Children.begin(), Children.end()); |
||
4762 | } |
||
4763 | |||
4764 | child_range used_children() { |
||
4765 | return child_range(child_iterator(), child_iterator()); |
||
4766 | } |
||
4767 | const_child_range used_children() const { |
||
4768 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
4769 | } |
||
4770 | |||
4771 | static bool classof(const OMPClause *T) { |
||
4772 | return T->getClauseKind() == llvm::omp::OMPC_depobj; |
||
4773 | } |
||
4774 | }; |
||
4775 | |||
4776 | /// This represents implicit clause 'depend' for the '#pragma omp task' |
||
4777 | /// directive. |
||
4778 | /// |
||
4779 | /// \code |
||
4780 | /// #pragma omp task depend(in:a,b) |
||
4781 | /// \endcode |
||
4782 | /// In this example directive '#pragma omp task' with clause 'depend' with the |
||
4783 | /// variables 'a' and 'b' with dependency 'in'. |
||
4784 | class OMPDependClause final |
||
4785 | : public OMPVarListClause<OMPDependClause>, |
||
4786 | private llvm::TrailingObjects<OMPDependClause, Expr *> { |
||
4787 | friend class OMPClauseReader; |
||
4788 | friend OMPVarListClause; |
||
4789 | friend TrailingObjects; |
||
4790 | |||
4791 | public: |
||
4792 | struct DependDataTy final { |
||
4793 | /// Dependency type (one of in, out, inout). |
||
4794 | OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown; |
||
4795 | |||
4796 | /// Dependency type location. |
||
4797 | SourceLocation DepLoc; |
||
4798 | |||
4799 | /// Colon location. |
||
4800 | SourceLocation ColonLoc; |
||
4801 | |||
4802 | /// Location of 'omp_all_memory'. |
||
4803 | SourceLocation OmpAllMemoryLoc; |
||
4804 | }; |
||
4805 | |||
4806 | private: |
||
4807 | /// Dependency type and source locations. |
||
4808 | DependDataTy Data; |
||
4809 | |||
4810 | /// Number of loops, associated with the depend clause. |
||
4811 | unsigned NumLoops = 0; |
||
4812 | |||
4813 | /// Build clause with number of variables \a N. |
||
4814 | /// |
||
4815 | /// \param StartLoc Starting location of the clause. |
||
4816 | /// \param LParenLoc Location of '('. |
||
4817 | /// \param EndLoc Ending location of the clause. |
||
4818 | /// \param N Number of the variables in the clause. |
||
4819 | /// \param NumLoops Number of loops that is associated with this depend |
||
4820 | /// clause. |
||
4821 | OMPDependClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
4822 | SourceLocation EndLoc, unsigned N, unsigned NumLoops) |
||
4823 | : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, StartLoc, |
||
4824 | LParenLoc, EndLoc, N), |
||
4825 | NumLoops(NumLoops) {} |
||
4826 | |||
4827 | /// Build an empty clause. |
||
4828 | /// |
||
4829 | /// \param N Number of variables. |
||
4830 | /// \param NumLoops Number of loops that is associated with this depend |
||
4831 | /// clause. |
||
4832 | explicit OMPDependClause(unsigned N, unsigned NumLoops) |
||
4833 | : OMPVarListClause<OMPDependClause>(llvm::omp::OMPC_depend, |
||
4834 | SourceLocation(), SourceLocation(), |
||
4835 | SourceLocation(), N), |
||
4836 | NumLoops(NumLoops) {} |
||
4837 | |||
4838 | /// Set dependency kind. |
||
4839 | void setDependencyKind(OpenMPDependClauseKind K) { Data.DepKind = K; } |
||
4840 | |||
4841 | /// Set dependency kind and its location. |
||
4842 | void setDependencyLoc(SourceLocation Loc) { Data.DepLoc = Loc; } |
||
4843 | |||
4844 | /// Set colon location. |
||
4845 | void setColonLoc(SourceLocation Loc) { Data.ColonLoc = Loc; } |
||
4846 | |||
4847 | /// Set the 'omp_all_memory' location. |
||
4848 | void setOmpAllMemoryLoc(SourceLocation Loc) { Data.OmpAllMemoryLoc = Loc; } |
||
4849 | |||
4850 | /// Sets optional dependency modifier. |
||
4851 | void setModifier(Expr *DepModifier); |
||
4852 | |||
4853 | public: |
||
4854 | /// Creates clause with a list of variables \a VL. |
||
4855 | /// |
||
4856 | /// \param C AST context. |
||
4857 | /// \param StartLoc Starting location of the clause. |
||
4858 | /// \param LParenLoc Location of '('. |
||
4859 | /// \param EndLoc Ending location of the clause. |
||
4860 | /// \param Data Dependency type and source locations. |
||
4861 | /// \param VL List of references to the variables. |
||
4862 | /// \param NumLoops Number of loops that is associated with this depend |
||
4863 | /// clause. |
||
4864 | static OMPDependClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
4865 | SourceLocation LParenLoc, |
||
4866 | SourceLocation EndLoc, DependDataTy Data, |
||
4867 | Expr *DepModifier, ArrayRef<Expr *> VL, |
||
4868 | unsigned NumLoops); |
||
4869 | |||
4870 | /// Creates an empty clause with \a N variables. |
||
4871 | /// |
||
4872 | /// \param C AST context. |
||
4873 | /// \param N The number of variables. |
||
4874 | /// \param NumLoops Number of loops that is associated with this depend |
||
4875 | /// clause. |
||
4876 | static OMPDependClause *CreateEmpty(const ASTContext &C, unsigned N, |
||
4877 | unsigned NumLoops); |
||
4878 | |||
4879 | /// Get dependency type. |
||
4880 | OpenMPDependClauseKind getDependencyKind() const { return Data.DepKind; } |
||
4881 | |||
4882 | /// Get dependency type location. |
||
4883 | SourceLocation getDependencyLoc() const { return Data.DepLoc; } |
||
4884 | |||
4885 | /// Get colon location. |
||
4886 | SourceLocation getColonLoc() const { return Data.ColonLoc; } |
||
4887 | |||
4888 | /// Get 'omp_all_memory' location. |
||
4889 | SourceLocation getOmpAllMemoryLoc() const { return Data.OmpAllMemoryLoc; } |
||
4890 | |||
4891 | /// Return optional depend modifier. |
||
4892 | Expr *getModifier(); |
||
4893 | const Expr *getModifier() const { |
||
4894 | return const_cast<OMPDependClause *>(this)->getModifier(); |
||
4895 | } |
||
4896 | |||
4897 | /// Get number of loops associated with the clause. |
||
4898 | unsigned getNumLoops() const { return NumLoops; } |
||
4899 | |||
4900 | /// Set the loop data for the depend clauses with 'sink|source' kind of |
||
4901 | /// dependency. |
||
4902 | void setLoopData(unsigned NumLoop, Expr *Cnt); |
||
4903 | |||
4904 | /// Get the loop data. |
||
4905 | Expr *getLoopData(unsigned NumLoop); |
||
4906 | const Expr *getLoopData(unsigned NumLoop) const; |
||
4907 | |||
4908 | child_range children() { |
||
4909 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
4910 | reinterpret_cast<Stmt **>(varlist_end())); |
||
4911 | } |
||
4912 | |||
4913 | const_child_range children() const { |
||
4914 | auto Children = const_cast<OMPDependClause *>(this)->children(); |
||
4915 | return const_child_range(Children.begin(), Children.end()); |
||
4916 | } |
||
4917 | |||
4918 | child_range used_children() { |
||
4919 | return child_range(child_iterator(), child_iterator()); |
||
4920 | } |
||
4921 | const_child_range used_children() const { |
||
4922 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
4923 | } |
||
4924 | |||
4925 | static bool classof(const OMPClause *T) { |
||
4926 | return T->getClauseKind() == llvm::omp::OMPC_depend; |
||
4927 | } |
||
4928 | }; |
||
4929 | |||
4930 | /// This represents 'device' clause in the '#pragma omp ...' |
||
4931 | /// directive. |
||
4932 | /// |
||
4933 | /// \code |
||
4934 | /// #pragma omp target device(a) |
||
4935 | /// \endcode |
||
4936 | /// In this example directive '#pragma omp target' has clause 'device' |
||
4937 | /// with single expression 'a'. |
||
4938 | class OMPDeviceClause : public OMPClause, public OMPClauseWithPreInit { |
||
4939 | friend class OMPClauseReader; |
||
4940 | |||
4941 | /// Location of '('. |
||
4942 | SourceLocation LParenLoc; |
||
4943 | |||
4944 | /// Device clause modifier. |
||
4945 | OpenMPDeviceClauseModifier Modifier = OMPC_DEVICE_unknown; |
||
4946 | |||
4947 | /// Location of the modifier. |
||
4948 | SourceLocation ModifierLoc; |
||
4949 | |||
4950 | /// Device number. |
||
4951 | Stmt *Device = nullptr; |
||
4952 | |||
4953 | /// Set the device number. |
||
4954 | /// |
||
4955 | /// \param E Device number. |
||
4956 | void setDevice(Expr *E) { Device = E; } |
||
4957 | |||
4958 | /// Sets modifier. |
||
4959 | void setModifier(OpenMPDeviceClauseModifier M) { Modifier = M; } |
||
4960 | |||
4961 | /// Setst modifier location. |
||
4962 | void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; } |
||
4963 | |||
4964 | public: |
||
4965 | /// Build 'device' clause. |
||
4966 | /// |
||
4967 | /// \param Modifier Clause modifier. |
||
4968 | /// \param E Expression associated with this clause. |
||
4969 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
4970 | /// clause must be captured. |
||
4971 | /// \param StartLoc Starting location of the clause. |
||
4972 | /// \param ModifierLoc Modifier location. |
||
4973 | /// \param LParenLoc Location of '('. |
||
4974 | /// \param EndLoc Ending location of the clause. |
||
4975 | OMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *E, Stmt *HelperE, |
||
4976 | OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, |
||
4977 | SourceLocation LParenLoc, SourceLocation ModifierLoc, |
||
4978 | SourceLocation EndLoc) |
||
4979 | : OMPClause(llvm::omp::OMPC_device, StartLoc, EndLoc), |
||
4980 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier), |
||
4981 | ModifierLoc(ModifierLoc), Device(E) { |
||
4982 | setPreInitStmt(HelperE, CaptureRegion); |
||
4983 | } |
||
4984 | |||
4985 | /// Build an empty clause. |
||
4986 | OMPDeviceClause() |
||
4987 | : OMPClause(llvm::omp::OMPC_device, SourceLocation(), SourceLocation()), |
||
4988 | OMPClauseWithPreInit(this) {} |
||
4989 | |||
4990 | /// Sets the location of '('. |
||
4991 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
4992 | |||
4993 | /// Returns the location of '('. |
||
4994 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
4995 | |||
4996 | /// Return device number. |
||
4997 | Expr *getDevice() { return cast<Expr>(Device); } |
||
4998 | |||
4999 | /// Return device number. |
||
5000 | Expr *getDevice() const { return cast<Expr>(Device); } |
||
5001 | |||
5002 | /// Gets modifier. |
||
5003 | OpenMPDeviceClauseModifier getModifier() const { return Modifier; } |
||
5004 | |||
5005 | /// Gets modifier location. |
||
5006 | SourceLocation getModifierLoc() const { return ModifierLoc; } |
||
5007 | |||
5008 | child_range children() { return child_range(&Device, &Device + 1); } |
||
5009 | |||
5010 | const_child_range children() const { |
||
5011 | return const_child_range(&Device, &Device + 1); |
||
5012 | } |
||
5013 | |||
5014 | child_range used_children() { |
||
5015 | return child_range(child_iterator(), child_iterator()); |
||
5016 | } |
||
5017 | const_child_range used_children() const { |
||
5018 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
5019 | } |
||
5020 | |||
5021 | static bool classof(const OMPClause *T) { |
||
5022 | return T->getClauseKind() == llvm::omp::OMPC_device; |
||
5023 | } |
||
5024 | }; |
||
5025 | |||
5026 | /// This represents 'threads' clause in the '#pragma omp ...' directive. |
||
5027 | /// |
||
5028 | /// \code |
||
5029 | /// #pragma omp ordered threads |
||
5030 | /// \endcode |
||
5031 | /// In this example directive '#pragma omp ordered' has simple 'threads' clause. |
||
5032 | class OMPThreadsClause final |
||
5033 | : public OMPNoChildClause<llvm::omp::OMPC_threads> { |
||
5034 | public: |
||
5035 | /// Build 'threads' clause. |
||
5036 | /// |
||
5037 | /// \param StartLoc Starting location of the clause. |
||
5038 | /// \param EndLoc Ending location of the clause. |
||
5039 | OMPThreadsClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
5040 | : OMPNoChildClause(StartLoc, EndLoc) {} |
||
5041 | |||
5042 | /// Build an empty clause. |
||
5043 | OMPThreadsClause() : OMPNoChildClause() {} |
||
5044 | }; |
||
5045 | |||
5046 | /// This represents 'simd' clause in the '#pragma omp ...' directive. |
||
5047 | /// |
||
5048 | /// \code |
||
5049 | /// #pragma omp ordered simd |
||
5050 | /// \endcode |
||
5051 | /// In this example directive '#pragma omp ordered' has simple 'simd' clause. |
||
5052 | class OMPSIMDClause : public OMPClause { |
||
5053 | public: |
||
5054 | /// Build 'simd' clause. |
||
5055 | /// |
||
5056 | /// \param StartLoc Starting location of the clause. |
||
5057 | /// \param EndLoc Ending location of the clause. |
||
5058 | OMPSIMDClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
5059 | : OMPClause(llvm::omp::OMPC_simd, StartLoc, EndLoc) {} |
||
5060 | |||
5061 | /// Build an empty clause. |
||
5062 | OMPSIMDClause() |
||
5063 | : OMPClause(llvm::omp::OMPC_simd, SourceLocation(), SourceLocation()) {} |
||
5064 | |||
5065 | child_range children() { |
||
5066 | return child_range(child_iterator(), child_iterator()); |
||
5067 | } |
||
5068 | |||
5069 | const_child_range children() const { |
||
5070 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
5071 | } |
||
5072 | |||
5073 | child_range used_children() { |
||
5074 | return child_range(child_iterator(), child_iterator()); |
||
5075 | } |
||
5076 | const_child_range used_children() const { |
||
5077 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
5078 | } |
||
5079 | |||
5080 | static bool classof(const OMPClause *T) { |
||
5081 | return T->getClauseKind() == llvm::omp::OMPC_simd; |
||
5082 | } |
||
5083 | }; |
||
5084 | |||
5085 | /// Struct that defines common infrastructure to handle mappable |
||
5086 | /// expressions used in OpenMP clauses. |
||
5087 | class OMPClauseMappableExprCommon { |
||
5088 | public: |
||
5089 | /// Class that represents a component of a mappable expression. E.g. |
||
5090 | /// for an expression S.a, the first component is a declaration reference |
||
5091 | /// expression associated with 'S' and the second is a member expression |
||
5092 | /// associated with the field declaration 'a'. If the expression is an array |
||
5093 | /// subscript it may not have any associated declaration. In that case the |
||
5094 | /// associated declaration is set to nullptr. |
||
5095 | class MappableComponent { |
||
5096 | /// Pair of Expression and Non-contiguous pair associated with the |
||
5097 | /// component. |
||
5098 | llvm::PointerIntPair<Expr *, 1, bool> AssociatedExpressionNonContiguousPr; |
||
5099 | |||
5100 | /// Declaration associated with the declaration. If the component does |
||
5101 | /// not have a declaration (e.g. array subscripts or section), this is set |
||
5102 | /// to nullptr. |
||
5103 | ValueDecl *AssociatedDeclaration = nullptr; |
||
5104 | |||
5105 | public: |
||
5106 | explicit MappableComponent() = default; |
||
5107 | explicit MappableComponent(Expr *AssociatedExpression, |
||
5108 | ValueDecl *AssociatedDeclaration, |
||
5109 | bool IsNonContiguous) |
||
5110 | : AssociatedExpressionNonContiguousPr(AssociatedExpression, |
||
5111 | IsNonContiguous), |
||
5112 | AssociatedDeclaration( |
||
5113 | AssociatedDeclaration |
||
5114 | ? cast<ValueDecl>(AssociatedDeclaration->getCanonicalDecl()) |
||
5115 | : nullptr) {} |
||
5116 | |||
5117 | Expr *getAssociatedExpression() const { |
||
5118 | return AssociatedExpressionNonContiguousPr.getPointer(); |
||
5119 | } |
||
5120 | |||
5121 | bool isNonContiguous() const { |
||
5122 | return AssociatedExpressionNonContiguousPr.getInt(); |
||
5123 | } |
||
5124 | |||
5125 | ValueDecl *getAssociatedDeclaration() const { |
||
5126 | return AssociatedDeclaration; |
||
5127 | } |
||
5128 | }; |
||
5129 | |||
5130 | // List of components of an expression. This first one is the whole |
||
5131 | // expression and the last one is the base expression. |
||
5132 | using MappableExprComponentList = SmallVector<MappableComponent, 8>; |
||
5133 | using MappableExprComponentListRef = ArrayRef<MappableComponent>; |
||
5134 | |||
5135 | // List of all component lists associated to the same base declaration. |
||
5136 | // E.g. if both 'S.a' and 'S.b' are a mappable expressions, each will have |
||
5137 | // their component list but the same base declaration 'S'. |
||
5138 | using MappableExprComponentLists = SmallVector<MappableExprComponentList, 8>; |
||
5139 | using MappableExprComponentListsRef = ArrayRef<MappableExprComponentList>; |
||
5140 | |||
5141 | protected: |
||
5142 | // Return the total number of elements in a list of component lists. |
||
5143 | static unsigned |
||
5144 | getComponentsTotalNumber(MappableExprComponentListsRef ComponentLists); |
||
5145 | |||
5146 | // Return the total number of elements in a list of declarations. All |
||
5147 | // declarations are expected to be canonical. |
||
5148 | static unsigned |
||
5149 | getUniqueDeclarationsTotalNumber(ArrayRef<const ValueDecl *> Declarations); |
||
5150 | }; |
||
5151 | |||
5152 | /// This structure contains all sizes needed for by an |
||
5153 | /// OMPMappableExprListClause. |
||
5154 | struct OMPMappableExprListSizeTy { |
||
5155 | /// Number of expressions listed. |
||
5156 | unsigned NumVars; |
||
5157 | /// Number of unique base declarations. |
||
5158 | unsigned NumUniqueDeclarations; |
||
5159 | /// Number of component lists. |
||
5160 | unsigned NumComponentLists; |
||
5161 | /// Total number of expression components. |
||
5162 | unsigned NumComponents; |
||
5163 | OMPMappableExprListSizeTy() = default; |
||
5164 | OMPMappableExprListSizeTy(unsigned NumVars, unsigned NumUniqueDeclarations, |
||
5165 | unsigned NumComponentLists, unsigned NumComponents) |
||
5166 | : NumVars(NumVars), NumUniqueDeclarations(NumUniqueDeclarations), |
||
5167 | NumComponentLists(NumComponentLists), NumComponents(NumComponents) {} |
||
5168 | }; |
||
5169 | |||
5170 | /// This represents clauses with a list of expressions that are mappable. |
||
5171 | /// Examples of these clauses are 'map' in |
||
5172 | /// '#pragma omp target [enter|exit] [data]...' directives, and 'to' and 'from |
||
5173 | /// in '#pragma omp target update...' directives. |
||
5174 | template <class T> |
||
5175 | class OMPMappableExprListClause : public OMPVarListClause<T>, |
||
5176 | public OMPClauseMappableExprCommon { |
||
5177 | friend class OMPClauseReader; |
||
5178 | |||
5179 | /// Number of unique declarations in this clause. |
||
5180 | unsigned NumUniqueDeclarations; |
||
5181 | |||
5182 | /// Number of component lists in this clause. |
||
5183 | unsigned NumComponentLists; |
||
5184 | |||
5185 | /// Total number of components in this clause. |
||
5186 | unsigned NumComponents; |
||
5187 | |||
5188 | /// Whether this clause is possible to have user-defined mappers associated. |
||
5189 | /// It should be true for map, to, and from clauses, and false for |
||
5190 | /// use_device_ptr and is_device_ptr. |
||
5191 | const bool SupportsMapper; |
||
5192 | |||
5193 | /// C++ nested name specifier for the associated user-defined mapper. |
||
5194 | NestedNameSpecifierLoc MapperQualifierLoc; |
||
5195 | |||
5196 | /// The associated user-defined mapper identifier information. |
||
5197 | DeclarationNameInfo MapperIdInfo; |
||
5198 | |||
5199 | protected: |
||
5200 | /// Build a clause for \a NumUniqueDeclarations declarations, \a |
||
5201 | /// NumComponentLists total component lists, and \a NumComponents total |
||
5202 | /// components. |
||
5203 | /// |
||
5204 | /// \param K Kind of the clause. |
||
5205 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
5206 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
5207 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
5208 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
5209 | /// NumVars: number of expressions listed in this clause; 2) |
||
5210 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
5211 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
5212 | /// NumComponents: total number of expression components in the clause. |
||
5213 | /// \param SupportsMapper Indicates whether this clause is possible to have |
||
5214 | /// user-defined mappers associated. |
||
5215 | /// \param MapperQualifierLocPtr C++ nested name specifier for the associated |
||
5216 | /// user-defined mapper. |
||
5217 | /// \param MapperIdInfoPtr The identifier of associated user-defined mapper. |
||
5218 | OMPMappableExprListClause( |
||
5219 | OpenMPClauseKind K, const OMPVarListLocTy &Locs, |
||
5220 | const OMPMappableExprListSizeTy &Sizes, bool SupportsMapper = false, |
||
5221 | NestedNameSpecifierLoc *MapperQualifierLocPtr = nullptr, |
||
5222 | DeclarationNameInfo *MapperIdInfoPtr = nullptr) |
||
5223 | : OMPVarListClause<T>(K, Locs.StartLoc, Locs.LParenLoc, Locs.EndLoc, |
||
5224 | Sizes.NumVars), |
||
5225 | NumUniqueDeclarations(Sizes.NumUniqueDeclarations), |
||
5226 | NumComponentLists(Sizes.NumComponentLists), |
||
5227 | NumComponents(Sizes.NumComponents), SupportsMapper(SupportsMapper) { |
||
5228 | if (MapperQualifierLocPtr) |
||
5229 | MapperQualifierLoc = *MapperQualifierLocPtr; |
||
5230 | if (MapperIdInfoPtr) |
||
5231 | MapperIdInfo = *MapperIdInfoPtr; |
||
5232 | } |
||
5233 | |||
5234 | /// Get the unique declarations that are in the trailing objects of the |
||
5235 | /// class. |
||
5236 | MutableArrayRef<ValueDecl *> getUniqueDeclsRef() { |
||
5237 | return MutableArrayRef<ValueDecl *>( |
||
5238 | static_cast<T *>(this)->template getTrailingObjects<ValueDecl *>(), |
||
5239 | NumUniqueDeclarations); |
||
5240 | } |
||
5241 | |||
5242 | /// Get the unique declarations that are in the trailing objects of the |
||
5243 | /// class. |
||
5244 | ArrayRef<ValueDecl *> getUniqueDeclsRef() const { |
||
5245 | return ArrayRef<ValueDecl *>( |
||
5246 | static_cast<const T *>(this) |
||
5247 | ->template getTrailingObjects<ValueDecl *>(), |
||
5248 | NumUniqueDeclarations); |
||
5249 | } |
||
5250 | |||
5251 | /// Set the unique declarations that are in the trailing objects of the |
||
5252 | /// class. |
||
5253 | void setUniqueDecls(ArrayRef<ValueDecl *> UDs) { |
||
5254 | assert(UDs.size() == NumUniqueDeclarations && |
||
5255 | "Unexpected amount of unique declarations."); |
||
5256 | std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin()); |
||
5257 | } |
||
5258 | |||
5259 | /// Get the number of lists per declaration that are in the trailing |
||
5260 | /// objects of the class. |
||
5261 | MutableArrayRef<unsigned> getDeclNumListsRef() { |
||
5262 | return MutableArrayRef<unsigned>( |
||
5263 | static_cast<T *>(this)->template getTrailingObjects<unsigned>(), |
||
5264 | NumUniqueDeclarations); |
||
5265 | } |
||
5266 | |||
5267 | /// Get the number of lists per declaration that are in the trailing |
||
5268 | /// objects of the class. |
||
5269 | ArrayRef<unsigned> getDeclNumListsRef() const { |
||
5270 | return ArrayRef<unsigned>( |
||
5271 | static_cast<const T *>(this)->template getTrailingObjects<unsigned>(), |
||
5272 | NumUniqueDeclarations); |
||
5273 | } |
||
5274 | |||
5275 | /// Set the number of lists per declaration that are in the trailing |
||
5276 | /// objects of the class. |
||
5277 | void setDeclNumLists(ArrayRef<unsigned> DNLs) { |
||
5278 | assert(DNLs.size() == NumUniqueDeclarations && |
||
5279 | "Unexpected amount of list numbers."); |
||
5280 | std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin()); |
||
5281 | } |
||
5282 | |||
5283 | /// Get the cumulative component lists sizes that are in the trailing |
||
5284 | /// objects of the class. They are appended after the number of lists. |
||
5285 | MutableArrayRef<unsigned> getComponentListSizesRef() { |
||
5286 | return MutableArrayRef<unsigned>( |
||
5287 | static_cast<T *>(this)->template getTrailingObjects<unsigned>() + |
||
5288 | NumUniqueDeclarations, |
||
5289 | NumComponentLists); |
||
5290 | } |
||
5291 | |||
5292 | /// Get the cumulative component lists sizes that are in the trailing |
||
5293 | /// objects of the class. They are appended after the number of lists. |
||
5294 | ArrayRef<unsigned> getComponentListSizesRef() const { |
||
5295 | return ArrayRef<unsigned>( |
||
5296 | static_cast<const T *>(this)->template getTrailingObjects<unsigned>() + |
||
5297 | NumUniqueDeclarations, |
||
5298 | NumComponentLists); |
||
5299 | } |
||
5300 | |||
5301 | /// Set the cumulative component lists sizes that are in the trailing |
||
5302 | /// objects of the class. |
||
5303 | void setComponentListSizes(ArrayRef<unsigned> CLSs) { |
||
5304 | assert(CLSs.size() == NumComponentLists && |
||
5305 | "Unexpected amount of component lists."); |
||
5306 | std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin()); |
||
5307 | } |
||
5308 | |||
5309 | /// Get the components that are in the trailing objects of the class. |
||
5310 | MutableArrayRef<MappableComponent> getComponentsRef() { |
||
5311 | return MutableArrayRef<MappableComponent>( |
||
5312 | static_cast<T *>(this) |
||
5313 | ->template getTrailingObjects<MappableComponent>(), |
||
5314 | NumComponents); |
||
5315 | } |
||
5316 | |||
5317 | /// Get the components that are in the trailing objects of the class. |
||
5318 | ArrayRef<MappableComponent> getComponentsRef() const { |
||
5319 | return ArrayRef<MappableComponent>( |
||
5320 | static_cast<const T *>(this) |
||
5321 | ->template getTrailingObjects<MappableComponent>(), |
||
5322 | NumComponents); |
||
5323 | } |
||
5324 | |||
5325 | /// Set the components that are in the trailing objects of the class. |
||
5326 | /// This requires the list sizes so that it can also fill the original |
||
5327 | /// expressions, which are the first component of each list. |
||
5328 | void setComponents(ArrayRef<MappableComponent> Components, |
||
5329 | ArrayRef<unsigned> CLSs) { |
||
5330 | assert(Components.size() == NumComponents && |
||
5331 | "Unexpected amount of component lists."); |
||
5332 | assert(CLSs.size() == NumComponentLists && |
||
5333 | "Unexpected amount of list sizes."); |
||
5334 | std::copy(Components.begin(), Components.end(), getComponentsRef().begin()); |
||
5335 | } |
||
5336 | |||
5337 | /// Fill the clause information from the list of declarations and |
||
5338 | /// associated component lists. |
||
5339 | void setClauseInfo(ArrayRef<ValueDecl *> Declarations, |
||
5340 | MappableExprComponentListsRef ComponentLists) { |
||
5341 | // Perform some checks to make sure the data sizes are consistent with the |
||
5342 | // information available when the clause was created. |
||
5343 | assert(getUniqueDeclarationsTotalNumber(Declarations) == |
||
5344 | NumUniqueDeclarations && |
||
5345 | "Unexpected number of mappable expression info entries!"); |
||
5346 | assert(getComponentsTotalNumber(ComponentLists) == NumComponents && |
||
5347 | "Unexpected total number of components!"); |
||
5348 | assert(Declarations.size() == ComponentLists.size() && |
||
5349 | "Declaration and component lists size is not consistent!"); |
||
5350 | assert(Declarations.size() == NumComponentLists && |
||
5351 | "Unexpected declaration and component lists size!"); |
||
5352 | |||
5353 | // Organize the components by declaration and retrieve the original |
||
5354 | // expression. Original expressions are always the first component of the |
||
5355 | // mappable component list. |
||
5356 | llvm::MapVector<ValueDecl *, SmallVector<MappableExprComponentListRef, 8>> |
||
5357 | ComponentListMap; |
||
5358 | { |
||
5359 | auto CI = ComponentLists.begin(); |
||
5360 | for (auto DI = Declarations.begin(), DE = Declarations.end(); DI != DE; |
||
5361 | ++DI, ++CI) { |
||
5362 | assert(!CI->empty() && "Invalid component list!"); |
||
5363 | ComponentListMap[*DI].push_back(*CI); |
||
5364 | } |
||
5365 | } |
||
5366 | |||
5367 | // Iterators of the target storage. |
||
5368 | auto UniqueDeclarations = getUniqueDeclsRef(); |
||
5369 | auto UDI = UniqueDeclarations.begin(); |
||
5370 | |||
5371 | auto DeclNumLists = getDeclNumListsRef(); |
||
5372 | auto DNLI = DeclNumLists.begin(); |
||
5373 | |||
5374 | auto ComponentListSizes = getComponentListSizesRef(); |
||
5375 | auto CLSI = ComponentListSizes.begin(); |
||
5376 | |||
5377 | auto Components = getComponentsRef(); |
||
5378 | auto CI = Components.begin(); |
||
5379 | |||
5380 | // Variable to compute the accumulation of the number of components. |
||
5381 | unsigned PrevSize = 0u; |
||
5382 | |||
5383 | // Scan all the declarations and associated component lists. |
||
5384 | for (auto &M : ComponentListMap) { |
||
5385 | // The declaration. |
||
5386 | auto *D = M.first; |
||
5387 | // The component lists. |
||
5388 | auto CL = M.second; |
||
5389 | |||
5390 | // Initialize the entry. |
||
5391 | *UDI = D; |
||
5392 | ++UDI; |
||
5393 | |||
5394 | *DNLI = CL.size(); |
||
5395 | ++DNLI; |
||
5396 | |||
5397 | // Obtain the cumulative sizes and concatenate all the components in the |
||
5398 | // reserved storage. |
||
5399 | for (auto C : CL) { |
||
5400 | // Accumulate with the previous size. |
||
5401 | PrevSize += C.size(); |
||
5402 | |||
5403 | // Save the size. |
||
5404 | *CLSI = PrevSize; |
||
5405 | ++CLSI; |
||
5406 | |||
5407 | // Append components after the current components iterator. |
||
5408 | CI = std::copy(C.begin(), C.end(), CI); |
||
5409 | } |
||
5410 | } |
||
5411 | } |
||
5412 | |||
5413 | /// Set the nested name specifier of associated user-defined mapper. |
||
5414 | void setMapperQualifierLoc(NestedNameSpecifierLoc NNSL) { |
||
5415 | MapperQualifierLoc = NNSL; |
||
5416 | } |
||
5417 | |||
5418 | /// Set the name of associated user-defined mapper. |
||
5419 | void setMapperIdInfo(DeclarationNameInfo MapperId) { |
||
5420 | MapperIdInfo = MapperId; |
||
5421 | } |
||
5422 | |||
5423 | /// Get the user-defined mapper references that are in the trailing objects of |
||
5424 | /// the class. |
||
5425 | MutableArrayRef<Expr *> getUDMapperRefs() { |
||
5426 | assert(SupportsMapper && |
||
5427 | "Must be a clause that is possible to have user-defined mappers"); |
||
5428 | return llvm::MutableArrayRef<Expr *>( |
||
5429 | static_cast<T *>(this)->template getTrailingObjects<Expr *>() + |
||
5430 | OMPVarListClause<T>::varlist_size(), |
||
5431 | OMPVarListClause<T>::varlist_size()); |
||
5432 | } |
||
5433 | |||
5434 | /// Get the user-defined mappers references that are in the trailing objects |
||
5435 | /// of the class. |
||
5436 | ArrayRef<Expr *> getUDMapperRefs() const { |
||
5437 | assert(SupportsMapper && |
||
5438 | "Must be a clause that is possible to have user-defined mappers"); |
||
5439 | return llvm::ArrayRef<Expr *>( |
||
5440 | static_cast<const T *>(this)->template getTrailingObjects<Expr *>() + |
||
5441 | OMPVarListClause<T>::varlist_size(), |
||
5442 | OMPVarListClause<T>::varlist_size()); |
||
5443 | } |
||
5444 | |||
5445 | /// Set the user-defined mappers that are in the trailing objects of the |
||
5446 | /// class. |
||
5447 | void setUDMapperRefs(ArrayRef<Expr *> DMDs) { |
||
5448 | assert(DMDs.size() == OMPVarListClause<T>::varlist_size() && |
||
5449 | "Unexpected number of user-defined mappers."); |
||
5450 | assert(SupportsMapper && |
||
5451 | "Must be a clause that is possible to have user-defined mappers"); |
||
5452 | std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin()); |
||
5453 | } |
||
5454 | |||
5455 | public: |
||
5456 | /// Return the number of unique base declarations in this clause. |
||
5457 | unsigned getUniqueDeclarationsNum() const { return NumUniqueDeclarations; } |
||
5458 | |||
5459 | /// Return the number of lists derived from the clause expressions. |
||
5460 | unsigned getTotalComponentListNum() const { return NumComponentLists; } |
||
5461 | |||
5462 | /// Return the total number of components in all lists derived from the |
||
5463 | /// clause. |
||
5464 | unsigned getTotalComponentsNum() const { return NumComponents; } |
||
5465 | |||
5466 | /// Gets the nested name specifier for associated user-defined mapper. |
||
5467 | NestedNameSpecifierLoc getMapperQualifierLoc() const { |
||
5468 | return MapperQualifierLoc; |
||
5469 | } |
||
5470 | |||
5471 | /// Gets the name info for associated user-defined mapper. |
||
5472 | const DeclarationNameInfo &getMapperIdInfo() const { return MapperIdInfo; } |
||
5473 | |||
5474 | /// Iterator that browse the components by lists. It also allows |
||
5475 | /// browsing components of a single declaration. |
||
5476 | class const_component_lists_iterator |
||
5477 | : public llvm::iterator_adaptor_base< |
||
5478 | const_component_lists_iterator, |
||
5479 | MappableExprComponentListRef::const_iterator, |
||
5480 | std::forward_iterator_tag, MappableComponent, ptrdiff_t, |
||
5481 | MappableComponent, MappableComponent> { |
||
5482 | // The declaration the iterator currently refers to. |
||
5483 | ArrayRef<ValueDecl *>::iterator DeclCur; |
||
5484 | |||
5485 | // The list number associated with the current declaration. |
||
5486 | ArrayRef<unsigned>::iterator NumListsCur; |
||
5487 | |||
5488 | // Whether this clause is possible to have user-defined mappers associated. |
||
5489 | const bool SupportsMapper; |
||
5490 | |||
5491 | // The user-defined mapper associated with the current declaration. |
||
5492 | ArrayRef<Expr *>::iterator MapperCur; |
||
5493 | |||
5494 | // Remaining lists for the current declaration. |
||
5495 | unsigned RemainingLists = 0; |
||
5496 | |||
5497 | // The cumulative size of the previous list, or zero if there is no previous |
||
5498 | // list. |
||
5499 | unsigned PrevListSize = 0; |
||
5500 | |||
5501 | // The cumulative sizes of the current list - it will delimit the remaining |
||
5502 | // range of interest. |
||
5503 | ArrayRef<unsigned>::const_iterator ListSizeCur; |
||
5504 | ArrayRef<unsigned>::const_iterator ListSizeEnd; |
||
5505 | |||
5506 | // Iterator to the end of the components storage. |
||
5507 | MappableExprComponentListRef::const_iterator End; |
||
5508 | |||
5509 | public: |
||
5510 | /// Construct an iterator that scans all lists. |
||
5511 | explicit const_component_lists_iterator( |
||
5512 | ArrayRef<ValueDecl *> UniqueDecls, ArrayRef<unsigned> DeclsListNum, |
||
5513 | ArrayRef<unsigned> CumulativeListSizes, |
||
5514 | MappableExprComponentListRef Components, bool SupportsMapper, |
||
5515 | ArrayRef<Expr *> Mappers) |
||
5516 | : const_component_lists_iterator::iterator_adaptor_base( |
||
5517 | Components.begin()), |
||
5518 | DeclCur(UniqueDecls.begin()), NumListsCur(DeclsListNum.begin()), |
||
5519 | SupportsMapper(SupportsMapper), |
||
5520 | ListSizeCur(CumulativeListSizes.begin()), |
||
5521 | ListSizeEnd(CumulativeListSizes.end()), End(Components.end()) { |
||
5522 | assert(UniqueDecls.size() == DeclsListNum.size() && |
||
5523 | "Inconsistent number of declarations and list sizes!"); |
||
5524 | if (!DeclsListNum.empty()) |
||
5525 | RemainingLists = *NumListsCur; |
||
5526 | if (SupportsMapper) |
||
5527 | MapperCur = Mappers.begin(); |
||
5528 | } |
||
5529 | |||
5530 | /// Construct an iterator that scan lists for a given declaration \a |
||
5531 | /// Declaration. |
||
5532 | explicit const_component_lists_iterator( |
||
5533 | const ValueDecl *Declaration, ArrayRef<ValueDecl *> UniqueDecls, |
||
5534 | ArrayRef<unsigned> DeclsListNum, ArrayRef<unsigned> CumulativeListSizes, |
||
5535 | MappableExprComponentListRef Components, bool SupportsMapper, |
||
5536 | ArrayRef<Expr *> Mappers) |
||
5537 | : const_component_lists_iterator(UniqueDecls, DeclsListNum, |
||
5538 | CumulativeListSizes, Components, |
||
5539 | SupportsMapper, Mappers) { |
||
5540 | // Look for the desired declaration. While we are looking for it, we |
||
5541 | // update the state so that we know the component where a given list |
||
5542 | // starts. |
||
5543 | for (; DeclCur != UniqueDecls.end(); ++DeclCur, ++NumListsCur) { |
||
5544 | if (*DeclCur == Declaration) |
||
5545 | break; |
||
5546 | |||
5547 | assert(*NumListsCur > 0 && "No lists associated with declaration??"); |
||
5548 | |||
5549 | // Skip the lists associated with the current declaration, but save the |
||
5550 | // last list size that was skipped. |
||
5551 | std::advance(ListSizeCur, *NumListsCur - 1); |
||
5552 | PrevListSize = *ListSizeCur; |
||
5553 | ++ListSizeCur; |
||
5554 | |||
5555 | if (SupportsMapper) |
||
5556 | ++MapperCur; |
||
5557 | } |
||
5558 | |||
5559 | // If we didn't find any declaration, advance the iterator to after the |
||
5560 | // last component and set remaining lists to zero. |
||
5561 | if (ListSizeCur == CumulativeListSizes.end()) { |
||
5562 | this->I = End; |
||
5563 | RemainingLists = 0u; |
||
5564 | return; |
||
5565 | } |
||
5566 | |||
5567 | // Set the remaining lists with the total number of lists of the current |
||
5568 | // declaration. |
||
5569 | RemainingLists = *NumListsCur; |
||
5570 | |||
5571 | // Adjust the list size end iterator to the end of the relevant range. |
||
5572 | ListSizeEnd = ListSizeCur; |
||
5573 | std::advance(ListSizeEnd, RemainingLists); |
||
5574 | |||
5575 | // Given that the list sizes are cumulative, the index of the component |
||
5576 | // that start the list is the size of the previous list. |
||
5577 | std::advance(this->I, PrevListSize); |
||
5578 | } |
||
5579 | |||
5580 | // Return the array with the current list. The sizes are cumulative, so the |
||
5581 | // array size is the difference between the current size and previous one. |
||
5582 | std::tuple<const ValueDecl *, MappableExprComponentListRef, |
||
5583 | const ValueDecl *> |
||
5584 | operator*() const { |
||
5585 | assert(ListSizeCur != ListSizeEnd && "Invalid iterator!"); |
||
5586 | const ValueDecl *Mapper = nullptr; |
||
5587 | if (SupportsMapper && *MapperCur) |
||
5588 | Mapper = cast<ValueDecl>(cast<DeclRefExpr>(*MapperCur)->getDecl()); |
||
5589 | return std::make_tuple( |
||
5590 | *DeclCur, |
||
5591 | MappableExprComponentListRef(&*this->I, *ListSizeCur - PrevListSize), |
||
5592 | Mapper); |
||
5593 | } |
||
5594 | std::tuple<const ValueDecl *, MappableExprComponentListRef, |
||
5595 | const ValueDecl *> |
||
5596 | operator->() const { |
||
5597 | return **this; |
||
5598 | } |
||
5599 | |||
5600 | // Skip the components of the current list. |
||
5601 | const_component_lists_iterator &operator++() { |
||
5602 | assert(ListSizeCur != ListSizeEnd && RemainingLists && |
||
5603 | "Invalid iterator!"); |
||
5604 | |||
5605 | // If we don't have more lists just skip all the components. Otherwise, |
||
5606 | // advance the iterator by the number of components in the current list. |
||
5607 | if (std::next(ListSizeCur) == ListSizeEnd) { |
||
5608 | this->I = End; |
||
5609 | RemainingLists = 0; |
||
5610 | } else { |
||
5611 | std::advance(this->I, *ListSizeCur - PrevListSize); |
||
5612 | PrevListSize = *ListSizeCur; |
||
5613 | |||
5614 | // We are done with a declaration, move to the next one. |
||
5615 | if (!(--RemainingLists)) { |
||
5616 | ++DeclCur; |
||
5617 | ++NumListsCur; |
||
5618 | RemainingLists = *NumListsCur; |
||
5619 | assert(RemainingLists && "No lists in the following declaration??"); |
||
5620 | } |
||
5621 | } |
||
5622 | |||
5623 | ++ListSizeCur; |
||
5624 | if (SupportsMapper) |
||
5625 | ++MapperCur; |
||
5626 | return *this; |
||
5627 | } |
||
5628 | }; |
||
5629 | |||
5630 | using const_component_lists_range = |
||
5631 | llvm::iterator_range<const_component_lists_iterator>; |
||
5632 | |||
5633 | /// Iterators for all component lists. |
||
5634 | const_component_lists_iterator component_lists_begin() const { |
||
5635 | return const_component_lists_iterator( |
||
5636 | getUniqueDeclsRef(), getDeclNumListsRef(), getComponentListSizesRef(), |
||
5637 | getComponentsRef(), SupportsMapper, |
||
5638 | SupportsMapper ? getUDMapperRefs() : std::nullopt); |
||
5639 | } |
||
5640 | const_component_lists_iterator component_lists_end() const { |
||
5641 | return const_component_lists_iterator( |
||
5642 | ArrayRef<ValueDecl *>(), ArrayRef<unsigned>(), ArrayRef<unsigned>(), |
||
5643 | MappableExprComponentListRef(getComponentsRef().end(), |
||
5644 | getComponentsRef().end()), |
||
5645 | SupportsMapper, std::nullopt); |
||
5646 | } |
||
5647 | const_component_lists_range component_lists() const { |
||
5648 | return {component_lists_begin(), component_lists_end()}; |
||
5649 | } |
||
5650 | |||
5651 | /// Iterators for component lists associated with the provided |
||
5652 | /// declaration. |
||
5653 | const_component_lists_iterator |
||
5654 | decl_component_lists_begin(const ValueDecl *VD) const { |
||
5655 | return const_component_lists_iterator( |
||
5656 | VD, getUniqueDeclsRef(), getDeclNumListsRef(), |
||
5657 | getComponentListSizesRef(), getComponentsRef(), SupportsMapper, |
||
5658 | SupportsMapper ? getUDMapperRefs() : std::nullopt); |
||
5659 | } |
||
5660 | const_component_lists_iterator decl_component_lists_end() const { |
||
5661 | return component_lists_end(); |
||
5662 | } |
||
5663 | const_component_lists_range decl_component_lists(const ValueDecl *VD) const { |
||
5664 | return {decl_component_lists_begin(VD), decl_component_lists_end()}; |
||
5665 | } |
||
5666 | |||
5667 | /// Iterators to access all the declarations, number of lists, list sizes, and |
||
5668 | /// components. |
||
5669 | using const_all_decls_iterator = ArrayRef<ValueDecl *>::iterator; |
||
5670 | using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>; |
||
5671 | |||
5672 | const_all_decls_range all_decls() const { |
||
5673 | auto A = getUniqueDeclsRef(); |
||
5674 | return const_all_decls_range(A.begin(), A.end()); |
||
5675 | } |
||
5676 | |||
5677 | using const_all_num_lists_iterator = ArrayRef<unsigned>::iterator; |
||
5678 | using const_all_num_lists_range = |
||
5679 | llvm::iterator_range<const_all_num_lists_iterator>; |
||
5680 | |||
5681 | const_all_num_lists_range all_num_lists() const { |
||
5682 | auto A = getDeclNumListsRef(); |
||
5683 | return const_all_num_lists_range(A.begin(), A.end()); |
||
5684 | } |
||
5685 | |||
5686 | using const_all_lists_sizes_iterator = ArrayRef<unsigned>::iterator; |
||
5687 | using const_all_lists_sizes_range = |
||
5688 | llvm::iterator_range<const_all_lists_sizes_iterator>; |
||
5689 | |||
5690 | const_all_lists_sizes_range all_lists_sizes() const { |
||
5691 | auto A = getComponentListSizesRef(); |
||
5692 | return const_all_lists_sizes_range(A.begin(), A.end()); |
||
5693 | } |
||
5694 | |||
5695 | using const_all_components_iterator = ArrayRef<MappableComponent>::iterator; |
||
5696 | using const_all_components_range = |
||
5697 | llvm::iterator_range<const_all_components_iterator>; |
||
5698 | |||
5699 | const_all_components_range all_components() const { |
||
5700 | auto A = getComponentsRef(); |
||
5701 | return const_all_components_range(A.begin(), A.end()); |
||
5702 | } |
||
5703 | |||
5704 | using mapperlist_iterator = MutableArrayRef<Expr *>::iterator; |
||
5705 | using mapperlist_const_iterator = ArrayRef<const Expr *>::iterator; |
||
5706 | using mapperlist_range = llvm::iterator_range<mapperlist_iterator>; |
||
5707 | using mapperlist_const_range = |
||
5708 | llvm::iterator_range<mapperlist_const_iterator>; |
||
5709 | |||
5710 | mapperlist_iterator mapperlist_begin() { return getUDMapperRefs().begin(); } |
||
5711 | mapperlist_iterator mapperlist_end() { return getUDMapperRefs().end(); } |
||
5712 | mapperlist_const_iterator mapperlist_begin() const { |
||
5713 | return getUDMapperRefs().begin(); |
||
5714 | } |
||
5715 | mapperlist_const_iterator mapperlist_end() const { |
||
5716 | return getUDMapperRefs().end(); |
||
5717 | } |
||
5718 | mapperlist_range mapperlists() { |
||
5719 | return mapperlist_range(mapperlist_begin(), mapperlist_end()); |
||
5720 | } |
||
5721 | mapperlist_const_range mapperlists() const { |
||
5722 | return mapperlist_const_range(mapperlist_begin(), mapperlist_end()); |
||
5723 | } |
||
5724 | }; |
||
5725 | |||
5726 | /// This represents clause 'map' in the '#pragma omp ...' |
||
5727 | /// directives. |
||
5728 | /// |
||
5729 | /// \code |
||
5730 | /// #pragma omp target map(a,b) |
||
5731 | /// \endcode |
||
5732 | /// In this example directive '#pragma omp target' has clause 'map' |
||
5733 | /// with the variables 'a' and 'b'. |
||
5734 | class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>, |
||
5735 | private llvm::TrailingObjects< |
||
5736 | OMPMapClause, Expr *, ValueDecl *, unsigned, |
||
5737 | OMPClauseMappableExprCommon::MappableComponent> { |
||
5738 | friend class OMPClauseReader; |
||
5739 | friend OMPMappableExprListClause; |
||
5740 | friend OMPVarListClause; |
||
5741 | friend TrailingObjects; |
||
5742 | |||
5743 | /// Define the sizes of each trailing object array except the last one. This |
||
5744 | /// is required for TrailingObjects to work properly. |
||
5745 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
||
5746 | // There are varlist_size() of expressions, and varlist_size() of |
||
5747 | // user-defined mappers. |
||
5748 | return 2 * varlist_size() + 1; |
||
5749 | } |
||
5750 | size_t numTrailingObjects(OverloadToken<ValueDecl *>) const { |
||
5751 | return getUniqueDeclarationsNum(); |
||
5752 | } |
||
5753 | size_t numTrailingObjects(OverloadToken<unsigned>) const { |
||
5754 | return getUniqueDeclarationsNum() + getTotalComponentListNum(); |
||
5755 | } |
||
5756 | |||
5757 | private: |
||
5758 | /// Map-type-modifiers for the 'map' clause. |
||
5759 | OpenMPMapModifierKind MapTypeModifiers[NumberOfOMPMapClauseModifiers] = { |
||
5760 | OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown, |
||
5761 | OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown, |
||
5762 | OMPC_MAP_MODIFIER_unknown, OMPC_MAP_MODIFIER_unknown}; |
||
5763 | |||
5764 | /// Location of map-type-modifiers for the 'map' clause. |
||
5765 | SourceLocation MapTypeModifiersLoc[NumberOfOMPMapClauseModifiers]; |
||
5766 | |||
5767 | /// Map type for the 'map' clause. |
||
5768 | OpenMPMapClauseKind MapType = OMPC_MAP_unknown; |
||
5769 | |||
5770 | /// Is this an implicit map type or not. |
||
5771 | bool MapTypeIsImplicit = false; |
||
5772 | |||
5773 | /// Location of the map type. |
||
5774 | SourceLocation MapLoc; |
||
5775 | |||
5776 | /// Colon location. |
||
5777 | SourceLocation ColonLoc; |
||
5778 | |||
5779 | /// Build a clause for \a NumVars listed expressions, \a |
||
5780 | /// NumUniqueDeclarations declarations, \a NumComponentLists total component |
||
5781 | /// lists, and \a NumComponents total expression components. |
||
5782 | /// |
||
5783 | /// \param MapModifiers Map-type-modifiers. |
||
5784 | /// \param MapModifiersLoc Locations of map-type-modifiers. |
||
5785 | /// \param MapperQualifierLoc C++ nested name specifier for the associated |
||
5786 | /// user-defined mapper. |
||
5787 | /// \param MapperIdInfo The identifier of associated user-defined mapper. |
||
5788 | /// \param MapType Map type. |
||
5789 | /// \param MapTypeIsImplicit Map type is inferred implicitly. |
||
5790 | /// \param MapLoc Location of the map type. |
||
5791 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
5792 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
5793 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
5794 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
5795 | /// NumVars: number of expressions listed in this clause; 2) |
||
5796 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
5797 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
5798 | /// NumComponents: total number of expression components in the clause. |
||
5799 | explicit OMPMapClause(ArrayRef<OpenMPMapModifierKind> MapModifiers, |
||
5800 | ArrayRef<SourceLocation> MapModifiersLoc, |
||
5801 | NestedNameSpecifierLoc MapperQualifierLoc, |
||
5802 | DeclarationNameInfo MapperIdInfo, |
||
5803 | OpenMPMapClauseKind MapType, bool MapTypeIsImplicit, |
||
5804 | SourceLocation MapLoc, const OMPVarListLocTy &Locs, |
||
5805 | const OMPMappableExprListSizeTy &Sizes) |
||
5806 | : OMPMappableExprListClause(llvm::omp::OMPC_map, Locs, Sizes, |
||
5807 | /*SupportsMapper=*/true, &MapperQualifierLoc, |
||
5808 | &MapperIdInfo), |
||
5809 | MapType(MapType), MapTypeIsImplicit(MapTypeIsImplicit), MapLoc(MapLoc) { |
||
5810 | assert(std::size(MapTypeModifiers) == MapModifiers.size() && |
||
5811 | "Unexpected number of map type modifiers."); |
||
5812 | llvm::copy(MapModifiers, std::begin(MapTypeModifiers)); |
||
5813 | |||
5814 | assert(std::size(MapTypeModifiersLoc) == MapModifiersLoc.size() && |
||
5815 | "Unexpected number of map type modifier locations."); |
||
5816 | llvm::copy(MapModifiersLoc, std::begin(MapTypeModifiersLoc)); |
||
5817 | } |
||
5818 | |||
5819 | /// Build an empty clause. |
||
5820 | /// |
||
5821 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
5822 | /// NumVars: number of expressions listed in this clause; 2) |
||
5823 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
5824 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
5825 | /// NumComponents: total number of expression components in the clause. |
||
5826 | explicit OMPMapClause(const OMPMappableExprListSizeTy &Sizes) |
||
5827 | : OMPMappableExprListClause(llvm::omp::OMPC_map, OMPVarListLocTy(), Sizes, |
||
5828 | /*SupportsMapper=*/true) {} |
||
5829 | |||
5830 | /// Set map-type-modifier for the clause. |
||
5831 | /// |
||
5832 | /// \param I index for map-type-modifier. |
||
5833 | /// \param T map-type-modifier for the clause. |
||
5834 | void setMapTypeModifier(unsigned I, OpenMPMapModifierKind T) { |
||
5835 | assert(I < NumberOfOMPMapClauseModifiers && |
||
5836 | "Unexpected index to store map type modifier, exceeds array size."); |
||
5837 | MapTypeModifiers[I] = T; |
||
5838 | } |
||
5839 | |||
5840 | /// Set location for the map-type-modifier. |
||
5841 | /// |
||
5842 | /// \param I index for map-type-modifier location. |
||
5843 | /// \param TLoc map-type-modifier location. |
||
5844 | void setMapTypeModifierLoc(unsigned I, SourceLocation TLoc) { |
||
5845 | assert(I < NumberOfOMPMapClauseModifiers && |
||
5846 | "Index to store map type modifier location exceeds array size."); |
||
5847 | MapTypeModifiersLoc[I] = TLoc; |
||
5848 | } |
||
5849 | |||
5850 | /// Set type for the clause. |
||
5851 | /// |
||
5852 | /// \param T Type for the clause. |
||
5853 | void setMapType(OpenMPMapClauseKind T) { MapType = T; } |
||
5854 | |||
5855 | /// Set type location. |
||
5856 | /// |
||
5857 | /// \param TLoc Type location. |
||
5858 | void setMapLoc(SourceLocation TLoc) { MapLoc = TLoc; } |
||
5859 | |||
5860 | /// Set colon location. |
||
5861 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
5862 | |||
5863 | /// Set iterator modifier. |
||
5864 | void setIteratorModifier(Expr *IteratorModifier) { |
||
5865 | getTrailingObjects<Expr *>()[2 * varlist_size()] = IteratorModifier; |
||
5866 | } |
||
5867 | |||
5868 | public: |
||
5869 | /// Creates clause with a list of variables \a VL. |
||
5870 | /// |
||
5871 | /// \param C AST context. |
||
5872 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
5873 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
5874 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
5875 | /// \param Vars The original expression used in the clause. |
||
5876 | /// \param Declarations Declarations used in the clause. |
||
5877 | /// \param ComponentLists Component lists used in the clause. |
||
5878 | /// \param UDMapperRefs References to user-defined mappers associated with |
||
5879 | /// expressions used in the clause. |
||
5880 | /// \param IteratorModifier Iterator modifier. |
||
5881 | /// \param MapModifiers Map-type-modifiers. |
||
5882 | /// \param MapModifiersLoc Location of map-type-modifiers. |
||
5883 | /// \param UDMQualifierLoc C++ nested name specifier for the associated |
||
5884 | /// user-defined mapper. |
||
5885 | /// \param MapperId The identifier of associated user-defined mapper. |
||
5886 | /// \param Type Map type. |
||
5887 | /// \param TypeIsImplicit Map type is inferred implicitly. |
||
5888 | /// \param TypeLoc Location of the map type. |
||
5889 | static OMPMapClause * |
||
5890 | Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
||
5891 | ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations, |
||
5892 | MappableExprComponentListsRef ComponentLists, |
||
5893 | ArrayRef<Expr *> UDMapperRefs, Expr *IteratorModifier, |
||
5894 | ArrayRef<OpenMPMapModifierKind> MapModifiers, |
||
5895 | ArrayRef<SourceLocation> MapModifiersLoc, |
||
5896 | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId, |
||
5897 | OpenMPMapClauseKind Type, bool TypeIsImplicit, SourceLocation TypeLoc); |
||
5898 | |||
5899 | /// Creates an empty clause with the place for \a NumVars original |
||
5900 | /// expressions, \a NumUniqueDeclarations declarations, \NumComponentLists |
||
5901 | /// lists, and \a NumComponents expression components. |
||
5902 | /// |
||
5903 | /// \param C AST context. |
||
5904 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
5905 | /// NumVars: number of expressions listed in this clause; 2) |
||
5906 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
5907 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
5908 | /// NumComponents: total number of expression components in the clause. |
||
5909 | static OMPMapClause *CreateEmpty(const ASTContext &C, |
||
5910 | const OMPMappableExprListSizeTy &Sizes); |
||
5911 | |||
5912 | /// Fetches Expr * of iterator modifier. |
||
5913 | Expr *getIteratorModifier() { |
||
5914 | return getTrailingObjects<Expr *>()[2 * varlist_size()]; |
||
5915 | } |
||
5916 | |||
5917 | /// Fetches mapping kind for the clause. |
||
5918 | OpenMPMapClauseKind getMapType() const LLVM_READONLY { return MapType; } |
||
5919 | |||
5920 | /// Is this an implicit map type? |
||
5921 | /// We have to capture 'IsMapTypeImplicit' from the parser for more |
||
5922 | /// informative error messages. It helps distinguish map(r) from |
||
5923 | /// map(tofrom: r), which is important to print more helpful error |
||
5924 | /// messages for some target directives. |
||
5925 | bool isImplicitMapType() const LLVM_READONLY { return MapTypeIsImplicit; } |
||
5926 | |||
5927 | /// Fetches the map-type-modifier at 'Cnt' index of array of modifiers. |
||
5928 | /// |
||
5929 | /// \param Cnt index for map-type-modifier. |
||
5930 | OpenMPMapModifierKind getMapTypeModifier(unsigned Cnt) const LLVM_READONLY { |
||
5931 | assert(Cnt < NumberOfOMPMapClauseModifiers && |
||
5932 | "Requested modifier exceeds the total number of modifiers."); |
||
5933 | return MapTypeModifiers[Cnt]; |
||
5934 | } |
||
5935 | |||
5936 | /// Fetches the map-type-modifier location at 'Cnt' index of array of |
||
5937 | /// modifiers' locations. |
||
5938 | /// |
||
5939 | /// \param Cnt index for map-type-modifier location. |
||
5940 | SourceLocation getMapTypeModifierLoc(unsigned Cnt) const LLVM_READONLY { |
||
5941 | assert(Cnt < NumberOfOMPMapClauseModifiers && |
||
5942 | "Requested modifier location exceeds total number of modifiers."); |
||
5943 | return MapTypeModifiersLoc[Cnt]; |
||
5944 | } |
||
5945 | |||
5946 | /// Fetches ArrayRef of map-type-modifiers. |
||
5947 | ArrayRef<OpenMPMapModifierKind> getMapTypeModifiers() const LLVM_READONLY { |
||
5948 | return llvm::ArrayRef(MapTypeModifiers); |
||
5949 | } |
||
5950 | |||
5951 | /// Fetches ArrayRef of location of map-type-modifiers. |
||
5952 | ArrayRef<SourceLocation> getMapTypeModifiersLoc() const LLVM_READONLY { |
||
5953 | return llvm::ArrayRef(MapTypeModifiersLoc); |
||
5954 | } |
||
5955 | |||
5956 | /// Fetches location of clause mapping kind. |
||
5957 | SourceLocation getMapLoc() const LLVM_READONLY { return MapLoc; } |
||
5958 | |||
5959 | /// Get colon location. |
||
5960 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
5961 | |||
5962 | child_range children() { |
||
5963 | return child_range( |
||
5964 | reinterpret_cast<Stmt **>(varlist_begin()), |
||
5965 | reinterpret_cast<Stmt **>(varlist_end())); |
||
5966 | } |
||
5967 | |||
5968 | const_child_range children() const { |
||
5969 | auto Children = const_cast<OMPMapClause *>(this)->children(); |
||
5970 | return const_child_range(Children.begin(), Children.end()); |
||
5971 | } |
||
5972 | |||
5973 | child_range used_children() { |
||
5974 | if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_tofrom) |
||
5975 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
5976 | reinterpret_cast<Stmt **>(varlist_end())); |
||
5977 | return child_range(child_iterator(), child_iterator()); |
||
5978 | } |
||
5979 | const_child_range used_children() const { |
||
5980 | auto Children = const_cast<OMPMapClause *>(this)->used_children(); |
||
5981 | return const_child_range(Children.begin(), Children.end()); |
||
5982 | } |
||
5983 | |||
5984 | |||
5985 | static bool classof(const OMPClause *T) { |
||
5986 | return T->getClauseKind() == llvm::omp::OMPC_map; |
||
5987 | } |
||
5988 | }; |
||
5989 | |||
5990 | /// This represents 'num_teams' clause in the '#pragma omp ...' |
||
5991 | /// directive. |
||
5992 | /// |
||
5993 | /// \code |
||
5994 | /// #pragma omp teams num_teams(n) |
||
5995 | /// \endcode |
||
5996 | /// In this example directive '#pragma omp teams' has clause 'num_teams' |
||
5997 | /// with single expression 'n'. |
||
5998 | class OMPNumTeamsClause : public OMPClause, public OMPClauseWithPreInit { |
||
5999 | friend class OMPClauseReader; |
||
6000 | |||
6001 | /// Location of '('. |
||
6002 | SourceLocation LParenLoc; |
||
6003 | |||
6004 | /// NumTeams number. |
||
6005 | Stmt *NumTeams = nullptr; |
||
6006 | |||
6007 | /// Set the NumTeams number. |
||
6008 | /// |
||
6009 | /// \param E NumTeams number. |
||
6010 | void setNumTeams(Expr *E) { NumTeams = E; } |
||
6011 | |||
6012 | public: |
||
6013 | /// Build 'num_teams' clause. |
||
6014 | /// |
||
6015 | /// \param E Expression associated with this clause. |
||
6016 | /// \param HelperE Helper Expression associated with this clause. |
||
6017 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
6018 | /// clause must be captured. |
||
6019 | /// \param StartLoc Starting location of the clause. |
||
6020 | /// \param LParenLoc Location of '('. |
||
6021 | /// \param EndLoc Ending location of the clause. |
||
6022 | OMPNumTeamsClause(Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion, |
||
6023 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
6024 | SourceLocation EndLoc) |
||
6025 | : OMPClause(llvm::omp::OMPC_num_teams, StartLoc, EndLoc), |
||
6026 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), NumTeams(E) { |
||
6027 | setPreInitStmt(HelperE, CaptureRegion); |
||
6028 | } |
||
6029 | |||
6030 | /// Build an empty clause. |
||
6031 | OMPNumTeamsClause() |
||
6032 | : OMPClause(llvm::omp::OMPC_num_teams, SourceLocation(), |
||
6033 | SourceLocation()), |
||
6034 | OMPClauseWithPreInit(this) {} |
||
6035 | |||
6036 | /// Sets the location of '('. |
||
6037 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6038 | |||
6039 | /// Returns the location of '('. |
||
6040 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
6041 | |||
6042 | /// Return NumTeams number. |
||
6043 | Expr *getNumTeams() { return cast<Expr>(NumTeams); } |
||
6044 | |||
6045 | /// Return NumTeams number. |
||
6046 | Expr *getNumTeams() const { return cast<Expr>(NumTeams); } |
||
6047 | |||
6048 | child_range children() { return child_range(&NumTeams, &NumTeams + 1); } |
||
6049 | |||
6050 | const_child_range children() const { |
||
6051 | return const_child_range(&NumTeams, &NumTeams + 1); |
||
6052 | } |
||
6053 | |||
6054 | child_range used_children() { |
||
6055 | return child_range(child_iterator(), child_iterator()); |
||
6056 | } |
||
6057 | const_child_range used_children() const { |
||
6058 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6059 | } |
||
6060 | |||
6061 | static bool classof(const OMPClause *T) { |
||
6062 | return T->getClauseKind() == llvm::omp::OMPC_num_teams; |
||
6063 | } |
||
6064 | }; |
||
6065 | |||
6066 | /// This represents 'thread_limit' clause in the '#pragma omp ...' |
||
6067 | /// directive. |
||
6068 | /// |
||
6069 | /// \code |
||
6070 | /// #pragma omp teams thread_limit(n) |
||
6071 | /// \endcode |
||
6072 | /// In this example directive '#pragma omp teams' has clause 'thread_limit' |
||
6073 | /// with single expression 'n'. |
||
6074 | class OMPThreadLimitClause : public OMPClause, public OMPClauseWithPreInit { |
||
6075 | friend class OMPClauseReader; |
||
6076 | |||
6077 | /// Location of '('. |
||
6078 | SourceLocation LParenLoc; |
||
6079 | |||
6080 | /// ThreadLimit number. |
||
6081 | Stmt *ThreadLimit = nullptr; |
||
6082 | |||
6083 | /// Set the ThreadLimit number. |
||
6084 | /// |
||
6085 | /// \param E ThreadLimit number. |
||
6086 | void setThreadLimit(Expr *E) { ThreadLimit = E; } |
||
6087 | |||
6088 | public: |
||
6089 | /// Build 'thread_limit' clause. |
||
6090 | /// |
||
6091 | /// \param E Expression associated with this clause. |
||
6092 | /// \param HelperE Helper Expression associated with this clause. |
||
6093 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
6094 | /// clause must be captured. |
||
6095 | /// \param StartLoc Starting location of the clause. |
||
6096 | /// \param LParenLoc Location of '('. |
||
6097 | /// \param EndLoc Ending location of the clause. |
||
6098 | OMPThreadLimitClause(Expr *E, Stmt *HelperE, |
||
6099 | OpenMPDirectiveKind CaptureRegion, |
||
6100 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
6101 | SourceLocation EndLoc) |
||
6102 | : OMPClause(llvm::omp::OMPC_thread_limit, StartLoc, EndLoc), |
||
6103 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), ThreadLimit(E) { |
||
6104 | setPreInitStmt(HelperE, CaptureRegion); |
||
6105 | } |
||
6106 | |||
6107 | /// Build an empty clause. |
||
6108 | OMPThreadLimitClause() |
||
6109 | : OMPClause(llvm::omp::OMPC_thread_limit, SourceLocation(), |
||
6110 | SourceLocation()), |
||
6111 | OMPClauseWithPreInit(this) {} |
||
6112 | |||
6113 | /// Sets the location of '('. |
||
6114 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6115 | |||
6116 | /// Returns the location of '('. |
||
6117 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
6118 | |||
6119 | /// Return ThreadLimit number. |
||
6120 | Expr *getThreadLimit() { return cast<Expr>(ThreadLimit); } |
||
6121 | |||
6122 | /// Return ThreadLimit number. |
||
6123 | Expr *getThreadLimit() const { return cast<Expr>(ThreadLimit); } |
||
6124 | |||
6125 | child_range children() { return child_range(&ThreadLimit, &ThreadLimit + 1); } |
||
6126 | |||
6127 | const_child_range children() const { |
||
6128 | return const_child_range(&ThreadLimit, &ThreadLimit + 1); |
||
6129 | } |
||
6130 | |||
6131 | child_range used_children() { |
||
6132 | return child_range(child_iterator(), child_iterator()); |
||
6133 | } |
||
6134 | const_child_range used_children() const { |
||
6135 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6136 | } |
||
6137 | |||
6138 | static bool classof(const OMPClause *T) { |
||
6139 | return T->getClauseKind() == llvm::omp::OMPC_thread_limit; |
||
6140 | } |
||
6141 | }; |
||
6142 | |||
6143 | /// This represents 'priority' clause in the '#pragma omp ...' |
||
6144 | /// directive. |
||
6145 | /// |
||
6146 | /// \code |
||
6147 | /// #pragma omp task priority(n) |
||
6148 | /// \endcode |
||
6149 | /// In this example directive '#pragma omp teams' has clause 'priority' with |
||
6150 | /// single expression 'n'. |
||
6151 | class OMPPriorityClause : public OMPClause, public OMPClauseWithPreInit { |
||
6152 | friend class OMPClauseReader; |
||
6153 | |||
6154 | /// Location of '('. |
||
6155 | SourceLocation LParenLoc; |
||
6156 | |||
6157 | /// Priority number. |
||
6158 | Stmt *Priority = nullptr; |
||
6159 | |||
6160 | /// Set the Priority number. |
||
6161 | /// |
||
6162 | /// \param E Priority number. |
||
6163 | void setPriority(Expr *E) { Priority = E; } |
||
6164 | |||
6165 | public: |
||
6166 | /// Build 'priority' clause. |
||
6167 | /// |
||
6168 | /// \param Priority Expression associated with this clause. |
||
6169 | /// \param HelperPriority Helper priority for the construct. |
||
6170 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
6171 | /// clause must be captured. |
||
6172 | /// \param StartLoc Starting location of the clause. |
||
6173 | /// \param LParenLoc Location of '('. |
||
6174 | /// \param EndLoc Ending location of the clause. |
||
6175 | OMPPriorityClause(Expr *Priority, Stmt *HelperPriority, |
||
6176 | OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, |
||
6177 | SourceLocation LParenLoc, SourceLocation EndLoc) |
||
6178 | : OMPClause(llvm::omp::OMPC_priority, StartLoc, EndLoc), |
||
6179 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Priority(Priority) { |
||
6180 | setPreInitStmt(HelperPriority, CaptureRegion); |
||
6181 | } |
||
6182 | |||
6183 | /// Build an empty clause. |
||
6184 | OMPPriorityClause() |
||
6185 | : OMPClause(llvm::omp::OMPC_priority, SourceLocation(), SourceLocation()), |
||
6186 | OMPClauseWithPreInit(this) {} |
||
6187 | |||
6188 | /// Sets the location of '('. |
||
6189 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6190 | |||
6191 | /// Returns the location of '('. |
||
6192 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
6193 | |||
6194 | /// Return Priority number. |
||
6195 | Expr *getPriority() { return cast<Expr>(Priority); } |
||
6196 | |||
6197 | /// Return Priority number. |
||
6198 | Expr *getPriority() const { return cast<Expr>(Priority); } |
||
6199 | |||
6200 | child_range children() { return child_range(&Priority, &Priority + 1); } |
||
6201 | |||
6202 | const_child_range children() const { |
||
6203 | return const_child_range(&Priority, &Priority + 1); |
||
6204 | } |
||
6205 | |||
6206 | child_range used_children(); |
||
6207 | const_child_range used_children() const { |
||
6208 | auto Children = const_cast<OMPPriorityClause *>(this)->used_children(); |
||
6209 | return const_child_range(Children.begin(), Children.end()); |
||
6210 | } |
||
6211 | |||
6212 | static bool classof(const OMPClause *T) { |
||
6213 | return T->getClauseKind() == llvm::omp::OMPC_priority; |
||
6214 | } |
||
6215 | }; |
||
6216 | |||
6217 | /// This represents 'grainsize' clause in the '#pragma omp ...' |
||
6218 | /// directive. |
||
6219 | /// |
||
6220 | /// \code |
||
6221 | /// #pragma omp taskloop grainsize(4) |
||
6222 | /// \endcode |
||
6223 | /// In this example directive '#pragma omp taskloop' has clause 'grainsize' |
||
6224 | /// with single expression '4'. |
||
6225 | class OMPGrainsizeClause : public OMPClause, public OMPClauseWithPreInit { |
||
6226 | friend class OMPClauseReader; |
||
6227 | |||
6228 | /// Location of '('. |
||
6229 | SourceLocation LParenLoc; |
||
6230 | |||
6231 | /// Modifiers for 'grainsize' clause. |
||
6232 | OpenMPGrainsizeClauseModifier Modifier = OMPC_GRAINSIZE_unknown; |
||
6233 | |||
6234 | /// Location of the modifier. |
||
6235 | SourceLocation ModifierLoc; |
||
6236 | |||
6237 | /// Safe iteration space distance. |
||
6238 | Stmt *Grainsize = nullptr; |
||
6239 | |||
6240 | /// Set safelen. |
||
6241 | void setGrainsize(Expr *Size) { Grainsize = Size; } |
||
6242 | |||
6243 | /// Sets modifier. |
||
6244 | void setModifier(OpenMPGrainsizeClauseModifier M) { Modifier = M; } |
||
6245 | |||
6246 | /// Sets modifier location. |
||
6247 | void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; } |
||
6248 | |||
6249 | public: |
||
6250 | /// Build 'grainsize' clause. |
||
6251 | /// |
||
6252 | /// \param Modifier Clause modifier. |
||
6253 | /// \param Size Expression associated with this clause. |
||
6254 | /// \param HelperSize Helper grainsize for the construct. |
||
6255 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
6256 | /// clause must be captured. |
||
6257 | /// \param StartLoc Starting location of the clause. |
||
6258 | /// \param ModifierLoc Modifier location. |
||
6259 | /// \param LParenLoc Location of '('. |
||
6260 | /// \param EndLoc Ending location of the clause. |
||
6261 | OMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, |
||
6262 | Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, |
||
6263 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
6264 | SourceLocation ModifierLoc, SourceLocation EndLoc) |
||
6265 | : OMPClause(llvm::omp::OMPC_grainsize, StartLoc, EndLoc), |
||
6266 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier), |
||
6267 | ModifierLoc(ModifierLoc), Grainsize(Size) { |
||
6268 | setPreInitStmt(HelperSize, CaptureRegion); |
||
6269 | } |
||
6270 | |||
6271 | /// Build an empty clause. |
||
6272 | explicit OMPGrainsizeClause() |
||
6273 | : OMPClause(llvm::omp::OMPC_grainsize, SourceLocation(), |
||
6274 | SourceLocation()), |
||
6275 | OMPClauseWithPreInit(this) {} |
||
6276 | |||
6277 | /// Sets the location of '('. |
||
6278 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6279 | |||
6280 | /// Returns the location of '('. |
||
6281 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
6282 | |||
6283 | /// Return safe iteration space distance. |
||
6284 | Expr *getGrainsize() const { return cast_or_null<Expr>(Grainsize); } |
||
6285 | |||
6286 | /// Gets modifier. |
||
6287 | OpenMPGrainsizeClauseModifier getModifier() const { return Modifier; } |
||
6288 | |||
6289 | /// Gets modifier location. |
||
6290 | SourceLocation getModifierLoc() const { return ModifierLoc; } |
||
6291 | |||
6292 | child_range children() { return child_range(&Grainsize, &Grainsize + 1); } |
||
6293 | |||
6294 | const_child_range children() const { |
||
6295 | return const_child_range(&Grainsize, &Grainsize + 1); |
||
6296 | } |
||
6297 | |||
6298 | child_range used_children(); |
||
6299 | const_child_range used_children() const { |
||
6300 | auto Children = const_cast<OMPGrainsizeClause *>(this)->used_children(); |
||
6301 | return const_child_range(Children.begin(), Children.end()); |
||
6302 | } |
||
6303 | |||
6304 | static bool classof(const OMPClause *T) { |
||
6305 | return T->getClauseKind() == llvm::omp::OMPC_grainsize; |
||
6306 | } |
||
6307 | }; |
||
6308 | |||
6309 | /// This represents 'nogroup' clause in the '#pragma omp ...' directive. |
||
6310 | /// |
||
6311 | /// \code |
||
6312 | /// #pragma omp taskloop nogroup |
||
6313 | /// \endcode |
||
6314 | /// In this example directive '#pragma omp taskloop' has 'nogroup' clause. |
||
6315 | class OMPNogroupClause : public OMPClause { |
||
6316 | public: |
||
6317 | /// Build 'nogroup' clause. |
||
6318 | /// |
||
6319 | /// \param StartLoc Starting location of the clause. |
||
6320 | /// \param EndLoc Ending location of the clause. |
||
6321 | OMPNogroupClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
6322 | : OMPClause(llvm::omp::OMPC_nogroup, StartLoc, EndLoc) {} |
||
6323 | |||
6324 | /// Build an empty clause. |
||
6325 | OMPNogroupClause() |
||
6326 | : OMPClause(llvm::omp::OMPC_nogroup, SourceLocation(), SourceLocation()) { |
||
6327 | } |
||
6328 | |||
6329 | child_range children() { |
||
6330 | return child_range(child_iterator(), child_iterator()); |
||
6331 | } |
||
6332 | |||
6333 | const_child_range children() const { |
||
6334 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6335 | } |
||
6336 | |||
6337 | child_range used_children() { |
||
6338 | return child_range(child_iterator(), child_iterator()); |
||
6339 | } |
||
6340 | const_child_range used_children() const { |
||
6341 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6342 | } |
||
6343 | |||
6344 | static bool classof(const OMPClause *T) { |
||
6345 | return T->getClauseKind() == llvm::omp::OMPC_nogroup; |
||
6346 | } |
||
6347 | }; |
||
6348 | |||
6349 | /// This represents 'num_tasks' clause in the '#pragma omp ...' |
||
6350 | /// directive. |
||
6351 | /// |
||
6352 | /// \code |
||
6353 | /// #pragma omp taskloop num_tasks(4) |
||
6354 | /// \endcode |
||
6355 | /// In this example directive '#pragma omp taskloop' has clause 'num_tasks' |
||
6356 | /// with single expression '4'. |
||
6357 | class OMPNumTasksClause : public OMPClause, public OMPClauseWithPreInit { |
||
6358 | friend class OMPClauseReader; |
||
6359 | |||
6360 | /// Location of '('. |
||
6361 | SourceLocation LParenLoc; |
||
6362 | |||
6363 | /// Modifiers for 'num_tasks' clause. |
||
6364 | OpenMPNumTasksClauseModifier Modifier = OMPC_NUMTASKS_unknown; |
||
6365 | |||
6366 | /// Location of the modifier. |
||
6367 | SourceLocation ModifierLoc; |
||
6368 | |||
6369 | /// Safe iteration space distance. |
||
6370 | Stmt *NumTasks = nullptr; |
||
6371 | |||
6372 | /// Set safelen. |
||
6373 | void setNumTasks(Expr *Size) { NumTasks = Size; } |
||
6374 | |||
6375 | /// Sets modifier. |
||
6376 | void setModifier(OpenMPNumTasksClauseModifier M) { Modifier = M; } |
||
6377 | |||
6378 | /// Sets modifier location. |
||
6379 | void setModifierLoc(SourceLocation Loc) { ModifierLoc = Loc; } |
||
6380 | |||
6381 | public: |
||
6382 | /// Build 'num_tasks' clause. |
||
6383 | /// |
||
6384 | /// \param Modifier Clause modifier. |
||
6385 | /// \param Size Expression associated with this clause. |
||
6386 | /// \param HelperSize Helper grainsize for the construct. |
||
6387 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
6388 | /// clause must be captured. |
||
6389 | /// \param StartLoc Starting location of the clause. |
||
6390 | /// \param EndLoc Ending location of the clause. |
||
6391 | /// \param ModifierLoc Modifier location. |
||
6392 | /// \param LParenLoc Location of '('. |
||
6393 | OMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *Size, |
||
6394 | Stmt *HelperSize, OpenMPDirectiveKind CaptureRegion, |
||
6395 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
6396 | SourceLocation ModifierLoc, SourceLocation EndLoc) |
||
6397 | : OMPClause(llvm::omp::OMPC_num_tasks, StartLoc, EndLoc), |
||
6398 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Modifier(Modifier), |
||
6399 | ModifierLoc(ModifierLoc), NumTasks(Size) { |
||
6400 | setPreInitStmt(HelperSize, CaptureRegion); |
||
6401 | } |
||
6402 | |||
6403 | /// Build an empty clause. |
||
6404 | explicit OMPNumTasksClause() |
||
6405 | : OMPClause(llvm::omp::OMPC_num_tasks, SourceLocation(), |
||
6406 | SourceLocation()), |
||
6407 | OMPClauseWithPreInit(this) {} |
||
6408 | |||
6409 | /// Sets the location of '('. |
||
6410 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6411 | |||
6412 | /// Returns the location of '('. |
||
6413 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
6414 | |||
6415 | /// Return safe iteration space distance. |
||
6416 | Expr *getNumTasks() const { return cast_or_null<Expr>(NumTasks); } |
||
6417 | |||
6418 | /// Gets modifier. |
||
6419 | OpenMPNumTasksClauseModifier getModifier() const { return Modifier; } |
||
6420 | |||
6421 | /// Gets modifier location. |
||
6422 | SourceLocation getModifierLoc() const { return ModifierLoc; } |
||
6423 | |||
6424 | child_range children() { return child_range(&NumTasks, &NumTasks + 1); } |
||
6425 | |||
6426 | const_child_range children() const { |
||
6427 | return const_child_range(&NumTasks, &NumTasks + 1); |
||
6428 | } |
||
6429 | |||
6430 | child_range used_children(); |
||
6431 | const_child_range used_children() const { |
||
6432 | auto Children = const_cast<OMPNumTasksClause *>(this)->used_children(); |
||
6433 | return const_child_range(Children.begin(), Children.end()); |
||
6434 | } |
||
6435 | |||
6436 | static bool classof(const OMPClause *T) { |
||
6437 | return T->getClauseKind() == llvm::omp::OMPC_num_tasks; |
||
6438 | } |
||
6439 | }; |
||
6440 | |||
6441 | /// This represents 'hint' clause in the '#pragma omp ...' directive. |
||
6442 | /// |
||
6443 | /// \code |
||
6444 | /// #pragma omp critical (name) hint(6) |
||
6445 | /// \endcode |
||
6446 | /// In this example directive '#pragma omp critical' has name 'name' and clause |
||
6447 | /// 'hint' with argument '6'. |
||
6448 | class OMPHintClause : public OMPClause { |
||
6449 | friend class OMPClauseReader; |
||
6450 | |||
6451 | /// Location of '('. |
||
6452 | SourceLocation LParenLoc; |
||
6453 | |||
6454 | /// Hint expression of the 'hint' clause. |
||
6455 | Stmt *Hint = nullptr; |
||
6456 | |||
6457 | /// Set hint expression. |
||
6458 | void setHint(Expr *H) { Hint = H; } |
||
6459 | |||
6460 | public: |
||
6461 | /// Build 'hint' clause with expression \a Hint. |
||
6462 | /// |
||
6463 | /// \param Hint Hint expression. |
||
6464 | /// \param StartLoc Starting location of the clause. |
||
6465 | /// \param LParenLoc Location of '('. |
||
6466 | /// \param EndLoc Ending location of the clause. |
||
6467 | OMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
6468 | SourceLocation EndLoc) |
||
6469 | : OMPClause(llvm::omp::OMPC_hint, StartLoc, EndLoc), LParenLoc(LParenLoc), |
||
6470 | Hint(Hint) {} |
||
6471 | |||
6472 | /// Build an empty clause. |
||
6473 | OMPHintClause() |
||
6474 | : OMPClause(llvm::omp::OMPC_hint, SourceLocation(), SourceLocation()) {} |
||
6475 | |||
6476 | /// Sets the location of '('. |
||
6477 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6478 | |||
6479 | /// Returns the location of '('. |
||
6480 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
6481 | |||
6482 | /// Returns number of threads. |
||
6483 | Expr *getHint() const { return cast_or_null<Expr>(Hint); } |
||
6484 | |||
6485 | child_range children() { return child_range(&Hint, &Hint + 1); } |
||
6486 | |||
6487 | const_child_range children() const { |
||
6488 | return const_child_range(&Hint, &Hint + 1); |
||
6489 | } |
||
6490 | |||
6491 | child_range used_children() { |
||
6492 | return child_range(child_iterator(), child_iterator()); |
||
6493 | } |
||
6494 | const_child_range used_children() const { |
||
6495 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6496 | } |
||
6497 | |||
6498 | static bool classof(const OMPClause *T) { |
||
6499 | return T->getClauseKind() == llvm::omp::OMPC_hint; |
||
6500 | } |
||
6501 | }; |
||
6502 | |||
6503 | /// This represents 'dist_schedule' clause in the '#pragma omp ...' |
||
6504 | /// directive. |
||
6505 | /// |
||
6506 | /// \code |
||
6507 | /// #pragma omp distribute dist_schedule(static, 3) |
||
6508 | /// \endcode |
||
6509 | /// In this example directive '#pragma omp distribute' has 'dist_schedule' |
||
6510 | /// clause with arguments 'static' and '3'. |
||
6511 | class OMPDistScheduleClause : public OMPClause, public OMPClauseWithPreInit { |
||
6512 | friend class OMPClauseReader; |
||
6513 | |||
6514 | /// Location of '('. |
||
6515 | SourceLocation LParenLoc; |
||
6516 | |||
6517 | /// A kind of the 'schedule' clause. |
||
6518 | OpenMPDistScheduleClauseKind Kind = OMPC_DIST_SCHEDULE_unknown; |
||
6519 | |||
6520 | /// Start location of the schedule kind in source code. |
||
6521 | SourceLocation KindLoc; |
||
6522 | |||
6523 | /// Location of ',' (if any). |
||
6524 | SourceLocation CommaLoc; |
||
6525 | |||
6526 | /// Chunk size. |
||
6527 | Expr *ChunkSize = nullptr; |
||
6528 | |||
6529 | /// Set schedule kind. |
||
6530 | /// |
||
6531 | /// \param K Schedule kind. |
||
6532 | void setDistScheduleKind(OpenMPDistScheduleClauseKind K) { Kind = K; } |
||
6533 | |||
6534 | /// Sets the location of '('. |
||
6535 | /// |
||
6536 | /// \param Loc Location of '('. |
||
6537 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6538 | |||
6539 | /// Set schedule kind start location. |
||
6540 | /// |
||
6541 | /// \param KLoc Schedule kind location. |
||
6542 | void setDistScheduleKindLoc(SourceLocation KLoc) { KindLoc = KLoc; } |
||
6543 | |||
6544 | /// Set location of ','. |
||
6545 | /// |
||
6546 | /// \param Loc Location of ','. |
||
6547 | void setCommaLoc(SourceLocation Loc) { CommaLoc = Loc; } |
||
6548 | |||
6549 | /// Set chunk size. |
||
6550 | /// |
||
6551 | /// \param E Chunk size. |
||
6552 | void setChunkSize(Expr *E) { ChunkSize = E; } |
||
6553 | |||
6554 | public: |
||
6555 | /// Build 'dist_schedule' clause with schedule kind \a Kind and chunk |
||
6556 | /// size expression \a ChunkSize. |
||
6557 | /// |
||
6558 | /// \param StartLoc Starting location of the clause. |
||
6559 | /// \param LParenLoc Location of '('. |
||
6560 | /// \param KLoc Starting location of the argument. |
||
6561 | /// \param CommaLoc Location of ','. |
||
6562 | /// \param EndLoc Ending location of the clause. |
||
6563 | /// \param Kind DistSchedule kind. |
||
6564 | /// \param ChunkSize Chunk size. |
||
6565 | /// \param HelperChunkSize Helper chunk size for combined directives. |
||
6566 | OMPDistScheduleClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
6567 | SourceLocation KLoc, SourceLocation CommaLoc, |
||
6568 | SourceLocation EndLoc, |
||
6569 | OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, |
||
6570 | Stmt *HelperChunkSize) |
||
6571 | : OMPClause(llvm::omp::OMPC_dist_schedule, StartLoc, EndLoc), |
||
6572 | OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Kind(Kind), |
||
6573 | KindLoc(KLoc), CommaLoc(CommaLoc), ChunkSize(ChunkSize) { |
||
6574 | setPreInitStmt(HelperChunkSize); |
||
6575 | } |
||
6576 | |||
6577 | /// Build an empty clause. |
||
6578 | explicit OMPDistScheduleClause() |
||
6579 | : OMPClause(llvm::omp::OMPC_dist_schedule, SourceLocation(), |
||
6580 | SourceLocation()), |
||
6581 | OMPClauseWithPreInit(this) {} |
||
6582 | |||
6583 | /// Get kind of the clause. |
||
6584 | OpenMPDistScheduleClauseKind getDistScheduleKind() const { return Kind; } |
||
6585 | |||
6586 | /// Get location of '('. |
||
6587 | SourceLocation getLParenLoc() { return LParenLoc; } |
||
6588 | |||
6589 | /// Get kind location. |
||
6590 | SourceLocation getDistScheduleKindLoc() { return KindLoc; } |
||
6591 | |||
6592 | /// Get location of ','. |
||
6593 | SourceLocation getCommaLoc() { return CommaLoc; } |
||
6594 | |||
6595 | /// Get chunk size. |
||
6596 | Expr *getChunkSize() { return ChunkSize; } |
||
6597 | |||
6598 | /// Get chunk size. |
||
6599 | const Expr *getChunkSize() const { return ChunkSize; } |
||
6600 | |||
6601 | child_range children() { |
||
6602 | return child_range(reinterpret_cast<Stmt **>(&ChunkSize), |
||
6603 | reinterpret_cast<Stmt **>(&ChunkSize) + 1); |
||
6604 | } |
||
6605 | |||
6606 | const_child_range children() const { |
||
6607 | auto Children = const_cast<OMPDistScheduleClause *>(this)->children(); |
||
6608 | return const_child_range(Children.begin(), Children.end()); |
||
6609 | } |
||
6610 | |||
6611 | child_range used_children() { |
||
6612 | return child_range(child_iterator(), child_iterator()); |
||
6613 | } |
||
6614 | const_child_range used_children() const { |
||
6615 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6616 | } |
||
6617 | |||
6618 | static bool classof(const OMPClause *T) { |
||
6619 | return T->getClauseKind() == llvm::omp::OMPC_dist_schedule; |
||
6620 | } |
||
6621 | }; |
||
6622 | |||
6623 | /// This represents 'defaultmap' clause in the '#pragma omp ...' directive. |
||
6624 | /// |
||
6625 | /// \code |
||
6626 | /// #pragma omp target defaultmap(tofrom: scalar) |
||
6627 | /// \endcode |
||
6628 | /// In this example directive '#pragma omp target' has 'defaultmap' clause of kind |
||
6629 | /// 'scalar' with modifier 'tofrom'. |
||
6630 | class OMPDefaultmapClause : public OMPClause { |
||
6631 | friend class OMPClauseReader; |
||
6632 | |||
6633 | /// Location of '('. |
||
6634 | SourceLocation LParenLoc; |
||
6635 | |||
6636 | /// Modifiers for 'defaultmap' clause. |
||
6637 | OpenMPDefaultmapClauseModifier Modifier = OMPC_DEFAULTMAP_MODIFIER_unknown; |
||
6638 | |||
6639 | /// Locations of modifiers. |
||
6640 | SourceLocation ModifierLoc; |
||
6641 | |||
6642 | /// A kind of the 'defaultmap' clause. |
||
6643 | OpenMPDefaultmapClauseKind Kind = OMPC_DEFAULTMAP_unknown; |
||
6644 | |||
6645 | /// Start location of the defaultmap kind in source code. |
||
6646 | SourceLocation KindLoc; |
||
6647 | |||
6648 | /// Set defaultmap kind. |
||
6649 | /// |
||
6650 | /// \param K Defaultmap kind. |
||
6651 | void setDefaultmapKind(OpenMPDefaultmapClauseKind K) { Kind = K; } |
||
6652 | |||
6653 | /// Set the defaultmap modifier. |
||
6654 | /// |
||
6655 | /// \param M Defaultmap modifier. |
||
6656 | void setDefaultmapModifier(OpenMPDefaultmapClauseModifier M) { |
||
6657 | Modifier = M; |
||
6658 | } |
||
6659 | |||
6660 | /// Set location of the defaultmap modifier. |
||
6661 | void setDefaultmapModifierLoc(SourceLocation Loc) { |
||
6662 | ModifierLoc = Loc; |
||
6663 | } |
||
6664 | |||
6665 | /// Sets the location of '('. |
||
6666 | /// |
||
6667 | /// \param Loc Location of '('. |
||
6668 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
6669 | |||
6670 | /// Set defaultmap kind start location. |
||
6671 | /// |
||
6672 | /// \param KLoc Defaultmap kind location. |
||
6673 | void setDefaultmapKindLoc(SourceLocation KLoc) { KindLoc = KLoc; } |
||
6674 | |||
6675 | public: |
||
6676 | /// Build 'defaultmap' clause with defaultmap kind \a Kind |
||
6677 | /// |
||
6678 | /// \param StartLoc Starting location of the clause. |
||
6679 | /// \param LParenLoc Location of '('. |
||
6680 | /// \param KLoc Starting location of the argument. |
||
6681 | /// \param EndLoc Ending location of the clause. |
||
6682 | /// \param Kind Defaultmap kind. |
||
6683 | /// \param M The modifier applied to 'defaultmap' clause. |
||
6684 | /// \param MLoc Location of the modifier |
||
6685 | OMPDefaultmapClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
6686 | SourceLocation MLoc, SourceLocation KLoc, |
||
6687 | SourceLocation EndLoc, OpenMPDefaultmapClauseKind Kind, |
||
6688 | OpenMPDefaultmapClauseModifier M) |
||
6689 | : OMPClause(llvm::omp::OMPC_defaultmap, StartLoc, EndLoc), |
||
6690 | LParenLoc(LParenLoc), Modifier(M), ModifierLoc(MLoc), Kind(Kind), |
||
6691 | KindLoc(KLoc) {} |
||
6692 | |||
6693 | /// Build an empty clause. |
||
6694 | explicit OMPDefaultmapClause() |
||
6695 | : OMPClause(llvm::omp::OMPC_defaultmap, SourceLocation(), |
||
6696 | SourceLocation()) {} |
||
6697 | |||
6698 | /// Get kind of the clause. |
||
6699 | OpenMPDefaultmapClauseKind getDefaultmapKind() const { return Kind; } |
||
6700 | |||
6701 | /// Get the modifier of the clause. |
||
6702 | OpenMPDefaultmapClauseModifier getDefaultmapModifier() const { |
||
6703 | return Modifier; |
||
6704 | } |
||
6705 | |||
6706 | /// Get location of '('. |
||
6707 | SourceLocation getLParenLoc() { return LParenLoc; } |
||
6708 | |||
6709 | /// Get kind location. |
||
6710 | SourceLocation getDefaultmapKindLoc() { return KindLoc; } |
||
6711 | |||
6712 | /// Get the modifier location. |
||
6713 | SourceLocation getDefaultmapModifierLoc() const { |
||
6714 | return ModifierLoc; |
||
6715 | } |
||
6716 | |||
6717 | child_range children() { |
||
6718 | return child_range(child_iterator(), child_iterator()); |
||
6719 | } |
||
6720 | |||
6721 | const_child_range children() const { |
||
6722 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6723 | } |
||
6724 | |||
6725 | child_range used_children() { |
||
6726 | return child_range(child_iterator(), child_iterator()); |
||
6727 | } |
||
6728 | const_child_range used_children() const { |
||
6729 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6730 | } |
||
6731 | |||
6732 | static bool classof(const OMPClause *T) { |
||
6733 | return T->getClauseKind() == llvm::omp::OMPC_defaultmap; |
||
6734 | } |
||
6735 | }; |
||
6736 | |||
6737 | /// This represents clause 'to' in the '#pragma omp ...' |
||
6738 | /// directives. |
||
6739 | /// |
||
6740 | /// \code |
||
6741 | /// #pragma omp target update to(a,b) |
||
6742 | /// \endcode |
||
6743 | /// In this example directive '#pragma omp target update' has clause 'to' |
||
6744 | /// with the variables 'a' and 'b'. |
||
6745 | class OMPToClause final : public OMPMappableExprListClause<OMPToClause>, |
||
6746 | private llvm::TrailingObjects< |
||
6747 | OMPToClause, Expr *, ValueDecl *, unsigned, |
||
6748 | OMPClauseMappableExprCommon::MappableComponent> { |
||
6749 | friend class OMPClauseReader; |
||
6750 | friend OMPMappableExprListClause; |
||
6751 | friend OMPVarListClause; |
||
6752 | friend TrailingObjects; |
||
6753 | |||
6754 | /// Motion-modifiers for the 'to' clause. |
||
6755 | OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = { |
||
6756 | OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown}; |
||
6757 | |||
6758 | /// Location of motion-modifiers for the 'to' clause. |
||
6759 | SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers]; |
||
6760 | |||
6761 | /// Colon location. |
||
6762 | SourceLocation ColonLoc; |
||
6763 | |||
6764 | /// Build clause with number of variables \a NumVars. |
||
6765 | /// |
||
6766 | /// \param TheMotionModifiers Motion-modifiers. |
||
6767 | /// \param TheMotionModifiersLoc Locations of motion-modifiers. |
||
6768 | /// \param MapperQualifierLoc C++ nested name specifier for the associated |
||
6769 | /// user-defined mapper. |
||
6770 | /// \param MapperIdInfo The identifier of associated user-defined mapper. |
||
6771 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
6772 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
6773 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
6774 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
6775 | /// NumVars: number of expressions listed in this clause; 2) |
||
6776 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
6777 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
6778 | /// NumComponents: total number of expression components in the clause. |
||
6779 | explicit OMPToClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers, |
||
6780 | ArrayRef<SourceLocation> TheMotionModifiersLoc, |
||
6781 | NestedNameSpecifierLoc MapperQualifierLoc, |
||
6782 | DeclarationNameInfo MapperIdInfo, |
||
6783 | const OMPVarListLocTy &Locs, |
||
6784 | const OMPMappableExprListSizeTy &Sizes) |
||
6785 | : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes, |
||
6786 | /*SupportsMapper=*/true, &MapperQualifierLoc, |
||
6787 | &MapperIdInfo) { |
||
6788 | assert(std::size(MotionModifiers) == TheMotionModifiers.size() && |
||
6789 | "Unexpected number of motion modifiers."); |
||
6790 | llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); |
||
6791 | |||
6792 | assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && |
||
6793 | "Unexpected number of motion modifier locations."); |
||
6794 | llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); |
||
6795 | } |
||
6796 | |||
6797 | /// Build an empty clause. |
||
6798 | /// |
||
6799 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
6800 | /// NumVars: number of expressions listed in this clause; 2) |
||
6801 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
6802 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
6803 | /// NumComponents: total number of expression components in the clause. |
||
6804 | explicit OMPToClause(const OMPMappableExprListSizeTy &Sizes) |
||
6805 | : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes, |
||
6806 | /*SupportsMapper=*/true) {} |
||
6807 | |||
6808 | /// Set motion-modifier for the clause. |
||
6809 | /// |
||
6810 | /// \param I index for motion-modifier. |
||
6811 | /// \param T motion-modifier for the clause. |
||
6812 | void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) { |
||
6813 | assert(I < NumberOfOMPMotionModifiers && |
||
6814 | "Unexpected index to store motion modifier, exceeds array size."); |
||
6815 | MotionModifiers[I] = T; |
||
6816 | } |
||
6817 | |||
6818 | /// Set location for the motion-modifier. |
||
6819 | /// |
||
6820 | /// \param I index for motion-modifier location. |
||
6821 | /// \param TLoc motion-modifier location. |
||
6822 | void setMotionModifierLoc(unsigned I, SourceLocation TLoc) { |
||
6823 | assert(I < NumberOfOMPMotionModifiers && |
||
6824 | "Index to store motion modifier location exceeds array size."); |
||
6825 | MotionModifiersLoc[I] = TLoc; |
||
6826 | } |
||
6827 | |||
6828 | /// Set colon location. |
||
6829 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
6830 | |||
6831 | /// Define the sizes of each trailing object array except the last one. This |
||
6832 | /// is required for TrailingObjects to work properly. |
||
6833 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
||
6834 | // There are varlist_size() of expressions, and varlist_size() of |
||
6835 | // user-defined mappers. |
||
6836 | return 2 * varlist_size(); |
||
6837 | } |
||
6838 | size_t numTrailingObjects(OverloadToken<ValueDecl *>) const { |
||
6839 | return getUniqueDeclarationsNum(); |
||
6840 | } |
||
6841 | size_t numTrailingObjects(OverloadToken<unsigned>) const { |
||
6842 | return getUniqueDeclarationsNum() + getTotalComponentListNum(); |
||
6843 | } |
||
6844 | |||
6845 | public: |
||
6846 | /// Creates clause with a list of variables \a Vars. |
||
6847 | /// |
||
6848 | /// \param C AST context. |
||
6849 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
6850 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
6851 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
6852 | /// \param Vars The original expression used in the clause. |
||
6853 | /// \param Declarations Declarations used in the clause. |
||
6854 | /// \param ComponentLists Component lists used in the clause. |
||
6855 | /// \param MotionModifiers Motion-modifiers. |
||
6856 | /// \param MotionModifiersLoc Location of motion-modifiers. |
||
6857 | /// \param UDMapperRefs References to user-defined mappers associated with |
||
6858 | /// expressions used in the clause. |
||
6859 | /// \param UDMQualifierLoc C++ nested name specifier for the associated |
||
6860 | /// user-defined mapper. |
||
6861 | /// \param MapperId The identifier of associated user-defined mapper. |
||
6862 | static OMPToClause *Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
||
6863 | ArrayRef<Expr *> Vars, |
||
6864 | ArrayRef<ValueDecl *> Declarations, |
||
6865 | MappableExprComponentListsRef ComponentLists, |
||
6866 | ArrayRef<Expr *> UDMapperRefs, |
||
6867 | ArrayRef<OpenMPMotionModifierKind> MotionModifiers, |
||
6868 | ArrayRef<SourceLocation> MotionModifiersLoc, |
||
6869 | NestedNameSpecifierLoc UDMQualifierLoc, |
||
6870 | DeclarationNameInfo MapperId); |
||
6871 | |||
6872 | /// Creates an empty clause with the place for \a NumVars variables. |
||
6873 | /// |
||
6874 | /// \param C AST context. |
||
6875 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
6876 | /// NumVars: number of expressions listed in this clause; 2) |
||
6877 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
6878 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
6879 | /// NumComponents: total number of expression components in the clause. |
||
6880 | static OMPToClause *CreateEmpty(const ASTContext &C, |
||
6881 | const OMPMappableExprListSizeTy &Sizes); |
||
6882 | |||
6883 | /// Fetches the motion-modifier at 'Cnt' index of array of modifiers. |
||
6884 | /// |
||
6885 | /// \param Cnt index for motion-modifier. |
||
6886 | OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY { |
||
6887 | assert(Cnt < NumberOfOMPMotionModifiers && |
||
6888 | "Requested modifier exceeds the total number of modifiers."); |
||
6889 | return MotionModifiers[Cnt]; |
||
6890 | } |
||
6891 | |||
6892 | /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers' |
||
6893 | /// locations. |
||
6894 | /// |
||
6895 | /// \param Cnt index for motion-modifier location. |
||
6896 | SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY { |
||
6897 | assert(Cnt < NumberOfOMPMotionModifiers && |
||
6898 | "Requested modifier location exceeds total number of modifiers."); |
||
6899 | return MotionModifiersLoc[Cnt]; |
||
6900 | } |
||
6901 | |||
6902 | /// Fetches ArrayRef of motion-modifiers. |
||
6903 | ArrayRef<OpenMPMotionModifierKind> getMotionModifiers() const LLVM_READONLY { |
||
6904 | return llvm::ArrayRef(MotionModifiers); |
||
6905 | } |
||
6906 | |||
6907 | /// Fetches ArrayRef of location of motion-modifiers. |
||
6908 | ArrayRef<SourceLocation> getMotionModifiersLoc() const LLVM_READONLY { |
||
6909 | return llvm::ArrayRef(MotionModifiersLoc); |
||
6910 | } |
||
6911 | |||
6912 | /// Get colon location. |
||
6913 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
6914 | |||
6915 | child_range children() { |
||
6916 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
6917 | reinterpret_cast<Stmt **>(varlist_end())); |
||
6918 | } |
||
6919 | |||
6920 | const_child_range children() const { |
||
6921 | auto Children = const_cast<OMPToClause *>(this)->children(); |
||
6922 | return const_child_range(Children.begin(), Children.end()); |
||
6923 | } |
||
6924 | |||
6925 | child_range used_children() { |
||
6926 | return child_range(child_iterator(), child_iterator()); |
||
6927 | } |
||
6928 | const_child_range used_children() const { |
||
6929 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
6930 | } |
||
6931 | |||
6932 | static bool classof(const OMPClause *T) { |
||
6933 | return T->getClauseKind() == llvm::omp::OMPC_to; |
||
6934 | } |
||
6935 | }; |
||
6936 | |||
6937 | /// This represents clause 'from' in the '#pragma omp ...' |
||
6938 | /// directives. |
||
6939 | /// |
||
6940 | /// \code |
||
6941 | /// #pragma omp target update from(a,b) |
||
6942 | /// \endcode |
||
6943 | /// In this example directive '#pragma omp target update' has clause 'from' |
||
6944 | /// with the variables 'a' and 'b'. |
||
6945 | class OMPFromClause final |
||
6946 | : public OMPMappableExprListClause<OMPFromClause>, |
||
6947 | private llvm::TrailingObjects< |
||
6948 | OMPFromClause, Expr *, ValueDecl *, unsigned, |
||
6949 | OMPClauseMappableExprCommon::MappableComponent> { |
||
6950 | friend class OMPClauseReader; |
||
6951 | friend OMPMappableExprListClause; |
||
6952 | friend OMPVarListClause; |
||
6953 | friend TrailingObjects; |
||
6954 | |||
6955 | /// Motion-modifiers for the 'from' clause. |
||
6956 | OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = { |
||
6957 | OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown}; |
||
6958 | |||
6959 | /// Location of motion-modifiers for the 'from' clause. |
||
6960 | SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers]; |
||
6961 | |||
6962 | /// Colon location. |
||
6963 | SourceLocation ColonLoc; |
||
6964 | |||
6965 | /// Build clause with number of variables \a NumVars. |
||
6966 | /// |
||
6967 | /// \param TheMotionModifiers Motion-modifiers. |
||
6968 | /// \param TheMotionModifiersLoc Locations of motion-modifiers. |
||
6969 | /// \param MapperQualifierLoc C++ nested name specifier for the associated |
||
6970 | /// user-defined mapper. |
||
6971 | /// \param MapperIdInfo The identifier of associated user-defined mapper. |
||
6972 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
6973 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
6974 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
6975 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
6976 | /// NumVars: number of expressions listed in this clause; 2) |
||
6977 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
6978 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
6979 | /// NumComponents: total number of expression components in the clause. |
||
6980 | explicit OMPFromClause(ArrayRef<OpenMPMotionModifierKind> TheMotionModifiers, |
||
6981 | ArrayRef<SourceLocation> TheMotionModifiersLoc, |
||
6982 | NestedNameSpecifierLoc MapperQualifierLoc, |
||
6983 | DeclarationNameInfo MapperIdInfo, |
||
6984 | const OMPVarListLocTy &Locs, |
||
6985 | const OMPMappableExprListSizeTy &Sizes) |
||
6986 | : OMPMappableExprListClause(llvm::omp::OMPC_from, Locs, Sizes, |
||
6987 | /*SupportsMapper=*/true, &MapperQualifierLoc, |
||
6988 | &MapperIdInfo) { |
||
6989 | assert(std::size(MotionModifiers) == TheMotionModifiers.size() && |
||
6990 | "Unexpected number of motion modifiers."); |
||
6991 | llvm::copy(TheMotionModifiers, std::begin(MotionModifiers)); |
||
6992 | |||
6993 | assert(std::size(MotionModifiersLoc) == TheMotionModifiersLoc.size() && |
||
6994 | "Unexpected number of motion modifier locations."); |
||
6995 | llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc)); |
||
6996 | } |
||
6997 | |||
6998 | /// Build an empty clause. |
||
6999 | /// |
||
7000 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7001 | /// NumVars: number of expressions listed in this clause; 2) |
||
7002 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7003 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7004 | /// NumComponents: total number of expression components in the clause. |
||
7005 | explicit OMPFromClause(const OMPMappableExprListSizeTy &Sizes) |
||
7006 | : OMPMappableExprListClause(llvm::omp::OMPC_from, OMPVarListLocTy(), |
||
7007 | Sizes, /*SupportsMapper=*/true) {} |
||
7008 | |||
7009 | /// Set motion-modifier for the clause. |
||
7010 | /// |
||
7011 | /// \param I index for motion-modifier. |
||
7012 | /// \param T motion-modifier for the clause. |
||
7013 | void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) { |
||
7014 | assert(I < NumberOfOMPMotionModifiers && |
||
7015 | "Unexpected index to store motion modifier, exceeds array size."); |
||
7016 | MotionModifiers[I] = T; |
||
7017 | } |
||
7018 | |||
7019 | /// Set location for the motion-modifier. |
||
7020 | /// |
||
7021 | /// \param I index for motion-modifier location. |
||
7022 | /// \param TLoc motion-modifier location. |
||
7023 | void setMotionModifierLoc(unsigned I, SourceLocation TLoc) { |
||
7024 | assert(I < NumberOfOMPMotionModifiers && |
||
7025 | "Index to store motion modifier location exceeds array size."); |
||
7026 | MotionModifiersLoc[I] = TLoc; |
||
7027 | } |
||
7028 | |||
7029 | /// Set colon location. |
||
7030 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
7031 | |||
7032 | /// Define the sizes of each trailing object array except the last one. This |
||
7033 | /// is required for TrailingObjects to work properly. |
||
7034 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
||
7035 | // There are varlist_size() of expressions, and varlist_size() of |
||
7036 | // user-defined mappers. |
||
7037 | return 2 * varlist_size(); |
||
7038 | } |
||
7039 | size_t numTrailingObjects(OverloadToken<ValueDecl *>) const { |
||
7040 | return getUniqueDeclarationsNum(); |
||
7041 | } |
||
7042 | size_t numTrailingObjects(OverloadToken<unsigned>) const { |
||
7043 | return getUniqueDeclarationsNum() + getTotalComponentListNum(); |
||
7044 | } |
||
7045 | |||
7046 | public: |
||
7047 | /// Creates clause with a list of variables \a Vars. |
||
7048 | /// |
||
7049 | /// \param C AST context. |
||
7050 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7051 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7052 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7053 | /// \param Vars The original expression used in the clause. |
||
7054 | /// \param Declarations Declarations used in the clause. |
||
7055 | /// \param ComponentLists Component lists used in the clause. |
||
7056 | /// \param MotionModifiers Motion-modifiers. |
||
7057 | /// \param MotionModifiersLoc Location of motion-modifiers. |
||
7058 | /// \param UDMapperRefs References to user-defined mappers associated with |
||
7059 | /// expressions used in the clause. |
||
7060 | /// \param UDMQualifierLoc C++ nested name specifier for the associated |
||
7061 | /// user-defined mapper. |
||
7062 | /// \param MapperId The identifier of associated user-defined mapper. |
||
7063 | static OMPFromClause * |
||
7064 | Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
||
7065 | ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations, |
||
7066 | MappableExprComponentListsRef ComponentLists, |
||
7067 | ArrayRef<Expr *> UDMapperRefs, |
||
7068 | ArrayRef<OpenMPMotionModifierKind> MotionModifiers, |
||
7069 | ArrayRef<SourceLocation> MotionModifiersLoc, |
||
7070 | NestedNameSpecifierLoc UDMQualifierLoc, DeclarationNameInfo MapperId); |
||
7071 | |||
7072 | /// Creates an empty clause with the place for \a NumVars variables. |
||
7073 | /// |
||
7074 | /// \param C AST context. |
||
7075 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7076 | /// NumVars: number of expressions listed in this clause; 2) |
||
7077 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7078 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7079 | /// NumComponents: total number of expression components in the clause. |
||
7080 | static OMPFromClause *CreateEmpty(const ASTContext &C, |
||
7081 | const OMPMappableExprListSizeTy &Sizes); |
||
7082 | |||
7083 | /// Fetches the motion-modifier at 'Cnt' index of array of modifiers. |
||
7084 | /// |
||
7085 | /// \param Cnt index for motion-modifier. |
||
7086 | OpenMPMotionModifierKind getMotionModifier(unsigned Cnt) const LLVM_READONLY { |
||
7087 | assert(Cnt < NumberOfOMPMotionModifiers && |
||
7088 | "Requested modifier exceeds the total number of modifiers."); |
||
7089 | return MotionModifiers[Cnt]; |
||
7090 | } |
||
7091 | |||
7092 | /// Fetches the motion-modifier location at 'Cnt' index of array of modifiers' |
||
7093 | /// locations. |
||
7094 | /// |
||
7095 | /// \param Cnt index for motion-modifier location. |
||
7096 | SourceLocation getMotionModifierLoc(unsigned Cnt) const LLVM_READONLY { |
||
7097 | assert(Cnt < NumberOfOMPMotionModifiers && |
||
7098 | "Requested modifier location exceeds total number of modifiers."); |
||
7099 | return MotionModifiersLoc[Cnt]; |
||
7100 | } |
||
7101 | |||
7102 | /// Fetches ArrayRef of motion-modifiers. |
||
7103 | ArrayRef<OpenMPMotionModifierKind> getMotionModifiers() const LLVM_READONLY { |
||
7104 | return llvm::ArrayRef(MotionModifiers); |
||
7105 | } |
||
7106 | |||
7107 | /// Fetches ArrayRef of location of motion-modifiers. |
||
7108 | ArrayRef<SourceLocation> getMotionModifiersLoc() const LLVM_READONLY { |
||
7109 | return llvm::ArrayRef(MotionModifiersLoc); |
||
7110 | } |
||
7111 | |||
7112 | /// Get colon location. |
||
7113 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
7114 | |||
7115 | child_range children() { |
||
7116 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
7117 | reinterpret_cast<Stmt **>(varlist_end())); |
||
7118 | } |
||
7119 | |||
7120 | const_child_range children() const { |
||
7121 | auto Children = const_cast<OMPFromClause *>(this)->children(); |
||
7122 | return const_child_range(Children.begin(), Children.end()); |
||
7123 | } |
||
7124 | |||
7125 | child_range used_children() { |
||
7126 | return child_range(child_iterator(), child_iterator()); |
||
7127 | } |
||
7128 | const_child_range used_children() const { |
||
7129 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7130 | } |
||
7131 | |||
7132 | static bool classof(const OMPClause *T) { |
||
7133 | return T->getClauseKind() == llvm::omp::OMPC_from; |
||
7134 | } |
||
7135 | }; |
||
7136 | |||
7137 | /// This represents clause 'use_device_ptr' in the '#pragma omp ...' |
||
7138 | /// directives. |
||
7139 | /// |
||
7140 | /// \code |
||
7141 | /// #pragma omp target data use_device_ptr(a,b) |
||
7142 | /// \endcode |
||
7143 | /// In this example directive '#pragma omp target data' has clause |
||
7144 | /// 'use_device_ptr' with the variables 'a' and 'b'. |
||
7145 | class OMPUseDevicePtrClause final |
||
7146 | : public OMPMappableExprListClause<OMPUseDevicePtrClause>, |
||
7147 | private llvm::TrailingObjects< |
||
7148 | OMPUseDevicePtrClause, Expr *, ValueDecl *, unsigned, |
||
7149 | OMPClauseMappableExprCommon::MappableComponent> { |
||
7150 | friend class OMPClauseReader; |
||
7151 | friend OMPMappableExprListClause; |
||
7152 | friend OMPVarListClause; |
||
7153 | friend TrailingObjects; |
||
7154 | |||
7155 | /// Build clause with number of variables \a NumVars. |
||
7156 | /// |
||
7157 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7158 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7159 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7160 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7161 | /// NumVars: number of expressions listed in this clause; 2) |
||
7162 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7163 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7164 | /// NumComponents: total number of expression components in the clause. |
||
7165 | explicit OMPUseDevicePtrClause(const OMPVarListLocTy &Locs, |
||
7166 | const OMPMappableExprListSizeTy &Sizes) |
||
7167 | : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, Locs, Sizes) { |
||
7168 | } |
||
7169 | |||
7170 | /// Build an empty clause. |
||
7171 | /// |
||
7172 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7173 | /// NumVars: number of expressions listed in this clause; 2) |
||
7174 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7175 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7176 | /// NumComponents: total number of expression components in the clause. |
||
7177 | explicit OMPUseDevicePtrClause(const OMPMappableExprListSizeTy &Sizes) |
||
7178 | : OMPMappableExprListClause(llvm::omp::OMPC_use_device_ptr, |
||
7179 | OMPVarListLocTy(), Sizes) {} |
||
7180 | |||
7181 | /// Define the sizes of each trailing object array except the last one. This |
||
7182 | /// is required for TrailingObjects to work properly. |
||
7183 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
||
7184 | return 3 * varlist_size(); |
||
7185 | } |
||
7186 | size_t numTrailingObjects(OverloadToken<ValueDecl *>) const { |
||
7187 | return getUniqueDeclarationsNum(); |
||
7188 | } |
||
7189 | size_t numTrailingObjects(OverloadToken<unsigned>) const { |
||
7190 | return getUniqueDeclarationsNum() + getTotalComponentListNum(); |
||
7191 | } |
||
7192 | |||
7193 | /// Sets the list of references to private copies with initializers for new |
||
7194 | /// private variables. |
||
7195 | /// \param VL List of references. |
||
7196 | void setPrivateCopies(ArrayRef<Expr *> VL); |
||
7197 | |||
7198 | /// Gets the list of references to private copies with initializers for new |
||
7199 | /// private variables. |
||
7200 | MutableArrayRef<Expr *> getPrivateCopies() { |
||
7201 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
7202 | } |
||
7203 | ArrayRef<const Expr *> getPrivateCopies() const { |
||
7204 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
7205 | } |
||
7206 | |||
7207 | /// Sets the list of references to initializer variables for new private |
||
7208 | /// variables. |
||
7209 | /// \param VL List of references. |
||
7210 | void setInits(ArrayRef<Expr *> VL); |
||
7211 | |||
7212 | /// Gets the list of references to initializer variables for new private |
||
7213 | /// variables. |
||
7214 | MutableArrayRef<Expr *> getInits() { |
||
7215 | return MutableArrayRef<Expr *>(getPrivateCopies().end(), varlist_size()); |
||
7216 | } |
||
7217 | ArrayRef<const Expr *> getInits() const { |
||
7218 | return llvm::ArrayRef(getPrivateCopies().end(), varlist_size()); |
||
7219 | } |
||
7220 | |||
7221 | public: |
||
7222 | /// Creates clause with a list of variables \a Vars. |
||
7223 | /// |
||
7224 | /// \param C AST context. |
||
7225 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7226 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7227 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7228 | /// \param Vars The original expression used in the clause. |
||
7229 | /// \param PrivateVars Expressions referring to private copies. |
||
7230 | /// \param Inits Expressions referring to private copy initializers. |
||
7231 | /// \param Declarations Declarations used in the clause. |
||
7232 | /// \param ComponentLists Component lists used in the clause. |
||
7233 | static OMPUseDevicePtrClause * |
||
7234 | Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
||
7235 | ArrayRef<Expr *> Vars, ArrayRef<Expr *> PrivateVars, |
||
7236 | ArrayRef<Expr *> Inits, ArrayRef<ValueDecl *> Declarations, |
||
7237 | MappableExprComponentListsRef ComponentLists); |
||
7238 | |||
7239 | /// Creates an empty clause with the place for \a NumVars variables. |
||
7240 | /// |
||
7241 | /// \param C AST context. |
||
7242 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7243 | /// NumVars: number of expressions listed in this clause; 2) |
||
7244 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7245 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7246 | /// NumComponents: total number of expression components in the clause. |
||
7247 | static OMPUseDevicePtrClause * |
||
7248 | CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes); |
||
7249 | |||
7250 | using private_copies_iterator = MutableArrayRef<Expr *>::iterator; |
||
7251 | using private_copies_const_iterator = ArrayRef<const Expr *>::iterator; |
||
7252 | using private_copies_range = llvm::iterator_range<private_copies_iterator>; |
||
7253 | using private_copies_const_range = |
||
7254 | llvm::iterator_range<private_copies_const_iterator>; |
||
7255 | |||
7256 | private_copies_range private_copies() { |
||
7257 | return private_copies_range(getPrivateCopies().begin(), |
||
7258 | getPrivateCopies().end()); |
||
7259 | } |
||
7260 | |||
7261 | private_copies_const_range private_copies() const { |
||
7262 | return private_copies_const_range(getPrivateCopies().begin(), |
||
7263 | getPrivateCopies().end()); |
||
7264 | } |
||
7265 | |||
7266 | using inits_iterator = MutableArrayRef<Expr *>::iterator; |
||
7267 | using inits_const_iterator = ArrayRef<const Expr *>::iterator; |
||
7268 | using inits_range = llvm::iterator_range<inits_iterator>; |
||
7269 | using inits_const_range = llvm::iterator_range<inits_const_iterator>; |
||
7270 | |||
7271 | inits_range inits() { |
||
7272 | return inits_range(getInits().begin(), getInits().end()); |
||
7273 | } |
||
7274 | |||
7275 | inits_const_range inits() const { |
||
7276 | return inits_const_range(getInits().begin(), getInits().end()); |
||
7277 | } |
||
7278 | |||
7279 | child_range children() { |
||
7280 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
7281 | reinterpret_cast<Stmt **>(varlist_end())); |
||
7282 | } |
||
7283 | |||
7284 | const_child_range children() const { |
||
7285 | auto Children = const_cast<OMPUseDevicePtrClause *>(this)->children(); |
||
7286 | return const_child_range(Children.begin(), Children.end()); |
||
7287 | } |
||
7288 | |||
7289 | child_range used_children() { |
||
7290 | return child_range(child_iterator(), child_iterator()); |
||
7291 | } |
||
7292 | const_child_range used_children() const { |
||
7293 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7294 | } |
||
7295 | |||
7296 | static bool classof(const OMPClause *T) { |
||
7297 | return T->getClauseKind() == llvm::omp::OMPC_use_device_ptr; |
||
7298 | } |
||
7299 | }; |
||
7300 | |||
7301 | /// This represents clause 'use_device_addr' in the '#pragma omp ...' |
||
7302 | /// directives. |
||
7303 | /// |
||
7304 | /// \code |
||
7305 | /// #pragma omp target data use_device_addr(a,b) |
||
7306 | /// \endcode |
||
7307 | /// In this example directive '#pragma omp target data' has clause |
||
7308 | /// 'use_device_addr' with the variables 'a' and 'b'. |
||
7309 | class OMPUseDeviceAddrClause final |
||
7310 | : public OMPMappableExprListClause<OMPUseDeviceAddrClause>, |
||
7311 | private llvm::TrailingObjects< |
||
7312 | OMPUseDeviceAddrClause, Expr *, ValueDecl *, unsigned, |
||
7313 | OMPClauseMappableExprCommon::MappableComponent> { |
||
7314 | friend class OMPClauseReader; |
||
7315 | friend OMPMappableExprListClause; |
||
7316 | friend OMPVarListClause; |
||
7317 | friend TrailingObjects; |
||
7318 | |||
7319 | /// Build clause with number of variables \a NumVars. |
||
7320 | /// |
||
7321 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7322 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7323 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7324 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7325 | /// NumVars: number of expressions listed in this clause; 2) |
||
7326 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7327 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7328 | /// NumComponents: total number of expression components in the clause. |
||
7329 | explicit OMPUseDeviceAddrClause(const OMPVarListLocTy &Locs, |
||
7330 | const OMPMappableExprListSizeTy &Sizes) |
||
7331 | : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, Locs, |
||
7332 | Sizes) {} |
||
7333 | |||
7334 | /// Build an empty clause. |
||
7335 | /// |
||
7336 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7337 | /// NumVars: number of expressions listed in this clause; 2) |
||
7338 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7339 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7340 | /// NumComponents: total number of expression components in the clause. |
||
7341 | explicit OMPUseDeviceAddrClause(const OMPMappableExprListSizeTy &Sizes) |
||
7342 | : OMPMappableExprListClause(llvm::omp::OMPC_use_device_addr, |
||
7343 | OMPVarListLocTy(), Sizes) {} |
||
7344 | |||
7345 | /// Define the sizes of each trailing object array except the last one. This |
||
7346 | /// is required for TrailingObjects to work properly. |
||
7347 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
||
7348 | return varlist_size(); |
||
7349 | } |
||
7350 | size_t numTrailingObjects(OverloadToken<ValueDecl *>) const { |
||
7351 | return getUniqueDeclarationsNum(); |
||
7352 | } |
||
7353 | size_t numTrailingObjects(OverloadToken<unsigned>) const { |
||
7354 | return getUniqueDeclarationsNum() + getTotalComponentListNum(); |
||
7355 | } |
||
7356 | |||
7357 | public: |
||
7358 | /// Creates clause with a list of variables \a Vars. |
||
7359 | /// |
||
7360 | /// \param C AST context. |
||
7361 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7362 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7363 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7364 | /// \param Vars The original expression used in the clause. |
||
7365 | /// \param Declarations Declarations used in the clause. |
||
7366 | /// \param ComponentLists Component lists used in the clause. |
||
7367 | static OMPUseDeviceAddrClause * |
||
7368 | Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
||
7369 | ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations, |
||
7370 | MappableExprComponentListsRef ComponentLists); |
||
7371 | |||
7372 | /// Creates an empty clause with the place for \a NumVars variables. |
||
7373 | /// |
||
7374 | /// \param C AST context. |
||
7375 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7376 | /// NumVars: number of expressions listed in this clause; 2) |
||
7377 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7378 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7379 | /// NumComponents: total number of expression components in the clause. |
||
7380 | static OMPUseDeviceAddrClause * |
||
7381 | CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes); |
||
7382 | |||
7383 | child_range children() { |
||
7384 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
7385 | reinterpret_cast<Stmt **>(varlist_end())); |
||
7386 | } |
||
7387 | |||
7388 | const_child_range children() const { |
||
7389 | auto Children = const_cast<OMPUseDeviceAddrClause *>(this)->children(); |
||
7390 | return const_child_range(Children.begin(), Children.end()); |
||
7391 | } |
||
7392 | |||
7393 | child_range used_children() { |
||
7394 | return child_range(child_iterator(), child_iterator()); |
||
7395 | } |
||
7396 | const_child_range used_children() const { |
||
7397 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7398 | } |
||
7399 | |||
7400 | static bool classof(const OMPClause *T) { |
||
7401 | return T->getClauseKind() == llvm::omp::OMPC_use_device_addr; |
||
7402 | } |
||
7403 | }; |
||
7404 | |||
7405 | /// This represents clause 'is_device_ptr' in the '#pragma omp ...' |
||
7406 | /// directives. |
||
7407 | /// |
||
7408 | /// \code |
||
7409 | /// #pragma omp target is_device_ptr(a,b) |
||
7410 | /// \endcode |
||
7411 | /// In this example directive '#pragma omp target' has clause |
||
7412 | /// 'is_device_ptr' with the variables 'a' and 'b'. |
||
7413 | class OMPIsDevicePtrClause final |
||
7414 | : public OMPMappableExprListClause<OMPIsDevicePtrClause>, |
||
7415 | private llvm::TrailingObjects< |
||
7416 | OMPIsDevicePtrClause, Expr *, ValueDecl *, unsigned, |
||
7417 | OMPClauseMappableExprCommon::MappableComponent> { |
||
7418 | friend class OMPClauseReader; |
||
7419 | friend OMPMappableExprListClause; |
||
7420 | friend OMPVarListClause; |
||
7421 | friend TrailingObjects; |
||
7422 | |||
7423 | /// Build clause with number of variables \a NumVars. |
||
7424 | /// |
||
7425 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7426 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7427 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7428 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7429 | /// NumVars: number of expressions listed in this clause; 2) |
||
7430 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7431 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7432 | /// NumComponents: total number of expression components in the clause. |
||
7433 | explicit OMPIsDevicePtrClause(const OMPVarListLocTy &Locs, |
||
7434 | const OMPMappableExprListSizeTy &Sizes) |
||
7435 | : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, Locs, Sizes) {} |
||
7436 | |||
7437 | /// Build an empty clause. |
||
7438 | /// |
||
7439 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7440 | /// NumVars: number of expressions listed in this clause; 2) |
||
7441 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7442 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7443 | /// NumComponents: total number of expression components in the clause. |
||
7444 | explicit OMPIsDevicePtrClause(const OMPMappableExprListSizeTy &Sizes) |
||
7445 | : OMPMappableExprListClause(llvm::omp::OMPC_is_device_ptr, |
||
7446 | OMPVarListLocTy(), Sizes) {} |
||
7447 | |||
7448 | /// Define the sizes of each trailing object array except the last one. This |
||
7449 | /// is required for TrailingObjects to work properly. |
||
7450 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
||
7451 | return varlist_size(); |
||
7452 | } |
||
7453 | size_t numTrailingObjects(OverloadToken<ValueDecl *>) const { |
||
7454 | return getUniqueDeclarationsNum(); |
||
7455 | } |
||
7456 | size_t numTrailingObjects(OverloadToken<unsigned>) const { |
||
7457 | return getUniqueDeclarationsNum() + getTotalComponentListNum(); |
||
7458 | } |
||
7459 | |||
7460 | public: |
||
7461 | /// Creates clause with a list of variables \a Vars. |
||
7462 | /// |
||
7463 | /// \param C AST context. |
||
7464 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7465 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7466 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7467 | /// \param Vars The original expression used in the clause. |
||
7468 | /// \param Declarations Declarations used in the clause. |
||
7469 | /// \param ComponentLists Component lists used in the clause. |
||
7470 | static OMPIsDevicePtrClause * |
||
7471 | Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
||
7472 | ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations, |
||
7473 | MappableExprComponentListsRef ComponentLists); |
||
7474 | |||
7475 | /// Creates an empty clause with the place for \a NumVars variables. |
||
7476 | /// |
||
7477 | /// \param C AST context. |
||
7478 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7479 | /// NumVars: number of expressions listed in this clause; 2) |
||
7480 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7481 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7482 | /// NumComponents: total number of expression components in the clause. |
||
7483 | static OMPIsDevicePtrClause * |
||
7484 | CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes); |
||
7485 | |||
7486 | child_range children() { |
||
7487 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
7488 | reinterpret_cast<Stmt **>(varlist_end())); |
||
7489 | } |
||
7490 | |||
7491 | const_child_range children() const { |
||
7492 | auto Children = const_cast<OMPIsDevicePtrClause *>(this)->children(); |
||
7493 | return const_child_range(Children.begin(), Children.end()); |
||
7494 | } |
||
7495 | |||
7496 | child_range used_children() { |
||
7497 | return child_range(child_iterator(), child_iterator()); |
||
7498 | } |
||
7499 | const_child_range used_children() const { |
||
7500 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7501 | } |
||
7502 | |||
7503 | static bool classof(const OMPClause *T) { |
||
7504 | return T->getClauseKind() == llvm::omp::OMPC_is_device_ptr; |
||
7505 | } |
||
7506 | }; |
||
7507 | |||
7508 | /// This represents clause 'has_device_ptr' in the '#pragma omp ...' |
||
7509 | /// directives. |
||
7510 | /// |
||
7511 | /// \code |
||
7512 | /// #pragma omp target has_device_addr(a,b) |
||
7513 | /// \endcode |
||
7514 | /// In this example directive '#pragma omp target' has clause |
||
7515 | /// 'has_device_ptr' with the variables 'a' and 'b'. |
||
7516 | class OMPHasDeviceAddrClause final |
||
7517 | : public OMPMappableExprListClause<OMPHasDeviceAddrClause>, |
||
7518 | private llvm::TrailingObjects< |
||
7519 | OMPHasDeviceAddrClause, Expr *, ValueDecl *, unsigned, |
||
7520 | OMPClauseMappableExprCommon::MappableComponent> { |
||
7521 | friend class OMPClauseReader; |
||
7522 | friend OMPMappableExprListClause; |
||
7523 | friend OMPVarListClause; |
||
7524 | friend TrailingObjects; |
||
7525 | |||
7526 | /// Build clause with number of variables \a NumVars. |
||
7527 | /// |
||
7528 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7529 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7530 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7531 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7532 | /// NumVars: number of expressions listed in this clause; 2) |
||
7533 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7534 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7535 | /// NumComponents: total number of expression components in the clause. |
||
7536 | explicit OMPHasDeviceAddrClause(const OMPVarListLocTy &Locs, |
||
7537 | const OMPMappableExprListSizeTy &Sizes) |
||
7538 | : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, Locs, |
||
7539 | Sizes) {} |
||
7540 | |||
7541 | /// Build an empty clause. |
||
7542 | /// |
||
7543 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7544 | /// NumVars: number of expressions listed in this clause; 2) |
||
7545 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7546 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7547 | /// NumComponents: total number of expression components in the clause. |
||
7548 | explicit OMPHasDeviceAddrClause(const OMPMappableExprListSizeTy &Sizes) |
||
7549 | : OMPMappableExprListClause(llvm::omp::OMPC_has_device_addr, |
||
7550 | OMPVarListLocTy(), Sizes) {} |
||
7551 | |||
7552 | /// Define the sizes of each trailing object array except the last one. This |
||
7553 | /// is required for TrailingObjects to work properly. |
||
7554 | size_t numTrailingObjects(OverloadToken<Expr *>) const { |
||
7555 | return varlist_size(); |
||
7556 | } |
||
7557 | size_t numTrailingObjects(OverloadToken<ValueDecl *>) const { |
||
7558 | return getUniqueDeclarationsNum(); |
||
7559 | } |
||
7560 | size_t numTrailingObjects(OverloadToken<unsigned>) const { |
||
7561 | return getUniqueDeclarationsNum() + getTotalComponentListNum(); |
||
7562 | } |
||
7563 | |||
7564 | public: |
||
7565 | /// Creates clause with a list of variables \a Vars. |
||
7566 | /// |
||
7567 | /// \param C AST context. |
||
7568 | /// \param Locs Locations needed to build a mappable clause. It includes 1) |
||
7569 | /// StartLoc: starting location of the clause (the clause keyword); 2) |
||
7570 | /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause. |
||
7571 | /// \param Vars The original expression used in the clause. |
||
7572 | /// \param Declarations Declarations used in the clause. |
||
7573 | /// \param ComponentLists Component lists used in the clause. |
||
7574 | static OMPHasDeviceAddrClause * |
||
7575 | Create(const ASTContext &C, const OMPVarListLocTy &Locs, |
||
7576 | ArrayRef<Expr *> Vars, ArrayRef<ValueDecl *> Declarations, |
||
7577 | MappableExprComponentListsRef ComponentLists); |
||
7578 | |||
7579 | /// Creates an empty clause with the place for \a NumVars variables. |
||
7580 | /// |
||
7581 | /// \param C AST context. |
||
7582 | /// \param Sizes All required sizes to build a mappable clause. It includes 1) |
||
7583 | /// NumVars: number of expressions listed in this clause; 2) |
||
7584 | /// NumUniqueDeclarations: number of unique base declarations in this clause; |
||
7585 | /// 3) NumComponentLists: number of component lists in this clause; and 4) |
||
7586 | /// NumComponents: total number of expression components in the clause. |
||
7587 | static OMPHasDeviceAddrClause * |
||
7588 | CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes); |
||
7589 | |||
7590 | child_range children() { |
||
7591 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
7592 | reinterpret_cast<Stmt **>(varlist_end())); |
||
7593 | } |
||
7594 | |||
7595 | const_child_range children() const { |
||
7596 | auto Children = const_cast<OMPHasDeviceAddrClause *>(this)->children(); |
||
7597 | return const_child_range(Children.begin(), Children.end()); |
||
7598 | } |
||
7599 | |||
7600 | child_range used_children() { |
||
7601 | return child_range(child_iterator(), child_iterator()); |
||
7602 | } |
||
7603 | const_child_range used_children() const { |
||
7604 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7605 | } |
||
7606 | |||
7607 | static bool classof(const OMPClause *T) { |
||
7608 | return T->getClauseKind() == llvm::omp::OMPC_has_device_addr; |
||
7609 | } |
||
7610 | }; |
||
7611 | |||
7612 | /// This represents clause 'nontemporal' in the '#pragma omp ...' directives. |
||
7613 | /// |
||
7614 | /// \code |
||
7615 | /// #pragma omp simd nontemporal(a) |
||
7616 | /// \endcode |
||
7617 | /// In this example directive '#pragma omp simd' has clause 'nontemporal' for |
||
7618 | /// the variable 'a'. |
||
7619 | class OMPNontemporalClause final |
||
7620 | : public OMPVarListClause<OMPNontemporalClause>, |
||
7621 | private llvm::TrailingObjects<OMPNontemporalClause, Expr *> { |
||
7622 | friend class OMPClauseReader; |
||
7623 | friend OMPVarListClause; |
||
7624 | friend TrailingObjects; |
||
7625 | |||
7626 | /// Build clause with number of variables \a N. |
||
7627 | /// |
||
7628 | /// \param StartLoc Starting location of the clause. |
||
7629 | /// \param LParenLoc Location of '('. |
||
7630 | /// \param EndLoc Ending location of the clause. |
||
7631 | /// \param N Number of the variables in the clause. |
||
7632 | OMPNontemporalClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
7633 | SourceLocation EndLoc, unsigned N) |
||
7634 | : OMPVarListClause<OMPNontemporalClause>(llvm::omp::OMPC_nontemporal, |
||
7635 | StartLoc, LParenLoc, EndLoc, N) { |
||
7636 | } |
||
7637 | |||
7638 | /// Build an empty clause. |
||
7639 | /// |
||
7640 | /// \param N Number of variables. |
||
7641 | explicit OMPNontemporalClause(unsigned N) |
||
7642 | : OMPVarListClause<OMPNontemporalClause>( |
||
7643 | llvm::omp::OMPC_nontemporal, SourceLocation(), SourceLocation(), |
||
7644 | SourceLocation(), N) {} |
||
7645 | |||
7646 | /// Get the list of privatied copies if the member expression was captured by |
||
7647 | /// one of the privatization clauses. |
||
7648 | MutableArrayRef<Expr *> getPrivateRefs() { |
||
7649 | return MutableArrayRef<Expr *>(varlist_end(), varlist_size()); |
||
7650 | } |
||
7651 | ArrayRef<const Expr *> getPrivateRefs() const { |
||
7652 | return llvm::ArrayRef(varlist_end(), varlist_size()); |
||
7653 | } |
||
7654 | |||
7655 | public: |
||
7656 | /// Creates clause with a list of variables \a VL. |
||
7657 | /// |
||
7658 | /// \param C AST context. |
||
7659 | /// \param StartLoc Starting location of the clause. |
||
7660 | /// \param LParenLoc Location of '('. |
||
7661 | /// \param EndLoc Ending location of the clause. |
||
7662 | /// \param VL List of references to the variables. |
||
7663 | static OMPNontemporalClause * |
||
7664 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
7665 | SourceLocation EndLoc, ArrayRef<Expr *> VL); |
||
7666 | |||
7667 | /// Creates an empty clause with the place for \a N variables. |
||
7668 | /// |
||
7669 | /// \param C AST context. |
||
7670 | /// \param N The number of variables. |
||
7671 | static OMPNontemporalClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
7672 | |||
7673 | /// Sets the list of references to private copies created in private clauses. |
||
7674 | /// \param VL List of references. |
||
7675 | void setPrivateRefs(ArrayRef<Expr *> VL); |
||
7676 | |||
7677 | child_range children() { |
||
7678 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
7679 | reinterpret_cast<Stmt **>(varlist_end())); |
||
7680 | } |
||
7681 | |||
7682 | const_child_range children() const { |
||
7683 | auto Children = const_cast<OMPNontemporalClause *>(this)->children(); |
||
7684 | return const_child_range(Children.begin(), Children.end()); |
||
7685 | } |
||
7686 | |||
7687 | child_range private_refs() { |
||
7688 | return child_range(reinterpret_cast<Stmt **>(getPrivateRefs().begin()), |
||
7689 | reinterpret_cast<Stmt **>(getPrivateRefs().end())); |
||
7690 | } |
||
7691 | |||
7692 | const_child_range private_refs() const { |
||
7693 | auto Children = const_cast<OMPNontemporalClause *>(this)->private_refs(); |
||
7694 | return const_child_range(Children.begin(), Children.end()); |
||
7695 | } |
||
7696 | |||
7697 | child_range used_children() { |
||
7698 | return child_range(child_iterator(), child_iterator()); |
||
7699 | } |
||
7700 | const_child_range used_children() const { |
||
7701 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7702 | } |
||
7703 | |||
7704 | static bool classof(const OMPClause *T) { |
||
7705 | return T->getClauseKind() == llvm::omp::OMPC_nontemporal; |
||
7706 | } |
||
7707 | }; |
||
7708 | |||
7709 | /// This represents 'order' clause in the '#pragma omp ...' directive. |
||
7710 | /// |
||
7711 | /// \code |
||
7712 | /// #pragma omp simd order(concurrent) |
||
7713 | /// \endcode |
||
7714 | /// In this example directive '#pragma omp parallel' has simple 'order' |
||
7715 | /// clause with kind 'concurrent'. |
||
7716 | class OMPOrderClause final : public OMPClause { |
||
7717 | friend class OMPClauseReader; |
||
7718 | |||
7719 | /// Location of '('. |
||
7720 | SourceLocation LParenLoc; |
||
7721 | |||
7722 | /// A kind of the 'order' clause. |
||
7723 | OpenMPOrderClauseKind Kind = OMPC_ORDER_unknown; |
||
7724 | |||
7725 | /// Start location of the kind in source code. |
||
7726 | SourceLocation KindKwLoc; |
||
7727 | |||
7728 | /// A modifier for order clause |
||
7729 | OpenMPOrderClauseModifier Modifier = OMPC_ORDER_MODIFIER_unknown; |
||
7730 | |||
7731 | /// Start location of the modifier in source code. |
||
7732 | SourceLocation ModifierKwLoc; |
||
7733 | |||
7734 | /// Set kind of the clause. |
||
7735 | /// |
||
7736 | /// \param K Argument of clause. |
||
7737 | void setKind(OpenMPOrderClauseKind K) { Kind = K; } |
||
7738 | |||
7739 | /// Set argument location. |
||
7740 | /// |
||
7741 | /// \param KLoc Argument location. |
||
7742 | void setKindKwLoc(SourceLocation KLoc) { KindKwLoc = KLoc; } |
||
7743 | |||
7744 | /// Set modifier of the clause. |
||
7745 | /// |
||
7746 | /// \param M Argument of clause. |
||
7747 | void setModifier(OpenMPOrderClauseModifier M) { Modifier = M; } |
||
7748 | |||
7749 | /// Set modifier location. |
||
7750 | /// |
||
7751 | /// \param MLoc Modifier keyword location. |
||
7752 | void setModifierKwLoc(SourceLocation MLoc) { ModifierKwLoc = MLoc; } |
||
7753 | |||
7754 | public: |
||
7755 | /// Build 'order' clause with argument \p A ('concurrent'). |
||
7756 | /// |
||
7757 | /// \param A Argument of the clause ('concurrent'). |
||
7758 | /// \param ALoc Starting location of the argument. |
||
7759 | /// \param StartLoc Starting location of the clause. |
||
7760 | /// \param LParenLoc Location of '('. |
||
7761 | /// \param EndLoc Ending location of the clause. |
||
7762 | /// \param Modifier The modifier applied to 'order' clause. |
||
7763 | /// \param MLoc Location of the modifier |
||
7764 | OMPOrderClause(OpenMPOrderClauseKind A, SourceLocation ALoc, |
||
7765 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
7766 | SourceLocation EndLoc, OpenMPOrderClauseModifier M, |
||
7767 | SourceLocation MLoc) |
||
7768 | : OMPClause(llvm::omp::OMPC_order, StartLoc, EndLoc), |
||
7769 | LParenLoc(LParenLoc), Kind(A), KindKwLoc(ALoc), Modifier(M), |
||
7770 | ModifierKwLoc(MLoc) {} |
||
7771 | |||
7772 | /// Build an empty clause. |
||
7773 | OMPOrderClause() |
||
7774 | : OMPClause(llvm::omp::OMPC_order, SourceLocation(), SourceLocation()) {} |
||
7775 | |||
7776 | /// Sets the location of '('. |
||
7777 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
7778 | |||
7779 | /// Returns the location of '('. |
||
7780 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
7781 | |||
7782 | /// Returns kind of the clause. |
||
7783 | OpenMPOrderClauseKind getKind() const { return Kind; } |
||
7784 | |||
7785 | /// Returns location of clause kind. |
||
7786 | SourceLocation getKindKwLoc() const { return KindKwLoc; } |
||
7787 | |||
7788 | /// Returns Modifier of the clause. |
||
7789 | OpenMPOrderClauseModifier getModifier() const { return Modifier; } |
||
7790 | |||
7791 | /// Returns location of clause modifier. |
||
7792 | SourceLocation getModifierKwLoc() const { return ModifierKwLoc; } |
||
7793 | |||
7794 | child_range children() { |
||
7795 | return child_range(child_iterator(), child_iterator()); |
||
7796 | } |
||
7797 | |||
7798 | const_child_range children() const { |
||
7799 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7800 | } |
||
7801 | |||
7802 | child_range used_children() { |
||
7803 | return child_range(child_iterator(), child_iterator()); |
||
7804 | } |
||
7805 | const_child_range used_children() const { |
||
7806 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7807 | } |
||
7808 | |||
7809 | static bool classof(const OMPClause *T) { |
||
7810 | return T->getClauseKind() == llvm::omp::OMPC_order; |
||
7811 | } |
||
7812 | }; |
||
7813 | |||
7814 | /// This represents the 'init' clause in '#pragma omp ...' directives. |
||
7815 | /// |
||
7816 | /// \code |
||
7817 | /// #pragma omp interop init(target:obj) |
||
7818 | /// \endcode |
||
7819 | class OMPInitClause final |
||
7820 | : public OMPVarListClause<OMPInitClause>, |
||
7821 | private llvm::TrailingObjects<OMPInitClause, Expr *> { |
||
7822 | friend class OMPClauseReader; |
||
7823 | friend OMPVarListClause; |
||
7824 | friend TrailingObjects; |
||
7825 | |||
7826 | /// Location of interop variable. |
||
7827 | SourceLocation VarLoc; |
||
7828 | |||
7829 | bool IsTarget = false; |
||
7830 | bool IsTargetSync = false; |
||
7831 | |||
7832 | void setInteropVar(Expr *E) { varlist_begin()[0] = E; } |
||
7833 | |||
7834 | void setIsTarget(bool V) { IsTarget = V; } |
||
7835 | |||
7836 | void setIsTargetSync(bool V) { IsTargetSync = V; } |
||
7837 | |||
7838 | /// Sets the location of the interop variable. |
||
7839 | void setVarLoc(SourceLocation Loc) { VarLoc = Loc; } |
||
7840 | |||
7841 | /// Build 'init' clause. |
||
7842 | /// |
||
7843 | /// \param IsTarget Uses the 'target' interop-type. |
||
7844 | /// \param IsTargetSync Uses the 'targetsync' interop-type. |
||
7845 | /// \param StartLoc Starting location of the clause. |
||
7846 | /// \param LParenLoc Location of '('. |
||
7847 | /// \param VarLoc Location of the interop variable. |
||
7848 | /// \param EndLoc Ending location of the clause. |
||
7849 | /// \param N Number of expressions. |
||
7850 | OMPInitClause(bool IsTarget, bool IsTargetSync, SourceLocation StartLoc, |
||
7851 | SourceLocation LParenLoc, SourceLocation VarLoc, |
||
7852 | SourceLocation EndLoc, unsigned N) |
||
7853 | : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, StartLoc, |
||
7854 | LParenLoc, EndLoc, N), |
||
7855 | VarLoc(VarLoc), IsTarget(IsTarget), IsTargetSync(IsTargetSync) {} |
||
7856 | |||
7857 | /// Build an empty clause. |
||
7858 | OMPInitClause(unsigned N) |
||
7859 | : OMPVarListClause<OMPInitClause>(llvm::omp::OMPC_init, SourceLocation(), |
||
7860 | SourceLocation(), SourceLocation(), N) { |
||
7861 | } |
||
7862 | |||
7863 | public: |
||
7864 | /// Creates a fully specified clause. |
||
7865 | /// |
||
7866 | /// \param C AST context. |
||
7867 | /// \param InteropVar The interop variable. |
||
7868 | /// \param InteropInfo The interop-type and prefer_type list. |
||
7869 | /// \param StartLoc Starting location of the clause. |
||
7870 | /// \param LParenLoc Location of '('. |
||
7871 | /// \param VarLoc Location of the interop variable. |
||
7872 | /// \param EndLoc Ending location of the clause. |
||
7873 | static OMPInitClause *Create(const ASTContext &C, Expr *InteropVar, |
||
7874 | OMPInteropInfo &InteropInfo, |
||
7875 | SourceLocation StartLoc, |
||
7876 | SourceLocation LParenLoc, SourceLocation VarLoc, |
||
7877 | SourceLocation EndLoc); |
||
7878 | |||
7879 | /// Creates an empty clause with \a N expressions. |
||
7880 | /// |
||
7881 | /// \param C AST context. |
||
7882 | /// \param N Number of expression items. |
||
7883 | static OMPInitClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
7884 | |||
7885 | /// Returns the location of the interop variable. |
||
7886 | SourceLocation getVarLoc() const { return VarLoc; } |
||
7887 | |||
7888 | /// Returns the interop variable. |
||
7889 | Expr *getInteropVar() { return varlist_begin()[0]; } |
||
7890 | const Expr *getInteropVar() const { return varlist_begin()[0]; } |
||
7891 | |||
7892 | /// Returns true is interop-type 'target' is used. |
||
7893 | bool getIsTarget() const { return IsTarget; } |
||
7894 | |||
7895 | /// Returns true is interop-type 'targetsync' is used. |
||
7896 | bool getIsTargetSync() const { return IsTargetSync; } |
||
7897 | |||
7898 | child_range children() { |
||
7899 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
7900 | reinterpret_cast<Stmt **>(varlist_end())); |
||
7901 | } |
||
7902 | |||
7903 | const_child_range children() const { |
||
7904 | auto Children = const_cast<OMPInitClause *>(this)->children(); |
||
7905 | return const_child_range(Children.begin(), Children.end()); |
||
7906 | } |
||
7907 | |||
7908 | child_range used_children() { |
||
7909 | return child_range(child_iterator(), child_iterator()); |
||
7910 | } |
||
7911 | const_child_range used_children() const { |
||
7912 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7913 | } |
||
7914 | |||
7915 | using prefs_iterator = MutableArrayRef<Expr *>::iterator; |
||
7916 | using const_prefs_iterator = ArrayRef<const Expr *>::iterator; |
||
7917 | using prefs_range = llvm::iterator_range<prefs_iterator>; |
||
7918 | using const_prefs_range = llvm::iterator_range<const_prefs_iterator>; |
||
7919 | |||
7920 | prefs_range prefs() { |
||
7921 | return prefs_range(reinterpret_cast<Expr **>(std::next(varlist_begin())), |
||
7922 | reinterpret_cast<Expr **>(varlist_end())); |
||
7923 | } |
||
7924 | |||
7925 | const_prefs_range prefs() const { |
||
7926 | auto Prefs = const_cast<OMPInitClause *>(this)->prefs(); |
||
7927 | return const_prefs_range(Prefs.begin(), Prefs.end()); |
||
7928 | } |
||
7929 | |||
7930 | static bool classof(const OMPClause *T) { |
||
7931 | return T->getClauseKind() == llvm::omp::OMPC_init; |
||
7932 | } |
||
7933 | }; |
||
7934 | |||
7935 | /// This represents the 'use' clause in '#pragma omp ...' directives. |
||
7936 | /// |
||
7937 | /// \code |
||
7938 | /// #pragma omp interop use(obj) |
||
7939 | /// \endcode |
||
7940 | class OMPUseClause final : public OMPClause { |
||
7941 | friend class OMPClauseReader; |
||
7942 | |||
7943 | /// Location of '('. |
||
7944 | SourceLocation LParenLoc; |
||
7945 | |||
7946 | /// Location of interop variable. |
||
7947 | SourceLocation VarLoc; |
||
7948 | |||
7949 | /// The interop variable. |
||
7950 | Stmt *InteropVar = nullptr; |
||
7951 | |||
7952 | /// Set the interop variable. |
||
7953 | void setInteropVar(Expr *E) { InteropVar = E; } |
||
7954 | |||
7955 | /// Sets the location of '('. |
||
7956 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
7957 | |||
7958 | /// Sets the location of the interop variable. |
||
7959 | void setVarLoc(SourceLocation Loc) { VarLoc = Loc; } |
||
7960 | |||
7961 | public: |
||
7962 | /// Build 'use' clause with and interop variable expression \a InteropVar. |
||
7963 | /// |
||
7964 | /// \param InteropVar The interop variable. |
||
7965 | /// \param StartLoc Starting location of the clause. |
||
7966 | /// \param LParenLoc Location of '('. |
||
7967 | /// \param VarLoc Location of the interop variable. |
||
7968 | /// \param EndLoc Ending location of the clause. |
||
7969 | OMPUseClause(Expr *InteropVar, SourceLocation StartLoc, |
||
7970 | SourceLocation LParenLoc, SourceLocation VarLoc, |
||
7971 | SourceLocation EndLoc) |
||
7972 | : OMPClause(llvm::omp::OMPC_use, StartLoc, EndLoc), LParenLoc(LParenLoc), |
||
7973 | VarLoc(VarLoc), InteropVar(InteropVar) {} |
||
7974 | |||
7975 | /// Build an empty clause. |
||
7976 | OMPUseClause() |
||
7977 | : OMPClause(llvm::omp::OMPC_use, SourceLocation(), SourceLocation()) {} |
||
7978 | |||
7979 | /// Returns the location of '('. |
||
7980 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
7981 | |||
7982 | /// Returns the location of the interop variable. |
||
7983 | SourceLocation getVarLoc() const { return VarLoc; } |
||
7984 | |||
7985 | /// Returns the interop variable. |
||
7986 | Expr *getInteropVar() const { return cast<Expr>(InteropVar); } |
||
7987 | |||
7988 | child_range children() { return child_range(&InteropVar, &InteropVar + 1); } |
||
7989 | |||
7990 | const_child_range children() const { |
||
7991 | return const_child_range(&InteropVar, &InteropVar + 1); |
||
7992 | } |
||
7993 | |||
7994 | child_range used_children() { |
||
7995 | return child_range(child_iterator(), child_iterator()); |
||
7996 | } |
||
7997 | const_child_range used_children() const { |
||
7998 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
7999 | } |
||
8000 | |||
8001 | static bool classof(const OMPClause *T) { |
||
8002 | return T->getClauseKind() == llvm::omp::OMPC_use; |
||
8003 | } |
||
8004 | }; |
||
8005 | |||
8006 | /// This represents 'destroy' clause in the '#pragma omp depobj' |
||
8007 | /// directive or the '#pragma omp interop' directive.. |
||
8008 | /// |
||
8009 | /// \code |
||
8010 | /// #pragma omp depobj(a) destroy |
||
8011 | /// #pragma omp interop destroy(obj) |
||
8012 | /// \endcode |
||
8013 | /// In these examples directive '#pragma omp depobj' and '#pragma omp interop' |
||
8014 | /// have a 'destroy' clause. The 'interop' directive includes an object. |
||
8015 | class OMPDestroyClause final : public OMPClause { |
||
8016 | friend class OMPClauseReader; |
||
8017 | |||
8018 | /// Location of '('. |
||
8019 | SourceLocation LParenLoc; |
||
8020 | |||
8021 | /// Location of interop variable. |
||
8022 | SourceLocation VarLoc; |
||
8023 | |||
8024 | /// The interop variable. |
||
8025 | Stmt *InteropVar = nullptr; |
||
8026 | |||
8027 | /// Set the interop variable. |
||
8028 | void setInteropVar(Expr *E) { InteropVar = E; } |
||
8029 | |||
8030 | /// Sets the location of '('. |
||
8031 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
8032 | |||
8033 | /// Sets the location of the interop variable. |
||
8034 | void setVarLoc(SourceLocation Loc) { VarLoc = Loc; } |
||
8035 | |||
8036 | public: |
||
8037 | /// Build 'destroy' clause with an interop variable expression \a InteropVar. |
||
8038 | /// |
||
8039 | /// \param InteropVar The interop variable. |
||
8040 | /// \param StartLoc Starting location of the clause. |
||
8041 | /// \param LParenLoc Location of '('. |
||
8042 | /// \param VarLoc Location of the interop variable. |
||
8043 | /// \param EndLoc Ending location of the clause. |
||
8044 | OMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, |
||
8045 | SourceLocation LParenLoc, SourceLocation VarLoc, |
||
8046 | SourceLocation EndLoc) |
||
8047 | : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc), |
||
8048 | LParenLoc(LParenLoc), VarLoc(VarLoc), InteropVar(InteropVar) {} |
||
8049 | |||
8050 | /// Build 'destroy' clause. |
||
8051 | /// |
||
8052 | /// \param StartLoc Starting location of the clause. |
||
8053 | /// \param EndLoc Ending location of the clause. |
||
8054 | OMPDestroyClause(SourceLocation StartLoc, SourceLocation EndLoc) |
||
8055 | : OMPClause(llvm::omp::OMPC_destroy, StartLoc, EndLoc) {} |
||
8056 | |||
8057 | /// Build an empty clause. |
||
8058 | OMPDestroyClause() |
||
8059 | : OMPClause(llvm::omp::OMPC_destroy, SourceLocation(), SourceLocation()) { |
||
8060 | } |
||
8061 | |||
8062 | /// Returns the location of '('. |
||
8063 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
8064 | |||
8065 | /// Returns the location of the interop variable. |
||
8066 | SourceLocation getVarLoc() const { return VarLoc; } |
||
8067 | |||
8068 | /// Returns the interop variable. |
||
8069 | Expr *getInteropVar() const { return cast_or_null<Expr>(InteropVar); } |
||
8070 | |||
8071 | child_range children() { |
||
8072 | if (InteropVar) |
||
8073 | return child_range(&InteropVar, &InteropVar + 1); |
||
8074 | return child_range(child_iterator(), child_iterator()); |
||
8075 | } |
||
8076 | |||
8077 | const_child_range children() const { |
||
8078 | if (InteropVar) |
||
8079 | return const_child_range(&InteropVar, &InteropVar + 1); |
||
8080 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
8081 | } |
||
8082 | |||
8083 | child_range used_children() { |
||
8084 | return child_range(child_iterator(), child_iterator()); |
||
8085 | } |
||
8086 | const_child_range used_children() const { |
||
8087 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
8088 | } |
||
8089 | |||
8090 | static bool classof(const OMPClause *T) { |
||
8091 | return T->getClauseKind() == llvm::omp::OMPC_destroy; |
||
8092 | } |
||
8093 | }; |
||
8094 | |||
8095 | /// This represents 'novariants' clause in the '#pragma omp ...' directive. |
||
8096 | /// |
||
8097 | /// \code |
||
8098 | /// #pragma omp dispatch novariants(a > 5) |
||
8099 | /// \endcode |
||
8100 | /// In this example directive '#pragma omp dispatch' has simple 'novariants' |
||
8101 | /// clause with condition 'a > 5'. |
||
8102 | class OMPNovariantsClause final |
||
8103 | : public OMPOneStmtClause<llvm::omp::OMPC_novariants, OMPClause>, |
||
8104 | public OMPClauseWithPreInit { |
||
8105 | friend class OMPClauseReader; |
||
8106 | |||
8107 | /// Set condition. |
||
8108 | void setCondition(Expr *Cond) { setStmt(Cond); } |
||
8109 | |||
8110 | public: |
||
8111 | /// Build 'novariants' clause with condition \a Cond. |
||
8112 | /// |
||
8113 | /// \param Cond Condition of the clause. |
||
8114 | /// \param HelperCond Helper condition for the construct. |
||
8115 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
8116 | /// clause must be captured. |
||
8117 | /// \param StartLoc Starting location of the clause. |
||
8118 | /// \param LParenLoc Location of '('. |
||
8119 | /// \param EndLoc Ending location of the clause. |
||
8120 | OMPNovariantsClause(Expr *Cond, Stmt *HelperCond, |
||
8121 | OpenMPDirectiveKind CaptureRegion, |
||
8122 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8123 | SourceLocation EndLoc) |
||
8124 | : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc), |
||
8125 | OMPClauseWithPreInit(this) { |
||
8126 | setPreInitStmt(HelperCond, CaptureRegion); |
||
8127 | } |
||
8128 | |||
8129 | /// Build an empty clause. |
||
8130 | OMPNovariantsClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {} |
||
8131 | |||
8132 | /// Returns condition. |
||
8133 | Expr *getCondition() const { return getStmtAs<Expr>(); } |
||
8134 | |||
8135 | child_range used_children(); |
||
8136 | const_child_range used_children() const { |
||
8137 | auto Children = const_cast<OMPNovariantsClause *>(this)->used_children(); |
||
8138 | return const_child_range(Children.begin(), Children.end()); |
||
8139 | } |
||
8140 | }; |
||
8141 | |||
8142 | /// This represents 'nocontext' clause in the '#pragma omp ...' directive. |
||
8143 | /// |
||
8144 | /// \code |
||
8145 | /// #pragma omp dispatch nocontext(a > 5) |
||
8146 | /// \endcode |
||
8147 | /// In this example directive '#pragma omp dispatch' has simple 'nocontext' |
||
8148 | /// clause with condition 'a > 5'. |
||
8149 | class OMPNocontextClause final |
||
8150 | : public OMPOneStmtClause<llvm::omp::OMPC_nocontext, OMPClause>, |
||
8151 | public OMPClauseWithPreInit { |
||
8152 | friend class OMPClauseReader; |
||
8153 | |||
8154 | /// Set condition. |
||
8155 | void setCondition(Expr *Cond) { setStmt(Cond); } |
||
8156 | |||
8157 | public: |
||
8158 | /// Build 'nocontext' clause with condition \a Cond. |
||
8159 | /// |
||
8160 | /// \param Cond Condition of the clause. |
||
8161 | /// \param HelperCond Helper condition for the construct. |
||
8162 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
8163 | /// clause must be captured. |
||
8164 | /// \param StartLoc Starting location of the clause. |
||
8165 | /// \param LParenLoc Location of '('. |
||
8166 | /// \param EndLoc Ending location of the clause. |
||
8167 | OMPNocontextClause(Expr *Cond, Stmt *HelperCond, |
||
8168 | OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, |
||
8169 | SourceLocation LParenLoc, SourceLocation EndLoc) |
||
8170 | : OMPOneStmtClause(Cond, StartLoc, LParenLoc, EndLoc), |
||
8171 | OMPClauseWithPreInit(this) { |
||
8172 | setPreInitStmt(HelperCond, CaptureRegion); |
||
8173 | } |
||
8174 | |||
8175 | /// Build an empty clause. |
||
8176 | OMPNocontextClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {} |
||
8177 | |||
8178 | /// Returns condition. |
||
8179 | Expr *getCondition() const { return getStmtAs<Expr>(); } |
||
8180 | |||
8181 | child_range used_children(); |
||
8182 | const_child_range used_children() const { |
||
8183 | auto Children = const_cast<OMPNocontextClause *>(this)->used_children(); |
||
8184 | return const_child_range(Children.begin(), Children.end()); |
||
8185 | } |
||
8186 | }; |
||
8187 | |||
8188 | /// This represents 'detach' clause in the '#pragma omp task' directive. |
||
8189 | /// |
||
8190 | /// \code |
||
8191 | /// #pragma omp task detach(evt) |
||
8192 | /// \endcode |
||
8193 | /// In this example directive '#pragma omp detach' has simple 'detach' clause |
||
8194 | /// with the variable 'evt'. |
||
8195 | class OMPDetachClause final |
||
8196 | : public OMPOneStmtClause<llvm::omp::OMPC_detach, OMPClause> { |
||
8197 | friend class OMPClauseReader; |
||
8198 | |||
8199 | /// Set condition. |
||
8200 | void setEventHandler(Expr *E) { setStmt(E); } |
||
8201 | |||
8202 | public: |
||
8203 | /// Build 'detach' clause with event-handler \a Evt. |
||
8204 | /// |
||
8205 | /// \param Evt Event handler expression. |
||
8206 | /// \param StartLoc Starting location of the clause. |
||
8207 | /// \param LParenLoc Location of '('. |
||
8208 | /// \param EndLoc Ending location of the clause. |
||
8209 | OMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8210 | SourceLocation EndLoc) |
||
8211 | : OMPOneStmtClause(Evt, StartLoc, LParenLoc, EndLoc) {} |
||
8212 | |||
8213 | /// Build an empty clause. |
||
8214 | OMPDetachClause() : OMPOneStmtClause() {} |
||
8215 | |||
8216 | /// Returns event-handler expression. |
||
8217 | Expr *getEventHandler() const { return getStmtAs<Expr>(); } |
||
8218 | }; |
||
8219 | |||
8220 | /// This represents clause 'inclusive' in the '#pragma omp scan' directive. |
||
8221 | /// |
||
8222 | /// \code |
||
8223 | /// #pragma omp scan inclusive(a,b) |
||
8224 | /// \endcode |
||
8225 | /// In this example directive '#pragma omp scan' has clause 'inclusive' |
||
8226 | /// with the variables 'a' and 'b'. |
||
8227 | class OMPInclusiveClause final |
||
8228 | : public OMPVarListClause<OMPInclusiveClause>, |
||
8229 | private llvm::TrailingObjects<OMPInclusiveClause, Expr *> { |
||
8230 | friend class OMPClauseReader; |
||
8231 | friend OMPVarListClause; |
||
8232 | friend TrailingObjects; |
||
8233 | |||
8234 | /// Build clause with number of variables \a N. |
||
8235 | /// |
||
8236 | /// \param StartLoc Starting location of the clause. |
||
8237 | /// \param LParenLoc Location of '('. |
||
8238 | /// \param EndLoc Ending location of the clause. |
||
8239 | /// \param N Number of the variables in the clause. |
||
8240 | OMPInclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8241 | SourceLocation EndLoc, unsigned N) |
||
8242 | : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive, |
||
8243 | StartLoc, LParenLoc, EndLoc, N) {} |
||
8244 | |||
8245 | /// Build an empty clause. |
||
8246 | /// |
||
8247 | /// \param N Number of variables. |
||
8248 | explicit OMPInclusiveClause(unsigned N) |
||
8249 | : OMPVarListClause<OMPInclusiveClause>(llvm::omp::OMPC_inclusive, |
||
8250 | SourceLocation(), SourceLocation(), |
||
8251 | SourceLocation(), N) {} |
||
8252 | |||
8253 | public: |
||
8254 | /// Creates clause with a list of variables \a VL. |
||
8255 | /// |
||
8256 | /// \param C AST context. |
||
8257 | /// \param StartLoc Starting location of the clause. |
||
8258 | /// \param LParenLoc Location of '('. |
||
8259 | /// \param EndLoc Ending location of the clause. |
||
8260 | /// \param VL List of references to the original variables. |
||
8261 | static OMPInclusiveClause *Create(const ASTContext &C, |
||
8262 | SourceLocation StartLoc, |
||
8263 | SourceLocation LParenLoc, |
||
8264 | SourceLocation EndLoc, ArrayRef<Expr *> VL); |
||
8265 | |||
8266 | /// Creates an empty clause with the place for \a N variables. |
||
8267 | /// |
||
8268 | /// \param C AST context. |
||
8269 | /// \param N The number of variables. |
||
8270 | static OMPInclusiveClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
8271 | |||
8272 | child_range children() { |
||
8273 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
8274 | reinterpret_cast<Stmt **>(varlist_end())); |
||
8275 | } |
||
8276 | |||
8277 | const_child_range children() const { |
||
8278 | auto Children = const_cast<OMPInclusiveClause *>(this)->children(); |
||
8279 | return const_child_range(Children.begin(), Children.end()); |
||
8280 | } |
||
8281 | |||
8282 | child_range used_children() { |
||
8283 | return child_range(child_iterator(), child_iterator()); |
||
8284 | } |
||
8285 | const_child_range used_children() const { |
||
8286 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
8287 | } |
||
8288 | |||
8289 | static bool classof(const OMPClause *T) { |
||
8290 | return T->getClauseKind() == llvm::omp::OMPC_inclusive; |
||
8291 | } |
||
8292 | }; |
||
8293 | |||
8294 | /// This represents clause 'exclusive' in the '#pragma omp scan' directive. |
||
8295 | /// |
||
8296 | /// \code |
||
8297 | /// #pragma omp scan exclusive(a,b) |
||
8298 | /// \endcode |
||
8299 | /// In this example directive '#pragma omp scan' has clause 'exclusive' |
||
8300 | /// with the variables 'a' and 'b'. |
||
8301 | class OMPExclusiveClause final |
||
8302 | : public OMPVarListClause<OMPExclusiveClause>, |
||
8303 | private llvm::TrailingObjects<OMPExclusiveClause, Expr *> { |
||
8304 | friend class OMPClauseReader; |
||
8305 | friend OMPVarListClause; |
||
8306 | friend TrailingObjects; |
||
8307 | |||
8308 | /// Build clause with number of variables \a N. |
||
8309 | /// |
||
8310 | /// \param StartLoc Starting location of the clause. |
||
8311 | /// \param LParenLoc Location of '('. |
||
8312 | /// \param EndLoc Ending location of the clause. |
||
8313 | /// \param N Number of the variables in the clause. |
||
8314 | OMPExclusiveClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8315 | SourceLocation EndLoc, unsigned N) |
||
8316 | : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive, |
||
8317 | StartLoc, LParenLoc, EndLoc, N) {} |
||
8318 | |||
8319 | /// Build an empty clause. |
||
8320 | /// |
||
8321 | /// \param N Number of variables. |
||
8322 | explicit OMPExclusiveClause(unsigned N) |
||
8323 | : OMPVarListClause<OMPExclusiveClause>(llvm::omp::OMPC_exclusive, |
||
8324 | SourceLocation(), SourceLocation(), |
||
8325 | SourceLocation(), N) {} |
||
8326 | |||
8327 | public: |
||
8328 | /// Creates clause with a list of variables \a VL. |
||
8329 | /// |
||
8330 | /// \param C AST context. |
||
8331 | /// \param StartLoc Starting location of the clause. |
||
8332 | /// \param LParenLoc Location of '('. |
||
8333 | /// \param EndLoc Ending location of the clause. |
||
8334 | /// \param VL List of references to the original variables. |
||
8335 | static OMPExclusiveClause *Create(const ASTContext &C, |
||
8336 | SourceLocation StartLoc, |
||
8337 | SourceLocation LParenLoc, |
||
8338 | SourceLocation EndLoc, ArrayRef<Expr *> VL); |
||
8339 | |||
8340 | /// Creates an empty clause with the place for \a N variables. |
||
8341 | /// |
||
8342 | /// \param C AST context. |
||
8343 | /// \param N The number of variables. |
||
8344 | static OMPExclusiveClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
8345 | |||
8346 | child_range children() { |
||
8347 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
8348 | reinterpret_cast<Stmt **>(varlist_end())); |
||
8349 | } |
||
8350 | |||
8351 | const_child_range children() const { |
||
8352 | auto Children = const_cast<OMPExclusiveClause *>(this)->children(); |
||
8353 | return const_child_range(Children.begin(), Children.end()); |
||
8354 | } |
||
8355 | |||
8356 | child_range used_children() { |
||
8357 | return child_range(child_iterator(), child_iterator()); |
||
8358 | } |
||
8359 | const_child_range used_children() const { |
||
8360 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
8361 | } |
||
8362 | |||
8363 | static bool classof(const OMPClause *T) { |
||
8364 | return T->getClauseKind() == llvm::omp::OMPC_exclusive; |
||
8365 | } |
||
8366 | }; |
||
8367 | |||
8368 | /// This represents clause 'uses_allocators' in the '#pragma omp target'-based |
||
8369 | /// directives. |
||
8370 | /// |
||
8371 | /// \code |
||
8372 | /// #pragma omp target uses_allocators(default_allocator, my_allocator(traits)) |
||
8373 | /// \endcode |
||
8374 | /// In this example directive '#pragma omp target' has clause 'uses_allocators' |
||
8375 | /// with the allocators 'default_allocator' and user-defined 'my_allocator'. |
||
8376 | class OMPUsesAllocatorsClause final |
||
8377 | : public OMPClause, |
||
8378 | private llvm::TrailingObjects<OMPUsesAllocatorsClause, Expr *, |
||
8379 | SourceLocation> { |
||
8380 | public: |
||
8381 | /// Data for list of allocators. |
||
8382 | struct Data { |
||
8383 | /// Allocator. |
||
8384 | Expr *Allocator = nullptr; |
||
8385 | /// Allocator traits. |
||
8386 | Expr *AllocatorTraits = nullptr; |
||
8387 | /// Locations of '(' and ')' symbols. |
||
8388 | SourceLocation LParenLoc, RParenLoc; |
||
8389 | }; |
||
8390 | |||
8391 | private: |
||
8392 | friend class OMPClauseReader; |
||
8393 | friend TrailingObjects; |
||
8394 | |||
8395 | enum class ExprOffsets { |
||
8396 | Allocator, |
||
8397 | AllocatorTraits, |
||
8398 | Total, |
||
8399 | }; |
||
8400 | |||
8401 | enum class ParenLocsOffsets { |
||
8402 | LParen, |
||
8403 | RParen, |
||
8404 | Total, |
||
8405 | }; |
||
8406 | |||
8407 | /// Location of '('. |
||
8408 | SourceLocation LParenLoc; |
||
8409 | /// Total number of allocators in the clause. |
||
8410 | unsigned NumOfAllocators = 0; |
||
8411 | |||
8412 | /// Build clause. |
||
8413 | /// |
||
8414 | /// \param StartLoc Starting location of the clause. |
||
8415 | /// \param LParenLoc Location of '('. |
||
8416 | /// \param EndLoc Ending location of the clause. |
||
8417 | /// \param N Number of allocators associated with the clause. |
||
8418 | OMPUsesAllocatorsClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8419 | SourceLocation EndLoc, unsigned N) |
||
8420 | : OMPClause(llvm::omp::OMPC_uses_allocators, StartLoc, EndLoc), |
||
8421 | LParenLoc(LParenLoc), NumOfAllocators(N) {} |
||
8422 | |||
8423 | /// Build an empty clause. |
||
8424 | /// \param N Number of allocators associated with the clause. |
||
8425 | /// |
||
8426 | explicit OMPUsesAllocatorsClause(unsigned N) |
||
8427 | : OMPClause(llvm::omp::OMPC_uses_allocators, SourceLocation(), |
||
8428 | SourceLocation()), |
||
8429 | NumOfAllocators(N) {} |
||
8430 | |||
8431 | unsigned numTrailingObjects(OverloadToken<Expr *>) const { |
||
8432 | return NumOfAllocators * static_cast<int>(ExprOffsets::Total); |
||
8433 | } |
||
8434 | |||
8435 | /// Sets the location of '('. |
||
8436 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
8437 | |||
8438 | /// Sets the allocators data for the clause. |
||
8439 | void setAllocatorsData(ArrayRef<OMPUsesAllocatorsClause::Data> Data); |
||
8440 | |||
8441 | public: |
||
8442 | /// Creates clause with a list of allocators \p Data. |
||
8443 | /// |
||
8444 | /// \param C AST context. |
||
8445 | /// \param StartLoc Starting location of the clause. |
||
8446 | /// \param LParenLoc Location of '('. |
||
8447 | /// \param EndLoc Ending location of the clause. |
||
8448 | /// \param Data List of allocators. |
||
8449 | static OMPUsesAllocatorsClause * |
||
8450 | Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8451 | SourceLocation EndLoc, ArrayRef<OMPUsesAllocatorsClause::Data> Data); |
||
8452 | |||
8453 | /// Creates an empty clause with the place for \p N allocators. |
||
8454 | /// |
||
8455 | /// \param C AST context. |
||
8456 | /// \param N The number of allocators. |
||
8457 | static OMPUsesAllocatorsClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
8458 | |||
8459 | /// Returns the location of '('. |
||
8460 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
8461 | |||
8462 | /// Returns number of allocators associated with the clause. |
||
8463 | unsigned getNumberOfAllocators() const { return NumOfAllocators; } |
||
8464 | |||
8465 | /// Returns data for the specified allocator. |
||
8466 | OMPUsesAllocatorsClause::Data getAllocatorData(unsigned I) const; |
||
8467 | |||
8468 | // Iterators |
||
8469 | child_range children() { |
||
8470 | Stmt **Begin = reinterpret_cast<Stmt **>(getTrailingObjects<Expr *>()); |
||
8471 | return child_range(Begin, Begin + NumOfAllocators * |
||
8472 | static_cast<int>(ExprOffsets::Total)); |
||
8473 | } |
||
8474 | const_child_range children() const { |
||
8475 | Stmt *const *Begin = |
||
8476 | reinterpret_cast<Stmt *const *>(getTrailingObjects<Expr *>()); |
||
8477 | return const_child_range( |
||
8478 | Begin, Begin + NumOfAllocators * static_cast<int>(ExprOffsets::Total)); |
||
8479 | } |
||
8480 | |||
8481 | child_range used_children() { |
||
8482 | return child_range(child_iterator(), child_iterator()); |
||
8483 | } |
||
8484 | const_child_range used_children() const { |
||
8485 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
8486 | } |
||
8487 | |||
8488 | static bool classof(const OMPClause *T) { |
||
8489 | return T->getClauseKind() == llvm::omp::OMPC_uses_allocators; |
||
8490 | } |
||
8491 | }; |
||
8492 | |||
8493 | /// This represents clause 'affinity' in the '#pragma omp task'-based |
||
8494 | /// directives. |
||
8495 | /// |
||
8496 | /// \code |
||
8497 | /// #pragma omp task affinity(iterator(i = 0:n) : ([3][n])a, b[:n], c[i]) |
||
8498 | /// \endcode |
||
8499 | /// In this example directive '#pragma omp task' has clause 'affinity' with the |
||
8500 | /// affinity modifer 'iterator(i = 0:n)' and locator items '([3][n])a', 'b[:n]' |
||
8501 | /// and 'c[i]'. |
||
8502 | class OMPAffinityClause final |
||
8503 | : public OMPVarListClause<OMPAffinityClause>, |
||
8504 | private llvm::TrailingObjects<OMPAffinityClause, Expr *> { |
||
8505 | friend class OMPClauseReader; |
||
8506 | friend OMPVarListClause; |
||
8507 | friend TrailingObjects; |
||
8508 | |||
8509 | /// Location of ':' symbol. |
||
8510 | SourceLocation ColonLoc; |
||
8511 | |||
8512 | /// Build clause. |
||
8513 | /// |
||
8514 | /// \param StartLoc Starting location of the clause. |
||
8515 | /// \param LParenLoc Location of '('. |
||
8516 | /// \param ColonLoc Location of ':'. |
||
8517 | /// \param EndLoc Ending location of the clause. |
||
8518 | /// \param N Number of locators associated with the clause. |
||
8519 | OMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8520 | SourceLocation ColonLoc, SourceLocation EndLoc, unsigned N) |
||
8521 | : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, StartLoc, |
||
8522 | LParenLoc, EndLoc, N) {} |
||
8523 | |||
8524 | /// Build an empty clause. |
||
8525 | /// \param N Number of locators associated with the clause. |
||
8526 | /// |
||
8527 | explicit OMPAffinityClause(unsigned N) |
||
8528 | : OMPVarListClause<OMPAffinityClause>(llvm::omp::OMPC_affinity, |
||
8529 | SourceLocation(), SourceLocation(), |
||
8530 | SourceLocation(), N) {} |
||
8531 | |||
8532 | /// Sets the affinity modifier for the clause, if any. |
||
8533 | void setModifier(Expr *E) { |
||
8534 | getTrailingObjects<Expr *>()[varlist_size()] = E; |
||
8535 | } |
||
8536 | |||
8537 | /// Sets the location of ':' symbol. |
||
8538 | void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; } |
||
8539 | |||
8540 | public: |
||
8541 | /// Creates clause with a modifier a list of locator items. |
||
8542 | /// |
||
8543 | /// \param C AST context. |
||
8544 | /// \param StartLoc Starting location of the clause. |
||
8545 | /// \param LParenLoc Location of '('. |
||
8546 | /// \param ColonLoc Location of ':'. |
||
8547 | /// \param EndLoc Ending location of the clause. |
||
8548 | /// \param Locators List of locator items. |
||
8549 | static OMPAffinityClause *Create(const ASTContext &C, SourceLocation StartLoc, |
||
8550 | SourceLocation LParenLoc, |
||
8551 | SourceLocation ColonLoc, |
||
8552 | SourceLocation EndLoc, Expr *Modifier, |
||
8553 | ArrayRef<Expr *> Locators); |
||
8554 | |||
8555 | /// Creates an empty clause with the place for \p N locator items. |
||
8556 | /// |
||
8557 | /// \param C AST context. |
||
8558 | /// \param N The number of locator items. |
||
8559 | static OMPAffinityClause *CreateEmpty(const ASTContext &C, unsigned N); |
||
8560 | |||
8561 | /// Gets affinity modifier. |
||
8562 | Expr *getModifier() { return getTrailingObjects<Expr *>()[varlist_size()]; } |
||
8563 | Expr *getModifier() const { |
||
8564 | return getTrailingObjects<Expr *>()[varlist_size()]; |
||
8565 | } |
||
8566 | |||
8567 | /// Gets the location of ':' symbol. |
||
8568 | SourceLocation getColonLoc() const { return ColonLoc; } |
||
8569 | |||
8570 | // Iterators |
||
8571 | child_range children() { |
||
8572 | int Offset = getModifier() ? 1 : 0; |
||
8573 | return child_range(reinterpret_cast<Stmt **>(varlist_begin()), |
||
8574 | reinterpret_cast<Stmt **>(varlist_end() + Offset)); |
||
8575 | } |
||
8576 | |||
8577 | const_child_range children() const { |
||
8578 | auto Children = const_cast<OMPAffinityClause *>(this)->children(); |
||
8579 | return const_child_range(Children.begin(), Children.end()); |
||
8580 | } |
||
8581 | |||
8582 | child_range used_children() { |
||
8583 | return child_range(child_iterator(), child_iterator()); |
||
8584 | } |
||
8585 | const_child_range used_children() const { |
||
8586 | return const_child_range(const_child_iterator(), const_child_iterator()); |
||
8587 | } |
||
8588 | |||
8589 | static bool classof(const OMPClause *T) { |
||
8590 | return T->getClauseKind() == llvm::omp::OMPC_affinity; |
||
8591 | } |
||
8592 | }; |
||
8593 | |||
8594 | /// This represents 'filter' clause in the '#pragma omp ...' directive. |
||
8595 | /// |
||
8596 | /// \code |
||
8597 | /// #pragma omp masked filter(tid) |
||
8598 | /// \endcode |
||
8599 | /// In this example directive '#pragma omp masked' has 'filter' clause with |
||
8600 | /// thread id. |
||
8601 | class OMPFilterClause final |
||
8602 | : public OMPOneStmtClause<llvm::omp::OMPC_filter, OMPClause>, |
||
8603 | public OMPClauseWithPreInit { |
||
8604 | friend class OMPClauseReader; |
||
8605 | |||
8606 | /// Sets the thread identifier. |
||
8607 | void setThreadID(Expr *TID) { setStmt(TID); } |
||
8608 | |||
8609 | public: |
||
8610 | /// Build 'filter' clause with thread-id \a ThreadID. |
||
8611 | /// |
||
8612 | /// \param ThreadID Thread identifier. |
||
8613 | /// \param HelperE Helper expression associated with this clause. |
||
8614 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
8615 | /// clause must be captured. |
||
8616 | /// \param StartLoc Starting location of the clause. |
||
8617 | /// \param LParenLoc Location of '('. |
||
8618 | /// \param EndLoc Ending location of the clause. |
||
8619 | OMPFilterClause(Expr *ThreadID, Stmt *HelperE, |
||
8620 | OpenMPDirectiveKind CaptureRegion, SourceLocation StartLoc, |
||
8621 | SourceLocation LParenLoc, SourceLocation EndLoc) |
||
8622 | : OMPOneStmtClause(ThreadID, StartLoc, LParenLoc, EndLoc), |
||
8623 | OMPClauseWithPreInit(this) { |
||
8624 | setPreInitStmt(HelperE, CaptureRegion); |
||
8625 | } |
||
8626 | |||
8627 | /// Build an empty clause. |
||
8628 | OMPFilterClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {} |
||
8629 | |||
8630 | /// Return thread identifier. |
||
8631 | Expr *getThreadID() const { return getStmtAs<Expr>(); } |
||
8632 | |||
8633 | /// Return thread identifier. |
||
8634 | Expr *getThreadID() { return getStmtAs<Expr>(); } |
||
8635 | }; |
||
8636 | |||
8637 | /// This represents 'bind' clause in the '#pragma omp ...' directives. |
||
8638 | /// |
||
8639 | /// \code |
||
8640 | /// #pragma omp loop bind(parallel) |
||
8641 | /// \endcode |
||
8642 | class OMPBindClause final : public OMPNoChildClause<llvm::omp::OMPC_bind> { |
||
8643 | friend class OMPClauseReader; |
||
8644 | |||
8645 | /// Location of '('. |
||
8646 | SourceLocation LParenLoc; |
||
8647 | |||
8648 | /// The binding kind of 'bind' clause. |
||
8649 | OpenMPBindClauseKind Kind = OMPC_BIND_unknown; |
||
8650 | |||
8651 | /// Start location of the kind in source code. |
||
8652 | SourceLocation KindLoc; |
||
8653 | |||
8654 | /// Sets the location of '('. |
||
8655 | void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; } |
||
8656 | |||
8657 | /// Set the binding kind. |
||
8658 | void setBindKind(OpenMPBindClauseKind K) { Kind = K; } |
||
8659 | |||
8660 | /// Set the binding kind location. |
||
8661 | void setBindKindLoc(SourceLocation KLoc) { KindLoc = KLoc; } |
||
8662 | |||
8663 | /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread'). |
||
8664 | /// |
||
8665 | /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread'). |
||
8666 | /// \param KLoc Starting location of the binding kind. |
||
8667 | /// \param StartLoc Starting location of the clause. |
||
8668 | /// \param LParenLoc Location of '('. |
||
8669 | /// \param EndLoc Ending location of the clause. |
||
8670 | OMPBindClause(OpenMPBindClauseKind K, SourceLocation KLoc, |
||
8671 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
8672 | SourceLocation EndLoc) |
||
8673 | : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Kind(K), |
||
8674 | KindLoc(KLoc) {} |
||
8675 | |||
8676 | /// Build an empty clause. |
||
8677 | OMPBindClause() : OMPNoChildClause() {} |
||
8678 | |||
8679 | public: |
||
8680 | /// Build 'bind' clause with kind \a K ('teams', 'parallel', or 'thread'). |
||
8681 | /// |
||
8682 | /// \param C AST context |
||
8683 | /// \param K Binding kind of the clause ('teams', 'parallel' or 'thread'). |
||
8684 | /// \param KLoc Starting location of the binding kind. |
||
8685 | /// \param StartLoc Starting location of the clause. |
||
8686 | /// \param LParenLoc Location of '('. |
||
8687 | /// \param EndLoc Ending location of the clause. |
||
8688 | static OMPBindClause *Create(const ASTContext &C, OpenMPBindClauseKind K, |
||
8689 | SourceLocation KLoc, SourceLocation StartLoc, |
||
8690 | SourceLocation LParenLoc, SourceLocation EndLoc); |
||
8691 | |||
8692 | /// Build an empty 'bind' clause. |
||
8693 | /// |
||
8694 | /// \param C AST context |
||
8695 | static OMPBindClause *CreateEmpty(const ASTContext &C); |
||
8696 | |||
8697 | /// Returns the location of '('. |
||
8698 | SourceLocation getLParenLoc() const { return LParenLoc; } |
||
8699 | |||
8700 | /// Returns kind of the clause. |
||
8701 | OpenMPBindClauseKind getBindKind() const { return Kind; } |
||
8702 | |||
8703 | /// Returns location of clause kind. |
||
8704 | SourceLocation getBindKindLoc() const { return KindLoc; } |
||
8705 | }; |
||
8706 | |||
8707 | /// This class implements a simple visitor for OMPClause |
||
8708 | /// subclasses. |
||
8709 | template<class ImplClass, template <typename> class Ptr, typename RetTy> |
||
8710 | class OMPClauseVisitorBase { |
||
8711 | public: |
||
8712 | #define PTR(CLASS) Ptr<CLASS> |
||
8713 | #define DISPATCH(CLASS) \ |
||
8714 | return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S)) |
||
8715 | |||
8716 | #define GEN_CLANG_CLAUSE_CLASS |
||
8717 | #define CLAUSE_CLASS(Enum, Str, Class) \ |
||
8718 | RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); } |
||
8719 | #include "llvm/Frontend/OpenMP/OMP.inc" |
||
8720 | |||
8721 | RetTy Visit(PTR(OMPClause) S) { |
||
8722 | // Top switch clause: visit each OMPClause. |
||
8723 | switch (S->getClauseKind()) { |
||
8724 | #define GEN_CLANG_CLAUSE_CLASS |
||
8725 | #define CLAUSE_CLASS(Enum, Str, Class) \ |
||
8726 | case llvm::omp::Clause::Enum: \ |
||
8727 | return Visit##Class(static_cast<PTR(Class)>(S)); |
||
8728 | #define CLAUSE_NO_CLASS(Enum, Str) \ |
||
8729 | case llvm::omp::Clause::Enum: \ |
||
8730 | break; |
||
8731 | #include "llvm/Frontend/OpenMP/OMP.inc" |
||
8732 | } |
||
8733 | } |
||
8734 | // Base case, ignore it. :) |
||
8735 | RetTy VisitOMPClause(PTR(OMPClause) Node) { return RetTy(); } |
||
8736 | #undef PTR |
||
8737 | #undef DISPATCH |
||
8738 | }; |
||
8739 | |||
8740 | template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>; |
||
8741 | |||
8742 | template <class ImplClass, typename RetTy = void> |
||
8743 | class OMPClauseVisitor |
||
8744 | : public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {}; |
||
8745 | template<class ImplClass, typename RetTy = void> |
||
8746 | class ConstOMPClauseVisitor : |
||
8747 | public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {}; |
||
8748 | |||
8749 | class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> { |
||
8750 | raw_ostream &OS; |
||
8751 | const PrintingPolicy &Policy; |
||
8752 | |||
8753 | /// Process clauses with list of variables. |
||
8754 | template <typename T> void VisitOMPClauseList(T *Node, char StartSym); |
||
8755 | /// Process motion clauses. |
||
8756 | template <typename T> void VisitOMPMotionClause(T *Node); |
||
8757 | |||
8758 | public: |
||
8759 | OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy) |
||
8760 | : OS(OS), Policy(Policy) {} |
||
8761 | |||
8762 | #define GEN_CLANG_CLAUSE_CLASS |
||
8763 | #define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S); |
||
8764 | #include "llvm/Frontend/OpenMP/OMP.inc" |
||
8765 | }; |
||
8766 | |||
8767 | struct OMPTraitProperty { |
||
8768 | llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid; |
||
8769 | |||
8770 | /// The raw string as we parsed it. This is needed for the `isa` trait set |
||
8771 | /// (which accepts anything) and (later) extensions. |
||
8772 | StringRef RawString; |
||
8773 | }; |
||
8774 | struct OMPTraitSelector { |
||
8775 | Expr *ScoreOrCondition = nullptr; |
||
8776 | llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid; |
||
8777 | llvm::SmallVector<OMPTraitProperty, 1> Properties; |
||
8778 | }; |
||
8779 | struct OMPTraitSet { |
||
8780 | llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid; |
||
8781 | llvm::SmallVector<OMPTraitSelector, 2> Selectors; |
||
8782 | }; |
||
8783 | |||
8784 | /// Helper data structure representing the traits in a match clause of an |
||
8785 | /// `declare variant` or `metadirective`. The outer level is an ordered |
||
8786 | /// collection of selector sets, each with an associated kind and an ordered |
||
8787 | /// collection of selectors. A selector has a kind, an optional score/condition, |
||
8788 | /// and an ordered collection of properties. |
||
8789 | class OMPTraitInfo { |
||
8790 | /// Private constructor accesible only by ASTContext. |
||
8791 | OMPTraitInfo() {} |
||
8792 | friend class ASTContext; |
||
8793 | |||
8794 | public: |
||
8795 | /// Reconstruct a (partial) OMPTraitInfo object from a mangled name. |
||
8796 | OMPTraitInfo(StringRef MangledName); |
||
8797 | |||
8798 | /// The outermost level of selector sets. |
||
8799 | llvm::SmallVector<OMPTraitSet, 2> Sets; |
||
8800 | |||
8801 | bool anyScoreOrCondition( |
||
8802 | llvm::function_ref<bool(Expr *&, bool /* IsScore */)> Cond) { |
||
8803 | return llvm::any_of(Sets, [&](OMPTraitSet &Set) { |
||
8804 | return llvm::any_of( |
||
8805 | Set.Selectors, [&](OMPTraitSelector &Selector) { |
||
8806 | return Cond(Selector.ScoreOrCondition, |
||
8807 | /* IsScore */ Selector.Kind != |
||
8808 | llvm::omp::TraitSelector::user_condition); |
||
8809 | }); |
||
8810 | }); |
||
8811 | } |
||
8812 | |||
8813 | /// Create a variant match info object from this trait info object. While the |
||
8814 | /// former is a flat representation the actual main difference is that the |
||
8815 | /// latter uses clang::Expr to store the score/condition while the former is |
||
8816 | /// independent of clang. Thus, expressions and conditions are evaluated in |
||
8817 | /// this method. |
||
8818 | void getAsVariantMatchInfo(ASTContext &ASTCtx, |
||
8819 | llvm::omp::VariantMatchInfo &VMI) const; |
||
8820 | |||
8821 | /// Return a string representation identifying this context selector. |
||
8822 | std::string getMangledName() const; |
||
8823 | |||
8824 | /// Check the extension trait \p TP is active. |
||
8825 | bool isExtensionActive(llvm::omp::TraitProperty TP) { |
||
8826 | for (const OMPTraitSet &Set : Sets) { |
||
8827 | if (Set.Kind != llvm::omp::TraitSet::implementation) |
||
8828 | continue; |
||
8829 | for (const OMPTraitSelector &Selector : Set.Selectors) { |
||
8830 | if (Selector.Kind != llvm::omp::TraitSelector::implementation_extension) |
||
8831 | continue; |
||
8832 | for (const OMPTraitProperty &Property : Selector.Properties) { |
||
8833 | if (Property.Kind == TP) |
||
8834 | return true; |
||
8835 | } |
||
8836 | } |
||
8837 | } |
||
8838 | return false; |
||
8839 | } |
||
8840 | |||
8841 | /// Print a human readable representation into \p OS. |
||
8842 | void print(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const; |
||
8843 | }; |
||
8844 | llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI); |
||
8845 | llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI); |
||
8846 | |||
8847 | /// Clang specific specialization of the OMPContext to lookup target features. |
||
8848 | struct TargetOMPContext final : public llvm::omp::OMPContext { |
||
8849 | TargetOMPContext(ASTContext &ASTCtx, |
||
8850 | std::function<void(StringRef)> &&DiagUnknownTrait, |
||
8851 | const FunctionDecl *CurrentFunctionDecl, |
||
8852 | ArrayRef<llvm::omp::TraitProperty> ConstructTraits); |
||
8853 | |||
8854 | virtual ~TargetOMPContext() = default; |
||
8855 | |||
8856 | /// See llvm::omp::OMPContext::matchesISATrait |
||
8857 | bool matchesISATrait(StringRef RawString) const override; |
||
8858 | |||
8859 | private: |
||
8860 | std::function<bool(StringRef)> FeatureValidityCheck; |
||
8861 | std::function<void(StringRef)> DiagUnknownTrait; |
||
8862 | llvm::StringMap<bool> FeatureMap; |
||
8863 | }; |
||
8864 | |||
8865 | /// Contains data for OpenMP directives: clauses, children |
||
8866 | /// expressions/statements (helpers for codegen) and associated statement, if |
||
8867 | /// any. |
||
8868 | class OMPChildren final |
||
8869 | : private llvm::TrailingObjects<OMPChildren, OMPClause *, Stmt *> { |
||
8870 | friend TrailingObjects; |
||
8871 | friend class OMPClauseReader; |
||
8872 | friend class OMPExecutableDirective; |
||
8873 | template <typename T> friend class OMPDeclarativeDirective; |
||
8874 | |||
8875 | /// Numbers of clauses. |
||
8876 | unsigned NumClauses = 0; |
||
8877 | /// Number of child expressions/stmts. |
||
8878 | unsigned NumChildren = 0; |
||
8879 | /// true if the directive has associated statement. |
||
8880 | bool HasAssociatedStmt = false; |
||
8881 | |||
8882 | /// Define the sizes of each trailing object array except the last one. This |
||
8883 | /// is required for TrailingObjects to work properly. |
||
8884 | size_t numTrailingObjects(OverloadToken<OMPClause *>) const { |
||
8885 | return NumClauses; |
||
8886 | } |
||
8887 | |||
8888 | OMPChildren() = delete; |
||
8889 | |||
8890 | OMPChildren(unsigned NumClauses, unsigned NumChildren, bool HasAssociatedStmt) |
||
8891 | : NumClauses(NumClauses), NumChildren(NumChildren), |
||
8892 | HasAssociatedStmt(HasAssociatedStmt) {} |
||
8893 | |||
8894 | static size_t size(unsigned NumClauses, bool HasAssociatedStmt, |
||
8895 | unsigned NumChildren); |
||
8896 | |||
8897 | static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses); |
||
8898 | static OMPChildren *Create(void *Mem, ArrayRef<OMPClause *> Clauses, Stmt *S, |
||
8899 | unsigned NumChildren = 0); |
||
8900 | static OMPChildren *CreateEmpty(void *Mem, unsigned NumClauses, |
||
8901 | bool HasAssociatedStmt = false, |
||
8902 | unsigned NumChildren = 0); |
||
8903 | |||
8904 | public: |
||
8905 | unsigned getNumClauses() const { return NumClauses; } |
||
8906 | unsigned getNumChildren() const { return NumChildren; } |
||
8907 | bool hasAssociatedStmt() const { return HasAssociatedStmt; } |
||
8908 | |||
8909 | /// Set associated statement. |
||
8910 | void setAssociatedStmt(Stmt *S) { |
||
8911 | getTrailingObjects<Stmt *>()[NumChildren] = S; |
||
8912 | } |
||
8913 | |||
8914 | void setChildren(ArrayRef<Stmt *> Children); |
||
8915 | |||
8916 | /// Sets the list of variables for this clause. |
||
8917 | /// |
||
8918 | /// \param Clauses The list of clauses for the directive. |
||
8919 | /// |
||
8920 | void setClauses(ArrayRef<OMPClause *> Clauses); |
||
8921 | |||
8922 | /// Returns statement associated with the directive. |
||
8923 | const Stmt *getAssociatedStmt() const { |
||
8924 | return const_cast<OMPChildren *>(this)->getAssociatedStmt(); |
||
8925 | } |
||
8926 | Stmt *getAssociatedStmt() { |
||
8927 | assert(HasAssociatedStmt && |
||
8928 | "Expected directive with the associated statement."); |
||
8929 | return getTrailingObjects<Stmt *>()[NumChildren]; |
||
8930 | } |
||
8931 | |||
8932 | /// Get the clauses storage. |
||
8933 | MutableArrayRef<OMPClause *> getClauses() { |
||
8934 | return llvm::MutableArrayRef(getTrailingObjects<OMPClause *>(), |
||
8935 | NumClauses); |
||
8936 | } |
||
8937 | ArrayRef<OMPClause *> getClauses() const { |
||
8938 | return const_cast<OMPChildren *>(this)->getClauses(); |
||
8939 | } |
||
8940 | |||
8941 | /// Returns the captured statement associated with the |
||
8942 | /// component region within the (combined) directive. |
||
8943 | /// |
||
8944 | /// \param RegionKind Component region kind. |
||
8945 | const CapturedStmt * |
||
8946 | getCapturedStmt(OpenMPDirectiveKind RegionKind, |
||
8947 | ArrayRef<OpenMPDirectiveKind> CaptureRegions) const { |
||
8948 | assert(llvm::is_contained(CaptureRegions, RegionKind) && |
||
8949 | "RegionKind not found in OpenMP CaptureRegions."); |
||
8950 | auto *CS = cast<CapturedStmt>(getAssociatedStmt()); |
||
8951 | for (auto ThisCaptureRegion : CaptureRegions) { |
||
8952 | if (ThisCaptureRegion == RegionKind) |
||
8953 | return CS; |
||
8954 | CS = cast<CapturedStmt>(CS->getCapturedStmt()); |
||
8955 | } |
||
8956 | llvm_unreachable("Incorrect RegionKind specified for directive."); |
||
8957 | } |
||
8958 | |||
8959 | /// Get innermost captured statement for the construct. |
||
8960 | CapturedStmt * |
||
8961 | getInnermostCapturedStmt(ArrayRef<OpenMPDirectiveKind> CaptureRegions) { |
||
8962 | assert(hasAssociatedStmt() && "Must have associated captured statement."); |
||
8963 | assert(!CaptureRegions.empty() && |
||
8964 | "At least one captured statement must be provided."); |
||
8965 | auto *CS = cast<CapturedStmt>(getAssociatedStmt()); |
||
8966 | for (unsigned Level = CaptureRegions.size(); Level > 1; --Level) |
||
8967 | CS = cast<CapturedStmt>(CS->getCapturedStmt()); |
||
8968 | return CS; |
||
8969 | } |
||
8970 | |||
8971 | const CapturedStmt * |
||
8972 | getInnermostCapturedStmt(ArrayRef<OpenMPDirectiveKind> CaptureRegions) const { |
||
8973 | return const_cast<OMPChildren *>(this)->getInnermostCapturedStmt( |
||
8974 | CaptureRegions); |
||
8975 | } |
||
8976 | |||
8977 | MutableArrayRef<Stmt *> getChildren(); |
||
8978 | ArrayRef<Stmt *> getChildren() const { |
||
8979 | return const_cast<OMPChildren *>(this)->getChildren(); |
||
8980 | } |
||
8981 | |||
8982 | Stmt *getRawStmt() { |
||
8983 | assert(HasAssociatedStmt && |
||
8984 | "Expected directive with the associated statement."); |
||
8985 | if (auto *CS = dyn_cast<CapturedStmt>(getAssociatedStmt())) { |
||
8986 | Stmt *S = nullptr; |
||
8987 | do { |
||
8988 | S = CS->getCapturedStmt(); |
||
8989 | CS = dyn_cast<CapturedStmt>(S); |
||
8990 | } while (CS); |
||
8991 | return S; |
||
8992 | } |
||
8993 | return getAssociatedStmt(); |
||
8994 | } |
||
8995 | const Stmt *getRawStmt() const { |
||
8996 | return const_cast<OMPChildren *>(this)->getRawStmt(); |
||
8997 | } |
||
8998 | |||
8999 | Stmt::child_range getAssociatedStmtAsRange() { |
||
9000 | if (!HasAssociatedStmt) |
||
9001 | return Stmt::child_range(Stmt::child_iterator(), Stmt::child_iterator()); |
||
9002 | return Stmt::child_range(&getTrailingObjects<Stmt *>()[NumChildren], |
||
9003 | &getTrailingObjects<Stmt *>()[NumChildren + 1]); |
||
9004 | } |
||
9005 | }; |
||
9006 | |||
9007 | /// This represents 'ompx_dyn_cgroup_mem' clause in the '#pragma omp target ...' |
||
9008 | /// directive. |
||
9009 | /// |
||
9010 | /// \code |
||
9011 | /// #pragma omp target [...] ompx_dyn_cgroup_mem(N) |
||
9012 | /// \endcode |
||
9013 | class OMPXDynCGroupMemClause |
||
9014 | : public OMPOneStmtClause<llvm::omp::OMPC_ompx_dyn_cgroup_mem, OMPClause>, |
||
9015 | public OMPClauseWithPreInit { |
||
9016 | friend class OMPClauseReader; |
||
9017 | |||
9018 | /// Set size. |
||
9019 | void setSize(Expr *E) { setStmt(E); } |
||
9020 | |||
9021 | public: |
||
9022 | /// Build 'ompx_dyn_cgroup_mem' clause. |
||
9023 | /// |
||
9024 | /// \param Size Size expression. |
||
9025 | /// \param HelperSize Helper Size expression |
||
9026 | /// \param CaptureRegion Innermost OpenMP region where expressions in this |
||
9027 | /// \param StartLoc Starting location of the clause. |
||
9028 | /// \param LParenLoc Location of '('. |
||
9029 | /// \param EndLoc Ending location of the clause. |
||
9030 | OMPXDynCGroupMemClause(Expr *Size, Stmt *HelperSize, |
||
9031 | OpenMPDirectiveKind CaptureRegion, |
||
9032 | SourceLocation StartLoc, SourceLocation LParenLoc, |
||
9033 | SourceLocation EndLoc) |
||
9034 | : OMPOneStmtClause(Size, StartLoc, LParenLoc, EndLoc), |
||
9035 | OMPClauseWithPreInit(this) { |
||
9036 | setPreInitStmt(HelperSize, CaptureRegion); |
||
9037 | } |
||
9038 | |||
9039 | /// Build an empty clause. |
||
9040 | OMPXDynCGroupMemClause() : OMPOneStmtClause(), OMPClauseWithPreInit(this) {} |
||
9041 | |||
9042 | /// Return the size expression. |
||
9043 | Expr *getSize() { return getStmtAs<Expr>(); } |
||
9044 | |||
9045 | /// Return the size expression. |
||
9046 | Expr *getSize() const { return getStmtAs<Expr>(); } |
||
9047 | }; |
||
9048 | |||
9049 | } // namespace clang |
||
9050 | |||
9051 | #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H |