ptx_parser/parser/instruction/
dp2a.rs1#![allow(unused)]
8
9use crate::parser::{
10 PtxParseError, PtxParser, PtxTokenStream, Span,
11 util::{
12 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
13 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
14 },
15};
16use crate::r#type::common::*;
17use crate::{alt, ok, seq_n};
18
19pub mod section_0 {
20 use super::*;
21 use crate::r#type::instruction::dp2a::section_0::*;
22
23 impl PtxParser for Atype {
28 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
29 alt!(
30 map(string_p(".u32"), |_, _span| Atype::U32),
31 map(string_p(".s32"), |_, _span| Atype::S32)
32 )
33 }
34 }
35
36 impl PtxParser for Btype {
37 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
38 alt!(
39 map(string_p(".u32"), |_, _span| Btype::U32),
40 map(string_p(".s32"), |_, _span| Btype::S32)
41 )
42 }
43 }
44
45 impl PtxParser for Mode {
46 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
47 alt!(
48 map(string_p(".lo"), |_, _span| Mode::Lo),
49 map(string_p(".hi"), |_, _span| Mode::Hi)
50 )
51 }
52 }
53
54 impl PtxParser for Dp2aModeAtypeBtype {
55 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
56 try_map(
57 seq_n!(
58 string_p("dp2a"),
59 Mode::parse(),
60 Atype::parse(),
61 Btype::parse(),
62 GeneralOperand::parse(),
63 comma_p(),
64 GeneralOperand::parse(),
65 comma_p(),
66 GeneralOperand::parse(),
67 comma_p(),
68 GeneralOperand::parse(),
69 semicolon_p()
70 ),
71 |(_, mode, atype, btype, d, _, a, _, b, _, c, _), span| {
72 ok!(Dp2aModeAtypeBtype {
73 mode = mode,
74 atype = atype,
75 btype = btype,
76 d = d,
77 a = a,
78 b = b,
79 c = c,
80
81 })
82 },
83 )
84 }
85 }
86}