Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:50

0001 //===--- OpenMPKinds.h - OpenMP enums ---------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// Defines some OpenMP-specific enums and functions.
0011 ///
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H
0015 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
0016 
0017 #include "clang/Basic/LangOptions.h"
0018 #include "llvm/ADT/Sequence.h"
0019 #include "llvm/ADT/StringRef.h"
0020 #include "llvm/Frontend/OpenMP/OMPConstants.h"
0021 
0022 namespace clang {
0023 
0024 /// OpenMP directives.
0025 using OpenMPDirectiveKind = llvm::omp::Directive;
0026 
0027 /// OpenMP clauses.
0028 using OpenMPClauseKind = llvm::omp::Clause;
0029 
0030 /// OpenMP attributes for 'schedule' clause.
0031 enum OpenMPScheduleClauseKind {
0032 #define OPENMP_SCHEDULE_KIND(Name) \
0033   OMPC_SCHEDULE_##Name,
0034 #include "clang/Basic/OpenMPKinds.def"
0035   OMPC_SCHEDULE_unknown
0036 };
0037 
0038 /// OpenMP modifiers for 'schedule' clause.
0039 enum OpenMPScheduleClauseModifier {
0040   OMPC_SCHEDULE_MODIFIER_unknown = OMPC_SCHEDULE_unknown,
0041 #define OPENMP_SCHEDULE_MODIFIER(Name) \
0042   OMPC_SCHEDULE_MODIFIER_##Name,
0043 #include "clang/Basic/OpenMPKinds.def"
0044   OMPC_SCHEDULE_MODIFIER_last
0045 };
0046 
0047 /// OpenMP modifiers for 'device' clause.
0048 enum OpenMPDeviceClauseModifier {
0049 #define OPENMP_DEVICE_MODIFIER(Name) OMPC_DEVICE_##Name,
0050 #include "clang/Basic/OpenMPKinds.def"
0051   OMPC_DEVICE_unknown,
0052 };
0053 
0054 /// OpenMP attributes for 'depend' clause.
0055 enum OpenMPDependClauseKind {
0056 #define OPENMP_DEPEND_KIND(Name) \
0057   OMPC_DEPEND_##Name,
0058 #include "clang/Basic/OpenMPKinds.def"
0059   OMPC_DEPEND_unknown
0060 };
0061 
0062 /// OpenMP attributes for 'linear' clause.
0063 enum OpenMPLinearClauseKind {
0064 #define OPENMP_LINEAR_KIND(Name) \
0065   OMPC_LINEAR_##Name,
0066 #include "clang/Basic/OpenMPKinds.def"
0067   OMPC_LINEAR_unknown
0068 };
0069 
0070 /// OpenMP mapping kind for 'map' clause.
0071 enum OpenMPMapClauseKind {
0072 #define OPENMP_MAP_KIND(Name) \
0073   OMPC_MAP_##Name,
0074 #include "clang/Basic/OpenMPKinds.def"
0075   OMPC_MAP_unknown
0076 };
0077 
0078 /// OpenMP modifier kind for 'map' clause.
0079 enum OpenMPMapModifierKind {
0080   OMPC_MAP_MODIFIER_unknown = OMPC_MAP_unknown,
0081 #define OPENMP_MAP_MODIFIER_KIND(Name) \
0082   OMPC_MAP_MODIFIER_##Name,
0083 #include "clang/Basic/OpenMPKinds.def"
0084   OMPC_MAP_MODIFIER_last
0085 };
0086 
0087 /// Number of allowed map-type-modifiers.
0088 static constexpr unsigned NumberOfOMPMapClauseModifiers =
0089     OMPC_MAP_MODIFIER_last - OMPC_MAP_MODIFIER_unknown - 1;
0090 
0091 /// OpenMP modifier kind for 'to' or 'from' clause.
0092 enum OpenMPMotionModifierKind {
0093 #define OPENMP_MOTION_MODIFIER_KIND(Name) \
0094   OMPC_MOTION_MODIFIER_##Name,
0095 #include "clang/Basic/OpenMPKinds.def"
0096   OMPC_MOTION_MODIFIER_unknown
0097 };
0098 
0099 /// Number of allowed motion-modifiers.
0100 static constexpr unsigned NumberOfOMPMotionModifiers =
0101     OMPC_MOTION_MODIFIER_unknown;
0102 
0103 /// OpenMP attributes for 'dist_schedule' clause.
0104 enum OpenMPDistScheduleClauseKind {
0105 #define OPENMP_DIST_SCHEDULE_KIND(Name) OMPC_DIST_SCHEDULE_##Name,
0106 #include "clang/Basic/OpenMPKinds.def"
0107   OMPC_DIST_SCHEDULE_unknown
0108 };
0109 
0110 /// OpenMP attributes for 'defaultmap' clause.
0111 enum OpenMPDefaultmapClauseKind {
0112 #define OPENMP_DEFAULTMAP_KIND(Name) \
0113   OMPC_DEFAULTMAP_##Name,
0114 #include "clang/Basic/OpenMPKinds.def"
0115   OMPC_DEFAULTMAP_unknown
0116 };
0117 
0118 /// OpenMP modifiers for 'defaultmap' clause.
0119 enum OpenMPDefaultmapClauseModifier {
0120   OMPC_DEFAULTMAP_MODIFIER_unknown = OMPC_DEFAULTMAP_unknown,
0121 #define OPENMP_DEFAULTMAP_MODIFIER(Name) \
0122   OMPC_DEFAULTMAP_MODIFIER_##Name,
0123 #include "clang/Basic/OpenMPKinds.def"
0124   OMPC_DEFAULTMAP_MODIFIER_last
0125 };
0126 
0127 /// OpenMP attributes for 'atomic_default_mem_order' clause.
0128 enum OpenMPAtomicDefaultMemOrderClauseKind {
0129 #define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name)  \
0130   OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name,
0131 #include "clang/Basic/OpenMPKinds.def"
0132   OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown
0133 };
0134 
0135 /// OpenMP attributes for 'at' clause.
0136 enum OpenMPAtClauseKind {
0137 #define OPENMP_AT_KIND(Name) OMPC_AT_##Name,
0138 #include "clang/Basic/OpenMPKinds.def"
0139   OMPC_AT_unknown
0140 };
0141 
0142 /// OpenMP attributes for 'severity' clause.
0143 enum OpenMPSeverityClauseKind {
0144 #define OPENMP_SEVERITY_KIND(Name) OMPC_SEVERITY_##Name,
0145 #include "clang/Basic/OpenMPKinds.def"
0146   OMPC_SEVERITY_unknown
0147 };
0148 
0149 /// OpenMP device type for 'device_type' clause.
0150 enum OpenMPDeviceType {
0151 #define OPENMP_DEVICE_TYPE_KIND(Name) \
0152   OMPC_DEVICE_TYPE_##Name,
0153 #include "clang/Basic/OpenMPKinds.def"
0154   OMPC_DEVICE_TYPE_unknown
0155 };
0156 
0157 /// OpenMP 'lastprivate' clause modifier.
0158 enum OpenMPLastprivateModifier {
0159 #define OPENMP_LASTPRIVATE_KIND(Name) OMPC_LASTPRIVATE_##Name,
0160 #include "clang/Basic/OpenMPKinds.def"
0161   OMPC_LASTPRIVATE_unknown,
0162 };
0163 
0164 /// OpenMP attributes for 'order' clause.
0165 enum OpenMPOrderClauseKind {
0166 #define OPENMP_ORDER_KIND(Name) OMPC_ORDER_##Name,
0167 #include "clang/Basic/OpenMPKinds.def"
0168   OMPC_ORDER_unknown,
0169 };
0170 
0171 /// OpenMP modifiers for 'order' clause.
0172 enum OpenMPOrderClauseModifier {
0173   OMPC_ORDER_MODIFIER_unknown = OMPC_ORDER_unknown,
0174 #define OPENMP_ORDER_MODIFIER(Name) OMPC_ORDER_MODIFIER_##Name,
0175 #include "clang/Basic/OpenMPKinds.def"
0176   OMPC_ORDER_MODIFIER_last
0177 };
0178 
0179 /// Scheduling data for loop-based OpenMP directives.
0180 struct OpenMPScheduleTy final {
0181   OpenMPScheduleClauseKind Schedule = OMPC_SCHEDULE_unknown;
0182   OpenMPScheduleClauseModifier M1 = OMPC_SCHEDULE_MODIFIER_unknown;
0183   OpenMPScheduleClauseModifier M2 = OMPC_SCHEDULE_MODIFIER_unknown;
0184 };
0185 
0186 /// OpenMP modifiers for 'reduction' clause.
0187 enum OpenMPReductionClauseModifier {
0188 #define OPENMP_REDUCTION_MODIFIER(Name) OMPC_REDUCTION_##Name,
0189 #include "clang/Basic/OpenMPKinds.def"
0190   OMPC_REDUCTION_unknown,
0191 };
0192 
0193 /// OpenMP adjust-op kinds for 'adjust_args' clause.
0194 enum OpenMPAdjustArgsOpKind {
0195 #define OPENMP_ADJUST_ARGS_KIND(Name) OMPC_ADJUST_ARGS_##Name,
0196 #include "clang/Basic/OpenMPKinds.def"
0197   OMPC_ADJUST_ARGS_unknown,
0198 };
0199 
0200 /// OpenMP bindings for the 'bind' clause.
0201 enum OpenMPBindClauseKind {
0202 #define OPENMP_BIND_KIND(Name) OMPC_BIND_##Name,
0203 #include "clang/Basic/OpenMPKinds.def"
0204   OMPC_BIND_unknown
0205 };
0206 
0207 enum OpenMPGrainsizeClauseModifier {
0208 #define OPENMP_GRAINSIZE_MODIFIER(Name) OMPC_GRAINSIZE_##Name,
0209 #include "clang/Basic/OpenMPKinds.def"
0210   OMPC_GRAINSIZE_unknown
0211 };
0212 
0213 enum OpenMPNumTasksClauseModifier {
0214 #define OPENMP_NUMTASKS_MODIFIER(Name) OMPC_NUMTASKS_##Name,
0215 #include "clang/Basic/OpenMPKinds.def"
0216   OMPC_NUMTASKS_unknown
0217 };
0218 
0219 /// OpenMP dependence types for 'doacross' clause.
0220 enum OpenMPDoacrossClauseModifier {
0221 #define OPENMP_DOACROSS_MODIFIER(Name) OMPC_DOACROSS_##Name,
0222 #include "clang/Basic/OpenMPKinds.def"
0223   OMPC_DOACROSS_unknown
0224 };
0225 
0226 /// OpenMP modifiers for 'allocate' clause.
0227 enum OpenMPAllocateClauseModifier {
0228 #define OPENMP_ALLOCATE_MODIFIER(Name) OMPC_ALLOCATE_##Name,
0229 #include "clang/Basic/OpenMPKinds.def"
0230   OMPC_ALLOCATE_unknown
0231 };
0232 
0233 /// Number of allowed allocate-modifiers.
0234 static constexpr unsigned NumberOfOMPAllocateClauseModifiers =
0235     OMPC_ALLOCATE_unknown;
0236 
0237 /// Contains 'interop' data for 'append_args' and 'init' clauses.
0238 class Expr;
0239 struct OMPInteropInfo final {
0240   OMPInteropInfo(bool IsTarget = false, bool IsTargetSync = false)
0241       : IsTarget(IsTarget), IsTargetSync(IsTargetSync) {}
0242   bool IsTarget;
0243   bool IsTargetSync;
0244   llvm::SmallVector<Expr *, 4> PreferTypes;
0245 };
0246 
0247 unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str,
0248                                    const LangOptions &LangOpts);
0249 const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);
0250 
0251 /// Checks if the specified directive is a directive with an associated
0252 /// loop construct.
0253 /// \param DKind Specified directive.
0254 /// \return true - the directive is a loop-associated directive like 'omp simd'
0255 /// or 'omp for' directive, otherwise - false.
0256 bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind);
0257 
0258 /// Checks if the specified directive is a worksharing directive.
0259 /// \param DKind Specified directive.
0260 /// \return true - the directive is a worksharing directive like 'omp for',
0261 /// otherwise - false.
0262 bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind);
0263 
0264 /// Checks if the specified directive is a taskloop directive.
0265 /// \param DKind Specified directive.
0266 /// \return true - the directive is a worksharing directive like 'omp taskloop',
0267 /// otherwise - false.
0268 bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind);
0269 
0270 /// Checks if the specified directive is a parallel-kind directive.
0271 /// \param DKind Specified directive.
0272 /// \return true - the directive is a parallel-like directive like 'omp
0273 /// parallel', otherwise - false.
0274 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
0275 
0276 /// Checks if the specified directive is a target code offload directive.
0277 /// \param DKind Specified directive.
0278 /// \return true - the directive is a target code offload directive like
0279 /// 'omp target', 'omp target parallel', 'omp target xxx'
0280 /// otherwise - false.
0281 bool isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind);
0282 
0283 /// Checks if the specified directive is a target data offload directive.
0284 /// \param DKind Specified directive.
0285 /// \return true - the directive is a target data offload directive like
0286 /// 'omp target data', 'omp target update', 'omp target enter data',
0287 /// 'omp target exit data'
0288 /// otherwise - false.
0289 bool isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind);
0290 
0291 /// Checks if the specified composite/combined directive constitutes a teams
0292 /// directive in the outermost nest.  For example
0293 /// 'omp teams distribute' or 'omp teams distribute parallel for'.
0294 /// \param DKind Specified directive.
0295 /// \return true - the directive has teams on the outermost nest, otherwise -
0296 /// false.
0297 bool isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind);
0298 
0299 /// Checks if the specified directive is a teams-kind directive.  For example,
0300 /// 'omp teams distribute' or 'omp target teams'.
0301 /// \param DKind Specified directive.
0302 /// \return true - the directive is a teams-like directive, otherwise - false.
0303 bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind);
0304 
0305 /// Checks if the specified directive is a simd directive.
0306 /// \param DKind Specified directive.
0307 /// \return true - the directive is a simd directive like 'omp simd',
0308 /// otherwise - false.
0309 bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind);
0310 
0311 /// Checks if the specified directive is a distribute directive.
0312 /// \param DKind Specified directive.
0313 /// \return true - the directive is a distribute-directive like 'omp
0314 /// distribute',
0315 /// otherwise - false.
0316 bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind);
0317 
0318 /// Checks if the specified composite/combined directive constitutes a
0319 /// distribute directive in the outermost nest.  For example,
0320 /// 'omp distribute parallel for' or 'omp distribute'.
0321 /// \param DKind Specified directive.
0322 /// \return true - the directive has distribute on the outermost nest.
0323 /// otherwise - false.
0324 bool isOpenMPNestingDistributeDirective(OpenMPDirectiveKind DKind);
0325 
0326 /// Checks if the specified directive constitutes a 'loop' directive in the
0327 /// outermost nest.  For example, 'omp teams loop' or 'omp loop'.
0328 /// \param DKind Specified directive.
0329 /// \return true - the directive has loop on the outermost nest.
0330 /// otherwise - false.
0331 bool isOpenMPGenericLoopDirective(OpenMPDirectiveKind DKind);
0332 
0333 /// Checks if the specified clause is one of private clauses like
0334 /// 'private', 'firstprivate', 'reduction' etc..
0335 /// \param Kind Clause kind.
0336 /// \return true - the clause is a private clause, otherwise - false.
0337 bool isOpenMPPrivate(OpenMPClauseKind Kind);
0338 
0339 /// Checks if the specified clause is one of threadprivate clauses like
0340 /// 'threadprivate', 'copyin' or 'copyprivate'.
0341 /// \param Kind Clause kind.
0342 /// \return true - the clause is a threadprivate clause, otherwise - false.
0343 bool isOpenMPThreadPrivate(OpenMPClauseKind Kind);
0344 
0345 /// Checks if the specified directive kind is one of tasking directives - task,
0346 /// taskloop, taksloop simd, master taskloop, parallel master taskloop, master
0347 /// taskloop simd, or parallel master taskloop simd.
0348 bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind);
0349 
0350 /// Checks if the specified directive kind is one of the composite or combined
0351 /// directives that need loop bound sharing across loops outlined in nested
0352 /// functions
0353 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
0354 
0355 /// Checks if the specified directive is a loop transformation directive.
0356 /// \param DKind Specified directive.
0357 /// \return True iff the directive is a loop transformation.
0358 bool isOpenMPLoopTransformationDirective(OpenMPDirectiveKind DKind);
0359 
0360 /// Return the captured regions of an OpenMP directive.
0361 void getOpenMPCaptureRegions(
0362     llvm::SmallVectorImpl<OpenMPDirectiveKind> &CaptureRegions,
0363     OpenMPDirectiveKind DKind);
0364 
0365 /// Checks if the specified directive is a combined construct for which
0366 /// the first construct is a parallel construct.
0367 /// \param DKind Specified directive.
0368 /// \return true - if the above condition is met for this directive
0369 /// otherwise - false.
0370 bool isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind);
0371 
0372 /// Checks if the specified target directive, combined or not, needs task based
0373 /// thread_limit
0374 /// \param DKind Specified directive.
0375 /// \return true - if the above condition is met for this directive
0376 /// otherwise - false.
0377 bool needsTaskBasedThreadLimit(OpenMPDirectiveKind DKind);
0378 
0379 /// Checks if the parameter to the fail clause in "#pragma atomic compare fail"
0380 /// is restricted only to memory order clauses of "OMPC_acquire",
0381 /// "OMPC_relaxed" and "OMPC_seq_cst".
0382 bool checkFailClauseParameter(OpenMPClauseKind FailClauseParameter);
0383 
0384 /// Checks if the specified directive is considered as "executable". This
0385 /// combines the OpenMP categories of "executable" and "subsidiary", plus
0386 /// any other directives that should be treated as executable.
0387 /// \param DKind Specified directive.
0388 /// \return true - if the above condition is met for this directive
0389 /// otherwise - false.
0390 bool isOpenMPExecutableDirective(OpenMPDirectiveKind DKind);
0391 
0392 /// Checks if the specified directive is considered as "informational".
0393 /// \param DKind Specified directive.
0394 /// \return true if it is an informational directive, false otherwise.
0395 bool isOpenMPInformationalDirective(OpenMPDirectiveKind DKind);
0396 
0397 /// Checks if the specified directive can capture variables.
0398 /// \param DKind Specified directive.
0399 /// \return true - if the above condition is met for this directive
0400 /// otherwise - false.
0401 bool isOpenMPCapturingDirective(OpenMPDirectiveKind DKind);
0402 }
0403 
0404 template <>
0405 struct llvm::enum_iteration_traits<clang::OpenMPDefaultmapClauseKind> {
0406   static constexpr bool is_iterable = true;
0407 };
0408 #endif
0409