Skip to main content

ptx_parser/unparser/instruction/
ldu.rs

1//! Original PTX specification:
2//!
3//! ldu{.ss}.type      d, [a];       // load from address
4//! ldu{.ss}.vec.type  d, [a];       // vec load from address
5//! .ss   = { .global };             // state space
6//! .vec  = { .v2, .v4 };
7//! .type = { .b8, .b16, .b32, .b64, .b128,
8//! .u8, .u16, .u32, .u64,
9//! .s8, .s16, .s32, .s64,
10//! .f32, .f64 };
11
12#![allow(unused)]
13
14use crate::lexer::PtxToken;
15use crate::unparser::{PtxUnparser, common::*};
16
17pub mod section_0 {
18    use super::*;
19    use crate::r#type::instruction::ldu::section_0::*;
20
21    impl PtxUnparser for LduSsType {
22        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
23            self.unparse_tokens_mode(tokens, false);
24        }
25        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
26            push_opcode(tokens, "ldu");
27            if let Some(ss_0) = self.ss.as_ref() {
28                match ss_0 {
29                    Ss::Global => {
30                        push_directive(tokens, "global");
31                    }
32                }
33            }
34            match &self.type_ {
35                Type::B128 => {
36                    push_directive(tokens, "b128");
37                }
38                Type::B16 => {
39                    push_directive(tokens, "b16");
40                }
41                Type::B32 => {
42                    push_directive(tokens, "b32");
43                }
44                Type::B64 => {
45                    push_directive(tokens, "b64");
46                }
47                Type::U16 => {
48                    push_directive(tokens, "u16");
49                }
50                Type::U32 => {
51                    push_directive(tokens, "u32");
52                }
53                Type::U64 => {
54                    push_directive(tokens, "u64");
55                }
56                Type::S16 => {
57                    push_directive(tokens, "s16");
58                }
59                Type::S32 => {
60                    push_directive(tokens, "s32");
61                }
62                Type::S64 => {
63                    push_directive(tokens, "s64");
64                }
65                Type::F32 => {
66                    push_directive(tokens, "f32");
67                }
68                Type::F64 => {
69                    push_directive(tokens, "f64");
70                }
71                Type::B8 => {
72                    push_directive(tokens, "b8");
73                }
74                Type::U8 => {
75                    push_directive(tokens, "u8");
76                }
77                Type::S8 => {
78                    push_directive(tokens, "s8");
79                }
80            }
81            if spaced {
82                tokens.push(PtxToken::Space);
83            }
84            self.d.unparse_tokens_mode(tokens, spaced);
85            tokens.push(PtxToken::Comma);
86            if spaced {
87                tokens.push(PtxToken::Space);
88            }
89            self.a.unparse_tokens_mode(tokens, spaced);
90            tokens.push(PtxToken::Semicolon);
91            if spaced {
92                tokens.push(PtxToken::Newline);
93            }
94        }
95    }
96
97    impl PtxUnparser for LduSsVecType {
98        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
99            self.unparse_tokens_mode(tokens, false);
100        }
101        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
102            push_opcode(tokens, "ldu");
103            if let Some(ss_1) = self.ss.as_ref() {
104                match ss_1 {
105                    Ss::Global => {
106                        push_directive(tokens, "global");
107                    }
108                }
109            }
110            match &self.vec {
111                Vec::V2 => {
112                    push_directive(tokens, "v2");
113                }
114                Vec::V4 => {
115                    push_directive(tokens, "v4");
116                }
117            }
118            match &self.type_ {
119                Type::B128 => {
120                    push_directive(tokens, "b128");
121                }
122                Type::B16 => {
123                    push_directive(tokens, "b16");
124                }
125                Type::B32 => {
126                    push_directive(tokens, "b32");
127                }
128                Type::B64 => {
129                    push_directive(tokens, "b64");
130                }
131                Type::U16 => {
132                    push_directive(tokens, "u16");
133                }
134                Type::U32 => {
135                    push_directive(tokens, "u32");
136                }
137                Type::U64 => {
138                    push_directive(tokens, "u64");
139                }
140                Type::S16 => {
141                    push_directive(tokens, "s16");
142                }
143                Type::S32 => {
144                    push_directive(tokens, "s32");
145                }
146                Type::S64 => {
147                    push_directive(tokens, "s64");
148                }
149                Type::F32 => {
150                    push_directive(tokens, "f32");
151                }
152                Type::F64 => {
153                    push_directive(tokens, "f64");
154                }
155                Type::B8 => {
156                    push_directive(tokens, "b8");
157                }
158                Type::U8 => {
159                    push_directive(tokens, "u8");
160                }
161                Type::S8 => {
162                    push_directive(tokens, "s8");
163                }
164            }
165            if spaced {
166                tokens.push(PtxToken::Space);
167            }
168            self.d.unparse_tokens_mode(tokens, spaced);
169            tokens.push(PtxToken::Comma);
170            if spaced {
171                tokens.push(PtxToken::Space);
172            }
173            self.a.unparse_tokens_mode(tokens, spaced);
174            tokens.push(PtxToken::Semicolon);
175            if spaced {
176                tokens.push(PtxToken::Newline);
177            }
178        }
179    }
180}