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}
49
50pub mod section_1 {
51    use super::*;
52    use crate::r#type::instruction::cvt_pack::section_1::*;
53
54    impl PtxUnparser for CvtPackSatConverttypeAbtypeCtype {
55        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
56            push_opcode(tokens, "cvt");
57                    push_directive(tokens, "pack");
58                    push_directive(tokens, "sat");
59                    match &self.converttype {
60                            Converttype::U2 => {
61                                    push_directive(tokens, "u2");
62                            }
63                            Converttype::S2 => {
64                                    push_directive(tokens, "s2");
65                            }
66                            Converttype::U4 => {
67                                    push_directive(tokens, "u4");
68                            }
69                            Converttype::S4 => {
70                                    push_directive(tokens, "s4");
71                            }
72                            Converttype::U8 => {
73                                    push_directive(tokens, "u8");
74                            }
75                            Converttype::S8 => {
76                                    push_directive(tokens, "s8");
77                            }
78                    }
79                    match &self.abtype {
80                            Abtype::S32 => {
81                                    push_directive(tokens, "s32");
82                            }
83                    }
84                    match &self.ctype {
85                            Ctype::B32 => {
86                                    push_directive(tokens, "b32");
87                            }
88                    }
89                    self.d.unparse_tokens(tokens);
90            tokens.push(PtxToken::Comma);
91                    self.a.unparse_tokens(tokens);
92            tokens.push(PtxToken::Comma);
93                    self.b.unparse_tokens(tokens);
94            tokens.push(PtxToken::Comma);
95                    self.c.unparse_tokens(tokens);
96            tokens.push(PtxToken::Semicolon);
97        }
98    }
99
100}
101