ptx_parser/unparser/instruction/
add.rs1#![allow(unused)]
25
26use crate::lexer::PtxToken;
27use crate::unparser::{PtxUnparser, common::*};
28
29pub mod section_0 {
30 use super::*;
31 use crate::r#type::instruction::add::section_0::*;
32
33 impl PtxUnparser for AddType {
34 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
35 self.unparse_tokens_mode(tokens, false);
36 }
37 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
38 push_opcode(tokens, "add");
39 match &self.type_ {
40 Type::U16x2 => {
41 push_directive(tokens, "u16x2");
42 }
43 Type::S16x2 => {
44 push_directive(tokens, "s16x2");
45 }
46 Type::U16 => {
47 push_directive(tokens, "u16");
48 }
49 Type::U32 => {
50 push_directive(tokens, "u32");
51 }
52 Type::U64 => {
53 push_directive(tokens, "u64");
54 }
55 Type::S16 => {
56 push_directive(tokens, "s16");
57 }
58 Type::S32 => {
59 push_directive(tokens, "s32");
60 }
61 Type::S64 => {
62 push_directive(tokens, "s64");
63 }
64 }
65 if spaced {
66 tokens.push(PtxToken::Space);
67 }
68 self.d.unparse_tokens_mode(tokens, spaced);
69 tokens.push(PtxToken::Comma);
70 if spaced {
71 tokens.push(PtxToken::Space);
72 }
73 self.a.unparse_tokens_mode(tokens, spaced);
74 tokens.push(PtxToken::Comma);
75 if spaced {
76 tokens.push(PtxToken::Space);
77 }
78 self.b.unparse_tokens_mode(tokens, spaced);
79 tokens.push(PtxToken::Semicolon);
80 if spaced {
81 tokens.push(PtxToken::Newline);
82 }
83 }
84 }
85
86 impl PtxUnparser for AddSatS32 {
87 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
88 self.unparse_tokens_mode(tokens, false);
89 }
90 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
91 push_opcode(tokens, "add");
92 if self.sat {
93 push_directive(tokens, "sat");
94 }
95 push_directive(tokens, "s32");
96 if spaced {
97 tokens.push(PtxToken::Space);
98 }
99 self.d.unparse_tokens_mode(tokens, spaced);
100 tokens.push(PtxToken::Comma);
101 if spaced {
102 tokens.push(PtxToken::Space);
103 }
104 self.a.unparse_tokens_mode(tokens, spaced);
105 tokens.push(PtxToken::Comma);
106 if spaced {
107 tokens.push(PtxToken::Space);
108 }
109 self.b.unparse_tokens_mode(tokens, spaced);
110 tokens.push(PtxToken::Semicolon);
111 if spaced {
112 tokens.push(PtxToken::Newline);
113 }
114 }
115 }
116}
117
118pub mod section_1 {
119 use super::*;
120 use crate::r#type::instruction::add::section_1::*;
121
122 impl PtxUnparser for AddRndFtzSatF32 {
123 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
124 self.unparse_tokens_mode(tokens, false);
125 }
126 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
127 push_opcode(tokens, "add");
128 if let Some(rnd_0) = self.rnd.as_ref() {
129 match rnd_0 {
130 Rnd::Rn => {
131 push_directive(tokens, "rn");
132 }
133 Rnd::Rz => {
134 push_directive(tokens, "rz");
135 }
136 Rnd::Rm => {
137 push_directive(tokens, "rm");
138 }
139 Rnd::Rp => {
140 push_directive(tokens, "rp");
141 }
142 }
143 }
144 if self.ftz {
145 push_directive(tokens, "ftz");
146 }
147 if self.sat {
148 push_directive(tokens, "sat");
149 }
150 push_directive(tokens, "f32");
151 if spaced {
152 tokens.push(PtxToken::Space);
153 }
154 self.d.unparse_tokens_mode(tokens, spaced);
155 tokens.push(PtxToken::Comma);
156 if spaced {
157 tokens.push(PtxToken::Space);
158 }
159 self.a.unparse_tokens_mode(tokens, spaced);
160 tokens.push(PtxToken::Comma);
161 if spaced {
162 tokens.push(PtxToken::Space);
163 }
164 self.b.unparse_tokens_mode(tokens, spaced);
165 tokens.push(PtxToken::Semicolon);
166 if spaced {
167 tokens.push(PtxToken::Newline);
168 }
169 }
170 }
171
172 impl PtxUnparser for AddRndFtzF32x2 {
173 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
174 self.unparse_tokens_mode(tokens, false);
175 }
176 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
177 push_opcode(tokens, "add");
178 if let Some(rnd_1) = self.rnd.as_ref() {
179 match rnd_1 {
180 Rnd::Rn => {
181 push_directive(tokens, "rn");
182 }
183 Rnd::Rz => {
184 push_directive(tokens, "rz");
185 }
186 Rnd::Rm => {
187 push_directive(tokens, "rm");
188 }
189 Rnd::Rp => {
190 push_directive(tokens, "rp");
191 }
192 }
193 }
194 if self.ftz {
195 push_directive(tokens, "ftz");
196 }
197 push_directive(tokens, "f32x2");
198 if spaced {
199 tokens.push(PtxToken::Space);
200 }
201 self.d.unparse_tokens_mode(tokens, spaced);
202 tokens.push(PtxToken::Comma);
203 if spaced {
204 tokens.push(PtxToken::Space);
205 }
206 self.a.unparse_tokens_mode(tokens, spaced);
207 tokens.push(PtxToken::Comma);
208 if spaced {
209 tokens.push(PtxToken::Space);
210 }
211 self.b.unparse_tokens_mode(tokens, spaced);
212 tokens.push(PtxToken::Semicolon);
213 if spaced {
214 tokens.push(PtxToken::Newline);
215 }
216 }
217 }
218
219 impl PtxUnparser for AddRndF64 {
220 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
221 self.unparse_tokens_mode(tokens, false);
222 }
223 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
224 push_opcode(tokens, "add");
225 if let Some(rnd_2) = self.rnd.as_ref() {
226 match rnd_2 {
227 Rnd::Rn => {
228 push_directive(tokens, "rn");
229 }
230 Rnd::Rz => {
231 push_directive(tokens, "rz");
232 }
233 Rnd::Rm => {
234 push_directive(tokens, "rm");
235 }
236 Rnd::Rp => {
237 push_directive(tokens, "rp");
238 }
239 }
240 }
241 push_directive(tokens, "f64");
242 if spaced {
243 tokens.push(PtxToken::Space);
244 }
245 self.d.unparse_tokens_mode(tokens, spaced);
246 tokens.push(PtxToken::Comma);
247 if spaced {
248 tokens.push(PtxToken::Space);
249 }
250 self.a.unparse_tokens_mode(tokens, spaced);
251 tokens.push(PtxToken::Comma);
252 if spaced {
253 tokens.push(PtxToken::Space);
254 }
255 self.b.unparse_tokens_mode(tokens, spaced);
256 tokens.push(PtxToken::Semicolon);
257 if spaced {
258 tokens.push(PtxToken::Newline);
259 }
260 }
261 }
262}
263
264pub mod section_2 {
265 use super::*;
266 use crate::r#type::instruction::add::section_2::*;
267
268 impl PtxUnparser for AddRndFtzSatF16 {
269 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
270 self.unparse_tokens_mode(tokens, false);
271 }
272 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
273 push_opcode(tokens, "add");
274 if let Some(rnd_3) = self.rnd.as_ref() {
275 match rnd_3 {
276 Rnd::Rn => {
277 push_directive(tokens, "rn");
278 }
279 }
280 }
281 if self.ftz {
282 push_directive(tokens, "ftz");
283 }
284 if self.sat {
285 push_directive(tokens, "sat");
286 }
287 push_directive(tokens, "f16");
288 if spaced {
289 tokens.push(PtxToken::Space);
290 }
291 self.d.unparse_tokens_mode(tokens, spaced);
292 tokens.push(PtxToken::Comma);
293 if spaced {
294 tokens.push(PtxToken::Space);
295 }
296 self.a.unparse_tokens_mode(tokens, spaced);
297 tokens.push(PtxToken::Comma);
298 if spaced {
299 tokens.push(PtxToken::Space);
300 }
301 self.b.unparse_tokens_mode(tokens, spaced);
302 tokens.push(PtxToken::Semicolon);
303 if spaced {
304 tokens.push(PtxToken::Newline);
305 }
306 }
307 }
308
309 impl PtxUnparser for AddRndFtzSatF16x2 {
310 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
311 self.unparse_tokens_mode(tokens, false);
312 }
313 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
314 push_opcode(tokens, "add");
315 if let Some(rnd_4) = self.rnd.as_ref() {
316 match rnd_4 {
317 Rnd::Rn => {
318 push_directive(tokens, "rn");
319 }
320 }
321 }
322 if self.ftz {
323 push_directive(tokens, "ftz");
324 }
325 if self.sat {
326 push_directive(tokens, "sat");
327 }
328 push_directive(tokens, "f16x2");
329 if spaced {
330 tokens.push(PtxToken::Space);
331 }
332 self.d.unparse_tokens_mode(tokens, spaced);
333 tokens.push(PtxToken::Comma);
334 if spaced {
335 tokens.push(PtxToken::Space);
336 }
337 self.a.unparse_tokens_mode(tokens, spaced);
338 tokens.push(PtxToken::Comma);
339 if spaced {
340 tokens.push(PtxToken::Space);
341 }
342 self.b.unparse_tokens_mode(tokens, spaced);
343 tokens.push(PtxToken::Semicolon);
344 if spaced {
345 tokens.push(PtxToken::Newline);
346 }
347 }
348 }
349
350 impl PtxUnparser for AddRndBf16 {
351 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
352 self.unparse_tokens_mode(tokens, false);
353 }
354 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
355 push_opcode(tokens, "add");
356 if let Some(rnd_5) = self.rnd.as_ref() {
357 match rnd_5 {
358 Rnd::Rn => {
359 push_directive(tokens, "rn");
360 }
361 }
362 }
363 push_directive(tokens, "bf16");
364 if spaced {
365 tokens.push(PtxToken::Space);
366 }
367 self.d.unparse_tokens_mode(tokens, spaced);
368 tokens.push(PtxToken::Comma);
369 if spaced {
370 tokens.push(PtxToken::Space);
371 }
372 self.a.unparse_tokens_mode(tokens, spaced);
373 tokens.push(PtxToken::Comma);
374 if spaced {
375 tokens.push(PtxToken::Space);
376 }
377 self.b.unparse_tokens_mode(tokens, spaced);
378 tokens.push(PtxToken::Semicolon);
379 if spaced {
380 tokens.push(PtxToken::Newline);
381 }
382 }
383 }
384
385 impl PtxUnparser for AddRndBf16x2 {
386 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
387 self.unparse_tokens_mode(tokens, false);
388 }
389 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
390 push_opcode(tokens, "add");
391 if let Some(rnd_6) = self.rnd.as_ref() {
392 match rnd_6 {
393 Rnd::Rn => {
394 push_directive(tokens, "rn");
395 }
396 }
397 }
398 push_directive(tokens, "bf16x2");
399 if spaced {
400 tokens.push(PtxToken::Space);
401 }
402 self.d.unparse_tokens_mode(tokens, spaced);
403 tokens.push(PtxToken::Comma);
404 if spaced {
405 tokens.push(PtxToken::Space);
406 }
407 self.a.unparse_tokens_mode(tokens, spaced);
408 tokens.push(PtxToken::Comma);
409 if spaced {
410 tokens.push(PtxToken::Space);
411 }
412 self.b.unparse_tokens_mode(tokens, spaced);
413 tokens.push(PtxToken::Semicolon);
414 if spaced {
415 tokens.push(PtxToken::Newline);
416 }
417 }
418 }
419}
420
421pub mod section_3 {
422 use super::*;
423 use crate::r#type::instruction::add::section_3::*;
424
425 impl PtxUnparser for AddRndSatF32Atype {
426 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
427 self.unparse_tokens_mode(tokens, false);
428 }
429 fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
430 push_opcode(tokens, "add");
431 if let Some(rnd_7) = self.rnd.as_ref() {
432 match rnd_7 {
433 Rnd::Rn => {
434 push_directive(tokens, "rn");
435 }
436 Rnd::Rz => {
437 push_directive(tokens, "rz");
438 }
439 Rnd::Rm => {
440 push_directive(tokens, "rm");
441 }
442 Rnd::Rp => {
443 push_directive(tokens, "rp");
444 }
445 }
446 }
447 if self.sat {
448 push_directive(tokens, "sat");
449 }
450 push_directive(tokens, "f32");
451 match &self.atype {
452 Atype::Bf16 => {
453 push_directive(tokens, "bf16");
454 }
455 Atype::F16 => {
456 push_directive(tokens, "f16");
457 }
458 }
459 if spaced {
460 tokens.push(PtxToken::Space);
461 }
462 self.d.unparse_tokens_mode(tokens, spaced);
463 tokens.push(PtxToken::Comma);
464 if spaced {
465 tokens.push(PtxToken::Space);
466 }
467 self.a.unparse_tokens_mode(tokens, spaced);
468 tokens.push(PtxToken::Comma);
469 if spaced {
470 tokens.push(PtxToken::Space);
471 }
472 self.c.unparse_tokens_mode(tokens, spaced);
473 tokens.push(PtxToken::Semicolon);
474 if spaced {
475 tokens.push(PtxToken::Newline);
476 }
477 }
478 }
479}