Skip to main content

ptx_parser/unparser/instruction/
tanh.rs

1//! Original PTX specification:
2//!
3//! tanh.approx.type d, a;
4//! .type = {.f16, .f32, .f16x2, .bf16, .bf16x2};
5
6#![allow(unused)]
7
8use crate::lexer::PtxToken;
9use crate::unparser::{PtxUnparser, common::*};
10
11pub mod section_0 {
12    use super::*;
13    use crate::r#type::instruction::tanh::section_0::*;
14
15    impl PtxUnparser for TanhApproxType {
16        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
17            self.unparse_tokens_mode(tokens, false);
18        }
19        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
20            push_opcode(tokens, "tanh");
21            push_directive(tokens, "approx");
22            match &self.type_ {
23                Type::Bf16x2 => {
24                    push_directive(tokens, "bf16x2");
25                }
26                Type::F16x2 => {
27                    push_directive(tokens, "f16x2");
28                }
29                Type::Bf16 => {
30                    push_directive(tokens, "bf16");
31                }
32                Type::F16 => {
33                    push_directive(tokens, "f16");
34                }
35                Type::F32 => {
36                    push_directive(tokens, "f32");
37                }
38            }
39            if spaced {
40                tokens.push(PtxToken::Space);
41            }
42            self.d.unparse_tokens_mode(tokens, spaced);
43            tokens.push(PtxToken::Comma);
44            if spaced {
45                tokens.push(PtxToken::Space);
46            }
47            self.a.unparse_tokens_mode(tokens, spaced);
48            tokens.push(PtxToken::Semicolon);
49            if spaced {
50                tokens.push(PtxToken::Newline);
51            }
52        }
53    }
54}