1#![allow(unused)]
28
29use crate::parser::{
30 PtxParseError, PtxParser, PtxTokenStream, Span,
31 util::{
32 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
33 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
34 },
35};
36use crate::r#type::common::*;
37use crate::{alt, ok, seq_n};
38
39pub mod section_0 {
40 use super::*;
41 use crate::r#type::instruction::membar::section_0::*;
42
43 impl PtxParser for Level {
48 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
49 alt!(
50 map(string_p(".cta"), |_, _span| Level::Cta),
51 map(string_p(".sys"), |_, _span| Level::Sys),
52 map(string_p(".gl"), |_, _span| Level::Gl)
53 )
54 }
55 }
56
57 impl PtxParser for OpRestrict {
58 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
59 alt!(map(string_p(".mbarrier_init"), |_, _span| {
60 OpRestrict::MbarrierInit
61 }))
62 }
63 }
64
65 impl PtxParser for Proxykind {
66 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
67 alt!(
68 map(string_p(".async.shared::cluster"), |_, _span| {
69 Proxykind::AsyncSharedCluster
70 }),
71 map(string_p(".async.shared::cta"), |_, _span| {
72 Proxykind::AsyncSharedCta
73 }),
74 map(string_p(".async.global"), |_, _span| Proxykind::AsyncGlobal),
75 map(string_p(".alias"), |_, _span| Proxykind::Alias),
76 map(string_p(".async"), |_, _span| Proxykind::Async)
77 )
78 }
79 }
80
81 impl PtxParser for Scope {
82 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
83 alt!(
84 map(string_p(".cluster"), |_, _span| Scope::Cluster),
85 map(string_p(".cta"), |_, _span| Scope::Cta),
86 map(string_p(".gpu"), |_, _span| Scope::Gpu),
87 map(string_p(".sys"), |_, _span| Scope::Sys)
88 )
89 }
90 }
91
92 impl PtxParser for Sem {
93 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
94 alt!(
95 map(string_p(".acq_rel"), |_, _span| Sem::AcqRel),
96 map(string_p(".acquire"), |_, _span| Sem::Acquire),
97 map(string_p(".release"), |_, _span| Sem::Release),
98 map(string_p(".sc"), |_, _span| Sem::Sc)
99 )
100 }
101 }
102
103 impl PtxParser for ToProxykindFromProxykind {
104 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
105 alt!(map(string_p(".tensormap::generic"), |_, _span| {
106 ToProxykindFromProxykind::TensormapGeneric
107 }))
108 }
109 }
110
111 impl PtxParser for FenceSemScope {
112 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
113 try_map(
114 seq_n!(
115 string_p("fence"),
116 optional(Sem::parse()),
117 Scope::parse(),
118 semicolon_p()
119 ),
120 |(_, sem, scope, _), span| {
121 ok!(FenceSemScope {
122 sem = sem,
123 scope = scope,
124
125 })
126 },
127 )
128 }
129 }
130
131 impl PtxParser for FenceAcquireSyncRestrictSharedClusterCluster {
132 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
133 try_map(
134 seq_n!(
135 string_p("fence"),
136 string_p(".acquire"),
137 string_p(".sync_restrict::shared::cluster"),
138 string_p(".cluster"),
139 semicolon_p()
140 ),
141 |(_, acquire, sync_restrict_shared_cluster, cluster, _), span| {
142 ok!(FenceAcquireSyncRestrictSharedClusterCluster {
143 acquire = acquire,
144 sync_restrict_shared_cluster = sync_restrict_shared_cluster,
145 cluster = cluster,
146
147 })
148 },
149 )
150 }
151 }
152
153 impl PtxParser for FenceReleaseSyncRestrictSharedCtaCluster {
154 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
155 try_map(
156 seq_n!(
157 string_p("fence"),
158 string_p(".release"),
159 string_p(".sync_restrict::shared::cta"),
160 string_p(".cluster"),
161 semicolon_p()
162 ),
163 |(_, release, sync_restrict_shared_cta, cluster, _), span| {
164 ok!(FenceReleaseSyncRestrictSharedCtaCluster {
165 release = release,
166 sync_restrict_shared_cta = sync_restrict_shared_cta,
167 cluster = cluster,
168
169 })
170 },
171 )
172 }
173 }
174
175 impl PtxParser for FenceOpRestrictReleaseCluster {
176 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
177 try_map(
178 seq_n!(
179 string_p("fence"),
180 OpRestrict::parse(),
181 string_p(".release"),
182 string_p(".cluster"),
183 semicolon_p()
184 ),
185 |(_, op_restrict, release, cluster, _), span| {
186 ok!(FenceOpRestrictReleaseCluster {
187 op_restrict = op_restrict,
188 release = release,
189 cluster = cluster,
190
191 })
192 },
193 )
194 }
195 }
196
197 impl PtxParser for FenceProxyProxykind {
198 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
199 try_map(
200 seq_n!(
201 string_p("fence"),
202 string_p(".proxy"),
203 Proxykind::parse(),
204 semicolon_p()
205 ),
206 |(_, proxy, proxykind, _), span| {
207 ok!(FenceProxyProxykind {
208 proxy = proxy,
209 proxykind = proxykind,
210
211 })
212 },
213 )
214 }
215 }
216
217 impl PtxParser for FenceProxyToProxykindFromProxykindReleaseScope {
218 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
219 try_map(
220 seq_n!(
221 string_p("fence"),
222 string_p(".proxy"),
223 ToProxykindFromProxykind::parse(),
224 string_p(".release"),
225 Scope::parse(),
226 semicolon_p()
227 ),
228 |(_, proxy, to_proxykind_from_proxykind, release, scope, _), span| {
229 ok!(FenceProxyToProxykindFromProxykindReleaseScope {
230 proxy = proxy,
231 to_proxykind_from_proxykind = to_proxykind_from_proxykind,
232 release = release,
233 scope = scope,
234
235 })
236 },
237 )
238 }
239 }
240
241 impl PtxParser for FenceProxyToProxykindFromProxykindAcquireScope {
242 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
243 try_map(
244 seq_n!(
245 string_p("fence"),
246 string_p(".proxy"),
247 ToProxykindFromProxykind::parse(),
248 string_p(".acquire"),
249 Scope::parse(),
250 AddressOperand::parse(),
251 comma_p(),
252 GeneralOperand::parse(),
253 semicolon_p()
254 ),
255 |(_, proxy, to_proxykind_from_proxykind, acquire, scope, addr, _, size, _),
256 span| {
257 ok!(FenceProxyToProxykindFromProxykindAcquireScope {
258 proxy = proxy,
259 to_proxykind_from_proxykind = to_proxykind_from_proxykind,
260 acquire = acquire,
261 scope = scope,
262 addr = addr,
263 size = size,
264
265 })
266 },
267 )
268 }
269 }
270
271 impl PtxParser for FenceProxyAsyncGenericAcquireSyncRestrictSharedClusterCluster {
272 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
273 try_map(
274 seq_n!(
275 string_p("fence"),
276 string_p(".proxy"),
277 string_p(".async::generic"),
278 string_p(".acquire"),
279 string_p(".sync_restrict::shared::cluster"),
280 string_p(".cluster"),
281 semicolon_p()
282 ),
283 |(_, proxy, async_generic, acquire, sync_restrict_shared_cluster, cluster, _),
284 span| {
285 ok!(FenceProxyAsyncGenericAcquireSyncRestrictSharedClusterCluster {
286 proxy = proxy,
287 async_generic = async_generic,
288 acquire = acquire,
289 sync_restrict_shared_cluster = sync_restrict_shared_cluster,
290 cluster = cluster,
291
292 })
293 },
294 )
295 }
296 }
297
298 impl PtxParser for FenceProxyAsyncGenericReleaseSyncRestrictSharedCtaCluster {
299 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
300 try_map(
301 seq_n!(
302 string_p("fence"),
303 string_p(".proxy"),
304 string_p(".async::generic"),
305 string_p(".release"),
306 string_p(".sync_restrict::shared::cta"),
307 string_p(".cluster"),
308 semicolon_p()
309 ),
310 |(_, proxy, async_generic, release, sync_restrict_shared_cta, cluster, _), span| {
311 ok!(FenceProxyAsyncGenericReleaseSyncRestrictSharedCtaCluster {
312 proxy = proxy,
313 async_generic = async_generic,
314 release = release,
315 sync_restrict_shared_cta = sync_restrict_shared_cta,
316 cluster = cluster,
317
318 })
319 },
320 )
321 }
322 }
323
324 impl PtxParser for MembarLevel {
325 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
326 try_map(
327 seq_n!(string_p("membar"), Level::parse(), semicolon_p()),
328 |(_, level, _), span| {
329 ok!(MembarLevel {
330 level = level,
331
332 })
333 },
334 )
335 }
336 }
337
338 impl PtxParser for MembarProxyProxykind {
339 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
340 try_map(
341 seq_n!(
342 string_p("membar"),
343 string_p(".proxy"),
344 Proxykind::parse(),
345 semicolon_p()
346 ),
347 |(_, proxy, proxykind, _), span| {
348 ok!(MembarProxyProxykind {
349 proxy = proxy,
350 proxykind = proxykind,
351
352 })
353 },
354 )
355 }
356 }
357}