1#![allow(unused)]
20
21use crate::parser::{
22 PtxParseError, PtxParser, PtxTokenStream, Span,
23 util::{
24 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
25 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
26 },
27};
28use crate::r#type::common::*;
29use crate::{alt, ok, seq_n};
30
31pub mod section_0 {
32 use super::*;
33 use crate::r#type::instruction::mul::section_0::*;
34
35 impl PtxParser for Mode {
40 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
41 alt!(
42 map(string_p(".wide"), |_, _span| Mode::Wide),
43 map(string_p(".hi"), |_, _span| Mode::Hi),
44 map(string_p(".lo"), |_, _span| Mode::Lo)
45 )
46 }
47 }
48
49 impl PtxParser for Type {
50 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
51 alt!(
52 map(string_p(".u16"), |_, _span| Type::U16),
53 map(string_p(".u32"), |_, _span| Type::U32),
54 map(string_p(".u64"), |_, _span| Type::U64),
55 map(string_p(".s16"), |_, _span| Type::S16),
56 map(string_p(".s32"), |_, _span| Type::S32),
57 map(string_p(".s64"), |_, _span| Type::S64)
58 )
59 }
60 }
61
62 impl PtxParser for MulModeType {
63 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
64 try_map(
65 seq_n!(
66 string_p("mul"),
67 Mode::parse(),
68 Type::parse(),
69 GeneralOperand::parse(),
70 comma_p(),
71 GeneralOperand::parse(),
72 comma_p(),
73 GeneralOperand::parse(),
74 semicolon_p()
75 ),
76 |(_, mode, type_, d, _, a, _, b, _), span| {
77 ok!(MulModeType {
78 mode = mode,
79 type_ = type_,
80 d = d,
81 a = a,
82 b = b,
83
84 })
85 },
86 )
87 }
88 }
89}
90
91pub mod section_1 {
92 use super::*;
93 use crate::r#type::instruction::mul::section_1::*;
94
95 impl PtxParser for Rnd {
100 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
101 alt!(
102 map(string_p(".rn"), |_, _span| Rnd::Rn),
103 map(string_p(".rz"), |_, _span| Rnd::Rz),
104 map(string_p(".rm"), |_, _span| Rnd::Rm),
105 map(string_p(".rp"), |_, _span| Rnd::Rp)
106 )
107 }
108 }
109
110 impl PtxParser for MulRndFtzSatF32 {
111 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
112 try_map(
113 seq_n!(
114 string_p("mul"),
115 optional(Rnd::parse()),
116 map(optional(string_p(".ftz")), |value, _| value.is_some()),
117 map(optional(string_p(".sat")), |value, _| value.is_some()),
118 string_p(".f32"),
119 GeneralOperand::parse(),
120 comma_p(),
121 GeneralOperand::parse(),
122 comma_p(),
123 GeneralOperand::parse(),
124 semicolon_p()
125 ),
126 |(_, rnd, ftz, sat, f32, d, _, a, _, b, _), span| {
127 ok!(MulRndFtzSatF32 {
128 rnd = rnd,
129 ftz = ftz,
130 sat = sat,
131 f32 = f32,
132 d = d,
133 a = a,
134 b = b,
135
136 })
137 },
138 )
139 }
140 }
141
142 impl PtxParser for MulRndFtzF32x2 {
143 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
144 try_map(
145 seq_n!(
146 string_p("mul"),
147 optional(Rnd::parse()),
148 map(optional(string_p(".ftz")), |value, _| value.is_some()),
149 string_p(".f32x2"),
150 GeneralOperand::parse(),
151 comma_p(),
152 GeneralOperand::parse(),
153 comma_p(),
154 GeneralOperand::parse(),
155 semicolon_p()
156 ),
157 |(_, rnd, ftz, f32x2, d, _, a, _, b, _), span| {
158 ok!(MulRndFtzF32x2 {
159 rnd = rnd,
160 ftz = ftz,
161 f32x2 = f32x2,
162 d = d,
163 a = a,
164 b = b,
165
166 })
167 },
168 )
169 }
170 }
171
172 impl PtxParser for MulRndF64 {
173 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
174 try_map(
175 seq_n!(
176 string_p("mul"),
177 optional(Rnd::parse()),
178 string_p(".f64"),
179 GeneralOperand::parse(),
180 comma_p(),
181 GeneralOperand::parse(),
182 comma_p(),
183 GeneralOperand::parse(),
184 semicolon_p()
185 ),
186 |(_, rnd, f64, d, _, a, _, b, _), span| {
187 ok!(MulRndF64 {
188 rnd = rnd,
189 f64 = f64,
190 d = d,
191 a = a,
192 b = b,
193
194 })
195 },
196 )
197 }
198 }
199}
200
201pub mod section_2 {
202 use super::*;
203 use crate::r#type::instruction::mul::section_2::*;
204
205 impl PtxParser for Rnd {
210 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
211 alt!(map(string_p(".rn"), |_, _span| Rnd::Rn))
212 }
213 }
214
215 impl PtxParser for MulRndFtzSatF16 {
216 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
217 try_map(
218 seq_n!(
219 string_p("mul"),
220 optional(Rnd::parse()),
221 map(optional(string_p(".ftz")), |value, _| value.is_some()),
222 map(optional(string_p(".sat")), |value, _| value.is_some()),
223 string_p(".f16"),
224 GeneralOperand::parse(),
225 comma_p(),
226 GeneralOperand::parse(),
227 comma_p(),
228 GeneralOperand::parse(),
229 semicolon_p()
230 ),
231 |(_, rnd, ftz, sat, f16, d, _, a, _, b, _), span| {
232 ok!(MulRndFtzSatF16 {
233 rnd = rnd,
234 ftz = ftz,
235 sat = sat,
236 f16 = f16,
237 d = d,
238 a = a,
239 b = b,
240
241 })
242 },
243 )
244 }
245 }
246
247 impl PtxParser for MulRndFtzSatF16x2 {
248 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
249 try_map(
250 seq_n!(
251 string_p("mul"),
252 optional(Rnd::parse()),
253 map(optional(string_p(".ftz")), |value, _| value.is_some()),
254 map(optional(string_p(".sat")), |value, _| value.is_some()),
255 string_p(".f16x2"),
256 GeneralOperand::parse(),
257 comma_p(),
258 GeneralOperand::parse(),
259 comma_p(),
260 GeneralOperand::parse(),
261 semicolon_p()
262 ),
263 |(_, rnd, ftz, sat, f16x2, d, _, a, _, b, _), span| {
264 ok!(MulRndFtzSatF16x2 {
265 rnd = rnd,
266 ftz = ftz,
267 sat = sat,
268 f16x2 = f16x2,
269 d = d,
270 a = a,
271 b = b,
272
273 })
274 },
275 )
276 }
277 }
278
279 impl PtxParser for MulRndBf16 {
280 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
281 try_map(
282 seq_n!(
283 string_p("mul"),
284 optional(Rnd::parse()),
285 string_p(".bf16"),
286 GeneralOperand::parse(),
287 comma_p(),
288 GeneralOperand::parse(),
289 comma_p(),
290 GeneralOperand::parse(),
291 semicolon_p()
292 ),
293 |(_, rnd, bf16, d, _, a, _, b, _), span| {
294 ok!(MulRndBf16 {
295 rnd = rnd,
296 bf16 = bf16,
297 d = d,
298 a = a,
299 b = b,
300
301 })
302 },
303 )
304 }
305 }
306
307 impl PtxParser for MulRndBf16x2 {
308 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
309 try_map(
310 seq_n!(
311 string_p("mul"),
312 optional(Rnd::parse()),
313 string_p(".bf16x2"),
314 GeneralOperand::parse(),
315 comma_p(),
316 GeneralOperand::parse(),
317 comma_p(),
318 GeneralOperand::parse(),
319 semicolon_p()
320 ),
321 |(_, rnd, bf16x2, d, _, a, _, b, _), span| {
322 ok!(MulRndBf16x2 {
323 rnd = rnd,
324 bf16x2 = bf16x2,
325 d = d,
326 a = a,
327 b = b,
328
329 })
330 },
331 )
332 }
333 }
334}