ptx_parser/unparser/instruction/
ex2.rs

1//! Original PTX specification:
2//!
3//! ex2.approx{.ftz}.f32  d, a;
4//! 
5//! ex2.approx.atype     d, a;
6//! ex2.approx.ftz.btype d, a;
7//! .atype = { .f16,  .f16x2};
8//! .btype = { .bf16, .bf16x2};
9
10#![allow(unused)]
11
12use crate::lexer::PtxToken;
13use crate::unparser::{PtxUnparser, common::*};
14
15pub mod section_0 {
16    use super::*;
17    use crate::r#type::instruction::ex2::section_0::*;
18
19    impl PtxUnparser for Ex2ApproxFtzF32 {
20        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
21            push_opcode(tokens, "ex2");
22                    push_directive(tokens, "approx");
23                    if self.ftz {
24                            push_directive(tokens, "ftz");
25                    }
26                    push_directive(tokens, "f32");
27                    self.d.unparse_tokens(tokens);
28            tokens.push(PtxToken::Comma);
29                    self.a.unparse_tokens(tokens);
30            tokens.push(PtxToken::Semicolon);
31        }
32    }
33
34    impl PtxUnparser for Ex2ApproxAtype {
35        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
36            push_opcode(tokens, "ex2");
37                    push_directive(tokens, "approx");
38                    match &self.atype {
39                            Atype::F16x2 => {
40                                    push_directive(tokens, "f16x2");
41                            }
42                            Atype::F16 => {
43                                    push_directive(tokens, "f16");
44                            }
45                    }
46                    self.d.unparse_tokens(tokens);
47            tokens.push(PtxToken::Comma);
48                    self.a.unparse_tokens(tokens);
49            tokens.push(PtxToken::Semicolon);
50        }
51    }
52
53    impl PtxUnparser for Ex2ApproxFtzBtype {
54        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
55            push_opcode(tokens, "ex2");
56                    push_directive(tokens, "approx");
57                    push_directive(tokens, "ftz");
58                    match &self.btype {
59                            Btype::Bf16x2 => {
60                                    push_directive(tokens, "bf16x2");
61                            }
62                            Btype::Bf16 => {
63                                    push_directive(tokens, "bf16");
64                            }
65                    }
66                    self.d.unparse_tokens(tokens);
67            tokens.push(PtxToken::Comma);
68                    self.a.unparse_tokens(tokens);
69            tokens.push(PtxToken::Semicolon);
70        }
71    }
72
73}
74