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            push_opcode(tokens, "tld4");
21            match &self.comp {
22                Comp::R => {
23                    push_directive(tokens, "r");
24                }
25                Comp::G => {
26                    push_directive(tokens, "g");
27                }
28                Comp::B => {
29                    push_directive(tokens, "b");
30                }
31                Comp::A => {
32                    push_directive(tokens, "a");
33                }
34            }
35            push_directive(tokens, "2d");
36            push_directive(tokens, "v4");
37            match &self.dtype {
38                Dtype::U32 => {
39                    push_directive(tokens, "u32");
40                }
41                Dtype::S32 => {
42                    push_directive(tokens, "s32");
43                }
44                Dtype::F32 => {
45                    push_directive(tokens, "f32");
46                }
47            }
48            push_directive(tokens, "f32");
49            self.d.unparse_tokens(tokens);
50            if let Some(p_0) = self.p.as_ref() {
51                tokens.push(PtxToken::Pipe);
52                p_0.unparse_tokens(tokens);
53            }
54            tokens.push(PtxToken::Comma);
55            self.a.unparse_tokens(tokens);
56            if self.e.is_some() {
57                tokens.push(PtxToken::Comma);
58            }
59            if let Some(opt_1) = self.e.as_ref() {
60                opt_1.unparse_tokens(tokens);
61            }
62            if self.f.is_some() {
63                tokens.push(PtxToken::Comma);
64            }
65            if let Some(opt_2) = self.f.as_ref() {
66                opt_2.unparse_tokens(tokens);
67            }
68            tokens.push(PtxToken::Semicolon);
69        }
70    }
71
72    impl PtxUnparser for Tld4CompGeomV4DtypeF32 {
73        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
74            push_opcode(tokens, "tld4");
75            match &self.comp {
76                Comp::R => {
77                    push_directive(tokens, "r");
78                }
79                Comp::G => {
80                    push_directive(tokens, "g");
81                }
82                Comp::B => {
83                    push_directive(tokens, "b");
84                }
85                Comp::A => {
86                    push_directive(tokens, "a");
87                }
88            }
89            match &self.geom {
90                Geom::Acube => {
91                    push_directive(tokens, "acube");
92                }
93                Geom::Cube => {
94                    push_directive(tokens, "cube");
95                }
96                Geom::A2d => {
97                    push_directive(tokens, "a2d");
98                }
99                Geom::_2d => {
100                    push_directive(tokens, "2d");
101                }
102            }
103            push_directive(tokens, "v4");
104            match &self.dtype {
105                Dtype::U32 => {
106                    push_directive(tokens, "u32");
107                }
108                Dtype::S32 => {
109                    push_directive(tokens, "s32");
110                }
111                Dtype::F32 => {
112                    push_directive(tokens, "f32");
113                }
114            }
115            push_directive(tokens, "f32");
116            self.d.unparse_tokens(tokens);
117            if let Some(p_3) = self.p.as_ref() {
118                tokens.push(PtxToken::Pipe);
119                p_3.unparse_tokens(tokens);
120            }
121            tokens.push(PtxToken::Comma);
122            self.a.unparse_tokens(tokens);
123            if self.e.is_some() {
124                tokens.push(PtxToken::Comma);
125            }
126            if let Some(opt_4) = self.e.as_ref() {
127                opt_4.unparse_tokens(tokens);
128            }
129            if self.f.is_some() {
130                tokens.push(PtxToken::Comma);
131            }
132            if let Some(opt_5) = self.f.as_ref() {
133                opt_5.unparse_tokens(tokens);
134            }
135            tokens.push(PtxToken::Semicolon);
136        }
137    }
138}