1 //===--- OpenMPKinds.h - OpenMP enums ---------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// 9 /// \file 10 /// Defines some OpenMP-specific enums and functions. 11 /// 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H 15 #define LLVM_CLANG_BASIC_OPENMPKINDS_H 16 17 #include "clang/Basic/LangOptions.h" 18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/Frontend/OpenMP/OMPConstants.h" 20 21 namespace clang { 22 23 /// OpenMP directives. 24 using OpenMPDirectiveKind = llvm::omp::Directive; 25 26 /// OpenMP clauses. 27 using OpenMPClauseKind = llvm::omp::Clause; 28 29 /// OpenMP attributes for 'schedule' clause. 30 enum OpenMPScheduleClauseKind { 31 #define OPENMP_SCHEDULE_KIND(Name) \ 32 OMPC_SCHEDULE_##Name, 33 #include "clang/Basic/OpenMPKinds.def" 34 OMPC_SCHEDULE_unknown 35 }; 36 37 /// OpenMP modifiers for 'schedule' clause. 38 enum OpenMPScheduleClauseModifier { 39 OMPC_SCHEDULE_MODIFIER_unknown = OMPC_SCHEDULE_unknown, 40 #define OPENMP_SCHEDULE_MODIFIER(Name) \ 41 OMPC_SCHEDULE_MODIFIER_##Name, 42 #include "clang/Basic/OpenMPKinds.def" 43 OMPC_SCHEDULE_MODIFIER_last 44 }; 45 46 /// OpenMP modifiers for 'device' clause. 47 enum OpenMPDeviceClauseModifier { 48 #define OPENMP_DEVICE_MODIFIER(Name) OMPC_DEVICE_##Name, 49 #include "clang/Basic/OpenMPKinds.def" 50 OMPC_DEVICE_unknown, 51 }; 52 53 /// OpenMP attributes for 'depend' clause. 54 enum OpenMPDependClauseKind { 55 #define OPENMP_DEPEND_KIND(Name) \ 56 OMPC_DEPEND_##Name, 57 #include "clang/Basic/OpenMPKinds.def" 58 OMPC_DEPEND_unknown 59 }; 60 61 /// OpenMP attributes for 'linear' clause. 62 enum OpenMPLinearClauseKind { 63 #define OPENMP_LINEAR_KIND(Name) \ 64 OMPC_LINEAR_##Name, 65 #include "clang/Basic/OpenMPKinds.def" 66 OMPC_LINEAR_unknown 67 }; 68 69 /// OpenMP mapping kind for 'map' clause. 70 enum OpenMPMapClauseKind { 71 #define OPENMP_MAP_KIND(Name) \ 72 OMPC_MAP_##Name, 73 #include "clang/Basic/OpenMPKinds.def" 74 OMPC_MAP_unknown 75 }; 76 77 /// OpenMP modifier kind for 'map' clause. 78 enum OpenMPMapModifierKind { 79 OMPC_MAP_MODIFIER_unknown = OMPC_MAP_unknown, 80 #define OPENMP_MAP_MODIFIER_KIND(Name) \ 81 OMPC_MAP_MODIFIER_##Name, 82 #include "clang/Basic/OpenMPKinds.def" 83 OMPC_MAP_MODIFIER_last 84 }; 85 86 /// Number of allowed map-type-modifiers. 87 static constexpr unsigned NumberOfOMPMapClauseModifiers = 88 OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1; 89 90 /// OpenMP modifier kind for 'to' or 'from' clause. 91 enum OpenMPMotionModifierKind { 92 #define OPENMP_MOTION_MODIFIER_KIND(Name) \ 93 OMPC_MOTION_MODIFIER_##Name, 94 #include "clang/Basic/OpenMPKinds.def" 95 OMPC_MOTION_MODIFIER_unknown 96 }; 97 98 /// Number of allowed motion-modifiers. 99 static constexpr unsigned NumberOfOMPMotionModifiers = 100 OMPC_MOTION_MODIFIER_unknown; 101 102 /// OpenMP attributes for 'dist_schedule' clause. 103 enum OpenMPDistScheduleClauseKind { 104 #define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name, 105 #include "clang/Basic/OpenMPKinds.def" 106 OMPC_DIST_SCHEDULE_unknown 107 }; 108 109 /// OpenMP attributes for 'defaultmap' clause. 110 enum OpenMPDefaultmapClauseKind { 111 #define OPENMP_DEFAULTMAP_KIND(Name) \ 112 OMPC_DEFAULTMAP_##Name, 113 #include "clang/Basic/OpenMPKinds.def" 114 OMPC_DEFAULTMAP_unknown 115 }; 116 117 /// OpenMP modifiers for 'defaultmap' clause. 118 enum OpenMPDefaultmapClauseModifier { 119 OMPC_DEFAULTMAP_MODIFIER_unknown = OMPC_DEFAULTMAP_unknown, 120 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \ 121 OMPC_DEFAULTMAP_MODIFIER_##Name, 122 #include "clang/Basic/OpenMPKinds.def" 123 OMPC_DEFAULTMAP_MODIFIER_last 124 }; 125 126 /// OpenMP attributes for 'atomic_default_mem_order' clause. 127 enum OpenMPAtomicDefaultMemOrderClauseKind { 128 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name) \ 129 OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name, 130 #include "clang/Basic/OpenMPKinds.def" 131 OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown 132 }; 133 134 /// OpenMP device type for 'device_type' clause. 135 enum OpenMPDeviceType { 136 #define OPENMP_DEVICE_TYPE_KIND(Name) \ 137 OMPC_DEVICE_TYPE_##Name, 138 #include "clang/Basic/OpenMPKinds.def" 139 OMPC_DEVICE_TYPE_unknown 140 }; 141 142 /// OpenMP 'lastprivate' clause modifier. 143 enum OpenMPLastprivateModifier { 144 #define OPENMP_LASTPRIVATE_KIND(Name) OMPC_LASTPRIVATE_##Name, 145 #include "clang/Basic/OpenMPKinds.def" 146 OMPC_LASTPRIVATE_unknown, 147 }; 148 149 /// OpenMP attributes for 'order' clause. 150 enum OpenMPOrderClauseKind { 151 #define OPENMP_ORDER_KIND(Name) OMPC_ORDER_##Name, 152 #include "clang/Basic/OpenMPKinds.def" 153 OMPC_ORDER_unknown, 154 }; 155 156 /// Scheduling data for loop-based OpenMP directives. 157 struct OpenMPScheduleTy final { 158 OpenMPScheduleClauseKind Schedule = OMPC_SCHEDULE_unknown; 159 OpenMPScheduleClauseModifier M1 = OMPC_SCHEDULE_MODIFIER_unknown; 160 OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown; 161 }; 162 163 /// OpenMP modifiers for 'reduction' clause. 164 enum OpenMPReductionClauseModifier { 165 #define OPENMP_REDUCTION_MODIFIER(Name) OMPC_REDUCTION_##Name, 166 #include "clang/Basic/OpenMPKinds.def" 167 OMPC_REDUCTION_unknown, 168 }; 169 170 /// OpenMP adjust-op kinds for 'adjust_args' clause. 171 enum OpenMPAdjustArgsOpKind { 172 #define OPENMP_ADJUST_ARGS_KIND(Name) OMPC_ADJUST_ARGS_##Name, 173 #include "clang/Basic/OpenMPKinds.def" 174 OMPC_ADJUST_ARGS_unknown, 175 }; 176 177 /// OpenMP bindings for the 'bind' clause. 178 enum OpenMPBindClauseKind { 179 #define OPENMP_BIND_KIND(Name) OMPC_BIND_##Name, 180 #include "clang/Basic/OpenMPKinds.def" 181 OMPC_BIND_unknown 182 }; 183 184 unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str, 185 const LangOptions &LangOpts); 186 const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type); 187 188 /// Checks if the specified directive is a directive with an associated 189 /// loop construct. 190 /// \param DKind Specified directive. 191 /// \return true - the directive is a loop-associated directive like 'omp simd' 192 /// or 'omp for' directive, otherwise - false. 193 bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind); 194 195 /// Checks if the specified directive is a worksharing directive. 196 /// \param DKind Specified directive. 197 /// \return true - the directive is a worksharing directive like 'omp for', 198 /// otherwise - false. 199 bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind); 200 201 /// Checks if the specified directive is a taskloop directive. 202 /// \param DKind Specified directive. 203 /// \return true - the directive is a worksharing directive like 'omp taskloop', 204 /// otherwise - false. 205 bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind); 206 207 /// Checks if the specified directive is a parallel-kind directive. 208 /// \param DKind Specified directive. 209 /// \return true - the directive is a parallel-like directive like 'omp 210 /// parallel', otherwise - false. 211 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind); 212 213 /// Checks if the specified directive is a target code offload directive. 214 /// \param DKind Specified directive. 215 /// \return true - the directive is a target code offload directive like 216 /// 'omp target', 'omp target parallel', 'omp target xxx' 217 /// otherwise - false. 218 bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind); 219 220 /// Checks if the specified directive is a target data offload directive. 221 /// \param DKind Specified directive. 222 /// \return true - the directive is a target data offload directive like 223 /// 'omp target data', 'omp target update', 'omp target enter data', 224 /// 'omp target exit data' 225 /// otherwise - false. 226 bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind); 227 228 /// Checks if the specified composite/combined directive constitutes a teams 229 /// directive in the outermost nest. For example 230 /// 'omp teams distribute' or 'omp teams distribute parallel for'. 231 /// \param DKind Specified directive. 232 /// \return true - the directive has teams on the outermost nest, otherwise - 233 /// false. 234 bool isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind); 235 236 /// Checks if the specified directive is a teams-kind directive. For example, 237 /// 'omp teams distribute' or 'omp target teams'. 238 /// \param DKind Specified directive. 239 /// \return true - the directive is a teams-like directive, otherwise - false. 240 bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind); 241 242 /// Checks if the specified directive is a simd directive. 243 /// \param DKind Specified directive. 244 /// \return true - the directive is a simd directive like 'omp simd', 245 /// otherwise - false. 246 bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind); 247 248 /// Checks if the specified directive is a distribute directive. 249 /// \param DKind Specified directive. 250 /// \return true - the directive is a distribute-directive like 'omp 251 /// distribute', 252 /// otherwise - false. 253 bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind); 254 255 /// Checks if the specified composite/combined directive constitutes a 256 /// distribute directive in the outermost nest. For example, 257 /// 'omp distribute parallel for' or 'omp distribute'. 258 /// \param DKind Specified directive. 259 /// \return true - the directive has distribute on the outermost nest. 260 /// otherwise - false. 261 bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind); 262 263 /// Checks if the specified directive constitutes a 'loop' directive in the 264 /// outermost nest. For example, 'omp teams loop' or 'omp loop'. 265 /// \param DKind Specified directive. 266 /// \return true - the directive has loop on the outermost nest. 267 /// otherwise - false. 268 bool isOpenMPGenericLoopDirective(OpenMPDirectiveKind DKind); 269 270 /// Checks if the specified clause is one of private clauses like 271 /// 'private', 'firstprivate', 'reduction' etc.. 272 /// \param Kind Clause kind. 273 /// \return true - the clause is a private clause, otherwise - false. 274 bool isOpenMPPrivate(OpenMPClauseKind Kind); 275 276 /// Checks if the specified clause is one of threadprivate clauses like 277 /// 'threadprivate', 'copyin' or 'copyprivate'. 278 /// \param Kind Clause kind. 279 /// \return true - the clause is a threadprivate clause, otherwise - false. 280 bool isOpenMPThreadPrivate(OpenMPClauseKind Kind); 281 282 /// Checks if the specified directive kind is one of tasking directives - task, 283 /// taskloop, taksloop simd, master taskloop, parallel master taskloop, master 284 /// taskloop simd, or parallel master taskloop simd. 285 bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind); 286 287 /// Checks if the specified directive kind is one of the composite or combined 288 /// directives that need loop bound sharing across loops outlined in nested 289 /// functions 290 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind); 291 292 /// Checks if the specified directive is a loop transformation directive. 293 /// \param DKind Specified directive. 294 /// \return True iff the directive is a loop transformation. 295 bool isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind); 296 297 /// Return the captured regions of an OpenMP directive. 298 void getOpenMPCaptureRegions( 299 llvm::SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions, 300 OpenMPDirectiveKind DKind); 301 } 302 303 #endif 304 305