Skip to main content

ptx_parser/parser/instruction/
wmma_load.rs

1//! Original PTX specification:
2//!
3//! // Floating point format .f16 loads:
4//! wmma.load.a.sync.aligned.layout.shape{.ss}.atype r, [p] {, stride};
5//! wmma.load.b.sync.aligned.layout.shape{.ss}.btype r, [p] {, stride};
6//! wmma.load.c.sync.aligned.layout.shape{.ss}.ctype r, [p] {, stride};
7//! .layout = {.row, .col};
8//! .shape  = {.m16n16k16, .m8n32k16, .m32n8k16};
9//! .ss     = {.global, .shared, .shared::cta};
10//! .atype  = {.f16, .s8, .u8};
11//! .btype  = {.f16, .s8, .u8};
12//! .ctype  = {.f16, .f32, .s32};
13//! ----------------------------------------------------------------
14//! // Alternate floating point format .bf16 loads:
15//! wmma.load.a.sync.aligned.layout.shape{.ss}.atype r, [p] {, stride};
16//! wmma.load.b.sync.aligned.layout.shape{.ss}.btype r, [p] {, stride};
17//! wmma.load.c.sync.aligned.layout.shape{.ss}.ctype r, [p] {, stride};
18//! .layout = {.row, .col};
19//! .shape  = {.m16n16k16, .m8n32k16, .m32n8k16};
20//! .ss     = {.global, .shared, .shared::cta};
21//! .atype  = {.bf16 };
22//! .btype  = {.bf16 };
23//! .ctype  = {.f32 };
24//! ----------------------------------------------------------------
25//! // Alternate floating point format .tf32 loads:
26//! wmma.load.a.sync.aligned.layout.shape{.ss}.atype r, [p] {, stride};
27//! wmma.load.b.sync.aligned.layout.shape{.ss}.btype r, [p] {, stride};
28//! wmma.load.c.sync.aligned.layout.shape{.ss}.ctype r, [p] {, stride};
29//! .layout = {.row, .col};
30//! .shape  = {.m16n16k8 };
31//! .ss     = {.global, .shared, .shared::cta};
32//! .atype  = {.tf32 };
33//! .btype  = {.tf32 };
34//! .ctype  = {.f32 };
35//! ----------------------------------------------------------------
36//! // Double precision Floating point .f64 loads:
37//! wmma.load.a.sync.aligned.layout.shape{.ss}.atype r, [p] {, stride};
38//! wmma.load.b.sync.aligned.layout.shape{.ss}.btype r, [p] {, stride};
39//! wmma.load.c.sync.aligned.layout.shape{.ss}.ctype r, [p] {, stride};
40//! .layout = {.row, .col};
41//! .shape  = {.m8n8k4 };
42//! .ss     = {.global, .shared, .shared::cta};
43//! .atype  = {.f64 };
44//! .btype  = {.f64 };
45//! .ctype  = {.f64 };
46//! ----------------------------------------------------------------
47//! // Sub-byte loads:
48//! wmma.load.a.sync.aligned.row.shape{.ss}.atype r, [p] {, stride};
49//! wmma.load.b.sync.aligned.col.shape{.ss}.btype r, [p] {, stride};
50//! wmma.load.c.sync.aligned.layout.shape{.ss}.ctype r, [p] {, stride};
51//! .layout = {.row, .col};
52//! .shape  = {.m8n8k32};
53//! .ss     = {.global, .shared, .shared::cta};
54//! .atype  = {.s4, .u4};
55//! .btype  = {.s4, .u4};
56//! .ctype  = {.s32};
57//! ----------------------------------------------------------------
58//! // Single-bit loads:
59//! wmma.load.a.sync.aligned.row.shape{.ss}.atype r, [p] {, stride};
60//! wmma.load.b.sync.aligned.col.shape{.ss}.btype r, [p] {, stride};
61//! wmma.load.c.sync.aligned.layout.shape{.ss}.ctype r, [p] {, stride};
62//! .layout = {.row, .col};
63//! .shape  = {.m8n8k128};
64//! .ss     = {.global, .shared, .shared::cta};
65//! .atype  = {.b1};
66//! .btype  = {.b1};
67//! .ctype  = {.s32};
68
69#![allow(unused)]
70
71use crate::parser::{
72    PtxParseError, PtxParser, PtxTokenStream, Span,
73    util::{
74        between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
75        pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
76    },
77};
78use crate::r#type::common::*;
79use crate::{alt, ok, seq_n};
80
81pub mod section_0 {
82    use super::*;
83    use crate::r#type::instruction::wmma_load::section_0::*;
84
85    // ============================================================================
86    // Generated enum parsers
87    // ============================================================================
88
89    impl PtxParser for Atype {
90        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
91            alt!(
92                map(string_p(".f16"), |_, _span| Atype::F16),
93                map(string_p(".s8"), |_, _span| Atype::S8),
94                map(string_p(".u8"), |_, _span| Atype::U8)
95            )
96        }
97    }
98
99    impl PtxParser for Btype {
100        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
101            alt!(
102                map(string_p(".f16"), |_, _span| Btype::F16),
103                map(string_p(".s8"), |_, _span| Btype::S8),
104                map(string_p(".u8"), |_, _span| Btype::U8)
105            )
106        }
107    }
108
109    impl PtxParser for Ctype {
110        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
111            alt!(
112                map(string_p(".f16"), |_, _span| Ctype::F16),
113                map(string_p(".f32"), |_, _span| Ctype::F32),
114                map(string_p(".s32"), |_, _span| Ctype::S32)
115            )
116        }
117    }
118
119    impl PtxParser for Layout {
120        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
121            alt!(
122                map(string_p(".row"), |_, _span| Layout::Row),
123                map(string_p(".col"), |_, _span| Layout::Col)
124            )
125        }
126    }
127
128    impl PtxParser for Shape {
129        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
130            alt!(
131                map(string_p(".m16n16k16"), |_, _span| Shape::M16n16k16),
132                map(string_p(".m8n32k16"), |_, _span| Shape::M8n32k16),
133                map(string_p(".m32n8k16"), |_, _span| Shape::M32n8k16)
134            )
135        }
136    }
137
138    impl PtxParser for Ss {
139        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
140            alt!(
141                map(string_p(".shared::cta"), |_, _span| Ss::SharedCta),
142                map(string_p(".global"), |_, _span| Ss::Global),
143                map(string_p(".shared"), |_, _span| Ss::Shared)
144            )
145        }
146    }
147
148    impl PtxParser for WmmaLoadASyncAlignedLayoutShapeSsAtype {
149        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
150            try_map(
151                seq_n!(
152                    string_p("wmma"),
153                    string_p(".load"),
154                    string_p(".a"),
155                    string_p(".sync"),
156                    string_p(".aligned"),
157                    Layout::parse(),
158                    Shape::parse(),
159                    optional(Ss::parse()),
160                    Atype::parse(),
161                    GeneralOperand::parse(),
162                    comma_p(),
163                    AddressOperand::parse(),
164                    map(
165                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
166                        |value, _| value.map(|(_, operand)| operand)
167                    ),
168                    semicolon_p()
169                ),
170                |(_, load, a, sync, aligned, layout, shape, ss, atype, r, _, p, stride, _),
171                 span| {
172                    ok!(WmmaLoadASyncAlignedLayoutShapeSsAtype {
173                        load = load,
174                        a = a,
175                        sync = sync,
176                        aligned = aligned,
177                        layout = layout,
178                        shape = shape,
179                        ss = ss,
180                        atype = atype,
181                        r = r,
182                        p = p,
183                        stride = stride,
184
185                    })
186                },
187            )
188        }
189    }
190
191    impl PtxParser for WmmaLoadBSyncAlignedLayoutShapeSsBtype {
192        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
193            try_map(
194                seq_n!(
195                    string_p("wmma"),
196                    string_p(".load"),
197                    string_p(".b"),
198                    string_p(".sync"),
199                    string_p(".aligned"),
200                    Layout::parse(),
201                    Shape::parse(),
202                    optional(Ss::parse()),
203                    Btype::parse(),
204                    GeneralOperand::parse(),
205                    comma_p(),
206                    AddressOperand::parse(),
207                    map(
208                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
209                        |value, _| value.map(|(_, operand)| operand)
210                    ),
211                    semicolon_p()
212                ),
213                |(_, load, b, sync, aligned, layout, shape, ss, btype, r, _, p, stride, _),
214                 span| {
215                    ok!(WmmaLoadBSyncAlignedLayoutShapeSsBtype {
216                        load = load,
217                        b = b,
218                        sync = sync,
219                        aligned = aligned,
220                        layout = layout,
221                        shape = shape,
222                        ss = ss,
223                        btype = btype,
224                        r = r,
225                        p = p,
226                        stride = stride,
227
228                    })
229                },
230            )
231        }
232    }
233
234    impl PtxParser for WmmaLoadCSyncAlignedLayoutShapeSsCtype {
235        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
236            try_map(
237                seq_n!(
238                    string_p("wmma"),
239                    string_p(".load"),
240                    string_p(".c"),
241                    string_p(".sync"),
242                    string_p(".aligned"),
243                    Layout::parse(),
244                    Shape::parse(),
245                    optional(Ss::parse()),
246                    Ctype::parse(),
247                    GeneralOperand::parse(),
248                    comma_p(),
249                    AddressOperand::parse(),
250                    map(
251                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
252                        |value, _| value.map(|(_, operand)| operand)
253                    ),
254                    semicolon_p()
255                ),
256                |(_, load, c, sync, aligned, layout, shape, ss, ctype, r, _, p, stride, _),
257                 span| {
258                    ok!(WmmaLoadCSyncAlignedLayoutShapeSsCtype {
259                        load = load,
260                        c = c,
261                        sync = sync,
262                        aligned = aligned,
263                        layout = layout,
264                        shape = shape,
265                        ss = ss,
266                        ctype = ctype,
267                        r = r,
268                        p = p,
269                        stride = stride,
270
271                    })
272                },
273            )
274        }
275    }
276}
277
278pub mod section_1 {
279    use super::*;
280    use crate::r#type::instruction::wmma_load::section_1::*;
281
282    // ============================================================================
283    // Generated enum parsers
284    // ============================================================================
285
286    impl PtxParser for Atype {
287        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
288            alt!(map(string_p(".bf16"), |_, _span| Atype::Bf16))
289        }
290    }
291
292    impl PtxParser for Btype {
293        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
294            alt!(map(string_p(".bf16"), |_, _span| Btype::Bf16))
295        }
296    }
297
298    impl PtxParser for Ctype {
299        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
300            alt!(map(string_p(".f32"), |_, _span| Ctype::F32))
301        }
302    }
303
304    impl PtxParser for Layout {
305        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
306            alt!(
307                map(string_p(".row"), |_, _span| Layout::Row),
308                map(string_p(".col"), |_, _span| Layout::Col)
309            )
310        }
311    }
312
313    impl PtxParser for Shape {
314        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
315            alt!(
316                map(string_p(".m16n16k16"), |_, _span| Shape::M16n16k16),
317                map(string_p(".m8n32k16"), |_, _span| Shape::M8n32k16),
318                map(string_p(".m32n8k16"), |_, _span| Shape::M32n8k16)
319            )
320        }
321    }
322
323    impl PtxParser for Ss {
324        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
325            alt!(
326                map(string_p(".shared::cta"), |_, _span| Ss::SharedCta),
327                map(string_p(".global"), |_, _span| Ss::Global),
328                map(string_p(".shared"), |_, _span| Ss::Shared)
329            )
330        }
331    }
332
333    impl PtxParser for WmmaLoadASyncAlignedLayoutShapeSsAtype1 {
334        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
335            try_map(
336                seq_n!(
337                    string_p("wmma"),
338                    string_p(".load"),
339                    string_p(".a"),
340                    string_p(".sync"),
341                    string_p(".aligned"),
342                    Layout::parse(),
343                    Shape::parse(),
344                    optional(Ss::parse()),
345                    Atype::parse(),
346                    GeneralOperand::parse(),
347                    comma_p(),
348                    AddressOperand::parse(),
349                    map(
350                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
351                        |value, _| value.map(|(_, operand)| operand)
352                    ),
353                    semicolon_p()
354                ),
355                |(_, load, a, sync, aligned, layout, shape, ss, atype, r, _, p, stride, _),
356                 span| {
357                    ok!(WmmaLoadASyncAlignedLayoutShapeSsAtype1 {
358                        load = load,
359                        a = a,
360                        sync = sync,
361                        aligned = aligned,
362                        layout = layout,
363                        shape = shape,
364                        ss = ss,
365                        atype = atype,
366                        r = r,
367                        p = p,
368                        stride = stride,
369
370                    })
371                },
372            )
373        }
374    }
375
376    impl PtxParser for WmmaLoadBSyncAlignedLayoutShapeSsBtype1 {
377        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
378            try_map(
379                seq_n!(
380                    string_p("wmma"),
381                    string_p(".load"),
382                    string_p(".b"),
383                    string_p(".sync"),
384                    string_p(".aligned"),
385                    Layout::parse(),
386                    Shape::parse(),
387                    optional(Ss::parse()),
388                    Btype::parse(),
389                    GeneralOperand::parse(),
390                    comma_p(),
391                    AddressOperand::parse(),
392                    map(
393                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
394                        |value, _| value.map(|(_, operand)| operand)
395                    ),
396                    semicolon_p()
397                ),
398                |(_, load, b, sync, aligned, layout, shape, ss, btype, r, _, p, stride, _),
399                 span| {
400                    ok!(WmmaLoadBSyncAlignedLayoutShapeSsBtype1 {
401                        load = load,
402                        b = b,
403                        sync = sync,
404                        aligned = aligned,
405                        layout = layout,
406                        shape = shape,
407                        ss = ss,
408                        btype = btype,
409                        r = r,
410                        p = p,
411                        stride = stride,
412
413                    })
414                },
415            )
416        }
417    }
418
419    impl PtxParser for WmmaLoadCSyncAlignedLayoutShapeSsCtype1 {
420        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
421            try_map(
422                seq_n!(
423                    string_p("wmma"),
424                    string_p(".load"),
425                    string_p(".c"),
426                    string_p(".sync"),
427                    string_p(".aligned"),
428                    Layout::parse(),
429                    Shape::parse(),
430                    optional(Ss::parse()),
431                    Ctype::parse(),
432                    GeneralOperand::parse(),
433                    comma_p(),
434                    AddressOperand::parse(),
435                    map(
436                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
437                        |value, _| value.map(|(_, operand)| operand)
438                    ),
439                    semicolon_p()
440                ),
441                |(_, load, c, sync, aligned, layout, shape, ss, ctype, r, _, p, stride, _),
442                 span| {
443                    ok!(WmmaLoadCSyncAlignedLayoutShapeSsCtype1 {
444                        load = load,
445                        c = c,
446                        sync = sync,
447                        aligned = aligned,
448                        layout = layout,
449                        shape = shape,
450                        ss = ss,
451                        ctype = ctype,
452                        r = r,
453                        p = p,
454                        stride = stride,
455
456                    })
457                },
458            )
459        }
460    }
461}
462
463pub mod section_2 {
464    use super::*;
465    use crate::r#type::instruction::wmma_load::section_2::*;
466
467    // ============================================================================
468    // Generated enum parsers
469    // ============================================================================
470
471    impl PtxParser for Atype {
472        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
473            alt!(map(string_p(".tf32"), |_, _span| Atype::Tf32))
474        }
475    }
476
477    impl PtxParser for Btype {
478        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
479            alt!(map(string_p(".tf32"), |_, _span| Btype::Tf32))
480        }
481    }
482
483    impl PtxParser for Ctype {
484        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
485            alt!(map(string_p(".f32"), |_, _span| Ctype::F32))
486        }
487    }
488
489    impl PtxParser for Layout {
490        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
491            alt!(
492                map(string_p(".row"), |_, _span| Layout::Row),
493                map(string_p(".col"), |_, _span| Layout::Col)
494            )
495        }
496    }
497
498    impl PtxParser for Shape {
499        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
500            alt!(map(string_p(".m16n16k8"), |_, _span| Shape::M16n16k8))
501        }
502    }
503
504    impl PtxParser for Ss {
505        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
506            alt!(
507                map(string_p(".shared::cta"), |_, _span| Ss::SharedCta),
508                map(string_p(".global"), |_, _span| Ss::Global),
509                map(string_p(".shared"), |_, _span| Ss::Shared)
510            )
511        }
512    }
513
514    impl PtxParser for WmmaLoadASyncAlignedLayoutShapeSsAtype2 {
515        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
516            try_map(
517                seq_n!(
518                    string_p("wmma"),
519                    string_p(".load"),
520                    string_p(".a"),
521                    string_p(".sync"),
522                    string_p(".aligned"),
523                    Layout::parse(),
524                    Shape::parse(),
525                    optional(Ss::parse()),
526                    Atype::parse(),
527                    GeneralOperand::parse(),
528                    comma_p(),
529                    AddressOperand::parse(),
530                    map(
531                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
532                        |value, _| value.map(|(_, operand)| operand)
533                    ),
534                    semicolon_p()
535                ),
536                |(_, load, a, sync, aligned, layout, shape, ss, atype, r, _, p, stride, _),
537                 span| {
538                    ok!(WmmaLoadASyncAlignedLayoutShapeSsAtype2 {
539                        load = load,
540                        a = a,
541                        sync = sync,
542                        aligned = aligned,
543                        layout = layout,
544                        shape = shape,
545                        ss = ss,
546                        atype = atype,
547                        r = r,
548                        p = p,
549                        stride = stride,
550
551                    })
552                },
553            )
554        }
555    }
556
557    impl PtxParser for WmmaLoadBSyncAlignedLayoutShapeSsBtype2 {
558        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
559            try_map(
560                seq_n!(
561                    string_p("wmma"),
562                    string_p(".load"),
563                    string_p(".b"),
564                    string_p(".sync"),
565                    string_p(".aligned"),
566                    Layout::parse(),
567                    Shape::parse(),
568                    optional(Ss::parse()),
569                    Btype::parse(),
570                    GeneralOperand::parse(),
571                    comma_p(),
572                    AddressOperand::parse(),
573                    map(
574                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
575                        |value, _| value.map(|(_, operand)| operand)
576                    ),
577                    semicolon_p()
578                ),
579                |(_, load, b, sync, aligned, layout, shape, ss, btype, r, _, p, stride, _),
580                 span| {
581                    ok!(WmmaLoadBSyncAlignedLayoutShapeSsBtype2 {
582                        load = load,
583                        b = b,
584                        sync = sync,
585                        aligned = aligned,
586                        layout = layout,
587                        shape = shape,
588                        ss = ss,
589                        btype = btype,
590                        r = r,
591                        p = p,
592                        stride = stride,
593
594                    })
595                },
596            )
597        }
598    }
599
600    impl PtxParser for WmmaLoadCSyncAlignedLayoutShapeSsCtype2 {
601        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
602            try_map(
603                seq_n!(
604                    string_p("wmma"),
605                    string_p(".load"),
606                    string_p(".c"),
607                    string_p(".sync"),
608                    string_p(".aligned"),
609                    Layout::parse(),
610                    Shape::parse(),
611                    optional(Ss::parse()),
612                    Ctype::parse(),
613                    GeneralOperand::parse(),
614                    comma_p(),
615                    AddressOperand::parse(),
616                    map(
617                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
618                        |value, _| value.map(|(_, operand)| operand)
619                    ),
620                    semicolon_p()
621                ),
622                |(_, load, c, sync, aligned, layout, shape, ss, ctype, r, _, p, stride, _),
623                 span| {
624                    ok!(WmmaLoadCSyncAlignedLayoutShapeSsCtype2 {
625                        load = load,
626                        c = c,
627                        sync = sync,
628                        aligned = aligned,
629                        layout = layout,
630                        shape = shape,
631                        ss = ss,
632                        ctype = ctype,
633                        r = r,
634                        p = p,
635                        stride = stride,
636
637                    })
638                },
639            )
640        }
641    }
642}
643
644pub mod section_3 {
645    use super::*;
646    use crate::r#type::instruction::wmma_load::section_3::*;
647
648    // ============================================================================
649    // Generated enum parsers
650    // ============================================================================
651
652    impl PtxParser for Atype {
653        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
654            alt!(map(string_p(".f64"), |_, _span| Atype::F64))
655        }
656    }
657
658    impl PtxParser for Btype {
659        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
660            alt!(map(string_p(".f64"), |_, _span| Btype::F64))
661        }
662    }
663
664    impl PtxParser for Ctype {
665        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
666            alt!(map(string_p(".f64"), |_, _span| Ctype::F64))
667        }
668    }
669
670    impl PtxParser for Layout {
671        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
672            alt!(
673                map(string_p(".row"), |_, _span| Layout::Row),
674                map(string_p(".col"), |_, _span| Layout::Col)
675            )
676        }
677    }
678
679    impl PtxParser for Shape {
680        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
681            alt!(map(string_p(".m8n8k4"), |_, _span| Shape::M8n8k4))
682        }
683    }
684
685    impl PtxParser for Ss {
686        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
687            alt!(
688                map(string_p(".shared::cta"), |_, _span| Ss::SharedCta),
689                map(string_p(".global"), |_, _span| Ss::Global),
690                map(string_p(".shared"), |_, _span| Ss::Shared)
691            )
692        }
693    }
694
695    impl PtxParser for WmmaLoadASyncAlignedLayoutShapeSsAtype3 {
696        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
697            try_map(
698                seq_n!(
699                    string_p("wmma"),
700                    string_p(".load"),
701                    string_p(".a"),
702                    string_p(".sync"),
703                    string_p(".aligned"),
704                    Layout::parse(),
705                    Shape::parse(),
706                    optional(Ss::parse()),
707                    Atype::parse(),
708                    GeneralOperand::parse(),
709                    comma_p(),
710                    AddressOperand::parse(),
711                    map(
712                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
713                        |value, _| value.map(|(_, operand)| operand)
714                    ),
715                    semicolon_p()
716                ),
717                |(_, load, a, sync, aligned, layout, shape, ss, atype, r, _, p, stride, _),
718                 span| {
719                    ok!(WmmaLoadASyncAlignedLayoutShapeSsAtype3 {
720                        load = load,
721                        a = a,
722                        sync = sync,
723                        aligned = aligned,
724                        layout = layout,
725                        shape = shape,
726                        ss = ss,
727                        atype = atype,
728                        r = r,
729                        p = p,
730                        stride = stride,
731
732                    })
733                },
734            )
735        }
736    }
737
738    impl PtxParser for WmmaLoadBSyncAlignedLayoutShapeSsBtype3 {
739        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
740            try_map(
741                seq_n!(
742                    string_p("wmma"),
743                    string_p(".load"),
744                    string_p(".b"),
745                    string_p(".sync"),
746                    string_p(".aligned"),
747                    Layout::parse(),
748                    Shape::parse(),
749                    optional(Ss::parse()),
750                    Btype::parse(),
751                    GeneralOperand::parse(),
752                    comma_p(),
753                    AddressOperand::parse(),
754                    map(
755                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
756                        |value, _| value.map(|(_, operand)| operand)
757                    ),
758                    semicolon_p()
759                ),
760                |(_, load, b, sync, aligned, layout, shape, ss, btype, r, _, p, stride, _),
761                 span| {
762                    ok!(WmmaLoadBSyncAlignedLayoutShapeSsBtype3 {
763                        load = load,
764                        b = b,
765                        sync = sync,
766                        aligned = aligned,
767                        layout = layout,
768                        shape = shape,
769                        ss = ss,
770                        btype = btype,
771                        r = r,
772                        p = p,
773                        stride = stride,
774
775                    })
776                },
777            )
778        }
779    }
780
781    impl PtxParser for WmmaLoadCSyncAlignedLayoutShapeSsCtype3 {
782        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
783            try_map(
784                seq_n!(
785                    string_p("wmma"),
786                    string_p(".load"),
787                    string_p(".c"),
788                    string_p(".sync"),
789                    string_p(".aligned"),
790                    Layout::parse(),
791                    Shape::parse(),
792                    optional(Ss::parse()),
793                    Ctype::parse(),
794                    GeneralOperand::parse(),
795                    comma_p(),
796                    AddressOperand::parse(),
797                    map(
798                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
799                        |value, _| value.map(|(_, operand)| operand)
800                    ),
801                    semicolon_p()
802                ),
803                |(_, load, c, sync, aligned, layout, shape, ss, ctype, r, _, p, stride, _),
804                 span| {
805                    ok!(WmmaLoadCSyncAlignedLayoutShapeSsCtype3 {
806                        load = load,
807                        c = c,
808                        sync = sync,
809                        aligned = aligned,
810                        layout = layout,
811                        shape = shape,
812                        ss = ss,
813                        ctype = ctype,
814                        r = r,
815                        p = p,
816                        stride = stride,
817
818                    })
819                },
820            )
821        }
822    }
823}
824
825pub mod section_4 {
826    use super::*;
827    use crate::r#type::instruction::wmma_load::section_4::*;
828
829    // ============================================================================
830    // Generated enum parsers
831    // ============================================================================
832
833    impl PtxParser for Atype {
834        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
835            alt!(
836                map(string_p(".s4"), |_, _span| Atype::S4),
837                map(string_p(".u4"), |_, _span| Atype::U4)
838            )
839        }
840    }
841
842    impl PtxParser for Btype {
843        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
844            alt!(
845                map(string_p(".s4"), |_, _span| Btype::S4),
846                map(string_p(".u4"), |_, _span| Btype::U4)
847            )
848        }
849    }
850
851    impl PtxParser for Ctype {
852        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
853            alt!(map(string_p(".s32"), |_, _span| Ctype::S32))
854        }
855    }
856
857    impl PtxParser for Layout {
858        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
859            alt!(
860                map(string_p(".row"), |_, _span| Layout::Row),
861                map(string_p(".col"), |_, _span| Layout::Col)
862            )
863        }
864    }
865
866    impl PtxParser for Shape {
867        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
868            alt!(map(string_p(".m8n8k32"), |_, _span| Shape::M8n8k32))
869        }
870    }
871
872    impl PtxParser for Ss {
873        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
874            alt!(
875                map(string_p(".shared::cta"), |_, _span| Ss::SharedCta),
876                map(string_p(".global"), |_, _span| Ss::Global),
877                map(string_p(".shared"), |_, _span| Ss::Shared)
878            )
879        }
880    }
881
882    impl PtxParser for WmmaLoadASyncAlignedRowShapeSsAtype {
883        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
884            try_map(
885                seq_n!(
886                    string_p("wmma"),
887                    string_p(".load"),
888                    string_p(".a"),
889                    string_p(".sync"),
890                    string_p(".aligned"),
891                    string_p(".row"),
892                    Shape::parse(),
893                    optional(Ss::parse()),
894                    Atype::parse(),
895                    GeneralOperand::parse(),
896                    comma_p(),
897                    AddressOperand::parse(),
898                    map(
899                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
900                        |value, _| value.map(|(_, operand)| operand)
901                    ),
902                    semicolon_p()
903                ),
904                |(_, load, a, sync, aligned, row, shape, ss, atype, r, _, p, stride, _), span| {
905                    ok!(WmmaLoadASyncAlignedRowShapeSsAtype {
906                        load = load,
907                        a = a,
908                        sync = sync,
909                        aligned = aligned,
910                        row = row,
911                        shape = shape,
912                        ss = ss,
913                        atype = atype,
914                        r = r,
915                        p = p,
916                        stride = stride,
917
918                    })
919                },
920            )
921        }
922    }
923
924    impl PtxParser for WmmaLoadBSyncAlignedColShapeSsBtype {
925        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
926            try_map(
927                seq_n!(
928                    string_p("wmma"),
929                    string_p(".load"),
930                    string_p(".b"),
931                    string_p(".sync"),
932                    string_p(".aligned"),
933                    string_p(".col"),
934                    Shape::parse(),
935                    optional(Ss::parse()),
936                    Btype::parse(),
937                    GeneralOperand::parse(),
938                    comma_p(),
939                    AddressOperand::parse(),
940                    map(
941                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
942                        |value, _| value.map(|(_, operand)| operand)
943                    ),
944                    semicolon_p()
945                ),
946                |(_, load, b, sync, aligned, col, shape, ss, btype, r, _, p, stride, _), span| {
947                    ok!(WmmaLoadBSyncAlignedColShapeSsBtype {
948                        load = load,
949                        b = b,
950                        sync = sync,
951                        aligned = aligned,
952                        col = col,
953                        shape = shape,
954                        ss = ss,
955                        btype = btype,
956                        r = r,
957                        p = p,
958                        stride = stride,
959
960                    })
961                },
962            )
963        }
964    }
965
966    impl PtxParser for WmmaLoadCSyncAlignedLayoutShapeSsCtype4 {
967        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
968            try_map(
969                seq_n!(
970                    string_p("wmma"),
971                    string_p(".load"),
972                    string_p(".c"),
973                    string_p(".sync"),
974                    string_p(".aligned"),
975                    Layout::parse(),
976                    Shape::parse(),
977                    optional(Ss::parse()),
978                    Ctype::parse(),
979                    GeneralOperand::parse(),
980                    comma_p(),
981                    AddressOperand::parse(),
982                    map(
983                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
984                        |value, _| value.map(|(_, operand)| operand)
985                    ),
986                    semicolon_p()
987                ),
988                |(_, load, c, sync, aligned, layout, shape, ss, ctype, r, _, p, stride, _),
989                 span| {
990                    ok!(WmmaLoadCSyncAlignedLayoutShapeSsCtype4 {
991                        load = load,
992                        c = c,
993                        sync = sync,
994                        aligned = aligned,
995                        layout = layout,
996                        shape = shape,
997                        ss = ss,
998                        ctype = ctype,
999                        r = r,
1000                        p = p,
1001                        stride = stride,
1002
1003                    })
1004                },
1005            )
1006        }
1007    }
1008}
1009
1010pub mod section_5 {
1011    use super::*;
1012    use crate::r#type::instruction::wmma_load::section_5::*;
1013
1014    // ============================================================================
1015    // Generated enum parsers
1016    // ============================================================================
1017
1018    impl PtxParser for Atype {
1019        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1020            alt!(map(string_p(".b1"), |_, _span| Atype::B1))
1021        }
1022    }
1023
1024    impl PtxParser for Btype {
1025        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1026            alt!(map(string_p(".b1"), |_, _span| Btype::B1))
1027        }
1028    }
1029
1030    impl PtxParser for Ctype {
1031        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1032            alt!(map(string_p(".s32"), |_, _span| Ctype::S32))
1033        }
1034    }
1035
1036    impl PtxParser for Layout {
1037        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1038            alt!(
1039                map(string_p(".row"), |_, _span| Layout::Row),
1040                map(string_p(".col"), |_, _span| Layout::Col)
1041            )
1042        }
1043    }
1044
1045    impl PtxParser for Shape {
1046        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1047            alt!(map(string_p(".m8n8k128"), |_, _span| Shape::M8n8k128))
1048        }
1049    }
1050
1051    impl PtxParser for Ss {
1052        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1053            alt!(
1054                map(string_p(".shared::cta"), |_, _span| Ss::SharedCta),
1055                map(string_p(".global"), |_, _span| Ss::Global),
1056                map(string_p(".shared"), |_, _span| Ss::Shared)
1057            )
1058        }
1059    }
1060
1061    impl PtxParser for WmmaLoadASyncAlignedRowShapeSsAtype1 {
1062        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1063            try_map(
1064                seq_n!(
1065                    string_p("wmma"),
1066                    string_p(".load"),
1067                    string_p(".a"),
1068                    string_p(".sync"),
1069                    string_p(".aligned"),
1070                    string_p(".row"),
1071                    Shape::parse(),
1072                    optional(Ss::parse()),
1073                    Atype::parse(),
1074                    GeneralOperand::parse(),
1075                    comma_p(),
1076                    AddressOperand::parse(),
1077                    map(
1078                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
1079                        |value, _| value.map(|(_, operand)| operand)
1080                    ),
1081                    semicolon_p()
1082                ),
1083                |(_, load, a, sync, aligned, row, shape, ss, atype, r, _, p, stride, _), span| {
1084                    ok!(WmmaLoadASyncAlignedRowShapeSsAtype1 {
1085                        load = load,
1086                        a = a,
1087                        sync = sync,
1088                        aligned = aligned,
1089                        row = row,
1090                        shape = shape,
1091                        ss = ss,
1092                        atype = atype,
1093                        r = r,
1094                        p = p,
1095                        stride = stride,
1096
1097                    })
1098                },
1099            )
1100        }
1101    }
1102
1103    impl PtxParser for WmmaLoadBSyncAlignedColShapeSsBtype1 {
1104        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1105            try_map(
1106                seq_n!(
1107                    string_p("wmma"),
1108                    string_p(".load"),
1109                    string_p(".b"),
1110                    string_p(".sync"),
1111                    string_p(".aligned"),
1112                    string_p(".col"),
1113                    Shape::parse(),
1114                    optional(Ss::parse()),
1115                    Btype::parse(),
1116                    GeneralOperand::parse(),
1117                    comma_p(),
1118                    AddressOperand::parse(),
1119                    map(
1120                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
1121                        |value, _| value.map(|(_, operand)| operand)
1122                    ),
1123                    semicolon_p()
1124                ),
1125                |(_, load, b, sync, aligned, col, shape, ss, btype, r, _, p, stride, _), span| {
1126                    ok!(WmmaLoadBSyncAlignedColShapeSsBtype1 {
1127                        load = load,
1128                        b = b,
1129                        sync = sync,
1130                        aligned = aligned,
1131                        col = col,
1132                        shape = shape,
1133                        ss = ss,
1134                        btype = btype,
1135                        r = r,
1136                        p = p,
1137                        stride = stride,
1138
1139                    })
1140                },
1141            )
1142        }
1143    }
1144
1145    impl PtxParser for WmmaLoadCSyncAlignedLayoutShapeSsCtype5 {
1146        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
1147            try_map(
1148                seq_n!(
1149                    string_p("wmma"),
1150                    string_p(".load"),
1151                    string_p(".c"),
1152                    string_p(".sync"),
1153                    string_p(".aligned"),
1154                    Layout::parse(),
1155                    Shape::parse(),
1156                    optional(Ss::parse()),
1157                    Ctype::parse(),
1158                    GeneralOperand::parse(),
1159                    comma_p(),
1160                    AddressOperand::parse(),
1161                    map(
1162                        optional(seq_n!(comma_p(), GeneralOperand::parse())),
1163                        |value, _| value.map(|(_, operand)| operand)
1164                    ),
1165                    semicolon_p()
1166                ),
1167                |(_, load, c, sync, aligned, layout, shape, ss, ctype, r, _, p, stride, _),
1168                 span| {
1169                    ok!(WmmaLoadCSyncAlignedLayoutShapeSsCtype5 {
1170                        load = load,
1171                        c = c,
1172                        sync = sync,
1173                        aligned = aligned,
1174                        layout = layout,
1175                        shape = shape,
1176                        ss = ss,
1177                        ctype = ctype,
1178                        r = r,
1179                        p = p,
1180                        stride = stride,
1181
1182                    })
1183                },
1184            )
1185        }
1186    }
1187}