1 //===--- OpenMPKinds.h - OpenMP enums ---------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 /// Defines some OpenMP-specific enums and functions.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H
15 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Frontend/OpenMP/OMPConstants.h"
22 /// OpenMP directives.
23 using OpenMPDirectiveKind = llvm::omp::Directive;
26 enum OpenMPClauseKind {
27 #define OPENMP_CLAUSE(Name, Class) \
29 #include "clang/Basic/OpenMPKinds.def"
37 /// OpenMP attributes for 'schedule' clause.
38 enum OpenMPScheduleClauseKind {
39 #define OPENMP_SCHEDULE_KIND(Name) \
41 #include "clang/Basic/OpenMPKinds.def"
45 /// OpenMP modifiers for 'schedule' clause.
46 enum OpenMPScheduleClauseModifier {
47 OMPC_SCHEDULE_MODIFIER_unknown = OMPC_SCHEDULE_unknown,
48 #define OPENMP_SCHEDULE_MODIFIER(Name) \
49 OMPC_SCHEDULE_MODIFIER_##Name,
50 #include "clang/Basic/OpenMPKinds.def"
51 OMPC_SCHEDULE_MODIFIER_last
54 /// OpenMP modifiers for 'device' clause.
55 enum OpenMPDeviceClauseModifier {
56 #define OPENMP_DEVICE_MODIFIER(Name) OMPC_DEVICE_##Name,
57 #include "clang/Basic/OpenMPKinds.def"
61 /// OpenMP attributes for 'depend' clause.
62 enum OpenMPDependClauseKind {
63 #define OPENMP_DEPEND_KIND(Name) \
65 #include "clang/Basic/OpenMPKinds.def"
69 /// OpenMP attributes for 'linear' clause.
70 enum OpenMPLinearClauseKind {
71 #define OPENMP_LINEAR_KIND(Name) \
73 #include "clang/Basic/OpenMPKinds.def"
77 /// OpenMP mapping kind for 'map' clause.
78 enum OpenMPMapClauseKind {
79 #define OPENMP_MAP_KIND(Name) \
81 #include "clang/Basic/OpenMPKinds.def"
85 /// OpenMP modifier kind for 'map' clause.
86 enum OpenMPMapModifierKind {
87 OMPC_MAP_MODIFIER_unknown = OMPC_MAP_unknown,
88 #define OPENMP_MAP_MODIFIER_KIND(Name) \
89 OMPC_MAP_MODIFIER_##Name,
90 #include "clang/Basic/OpenMPKinds.def"
91 OMPC_MAP_MODIFIER_last
94 /// OpenMP modifier kind for 'to' clause.
95 enum OpenMPToModifierKind {
96 #define OPENMP_TO_MODIFIER_KIND(Name) \
97 OMPC_TO_MODIFIER_##Name,
98 #include "clang/Basic/OpenMPKinds.def"
99 OMPC_TO_MODIFIER_unknown
102 /// OpenMP modifier kind for 'from' clause.
103 enum OpenMPFromModifierKind {
104 #define OPENMP_FROM_MODIFIER_KIND(Name) \
105 OMPC_FROM_MODIFIER_##Name,
106 #include "clang/Basic/OpenMPKinds.def"
107 OMPC_FROM_MODIFIER_unknown
110 /// OpenMP attributes for 'dist_schedule' clause.
111 enum OpenMPDistScheduleClauseKind {
112 #define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name,
113 #include "clang/Basic/OpenMPKinds.def"
114 OMPC_DIST_SCHEDULE_unknown
117 /// OpenMP attributes for 'defaultmap' clause.
118 enum OpenMPDefaultmapClauseKind {
119 #define OPENMP_DEFAULTMAP_KIND(Name) \
120 OMPC_DEFAULTMAP_##Name,
121 #include "clang/Basic/OpenMPKinds.def"
122 OMPC_DEFAULTMAP_unknown
125 /// OpenMP modifiers for 'defaultmap' clause.
126 enum OpenMPDefaultmapClauseModifier {
127 OMPC_DEFAULTMAP_MODIFIER_unknown = OMPC_DEFAULTMAP_unknown,
128 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
129 OMPC_DEFAULTMAP_MODIFIER_##Name,
130 #include "clang/Basic/OpenMPKinds.def"
131 OMPC_DEFAULTMAP_MODIFIER_last
134 /// OpenMP attributes for 'atomic_default_mem_order' clause.
135 enum OpenMPAtomicDefaultMemOrderClauseKind {
136 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
137 OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name,
138 #include "clang/Basic/OpenMPKinds.def"
139 OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
142 /// OpenMP device type for 'device_type' clause.
143 enum OpenMPDeviceType {
144 #define OPENMP_DEVICE_TYPE_KIND(Name) \
145 OMPC_DEVICE_TYPE_##Name,
146 #include "clang/Basic/OpenMPKinds.def"
147 OMPC_DEVICE_TYPE_unknown
150 /// OpenMP 'lastprivate' clause modifier.
151 enum OpenMPLastprivateModifier {
152 #define OPENMP_LASTPRIVATE_KIND(Name) OMPC_LASTPRIVATE_##Name,
153 #include "clang/Basic/OpenMPKinds.def"
154 OMPC_LASTPRIVATE_unknown,
157 /// OpenMP attributes for 'order' clause.
158 enum OpenMPOrderClauseKind {
159 #define OPENMP_ORDER_KIND(Name) OMPC_ORDER_##Name,
160 #include "clang/Basic/OpenMPKinds.def"
164 /// Scheduling data for loop-based OpenMP directives.
165 struct OpenMPScheduleTy final {
166 OpenMPScheduleClauseKind Schedule = OMPC_SCHEDULE_unknown;
167 OpenMPScheduleClauseModifier M1 = OMPC_SCHEDULE_MODIFIER_unknown;
168 OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown;
171 OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
172 const char *getOpenMPClauseName(OpenMPClauseKind Kind);
174 unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str);
175 const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);
177 bool isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
178 OpenMPClauseKind CKind,
179 unsigned OpenMPVersion);
181 /// Checks if the specified directive is a directive with an associated
183 /// \param DKind Specified directive.
184 /// \return true - the directive is a loop-associated directive like 'omp simd'
185 /// or 'omp for' directive, otherwise - false.
186 bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind);
188 /// Checks if the specified directive is a worksharing directive.
189 /// \param DKind Specified directive.
190 /// \return true - the directive is a worksharing directive like 'omp for',
191 /// otherwise - false.
192 bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind);
194 /// Checks if the specified directive is a taskloop directive.
195 /// \param DKind Specified directive.
196 /// \return true - the directive is a worksharing directive like 'omp taskloop',
197 /// otherwise - false.
198 bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind);
200 /// Checks if the specified directive is a parallel-kind directive.
201 /// \param DKind Specified directive.
202 /// \return true - the directive is a parallel-like directive like 'omp
203 /// parallel', otherwise - false.
204 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
206 /// Checks if the specified directive is a target code offload directive.
207 /// \param DKind Specified directive.
208 /// \return true - the directive is a target code offload directive like
209 /// 'omp target', 'omp target parallel', 'omp target xxx'
210 /// otherwise - false.
211 bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
213 /// Checks if the specified directive is a target data offload directive.
214 /// \param DKind Specified directive.
215 /// \return true - the directive is a target data offload directive like
216 /// 'omp target data', 'omp target update', 'omp target enter data',
217 /// 'omp target exit data'
218 /// otherwise - false.
219 bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);
221 /// Checks if the specified composite/combined directive constitutes a teams
222 /// directive in the outermost nest. For example
223 /// 'omp teams distribute' or 'omp teams distribute parallel for'.
224 /// \param DKind Specified directive.
225 /// \return true - the directive has teams on the outermost nest, otherwise -
227 bool isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind);
229 /// Checks if the specified directive is a teams-kind directive. For example,
230 /// 'omp teams distribute' or 'omp target teams'.
231 /// \param DKind Specified directive.
232 /// \return true - the directive is a teams-like directive, otherwise - false.
233 bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind);
235 /// Checks if the specified directive is a simd directive.
236 /// \param DKind Specified directive.
237 /// \return true - the directive is a simd directive like 'omp simd',
238 /// otherwise - false.
239 bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind);
241 /// Checks if the specified directive is a distribute directive.
242 /// \param DKind Specified directive.
243 /// \return true - the directive is a distribute-directive like 'omp
245 /// otherwise - false.
246 bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind);
248 /// Checks if the specified composite/combined directive constitutes a
249 /// distribute directive in the outermost nest. For example,
250 /// 'omp distribute parallel for' or 'omp distribute'.
251 /// \param DKind Specified directive.
252 /// \return true - the directive has distribute on the outermost nest.
253 /// otherwise - false.
254 bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind);
256 /// Checks if the specified clause is one of private clauses like
257 /// 'private', 'firstprivate', 'reduction' etc..
258 /// \param Kind Clause kind.
259 /// \return true - the clause is a private clause, otherwise - false.
260 bool isOpenMPPrivate(OpenMPClauseKind Kind);
262 /// Checks if the specified clause is one of threadprivate clauses like
263 /// 'threadprivate', 'copyin' or 'copyprivate'.
264 /// \param Kind Clause kind.
265 /// \return true - the clause is a threadprivate clause, otherwise - false.
266 bool isOpenMPThreadPrivate(OpenMPClauseKind Kind);
268 /// Checks if the specified directive kind is one of tasking directives - task,
269 /// taskloop, taksloop simd, master taskloop, parallel master taskloop, master
270 /// taskloop simd, or parallel master taskloop simd.
271 bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind);
273 /// Checks if the specified directive kind is one of the composite or combined
274 /// directives that need loop bound sharing across loops outlined in nested
276 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
278 /// Return the captured regions of an OpenMP directive.
279 void getOpenMPCaptureRegions(
280 llvm::SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
281 OpenMPDirectiveKind DKind);