ptx_parser/unparser/instruction/
neg.rs

1//! Original PTX specification:
2//!
3//! neg.type  d, a;
4//! .type = { .s16, .s32, .s64 };
5//!
6//! neg{.ftz}.f32  d, a;
7//! neg.f64        d, a;
8//!
9//! neg{.ftz}.f16    d, a;
10//! neg{.ftz}.f16x2  d, a;
11//! neg.bf16         d, a;
12//! neg.bf16x2       d, a;
13
14#![allow(unused)]
15
16use crate::lexer::PtxToken;
17use crate::unparser::{PtxUnparser, common::*};
18
19pub mod section_0 {
20    use super::*;
21    use crate::r#type::instruction::neg::section_0::*;
22
23    impl PtxUnparser for NegType {
24        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
25            push_opcode(tokens, "neg");
26            match &self.type_ {
27                Type::S16 => {
28                    push_directive(tokens, "s16");
29                }
30                Type::S32 => {
31                    push_directive(tokens, "s32");
32                }
33                Type::S64 => {
34                    push_directive(tokens, "s64");
35                }
36            }
37            self.d.unparse_tokens(tokens);
38            tokens.push(PtxToken::Comma);
39            self.a.unparse_tokens(tokens);
40            tokens.push(PtxToken::Semicolon);
41        }
42    }
43
44    impl PtxUnparser for NegFtzF32 {
45        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
46            push_opcode(tokens, "neg");
47            if self.ftz {
48                push_directive(tokens, "ftz");
49            }
50            push_directive(tokens, "f32");
51            self.d.unparse_tokens(tokens);
52            tokens.push(PtxToken::Comma);
53            self.a.unparse_tokens(tokens);
54            tokens.push(PtxToken::Semicolon);
55        }
56    }
57
58    impl PtxUnparser for NegF64 {
59        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
60            push_opcode(tokens, "neg");
61            push_directive(tokens, "f64");
62            self.d.unparse_tokens(tokens);
63            tokens.push(PtxToken::Comma);
64            self.a.unparse_tokens(tokens);
65            tokens.push(PtxToken::Semicolon);
66        }
67    }
68
69    impl PtxUnparser for NegFtzF16 {
70        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
71            push_opcode(tokens, "neg");
72            if self.ftz {
73                push_directive(tokens, "ftz");
74            }
75            push_directive(tokens, "f16");
76            self.d.unparse_tokens(tokens);
77            tokens.push(PtxToken::Comma);
78            self.a.unparse_tokens(tokens);
79            tokens.push(PtxToken::Semicolon);
80        }
81    }
82
83    impl PtxUnparser for NegFtzF16x2 {
84        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
85            push_opcode(tokens, "neg");
86            if self.ftz {
87                push_directive(tokens, "ftz");
88            }
89            push_directive(tokens, "f16x2");
90            self.d.unparse_tokens(tokens);
91            tokens.push(PtxToken::Comma);
92            self.a.unparse_tokens(tokens);
93            tokens.push(PtxToken::Semicolon);
94        }
95    }
96
97    impl PtxUnparser for NegBf16 {
98        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
99            push_opcode(tokens, "neg");
100            push_directive(tokens, "bf16");
101            self.d.unparse_tokens(tokens);
102            tokens.push(PtxToken::Comma);
103            self.a.unparse_tokens(tokens);
104            tokens.push(PtxToken::Semicolon);
105        }
106    }
107
108    impl PtxUnparser for NegBf16x2 {
109        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
110            push_opcode(tokens, "neg");
111            push_directive(tokens, "bf16x2");
112            self.d.unparse_tokens(tokens);
113            tokens.push(PtxToken::Comma);
114            self.a.unparse_tokens(tokens);
115            tokens.push(PtxToken::Semicolon);
116        }
117    }
118}