Skip to main content

ptx_parser/unparser/instruction/
call.rs

1//! Original PTX specification:
2//!
3//! // direct call to named function, func is a symbol
4//! call{.uni} (ret-param), func, (param-list);
5//! call{.uni} func, (param-list);
6//! call{.uni} func;
7//! // indirect call via pointer, with full list of call targets
8//! call{.uni} (ret-param), fptr, (param-list), flist;
9//! call{.uni} fptr, (param-list), flist;
10//! call{.uni} fptr, flist;
11//! // indirect call via pointer, with no knowledge of call targets
12//! call{.uni} (ret-param), fptr, (param-list), fproto;
13//! call{.uni} fptr, (param-list), fproto;
14//! call{.uni} fptr, fproto;
15
16#![allow(unused)]
17
18use crate::lexer::PtxToken;
19use crate::unparser::{PtxUnparser, common::*};
20
21pub mod section_0 {
22    use super::*;
23    use crate::r#type::instruction::call::section_0::*;
24
25    impl PtxUnparser for CallUni {
26        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
27            self.unparse_tokens_mode(tokens, false);
28        }
29        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
30            push_opcode(tokens, "call");
31            if self.uni {
32                push_directive(tokens, "uni");
33            }
34            if spaced {
35                tokens.push(PtxToken::Space);
36            }
37            tokens.push(PtxToken::LParen);
38            self.ret_param.unparse_tokens_mode(tokens, spaced);
39            tokens.push(PtxToken::RParen);
40            tokens.push(PtxToken::Comma);
41            if spaced {
42                tokens.push(PtxToken::Space);
43            }
44            self.func.unparse_tokens_mode(tokens, spaced);
45            tokens.push(PtxToken::Comma);
46            if spaced {
47                tokens.push(PtxToken::Space);
48            }
49            tokens.push(PtxToken::LParen);
50            for (idx, operand) in self.param_list.iter().enumerate() {
51                if idx > 0 {
52                    tokens.push(PtxToken::Comma);
53                }
54                operand.unparse_tokens_mode(tokens, spaced);
55            }
56            tokens.push(PtxToken::RParen);
57            tokens.push(PtxToken::Semicolon);
58            if spaced {
59                tokens.push(PtxToken::Newline);
60            }
61        }
62    }
63
64    impl PtxUnparser for CallUni1 {
65        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
66            self.unparse_tokens_mode(tokens, false);
67        }
68        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
69            push_opcode(tokens, "call");
70            if self.uni {
71                push_directive(tokens, "uni");
72            }
73            if spaced {
74                tokens.push(PtxToken::Space);
75            }
76            self.func.unparse_tokens_mode(tokens, spaced);
77            tokens.push(PtxToken::Comma);
78            if spaced {
79                tokens.push(PtxToken::Space);
80            }
81            tokens.push(PtxToken::LParen);
82            for (idx, operand) in self.param_list.iter().enumerate() {
83                if idx > 0 {
84                    tokens.push(PtxToken::Comma);
85                }
86                operand.unparse_tokens_mode(tokens, spaced);
87            }
88            tokens.push(PtxToken::RParen);
89            tokens.push(PtxToken::Semicolon);
90            if spaced {
91                tokens.push(PtxToken::Newline);
92            }
93        }
94    }
95
96    impl PtxUnparser for CallUni2 {
97        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
98            self.unparse_tokens_mode(tokens, false);
99        }
100        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
101            push_opcode(tokens, "call");
102            if self.uni {
103                push_directive(tokens, "uni");
104            }
105            if spaced {
106                tokens.push(PtxToken::Space);
107            }
108            self.func.unparse_tokens_mode(tokens, spaced);
109            tokens.push(PtxToken::Semicolon);
110            if spaced {
111                tokens.push(PtxToken::Newline);
112            }
113        }
114    }
115
116    impl PtxUnparser for CallUni3 {
117        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
118            self.unparse_tokens_mode(tokens, false);
119        }
120        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
121            push_opcode(tokens, "call");
122            if self.uni {
123                push_directive(tokens, "uni");
124            }
125            if spaced {
126                tokens.push(PtxToken::Space);
127            }
128            tokens.push(PtxToken::LParen);
129            self.ret_param.unparse_tokens_mode(tokens, spaced);
130            tokens.push(PtxToken::RParen);
131            tokens.push(PtxToken::Comma);
132            if spaced {
133                tokens.push(PtxToken::Space);
134            }
135            self.fptr.unparse_tokens_mode(tokens, spaced);
136            tokens.push(PtxToken::Comma);
137            if spaced {
138                tokens.push(PtxToken::Space);
139            }
140            tokens.push(PtxToken::LParen);
141            for (idx, operand) in self.param_list.iter().enumerate() {
142                if idx > 0 {
143                    tokens.push(PtxToken::Comma);
144                }
145                operand.unparse_tokens_mode(tokens, spaced);
146            }
147            tokens.push(PtxToken::RParen);
148            tokens.push(PtxToken::Comma);
149            if spaced {
150                tokens.push(PtxToken::Space);
151            }
152            self.flist.unparse_tokens_mode(tokens, spaced);
153            tokens.push(PtxToken::Semicolon);
154            if spaced {
155                tokens.push(PtxToken::Newline);
156            }
157        }
158    }
159
160    impl PtxUnparser for CallUni4 {
161        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
162            self.unparse_tokens_mode(tokens, false);
163        }
164        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
165            push_opcode(tokens, "call");
166            if self.uni {
167                push_directive(tokens, "uni");
168            }
169            if spaced {
170                tokens.push(PtxToken::Space);
171            }
172            self.fptr.unparse_tokens_mode(tokens, spaced);
173            tokens.push(PtxToken::Comma);
174            if spaced {
175                tokens.push(PtxToken::Space);
176            }
177            tokens.push(PtxToken::LParen);
178            for (idx, operand) in self.param_list.iter().enumerate() {
179                if idx > 0 {
180                    tokens.push(PtxToken::Comma);
181                }
182                operand.unparse_tokens_mode(tokens, spaced);
183            }
184            tokens.push(PtxToken::RParen);
185            tokens.push(PtxToken::Comma);
186            if spaced {
187                tokens.push(PtxToken::Space);
188            }
189            self.flist.unparse_tokens_mode(tokens, spaced);
190            tokens.push(PtxToken::Semicolon);
191            if spaced {
192                tokens.push(PtxToken::Newline);
193            }
194        }
195    }
196
197    impl PtxUnparser for CallUni5 {
198        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
199            self.unparse_tokens_mode(tokens, false);
200        }
201        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
202            push_opcode(tokens, "call");
203            if self.uni {
204                push_directive(tokens, "uni");
205            }
206            if spaced {
207                tokens.push(PtxToken::Space);
208            }
209            self.fptr.unparse_tokens_mode(tokens, spaced);
210            tokens.push(PtxToken::Comma);
211            if spaced {
212                tokens.push(PtxToken::Space);
213            }
214            self.flist.unparse_tokens_mode(tokens, spaced);
215            tokens.push(PtxToken::Semicolon);
216            if spaced {
217                tokens.push(PtxToken::Newline);
218            }
219        }
220    }
221
222    impl PtxUnparser for CallUni6 {
223        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
224            self.unparse_tokens_mode(tokens, false);
225        }
226        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
227            push_opcode(tokens, "call");
228            if self.uni {
229                push_directive(tokens, "uni");
230            }
231            if spaced {
232                tokens.push(PtxToken::Space);
233            }
234            tokens.push(PtxToken::LParen);
235            self.ret_param.unparse_tokens_mode(tokens, spaced);
236            tokens.push(PtxToken::RParen);
237            tokens.push(PtxToken::Comma);
238            if spaced {
239                tokens.push(PtxToken::Space);
240            }
241            self.fptr.unparse_tokens_mode(tokens, spaced);
242            tokens.push(PtxToken::Comma);
243            if spaced {
244                tokens.push(PtxToken::Space);
245            }
246            tokens.push(PtxToken::LParen);
247            for (idx, operand) in self.param_list.iter().enumerate() {
248                if idx > 0 {
249                    tokens.push(PtxToken::Comma);
250                }
251                operand.unparse_tokens_mode(tokens, spaced);
252            }
253            tokens.push(PtxToken::RParen);
254            tokens.push(PtxToken::Comma);
255            if spaced {
256                tokens.push(PtxToken::Space);
257            }
258            self.fproto.unparse_tokens_mode(tokens, spaced);
259            tokens.push(PtxToken::Semicolon);
260            if spaced {
261                tokens.push(PtxToken::Newline);
262            }
263        }
264    }
265
266    impl PtxUnparser for CallUni7 {
267        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
268            self.unparse_tokens_mode(tokens, false);
269        }
270        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
271            push_opcode(tokens, "call");
272            if self.uni {
273                push_directive(tokens, "uni");
274            }
275            if spaced {
276                tokens.push(PtxToken::Space);
277            }
278            self.fptr.unparse_tokens_mode(tokens, spaced);
279            tokens.push(PtxToken::Comma);
280            if spaced {
281                tokens.push(PtxToken::Space);
282            }
283            tokens.push(PtxToken::LParen);
284            for (idx, operand) in self.param_list.iter().enumerate() {
285                if idx > 0 {
286                    tokens.push(PtxToken::Comma);
287                }
288                operand.unparse_tokens_mode(tokens, spaced);
289            }
290            tokens.push(PtxToken::RParen);
291            tokens.push(PtxToken::Comma);
292            if spaced {
293                tokens.push(PtxToken::Space);
294            }
295            self.fproto.unparse_tokens_mode(tokens, spaced);
296            tokens.push(PtxToken::Semicolon);
297            if spaced {
298                tokens.push(PtxToken::Newline);
299            }
300        }
301    }
302
303    impl PtxUnparser for CallUni8 {
304        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
305            self.unparse_tokens_mode(tokens, false);
306        }
307        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
308            push_opcode(tokens, "call");
309            if self.uni {
310                push_directive(tokens, "uni");
311            }
312            if spaced {
313                tokens.push(PtxToken::Space);
314            }
315            self.fptr.unparse_tokens_mode(tokens, spaced);
316            tokens.push(PtxToken::Comma);
317            if spaced {
318                tokens.push(PtxToken::Space);
319            }
320            self.fproto.unparse_tokens_mode(tokens, spaced);
321            tokens.push(PtxToken::Semicolon);
322            if spaced {
323                tokens.push(PtxToken::Newline);
324            }
325        }
326    }
327}