ptx_parser/parser/instruction/
ex2.rs1#![allow(unused)]
11
12use crate::parser::{
13 PtxParseError, PtxParser, PtxTokenStream, Span,
14 util::{
15 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
16 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
17 },
18};
19use crate::r#type::common::*;
20use crate::{alt, ok, seq_n};
21
22pub mod section_0 {
23 use super::*;
24 use crate::r#type::instruction::ex2::section_0::*;
25
26 impl PtxParser for Atype {
31 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
32 alt!(
33 map(string_p(".f16x2"), |_, _span| Atype::F16x2),
34 map(string_p(".f16"), |_, _span| Atype::F16)
35 )
36 }
37 }
38
39 impl PtxParser for Btype {
40 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
41 alt!(
42 map(string_p(".bf16x2"), |_, _span| Btype::Bf16x2),
43 map(string_p(".bf16"), |_, _span| Btype::Bf16)
44 )
45 }
46 }
47
48 impl PtxParser for Ex2ApproxFtzF32 {
49 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
50 try_map(
51 seq_n!(
52 string_p("ex2"),
53 string_p(".approx"),
54 map(optional(string_p(".ftz")), |value, _| value.is_some()),
55 string_p(".f32"),
56 GeneralOperand::parse(),
57 comma_p(),
58 GeneralOperand::parse(),
59 semicolon_p()
60 ),
61 |(_, approx, ftz, f32, d, _, a, _), span| {
62 ok!(Ex2ApproxFtzF32 {
63 approx = approx,
64 ftz = ftz,
65 f32 = f32,
66 d = d,
67 a = a,
68
69 })
70 },
71 )
72 }
73 }
74
75 impl PtxParser for Ex2ApproxAtype {
76 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
77 try_map(
78 seq_n!(
79 string_p("ex2"),
80 string_p(".approx"),
81 Atype::parse(),
82 GeneralOperand::parse(),
83 comma_p(),
84 GeneralOperand::parse(),
85 semicolon_p()
86 ),
87 |(_, approx, atype, d, _, a, _), span| {
88 ok!(Ex2ApproxAtype {
89 approx = approx,
90 atype = atype,
91 d = d,
92 a = a,
93
94 })
95 },
96 )
97 }
98 }
99
100 impl PtxParser for Ex2ApproxFtzBtype {
101 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
102 try_map(
103 seq_n!(
104 string_p("ex2"),
105 string_p(".approx"),
106 string_p(".ftz"),
107 Btype::parse(),
108 GeneralOperand::parse(),
109 comma_p(),
110 GeneralOperand::parse(),
111 semicolon_p()
112 ),
113 |(_, approx, ftz, btype, d, _, a, _), span| {
114 ok!(Ex2ApproxFtzBtype {
115 approx = approx,
116 ftz = ftz,
117 btype = btype,
118 d = d,
119 a = a,
120
121 })
122 },
123 )
124 }
125 }
126}