ptx_parser/unparser/instruction/
cvt_pack.rs

1//! Original PTX specification:
2//!
3//! cvt.pack.sat.convertType.abType  d, a, b;
4//! .convertType  = { .u16, .s16 };
5//! .abType       = { .s32 };
6//! ----------------------------------------------------------------
7//! cvt.pack.sat.convertType.abType.cType  d, a, b, c;
8//! .convertType  = { .u2, .s2, .u4, .s4, .u8, .s8 };
9//! .abType       = { .s32 };
10//! .cType        = { .b32 };
11
12#![allow(unused)]
13
14use crate::lexer::PtxToken;
15use crate::unparser::{PtxUnparser, common::*};
16
17pub mod section_0 {
18    use super::*;
19    use crate::r#type::instruction::cvt_pack::section_0::*;
20
21    impl PtxUnparser for CvtPackSatConverttypeAbtype {
22        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
23            push_opcode(tokens, "cvt");
24            push_directive(tokens, "pack");
25            push_directive(tokens, "sat");
26            match &self.converttype {
27                Converttype::U16 => {
28                    push_directive(tokens, "u16");
29                }
30                Converttype::S16 => {
31                    push_directive(tokens, "s16");
32                }
33            }
34            match &self.abtype {
35                Abtype::S32 => {
36                    push_directive(tokens, "s32");
37                }
38            }
39            self.d.unparse_tokens(tokens);
40            tokens.push(PtxToken::Comma);
41            self.a.unparse_tokens(tokens);
42            tokens.push(PtxToken::Comma);
43            self.b.unparse_tokens(tokens);
44            tokens.push(PtxToken::Semicolon);
45        }
46    }
47}
48
49pub mod section_1 {
50    use super::*;
51    use crate::r#type::instruction::cvt_pack::section_1::*;
52
53    impl PtxUnparser for CvtPackSatConverttypeAbtypeCtype {
54        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
55            push_opcode(tokens, "cvt");
56            push_directive(tokens, "pack");
57            push_directive(tokens, "sat");
58            match &self.converttype {
59                Converttype::U2 => {
60                    push_directive(tokens, "u2");
61                }
62                Converttype::S2 => {
63                    push_directive(tokens, "s2");
64                }
65                Converttype::U4 => {
66                    push_directive(tokens, "u4");
67                }
68                Converttype::S4 => {
69                    push_directive(tokens, "s4");
70                }
71                Converttype::U8 => {
72                    push_directive(tokens, "u8");
73                }
74                Converttype::S8 => {
75                    push_directive(tokens, "s8");
76                }
77            }
78            match &self.abtype {
79                Abtype::S32 => {
80                    push_directive(tokens, "s32");
81                }
82            }
83            match &self.ctype {
84                Ctype::B32 => {
85                    push_directive(tokens, "b32");
86                }
87            }
88            self.d.unparse_tokens(tokens);
89            tokens.push(PtxToken::Comma);
90            self.a.unparse_tokens(tokens);
91            tokens.push(PtxToken::Comma);
92            self.b.unparse_tokens(tokens);
93            tokens.push(PtxToken::Comma);
94            self.c.unparse_tokens(tokens);
95            tokens.push(PtxToken::Semicolon);
96        }
97    }
98}