Skip to main content

ptx_parser/unparser/instruction/
vset4.rs

1//! Original PTX specification:
2//!
3//! // SIMD instruction with secondary SIMD merge operation
4//! vset4.atype.btype.cmp  d{.mask}, a{.asel}, b{.bsel}, c;
5//! // SIMD instruction with secondary accumulate operation
6//! vset4.atype.btype.cmp.add  d{.mask}, a{.asel}, b{.bsel}, c;
7//! .atype = .btype = { .u32, .s32 };
8//! .cmp   = { .eq, .ne, .lt, .le, .gt, .ge };
9//! .mask  = { .b0,
10//! .b1, .b10
11//! .b2, .b20, .b21, .b210,
12//! .b3, .b30, .b31, .b310, .b32, .b320, .b321, .b3210 };
13//! defaults to .b3210
14//! .asel = .bsel = { .b00, .b01, .b02, .b03, .b04, .b05, .b06, .b07,
15//!                   .b10, .b11, .b12, .b13, .b14, .b15, .b16, .b17,
16//!                   .b20, .b21, .b22, .b23, .b24, .b25, .b26, .b27,
17//!                   .b30, .b31, .b32, .b33, .b34, .b35, .b36, .b37,
18//!                   .b40, .b41, .b42, .b43, .b44, .b45, .b46, .b47,
19//!                   .b50, .b51, .b52, .b53, .b54, .b55, .b56, .b57,
20//!                   .b60, .b61, .b62, .b63, .b64, .b65, .b66, .b67,
21//!                   .b70, .b71, .b72, .b73, .b74, .b75, .b76, .b77
22//!                   } //.bxyzw, where x,y,z,w are from { 0, ..., 7 };
23//! // .asel defaults to .b3210
24//! // .bsel defaults to .b7654
25
26#![allow(unused)]
27
28use crate::lexer::PtxToken;
29use crate::unparser::{PtxUnparser, common::*};
30
31pub mod section_0 {
32    use super::*;
33    use crate::r#type::instruction::vset4::section_0::*;
34
35    impl PtxUnparser for Vset4AtypeBtypeCmp {
36        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
37            self.unparse_tokens_mode(tokens, false);
38        }
39        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
40            push_opcode(tokens, "vset4");
41            match &self.atype {
42                Atype::U32 => {
43                    push_directive(tokens, "u32");
44                }
45                Atype::S32 => {
46                    push_directive(tokens, "s32");
47                }
48            }
49            match &self.btype {
50                Btype::U32 => {
51                    push_directive(tokens, "u32");
52                }
53                Btype::S32 => {
54                    push_directive(tokens, "s32");
55                }
56            }
57            match &self.cmp {
58                Cmp::Eq => {
59                    push_directive(tokens, "eq");
60                }
61                Cmp::Ne => {
62                    push_directive(tokens, "ne");
63                }
64                Cmp::Lt => {
65                    push_directive(tokens, "lt");
66                }
67                Cmp::Le => {
68                    push_directive(tokens, "le");
69                }
70                Cmp::Gt => {
71                    push_directive(tokens, "gt");
72                }
73                Cmp::Ge => {
74                    push_directive(tokens, "ge");
75                }
76            }
77            if spaced {
78                tokens.push(PtxToken::Space);
79            }
80            self.d.unparse_tokens_mode(tokens, spaced);
81            if let Some(mask_0) = self.mask.as_ref() {
82                match mask_0 {
83                    Mask::B10B2 => {
84                        push_directive(tokens, "b10.b2");
85                    }
86                    Mask::B3210 => {
87                        push_directive(tokens, "b3210");
88                    }
89                    Mask::B210 => {
90                        push_directive(tokens, "b210");
91                    }
92                    Mask::B310 => {
93                        push_directive(tokens, "b310");
94                    }
95                    Mask::B320 => {
96                        push_directive(tokens, "b320");
97                    }
98                    Mask::B321 => {
99                        push_directive(tokens, "b321");
100                    }
101                    Mask::B20 => {
102                        push_directive(tokens, "b20");
103                    }
104                    Mask::B21 => {
105                        push_directive(tokens, "b21");
106                    }
107                    Mask::B30 => {
108                        push_directive(tokens, "b30");
109                    }
110                    Mask::B31 => {
111                        push_directive(tokens, "b31");
112                    }
113                    Mask::B32 => {
114                        push_directive(tokens, "b32");
115                    }
116                    Mask::B0 => {
117                        push_directive(tokens, "b0");
118                    }
119                    Mask::B1 => {
120                        push_directive(tokens, "b1");
121                    }
122                    Mask::B3 => {
123                        push_directive(tokens, "b3");
124                    }
125                }
126            }
127            tokens.push(PtxToken::Comma);
128            if spaced {
129                tokens.push(PtxToken::Space);
130            }
131            self.a.unparse_tokens_mode(tokens, spaced);
132            if self.asel {
133                push_directive(tokens, "asel");
134            }
135            tokens.push(PtxToken::Comma);
136            if spaced {
137                tokens.push(PtxToken::Space);
138            }
139            self.b.unparse_tokens_mode(tokens, spaced);
140            if let Some(bsel_1) = self.bsel.as_ref() {
141                match bsel_1 {
142                    Bsel::B00 => {
143                        push_directive(tokens, "b00");
144                    }
145                    Bsel::B01 => {
146                        push_directive(tokens, "b01");
147                    }
148                    Bsel::B02 => {
149                        push_directive(tokens, "b02");
150                    }
151                    Bsel::B03 => {
152                        push_directive(tokens, "b03");
153                    }
154                    Bsel::B04 => {
155                        push_directive(tokens, "b04");
156                    }
157                    Bsel::B05 => {
158                        push_directive(tokens, "b05");
159                    }
160                    Bsel::B06 => {
161                        push_directive(tokens, "b06");
162                    }
163                    Bsel::B07 => {
164                        push_directive(tokens, "b07");
165                    }
166                    Bsel::B10 => {
167                        push_directive(tokens, "b10");
168                    }
169                    Bsel::B11 => {
170                        push_directive(tokens, "b11");
171                    }
172                    Bsel::B12 => {
173                        push_directive(tokens, "b12");
174                    }
175                    Bsel::B13 => {
176                        push_directive(tokens, "b13");
177                    }
178                    Bsel::B14 => {
179                        push_directive(tokens, "b14");
180                    }
181                    Bsel::B15 => {
182                        push_directive(tokens, "b15");
183                    }
184                    Bsel::B16 => {
185                        push_directive(tokens, "b16");
186                    }
187                    Bsel::B17 => {
188                        push_directive(tokens, "b17");
189                    }
190                    Bsel::B20 => {
191                        push_directive(tokens, "b20");
192                    }
193                    Bsel::B21 => {
194                        push_directive(tokens, "b21");
195                    }
196                    Bsel::B22 => {
197                        push_directive(tokens, "b22");
198                    }
199                    Bsel::B23 => {
200                        push_directive(tokens, "b23");
201                    }
202                    Bsel::B24 => {
203                        push_directive(tokens, "b24");
204                    }
205                    Bsel::B25 => {
206                        push_directive(tokens, "b25");
207                    }
208                    Bsel::B26 => {
209                        push_directive(tokens, "b26");
210                    }
211                    Bsel::B27 => {
212                        push_directive(tokens, "b27");
213                    }
214                    Bsel::B30 => {
215                        push_directive(tokens, "b30");
216                    }
217                    Bsel::B31 => {
218                        push_directive(tokens, "b31");
219                    }
220                    Bsel::B32 => {
221                        push_directive(tokens, "b32");
222                    }
223                    Bsel::B33 => {
224                        push_directive(tokens, "b33");
225                    }
226                    Bsel::B34 => {
227                        push_directive(tokens, "b34");
228                    }
229                    Bsel::B35 => {
230                        push_directive(tokens, "b35");
231                    }
232                    Bsel::B36 => {
233                        push_directive(tokens, "b36");
234                    }
235                    Bsel::B37 => {
236                        push_directive(tokens, "b37");
237                    }
238                    Bsel::B40 => {
239                        push_directive(tokens, "b40");
240                    }
241                    Bsel::B41 => {
242                        push_directive(tokens, "b41");
243                    }
244                    Bsel::B42 => {
245                        push_directive(tokens, "b42");
246                    }
247                    Bsel::B43 => {
248                        push_directive(tokens, "b43");
249                    }
250                    Bsel::B44 => {
251                        push_directive(tokens, "b44");
252                    }
253                    Bsel::B45 => {
254                        push_directive(tokens, "b45");
255                    }
256                    Bsel::B46 => {
257                        push_directive(tokens, "b46");
258                    }
259                    Bsel::B47 => {
260                        push_directive(tokens, "b47");
261                    }
262                    Bsel::B50 => {
263                        push_directive(tokens, "b50");
264                    }
265                    Bsel::B51 => {
266                        push_directive(tokens, "b51");
267                    }
268                    Bsel::B52 => {
269                        push_directive(tokens, "b52");
270                    }
271                    Bsel::B53 => {
272                        push_directive(tokens, "b53");
273                    }
274                    Bsel::B54 => {
275                        push_directive(tokens, "b54");
276                    }
277                    Bsel::B55 => {
278                        push_directive(tokens, "b55");
279                    }
280                    Bsel::B56 => {
281                        push_directive(tokens, "b56");
282                    }
283                    Bsel::B57 => {
284                        push_directive(tokens, "b57");
285                    }
286                    Bsel::B60 => {
287                        push_directive(tokens, "b60");
288                    }
289                    Bsel::B61 => {
290                        push_directive(tokens, "b61");
291                    }
292                    Bsel::B62 => {
293                        push_directive(tokens, "b62");
294                    }
295                    Bsel::B63 => {
296                        push_directive(tokens, "b63");
297                    }
298                    Bsel::B64 => {
299                        push_directive(tokens, "b64");
300                    }
301                    Bsel::B65 => {
302                        push_directive(tokens, "b65");
303                    }
304                    Bsel::B66 => {
305                        push_directive(tokens, "b66");
306                    }
307                    Bsel::B67 => {
308                        push_directive(tokens, "b67");
309                    }
310                    Bsel::B70 => {
311                        push_directive(tokens, "b70");
312                    }
313                    Bsel::B71 => {
314                        push_directive(tokens, "b71");
315                    }
316                    Bsel::B72 => {
317                        push_directive(tokens, "b72");
318                    }
319                    Bsel::B73 => {
320                        push_directive(tokens, "b73");
321                    }
322                    Bsel::B74 => {
323                        push_directive(tokens, "b74");
324                    }
325                    Bsel::B75 => {
326                        push_directive(tokens, "b75");
327                    }
328                    Bsel::B76 => {
329                        push_directive(tokens, "b76");
330                    }
331                    Bsel::B77 => {
332                        push_directive(tokens, "b77");
333                    }
334                }
335            }
336            tokens.push(PtxToken::Comma);
337            if spaced {
338                tokens.push(PtxToken::Space);
339            }
340            self.c.unparse_tokens_mode(tokens, spaced);
341            tokens.push(PtxToken::Semicolon);
342            if spaced {
343                tokens.push(PtxToken::Newline);
344            }
345        }
346    }
347
348    impl PtxUnparser for Vset4AtypeBtypeCmpAdd {
349        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
350            self.unparse_tokens_mode(tokens, false);
351        }
352        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
353            push_opcode(tokens, "vset4");
354            match &self.atype {
355                Atype::U32 => {
356                    push_directive(tokens, "u32");
357                }
358                Atype::S32 => {
359                    push_directive(tokens, "s32");
360                }
361            }
362            match &self.btype {
363                Btype::U32 => {
364                    push_directive(tokens, "u32");
365                }
366                Btype::S32 => {
367                    push_directive(tokens, "s32");
368                }
369            }
370            match &self.cmp {
371                Cmp::Eq => {
372                    push_directive(tokens, "eq");
373                }
374                Cmp::Ne => {
375                    push_directive(tokens, "ne");
376                }
377                Cmp::Lt => {
378                    push_directive(tokens, "lt");
379                }
380                Cmp::Le => {
381                    push_directive(tokens, "le");
382                }
383                Cmp::Gt => {
384                    push_directive(tokens, "gt");
385                }
386                Cmp::Ge => {
387                    push_directive(tokens, "ge");
388                }
389            }
390            push_directive(tokens, "add");
391            if spaced {
392                tokens.push(PtxToken::Space);
393            }
394            self.d.unparse_tokens_mode(tokens, spaced);
395            if let Some(mask_2) = self.mask.as_ref() {
396                match mask_2 {
397                    Mask::B10B2 => {
398                        push_directive(tokens, "b10.b2");
399                    }
400                    Mask::B3210 => {
401                        push_directive(tokens, "b3210");
402                    }
403                    Mask::B210 => {
404                        push_directive(tokens, "b210");
405                    }
406                    Mask::B310 => {
407                        push_directive(tokens, "b310");
408                    }
409                    Mask::B320 => {
410                        push_directive(tokens, "b320");
411                    }
412                    Mask::B321 => {
413                        push_directive(tokens, "b321");
414                    }
415                    Mask::B20 => {
416                        push_directive(tokens, "b20");
417                    }
418                    Mask::B21 => {
419                        push_directive(tokens, "b21");
420                    }
421                    Mask::B30 => {
422                        push_directive(tokens, "b30");
423                    }
424                    Mask::B31 => {
425                        push_directive(tokens, "b31");
426                    }
427                    Mask::B32 => {
428                        push_directive(tokens, "b32");
429                    }
430                    Mask::B0 => {
431                        push_directive(tokens, "b0");
432                    }
433                    Mask::B1 => {
434                        push_directive(tokens, "b1");
435                    }
436                    Mask::B3 => {
437                        push_directive(tokens, "b3");
438                    }
439                }
440            }
441            tokens.push(PtxToken::Comma);
442            if spaced {
443                tokens.push(PtxToken::Space);
444            }
445            self.a.unparse_tokens_mode(tokens, spaced);
446            if self.asel {
447                push_directive(tokens, "asel");
448            }
449            tokens.push(PtxToken::Comma);
450            if spaced {
451                tokens.push(PtxToken::Space);
452            }
453            self.b.unparse_tokens_mode(tokens, spaced);
454            if let Some(bsel_3) = self.bsel.as_ref() {
455                match bsel_3 {
456                    Bsel::B00 => {
457                        push_directive(tokens, "b00");
458                    }
459                    Bsel::B01 => {
460                        push_directive(tokens, "b01");
461                    }
462                    Bsel::B02 => {
463                        push_directive(tokens, "b02");
464                    }
465                    Bsel::B03 => {
466                        push_directive(tokens, "b03");
467                    }
468                    Bsel::B04 => {
469                        push_directive(tokens, "b04");
470                    }
471                    Bsel::B05 => {
472                        push_directive(tokens, "b05");
473                    }
474                    Bsel::B06 => {
475                        push_directive(tokens, "b06");
476                    }
477                    Bsel::B07 => {
478                        push_directive(tokens, "b07");
479                    }
480                    Bsel::B10 => {
481                        push_directive(tokens, "b10");
482                    }
483                    Bsel::B11 => {
484                        push_directive(tokens, "b11");
485                    }
486                    Bsel::B12 => {
487                        push_directive(tokens, "b12");
488                    }
489                    Bsel::B13 => {
490                        push_directive(tokens, "b13");
491                    }
492                    Bsel::B14 => {
493                        push_directive(tokens, "b14");
494                    }
495                    Bsel::B15 => {
496                        push_directive(tokens, "b15");
497                    }
498                    Bsel::B16 => {
499                        push_directive(tokens, "b16");
500                    }
501                    Bsel::B17 => {
502                        push_directive(tokens, "b17");
503                    }
504                    Bsel::B20 => {
505                        push_directive(tokens, "b20");
506                    }
507                    Bsel::B21 => {
508                        push_directive(tokens, "b21");
509                    }
510                    Bsel::B22 => {
511                        push_directive(tokens, "b22");
512                    }
513                    Bsel::B23 => {
514                        push_directive(tokens, "b23");
515                    }
516                    Bsel::B24 => {
517                        push_directive(tokens, "b24");
518                    }
519                    Bsel::B25 => {
520                        push_directive(tokens, "b25");
521                    }
522                    Bsel::B26 => {
523                        push_directive(tokens, "b26");
524                    }
525                    Bsel::B27 => {
526                        push_directive(tokens, "b27");
527                    }
528                    Bsel::B30 => {
529                        push_directive(tokens, "b30");
530                    }
531                    Bsel::B31 => {
532                        push_directive(tokens, "b31");
533                    }
534                    Bsel::B32 => {
535                        push_directive(tokens, "b32");
536                    }
537                    Bsel::B33 => {
538                        push_directive(tokens, "b33");
539                    }
540                    Bsel::B34 => {
541                        push_directive(tokens, "b34");
542                    }
543                    Bsel::B35 => {
544                        push_directive(tokens, "b35");
545                    }
546                    Bsel::B36 => {
547                        push_directive(tokens, "b36");
548                    }
549                    Bsel::B37 => {
550                        push_directive(tokens, "b37");
551                    }
552                    Bsel::B40 => {
553                        push_directive(tokens, "b40");
554                    }
555                    Bsel::B41 => {
556                        push_directive(tokens, "b41");
557                    }
558                    Bsel::B42 => {
559                        push_directive(tokens, "b42");
560                    }
561                    Bsel::B43 => {
562                        push_directive(tokens, "b43");
563                    }
564                    Bsel::B44 => {
565                        push_directive(tokens, "b44");
566                    }
567                    Bsel::B45 => {
568                        push_directive(tokens, "b45");
569                    }
570                    Bsel::B46 => {
571                        push_directive(tokens, "b46");
572                    }
573                    Bsel::B47 => {
574                        push_directive(tokens, "b47");
575                    }
576                    Bsel::B50 => {
577                        push_directive(tokens, "b50");
578                    }
579                    Bsel::B51 => {
580                        push_directive(tokens, "b51");
581                    }
582                    Bsel::B52 => {
583                        push_directive(tokens, "b52");
584                    }
585                    Bsel::B53 => {
586                        push_directive(tokens, "b53");
587                    }
588                    Bsel::B54 => {
589                        push_directive(tokens, "b54");
590                    }
591                    Bsel::B55 => {
592                        push_directive(tokens, "b55");
593                    }
594                    Bsel::B56 => {
595                        push_directive(tokens, "b56");
596                    }
597                    Bsel::B57 => {
598                        push_directive(tokens, "b57");
599                    }
600                    Bsel::B60 => {
601                        push_directive(tokens, "b60");
602                    }
603                    Bsel::B61 => {
604                        push_directive(tokens, "b61");
605                    }
606                    Bsel::B62 => {
607                        push_directive(tokens, "b62");
608                    }
609                    Bsel::B63 => {
610                        push_directive(tokens, "b63");
611                    }
612                    Bsel::B64 => {
613                        push_directive(tokens, "b64");
614                    }
615                    Bsel::B65 => {
616                        push_directive(tokens, "b65");
617                    }
618                    Bsel::B66 => {
619                        push_directive(tokens, "b66");
620                    }
621                    Bsel::B67 => {
622                        push_directive(tokens, "b67");
623                    }
624                    Bsel::B70 => {
625                        push_directive(tokens, "b70");
626                    }
627                    Bsel::B71 => {
628                        push_directive(tokens, "b71");
629                    }
630                    Bsel::B72 => {
631                        push_directive(tokens, "b72");
632                    }
633                    Bsel::B73 => {
634                        push_directive(tokens, "b73");
635                    }
636                    Bsel::B74 => {
637                        push_directive(tokens, "b74");
638                    }
639                    Bsel::B75 => {
640                        push_directive(tokens, "b75");
641                    }
642                    Bsel::B76 => {
643                        push_directive(tokens, "b76");
644                    }
645                    Bsel::B77 => {
646                        push_directive(tokens, "b77");
647                    }
648                }
649            }
650            tokens.push(PtxToken::Comma);
651            if spaced {
652                tokens.push(PtxToken::Space);
653            }
654            self.c.unparse_tokens_mode(tokens, spaced);
655            tokens.push(PtxToken::Semicolon);
656            if spaced {
657                tokens.push(PtxToken::Newline);
658            }
659        }
660    }
661}