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 using OpenMPClauseKind = llvm::omp::Clause;
28 /// OpenMP attributes for 'schedule' clause.
29 enum OpenMPScheduleClauseKind {
30 #define OPENMP_SCHEDULE_KIND(Name) \
32 #include "clang/Basic/OpenMPKinds.def"
36 /// OpenMP modifiers for 'schedule' clause.
37 enum OpenMPScheduleClauseModifier {
38 OMPC_SCHEDULE_MODIFIER_unknown = OMPC_SCHEDULE_unknown,
39 #define OPENMP_SCHEDULE_MODIFIER(Name) \
40 OMPC_SCHEDULE_MODIFIER_##Name,
41 #include "clang/Basic/OpenMPKinds.def"
42 OMPC_SCHEDULE_MODIFIER_last
45 /// OpenMP modifiers for 'device' clause.
46 enum OpenMPDeviceClauseModifier {
47 #define OPENMP_DEVICE_MODIFIER(Name) OMPC_DEVICE_##Name,
48 #include "clang/Basic/OpenMPKinds.def"
52 /// OpenMP attributes for 'depend' clause.
53 enum OpenMPDependClauseKind {
54 #define OPENMP_DEPEND_KIND(Name) \
56 #include "clang/Basic/OpenMPKinds.def"
60 /// OpenMP attributes for 'linear' clause.
61 enum OpenMPLinearClauseKind {
62 #define OPENMP_LINEAR_KIND(Name) \
64 #include "clang/Basic/OpenMPKinds.def"
68 /// OpenMP mapping kind for 'map' clause.
69 enum OpenMPMapClauseKind {
70 #define OPENMP_MAP_KIND(Name) \
72 #include "clang/Basic/OpenMPKinds.def"
76 /// OpenMP modifier kind for 'map' clause.
77 enum OpenMPMapModifierKind {
78 OMPC_MAP_MODIFIER_unknown = OMPC_MAP_unknown,
79 #define OPENMP_MAP_MODIFIER_KIND(Name) \
80 OMPC_MAP_MODIFIER_##Name,
81 #include "clang/Basic/OpenMPKinds.def"
82 OMPC_MAP_MODIFIER_last
85 /// Number of allowed map-type-modifiers.
86 static constexpr unsigned NumberOfOMPMapClauseModifiers =
87 OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
89 /// OpenMP modifier kind for 'to' clause.
90 enum OpenMPToModifierKind {
91 #define OPENMP_TO_MODIFIER_KIND(Name) \
92 OMPC_TO_MODIFIER_##Name,
93 #include "clang/Basic/OpenMPKinds.def"
94 OMPC_TO_MODIFIER_unknown
97 /// OpenMP modifier kind for 'from' clause.
98 enum OpenMPFromModifierKind {
99 #define OPENMP_FROM_MODIFIER_KIND(Name) \
100 OMPC_FROM_MODIFIER_##Name,
101 #include "clang/Basic/OpenMPKinds.def"
102 OMPC_FROM_MODIFIER_unknown
105 /// OpenMP attributes for 'dist_schedule' clause.
106 enum OpenMPDistScheduleClauseKind {
107 #define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name,
108 #include "clang/Basic/OpenMPKinds.def"
109 OMPC_DIST_SCHEDULE_unknown
112 /// OpenMP attributes for 'defaultmap' clause.
113 enum OpenMPDefaultmapClauseKind {
114 #define OPENMP_DEFAULTMAP_KIND(Name) \
115 OMPC_DEFAULTMAP_##Name,
116 #include "clang/Basic/OpenMPKinds.def"
117 OMPC_DEFAULTMAP_unknown
120 /// OpenMP modifiers for 'defaultmap' clause.
121 enum OpenMPDefaultmapClauseModifier {
122 OMPC_DEFAULTMAP_MODIFIER_unknown = OMPC_DEFAULTMAP_unknown,
123 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
124 OMPC_DEFAULTMAP_MODIFIER_##Name,
125 #include "clang/Basic/OpenMPKinds.def"
126 OMPC_DEFAULTMAP_MODIFIER_last
129 /// OpenMP attributes for 'atomic_default_mem_order' clause.
130 enum OpenMPAtomicDefaultMemOrderClauseKind {
131 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \
132 OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name,
133 #include "clang/Basic/OpenMPKinds.def"
134 OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
137 /// OpenMP device type for 'device_type' clause.
138 enum OpenMPDeviceType {
139 #define OPENMP_DEVICE_TYPE_KIND(Name) \
140 OMPC_DEVICE_TYPE_##Name,
141 #include "clang/Basic/OpenMPKinds.def"
142 OMPC_DEVICE_TYPE_unknown
145 /// OpenMP 'lastprivate' clause modifier.
146 enum OpenMPLastprivateModifier {
147 #define OPENMP_LASTPRIVATE_KIND(Name) OMPC_LASTPRIVATE_##Name,
148 #include "clang/Basic/OpenMPKinds.def"
149 OMPC_LASTPRIVATE_unknown,
152 /// OpenMP attributes for 'order' clause.
153 enum OpenMPOrderClauseKind {
154 #define OPENMP_ORDER_KIND(Name) OMPC_ORDER_##Name,
155 #include "clang/Basic/OpenMPKinds.def"
159 /// Scheduling data for loop-based OpenMP directives.
160 struct OpenMPScheduleTy final {
161 OpenMPScheduleClauseKind Schedule = OMPC_SCHEDULE_unknown;
162 OpenMPScheduleClauseModifier M1 = OMPC_SCHEDULE_MODIFIER_unknown;
163 OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown;
166 /// OpenMP modifiers for 'reduction' clause.
167 enum OpenMPReductionClauseModifier {
168 #define OPENMP_REDUCTION_MODIFIER(Name) OMPC_REDUCTION_##Name,
169 #include "clang/Basic/OpenMPKinds.def"
170 OMPC_REDUCTION_unknown,
173 unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str);
174 const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);
176 /// Checks if the specified directive is a directive with an associated
178 /// \param DKind Specified directive.
179 /// \return true - the directive is a loop-associated directive like 'omp simd'
180 /// or 'omp for' directive, otherwise - false.
181 bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind);
183 /// Checks if the specified directive is a worksharing directive.
184 /// \param DKind Specified directive.
185 /// \return true - the directive is a worksharing directive like 'omp for',
186 /// otherwise - false.
187 bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind);
189 /// Checks if the specified directive is a taskloop directive.
190 /// \param DKind Specified directive.
191 /// \return true - the directive is a worksharing directive like 'omp taskloop',
192 /// otherwise - false.
193 bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind);
195 /// Checks if the specified directive is a parallel-kind directive.
196 /// \param DKind Specified directive.
197 /// \return true - the directive is a parallel-like directive like 'omp
198 /// parallel', otherwise - false.
199 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
201 /// Checks if the specified directive is a target code offload directive.
202 /// \param DKind Specified directive.
203 /// \return true - the directive is a target code offload directive like
204 /// 'omp target', 'omp target parallel', 'omp target xxx'
205 /// otherwise - false.
206 bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
208 /// Checks if the specified directive is a target data offload directive.
209 /// \param DKind Specified directive.
210 /// \return true - the directive is a target data offload directive like
211 /// 'omp target data', 'omp target update', 'omp target enter data',
212 /// 'omp target exit data'
213 /// otherwise - false.
214 bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);
216 /// Checks if the specified composite/combined directive constitutes a teams
217 /// directive in the outermost nest. For example
218 /// 'omp teams distribute' or 'omp teams distribute parallel for'.
219 /// \param DKind Specified directive.
220 /// \return true - the directive has teams on the outermost nest, otherwise -
222 bool isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind);
224 /// Checks if the specified directive is a teams-kind directive. For example,
225 /// 'omp teams distribute' or 'omp target teams'.
226 /// \param DKind Specified directive.
227 /// \return true - the directive is a teams-like directive, otherwise - false.
228 bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind);
230 /// Checks if the specified directive is a simd directive.
231 /// \param DKind Specified directive.
232 /// \return true - the directive is a simd directive like 'omp simd',
233 /// otherwise - false.
234 bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind);
236 /// Checks if the specified directive is a distribute directive.
237 /// \param DKind Specified directive.
238 /// \return true - the directive is a distribute-directive like 'omp
240 /// otherwise - false.
241 bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind);
243 /// Checks if the specified composite/combined directive constitutes a
244 /// distribute directive in the outermost nest. For example,
245 /// 'omp distribute parallel for' or 'omp distribute'.
246 /// \param DKind Specified directive.
247 /// \return true - the directive has distribute on the outermost nest.
248 /// otherwise - false.
249 bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind);
251 /// Checks if the specified clause is one of private clauses like
252 /// 'private', 'firstprivate', 'reduction' etc..
253 /// \param Kind Clause kind.
254 /// \return true - the clause is a private clause, otherwise - false.
255 bool isOpenMPPrivate(OpenMPClauseKind Kind);
257 /// Checks if the specified clause is one of threadprivate clauses like
258 /// 'threadprivate', 'copyin' or 'copyprivate'.
259 /// \param Kind Clause kind.
260 /// \return true - the clause is a threadprivate clause, otherwise - false.
261 bool isOpenMPThreadPrivate(OpenMPClauseKind Kind);
263 /// Checks if the specified directive kind is one of tasking directives - task,
264 /// taskloop, taksloop simd, master taskloop, parallel master taskloop, master
265 /// taskloop simd, or parallel master taskloop simd.
266 bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind);
268 /// Checks if the specified directive kind is one of the composite or combined
269 /// directives that need loop bound sharing across loops outlined in nested
271 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
273 /// Return the captured regions of an OpenMP directive.
274 void getOpenMPCaptureRegions(
275 llvm::SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
276 OpenMPDirectiveKind DKind);