Skip to main content

ptx_parser/parser/instruction/
dp4a.rs

1//! Original PTX specification:
2//!
3//! dp4a.atype.btype  d, a, b, c;
4//! .atype = .btype = { .u32, .s32 };
5
6#![allow(unused)]
7
8use crate::parser::{
9    PtxParseError, PtxParser, PtxTokenStream, Span,
10    util::{
11        between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
12        pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
13    },
14};
15use crate::r#type::common::*;
16use crate::{alt, ok, seq_n};
17
18pub mod section_0 {
19    use super::*;
20    use crate::r#type::instruction::dp4a::section_0::*;
21
22    // ============================================================================
23    // Generated enum parsers
24    // ============================================================================
25
26    impl PtxParser for Atype {
27        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
28            alt!(
29                map(string_p(".u32"), |_, _span| Atype::U32),
30                map(string_p(".s32"), |_, _span| Atype::S32)
31            )
32        }
33    }
34
35    impl PtxParser for Btype {
36        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
37            alt!(
38                map(string_p(".u32"), |_, _span| Btype::U32),
39                map(string_p(".s32"), |_, _span| Btype::S32)
40            )
41        }
42    }
43
44    impl PtxParser for Dp4aAtypeBtype {
45        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
46            try_map(
47                seq_n!(
48                    string_p("dp4a"),
49                    Atype::parse(),
50                    Btype::parse(),
51                    GeneralOperand::parse(),
52                    comma_p(),
53                    GeneralOperand::parse(),
54                    comma_p(),
55                    GeneralOperand::parse(),
56                    comma_p(),
57                    GeneralOperand::parse(),
58                    semicolon_p()
59                ),
60                |(_, atype, btype, d, _, a, _, b, _, c, _), span| {
61                    ok!(Dp4aAtypeBtype {
62                        atype = atype,
63                        btype = btype,
64                        d = d,
65                        a = a,
66                        b = b,
67                        c = c,
68
69                    })
70                },
71            )
72        }
73    }
74}