Skip to main content

ptx_parser/unparser/instruction/
rsqrt.rs

1//! Original PTX specification:
2//!
3//! rsqrt.approx{.ftz}.f32  d, a;
4//! rsqrt.approx.f64        d, a;
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::rsqrt::section_0::*;
14
15    impl PtxUnparser for RsqrtApproxFtzF32 {
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, "rsqrt");
21            push_directive(tokens, "approx");
22            if self.ftz {
23                push_directive(tokens, "ftz");
24            }
25            push_directive(tokens, "f32");
26            if spaced {
27                tokens.push(PtxToken::Space);
28            }
29            self.d.unparse_tokens_mode(tokens, spaced);
30            tokens.push(PtxToken::Comma);
31            if spaced {
32                tokens.push(PtxToken::Space);
33            }
34            self.a.unparse_tokens_mode(tokens, spaced);
35            tokens.push(PtxToken::Semicolon);
36            if spaced {
37                tokens.push(PtxToken::Newline);
38            }
39        }
40    }
41
42    impl PtxUnparser for RsqrtApproxF64 {
43        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
44            self.unparse_tokens_mode(tokens, false);
45        }
46        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
47            push_opcode(tokens, "rsqrt");
48            push_directive(tokens, "approx");
49            push_directive(tokens, "f64");
50            if spaced {
51                tokens.push(PtxToken::Space);
52            }
53            self.d.unparse_tokens_mode(tokens, spaced);
54            tokens.push(PtxToken::Comma);
55            if spaced {
56                tokens.push(PtxToken::Space);
57            }
58            self.a.unparse_tokens_mode(tokens, spaced);
59            tokens.push(PtxToken::Semicolon);
60            if spaced {
61                tokens.push(PtxToken::Newline);
62            }
63        }
64    }
65}