ptx_parser/unparser/instruction/vmad.rs
1//! Original PTX specification:
2//!
3//! // 32-bit scalar operation
4//! vmad.dtype.atype.btype{.sat}{.scale} d, {-}a{.asel}, {-}b{.bsel},
5//! {-}c;
6//! vmad.dtype.atype.btype.po{.sat}{.scale} d, a{.asel}, b{.bsel}, c;
7//! .dtype = .atype = .btype = { .u32, .s32 };
8//! .asel = .bsel = { .b0, .b1, .b2, .b3, .h0, .h1 };
9//! .scale = { .shr7, .shr15 };
10
11#![allow(unused)]
12
13use crate::lexer::PtxToken;
14use crate::unparser::{PtxUnparser, common::*};
15
16pub mod section_0 {
17 use super::*;
18 use crate::r#type::instruction::vmad::section_0::*;
19
20 impl PtxUnparser for VmadDtypeAtypeBtypeSatScale {
21 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
22 push_opcode(tokens, "vmad");
23 match &self.dtype {
24 Dtype::U32 => {
25 push_directive(tokens, "u32");
26 }
27 Dtype::S32 => {
28 push_directive(tokens, "s32");
29 }
30 }
31 match &self.atype {
32 Atype::U32 => {
33 push_directive(tokens, "u32");
34 }
35 Atype::S32 => {
36 push_directive(tokens, "s32");
37 }
38 }
39 match &self.btype {
40 Btype::U32 => {
41 push_directive(tokens, "u32");
42 }
43 Btype::S32 => {
44 push_directive(tokens, "s32");
45 }
46 }
47 if self.sat {
48 push_directive(tokens, "sat");
49 }
50 if let Some(scale_0) = self.scale.as_ref() {
51 match scale_0 {
52 Scale::Shr15 => {
53 push_directive(tokens, "shr15");
54 }
55 Scale::Shr7 => {
56 push_directive(tokens, "shr7");
57 }
58 }
59 }
60 self.d.unparse_tokens(tokens);
61 tokens.push(PtxToken::Comma);
62 if self.a_op { tokens.push(PtxToken::Minus); }
63 self.a.unparse_tokens(tokens);
64 if let Some(asel_1) = self.asel.as_ref() {
65 match asel_1 {
66 Asel::B0 => {
67 push_directive(tokens, "b0");
68 }
69 Asel::B1 => {
70 push_directive(tokens, "b1");
71 }
72 Asel::B2 => {
73 push_directive(tokens, "b2");
74 }
75 Asel::B3 => {
76 push_directive(tokens, "b3");
77 }
78 Asel::H0 => {
79 push_directive(tokens, "h0");
80 }
81 Asel::H1 => {
82 push_directive(tokens, "h1");
83 }
84 }
85 }
86 tokens.push(PtxToken::Comma);
87 if self.b_op { tokens.push(PtxToken::Minus); }
88 self.b.unparse_tokens(tokens);
89 if let Some(bsel_2) = self.bsel.as_ref() {
90 match bsel_2 {
91 Bsel::B0 => {
92 push_directive(tokens, "b0");
93 }
94 Bsel::B1 => {
95 push_directive(tokens, "b1");
96 }
97 Bsel::B2 => {
98 push_directive(tokens, "b2");
99 }
100 Bsel::B3 => {
101 push_directive(tokens, "b3");
102 }
103 Bsel::H0 => {
104 push_directive(tokens, "h0");
105 }
106 Bsel::H1 => {
107 push_directive(tokens, "h1");
108 }
109 }
110 }
111 tokens.push(PtxToken::Comma);
112 if self.c_op { tokens.push(PtxToken::Minus); }
113 self.c.unparse_tokens(tokens);
114 tokens.push(PtxToken::Semicolon);
115 }
116 }
117
118 impl PtxUnparser for VmadDtypeAtypeBtypePoSatScale {
119 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
120 push_opcode(tokens, "vmad");
121 match &self.dtype {
122 Dtype::U32 => {
123 push_directive(tokens, "u32");
124 }
125 Dtype::S32 => {
126 push_directive(tokens, "s32");
127 }
128 }
129 match &self.atype {
130 Atype::U32 => {
131 push_directive(tokens, "u32");
132 }
133 Atype::S32 => {
134 push_directive(tokens, "s32");
135 }
136 }
137 match &self.btype {
138 Btype::U32 => {
139 push_directive(tokens, "u32");
140 }
141 Btype::S32 => {
142 push_directive(tokens, "s32");
143 }
144 }
145 push_directive(tokens, "po");
146 if self.sat {
147 push_directive(tokens, "sat");
148 }
149 if let Some(scale_3) = self.scale.as_ref() {
150 match scale_3 {
151 Scale::Shr15 => {
152 push_directive(tokens, "shr15");
153 }
154 Scale::Shr7 => {
155 push_directive(tokens, "shr7");
156 }
157 }
158 }
159 self.d.unparse_tokens(tokens);
160 tokens.push(PtxToken::Comma);
161 self.a.unparse_tokens(tokens);
162 if let Some(asel_4) = self.asel.as_ref() {
163 match asel_4 {
164 Asel::B0 => {
165 push_directive(tokens, "b0");
166 }
167 Asel::B1 => {
168 push_directive(tokens, "b1");
169 }
170 Asel::B2 => {
171 push_directive(tokens, "b2");
172 }
173 Asel::B3 => {
174 push_directive(tokens, "b3");
175 }
176 Asel::H0 => {
177 push_directive(tokens, "h0");
178 }
179 Asel::H1 => {
180 push_directive(tokens, "h1");
181 }
182 }
183 }
184 tokens.push(PtxToken::Comma);
185 self.b.unparse_tokens(tokens);
186 if let Some(bsel_5) = self.bsel.as_ref() {
187 match bsel_5 {
188 Bsel::B0 => {
189 push_directive(tokens, "b0");
190 }
191 Bsel::B1 => {
192 push_directive(tokens, "b1");
193 }
194 Bsel::B2 => {
195 push_directive(tokens, "b2");
196 }
197 Bsel::B3 => {
198 push_directive(tokens, "b3");
199 }
200 Bsel::H0 => {
201 push_directive(tokens, "h0");
202 }
203 Bsel::H1 => {
204 push_directive(tokens, "h1");
205 }
206 }
207 }
208 tokens.push(PtxToken::Comma);
209 self.c.unparse_tokens(tokens);
210 tokens.push(PtxToken::Semicolon);
211 }
212 }
213
214}
215