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            push_opcode(tokens, "call");
28            if self.uni {
29                push_directive(tokens, "uni");
30            }
31            tokens.push(PtxToken::LParen);
32            self.ret_param.unparse_tokens(tokens);
33            tokens.push(PtxToken::RParen);
34            tokens.push(PtxToken::Comma);
35            self.func.unparse_tokens(tokens);
36            tokens.push(PtxToken::Comma);
37            tokens.push(PtxToken::LParen);
38            for (idx, operand) in self.param_list.iter().enumerate() {
39                if idx > 0 {
40                    tokens.push(PtxToken::Comma);
41                }
42                operand.unparse_tokens(tokens);
43            }
44            tokens.push(PtxToken::RParen);
45            tokens.push(PtxToken::Semicolon);
46        }
47    }
48
49    impl PtxUnparser for CallUni1 {
50        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
51            push_opcode(tokens, "call");
52            if self.uni {
53                push_directive(tokens, "uni");
54            }
55            self.func.unparse_tokens(tokens);
56            tokens.push(PtxToken::Comma);
57            tokens.push(PtxToken::LParen);
58            for (idx, operand) in self.param_list.iter().enumerate() {
59                if idx > 0 {
60                    tokens.push(PtxToken::Comma);
61                }
62                operand.unparse_tokens(tokens);
63            }
64            tokens.push(PtxToken::RParen);
65            tokens.push(PtxToken::Semicolon);
66        }
67    }
68
69    impl PtxUnparser for CallUni2 {
70        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
71            push_opcode(tokens, "call");
72            if self.uni {
73                push_directive(tokens, "uni");
74            }
75            self.func.unparse_tokens(tokens);
76            tokens.push(PtxToken::Semicolon);
77        }
78    }
79
80    impl PtxUnparser for CallUni3 {
81        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
82            push_opcode(tokens, "call");
83            if self.uni {
84                push_directive(tokens, "uni");
85            }
86            tokens.push(PtxToken::LParen);
87            self.ret_param.unparse_tokens(tokens);
88            tokens.push(PtxToken::RParen);
89            tokens.push(PtxToken::Comma);
90            self.fptr.unparse_tokens(tokens);
91            tokens.push(PtxToken::Comma);
92            tokens.push(PtxToken::LParen);
93            for (idx, operand) in self.param_list.iter().enumerate() {
94                if idx > 0 {
95                    tokens.push(PtxToken::Comma);
96                }
97                operand.unparse_tokens(tokens);
98            }
99            tokens.push(PtxToken::RParen);
100            tokens.push(PtxToken::Comma);
101            self.flist.unparse_tokens(tokens);
102            tokens.push(PtxToken::Semicolon);
103        }
104    }
105
106    impl PtxUnparser for CallUni4 {
107        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
108            push_opcode(tokens, "call");
109            if self.uni {
110                push_directive(tokens, "uni");
111            }
112            self.fptr.unparse_tokens(tokens);
113            tokens.push(PtxToken::Comma);
114            tokens.push(PtxToken::LParen);
115            for (idx, operand) in self.param_list.iter().enumerate() {
116                if idx > 0 {
117                    tokens.push(PtxToken::Comma);
118                }
119                operand.unparse_tokens(tokens);
120            }
121            tokens.push(PtxToken::RParen);
122            tokens.push(PtxToken::Comma);
123            self.flist.unparse_tokens(tokens);
124            tokens.push(PtxToken::Semicolon);
125        }
126    }
127
128    impl PtxUnparser for CallUni5 {
129        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
130            push_opcode(tokens, "call");
131            if self.uni {
132                push_directive(tokens, "uni");
133            }
134            self.fptr.unparse_tokens(tokens);
135            tokens.push(PtxToken::Comma);
136            self.flist.unparse_tokens(tokens);
137            tokens.push(PtxToken::Semicolon);
138        }
139    }
140
141    impl PtxUnparser for CallUni6 {
142        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
143            push_opcode(tokens, "call");
144            if self.uni {
145                push_directive(tokens, "uni");
146            }
147            tokens.push(PtxToken::LParen);
148            self.ret_param.unparse_tokens(tokens);
149            tokens.push(PtxToken::RParen);
150            tokens.push(PtxToken::Comma);
151            self.fptr.unparse_tokens(tokens);
152            tokens.push(PtxToken::Comma);
153            tokens.push(PtxToken::LParen);
154            for (idx, operand) in self.param_list.iter().enumerate() {
155                if idx > 0 {
156                    tokens.push(PtxToken::Comma);
157                }
158                operand.unparse_tokens(tokens);
159            }
160            tokens.push(PtxToken::RParen);
161            tokens.push(PtxToken::Comma);
162            self.fproto.unparse_tokens(tokens);
163            tokens.push(PtxToken::Semicolon);
164        }
165    }
166
167    impl PtxUnparser for CallUni7 {
168        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
169            push_opcode(tokens, "call");
170            if self.uni {
171                push_directive(tokens, "uni");
172            }
173            self.fptr.unparse_tokens(tokens);
174            tokens.push(PtxToken::Comma);
175            tokens.push(PtxToken::LParen);
176            for (idx, operand) in self.param_list.iter().enumerate() {
177                if idx > 0 {
178                    tokens.push(PtxToken::Comma);
179                }
180                operand.unparse_tokens(tokens);
181            }
182            tokens.push(PtxToken::RParen);
183            tokens.push(PtxToken::Comma);
184            self.fproto.unparse_tokens(tokens);
185            tokens.push(PtxToken::Semicolon);
186        }
187    }
188
189    impl PtxUnparser for CallUni8 {
190        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
191            push_opcode(tokens, "call");
192            if self.uni {
193                push_directive(tokens, "uni");
194            }
195            self.fptr.unparse_tokens(tokens);
196            tokens.push(PtxToken::Comma);
197            self.fproto.unparse_tokens(tokens);
198            tokens.push(PtxToken::Semicolon);
199        }
200    }
201}