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            push_opcode(tokens, "ldu");
24            if let Some(ss_0) = self.ss.as_ref() {
25                match ss_0 {
26                    Ss::Global => {
27                        push_directive(tokens, "global");
28                    }
29                }
30            }
31            match &self.type_ {
32                Type::B128 => {
33                    push_directive(tokens, "b128");
34                }
35                Type::B16 => {
36                    push_directive(tokens, "b16");
37                }
38                Type::B32 => {
39                    push_directive(tokens, "b32");
40                }
41                Type::B64 => {
42                    push_directive(tokens, "b64");
43                }
44                Type::U16 => {
45                    push_directive(tokens, "u16");
46                }
47                Type::U32 => {
48                    push_directive(tokens, "u32");
49                }
50                Type::U64 => {
51                    push_directive(tokens, "u64");
52                }
53                Type::S16 => {
54                    push_directive(tokens, "s16");
55                }
56                Type::S32 => {
57                    push_directive(tokens, "s32");
58                }
59                Type::S64 => {
60                    push_directive(tokens, "s64");
61                }
62                Type::F32 => {
63                    push_directive(tokens, "f32");
64                }
65                Type::F64 => {
66                    push_directive(tokens, "f64");
67                }
68                Type::B8 => {
69                    push_directive(tokens, "b8");
70                }
71                Type::U8 => {
72                    push_directive(tokens, "u8");
73                }
74                Type::S8 => {
75                    push_directive(tokens, "s8");
76                }
77            }
78            self.d.unparse_tokens(tokens);
79            tokens.push(PtxToken::Comma);
80            self.a.unparse_tokens(tokens);
81            tokens.push(PtxToken::Semicolon);
82        }
83    }
84
85    impl PtxUnparser for LduSsVecType {
86        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
87            push_opcode(tokens, "ldu");
88            if let Some(ss_1) = self.ss.as_ref() {
89                match ss_1 {
90                    Ss::Global => {
91                        push_directive(tokens, "global");
92                    }
93                }
94            }
95            match &self.vec {
96                Vec::V2 => {
97                    push_directive(tokens, "v2");
98                }
99                Vec::V4 => {
100                    push_directive(tokens, "v4");
101                }
102            }
103            match &self.type_ {
104                Type::B128 => {
105                    push_directive(tokens, "b128");
106                }
107                Type::B16 => {
108                    push_directive(tokens, "b16");
109                }
110                Type::B32 => {
111                    push_directive(tokens, "b32");
112                }
113                Type::B64 => {
114                    push_directive(tokens, "b64");
115                }
116                Type::U16 => {
117                    push_directive(tokens, "u16");
118                }
119                Type::U32 => {
120                    push_directive(tokens, "u32");
121                }
122                Type::U64 => {
123                    push_directive(tokens, "u64");
124                }
125                Type::S16 => {
126                    push_directive(tokens, "s16");
127                }
128                Type::S32 => {
129                    push_directive(tokens, "s32");
130                }
131                Type::S64 => {
132                    push_directive(tokens, "s64");
133                }
134                Type::F32 => {
135                    push_directive(tokens, "f32");
136                }
137                Type::F64 => {
138                    push_directive(tokens, "f64");
139                }
140                Type::B8 => {
141                    push_directive(tokens, "b8");
142                }
143                Type::U8 => {
144                    push_directive(tokens, "u8");
145                }
146                Type::S8 => {
147                    push_directive(tokens, "s8");
148                }
149            }
150            self.d.unparse_tokens(tokens);
151            tokens.push(PtxToken::Comma);
152            self.a.unparse_tokens(tokens);
153            tokens.push(PtxToken::Semicolon);
154        }
155    }
156}