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_unknown
39 };
40 
41 /// \brief OpenMP attributes for 'default' clause.
42 enum OpenMPDefaultClauseKind {
43 #define OPENMP_DEFAULT_KIND(Name) \
44   OMPC_DEFAULT_##Name,
45 #include "clang/Basic/OpenMPKinds.def"
46   OMPC_DEFAULT_unknown
47 };
48 
49 /// \brief OpenMP attributes for 'proc_bind' clause.
50 enum OpenMPProcBindClauseKind {
51 #define OPENMP_PROC_BIND_KIND(Name) \
52   OMPC_PROC_BIND_##Name,
53 #include "clang/Basic/OpenMPKinds.def"
54   OMPC_PROC_BIND_unknown
55 };
56 
57 /// \brief OpenMP attributes for 'schedule' clause.
58 enum OpenMPScheduleClauseKind {
59 #define OPENMP_SCHEDULE_KIND(Name) \
60   OMPC_SCHEDULE_##Name,
61 #include "clang/Basic/OpenMPKinds.def"
62   OMPC_SCHEDULE_unknown
63 };
64 
65 /// \brief OpenMP attributes for 'depend' clause.
66 enum OpenMPDependClauseKind {
67 #define OPENMP_DEPEND_KIND(Name) \
68   OMPC_DEPEND_##Name,
69 #include "clang/Basic/OpenMPKinds.def"
70   OMPC_DEPEND_unknown
71 };
72 
73 /// \brief OpenMP attributes for 'linear' clause.
74 enum OpenMPLinearClauseKind {
75 #define OPENMP_LINEAR_KIND(Name) \
76   OMPC_LINEAR_##Name,
77 #include "clang/Basic/OpenMPKinds.def"
78   OMPC_LINEAR_unknown
79 };
80 
81 /// \brief OpenMP mapping kind for 'map' clause.
82 enum OpenMPMapClauseKind {
83 #define OPENMP_MAP_KIND(Name) \
84   OMPC_MAP_##Name,
85 #include "clang/Basic/OpenMPKinds.def"
86   OMPC_MAP_unknown
87 };
88 
89 OpenMPDirectiveKind getOpenMPDirectiveKind(llvm::StringRef Str);
90 const char *getOpenMPDirectiveName(OpenMPDirectiveKind Kind);
91 
92 OpenMPClauseKind getOpenMPClauseKind(llvm::StringRef Str);
93 const char *getOpenMPClauseName(OpenMPClauseKind Kind);
94 
95 unsigned getOpenMPSimpleClauseType(OpenMPClauseKind Kind, llvm::StringRef Str);
96 const char *getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type);
97 
98 bool isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
99                                  OpenMPClauseKind CKind);
100 
101 /// \brief Checks if the specified directive is a directive with an associated
102 /// loop construct.
103 /// \param DKind Specified directive.
104 /// \return true - the directive is a loop-associated directive like 'omp simd'
105 /// or 'omp for' directive, otherwise - false.
106 bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind);
107 
108 /// \brief Checks if the specified directive is a worksharing directive.
109 /// \param DKind Specified directive.
110 /// \return true - the directive is a worksharing directive like 'omp for',
111 /// otherwise - false.
112 bool isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind);
113 
114 /// \brief Checks if the specified directive is a taskloop directive.
115 /// \param DKind Specified directive.
116 /// \return true - the directive is a worksharing directive like 'omp taskloop',
117 /// otherwise - false.
118 bool isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind);
119 
120 /// \brief Checks if the specified directive is a parallel-kind directive.
121 /// \param DKind Specified directive.
122 /// \return true - the directive is a parallel-like directive like 'omp
123 /// parallel', otherwise - false.
124 bool isOpenMPParallelDirective(OpenMPDirectiveKind DKind);
125 
126 /// \brief Checks if the specified directive is a target-kind directive.
127 /// \param DKind Specified directive.
128 /// \return true - the directive is a target-like directive like 'omp target',
129 /// otherwise - false.
130 bool isOpenMPTargetDirective(OpenMPDirectiveKind DKind);
131 
132 /// \brief Checks if the specified directive is a teams-kind directive.
133 /// \param DKind Specified directive.
134 /// \return true - the directive is a teams-like directive like 'omp teams',
135 /// otherwise - false.
136 bool isOpenMPTeamsDirective(OpenMPDirectiveKind DKind);
137 
138 /// \brief Checks if the specified directive is a simd directive.
139 /// \param DKind Specified directive.
140 /// \return true - the directive is a simd directive like 'omp simd',
141 /// otherwise - false.
142 bool isOpenMPSimdDirective(OpenMPDirectiveKind DKind);
143 
144 /// \brief Checks if the specified directive is a distribute directive.
145 /// \param DKind Specified directive.
146 /// \return true - the directive is a distribute-directive like 'omp
147 /// distribute',
148 /// otherwise - false.
149 bool isOpenMPDistributeDirective(OpenMPDirectiveKind DKind);
150 
151 /// \brief Checks if the specified clause is one of private clauses like
152 /// 'private', 'firstprivate', 'reduction' etc..
153 /// \param Kind Clause kind.
154 /// \return true - the clause is a private clause, otherwise - false.
155 bool isOpenMPPrivate(OpenMPClauseKind Kind);
156 
157 /// \brief Checks if the specified clause is one of threadprivate clauses like
158 /// 'threadprivate', 'copyin' or 'copyprivate'.
159 /// \param Kind Clause kind.
160 /// \return true - the clause is a threadprivate clause, otherwise - false.
161 bool isOpenMPThreadPrivate(OpenMPClauseKind Kind);
162 
163 }
164 
165 #endif
166 
167