1#![allow(unused)]
15
16use crate::parser::{
17 PtxParseError, PtxParser, PtxTokenStream, Span,
18 util::{
19 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
20 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
21 },
22};
23use crate::r#type::common::*;
24use crate::{alt, ok, seq_n};
25
26pub mod section_0 {
27 use super::*;
28 use crate::r#type::instruction::vop2::section_0::*;
29
30 impl PtxParser for Asel {
35 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
36 alt!(
37 map(string_p(".h00"), |_, _span| Asel::H00),
38 map(string_p(".h01"), |_, _span| Asel::H01),
39 map(string_p(".h02"), |_, _span| Asel::H02),
40 map(string_p(".h03"), |_, _span| Asel::H03),
41 map(string_p(".h10"), |_, _span| Asel::H10),
42 map(string_p(".h11"), |_, _span| Asel::H11),
43 map(string_p(".h12"), |_, _span| Asel::H12),
44 map(string_p(".h13"), |_, _span| Asel::H13),
45 map(string_p(".h20"), |_, _span| Asel::H20),
46 map(string_p(".h21"), |_, _span| Asel::H21),
47 map(string_p(".h22"), |_, _span| Asel::H22),
48 map(string_p(".h23"), |_, _span| Asel::H23),
49 map(string_p(".h30"), |_, _span| Asel::H30),
50 map(string_p(".h31"), |_, _span| Asel::H31),
51 map(string_p(".h32"), |_, _span| Asel::H32),
52 map(string_p(".h33"), |_, _span| Asel::H33)
53 )
54 }
55 }
56
57 impl PtxParser for Atype {
58 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
59 alt!(
60 map(string_p(".u32"), |_, _span| Atype::U32),
61 map(string_p(".s32"), |_, _span| Atype::S32)
62 )
63 }
64 }
65
66 impl PtxParser for Bsel {
67 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
68 alt!(
69 map(string_p(".h00"), |_, _span| Bsel::H00),
70 map(string_p(".h01"), |_, _span| Bsel::H01),
71 map(string_p(".h02"), |_, _span| Bsel::H02),
72 map(string_p(".h03"), |_, _span| Bsel::H03),
73 map(string_p(".h10"), |_, _span| Bsel::H10),
74 map(string_p(".h11"), |_, _span| Bsel::H11),
75 map(string_p(".h12"), |_, _span| Bsel::H12),
76 map(string_p(".h13"), |_, _span| Bsel::H13),
77 map(string_p(".h20"), |_, _span| Bsel::H20),
78 map(string_p(".h21"), |_, _span| Bsel::H21),
79 map(string_p(".h22"), |_, _span| Bsel::H22),
80 map(string_p(".h23"), |_, _span| Bsel::H23),
81 map(string_p(".h30"), |_, _span| Bsel::H30),
82 map(string_p(".h31"), |_, _span| Bsel::H31),
83 map(string_p(".h32"), |_, _span| Bsel::H32),
84 map(string_p(".h33"), |_, _span| Bsel::H33)
85 )
86 }
87 }
88
89 impl PtxParser for Btype {
90 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
91 alt!(
92 map(string_p(".u32"), |_, _span| Btype::U32),
93 map(string_p(".s32"), |_, _span| Btype::S32)
94 )
95 }
96 }
97
98 impl PtxParser for Dtype {
99 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
100 alt!(
101 map(string_p(".u32"), |_, _span| Dtype::U32),
102 map(string_p(".s32"), |_, _span| Dtype::S32)
103 )
104 }
105 }
106
107 impl PtxParser for Mask {
108 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
109 alt!(
110 map(string_p(".h10"), |_, _span| Mask::H10),
111 map(string_p(".h0"), |_, _span| Mask::H0),
112 map(string_p(".h1"), |_, _span| Mask::H1)
113 )
114 }
115 }
116
117 impl PtxParser for Vadd2DtypeAtypeBtypeSat {
118 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
119 try_map(
120 seq_n!(
121 string_p("vadd2"),
122 Dtype::parse(),
123 Atype::parse(),
124 Btype::parse(),
125 map(optional(string_p(".sat")), |value, _| value.is_some()),
126 GeneralOperand::parse(),
127 optional(Mask::parse()),
128 comma_p(),
129 GeneralOperand::parse(),
130 optional(Asel::parse()),
131 comma_p(),
132 GeneralOperand::parse(),
133 optional(Bsel::parse()),
134 comma_p(),
135 GeneralOperand::parse(),
136 semicolon_p()
137 ),
138 |(_, dtype, atype, btype, sat, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
139 ok!(Vadd2DtypeAtypeBtypeSat {
140 dtype = dtype,
141 atype = atype,
142 btype = btype,
143 sat = sat,
144 d = d,
145 mask = mask,
146 a = a,
147 asel = asel,
148 b = b,
149 bsel = bsel,
150 c = c,
151
152 })
153 },
154 )
155 }
156 }
157
158 impl PtxParser for Vsub2DtypeAtypeBtypeSat {
159 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
160 try_map(
161 seq_n!(
162 string_p("vsub2"),
163 Dtype::parse(),
164 Atype::parse(),
165 Btype::parse(),
166 map(optional(string_p(".sat")), |value, _| value.is_some()),
167 GeneralOperand::parse(),
168 optional(Mask::parse()),
169 comma_p(),
170 GeneralOperand::parse(),
171 optional(Asel::parse()),
172 comma_p(),
173 GeneralOperand::parse(),
174 optional(Bsel::parse()),
175 comma_p(),
176 GeneralOperand::parse(),
177 semicolon_p()
178 ),
179 |(_, dtype, atype, btype, sat, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
180 ok!(Vsub2DtypeAtypeBtypeSat {
181 dtype = dtype,
182 atype = atype,
183 btype = btype,
184 sat = sat,
185 d = d,
186 mask = mask,
187 a = a,
188 asel = asel,
189 b = b,
190 bsel = bsel,
191 c = c,
192
193 })
194 },
195 )
196 }
197 }
198
199 impl PtxParser for Vavrg2DtypeAtypeBtypeSat {
200 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
201 try_map(
202 seq_n!(
203 string_p("vavrg2"),
204 Dtype::parse(),
205 Atype::parse(),
206 Btype::parse(),
207 map(optional(string_p(".sat")), |value, _| value.is_some()),
208 GeneralOperand::parse(),
209 optional(Mask::parse()),
210 comma_p(),
211 GeneralOperand::parse(),
212 optional(Asel::parse()),
213 comma_p(),
214 GeneralOperand::parse(),
215 optional(Bsel::parse()),
216 comma_p(),
217 GeneralOperand::parse(),
218 semicolon_p()
219 ),
220 |(_, dtype, atype, btype, sat, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
221 ok!(Vavrg2DtypeAtypeBtypeSat {
222 dtype = dtype,
223 atype = atype,
224 btype = btype,
225 sat = sat,
226 d = d,
227 mask = mask,
228 a = a,
229 asel = asel,
230 b = b,
231 bsel = bsel,
232 c = c,
233
234 })
235 },
236 )
237 }
238 }
239
240 impl PtxParser for Vabsdiff2DtypeAtypeBtypeSat {
241 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
242 try_map(
243 seq_n!(
244 string_p("vabsdiff2"),
245 Dtype::parse(),
246 Atype::parse(),
247 Btype::parse(),
248 map(optional(string_p(".sat")), |value, _| value.is_some()),
249 GeneralOperand::parse(),
250 optional(Mask::parse()),
251 comma_p(),
252 GeneralOperand::parse(),
253 optional(Asel::parse()),
254 comma_p(),
255 GeneralOperand::parse(),
256 optional(Bsel::parse()),
257 comma_p(),
258 GeneralOperand::parse(),
259 semicolon_p()
260 ),
261 |(_, dtype, atype, btype, sat, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
262 ok!(Vabsdiff2DtypeAtypeBtypeSat {
263 dtype = dtype,
264 atype = atype,
265 btype = btype,
266 sat = sat,
267 d = d,
268 mask = mask,
269 a = a,
270 asel = asel,
271 b = b,
272 bsel = bsel,
273 c = c,
274
275 })
276 },
277 )
278 }
279 }
280
281 impl PtxParser for Vmin2DtypeAtypeBtypeSat {
282 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
283 try_map(
284 seq_n!(
285 string_p("vmin2"),
286 Dtype::parse(),
287 Atype::parse(),
288 Btype::parse(),
289 map(optional(string_p(".sat")), |value, _| value.is_some()),
290 GeneralOperand::parse(),
291 optional(Mask::parse()),
292 comma_p(),
293 GeneralOperand::parse(),
294 optional(Asel::parse()),
295 comma_p(),
296 GeneralOperand::parse(),
297 optional(Bsel::parse()),
298 comma_p(),
299 GeneralOperand::parse(),
300 semicolon_p()
301 ),
302 |(_, dtype, atype, btype, sat, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
303 ok!(Vmin2DtypeAtypeBtypeSat {
304 dtype = dtype,
305 atype = atype,
306 btype = btype,
307 sat = sat,
308 d = d,
309 mask = mask,
310 a = a,
311 asel = asel,
312 b = b,
313 bsel = bsel,
314 c = c,
315
316 })
317 },
318 )
319 }
320 }
321
322 impl PtxParser for Vmax2DtypeAtypeBtypeSat {
323 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
324 try_map(
325 seq_n!(
326 string_p("vmax2"),
327 Dtype::parse(),
328 Atype::parse(),
329 Btype::parse(),
330 map(optional(string_p(".sat")), |value, _| value.is_some()),
331 GeneralOperand::parse(),
332 optional(Mask::parse()),
333 comma_p(),
334 GeneralOperand::parse(),
335 optional(Asel::parse()),
336 comma_p(),
337 GeneralOperand::parse(),
338 optional(Bsel::parse()),
339 comma_p(),
340 GeneralOperand::parse(),
341 semicolon_p()
342 ),
343 |(_, dtype, atype, btype, sat, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
344 ok!(Vmax2DtypeAtypeBtypeSat {
345 dtype = dtype,
346 atype = atype,
347 btype = btype,
348 sat = sat,
349 d = d,
350 mask = mask,
351 a = a,
352 asel = asel,
353 b = b,
354 bsel = bsel,
355 c = c,
356
357 })
358 },
359 )
360 }
361 }
362
363 impl PtxParser for Vadd2DtypeAtypeBtypeAdd {
364 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
365 try_map(
366 seq_n!(
367 string_p("vadd2"),
368 Dtype::parse(),
369 Atype::parse(),
370 Btype::parse(),
371 string_p(".add"),
372 GeneralOperand::parse(),
373 optional(Mask::parse()),
374 comma_p(),
375 GeneralOperand::parse(),
376 optional(Asel::parse()),
377 comma_p(),
378 GeneralOperand::parse(),
379 optional(Bsel::parse()),
380 comma_p(),
381 GeneralOperand::parse(),
382 semicolon_p()
383 ),
384 |(_, dtype, atype, btype, add, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
385 ok!(Vadd2DtypeAtypeBtypeAdd {
386 dtype = dtype,
387 atype = atype,
388 btype = btype,
389 add = add,
390 d = d,
391 mask = mask,
392 a = a,
393 asel = asel,
394 b = b,
395 bsel = bsel,
396 c = c,
397
398 })
399 },
400 )
401 }
402 }
403
404 impl PtxParser for Vsub2DtypeAtypeBtypeAdd {
405 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
406 try_map(
407 seq_n!(
408 string_p("vsub2"),
409 Dtype::parse(),
410 Atype::parse(),
411 Btype::parse(),
412 string_p(".add"),
413 GeneralOperand::parse(),
414 optional(Mask::parse()),
415 comma_p(),
416 GeneralOperand::parse(),
417 optional(Asel::parse()),
418 comma_p(),
419 GeneralOperand::parse(),
420 optional(Bsel::parse()),
421 comma_p(),
422 GeneralOperand::parse(),
423 semicolon_p()
424 ),
425 |(_, dtype, atype, btype, add, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
426 ok!(Vsub2DtypeAtypeBtypeAdd {
427 dtype = dtype,
428 atype = atype,
429 btype = btype,
430 add = add,
431 d = d,
432 mask = mask,
433 a = a,
434 asel = asel,
435 b = b,
436 bsel = bsel,
437 c = c,
438
439 })
440 },
441 )
442 }
443 }
444
445 impl PtxParser for Vavrg2DtypeAtypeBtypeAdd {
446 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
447 try_map(
448 seq_n!(
449 string_p("vavrg2"),
450 Dtype::parse(),
451 Atype::parse(),
452 Btype::parse(),
453 string_p(".add"),
454 GeneralOperand::parse(),
455 optional(Mask::parse()),
456 comma_p(),
457 GeneralOperand::parse(),
458 optional(Asel::parse()),
459 comma_p(),
460 GeneralOperand::parse(),
461 optional(Bsel::parse()),
462 comma_p(),
463 GeneralOperand::parse(),
464 semicolon_p()
465 ),
466 |(_, dtype, atype, btype, add, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
467 ok!(Vavrg2DtypeAtypeBtypeAdd {
468 dtype = dtype,
469 atype = atype,
470 btype = btype,
471 add = add,
472 d = d,
473 mask = mask,
474 a = a,
475 asel = asel,
476 b = b,
477 bsel = bsel,
478 c = c,
479
480 })
481 },
482 )
483 }
484 }
485
486 impl PtxParser for Vabsdiff2DtypeAtypeBtypeAdd {
487 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
488 try_map(
489 seq_n!(
490 string_p("vabsdiff2"),
491 Dtype::parse(),
492 Atype::parse(),
493 Btype::parse(),
494 string_p(".add"),
495 GeneralOperand::parse(),
496 optional(Mask::parse()),
497 comma_p(),
498 GeneralOperand::parse(),
499 optional(Asel::parse()),
500 comma_p(),
501 GeneralOperand::parse(),
502 optional(Bsel::parse()),
503 comma_p(),
504 GeneralOperand::parse(),
505 semicolon_p()
506 ),
507 |(_, dtype, atype, btype, add, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
508 ok!(Vabsdiff2DtypeAtypeBtypeAdd {
509 dtype = dtype,
510 atype = atype,
511 btype = btype,
512 add = add,
513 d = d,
514 mask = mask,
515 a = a,
516 asel = asel,
517 b = b,
518 bsel = bsel,
519 c = c,
520
521 })
522 },
523 )
524 }
525 }
526
527 impl PtxParser for Vmin2DtypeAtypeBtypeAdd {
528 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
529 try_map(
530 seq_n!(
531 string_p("vmin2"),
532 Dtype::parse(),
533 Atype::parse(),
534 Btype::parse(),
535 string_p(".add"),
536 GeneralOperand::parse(),
537 optional(Mask::parse()),
538 comma_p(),
539 GeneralOperand::parse(),
540 optional(Asel::parse()),
541 comma_p(),
542 GeneralOperand::parse(),
543 optional(Bsel::parse()),
544 comma_p(),
545 GeneralOperand::parse(),
546 semicolon_p()
547 ),
548 |(_, dtype, atype, btype, add, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
549 ok!(Vmin2DtypeAtypeBtypeAdd {
550 dtype = dtype,
551 atype = atype,
552 btype = btype,
553 add = add,
554 d = d,
555 mask = mask,
556 a = a,
557 asel = asel,
558 b = b,
559 bsel = bsel,
560 c = c,
561
562 })
563 },
564 )
565 }
566 }
567
568 impl PtxParser for Vmax2DtypeAtypeBtypeAdd {
569 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
570 try_map(
571 seq_n!(
572 string_p("vmax2"),
573 Dtype::parse(),
574 Atype::parse(),
575 Btype::parse(),
576 string_p(".add"),
577 GeneralOperand::parse(),
578 optional(Mask::parse()),
579 comma_p(),
580 GeneralOperand::parse(),
581 optional(Asel::parse()),
582 comma_p(),
583 GeneralOperand::parse(),
584 optional(Bsel::parse()),
585 comma_p(),
586 GeneralOperand::parse(),
587 semicolon_p()
588 ),
589 |(_, dtype, atype, btype, add, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
590 ok!(Vmax2DtypeAtypeBtypeAdd {
591 dtype = dtype,
592 atype = atype,
593 btype = btype,
594 add = add,
595 d = d,
596 mask = mask,
597 a = a,
598 asel = asel,
599 b = b,
600 bsel = bsel,
601 c = c,
602
603 })
604 },
605 )
606 }
607 }
608}