ptx_parser/unparser/instruction/sust.rs
1//! Original PTX specification:
2//!
3//! sust.b.dim{.cop}.vec.ctype{.mode} [a, b], c; // unformatted
4//! sust.p.dim.vec.b32{.mode} [a, b], c; // formatted
5//! sust.b.adim{.cop}.vec.ctype{.mode} [a, b], c; // unformatted
6//! .cop = { .wb, .cg, .cs, .wt }; // cache operation
7//! .vec = { none, .v2, .v4 };
8//! .ctype = { .b8 , .b16, .b32, .b64 };
9//! .mode = { .trap, .clamp, .zero };
10//! .dim = { .1d, .2d, .3d };
11//! .adim = { .a1d, .a2d };
12
13#![allow(unused)]
14
15use crate::lexer::PtxToken;
16use crate::unparser::{PtxUnparser, common::*};
17
18pub mod section_0 {
19 use super::*;
20 use crate::r#type::instruction::sust::section_0::*;
21
22 impl PtxUnparser for SustBDimCopVecCtypeMode {
23 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
24 push_opcode(tokens, "sust");
25 push_directive(tokens, "b");
26 match &self.dim {
27 Dim::_1d => {
28 push_directive(tokens, "1d");
29 }
30 Dim::_2d => {
31 push_directive(tokens, "2d");
32 }
33 Dim::_3d => {
34 push_directive(tokens, "3d");
35 }
36 }
37 if let Some(cop_0) = self.cop.as_ref() {
38 match cop_0 {
39 Cop::Wb => {
40 push_directive(tokens, "wb");
41 }
42 Cop::Cg => {
43 push_directive(tokens, "cg");
44 }
45 Cop::Cs => {
46 push_directive(tokens, "cs");
47 }
48 Cop::Wt => {
49 push_directive(tokens, "wt");
50 }
51 }
52 }
53 match &self.vec {
54 Vec::None => {
55 push_token_from_str(tokens, "none");
56 }
57 Vec::V2 => {
58 push_directive(tokens, "v2");
59 }
60 Vec::V4 => {
61 push_directive(tokens, "v4");
62 }
63 }
64 match &self.ctype {
65 Ctype::B16 => {
66 push_directive(tokens, "b16");
67 }
68 Ctype::B32 => {
69 push_directive(tokens, "b32");
70 }
71 Ctype::B64 => {
72 push_directive(tokens, "b64");
73 }
74 Ctype::B8 => {
75 push_directive(tokens, "b8");
76 }
77 }
78 if let Some(mode_1) = self.mode.as_ref() {
79 match mode_1 {
80 Mode::Clamp => {
81 push_directive(tokens, "clamp");
82 }
83 Mode::Trap => {
84 push_directive(tokens, "trap");
85 }
86 Mode::Zero => {
87 push_directive(tokens, "zero");
88 }
89 }
90 }
91 self.a.unparse_tokens(tokens);
92 tokens.push(PtxToken::Comma);
93 self.c.unparse_tokens(tokens);
94 tokens.push(PtxToken::Semicolon);
95 }
96 }
97
98 impl PtxUnparser for SustPDimVecB32Mode {
99 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
100 push_opcode(tokens, "sust");
101 push_directive(tokens, "p");
102 match &self.dim {
103 Dim::_1d => {
104 push_directive(tokens, "1d");
105 }
106 Dim::_2d => {
107 push_directive(tokens, "2d");
108 }
109 Dim::_3d => {
110 push_directive(tokens, "3d");
111 }
112 }
113 match &self.vec {
114 Vec::None => {
115 push_token_from_str(tokens, "none");
116 }
117 Vec::V2 => {
118 push_directive(tokens, "v2");
119 }
120 Vec::V4 => {
121 push_directive(tokens, "v4");
122 }
123 }
124 push_directive(tokens, "b32");
125 if let Some(mode_2) = self.mode.as_ref() {
126 match mode_2 {
127 Mode::Clamp => {
128 push_directive(tokens, "clamp");
129 }
130 Mode::Trap => {
131 push_directive(tokens, "trap");
132 }
133 Mode::Zero => {
134 push_directive(tokens, "zero");
135 }
136 }
137 }
138 self.a.unparse_tokens(tokens);
139 tokens.push(PtxToken::Comma);
140 self.c.unparse_tokens(tokens);
141 tokens.push(PtxToken::Semicolon);
142 }
143 }
144
145 impl PtxUnparser for SustBAdimCopVecCtypeMode {
146 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
147 push_opcode(tokens, "sust");
148 push_directive(tokens, "b");
149 match &self.adim {
150 Adim::A1d => {
151 push_directive(tokens, "a1d");
152 }
153 Adim::A2d => {
154 push_directive(tokens, "a2d");
155 }
156 }
157 if let Some(cop_3) = self.cop.as_ref() {
158 match cop_3 {
159 Cop::Wb => {
160 push_directive(tokens, "wb");
161 }
162 Cop::Cg => {
163 push_directive(tokens, "cg");
164 }
165 Cop::Cs => {
166 push_directive(tokens, "cs");
167 }
168 Cop::Wt => {
169 push_directive(tokens, "wt");
170 }
171 }
172 }
173 match &self.vec {
174 Vec::None => {
175 push_token_from_str(tokens, "none");
176 }
177 Vec::V2 => {
178 push_directive(tokens, "v2");
179 }
180 Vec::V4 => {
181 push_directive(tokens, "v4");
182 }
183 }
184 match &self.ctype {
185 Ctype::B16 => {
186 push_directive(tokens, "b16");
187 }
188 Ctype::B32 => {
189 push_directive(tokens, "b32");
190 }
191 Ctype::B64 => {
192 push_directive(tokens, "b64");
193 }
194 Ctype::B8 => {
195 push_directive(tokens, "b8");
196 }
197 }
198 if let Some(mode_4) = self.mode.as_ref() {
199 match mode_4 {
200 Mode::Clamp => {
201 push_directive(tokens, "clamp");
202 }
203 Mode::Trap => {
204 push_directive(tokens, "trap");
205 }
206 Mode::Zero => {
207 push_directive(tokens, "zero");
208 }
209 }
210 }
211 self.a.unparse_tokens(tokens);
212 tokens.push(PtxToken::Comma);
213 self.c.unparse_tokens(tokens);
214 tokens.push(PtxToken::Semicolon);
215 }
216 }
217
218}
219