Home | History | Annotate | Download | only in Basic
      1 //===--- OpenMPKinds.h - OpenMP enums ---------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 ///
     10 /// \file
     11 /// \brief Defines some OpenMP-specific enums and functions.
     12 ///
     13 //===----------------------------------------------------------------------===//
     14 
     15 #ifndef LLVM_CLANG_BASIC_OPENMPKINDS_H
     16 #define LLVM_CLANG_BASIC_OPENMPKINDS_H
     17 
     18 #include "llvm/ADT/StringRef.h"
     19 
     20 namespace clang {
     21 
     22 /// \brief OpenMP directives.
     23 enum OpenMPDirectiveKind {
     24 #define OPENMP_DIRECTIVE(Name) \
     25   OMPD_##Name,
     26 #define OPENMP_DIRECTIVE_EXT(Name, Str) \
     27   OMPD_##Name,
     28 #include "clang/Basic/OpenMPKinds.def"
     29   OMPD_unknown
     30 };
     31 
     32 /// \brief OpenMP clauses.
     33 enum OpenMPClauseKind {
     34 #define OPENMP_CLAUSE(Name, Class) \
     35   OMPC_##Name,
     36 #include "clang/Basic/OpenMPKinds.def"
     37   OMPC_threadprivate,
     38   OMPC_uniform,
     39   OMPC_unknown
     40 };
     41 
     42 /// \brief OpenMP attributes for 'default' clause.
     43 enum OpenMPDefaultClauseKind {
     44 #define OPENMP_DEFAULT_KIND(Name) \
     45   OMPC_DEFAULT_##Name,
     46 #include "clang/Basic/OpenMPKinds.def"
     47   OMPC_DEFAULT_unknown
     48 };
     49 
     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
     56 };
     57 
     58 /// \brief OpenMP attributes for 'schedule' clause.
     59 enum OpenMPScheduleClauseKind {
     60 #define OPENMP_SCHEDULE_KIND(Name) \
     61   OMPC_SCHEDULE_##Name,
     62 #include "clang/Basic/OpenMPKinds.def"
     63   OMPC_SCHEDULE_unknown
     64 };
     65 
     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
     73 };
     74 
     75 /// \brief OpenMP attributes for 'depend' clause.
     76 enum OpenMPDependClauseKind {
     77 #define OPENMP_DEPEND_KIND(Name) \
     78   OMPC_DEPEND_##Name,
     79 #include "clang/Basic/OpenMPKinds.def"
     80   OMPC_DEPEND_unknown
     81 };
     82 
     83 /// \brief OpenMP attributes for 'linear' clause.
     84 enum OpenMPLinearClauseKind {
     85 #define OPENMP_LINEAR_KIND(Name) \
     86   OMPC_LINEAR_##Name,
     87 #include "clang/Basic/OpenMPKinds.def"
     88   OMPC_LINEAR_unknown
     89 };
     90 
     91 /// \brief OpenMP mapping kind for 'map' clause.
     92 enum OpenMPMapClauseKind {
     93 #define OPENMP_MAP_KIND(Name) \
     94   OMPC_MAP_##Name,
     95 #include "clang/Basic/OpenMPKinds.def"
     96   OMPC_MAP_unknown
     97 };
     98 
     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
    104 };
    105 
    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
    112 };
    113 
    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
    121 };
    122 
    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;
    128 };
    129 
    130 OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str);
    131 const char *getOpenMPDirectiveName(OpenMPDirectiveKind Kind);
    132 
    133 OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
    134 const char *getOpenMPClauseName(OpenMPClauseKind Kind);
    135 
    136 unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str);
    137 const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);
    138 
    139 bool isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
    140                                  OpenMPClauseKind CKind);
    141 
    142 /// \brief Checks if the specified directive is a directive with an associated
    143 /// loop construct.
    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);
    148 
    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);
    154 
    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);
    160 
    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);
    166 
    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);
    173 
    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);
    181 
    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);
    187 
    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);
    193 
    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
    197 /// distribute',
    198 /// otherwise - false.
    199 bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind);
    200 
    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);
    206 
    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);
    212 
    213 /// Checks if the specified directive kind is one of tasking directives - task,
    214 /// taskloop or taksloop simd.
    215 bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind);
    216 
    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
    219 /// functions
    220 bool isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind);
    221 }
    222 
    223 #endif
    224 
    225