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