ptx_parser/parser/instruction/
fma.rs1#![allow(unused)]
22
23use crate::lexer::PtxToken;
24use crate::parser::{PtxParseError, PtxParser, PtxTokenStream, Span};
25use crate::r#type::common::*;
26
27pub mod section_0 {
28 use super::*;
29 use crate::r#type::instruction::fma::section_0::*;
30
31 impl PtxParser for Rnd {
36 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
37 {
39 let saved_pos = stream.position();
40 if stream.expect_string(".rn").is_ok() {
41 return Ok(Rnd::Rn);
42 }
43 stream.set_position(saved_pos);
44 }
45 let saved_pos = stream.position();
46 {
48 let saved_pos = stream.position();
49 if stream.expect_string(".rz").is_ok() {
50 return Ok(Rnd::Rz);
51 }
52 stream.set_position(saved_pos);
53 }
54 stream.set_position(saved_pos);
55 let saved_pos = stream.position();
56 {
58 let saved_pos = stream.position();
59 if stream.expect_string(".rm").is_ok() {
60 return Ok(Rnd::Rm);
61 }
62 stream.set_position(saved_pos);
63 }
64 stream.set_position(saved_pos);
65 let saved_pos = stream.position();
66 {
68 let saved_pos = stream.position();
69 if stream.expect_string(".rp").is_ok() {
70 return Ok(Rnd::Rp);
71 }
72 stream.set_position(saved_pos);
73 }
74 stream.set_position(saved_pos);
75 let span = stream.peek().map(|(_, s)| s.clone()).unwrap_or(Span { start: 0, end: 0 });
76 let expected = &[".rn", ".rz", ".rm", ".rp"];
77 let found = stream.peek().map(|(t, _)| format!("{:?}", t)).unwrap_or_else(|_| "<end of input>".to_string());
78 Err(crate::parser::unexpected_value(span, expected, found))
79 }
80 }
81
82 impl PtxParser for FmaRndFtzSatF32 {
83 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
84 stream.expect_string("fma")?;
85 let rnd = Rnd::parse(stream)?;
86 stream.expect_complete()?;
87 let saved_pos = stream.position();
88 let ftz = stream.expect_string(".ftz").is_ok();
89 if !ftz {
90 stream.set_position(saved_pos);
91 }
92 stream.expect_complete()?;
93 let saved_pos = stream.position();
94 let sat = stream.expect_string(".sat").is_ok();
95 if !sat {
96 stream.set_position(saved_pos);
97 }
98 stream.expect_complete()?;
99 stream.expect_string(".f32")?;
100 let f32 = ();
101 stream.expect_complete()?;
102 let d = GeneralOperand::parse(stream)?;
103 stream.expect_complete()?;
104 stream.expect(&PtxToken::Comma)?;
105 let a = GeneralOperand::parse(stream)?;
106 stream.expect_complete()?;
107 stream.expect(&PtxToken::Comma)?;
108 let b = GeneralOperand::parse(stream)?;
109 stream.expect_complete()?;
110 stream.expect(&PtxToken::Comma)?;
111 let c = GeneralOperand::parse(stream)?;
112 stream.expect_complete()?;
113 stream.expect_complete()?;
114 stream.expect(&PtxToken::Semicolon)?;
115 Ok(FmaRndFtzSatF32 {
116 rnd,
117 ftz,
118 sat,
119 f32,
120 d,
121 a,
122 b,
123 c,
124 })
125 }
126 }
127
128
129 impl PtxParser for FmaRndFtzF32x2 {
130 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
131 stream.expect_string("fma")?;
132 let rnd = Rnd::parse(stream)?;
133 stream.expect_complete()?;
134 let saved_pos = stream.position();
135 let ftz = stream.expect_string(".ftz").is_ok();
136 if !ftz {
137 stream.set_position(saved_pos);
138 }
139 stream.expect_complete()?;
140 stream.expect_string(".f32x2")?;
141 let f32x2 = ();
142 stream.expect_complete()?;
143 let d = GeneralOperand::parse(stream)?;
144 stream.expect_complete()?;
145 stream.expect(&PtxToken::Comma)?;
146 let a = GeneralOperand::parse(stream)?;
147 stream.expect_complete()?;
148 stream.expect(&PtxToken::Comma)?;
149 let b = GeneralOperand::parse(stream)?;
150 stream.expect_complete()?;
151 stream.expect(&PtxToken::Comma)?;
152 let c = GeneralOperand::parse(stream)?;
153 stream.expect_complete()?;
154 stream.expect_complete()?;
155 stream.expect(&PtxToken::Semicolon)?;
156 Ok(FmaRndFtzF32x2 {
157 rnd,
158 ftz,
159 f32x2,
160 d,
161 a,
162 b,
163 c,
164 })
165 }
166 }
167
168
169 impl PtxParser for FmaRndF64 {
170 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
171 stream.expect_string("fma")?;
172 let rnd = Rnd::parse(stream)?;
173 stream.expect_complete()?;
174 stream.expect_string(".f64")?;
175 let f64 = ();
176 stream.expect_complete()?;
177 let d = GeneralOperand::parse(stream)?;
178 stream.expect_complete()?;
179 stream.expect(&PtxToken::Comma)?;
180 let a = GeneralOperand::parse(stream)?;
181 stream.expect_complete()?;
182 stream.expect(&PtxToken::Comma)?;
183 let b = GeneralOperand::parse(stream)?;
184 stream.expect_complete()?;
185 stream.expect(&PtxToken::Comma)?;
186 let c = GeneralOperand::parse(stream)?;
187 stream.expect_complete()?;
188 stream.expect_complete()?;
189 stream.expect(&PtxToken::Semicolon)?;
190 Ok(FmaRndF64 {
191 rnd,
192 f64,
193 d,
194 a,
195 b,
196 c,
197 })
198 }
199 }
200
201
202}
203
204pub mod section_1 {
205 use super::*;
206 use crate::r#type::instruction::fma::section_1::*;
207
208 impl PtxParser for Rnd {
213 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
214 {
216 let saved_pos = stream.position();
217 if stream.expect_string(".rn").is_ok() {
218 return Ok(Rnd::Rn);
219 }
220 stream.set_position(saved_pos);
221 }
222 let span = stream.peek().map(|(_, s)| s.clone()).unwrap_or(Span { start: 0, end: 0 });
223 let expected = &[".rn"];
224 let found = stream.peek().map(|(t, _)| format!("{:?}", t)).unwrap_or_else(|_| "<end of input>".to_string());
225 Err(crate::parser::unexpected_value(span, expected, found))
226 }
227 }
228
229 impl PtxParser for FmaRndFtzSatF16 {
230 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
231 stream.expect_string("fma")?;
232 let rnd = Rnd::parse(stream)?;
233 stream.expect_complete()?;
234 let saved_pos = stream.position();
235 let ftz = stream.expect_string(".ftz").is_ok();
236 if !ftz {
237 stream.set_position(saved_pos);
238 }
239 stream.expect_complete()?;
240 let saved_pos = stream.position();
241 let sat = stream.expect_string(".sat").is_ok();
242 if !sat {
243 stream.set_position(saved_pos);
244 }
245 stream.expect_complete()?;
246 stream.expect_string(".f16")?;
247 let f16 = ();
248 stream.expect_complete()?;
249 let d = GeneralOperand::parse(stream)?;
250 stream.expect_complete()?;
251 stream.expect(&PtxToken::Comma)?;
252 let a = GeneralOperand::parse(stream)?;
253 stream.expect_complete()?;
254 stream.expect(&PtxToken::Comma)?;
255 let b = GeneralOperand::parse(stream)?;
256 stream.expect_complete()?;
257 stream.expect(&PtxToken::Comma)?;
258 let c = GeneralOperand::parse(stream)?;
259 stream.expect_complete()?;
260 stream.expect_complete()?;
261 stream.expect(&PtxToken::Semicolon)?;
262 Ok(FmaRndFtzSatF16 {
263 rnd,
264 ftz,
265 sat,
266 f16,
267 d,
268 a,
269 b,
270 c,
271 })
272 }
273 }
274
275
276 impl PtxParser for FmaRndFtzSatF16x2 {
277 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
278 stream.expect_string("fma")?;
279 let rnd = Rnd::parse(stream)?;
280 stream.expect_complete()?;
281 let saved_pos = stream.position();
282 let ftz = stream.expect_string(".ftz").is_ok();
283 if !ftz {
284 stream.set_position(saved_pos);
285 }
286 stream.expect_complete()?;
287 let saved_pos = stream.position();
288 let sat = stream.expect_string(".sat").is_ok();
289 if !sat {
290 stream.set_position(saved_pos);
291 }
292 stream.expect_complete()?;
293 stream.expect_string(".f16x2")?;
294 let f16x2 = ();
295 stream.expect_complete()?;
296 let d = GeneralOperand::parse(stream)?;
297 stream.expect_complete()?;
298 stream.expect(&PtxToken::Comma)?;
299 let a = GeneralOperand::parse(stream)?;
300 stream.expect_complete()?;
301 stream.expect(&PtxToken::Comma)?;
302 let b = GeneralOperand::parse(stream)?;
303 stream.expect_complete()?;
304 stream.expect(&PtxToken::Comma)?;
305 let c = GeneralOperand::parse(stream)?;
306 stream.expect_complete()?;
307 stream.expect_complete()?;
308 stream.expect(&PtxToken::Semicolon)?;
309 Ok(FmaRndFtzSatF16x2 {
310 rnd,
311 ftz,
312 sat,
313 f16x2,
314 d,
315 a,
316 b,
317 c,
318 })
319 }
320 }
321
322
323 impl PtxParser for FmaRndFtzReluF16 {
324 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
325 stream.expect_string("fma")?;
326 let rnd = Rnd::parse(stream)?;
327 stream.expect_complete()?;
328 let saved_pos = stream.position();
329 let ftz = stream.expect_string(".ftz").is_ok();
330 if !ftz {
331 stream.set_position(saved_pos);
332 }
333 stream.expect_complete()?;
334 stream.expect_string(".relu")?;
335 let relu = ();
336 stream.expect_complete()?;
337 stream.expect_string(".f16")?;
338 let f16 = ();
339 stream.expect_complete()?;
340 let d = GeneralOperand::parse(stream)?;
341 stream.expect_complete()?;
342 stream.expect(&PtxToken::Comma)?;
343 let a = GeneralOperand::parse(stream)?;
344 stream.expect_complete()?;
345 stream.expect(&PtxToken::Comma)?;
346 let b = GeneralOperand::parse(stream)?;
347 stream.expect_complete()?;
348 stream.expect(&PtxToken::Comma)?;
349 let c = GeneralOperand::parse(stream)?;
350 stream.expect_complete()?;
351 stream.expect_complete()?;
352 stream.expect(&PtxToken::Semicolon)?;
353 Ok(FmaRndFtzReluF16 {
354 rnd,
355 ftz,
356 relu,
357 f16,
358 d,
359 a,
360 b,
361 c,
362 })
363 }
364 }
365
366
367 impl PtxParser for FmaRndFtzReluF16x2 {
368 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
369 stream.expect_string("fma")?;
370 let rnd = Rnd::parse(stream)?;
371 stream.expect_complete()?;
372 let saved_pos = stream.position();
373 let ftz = stream.expect_string(".ftz").is_ok();
374 if !ftz {
375 stream.set_position(saved_pos);
376 }
377 stream.expect_complete()?;
378 stream.expect_string(".relu")?;
379 let relu = ();
380 stream.expect_complete()?;
381 stream.expect_string(".f16x2")?;
382 let f16x2 = ();
383 stream.expect_complete()?;
384 let d = GeneralOperand::parse(stream)?;
385 stream.expect_complete()?;
386 stream.expect(&PtxToken::Comma)?;
387 let a = GeneralOperand::parse(stream)?;
388 stream.expect_complete()?;
389 stream.expect(&PtxToken::Comma)?;
390 let b = GeneralOperand::parse(stream)?;
391 stream.expect_complete()?;
392 stream.expect(&PtxToken::Comma)?;
393 let c = GeneralOperand::parse(stream)?;
394 stream.expect_complete()?;
395 stream.expect_complete()?;
396 stream.expect(&PtxToken::Semicolon)?;
397 Ok(FmaRndFtzReluF16x2 {
398 rnd,
399 ftz,
400 relu,
401 f16x2,
402 d,
403 a,
404 b,
405 c,
406 })
407 }
408 }
409
410
411 impl PtxParser for FmaRndReluBf16 {
412 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
413 stream.expect_string("fma")?;
414 let rnd = Rnd::parse(stream)?;
415 stream.expect_complete()?;
416 let saved_pos = stream.position();
417 let relu = stream.expect_string(".relu").is_ok();
418 if !relu {
419 stream.set_position(saved_pos);
420 }
421 stream.expect_complete()?;
422 stream.expect_string(".bf16")?;
423 let bf16 = ();
424 stream.expect_complete()?;
425 let d = GeneralOperand::parse(stream)?;
426 stream.expect_complete()?;
427 stream.expect(&PtxToken::Comma)?;
428 let a = GeneralOperand::parse(stream)?;
429 stream.expect_complete()?;
430 stream.expect(&PtxToken::Comma)?;
431 let b = GeneralOperand::parse(stream)?;
432 stream.expect_complete()?;
433 stream.expect(&PtxToken::Comma)?;
434 let c = GeneralOperand::parse(stream)?;
435 stream.expect_complete()?;
436 stream.expect_complete()?;
437 stream.expect(&PtxToken::Semicolon)?;
438 Ok(FmaRndReluBf16 {
439 rnd,
440 relu,
441 bf16,
442 d,
443 a,
444 b,
445 c,
446 })
447 }
448 }
449
450
451 impl PtxParser for FmaRndReluBf16x2 {
452 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
453 stream.expect_string("fma")?;
454 let rnd = Rnd::parse(stream)?;
455 stream.expect_complete()?;
456 let saved_pos = stream.position();
457 let relu = stream.expect_string(".relu").is_ok();
458 if !relu {
459 stream.set_position(saved_pos);
460 }
461 stream.expect_complete()?;
462 stream.expect_string(".bf16x2")?;
463 let bf16x2 = ();
464 stream.expect_complete()?;
465 let d = GeneralOperand::parse(stream)?;
466 stream.expect_complete()?;
467 stream.expect(&PtxToken::Comma)?;
468 let a = GeneralOperand::parse(stream)?;
469 stream.expect_complete()?;
470 stream.expect(&PtxToken::Comma)?;
471 let b = GeneralOperand::parse(stream)?;
472 stream.expect_complete()?;
473 stream.expect(&PtxToken::Comma)?;
474 let c = GeneralOperand::parse(stream)?;
475 stream.expect_complete()?;
476 stream.expect_complete()?;
477 stream.expect(&PtxToken::Semicolon)?;
478 Ok(FmaRndReluBf16x2 {
479 rnd,
480 relu,
481 bf16x2,
482 d,
483 a,
484 b,
485 c,
486 })
487 }
488 }
489
490
491 impl PtxParser for FmaRndOobReluType {
492 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
493 stream.expect_string("fma")?;
494 let rnd = Rnd::parse(stream)?;
495 stream.expect_complete()?;
496 stream.expect_string(".oob")?;
497 let oob = ();
498 stream.expect_complete()?;
499 let saved_pos = stream.position();
500 let relu = stream.expect_string(".relu").is_ok();
501 if !relu {
502 stream.set_position(saved_pos);
503 }
504 stream.expect_complete()?;
505 stream.expect_string(".type")?;
506 let type_ = ();
507 stream.expect_complete()?;
508 let d = GeneralOperand::parse(stream)?;
509 stream.expect_complete()?;
510 stream.expect(&PtxToken::Comma)?;
511 let a = GeneralOperand::parse(stream)?;
512 stream.expect_complete()?;
513 stream.expect(&PtxToken::Comma)?;
514 let b = GeneralOperand::parse(stream)?;
515 stream.expect_complete()?;
516 stream.expect(&PtxToken::Comma)?;
517 let c = GeneralOperand::parse(stream)?;
518 stream.expect_complete()?;
519 stream.expect_complete()?;
520 stream.expect(&PtxToken::Semicolon)?;
521 Ok(FmaRndOobReluType {
522 rnd,
523 oob,
524 relu,
525 type_,
526 d,
527 a,
528 b,
529 c,
530 })
531 }
532 }
533
534
535}
536
537pub mod section_2 {
538 use super::*;
539 use crate::r#type::instruction::fma::section_2::*;
540
541 impl PtxParser for Abtype {
546 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
547 {
549 let saved_pos = stream.position();
550 if stream.expect_string(".bf16").is_ok() {
551 return Ok(Abtype::Bf16);
552 }
553 stream.set_position(saved_pos);
554 }
555 let saved_pos = stream.position();
556 {
558 let saved_pos = stream.position();
559 if stream.expect_string(".f16").is_ok() {
560 return Ok(Abtype::F16);
561 }
562 stream.set_position(saved_pos);
563 }
564 stream.set_position(saved_pos);
565 let span = stream.peek().map(|(_, s)| s.clone()).unwrap_or(Span { start: 0, end: 0 });
566 let expected = &[".bf16", ".f16"];
567 let found = stream.peek().map(|(t, _)| format!("{:?}", t)).unwrap_or_else(|_| "<end of input>".to_string());
568 Err(crate::parser::unexpected_value(span, expected, found))
569 }
570 }
571
572 impl PtxParser for Rnd {
573 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
574 {
576 let saved_pos = stream.position();
577 if stream.expect_string(".rn").is_ok() {
578 return Ok(Rnd::Rn);
579 }
580 stream.set_position(saved_pos);
581 }
582 let saved_pos = stream.position();
583 {
585 let saved_pos = stream.position();
586 if stream.expect_string(".rz").is_ok() {
587 return Ok(Rnd::Rz);
588 }
589 stream.set_position(saved_pos);
590 }
591 stream.set_position(saved_pos);
592 let saved_pos = stream.position();
593 {
595 let saved_pos = stream.position();
596 if stream.expect_string(".rm").is_ok() {
597 return Ok(Rnd::Rm);
598 }
599 stream.set_position(saved_pos);
600 }
601 stream.set_position(saved_pos);
602 let saved_pos = stream.position();
603 {
605 let saved_pos = stream.position();
606 if stream.expect_string(".rp").is_ok() {
607 return Ok(Rnd::Rp);
608 }
609 stream.set_position(saved_pos);
610 }
611 stream.set_position(saved_pos);
612 let span = stream.peek().map(|(_, s)| s.clone()).unwrap_or(Span { start: 0, end: 0 });
613 let expected = &[".rn", ".rz", ".rm", ".rp"];
614 let found = stream.peek().map(|(t, _)| format!("{:?}", t)).unwrap_or_else(|_| "<end of input>".to_string());
615 Err(crate::parser::unexpected_value(span, expected, found))
616 }
617 }
618
619 impl PtxParser for FmaRndSatF32Abtype {
620 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
621 stream.expect_string("fma")?;
622 let rnd = Rnd::parse(stream)?;
623 stream.expect_complete()?;
624 let saved_pos = stream.position();
625 let sat = stream.expect_string(".sat").is_ok();
626 if !sat {
627 stream.set_position(saved_pos);
628 }
629 stream.expect_complete()?;
630 stream.expect_string(".f32")?;
631 let f32 = ();
632 stream.expect_complete()?;
633 let abtype = Abtype::parse(stream)?;
634 stream.expect_complete()?;
635 let d = GeneralOperand::parse(stream)?;
636 stream.expect_complete()?;
637 stream.expect(&PtxToken::Comma)?;
638 let a = GeneralOperand::parse(stream)?;
639 stream.expect_complete()?;
640 stream.expect(&PtxToken::Comma)?;
641 let b = GeneralOperand::parse(stream)?;
642 stream.expect_complete()?;
643 stream.expect(&PtxToken::Comma)?;
644 let c = GeneralOperand::parse(stream)?;
645 stream.expect_complete()?;
646 stream.expect_complete()?;
647 stream.expect(&PtxToken::Semicolon)?;
648 Ok(FmaRndSatF32Abtype {
649 rnd,
650 sat,
651 f32,
652 abtype,
653 d,
654 a,
655 b,
656 c,
657 })
658 }
659 }
660
661
662}
663