ptx_parser/unparser/instruction/
mov.rs

1//! Original PTX specification:
2//!
3//! mov.type  d, a;
4//! // mov.type  d, sreg;
5//! // mov.type  d, avar;       // get address of variable
6//! // mov.type  d, avar+imm;   // get address of variable with offset
7//! mov.u32   d, fname;      // get address of device function
8//! mov.u64   d, fname;      // get address of device function
9//! mov.u32   d, kernel;     // get address of entry function
10//! mov.u64   d, kernel;     // get address of entry function
11//! .type = { .pred,
12//! .b16, .b32, .b64,
13//! .u16, .u32, .u64,
14//! .s16, .s32, .s64,
15//! .f32, .f64 };
16//! ----------------------------------------------
17//! mov.type  d, a;
18//! .type = { .b16, .b32, .b64, .b128 };
19
20#![allow(unused)]
21
22use crate::lexer::PtxToken;
23use crate::unparser::{PtxUnparser, common::*};
24
25pub mod section_0 {
26    use super::*;
27    use crate::r#type::instruction::mov::section_0::*;
28
29    impl PtxUnparser for MovType {
30        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
31            push_opcode(tokens, "mov");
32            match &self.type_ {
33                Type::Pred => {
34                    push_directive(tokens, "pred");
35                }
36                Type::B16 => {
37                    push_directive(tokens, "b16");
38                }
39                Type::B32 => {
40                    push_directive(tokens, "b32");
41                }
42                Type::B64 => {
43                    push_directive(tokens, "b64");
44                }
45                Type::U16 => {
46                    push_directive(tokens, "u16");
47                }
48                Type::U32 => {
49                    push_directive(tokens, "u32");
50                }
51                Type::U64 => {
52                    push_directive(tokens, "u64");
53                }
54                Type::S16 => {
55                    push_directive(tokens, "s16");
56                }
57                Type::S32 => {
58                    push_directive(tokens, "s32");
59                }
60                Type::S64 => {
61                    push_directive(tokens, "s64");
62                }
63                Type::F32 => {
64                    push_directive(tokens, "f32");
65                }
66                Type::F64 => {
67                    push_directive(tokens, "f64");
68                }
69            }
70            self.d.unparse_tokens(tokens);
71            tokens.push(PtxToken::Comma);
72            self.a.unparse_tokens(tokens);
73            tokens.push(PtxToken::Semicolon);
74        }
75    }
76
77    impl PtxUnparser for MovU32 {
78        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
79            push_opcode(tokens, "mov");
80            push_directive(tokens, "u32");
81            self.d.unparse_tokens(tokens);
82            tokens.push(PtxToken::Comma);
83            self.fname.unparse_tokens(tokens);
84            tokens.push(PtxToken::Semicolon);
85        }
86    }
87
88    impl PtxUnparser for MovU64 {
89        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
90            push_opcode(tokens, "mov");
91            push_directive(tokens, "u64");
92            self.d.unparse_tokens(tokens);
93            tokens.push(PtxToken::Comma);
94            self.fname.unparse_tokens(tokens);
95            tokens.push(PtxToken::Semicolon);
96        }
97    }
98
99    impl PtxUnparser for MovU321 {
100        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
101            push_opcode(tokens, "mov");
102            push_directive(tokens, "u32");
103            self.d.unparse_tokens(tokens);
104            tokens.push(PtxToken::Comma);
105            self.kernel.unparse_tokens(tokens);
106            tokens.push(PtxToken::Semicolon);
107        }
108    }
109
110    impl PtxUnparser for MovU641 {
111        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
112            push_opcode(tokens, "mov");
113            push_directive(tokens, "u64");
114            self.d.unparse_tokens(tokens);
115            tokens.push(PtxToken::Comma);
116            self.kernel.unparse_tokens(tokens);
117            tokens.push(PtxToken::Semicolon);
118        }
119    }
120}
121
122pub mod section_1 {
123    use super::*;
124    use crate::r#type::instruction::mov::section_1::*;
125
126    impl PtxUnparser for MovType1 {
127        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
128            push_opcode(tokens, "mov");
129            match &self.type_ {
130                Type::B128 => {
131                    push_directive(tokens, "b128");
132                }
133                Type::B16 => {
134                    push_directive(tokens, "b16");
135                }
136                Type::B32 => {
137                    push_directive(tokens, "b32");
138                }
139                Type::B64 => {
140                    push_directive(tokens, "b64");
141                }
142            }
143            self.d.unparse_tokens(tokens);
144            tokens.push(PtxToken::Comma);
145            self.a.unparse_tokens(tokens);
146            tokens.push(PtxToken::Semicolon);
147        }
148    }
149}