1 | //===----- SemaOpenMP.h -- Semantic Analysis for OpenMP constructs -------===// |
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 | /// \file |
9 | /// This file declares semantic analysis for OpenMP constructs and |
10 | /// clauses. |
11 | /// |
12 | //===----------------------------------------------------------------------===// |
13 | |
14 | #ifndef LLVM_CLANG_SEMA_SEMAOPENMP_H |
15 | #define LLVM_CLANG_SEMA_SEMAOPENMP_H |
16 | |
17 | #include "clang/AST/Attr.h" |
18 | #include "clang/AST/Decl.h" |
19 | #include "clang/AST/DeclBase.h" |
20 | #include "clang/AST/DeclOpenMP.h" |
21 | #include "clang/AST/DeclarationName.h" |
22 | #include "clang/AST/Expr.h" |
23 | #include "clang/AST/ExprOpenMP.h" |
24 | #include "clang/AST/OpenMPClause.h" |
25 | #include "clang/AST/Stmt.h" |
26 | #include "clang/AST/StmtOpenMP.h" |
27 | #include "clang/AST/Type.h" |
28 | #include "clang/Basic/IdentifierTable.h" |
29 | #include "clang/Basic/LLVM.h" |
30 | #include "clang/Basic/OpenMPKinds.h" |
31 | #include "clang/Basic/SourceLocation.h" |
32 | #include "clang/Basic/Specifiers.h" |
33 | #include "clang/Sema/DeclSpec.h" |
34 | #include "clang/Sema/Ownership.h" |
35 | #include "clang/Sema/Scope.h" |
36 | #include "clang/Sema/ScopeInfo.h" |
37 | #include "clang/Sema/SemaBase.h" |
38 | #include "llvm/ADT/DenseMap.h" |
39 | #include "llvm/ADT/PointerUnion.h" |
40 | #include <optional> |
41 | #include <string> |
42 | #include <utility> |
43 | |
44 | namespace clang { |
45 | |
46 | class SemaOpenMP : public SemaBase { |
47 | public: |
48 | SemaOpenMP(Sema &S); |
49 | |
50 | friend class Parser; |
51 | friend class Sema; |
52 | |
53 | using DeclGroupPtrTy = OpaquePtr<DeclGroupRef>; |
54 | using CapturedParamNameType = std::pair<StringRef, QualType>; |
55 | |
56 | /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current |
57 | /// context is "used as device code". |
58 | /// |
59 | /// - If CurContext is a `declare target` function or it is known that the |
60 | /// function is emitted for the device, emits the diagnostics immediately. |
61 | /// - If CurContext is a non-`declare target` function and we are compiling |
62 | /// for the device, creates a diagnostic which is emitted if and when we |
63 | /// realize that the function will be codegen'ed. |
64 | /// |
65 | /// Example usage: |
66 | /// |
67 | /// // Variable-length arrays are not allowed in NVPTX device code. |
68 | /// if (diagIfOpenMPDeviceCode(Loc, diag::err_vla_unsupported)) |
69 | /// return ExprError(); |
70 | /// // Otherwise, continue parsing as normal. |
71 | SemaDiagnosticBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, |
72 | unsigned DiagID, |
73 | const FunctionDecl *FD); |
74 | |
75 | /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current |
76 | /// context is "used as host code". |
77 | /// |
78 | /// - If CurContext is a `declare target` function or it is known that the |
79 | /// function is emitted for the host, emits the diagnostics immediately. |
80 | /// - If CurContext is a non-host function, just ignore it. |
81 | /// |
82 | /// Example usage: |
83 | /// |
84 | /// // Variable-length arrays are not allowed in NVPTX device code. |
85 | /// if (diagIfOpenMPHostode(Loc, diag::err_vla_unsupported)) |
86 | /// return ExprError(); |
87 | /// // Otherwise, continue parsing as normal. |
88 | SemaDiagnosticBuilder diagIfOpenMPHostCode(SourceLocation Loc, |
89 | unsigned DiagID, |
90 | const FunctionDecl *FD); |
91 | |
92 | /// The declarator \p D defines a function in the scope \p S which is nested |
93 | /// in an `omp begin/end declare variant` scope. In this method we create a |
94 | /// declaration for \p D and rename \p D according to the OpenMP context |
95 | /// selector of the surrounding scope. Return all base functions in \p Bases. |
96 | void ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope( |
97 | Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, |
98 | SmallVectorImpl<FunctionDecl *> &Bases); |
99 | |
100 | /// Register \p D as specialization of all base functions in \p Bases in the |
101 | /// current `omp begin/end declare variant` scope. |
102 | void ActOnFinishedFunctionDefinitionInOpenMPDeclareVariantScope( |
103 | Decl *D, SmallVectorImpl<FunctionDecl *> &Bases); |
104 | |
105 | /// Act on \p D, a function definition inside of an `omp [begin/end] assumes`. |
106 | void ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Decl *D); |
107 | |
108 | /// Can we exit an OpenMP declare variant scope at the moment. |
109 | bool isInOpenMPDeclareVariantScope() const { |
110 | return !OMPDeclareVariantScopes.empty(); |
111 | } |
112 | |
113 | ExprResult |
114 | VerifyPositiveIntegerConstantInClause(Expr *Op, OpenMPClauseKind CKind, |
115 | bool StrictlyPositive = true, |
116 | bool SuppressExprDiags = false); |
117 | |
118 | /// Given the potential call expression \p Call, determine if there is a |
119 | /// specialization via the OpenMP declare variant mechanism available. If |
120 | /// there is, return the specialized call expression, otherwise return the |
121 | /// original \p Call. |
122 | ExprResult ActOnOpenMPCall(ExprResult Call, Scope *Scope, |
123 | SourceLocation LParenLoc, MultiExprArg ArgExprs, |
124 | SourceLocation RParenLoc, Expr *ExecConfig); |
125 | |
126 | /// Handle a `omp begin declare variant`. |
127 | void ActOnOpenMPBeginDeclareVariant(SourceLocation Loc, OMPTraitInfo &TI); |
128 | |
129 | /// Handle a `omp end declare variant`. |
130 | void ActOnOpenMPEndDeclareVariant(); |
131 | |
132 | /// Function tries to capture lambda's captured variables in the OpenMP region |
133 | /// before the original lambda is captured. |
134 | void tryCaptureOpenMPLambdas(ValueDecl *V); |
135 | |
136 | /// Return true if the provided declaration \a VD should be captured by |
137 | /// reference. |
138 | /// \param Level Relative level of nested OpenMP construct for that the check |
139 | /// is performed. |
140 | /// \param OpenMPCaptureLevel Capture level within an OpenMP construct. |
141 | bool isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level, |
142 | unsigned OpenMPCaptureLevel) const; |
143 | |
144 | /// Check if the specified variable is used in one of the private |
145 | /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP |
146 | /// constructs. |
147 | VarDecl *isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo = false, |
148 | unsigned StopAt = 0); |
149 | |
150 | /// The member expression(this->fd) needs to be rebuilt in the template |
151 | /// instantiation to generate private copy for OpenMP when default |
152 | /// clause is used. The function will return true if default |
153 | /// cluse is used. |
154 | bool isOpenMPRebuildMemberExpr(ValueDecl *D); |
155 | |
156 | ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK, |
157 | ExprObjectKind OK, SourceLocation Loc); |
158 | |
159 | /// If the current region is a loop-based region, mark the start of the loop |
160 | /// construct. |
161 | void startOpenMPLoop(); |
162 | |
163 | /// If the current region is a range loop-based region, mark the start of the |
164 | /// loop construct. |
165 | void startOpenMPCXXRangeFor(); |
166 | |
167 | /// Check if the specified variable is used in 'private' clause. |
168 | /// \param Level Relative level of nested OpenMP construct for that the check |
169 | /// is performed. |
170 | OpenMPClauseKind isOpenMPPrivateDecl(ValueDecl *D, unsigned Level, |
171 | unsigned CapLevel) const; |
172 | |
173 | /// Sets OpenMP capture kind (OMPC_private, OMPC_firstprivate, OMPC_map etc.) |
174 | /// for \p FD based on DSA for the provided corresponding captured declaration |
175 | /// \p D. |
176 | void setOpenMPCaptureKind(FieldDecl *FD, const ValueDecl *D, unsigned Level); |
177 | |
178 | /// Check if the specified variable is captured by 'target' directive. |
179 | /// \param Level Relative level of nested OpenMP construct for that the check |
180 | /// is performed. |
181 | bool isOpenMPTargetCapturedDecl(const ValueDecl *D, unsigned Level, |
182 | unsigned CaptureLevel) const; |
183 | |
184 | /// Check if the specified global variable must be captured by outer capture |
185 | /// regions. |
186 | /// \param Level Relative level of nested OpenMP construct for that |
187 | /// the check is performed. |
188 | bool isOpenMPGlobalCapturedDecl(ValueDecl *D, unsigned Level, |
189 | unsigned CaptureLevel) const; |
190 | |
191 | ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc, |
192 | Expr *Op); |
193 | /// Called on start of new data sharing attribute block. |
194 | void StartOpenMPDSABlock(OpenMPDirectiveKind K, |
195 | const DeclarationNameInfo &DirName, Scope *CurScope, |
196 | SourceLocation Loc); |
197 | /// Start analysis of clauses. |
198 | void StartOpenMPClause(OpenMPClauseKind K); |
199 | /// End analysis of clauses. |
200 | void EndOpenMPClause(); |
201 | /// Called on end of data sharing attribute block. |
202 | void EndOpenMPDSABlock(Stmt *CurDirective); |
203 | |
204 | /// Check if the current region is an OpenMP loop region and if it is, |
205 | /// mark loop control variable, used in \p Init for loop initialization, as |
206 | /// private by default. |
207 | /// \param Init First part of the for loop. |
208 | void ActOnOpenMPLoopInitialization(SourceLocation ForLoc, Stmt *Init); |
209 | |
210 | /// Called on well-formed '\#pragma omp metadirective' after parsing |
211 | /// of the associated statement. |
212 | StmtResult ActOnOpenMPMetaDirective(ArrayRef<OMPClause *> Clauses, |
213 | Stmt *AStmt, SourceLocation StartLoc, |
214 | SourceLocation EndLoc); |
215 | |
216 | // OpenMP directives and clauses. |
217 | /// Called on correct id-expression from the '#pragma omp |
218 | /// threadprivate'. |
219 | ExprResult ActOnOpenMPIdExpression(Scope *CurScope, CXXScopeSpec &ScopeSpec, |
220 | const DeclarationNameInfo &Id, |
221 | OpenMPDirectiveKind Kind); |
222 | /// Called on well-formed '#pragma omp threadprivate'. |
223 | DeclGroupPtrTy ActOnOpenMPThreadprivateDirective(SourceLocation Loc, |
224 | ArrayRef<Expr *> VarList); |
225 | /// Builds a new OpenMPThreadPrivateDecl and checks its correctness. |
226 | OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl(SourceLocation Loc, |
227 | ArrayRef<Expr *> VarList); |
228 | /// Called on well-formed '#pragma omp allocate'. |
229 | DeclGroupPtrTy ActOnOpenMPAllocateDirective(SourceLocation Loc, |
230 | ArrayRef<Expr *> VarList, |
231 | ArrayRef<OMPClause *> Clauses, |
232 | DeclContext *Owner = nullptr); |
233 | |
234 | /// Called on well-formed '#pragma omp [begin] assume[s]'. |
235 | void ActOnOpenMPAssumesDirective(SourceLocation Loc, |
236 | OpenMPDirectiveKind DKind, |
237 | ArrayRef<std::string> Assumptions, |
238 | bool SkippedClauses); |
239 | |
240 | /// Check if there is an active global `omp begin assumes` directive. |
241 | bool isInOpenMPAssumeScope() const { return !OMPAssumeScoped.empty(); } |
242 | |
243 | /// Check if there is an active global `omp assumes` directive. |
244 | bool hasGlobalOpenMPAssumes() const { return !OMPAssumeGlobal.empty(); } |
245 | |
246 | /// Called on well-formed '#pragma omp end assumes'. |
247 | void ActOnOpenMPEndAssumesDirective(); |
248 | |
249 | /// Called on well-formed '#pragma omp requires'. |
250 | DeclGroupPtrTy ActOnOpenMPRequiresDirective(SourceLocation Loc, |
251 | ArrayRef<OMPClause *> ClauseList); |
252 | /// Check restrictions on Requires directive |
253 | OMPRequiresDecl *CheckOMPRequiresDecl(SourceLocation Loc, |
254 | ArrayRef<OMPClause *> Clauses); |
255 | /// Check if the specified type is allowed to be used in 'omp declare |
256 | /// reduction' construct. |
257 | QualType ActOnOpenMPDeclareReductionType(SourceLocation TyLoc, |
258 | TypeResult ParsedType); |
259 | /// Called on start of '#pragma omp declare reduction'. |
260 | DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveStart( |
261 | Scope *S, DeclContext *DC, DeclarationName Name, |
262 | ArrayRef<std::pair<QualType, SourceLocation>> ReductionTypes, |
263 | AccessSpecifier AS, Decl *PrevDeclInScope = nullptr); |
264 | /// Initialize declare reduction construct initializer. |
265 | void ActOnOpenMPDeclareReductionCombinerStart(Scope *S, Decl *D); |
266 | /// Finish current declare reduction construct initializer. |
267 | void ActOnOpenMPDeclareReductionCombinerEnd(Decl *D, Expr *Combiner); |
268 | /// Initialize declare reduction construct initializer. |
269 | /// \return omp_priv variable. |
270 | VarDecl *ActOnOpenMPDeclareReductionInitializerStart(Scope *S, Decl *D); |
271 | /// Finish current declare reduction construct initializer. |
272 | void ActOnOpenMPDeclareReductionInitializerEnd(Decl *D, Expr *Initializer, |
273 | VarDecl *OmpPrivParm); |
274 | /// Called at the end of '#pragma omp declare reduction'. |
275 | DeclGroupPtrTy ActOnOpenMPDeclareReductionDirectiveEnd( |
276 | Scope *S, DeclGroupPtrTy DeclReductions, bool IsValid); |
277 | |
278 | /// Check variable declaration in 'omp declare mapper' construct. |
279 | TypeResult ActOnOpenMPDeclareMapperVarDecl(Scope *S, Declarator &D); |
280 | /// Check if the specified type is allowed to be used in 'omp declare |
281 | /// mapper' construct. |
282 | QualType ActOnOpenMPDeclareMapperType(SourceLocation TyLoc, |
283 | TypeResult ParsedType); |
284 | /// Called on start of '#pragma omp declare mapper'. |
285 | DeclGroupPtrTy ActOnOpenMPDeclareMapperDirective( |
286 | Scope *S, DeclContext *DC, DeclarationName Name, QualType MapperType, |
287 | SourceLocation StartLoc, DeclarationName VN, AccessSpecifier AS, |
288 | Expr *MapperVarRef, ArrayRef<OMPClause *> Clauses, |
289 | Decl *PrevDeclInScope = nullptr); |
290 | /// Build the mapper variable of '#pragma omp declare mapper'. |
291 | ExprResult ActOnOpenMPDeclareMapperDirectiveVarDecl(Scope *S, |
292 | QualType MapperType, |
293 | SourceLocation StartLoc, |
294 | DeclarationName VN); |
295 | void ActOnOpenMPIteratorVarDecl(VarDecl *VD); |
296 | bool isOpenMPDeclareMapperVarDeclAllowed(const VarDecl *VD) const; |
297 | const ValueDecl *getOpenMPDeclareMapperVarName() const; |
298 | |
299 | struct DeclareTargetContextInfo { |
300 | struct MapInfo { |
301 | OMPDeclareTargetDeclAttr::MapTypeTy MT; |
302 | SourceLocation Loc; |
303 | }; |
304 | /// Explicitly listed variables and functions in a 'to' or 'link' clause. |
305 | llvm::DenseMap<NamedDecl *, MapInfo> ExplicitlyMapped; |
306 | |
307 | /// The 'device_type' as parsed from the clause. |
308 | OMPDeclareTargetDeclAttr::DevTypeTy DT = OMPDeclareTargetDeclAttr::DT_Any; |
309 | |
310 | /// The directive kind, `begin declare target` or `declare target`. |
311 | OpenMPDirectiveKind Kind; |
312 | |
313 | /// The directive with indirect clause. |
314 | std::optional<Expr *> Indirect; |
315 | |
316 | /// The directive location. |
317 | SourceLocation Loc; |
318 | |
319 | DeclareTargetContextInfo(OpenMPDirectiveKind Kind, SourceLocation Loc) |
320 | : Kind(Kind), Loc(Loc) {} |
321 | }; |
322 | |
323 | /// Called on the start of target region i.e. '#pragma omp declare target'. |
324 | bool ActOnStartOpenMPDeclareTargetContext(DeclareTargetContextInfo &DTCI); |
325 | |
326 | /// Called at the end of target region i.e. '#pragma omp end declare target'. |
327 | const DeclareTargetContextInfo ActOnOpenMPEndDeclareTargetDirective(); |
328 | |
329 | /// Called once a target context is completed, that can be when a |
330 | /// '#pragma omp end declare target' was encountered or when a |
331 | /// '#pragma omp declare target' without declaration-definition-seq was |
332 | /// encountered. |
333 | void ActOnFinishedOpenMPDeclareTargetContext(DeclareTargetContextInfo &DTCI); |
334 | |
335 | /// Report unterminated 'omp declare target' or 'omp begin declare target' at |
336 | /// the end of a compilation unit. |
337 | void DiagnoseUnterminatedOpenMPDeclareTarget(); |
338 | |
339 | /// Searches for the provided declaration name for OpenMP declare target |
340 | /// directive. |
341 | NamedDecl *lookupOpenMPDeclareTargetName(Scope *CurScope, |
342 | CXXScopeSpec &ScopeSpec, |
343 | const DeclarationNameInfo &Id); |
344 | |
345 | /// Called on correct id-expression from the '#pragma omp declare target'. |
346 | void ActOnOpenMPDeclareTargetName(NamedDecl *ND, SourceLocation Loc, |
347 | OMPDeclareTargetDeclAttr::MapTypeTy MT, |
348 | DeclareTargetContextInfo &DTCI); |
349 | |
350 | /// Check declaration inside target region. |
351 | void |
352 | checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D, |
353 | SourceLocation IdLoc = SourceLocation()); |
354 | |
355 | /// Adds OMPDeclareTargetDeclAttr to referenced variables in declare target |
356 | /// directive. |
357 | void ActOnOpenMPDeclareTargetInitializer(Decl *D); |
358 | |
359 | /// Finishes analysis of the deferred functions calls that may be declared as |
360 | /// host/nohost during device/host compilation. |
361 | void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller, |
362 | const FunctionDecl *Callee, |
363 | SourceLocation Loc); |
364 | |
365 | /// Return true if currently in OpenMP task with untied clause context. |
366 | bool isInOpenMPTaskUntiedContext() const; |
367 | |
368 | /// Return true inside OpenMP declare target region. |
369 | bool isInOpenMPDeclareTargetContext() const { |
370 | return !DeclareTargetNesting.empty(); |
371 | } |
372 | /// Return true inside OpenMP target region. |
373 | bool isInOpenMPTargetExecutionDirective() const; |
374 | |
375 | /// Return the number of captured regions created for an OpenMP directive. |
376 | static int getOpenMPCaptureLevels(OpenMPDirectiveKind Kind); |
377 | |
378 | /// Initialization of captured region for OpenMP region. |
379 | void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope); |
380 | |
381 | /// Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to |
382 | /// an OpenMP loop directive. |
383 | StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt); |
384 | |
385 | /// Process a canonical OpenMP loop nest that can either be a canonical |
386 | /// literal loop (ForStmt or CXXForRangeStmt), or the generated loop of an |
387 | /// OpenMP loop transformation construct. |
388 | StmtResult ActOnOpenMPLoopnest(Stmt *AStmt); |
389 | |
390 | /// End of OpenMP region. |
391 | /// |
392 | /// \param S Statement associated with the current OpenMP region. |
393 | /// \param Clauses List of clauses for the current OpenMP region. |
394 | /// |
395 | /// \returns Statement for finished OpenMP region. |
396 | StmtResult ActOnOpenMPRegionEnd(StmtResult S, ArrayRef<OMPClause *> Clauses); |
397 | StmtResult ActOnOpenMPExecutableDirective( |
398 | OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, |
399 | OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses, |
400 | Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, |
401 | OpenMPDirectiveKind PrevMappedDirective = llvm::omp::OMPD_unknown); |
402 | /// Called on well-formed '\#pragma omp parallel' after parsing |
403 | /// of the associated statement. |
404 | StmtResult ActOnOpenMPParallelDirective(ArrayRef<OMPClause *> Clauses, |
405 | Stmt *AStmt, SourceLocation StartLoc, |
406 | SourceLocation EndLoc); |
407 | using VarsWithInheritedDSAType = |
408 | llvm::SmallDenseMap<const ValueDecl *, const Expr *, 4>; |
409 | /// Called on well-formed '\#pragma omp simd' after parsing |
410 | /// of the associated statement. |
411 | StmtResult |
412 | ActOnOpenMPSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, |
413 | SourceLocation StartLoc, SourceLocation EndLoc, |
414 | VarsWithInheritedDSAType &VarsWithImplicitDSA); |
415 | /// Called on well-formed '#pragma omp tile' after parsing of its clauses and |
416 | /// the associated statement. |
417 | StmtResult ActOnOpenMPTileDirective(ArrayRef<OMPClause *> Clauses, |
418 | Stmt *AStmt, SourceLocation StartLoc, |
419 | SourceLocation EndLoc); |
420 | /// Called on well-formed '#pragma omp unroll' after parsing of its clauses |
421 | /// and the associated statement. |
422 | StmtResult ActOnOpenMPUnrollDirective(ArrayRef<OMPClause *> Clauses, |
423 | Stmt *AStmt, SourceLocation StartLoc, |
424 | SourceLocation EndLoc); |
425 | /// Called on well-formed '\#pragma omp for' after parsing |
426 | /// of the associated statement. |
427 | StmtResult |
428 | ActOnOpenMPForDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, |
429 | SourceLocation StartLoc, SourceLocation EndLoc, |
430 | VarsWithInheritedDSAType &VarsWithImplicitDSA); |
431 | /// Called on well-formed '\#pragma omp for simd' after parsing |
432 | /// of the associated statement. |
433 | StmtResult |
434 | ActOnOpenMPForSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, |
435 | SourceLocation StartLoc, SourceLocation EndLoc, |
436 | VarsWithInheritedDSAType &VarsWithImplicitDSA); |
437 | /// Called on well-formed '\#pragma omp sections' after parsing |
438 | /// of the associated statement. |
439 | StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses, |
440 | Stmt *AStmt, SourceLocation StartLoc, |
441 | SourceLocation EndLoc); |
442 | /// Called on well-formed '\#pragma omp section' after parsing of the |
443 | /// associated statement. |
444 | StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc, |
445 | SourceLocation EndLoc); |
446 | /// Called on well-formed '\#pragma omp scope' after parsing of the |
447 | /// associated statement. |
448 | StmtResult ActOnOpenMPScopeDirective(ArrayRef<OMPClause *> Clauses, |
449 | Stmt *AStmt, SourceLocation StartLoc, |
450 | SourceLocation EndLoc); |
451 | /// Called on well-formed '\#pragma omp single' after parsing of the |
452 | /// associated statement. |
453 | StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses, |
454 | Stmt *AStmt, SourceLocation StartLoc, |
455 | SourceLocation EndLoc); |
456 | /// Called on well-formed '\#pragma omp master' after parsing of the |
457 | /// associated statement. |
458 | StmtResult ActOnOpenMPMasterDirective(Stmt *AStmt, SourceLocation StartLoc, |
459 | SourceLocation EndLoc); |
460 | /// Called on well-formed '\#pragma omp critical' after parsing of the |
461 | /// associated statement. |
462 | StmtResult ActOnOpenMPCriticalDirective(const DeclarationNameInfo &DirName, |
463 | ArrayRef<OMPClause *> Clauses, |
464 | Stmt *AStmt, SourceLocation StartLoc, |
465 | SourceLocation EndLoc); |
466 | /// Called on well-formed '\#pragma omp parallel for' after parsing |
467 | /// of the associated statement. |
468 | StmtResult ActOnOpenMPParallelForDirective( |
469 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
470 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
471 | /// Called on well-formed '\#pragma omp parallel for simd' after |
472 | /// parsing of the associated statement. |
473 | StmtResult ActOnOpenMPParallelForSimdDirective( |
474 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
475 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
476 | /// Called on well-formed '\#pragma omp parallel master' after |
477 | /// parsing of the associated statement. |
478 | StmtResult ActOnOpenMPParallelMasterDirective(ArrayRef<OMPClause *> Clauses, |
479 | Stmt *AStmt, |
480 | SourceLocation StartLoc, |
481 | SourceLocation EndLoc); |
482 | /// Called on well-formed '\#pragma omp parallel masked' after |
483 | /// parsing of the associated statement. |
484 | StmtResult ActOnOpenMPParallelMaskedDirective(ArrayRef<OMPClause *> Clauses, |
485 | Stmt *AStmt, |
486 | SourceLocation StartLoc, |
487 | SourceLocation EndLoc); |
488 | /// Called on well-formed '\#pragma omp parallel sections' after |
489 | /// parsing of the associated statement. |
490 | StmtResult ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses, |
491 | Stmt *AStmt, |
492 | SourceLocation StartLoc, |
493 | SourceLocation EndLoc); |
494 | /// Called on well-formed '\#pragma omp task' after parsing of the |
495 | /// associated statement. |
496 | StmtResult ActOnOpenMPTaskDirective(ArrayRef<OMPClause *> Clauses, |
497 | Stmt *AStmt, SourceLocation StartLoc, |
498 | SourceLocation EndLoc); |
499 | /// Called on well-formed '\#pragma omp taskyield'. |
500 | StmtResult ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc, |
501 | SourceLocation EndLoc); |
502 | /// Called on well-formed '\#pragma omp error'. |
503 | /// Error direcitive is allowed in both declared and excutable contexts. |
504 | /// Adding InExContext to identify which context is called from. |
505 | StmtResult ActOnOpenMPErrorDirective(ArrayRef<OMPClause *> Clauses, |
506 | SourceLocation StartLoc, |
507 | SourceLocation EndLoc, |
508 | bool InExContext = true); |
509 | /// Called on well-formed '\#pragma omp barrier'. |
510 | StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc, |
511 | SourceLocation EndLoc); |
512 | /// Called on well-formed '\#pragma omp taskwait'. |
513 | StmtResult ActOnOpenMPTaskwaitDirective(ArrayRef<OMPClause *> Clauses, |
514 | SourceLocation StartLoc, |
515 | SourceLocation EndLoc); |
516 | /// Called on well-formed '\#pragma omp taskgroup'. |
517 | StmtResult ActOnOpenMPTaskgroupDirective(ArrayRef<OMPClause *> Clauses, |
518 | Stmt *AStmt, SourceLocation StartLoc, |
519 | SourceLocation EndLoc); |
520 | /// Called on well-formed '\#pragma omp flush'. |
521 | StmtResult ActOnOpenMPFlushDirective(ArrayRef<OMPClause *> Clauses, |
522 | SourceLocation StartLoc, |
523 | SourceLocation EndLoc); |
524 | /// Called on well-formed '\#pragma omp depobj'. |
525 | StmtResult ActOnOpenMPDepobjDirective(ArrayRef<OMPClause *> Clauses, |
526 | SourceLocation StartLoc, |
527 | SourceLocation EndLoc); |
528 | /// Called on well-formed '\#pragma omp scan'. |
529 | StmtResult ActOnOpenMPScanDirective(ArrayRef<OMPClause *> Clauses, |
530 | SourceLocation StartLoc, |
531 | SourceLocation EndLoc); |
532 | /// Called on well-formed '\#pragma omp ordered' after parsing of the |
533 | /// associated statement. |
534 | StmtResult ActOnOpenMPOrderedDirective(ArrayRef<OMPClause *> Clauses, |
535 | Stmt *AStmt, SourceLocation StartLoc, |
536 | SourceLocation EndLoc); |
537 | /// Called on well-formed '\#pragma omp atomic' after parsing of the |
538 | /// associated statement. |
539 | StmtResult ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses, |
540 | Stmt *AStmt, SourceLocation StartLoc, |
541 | SourceLocation EndLoc); |
542 | /// Called on well-formed '\#pragma omp target' after parsing of the |
543 | /// associated statement. |
544 | StmtResult ActOnOpenMPTargetDirective(ArrayRef<OMPClause *> Clauses, |
545 | Stmt *AStmt, SourceLocation StartLoc, |
546 | SourceLocation EndLoc); |
547 | /// Called on well-formed '\#pragma omp target data' after parsing of |
548 | /// the associated statement. |
549 | StmtResult ActOnOpenMPTargetDataDirective(ArrayRef<OMPClause *> Clauses, |
550 | Stmt *AStmt, |
551 | SourceLocation StartLoc, |
552 | SourceLocation EndLoc); |
553 | /// Called on well-formed '\#pragma omp target enter data' after |
554 | /// parsing of the associated statement. |
555 | StmtResult ActOnOpenMPTargetEnterDataDirective(ArrayRef<OMPClause *> Clauses, |
556 | SourceLocation StartLoc, |
557 | SourceLocation EndLoc, |
558 | Stmt *AStmt); |
559 | /// Called on well-formed '\#pragma omp target exit data' after |
560 | /// parsing of the associated statement. |
561 | StmtResult ActOnOpenMPTargetExitDataDirective(ArrayRef<OMPClause *> Clauses, |
562 | SourceLocation StartLoc, |
563 | SourceLocation EndLoc, |
564 | Stmt *AStmt); |
565 | /// Called on well-formed '\#pragma omp target parallel' after |
566 | /// parsing of the associated statement. |
567 | StmtResult ActOnOpenMPTargetParallelDirective(ArrayRef<OMPClause *> Clauses, |
568 | Stmt *AStmt, |
569 | SourceLocation StartLoc, |
570 | SourceLocation EndLoc); |
571 | /// Called on well-formed '\#pragma omp target parallel for' after |
572 | /// parsing of the associated statement. |
573 | StmtResult ActOnOpenMPTargetParallelForDirective( |
574 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
575 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
576 | /// Called on well-formed '\#pragma omp teams' after parsing of the |
577 | /// associated statement. |
578 | StmtResult ActOnOpenMPTeamsDirective(ArrayRef<OMPClause *> Clauses, |
579 | Stmt *AStmt, SourceLocation StartLoc, |
580 | SourceLocation EndLoc); |
581 | /// Called on well-formed '\#pragma omp teams loop' after parsing of the |
582 | /// associated statement. |
583 | StmtResult ActOnOpenMPTeamsGenericLoopDirective( |
584 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
585 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
586 | /// Called on well-formed '\#pragma omp target teams loop' after parsing of |
587 | /// the associated statement. |
588 | StmtResult ActOnOpenMPTargetTeamsGenericLoopDirective( |
589 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
590 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
591 | /// Called on well-formed '\#pragma omp parallel loop' after parsing of the |
592 | /// associated statement. |
593 | StmtResult ActOnOpenMPParallelGenericLoopDirective( |
594 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
595 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
596 | /// Called on well-formed '\#pragma omp target parallel loop' after parsing |
597 | /// of the associated statement. |
598 | StmtResult ActOnOpenMPTargetParallelGenericLoopDirective( |
599 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
600 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
601 | /// Called on well-formed '\#pragma omp cancellation point'. |
602 | StmtResult |
603 | ActOnOpenMPCancellationPointDirective(SourceLocation StartLoc, |
604 | SourceLocation EndLoc, |
605 | OpenMPDirectiveKind CancelRegion); |
606 | /// Called on well-formed '\#pragma omp cancel'. |
607 | StmtResult ActOnOpenMPCancelDirective(ArrayRef<OMPClause *> Clauses, |
608 | SourceLocation StartLoc, |
609 | SourceLocation EndLoc, |
610 | OpenMPDirectiveKind CancelRegion); |
611 | /// Called on well-formed '\#pragma omp taskloop' after parsing of the |
612 | /// associated statement. |
613 | StmtResult |
614 | ActOnOpenMPTaskLoopDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, |
615 | SourceLocation StartLoc, SourceLocation EndLoc, |
616 | VarsWithInheritedDSAType &VarsWithImplicitDSA); |
617 | /// Called on well-formed '\#pragma omp taskloop simd' after parsing of |
618 | /// the associated statement. |
619 | StmtResult ActOnOpenMPTaskLoopSimdDirective( |
620 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
621 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
622 | /// Called on well-formed '\#pragma omp master taskloop' after parsing of the |
623 | /// associated statement. |
624 | StmtResult ActOnOpenMPMasterTaskLoopDirective( |
625 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
626 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
627 | /// Called on well-formed '\#pragma omp master taskloop simd' after parsing of |
628 | /// the associated statement. |
629 | StmtResult ActOnOpenMPMasterTaskLoopSimdDirective( |
630 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
631 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
632 | /// Called on well-formed '\#pragma omp parallel master taskloop' after |
633 | /// parsing of the associated statement. |
634 | StmtResult ActOnOpenMPParallelMasterTaskLoopDirective( |
635 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
636 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
637 | /// Called on well-formed '\#pragma omp parallel master taskloop simd' after |
638 | /// parsing of the associated statement. |
639 | StmtResult ActOnOpenMPParallelMasterTaskLoopSimdDirective( |
640 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
641 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
642 | /// Called on well-formed '\#pragma omp masked taskloop' after parsing of the |
643 | /// associated statement. |
644 | StmtResult ActOnOpenMPMaskedTaskLoopDirective( |
645 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
646 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
647 | /// Called on well-formed '\#pragma omp masked taskloop simd' after parsing of |
648 | /// the associated statement. |
649 | StmtResult ActOnOpenMPMaskedTaskLoopSimdDirective( |
650 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
651 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
652 | /// Called on well-formed '\#pragma omp parallel masked taskloop' after |
653 | /// parsing of the associated statement. |
654 | StmtResult ActOnOpenMPParallelMaskedTaskLoopDirective( |
655 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
656 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
657 | /// Called on well-formed '\#pragma omp parallel masked taskloop simd' after |
658 | /// parsing of the associated statement. |
659 | StmtResult ActOnOpenMPParallelMaskedTaskLoopSimdDirective( |
660 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
661 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
662 | /// Called on well-formed '\#pragma omp distribute' after parsing |
663 | /// of the associated statement. |
664 | StmtResult |
665 | ActOnOpenMPDistributeDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, |
666 | SourceLocation StartLoc, SourceLocation EndLoc, |
667 | VarsWithInheritedDSAType &VarsWithImplicitDSA); |
668 | /// Called on well-formed '\#pragma omp target update'. |
669 | StmtResult ActOnOpenMPTargetUpdateDirective(ArrayRef<OMPClause *> Clauses, |
670 | SourceLocation StartLoc, |
671 | SourceLocation EndLoc, |
672 | Stmt *AStmt); |
673 | /// Called on well-formed '\#pragma omp distribute parallel for' after |
674 | /// parsing of the associated statement. |
675 | StmtResult ActOnOpenMPDistributeParallelForDirective( |
676 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
677 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
678 | /// Called on well-formed '\#pragma omp distribute parallel for simd' |
679 | /// after parsing of the associated statement. |
680 | StmtResult ActOnOpenMPDistributeParallelForSimdDirective( |
681 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
682 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
683 | /// Called on well-formed '\#pragma omp distribute simd' after |
684 | /// parsing of the associated statement. |
685 | StmtResult ActOnOpenMPDistributeSimdDirective( |
686 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
687 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
688 | /// Called on well-formed '\#pragma omp target parallel for simd' after |
689 | /// parsing of the associated statement. |
690 | StmtResult ActOnOpenMPTargetParallelForSimdDirective( |
691 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
692 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
693 | /// Called on well-formed '\#pragma omp target simd' after parsing of |
694 | /// the associated statement. |
695 | StmtResult |
696 | ActOnOpenMPTargetSimdDirective(ArrayRef<OMPClause *> Clauses, Stmt *AStmt, |
697 | SourceLocation StartLoc, SourceLocation EndLoc, |
698 | VarsWithInheritedDSAType &VarsWithImplicitDSA); |
699 | /// Called on well-formed '\#pragma omp teams distribute' after parsing of |
700 | /// the associated statement. |
701 | StmtResult ActOnOpenMPTeamsDistributeDirective( |
702 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
703 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
704 | /// Called on well-formed '\#pragma omp teams distribute simd' after parsing |
705 | /// of the associated statement. |
706 | StmtResult ActOnOpenMPTeamsDistributeSimdDirective( |
707 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
708 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
709 | /// Called on well-formed '\#pragma omp teams distribute parallel for simd' |
710 | /// after parsing of the associated statement. |
711 | StmtResult ActOnOpenMPTeamsDistributeParallelForSimdDirective( |
712 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
713 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
714 | /// Called on well-formed '\#pragma omp teams distribute parallel for' |
715 | /// after parsing of the associated statement. |
716 | StmtResult ActOnOpenMPTeamsDistributeParallelForDirective( |
717 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
718 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
719 | /// Called on well-formed '\#pragma omp target teams' after parsing of the |
720 | /// associated statement. |
721 | StmtResult ActOnOpenMPTargetTeamsDirective(ArrayRef<OMPClause *> Clauses, |
722 | Stmt *AStmt, |
723 | SourceLocation StartLoc, |
724 | SourceLocation EndLoc); |
725 | /// Called on well-formed '\#pragma omp target teams distribute' after parsing |
726 | /// of the associated statement. |
727 | StmtResult ActOnOpenMPTargetTeamsDistributeDirective( |
728 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
729 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
730 | /// Called on well-formed '\#pragma omp target teams distribute parallel for' |
731 | /// after parsing of the associated statement. |
732 | StmtResult ActOnOpenMPTargetTeamsDistributeParallelForDirective( |
733 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
734 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
735 | /// Called on well-formed '\#pragma omp target teams distribute parallel for |
736 | /// simd' after parsing of the associated statement. |
737 | StmtResult ActOnOpenMPTargetTeamsDistributeParallelForSimdDirective( |
738 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
739 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
740 | /// Called on well-formed '\#pragma omp target teams distribute simd' after |
741 | /// parsing of the associated statement. |
742 | StmtResult ActOnOpenMPTargetTeamsDistributeSimdDirective( |
743 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
744 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
745 | /// Called on well-formed '\#pragma omp interop'. |
746 | StmtResult ActOnOpenMPInteropDirective(ArrayRef<OMPClause *> Clauses, |
747 | SourceLocation StartLoc, |
748 | SourceLocation EndLoc); |
749 | /// Called on well-formed '\#pragma omp dispatch' after parsing of the |
750 | // /associated statement. |
751 | StmtResult ActOnOpenMPDispatchDirective(ArrayRef<OMPClause *> Clauses, |
752 | Stmt *AStmt, SourceLocation StartLoc, |
753 | SourceLocation EndLoc); |
754 | /// Called on well-formed '\#pragma omp masked' after parsing of the |
755 | // /associated statement. |
756 | StmtResult ActOnOpenMPMaskedDirective(ArrayRef<OMPClause *> Clauses, |
757 | Stmt *AStmt, SourceLocation StartLoc, |
758 | SourceLocation EndLoc); |
759 | |
760 | /// Called on well-formed '\#pragma omp loop' after parsing of the |
761 | /// associated statement. |
762 | StmtResult ActOnOpenMPGenericLoopDirective( |
763 | ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, |
764 | SourceLocation EndLoc, VarsWithInheritedDSAType &VarsWithImplicitDSA); |
765 | |
766 | /// Checks correctness of linear modifiers. |
767 | bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind, |
768 | SourceLocation LinLoc); |
769 | /// Checks that the specified declaration matches requirements for the linear |
770 | /// decls. |
771 | bool CheckOpenMPLinearDecl(const ValueDecl *D, SourceLocation ELoc, |
772 | OpenMPLinearClauseKind LinKind, QualType Type, |
773 | bool IsDeclareSimd = false); |
774 | |
775 | /// Called on well-formed '\#pragma omp declare simd' after parsing of |
776 | /// the associated method/function. |
777 | DeclGroupPtrTy ActOnOpenMPDeclareSimdDirective( |
778 | DeclGroupPtrTy DG, OMPDeclareSimdDeclAttr::BranchStateTy BS, |
779 | Expr *Simdlen, ArrayRef<Expr *> Uniforms, ArrayRef<Expr *> Aligneds, |
780 | ArrayRef<Expr *> Alignments, ArrayRef<Expr *> Linears, |
781 | ArrayRef<unsigned> LinModifiers, ArrayRef<Expr *> Steps, SourceRange SR); |
782 | |
783 | /// Checks '\#pragma omp declare variant' variant function and original |
784 | /// functions after parsing of the associated method/function. |
785 | /// \param DG Function declaration to which declare variant directive is |
786 | /// applied to. |
787 | /// \param VariantRef Expression that references the variant function, which |
788 | /// must be used instead of the original one, specified in \p DG. |
789 | /// \param TI The trait info object representing the match clause. |
790 | /// \param NumAppendArgs The number of omp_interop_t arguments to account for |
791 | /// in checking. |
792 | /// \returns std::nullopt, if the function/variant function are not compatible |
793 | /// with the pragma, pair of original function/variant ref expression |
794 | /// otherwise. |
795 | std::optional<std::pair<FunctionDecl *, Expr *>> |
796 | checkOpenMPDeclareVariantFunction(DeclGroupPtrTy DG, Expr *VariantRef, |
797 | OMPTraitInfo &TI, unsigned NumAppendArgs, |
798 | SourceRange SR); |
799 | |
800 | /// Called on well-formed '\#pragma omp declare variant' after parsing of |
801 | /// the associated method/function. |
802 | /// \param FD Function declaration to which declare variant directive is |
803 | /// applied to. |
804 | /// \param VariantRef Expression that references the variant function, which |
805 | /// must be used instead of the original one, specified in \p DG. |
806 | /// \param TI The context traits associated with the function variant. |
807 | /// \param AdjustArgsNothing The list of 'nothing' arguments. |
808 | /// \param AdjustArgsNeedDevicePtr The list of 'need_device_ptr' arguments. |
809 | /// \param AppendArgs The list of 'append_args' arguments. |
810 | /// \param AdjustArgsLoc The Location of an 'adjust_args' clause. |
811 | /// \param AppendArgsLoc The Location of an 'append_args' clause. |
812 | /// \param SR The SourceRange of the 'declare variant' directive. |
813 | void ActOnOpenMPDeclareVariantDirective( |
814 | FunctionDecl *FD, Expr *VariantRef, OMPTraitInfo &TI, |
815 | ArrayRef<Expr *> AdjustArgsNothing, |
816 | ArrayRef<Expr *> AdjustArgsNeedDevicePtr, |
817 | ArrayRef<OMPInteropInfo> AppendArgs, SourceLocation AdjustArgsLoc, |
818 | SourceLocation AppendArgsLoc, SourceRange SR); |
819 | |
820 | OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr, |
821 | SourceLocation StartLoc, |
822 | SourceLocation LParenLoc, |
823 | SourceLocation EndLoc); |
824 | /// Called on well-formed 'allocator' clause. |
825 | OMPClause *ActOnOpenMPAllocatorClause(Expr *Allocator, |
826 | SourceLocation StartLoc, |
827 | SourceLocation LParenLoc, |
828 | SourceLocation EndLoc); |
829 | /// Called on well-formed 'if' clause. |
830 | OMPClause *ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, |
831 | Expr *Condition, SourceLocation StartLoc, |
832 | SourceLocation LParenLoc, |
833 | SourceLocation NameModifierLoc, |
834 | SourceLocation ColonLoc, |
835 | SourceLocation EndLoc); |
836 | /// Called on well-formed 'final' clause. |
837 | OMPClause *ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, |
838 | SourceLocation LParenLoc, |
839 | SourceLocation EndLoc); |
840 | /// Called on well-formed 'num_threads' clause. |
841 | OMPClause *ActOnOpenMPNumThreadsClause(Expr *NumThreads, |
842 | SourceLocation StartLoc, |
843 | SourceLocation LParenLoc, |
844 | SourceLocation EndLoc); |
845 | /// Called on well-formed 'align' clause. |
846 | OMPClause *ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, |
847 | SourceLocation LParenLoc, |
848 | SourceLocation EndLoc); |
849 | /// Called on well-formed 'safelen' clause. |
850 | OMPClause *ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, |
851 | SourceLocation LParenLoc, |
852 | SourceLocation EndLoc); |
853 | /// Called on well-formed 'simdlen' clause. |
854 | OMPClause *ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, |
855 | SourceLocation LParenLoc, |
856 | SourceLocation EndLoc); |
857 | /// Called on well-form 'sizes' clause. |
858 | OMPClause *ActOnOpenMPSizesClause(ArrayRef<Expr *> SizeExprs, |
859 | SourceLocation StartLoc, |
860 | SourceLocation LParenLoc, |
861 | SourceLocation EndLoc); |
862 | /// Called on well-form 'full' clauses. |
863 | OMPClause *ActOnOpenMPFullClause(SourceLocation StartLoc, |
864 | SourceLocation EndLoc); |
865 | /// Called on well-form 'partial' clauses. |
866 | OMPClause *ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, |
867 | SourceLocation LParenLoc, |
868 | SourceLocation EndLoc); |
869 | /// Called on well-formed 'collapse' clause. |
870 | OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops, |
871 | SourceLocation StartLoc, |
872 | SourceLocation LParenLoc, |
873 | SourceLocation EndLoc); |
874 | /// Called on well-formed 'ordered' clause. |
875 | OMPClause * |
876 | ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, |
877 | SourceLocation LParenLoc = SourceLocation(), |
878 | Expr *NumForLoops = nullptr); |
879 | /// Called on well-formed 'grainsize' clause. |
880 | OMPClause *ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, |
881 | Expr *Size, SourceLocation StartLoc, |
882 | SourceLocation LParenLoc, |
883 | SourceLocation ModifierLoc, |
884 | SourceLocation EndLoc); |
885 | /// Called on well-formed 'num_tasks' clause. |
886 | OMPClause *ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, |
887 | Expr *NumTasks, SourceLocation StartLoc, |
888 | SourceLocation LParenLoc, |
889 | SourceLocation ModifierLoc, |
890 | SourceLocation EndLoc); |
891 | /// Called on well-formed 'hint' clause. |
892 | OMPClause *ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, |
893 | SourceLocation LParenLoc, |
894 | SourceLocation EndLoc); |
895 | /// Called on well-formed 'detach' clause. |
896 | OMPClause *ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, |
897 | SourceLocation LParenLoc, |
898 | SourceLocation EndLoc); |
899 | |
900 | OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind, unsigned Argument, |
901 | SourceLocation ArgumentLoc, |
902 | SourceLocation StartLoc, |
903 | SourceLocation LParenLoc, |
904 | SourceLocation EndLoc); |
905 | /// Called on well-formed 'when' clause. |
906 | OMPClause *ActOnOpenMPWhenClause(OMPTraitInfo &TI, SourceLocation StartLoc, |
907 | SourceLocation LParenLoc, |
908 | SourceLocation EndLoc); |
909 | /// Called on well-formed 'default' clause. |
910 | OMPClause *ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind, |
911 | SourceLocation KindLoc, |
912 | SourceLocation StartLoc, |
913 | SourceLocation LParenLoc, |
914 | SourceLocation EndLoc); |
915 | /// Called on well-formed 'proc_bind' clause. |
916 | OMPClause *ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, |
917 | SourceLocation KindLoc, |
918 | SourceLocation StartLoc, |
919 | SourceLocation LParenLoc, |
920 | SourceLocation EndLoc); |
921 | /// Called on well-formed 'order' clause. |
922 | OMPClause *ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, |
923 | OpenMPOrderClauseKind Kind, |
924 | SourceLocation StartLoc, |
925 | SourceLocation LParenLoc, |
926 | SourceLocation MLoc, SourceLocation KindLoc, |
927 | SourceLocation EndLoc); |
928 | /// Called on well-formed 'update' clause. |
929 | OMPClause *ActOnOpenMPUpdateClause(OpenMPDependClauseKind Kind, |
930 | SourceLocation KindLoc, |
931 | SourceLocation StartLoc, |
932 | SourceLocation LParenLoc, |
933 | SourceLocation EndLoc); |
934 | |
935 | OMPClause *ActOnOpenMPSingleExprWithArgClause( |
936 | OpenMPClauseKind Kind, ArrayRef<unsigned> Arguments, Expr *Expr, |
937 | SourceLocation StartLoc, SourceLocation LParenLoc, |
938 | ArrayRef<SourceLocation> ArgumentsLoc, SourceLocation DelimLoc, |
939 | SourceLocation EndLoc); |
940 | /// Called on well-formed 'schedule' clause. |
941 | OMPClause *ActOnOpenMPScheduleClause( |
942 | OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, |
943 | OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, |
944 | SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, |
945 | SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc); |
946 | |
947 | OMPClause *ActOnOpenMPClause(OpenMPClauseKind Kind, SourceLocation StartLoc, |
948 | SourceLocation EndLoc); |
949 | /// Called on well-formed 'nowait' clause. |
950 | OMPClause *ActOnOpenMPNowaitClause(SourceLocation StartLoc, |
951 | SourceLocation EndLoc); |
952 | /// Called on well-formed 'untied' clause. |
953 | OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc, |
954 | SourceLocation EndLoc); |
955 | /// Called on well-formed 'mergeable' clause. |
956 | OMPClause *ActOnOpenMPMergeableClause(SourceLocation StartLoc, |
957 | SourceLocation EndLoc); |
958 | /// Called on well-formed 'read' clause. |
959 | OMPClause *ActOnOpenMPReadClause(SourceLocation StartLoc, |
960 | SourceLocation EndLoc); |
961 | /// Called on well-formed 'write' clause. |
962 | OMPClause *ActOnOpenMPWriteClause(SourceLocation StartLoc, |
963 | SourceLocation EndLoc); |
964 | /// Called on well-formed 'update' clause. |
965 | OMPClause *ActOnOpenMPUpdateClause(SourceLocation StartLoc, |
966 | SourceLocation EndLoc); |
967 | /// Called on well-formed 'capture' clause. |
968 | OMPClause *ActOnOpenMPCaptureClause(SourceLocation StartLoc, |
969 | SourceLocation EndLoc); |
970 | /// Called on well-formed 'compare' clause. |
971 | OMPClause *ActOnOpenMPCompareClause(SourceLocation StartLoc, |
972 | SourceLocation EndLoc); |
973 | /// Called on well-formed 'fail' clause. |
974 | OMPClause *ActOnOpenMPFailClause(SourceLocation StartLoc, |
975 | SourceLocation EndLoc); |
976 | OMPClause *ActOnOpenMPFailClause(OpenMPClauseKind Kind, |
977 | SourceLocation KindLoc, |
978 | SourceLocation StartLoc, |
979 | SourceLocation LParenLoc, |
980 | SourceLocation EndLoc); |
981 | |
982 | /// Called on well-formed 'seq_cst' clause. |
983 | OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc, |
984 | SourceLocation EndLoc); |
985 | /// Called on well-formed 'acq_rel' clause. |
986 | OMPClause *ActOnOpenMPAcqRelClause(SourceLocation StartLoc, |
987 | SourceLocation EndLoc); |
988 | /// Called on well-formed 'acquire' clause. |
989 | OMPClause *ActOnOpenMPAcquireClause(SourceLocation StartLoc, |
990 | SourceLocation EndLoc); |
991 | /// Called on well-formed 'release' clause. |
992 | OMPClause *ActOnOpenMPReleaseClause(SourceLocation StartLoc, |
993 | SourceLocation EndLoc); |
994 | /// Called on well-formed 'relaxed' clause. |
995 | OMPClause *ActOnOpenMPRelaxedClause(SourceLocation StartLoc, |
996 | SourceLocation EndLoc); |
997 | /// Called on well-formed 'weak' clause. |
998 | OMPClause *ActOnOpenMPWeakClause(SourceLocation StartLoc, |
999 | SourceLocation EndLoc); |
1000 | |
1001 | /// Called on well-formed 'init' clause. |
1002 | OMPClause * |
1003 | ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, |
1004 | SourceLocation StartLoc, SourceLocation LParenLoc, |
1005 | SourceLocation VarLoc, SourceLocation EndLoc); |
1006 | |
1007 | /// Called on well-formed 'use' clause. |
1008 | OMPClause *ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, |
1009 | SourceLocation LParenLoc, |
1010 | SourceLocation VarLoc, SourceLocation EndLoc); |
1011 | |
1012 | /// Called on well-formed 'destroy' clause. |
1013 | OMPClause *ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, |
1014 | SourceLocation LParenLoc, |
1015 | SourceLocation VarLoc, |
1016 | SourceLocation EndLoc); |
1017 | /// Called on well-formed 'novariants' clause. |
1018 | OMPClause *ActOnOpenMPNovariantsClause(Expr *Condition, |
1019 | SourceLocation StartLoc, |
1020 | SourceLocation LParenLoc, |
1021 | SourceLocation EndLoc); |
1022 | /// Called on well-formed 'nocontext' clause. |
1023 | OMPClause *ActOnOpenMPNocontextClause(Expr *Condition, |
1024 | SourceLocation StartLoc, |
1025 | SourceLocation LParenLoc, |
1026 | SourceLocation EndLoc); |
1027 | /// Called on well-formed 'filter' clause. |
1028 | OMPClause *ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, |
1029 | SourceLocation LParenLoc, |
1030 | SourceLocation EndLoc); |
1031 | /// Called on well-formed 'threads' clause. |
1032 | OMPClause *ActOnOpenMPThreadsClause(SourceLocation StartLoc, |
1033 | SourceLocation EndLoc); |
1034 | /// Called on well-formed 'simd' clause. |
1035 | OMPClause *ActOnOpenMPSIMDClause(SourceLocation StartLoc, |
1036 | SourceLocation EndLoc); |
1037 | /// Called on well-formed 'nogroup' clause. |
1038 | OMPClause *ActOnOpenMPNogroupClause(SourceLocation StartLoc, |
1039 | SourceLocation EndLoc); |
1040 | /// Called on well-formed 'unified_address' clause. |
1041 | OMPClause *ActOnOpenMPUnifiedAddressClause(SourceLocation StartLoc, |
1042 | SourceLocation EndLoc); |
1043 | |
1044 | /// Called on well-formed 'unified_address' clause. |
1045 | OMPClause *ActOnOpenMPUnifiedSharedMemoryClause(SourceLocation StartLoc, |
1046 | SourceLocation EndLoc); |
1047 | |
1048 | /// Called on well-formed 'reverse_offload' clause. |
1049 | OMPClause *ActOnOpenMPReverseOffloadClause(SourceLocation StartLoc, |
1050 | SourceLocation EndLoc); |
1051 | |
1052 | /// Called on well-formed 'dynamic_allocators' clause. |
1053 | OMPClause *ActOnOpenMPDynamicAllocatorsClause(SourceLocation StartLoc, |
1054 | SourceLocation EndLoc); |
1055 | |
1056 | /// Called on well-formed 'atomic_default_mem_order' clause. |
1057 | OMPClause *ActOnOpenMPAtomicDefaultMemOrderClause( |
1058 | OpenMPAtomicDefaultMemOrderClauseKind Kind, SourceLocation KindLoc, |
1059 | SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); |
1060 | |
1061 | /// Called on well-formed 'at' clause. |
1062 | OMPClause *ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, |
1063 | SourceLocation KindLoc, |
1064 | SourceLocation StartLoc, |
1065 | SourceLocation LParenLoc, |
1066 | SourceLocation EndLoc); |
1067 | |
1068 | /// Called on well-formed 'severity' clause. |
1069 | OMPClause *ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, |
1070 | SourceLocation KindLoc, |
1071 | SourceLocation StartLoc, |
1072 | SourceLocation LParenLoc, |
1073 | SourceLocation EndLoc); |
1074 | |
1075 | /// Called on well-formed 'message' clause. |
1076 | /// passing string for message. |
1077 | OMPClause *ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, |
1078 | SourceLocation LParenLoc, |
1079 | SourceLocation EndLoc); |
1080 | |
1081 | /// Data used for processing a list of variables in OpenMP clauses. |
1082 | struct OpenMPVarListDataTy final { |
1083 | Expr *DepModOrTailExpr = nullptr; |
1084 | Expr *IteratorExpr = nullptr; |
1085 | SourceLocation ColonLoc; |
1086 | SourceLocation RLoc; |
1087 | CXXScopeSpec ReductionOrMapperIdScopeSpec; |
1088 | DeclarationNameInfo ReductionOrMapperId; |
1089 | int = -1; ///< Additional modifier for linear, map, depend or |
1090 | ///< lastprivate clause. |
1091 | SmallVector<OpenMPMapModifierKind, NumberOfOMPMapClauseModifiers> |
1092 | MapTypeModifiers; |
1093 | SmallVector<SourceLocation, NumberOfOMPMapClauseModifiers> |
1094 | MapTypeModifiersLoc; |
1095 | SmallVector<OpenMPMotionModifierKind, NumberOfOMPMotionModifiers> |
1096 | MotionModifiers; |
1097 | SmallVector<SourceLocation, NumberOfOMPMotionModifiers> MotionModifiersLoc; |
1098 | bool IsMapTypeImplicit = false; |
1099 | SourceLocation ; |
1100 | SourceLocation OmpAllMemoryLoc; |
1101 | SourceLocation |
1102 | StepModifierLoc; /// 'step' modifier location for linear clause |
1103 | }; |
1104 | |
1105 | OMPClause *ActOnOpenMPVarListClause(OpenMPClauseKind Kind, |
1106 | ArrayRef<Expr *> Vars, |
1107 | const OMPVarListLocTy &Locs, |
1108 | OpenMPVarListDataTy &Data); |
1109 | /// Called on well-formed 'inclusive' clause. |
1110 | OMPClause *ActOnOpenMPInclusiveClause(ArrayRef<Expr *> VarList, |
1111 | SourceLocation StartLoc, |
1112 | SourceLocation LParenLoc, |
1113 | SourceLocation EndLoc); |
1114 | /// Called on well-formed 'exclusive' clause. |
1115 | OMPClause *ActOnOpenMPExclusiveClause(ArrayRef<Expr *> VarList, |
1116 | SourceLocation StartLoc, |
1117 | SourceLocation LParenLoc, |
1118 | SourceLocation EndLoc); |
1119 | /// Called on well-formed 'allocate' clause. |
1120 | OMPClause * |
1121 | ActOnOpenMPAllocateClause(Expr *Allocator, ArrayRef<Expr *> VarList, |
1122 | SourceLocation StartLoc, SourceLocation ColonLoc, |
1123 | SourceLocation LParenLoc, SourceLocation EndLoc); |
1124 | /// Called on well-formed 'private' clause. |
1125 | OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList, |
1126 | SourceLocation StartLoc, |
1127 | SourceLocation LParenLoc, |
1128 | SourceLocation EndLoc); |
1129 | /// Called on well-formed 'firstprivate' clause. |
1130 | OMPClause *ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList, |
1131 | SourceLocation StartLoc, |
1132 | SourceLocation LParenLoc, |
1133 | SourceLocation EndLoc); |
1134 | /// Called on well-formed 'lastprivate' clause. |
1135 | OMPClause *ActOnOpenMPLastprivateClause( |
1136 | ArrayRef<Expr *> VarList, OpenMPLastprivateModifier LPKind, |
1137 | SourceLocation LPKindLoc, SourceLocation ColonLoc, |
1138 | SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); |
1139 | /// Called on well-formed 'shared' clause. |
1140 | OMPClause *ActOnOpenMPSharedClause(ArrayRef<Expr *> VarList, |
1141 | SourceLocation StartLoc, |
1142 | SourceLocation LParenLoc, |
1143 | SourceLocation EndLoc); |
1144 | /// Called on well-formed 'reduction' clause. |
1145 | OMPClause *ActOnOpenMPReductionClause( |
1146 | ArrayRef<Expr *> VarList, OpenMPReductionClauseModifier Modifier, |
1147 | SourceLocation StartLoc, SourceLocation LParenLoc, |
1148 | SourceLocation ModifierLoc, SourceLocation ColonLoc, |
1149 | SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, |
1150 | const DeclarationNameInfo &ReductionId, |
1151 | ArrayRef<Expr *> UnresolvedReductions = std::nullopt); |
1152 | /// Called on well-formed 'task_reduction' clause. |
1153 | OMPClause *ActOnOpenMPTaskReductionClause( |
1154 | ArrayRef<Expr *> VarList, SourceLocation StartLoc, |
1155 | SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, |
1156 | CXXScopeSpec &ReductionIdScopeSpec, |
1157 | const DeclarationNameInfo &ReductionId, |
1158 | ArrayRef<Expr *> UnresolvedReductions = std::nullopt); |
1159 | /// Called on well-formed 'in_reduction' clause. |
1160 | OMPClause *ActOnOpenMPInReductionClause( |
1161 | ArrayRef<Expr *> VarList, SourceLocation StartLoc, |
1162 | SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, |
1163 | CXXScopeSpec &ReductionIdScopeSpec, |
1164 | const DeclarationNameInfo &ReductionId, |
1165 | ArrayRef<Expr *> UnresolvedReductions = std::nullopt); |
1166 | /// Called on well-formed 'linear' clause. |
1167 | OMPClause *ActOnOpenMPLinearClause( |
1168 | ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc, |
1169 | SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, |
1170 | SourceLocation LinLoc, SourceLocation ColonLoc, |
1171 | SourceLocation StepModifierLoc, SourceLocation EndLoc); |
1172 | /// Called on well-formed 'aligned' clause. |
1173 | OMPClause *ActOnOpenMPAlignedClause(ArrayRef<Expr *> VarList, Expr *Alignment, |
1174 | SourceLocation StartLoc, |
1175 | SourceLocation LParenLoc, |
1176 | SourceLocation ColonLoc, |
1177 | SourceLocation EndLoc); |
1178 | /// Called on well-formed 'copyin' clause. |
1179 | OMPClause *ActOnOpenMPCopyinClause(ArrayRef<Expr *> VarList, |
1180 | SourceLocation StartLoc, |
1181 | SourceLocation LParenLoc, |
1182 | SourceLocation EndLoc); |
1183 | /// Called on well-formed 'copyprivate' clause. |
1184 | OMPClause *ActOnOpenMPCopyprivateClause(ArrayRef<Expr *> VarList, |
1185 | SourceLocation StartLoc, |
1186 | SourceLocation LParenLoc, |
1187 | SourceLocation EndLoc); |
1188 | /// Called on well-formed 'flush' pseudo clause. |
1189 | OMPClause *ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList, |
1190 | SourceLocation StartLoc, |
1191 | SourceLocation LParenLoc, |
1192 | SourceLocation EndLoc); |
1193 | /// Called on well-formed 'depobj' pseudo clause. |
1194 | OMPClause *ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, |
1195 | SourceLocation LParenLoc, |
1196 | SourceLocation EndLoc); |
1197 | /// Called on well-formed 'depend' clause. |
1198 | OMPClause *ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, |
1199 | Expr *DepModifier, |
1200 | ArrayRef<Expr *> VarList, |
1201 | SourceLocation StartLoc, |
1202 | SourceLocation LParenLoc, |
1203 | SourceLocation EndLoc); |
1204 | /// Called on well-formed 'device' clause. |
1205 | OMPClause *ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, |
1206 | Expr *Device, SourceLocation StartLoc, |
1207 | SourceLocation LParenLoc, |
1208 | SourceLocation ModifierLoc, |
1209 | SourceLocation EndLoc); |
1210 | /// Called on well-formed 'map' clause. |
1211 | OMPClause *ActOnOpenMPMapClause( |
1212 | Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, |
1213 | ArrayRef<SourceLocation> MapTypeModifiersLoc, |
1214 | CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, |
1215 | OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, |
1216 | SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, |
1217 | const OMPVarListLocTy &Locs, bool NoDiagnose = false, |
1218 | ArrayRef<Expr *> UnresolvedMappers = std::nullopt); |
1219 | /// Called on well-formed 'num_teams' clause. |
1220 | OMPClause *ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, |
1221 | SourceLocation LParenLoc, |
1222 | SourceLocation EndLoc); |
1223 | /// Called on well-formed 'thread_limit' clause. |
1224 | OMPClause *ActOnOpenMPThreadLimitClause(Expr *ThreadLimit, |
1225 | SourceLocation StartLoc, |
1226 | SourceLocation LParenLoc, |
1227 | SourceLocation EndLoc); |
1228 | /// Called on well-formed 'priority' clause. |
1229 | OMPClause *ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, |
1230 | SourceLocation LParenLoc, |
1231 | SourceLocation EndLoc); |
1232 | /// Called on well-formed 'dist_schedule' clause. |
1233 | OMPClause *ActOnOpenMPDistScheduleClause( |
1234 | OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, |
1235 | SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, |
1236 | SourceLocation CommaLoc, SourceLocation EndLoc); |
1237 | /// Called on well-formed 'defaultmap' clause. |
1238 | OMPClause *ActOnOpenMPDefaultmapClause( |
1239 | OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, |
1240 | SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, |
1241 | SourceLocation KindLoc, SourceLocation EndLoc); |
1242 | /// Called on well-formed 'to' clause. |
1243 | OMPClause * |
1244 | ActOnOpenMPToClause(ArrayRef<OpenMPMotionModifierKind> MotionModifiers, |
1245 | ArrayRef<SourceLocation> MotionModifiersLoc, |
1246 | CXXScopeSpec &MapperIdScopeSpec, |
1247 | DeclarationNameInfo &MapperId, SourceLocation ColonLoc, |
1248 | ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs, |
1249 | ArrayRef<Expr *> UnresolvedMappers = std::nullopt); |
1250 | /// Called on well-formed 'from' clause. |
1251 | OMPClause * |
1252 | ActOnOpenMPFromClause(ArrayRef<OpenMPMotionModifierKind> MotionModifiers, |
1253 | ArrayRef<SourceLocation> MotionModifiersLoc, |
1254 | CXXScopeSpec &MapperIdScopeSpec, |
1255 | DeclarationNameInfo &MapperId, SourceLocation ColonLoc, |
1256 | ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs, |
1257 | ArrayRef<Expr *> UnresolvedMappers = std::nullopt); |
1258 | /// Called on well-formed 'use_device_ptr' clause. |
1259 | OMPClause *ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList, |
1260 | const OMPVarListLocTy &Locs); |
1261 | /// Called on well-formed 'use_device_addr' clause. |
1262 | OMPClause *ActOnOpenMPUseDeviceAddrClause(ArrayRef<Expr *> VarList, |
1263 | const OMPVarListLocTy &Locs); |
1264 | /// Called on well-formed 'is_device_ptr' clause. |
1265 | OMPClause *ActOnOpenMPIsDevicePtrClause(ArrayRef<Expr *> VarList, |
1266 | const OMPVarListLocTy &Locs); |
1267 | /// Called on well-formed 'has_device_addr' clause. |
1268 | OMPClause *ActOnOpenMPHasDeviceAddrClause(ArrayRef<Expr *> VarList, |
1269 | const OMPVarListLocTy &Locs); |
1270 | /// Called on well-formed 'nontemporal' clause. |
1271 | OMPClause *ActOnOpenMPNontemporalClause(ArrayRef<Expr *> VarList, |
1272 | SourceLocation StartLoc, |
1273 | SourceLocation LParenLoc, |
1274 | SourceLocation EndLoc); |
1275 | |
1276 | /// Data for list of allocators. |
1277 | struct UsesAllocatorsData { |
1278 | /// Allocator. |
1279 | Expr *Allocator = nullptr; |
1280 | /// Allocator traits. |
1281 | Expr *AllocatorTraits = nullptr; |
1282 | /// Locations of '(' and ')' symbols. |
1283 | SourceLocation LParenLoc, RParenLoc; |
1284 | }; |
1285 | /// Called on well-formed 'uses_allocators' clause. |
1286 | OMPClause *ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, |
1287 | SourceLocation LParenLoc, |
1288 | SourceLocation EndLoc, |
1289 | ArrayRef<UsesAllocatorsData> Data); |
1290 | /// Called on well-formed 'affinity' clause. |
1291 | OMPClause *ActOnOpenMPAffinityClause(SourceLocation StartLoc, |
1292 | SourceLocation LParenLoc, |
1293 | SourceLocation ColonLoc, |
1294 | SourceLocation EndLoc, Expr *Modifier, |
1295 | ArrayRef<Expr *> Locators); |
1296 | /// Called on a well-formed 'bind' clause. |
1297 | OMPClause *ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, |
1298 | SourceLocation KindLoc, |
1299 | SourceLocation StartLoc, |
1300 | SourceLocation LParenLoc, |
1301 | SourceLocation EndLoc); |
1302 | |
1303 | /// Called on a well-formed 'ompx_dyn_cgroup_mem' clause. |
1304 | OMPClause *ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, |
1305 | SourceLocation LParenLoc, |
1306 | SourceLocation EndLoc); |
1307 | |
1308 | /// Called on well-formed 'doacross' clause. |
1309 | OMPClause * |
1310 | ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, |
1311 | SourceLocation DepLoc, SourceLocation ColonLoc, |
1312 | ArrayRef<Expr *> VarList, SourceLocation StartLoc, |
1313 | SourceLocation LParenLoc, SourceLocation EndLoc); |
1314 | |
1315 | /// Called on a well-formed 'ompx_attribute' clause. |
1316 | OMPClause *ActOnOpenMPXAttributeClause(ArrayRef<const Attr *> Attrs, |
1317 | SourceLocation StartLoc, |
1318 | SourceLocation LParenLoc, |
1319 | SourceLocation EndLoc); |
1320 | |
1321 | /// Called on a well-formed 'ompx_bare' clause. |
1322 | OMPClause *ActOnOpenMPXBareClause(SourceLocation StartLoc, |
1323 | SourceLocation EndLoc); |
1324 | |
1325 | ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, |
1326 | Expr *LowerBound, |
1327 | SourceLocation ColonLocFirst, |
1328 | SourceLocation ColonLocSecond, |
1329 | Expr *Length, Expr *Stride, |
1330 | SourceLocation RBLoc); |
1331 | ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, |
1332 | SourceLocation RParenLoc, |
1333 | ArrayRef<Expr *> Dims, |
1334 | ArrayRef<SourceRange> Brackets); |
1335 | |
1336 | /// Data structure for iterator expression. |
1337 | struct OMPIteratorData { |
1338 | IdentifierInfo *DeclIdent = nullptr; |
1339 | SourceLocation DeclIdentLoc; |
1340 | ParsedType Type; |
1341 | OMPIteratorExpr::IteratorRange Range; |
1342 | SourceLocation AssignLoc; |
1343 | SourceLocation ColonLoc; |
1344 | SourceLocation SecColonLoc; |
1345 | }; |
1346 | |
1347 | ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, |
1348 | SourceLocation LLoc, SourceLocation RLoc, |
1349 | ArrayRef<OMPIteratorData> Data); |
1350 | |
1351 | private: |
1352 | void *VarDataSharingAttributesStack; |
1353 | |
1354 | /// Number of nested '#pragma omp declare target' directives. |
1355 | SmallVector<DeclareTargetContextInfo, 4> DeclareTargetNesting; |
1356 | |
1357 | /// Initialization of data-sharing attributes stack. |
1358 | void InitDataSharingAttributesStack(); |
1359 | void DestroyDataSharingAttributesStack(); |
1360 | |
1361 | /// Returns OpenMP nesting level for current directive. |
1362 | unsigned getOpenMPNestingLevel() const; |
1363 | |
1364 | /// Adjusts the function scopes index for the target-based regions. |
1365 | void adjustOpenMPTargetScopeIndex(unsigned &FunctionScopesIndex, |
1366 | unsigned Level) const; |
1367 | |
1368 | /// Returns the number of scopes associated with the construct on the given |
1369 | /// OpenMP level. |
1370 | int getNumberOfConstructScopes(unsigned Level) const; |
1371 | |
1372 | /// Push new OpenMP function region for non-capturing function. |
1373 | void pushOpenMPFunctionRegion(); |
1374 | |
1375 | /// Pop OpenMP function region for non-capturing function. |
1376 | void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI); |
1377 | |
1378 | /// Analyzes and checks a loop nest for use by a loop transformation. |
1379 | /// |
1380 | /// \param Kind The loop transformation directive kind. |
1381 | /// \param NumLoops How many nested loops the directive is expecting. |
1382 | /// \param AStmt Associated statement of the transformation directive. |
1383 | /// \param LoopHelpers [out] The loop analysis result. |
1384 | /// \param Body [out] The body code nested in \p NumLoops loop. |
1385 | /// \param OriginalInits [out] Collection of statements and declarations that |
1386 | /// must have been executed/declared before entering the |
1387 | /// loop. |
1388 | /// |
1389 | /// \return Whether there was any error. |
1390 | bool checkTransformableLoopNest( |
1391 | OpenMPDirectiveKind Kind, Stmt *AStmt, int NumLoops, |
1392 | SmallVectorImpl<OMPLoopBasedDirective::HelperExprs> &LoopHelpers, |
1393 | Stmt *&Body, |
1394 | SmallVectorImpl<SmallVector<llvm::PointerUnion<Stmt *, Decl *>, 0>> |
1395 | &OriginalInits); |
1396 | |
1397 | /// Helper to keep information about the current `omp begin/end declare |
1398 | /// variant` nesting. |
1399 | struct OMPDeclareVariantScope { |
1400 | /// The associated OpenMP context selector. |
1401 | OMPTraitInfo *TI; |
1402 | |
1403 | /// The associated OpenMP context selector mangling. |
1404 | std::string NameSuffix; |
1405 | |
1406 | OMPDeclareVariantScope(OMPTraitInfo &TI); |
1407 | }; |
1408 | |
1409 | /// Return the OMPTraitInfo for the surrounding scope, if any. |
1410 | OMPTraitInfo *getOMPTraitInfoForSurroundingScope() { |
1411 | return OMPDeclareVariantScopes.empty() ? nullptr |
1412 | : OMPDeclareVariantScopes.back().TI; |
1413 | } |
1414 | |
1415 | /// The current `omp begin/end declare variant` scopes. |
1416 | SmallVector<OMPDeclareVariantScope, 4> OMPDeclareVariantScopes; |
1417 | |
1418 | /// The current `omp begin/end assumes` scopes. |
1419 | SmallVector<OMPAssumeAttr *, 4> OMPAssumeScoped; |
1420 | |
1421 | /// All `omp assumes` we encountered so far. |
1422 | SmallVector<OMPAssumeAttr *, 4> OMPAssumeGlobal; |
1423 | |
1424 | /// OMPD_loop is mapped to OMPD_for, OMPD_distribute or OMPD_simd depending |
1425 | /// on the parameter of the bind clause. In the methods for the |
1426 | /// mapped directives, check the parameters of the lastprivate clause. |
1427 | bool checkLastPrivateForMappedDirectives(ArrayRef<OMPClause *> Clauses); |
1428 | /// Depending on the bind clause of OMPD_loop map the directive to new |
1429 | /// directives. |
1430 | /// 1) loop bind(parallel) --> OMPD_for |
1431 | /// 2) loop bind(teams) --> OMPD_distribute |
1432 | /// 3) loop bind(thread) --> OMPD_simd |
1433 | /// This is being handled in Sema instead of Codegen because of the need for |
1434 | /// rigorous semantic checking in the new mapped directives. |
1435 | bool mapLoopConstruct(llvm::SmallVector<OMPClause *> &ClausesWithoutBind, |
1436 | ArrayRef<OMPClause *> Clauses, |
1437 | OpenMPBindClauseKind &BindKind, |
1438 | OpenMPDirectiveKind &Kind, |
1439 | OpenMPDirectiveKind &PrevMappedDirective, |
1440 | SourceLocation StartLoc, SourceLocation EndLoc, |
1441 | const DeclarationNameInfo &DirName, |
1442 | OpenMPDirectiveKind CancelRegion); |
1443 | }; |
1444 | |
1445 | } // namespace clang |
1446 | |
1447 | #endif // LLVM_CLANG_SEMA_SEMAOPENMP_H |
1448 | |