Skip to main content

ptx_parser/unparser/instruction/
tld4.rs

1//! Original PTX specification:
2//!
3//! tld4.comp.2d.v4.dtype.f32    d{|p}, [a, c] {, e} {, f};
4//! tld4.comp.geom.v4.dtype.f32  d{|p}, [a, b, c] {, e} {, f};  // explicit sampler
5//! .comp  = { .r, .g, .b, .a };
6//! .geom  = { .2d, .a2d, .cube, .acube };
7//! .dtype = { .u32, .s32, .f32 };
8
9#![allow(unused)]
10
11use crate::lexer::PtxToken;
12use crate::unparser::{PtxUnparser, common::*};
13
14pub mod section_0 {
15    use super::*;
16    use crate::r#type::instruction::tld4::section_0::*;
17
18    impl PtxUnparser for Tld4Comp2dV4DtypeF32 {
19        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
20            self.unparse_tokens_mode(tokens, false);
21        }
22        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
23            push_opcode(tokens, "tld4");
24            match &self.comp {
25                Comp::R => {
26                    push_directive(tokens, "r");
27                }
28                Comp::G => {
29                    push_directive(tokens, "g");
30                }
31                Comp::B => {
32                    push_directive(tokens, "b");
33                }
34                Comp::A => {
35                    push_directive(tokens, "a");
36                }
37            }
38            push_directive(tokens, "2d");
39            push_directive(tokens, "v4");
40            match &self.dtype {
41                Dtype::U32 => {
42                    push_directive(tokens, "u32");
43                }
44                Dtype::S32 => {
45                    push_directive(tokens, "s32");
46                }
47                Dtype::F32 => {
48                    push_directive(tokens, "f32");
49                }
50            }
51            push_directive(tokens, "f32");
52            if spaced {
53                tokens.push(PtxToken::Space);
54            }
55            self.d.unparse_tokens_mode(tokens, spaced);
56            if let Some(p_0) = self.p.as_ref() {
57                tokens.push(PtxToken::Pipe);
58                p_0.unparse_tokens_mode(tokens, spaced);
59            }
60            tokens.push(PtxToken::Comma);
61            if spaced {
62                tokens.push(PtxToken::Space);
63            }
64            self.a.unparse_tokens_mode(tokens, spaced);
65            if self.e.is_some() {
66                tokens.push(PtxToken::Comma);
67            }
68            if let Some(opt_1) = self.e.as_ref() {
69                if spaced {
70                    tokens.push(PtxToken::Space);
71                }
72                opt_1.unparse_tokens_mode(tokens, spaced);
73            }
74            if self.f.is_some() {
75                tokens.push(PtxToken::Comma);
76            }
77            if let Some(opt_2) = self.f.as_ref() {
78                if spaced {
79                    tokens.push(PtxToken::Space);
80                }
81                opt_2.unparse_tokens_mode(tokens, spaced);
82            }
83            tokens.push(PtxToken::Semicolon);
84            if spaced {
85                tokens.push(PtxToken::Newline);
86            }
87        }
88    }
89
90    impl PtxUnparser for Tld4CompGeomV4DtypeF32 {
91        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
92            self.unparse_tokens_mode(tokens, false);
93        }
94        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
95            push_opcode(tokens, "tld4");
96            match &self.comp {
97                Comp::R => {
98                    push_directive(tokens, "r");
99                }
100                Comp::G => {
101                    push_directive(tokens, "g");
102                }
103                Comp::B => {
104                    push_directive(tokens, "b");
105                }
106                Comp::A => {
107                    push_directive(tokens, "a");
108                }
109            }
110            match &self.geom {
111                Geom::Acube => {
112                    push_directive(tokens, "acube");
113                }
114                Geom::Cube => {
115                    push_directive(tokens, "cube");
116                }
117                Geom::A2d => {
118                    push_directive(tokens, "a2d");
119                }
120                Geom::_2d => {
121                    push_directive(tokens, "2d");
122                }
123            }
124            push_directive(tokens, "v4");
125            match &self.dtype {
126                Dtype::U32 => {
127                    push_directive(tokens, "u32");
128                }
129                Dtype::S32 => {
130                    push_directive(tokens, "s32");
131                }
132                Dtype::F32 => {
133                    push_directive(tokens, "f32");
134                }
135            }
136            push_directive(tokens, "f32");
137            if spaced {
138                tokens.push(PtxToken::Space);
139            }
140            self.d.unparse_tokens_mode(tokens, spaced);
141            if let Some(p_3) = self.p.as_ref() {
142                tokens.push(PtxToken::Pipe);
143                p_3.unparse_tokens_mode(tokens, spaced);
144            }
145            tokens.push(PtxToken::Comma);
146            if spaced {
147                tokens.push(PtxToken::Space);
148            }
149            self.a.unparse_tokens_mode(tokens, spaced);
150            if self.e.is_some() {
151                tokens.push(PtxToken::Comma);
152            }
153            if let Some(opt_4) = self.e.as_ref() {
154                if spaced {
155                    tokens.push(PtxToken::Space);
156                }
157                opt_4.unparse_tokens_mode(tokens, spaced);
158            }
159            if self.f.is_some() {
160                tokens.push(PtxToken::Comma);
161            }
162            if let Some(opt_5) = self.f.as_ref() {
163                if spaced {
164                    tokens.push(PtxToken::Space);
165                }
166                opt_5.unparse_tokens_mode(tokens, spaced);
167            }
168            tokens.push(PtxToken::Semicolon);
169            if spaced {
170                tokens.push(PtxToken::Newline);
171            }
172        }
173    }
174}