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