ptx_parser/unparser/instruction/
sqrt.rs

1//! Original PTX specification:
2//!
3//! sqrt.approx{.ftz}.f32  d, a; // fast, approximate square root
4//! sqrt.rnd{.ftz}.f32     d, a; // IEEE 754 compliant rounding
5//! sqrt.rnd.f64           d, a; // IEEE 754 compliant rounding
6//! .rnd = { .rn, .rz, .rm, .rp };
7
8#![allow(unused)]
9
10use crate::lexer::PtxToken;
11use crate::unparser::{PtxUnparser, common::*};
12
13pub mod section_0 {
14    use super::*;
15    use crate::r#type::instruction::sqrt::section_0::*;
16
17    impl PtxUnparser for SqrtApproxFtzF32 {
18        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
19            push_opcode(tokens, "sqrt");
20                    push_directive(tokens, "approx");
21                    if self.ftz {
22                            push_directive(tokens, "ftz");
23                    }
24                    push_directive(tokens, "f32");
25                    self.d.unparse_tokens(tokens);
26            tokens.push(PtxToken::Comma);
27                    self.a.unparse_tokens(tokens);
28            tokens.push(PtxToken::Semicolon);
29        }
30    }
31
32    impl PtxUnparser for SqrtRndFtzF32 {
33        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
34            push_opcode(tokens, "sqrt");
35                    match &self.rnd {
36                            Rnd::Rn => {
37                                    push_directive(tokens, "rn");
38                            }
39                            Rnd::Rz => {
40                                    push_directive(tokens, "rz");
41                            }
42                            Rnd::Rm => {
43                                    push_directive(tokens, "rm");
44                            }
45                            Rnd::Rp => {
46                                    push_directive(tokens, "rp");
47                            }
48                    }
49                    if self.ftz {
50                            push_directive(tokens, "ftz");
51                    }
52                    push_directive(tokens, "f32");
53                    self.d.unparse_tokens(tokens);
54            tokens.push(PtxToken::Comma);
55                    self.a.unparse_tokens(tokens);
56            tokens.push(PtxToken::Semicolon);
57        }
58    }
59
60    impl PtxUnparser for SqrtRndF64 {
61        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
62            push_opcode(tokens, "sqrt");
63                    match &self.rnd {
64                            Rnd::Rn => {
65                                    push_directive(tokens, "rn");
66                            }
67                            Rnd::Rz => {
68                                    push_directive(tokens, "rz");
69                            }
70                            Rnd::Rm => {
71                                    push_directive(tokens, "rm");
72                            }
73                            Rnd::Rp => {
74                                    push_directive(tokens, "rp");
75                            }
76                    }
77                    push_directive(tokens, "f64");
78                    self.d.unparse_tokens(tokens);
79            tokens.push(PtxToken::Comma);
80                    self.a.unparse_tokens(tokens);
81            tokens.push(PtxToken::Semicolon);
82        }
83    }
84
85}
86