1 //===--- OpenMPKinds.h - OpenMP enums ---------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines some OpenMP-specific enums and functions.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H
16 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
18 #include "llvm/ADT/StringRef.h"
22 /// \brief OpenMP directives.
23 enum OpenMPDirectiveKind {
24 #define OPENMP_DIRECTIVE(Name) \
26 #define OPENMP_DIRECTIVE_EXT(Name, Str) \
28 #include "clang/Basic/OpenMPKinds.def"
32 /// \brief OpenMP clauses.
33 enum OpenMPClauseKind {
34 #define OPENMP_CLAUSE(Name, Class) \
36 #include "clang/Basic/OpenMPKinds.def"
42 /// \brief OpenMP attributes for 'default' clause.
43 enum OpenMPDefaultClauseKind {
44 #define OPENMP_DEFAULT_KIND(Name) \
46 #include "clang/Basic/OpenMPKinds.def"
50 /// \brief OpenMP attributes for 'proc_bind' clause.
51 enum OpenMPProcBindClauseKind {
52 #define OPENMP_PROC_BIND_KIND(Name) \
53 OMPC_PROC_BIND_##Name,
54 #include "clang/Basic/OpenMPKinds.def"
55 OMPC_PROC_BIND_unknown
58 /// \brief OpenMP attributes for 'schedule' clause.
59 enum OpenMPScheduleClauseKind {
60 #define OPENMP_SCHEDULE_KIND(Name) \
62 #include "clang/Basic/OpenMPKinds.def"
66 /// \brief OpenMP modifiers for 'schedule' clause.
67 enum OpenMPScheduleClauseModifier {
68 OMPC_SCHEDULE_MODIFIER_unknown = OMPC_SCHEDULE_unknown,
69 #define OPENMP_SCHEDULE_MODIFIER(Name) \
70 OMPC_SCHEDULE_MODIFIER_##Name,
71 #include "clang/Basic/OpenMPKinds.def"
72 OMPC_SCHEDULE_MODIFIER_last
75 /// \brief OpenMP attributes for 'depend' clause.
76 enum OpenMPDependClauseKind {
77 #define OPENMP_DEPEND_KIND(Name) \
79 #include "clang/Basic/OpenMPKinds.def"
83 /// \brief OpenMP attributes for 'linear' clause.
84 enum OpenMPLinearClauseKind {
85 #define OPENMP_LINEAR_KIND(Name) \
87 #include "clang/Basic/OpenMPKinds.def"
91 /// \brief OpenMP mapping kind for 'map' clause.
92 enum OpenMPMapClauseKind {
93 #define OPENMP_MAP_KIND(Name) \
95 #include "clang/Basic/OpenMPKinds.def"
99 /// \brief OpenMP attributes for 'dist_schedule' clause.
100 enum OpenMPDistScheduleClauseKind {
101 #define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name,
102 #include "clang/Basic/OpenMPKinds.def"
103 OMPC_DIST_SCHEDULE_unknown
106 /// \brief OpenMP attributes for 'defaultmap' clause.
107 enum OpenMPDefaultmapClauseKind {
108 #define OPENMP_DEFAULTMAP_KIND(Name) \
109 OMPC_DEFAULTMAP_##Name,
110 #include "clang/Basic/OpenMPKinds.def"
111 OMPC_DEFAULTMAP_unknown
114 /// \brief OpenMP modifiers for 'defaultmap' clause.
115 enum OpenMPDefaultmapClauseModifier {
116 OMPC_DEFAULTMAP_MODIFIER_unknown = OMPC_DEFAULTMAP_unknown,
117 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
118 OMPC_DEFAULTMAP_MODIFIER_##Name,
119 #include "clang/Basic/OpenMPKinds.def"
120 OMPC_DEFAULTMAP_MODIFIER_last
123 /// Scheduling data for loop-based OpenMP directives.
124 struct OpenMPScheduleTy final {
125 OpenMPScheduleClauseKind Schedule = OMPC_SCHEDULE_unknown;
126 OpenMPScheduleClauseModifier M1 = OMPC_SCHEDULE_MODIFIER_unknown;
127 OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown;
130 OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str);
131 const char *getOpenMPDirectiveName(OpenMPDirectiveKind Kind);
133 OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
134 const char *getOpenMPClauseName(OpenMPClauseKind Kind);
136 unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str);
137 const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);
139 bool isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
140 OpenMPClauseKind CKind);
142 /// \brief Checks if the specified directive is a directive with an associated
144 /// \param DKind Specified directive.
145 /// \return true - the directive is a loop-associated directive like 'omp simd'
146 /// or 'omp for' directive, otherwise - false.
147 bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind);
149 /// \brief Checks if the specified directive is a worksharing directive.
150 /// \param DKind Specified directive.
151 /// \return true - the directive is a worksharing directive like 'omp for',
152 /// otherwise - false.
153 bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind);
155 /// \brief Checks if the specified directive is a taskloop directive.
156 /// \param DKind Specified directive.
157 /// \return true - the directive is a worksharing directive like 'omp taskloop',
158 /// otherwise - false.
159 bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind);
161 /// \brief Checks if the specified directive is a parallel-kind directive.
162 /// \param DKind Specified directive.
163 /// \return true - the directive is a parallel-like directive like 'omp
164 /// parallel', otherwise - false.
165 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
167 /// \brief Checks if the specified directive is a target code offload directive.
168 /// \param DKind Specified directive.
169 /// \return true - the directive is a target code offload directive like
170 /// 'omp target', 'omp target parallel', 'omp target xxx'
171 /// otherwise - false.
172 bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
174 /// \brief Checks if the specified directive is a target data offload directive.
175 /// \param DKind Specified directive.
176 /// \return true - the directive is a target data offload directive like
177 /// 'omp target data', 'omp target update', 'omp target enter data',
178 /// 'omp target exit data'
179 /// otherwise - false.
180 bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);
182 /// \brief Checks if the specified directive is a teams-kind directive.
183 /// \param DKind Specified directive.
184 /// \return true - the directive is a teams-like directive like 'omp teams',
185 /// otherwise - false.
186 bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind);
188 /// \brief Checks if the specified directive is a simd directive.
189 /// \param DKind Specified directive.
190 /// \return true - the directive is a simd directive like 'omp simd',
191 /// otherwise - false.
192 bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind);
194 /// \brief Checks if the specified directive is a distribute directive.
195 /// \param DKind Specified directive.
196 /// \return true - the directive is a distribute-directive like 'omp
198 /// otherwise - false.
199 bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind);
201 /// \brief Checks if the specified clause is one of private clauses like
202 /// 'private', 'firstprivate', 'reduction' etc..
203 /// \param Kind Clause kind.
204 /// \return true - the clause is a private clause, otherwise - false.
205 bool isOpenMPPrivate(OpenMPClauseKind Kind);
207 /// \brief Checks if the specified clause is one of threadprivate clauses like
208 /// 'threadprivate', 'copyin' or 'copyprivate'.
209 /// \param Kind Clause kind.
210 /// \return true - the clause is a threadprivate clause, otherwise - false.
211 bool isOpenMPThreadPrivate(OpenMPClauseKind Kind);
213 /// Checks if the specified directive kind is one of tasking directives - task,
214 /// taskloop or taksloop simd.
215 bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind);
217 /// Checks if the specified directive kind is one of the composite or combined
218 /// directives that need loop bound sharing across loops outlined in nested
220 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);