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