1 | #ifndef LLVM_OpenACC_INC |
2 | #define LLVM_OpenACC_INC |
3 | |
4 | #include "llvm/ADT/ArrayRef.h" |
5 | #include "llvm/ADT/BitmaskEnum.h" |
6 | #include <cstddef> |
7 | |
8 | namespace llvm { |
9 | class StringRef; |
10 | namespace acc { |
11 | |
12 | LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); |
13 | |
14 | enum class Association { |
15 | Block, |
16 | Declaration, |
17 | Delimited, |
18 | Loop, |
19 | None, |
20 | Separating, |
21 | }; |
22 | |
23 | static constexpr std::size_t Association_enumSize = 6; |
24 | |
25 | enum class Category { |
26 | Declarative, |
27 | Executable, |
28 | Informational, |
29 | Meta, |
30 | Subsidiary, |
31 | Utility, |
32 | }; |
33 | |
34 | static constexpr std::size_t Category_enumSize = 6; |
35 | |
36 | enum class Directive { |
37 | ACCD_atomic, |
38 | ACCD_cache, |
39 | ACCD_data, |
40 | ACCD_declare, |
41 | ACCD_enter_data, |
42 | ACCD_exit_data, |
43 | ACCD_host_data, |
44 | ACCD_init, |
45 | ACCD_kernels, |
46 | ACCD_kernels_loop, |
47 | ACCD_loop, |
48 | ACCD_parallel, |
49 | ACCD_parallel_loop, |
50 | ACCD_routine, |
51 | ACCD_serial, |
52 | ACCD_serial_loop, |
53 | ACCD_set, |
54 | ACCD_shutdown, |
55 | ACCD_unknown, |
56 | ACCD_update, |
57 | ACCD_wait, |
58 | }; |
59 | |
60 | static constexpr std::size_t Directive_enumSize = 21; |
61 | |
62 | constexpr auto ACCD_atomic = llvm::acc::Directive::ACCD_atomic; |
63 | constexpr auto ACCD_cache = llvm::acc::Directive::ACCD_cache; |
64 | constexpr auto ACCD_data = llvm::acc::Directive::ACCD_data; |
65 | constexpr auto ACCD_declare = llvm::acc::Directive::ACCD_declare; |
66 | constexpr auto ACCD_enter_data = llvm::acc::Directive::ACCD_enter_data; |
67 | constexpr auto ACCD_exit_data = llvm::acc::Directive::ACCD_exit_data; |
68 | constexpr auto ACCD_host_data = llvm::acc::Directive::ACCD_host_data; |
69 | constexpr auto ACCD_init = llvm::acc::Directive::ACCD_init; |
70 | constexpr auto ACCD_kernels = llvm::acc::Directive::ACCD_kernels; |
71 | constexpr auto ACCD_kernels_loop = llvm::acc::Directive::ACCD_kernels_loop; |
72 | constexpr auto ACCD_loop = llvm::acc::Directive::ACCD_loop; |
73 | constexpr auto ACCD_parallel = llvm::acc::Directive::ACCD_parallel; |
74 | constexpr auto ACCD_parallel_loop = llvm::acc::Directive::ACCD_parallel_loop; |
75 | constexpr auto ACCD_routine = llvm::acc::Directive::ACCD_routine; |
76 | constexpr auto ACCD_serial = llvm::acc::Directive::ACCD_serial; |
77 | constexpr auto ACCD_serial_loop = llvm::acc::Directive::ACCD_serial_loop; |
78 | constexpr auto ACCD_set = llvm::acc::Directive::ACCD_set; |
79 | constexpr auto ACCD_shutdown = llvm::acc::Directive::ACCD_shutdown; |
80 | constexpr auto ACCD_unknown = llvm::acc::Directive::ACCD_unknown; |
81 | constexpr auto ACCD_update = llvm::acc::Directive::ACCD_update; |
82 | constexpr auto ACCD_wait = llvm::acc::Directive::ACCD_wait; |
83 | |
84 | enum class Clause { |
85 | ACCC_async, |
86 | ACCC_attach, |
87 | ACCC_auto, |
88 | ACCC_bind, |
89 | ACCC_capture, |
90 | ACCC_collapse, |
91 | ACCC_copy, |
92 | ACCC_copyin, |
93 | ACCC_copyout, |
94 | ACCC_create, |
95 | ACCC_default, |
96 | ACCC_default_async, |
97 | ACCC_delete, |
98 | ACCC_detach, |
99 | ACCC_device, |
100 | ACCC_device_num, |
101 | ACCC_deviceptr, |
102 | ACCC_device_resident, |
103 | ACCC_device_type, |
104 | ACCC_finalize, |
105 | ACCC_firstprivate, |
106 | ACCC_gang, |
107 | ACCC_host, |
108 | ACCC_if, |
109 | ACCC_if_present, |
110 | ACCC_independent, |
111 | ACCC_link, |
112 | ACCC_no_create, |
113 | ACCC_nohost, |
114 | ACCC_num_gangs, |
115 | ACCC_num_workers, |
116 | ACCC_present, |
117 | ACCC_private, |
118 | ACCC_read, |
119 | ACCC_reduction, |
120 | ACCC_self, |
121 | ACCC_seq, |
122 | ACCC_tile, |
123 | ACCC_unknown, |
124 | ACCC_use_device, |
125 | ACCC_vector, |
126 | ACCC_vector_length, |
127 | ACCC_wait, |
128 | ACCC_worker, |
129 | ACCC_write, |
130 | }; |
131 | |
132 | static constexpr std::size_t Clause_enumSize = 45; |
133 | |
134 | constexpr auto ACCC_async = llvm::acc::Clause::ACCC_async; |
135 | constexpr auto ACCC_attach = llvm::acc::Clause::ACCC_attach; |
136 | constexpr auto ACCC_auto = llvm::acc::Clause::ACCC_auto; |
137 | constexpr auto ACCC_bind = llvm::acc::Clause::ACCC_bind; |
138 | constexpr auto ACCC_capture = llvm::acc::Clause::ACCC_capture; |
139 | constexpr auto ACCC_collapse = llvm::acc::Clause::ACCC_collapse; |
140 | constexpr auto ACCC_copy = llvm::acc::Clause::ACCC_copy; |
141 | constexpr auto ACCC_copyin = llvm::acc::Clause::ACCC_copyin; |
142 | constexpr auto ACCC_copyout = llvm::acc::Clause::ACCC_copyout; |
143 | constexpr auto ACCC_create = llvm::acc::Clause::ACCC_create; |
144 | constexpr auto ACCC_default = llvm::acc::Clause::ACCC_default; |
145 | constexpr auto ACCC_default_async = llvm::acc::Clause::ACCC_default_async; |
146 | constexpr auto ACCC_delete = llvm::acc::Clause::ACCC_delete; |
147 | constexpr auto ACCC_detach = llvm::acc::Clause::ACCC_detach; |
148 | constexpr auto ACCC_device = llvm::acc::Clause::ACCC_device; |
149 | constexpr auto ACCC_device_num = llvm::acc::Clause::ACCC_device_num; |
150 | constexpr auto ACCC_deviceptr = llvm::acc::Clause::ACCC_deviceptr; |
151 | constexpr auto ACCC_device_resident = llvm::acc::Clause::ACCC_device_resident; |
152 | constexpr auto ACCC_device_type = llvm::acc::Clause::ACCC_device_type; |
153 | constexpr auto ACCC_finalize = llvm::acc::Clause::ACCC_finalize; |
154 | constexpr auto ACCC_firstprivate = llvm::acc::Clause::ACCC_firstprivate; |
155 | constexpr auto ACCC_gang = llvm::acc::Clause::ACCC_gang; |
156 | constexpr auto ACCC_host = llvm::acc::Clause::ACCC_host; |
157 | constexpr auto ACCC_if = llvm::acc::Clause::ACCC_if; |
158 | constexpr auto ACCC_if_present = llvm::acc::Clause::ACCC_if_present; |
159 | constexpr auto ACCC_independent = llvm::acc::Clause::ACCC_independent; |
160 | constexpr auto ACCC_link = llvm::acc::Clause::ACCC_link; |
161 | constexpr auto ACCC_no_create = llvm::acc::Clause::ACCC_no_create; |
162 | constexpr auto ACCC_nohost = llvm::acc::Clause::ACCC_nohost; |
163 | constexpr auto ACCC_num_gangs = llvm::acc::Clause::ACCC_num_gangs; |
164 | constexpr auto ACCC_num_workers = llvm::acc::Clause::ACCC_num_workers; |
165 | constexpr auto ACCC_present = llvm::acc::Clause::ACCC_present; |
166 | constexpr auto ACCC_private = llvm::acc::Clause::ACCC_private; |
167 | constexpr auto ACCC_read = llvm::acc::Clause::ACCC_read; |
168 | constexpr auto ACCC_reduction = llvm::acc::Clause::ACCC_reduction; |
169 | constexpr auto ACCC_self = llvm::acc::Clause::ACCC_self; |
170 | constexpr auto ACCC_seq = llvm::acc::Clause::ACCC_seq; |
171 | constexpr auto ACCC_tile = llvm::acc::Clause::ACCC_tile; |
172 | constexpr auto ACCC_unknown = llvm::acc::Clause::ACCC_unknown; |
173 | constexpr auto ACCC_use_device = llvm::acc::Clause::ACCC_use_device; |
174 | constexpr auto ACCC_vector = llvm::acc::Clause::ACCC_vector; |
175 | constexpr auto ACCC_vector_length = llvm::acc::Clause::ACCC_vector_length; |
176 | constexpr auto ACCC_wait = llvm::acc::Clause::ACCC_wait; |
177 | constexpr auto ACCC_worker = llvm::acc::Clause::ACCC_worker; |
178 | constexpr auto ACCC_write = llvm::acc::Clause::ACCC_write; |
179 | |
180 | enum class DefaultValue { |
181 | ACC_Default_present=0, |
182 | ACC_Default_none=1, |
183 | }; |
184 | |
185 | constexpr auto ACC_Default_present = llvm::acc::DefaultValue::ACC_Default_present; |
186 | constexpr auto ACC_Default_none = llvm::acc::DefaultValue::ACC_Default_none; |
187 | |
188 | // Enumeration helper functions |
189 | Directive getOpenACCDirectiveKind(llvm::StringRef Str); |
190 | |
191 | llvm::StringRef getOpenACCDirectiveName(Directive D); |
192 | |
193 | Clause getOpenACCClauseKind(llvm::StringRef Str); |
194 | |
195 | llvm::StringRef getOpenACCClauseName(Clause C); |
196 | |
197 | /// Return true if \p C is a valid clause for \p D in version \p Version. |
198 | bool isAllowedClauseForDirective(Directive D, Clause C, unsigned Version); |
199 | |
200 | constexpr std::size_t getMaxLeafCount() { return 2; } |
201 | Association getDirectiveAssociation(Directive D); |
202 | Category getDirectiveCategory(Directive D); |
203 | DefaultValue getDefaultValue(StringRef); |
204 | llvm::StringRef getOpenACCDefaultValueName(DefaultValue); |
205 | |
206 | } // namespace acc |
207 | } // namespace llvm |
208 | #endif // LLVM_OpenACC_INC |
209 | |