ptx_parser/unparser/instruction/
tensormap_replace.rs

1//! Original PTX specification:
2//!
3//! tensormap.replace.mode.field1{.ss}.b1024.type  [addr], new_val;
4//! tensormap.replace.mode.field2{.ss}.b1024.type  [addr], ord, new_val;
5//! tensormap.replace.mode.field3{.ss}.b1024.type  [addr], new_val;
6//! .mode    = { .tile };
7//! .field1  = { .global_address, .rank };
8//! .field2  = { .box_dim, .global_dim, .global_stride, .element_stride  };
9//! .field3  = { .elemtype,  .interleave_layout, .swizzle_mode, .swizzle_atomicity, .fill_mode };
10//! .ss      = { .global, .shared::cta };
11//! .type    = { .b32, .b64 };
12
13#![allow(unused)]
14
15use crate::lexer::PtxToken;
16use crate::unparser::{PtxUnparser, common::*};
17
18pub mod section_0 {
19    use super::*;
20    use crate::r#type::instruction::tensormap_replace::section_0::*;
21
22    impl PtxUnparser for TensormapReplaceModeField1SsB1024Type {
23        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
24            push_opcode(tokens, "tensormap");
25            push_directive(tokens, "replace");
26            match &self.mode {
27                Mode::Tile => {
28                    push_directive(tokens, "tile");
29                }
30            }
31            match &self.field1 {
32                Field1::GlobalAddress => {
33                    push_directive(tokens, "global_address");
34                }
35                Field1::Rank => {
36                    push_directive(tokens, "rank");
37                }
38            }
39            if let Some(ss_0) = self.ss.as_ref() {
40                match ss_0 {
41                    Ss::SharedCta => {
42                        push_directive(tokens, "shared::cta");
43                    }
44                    Ss::Global => {
45                        push_directive(tokens, "global");
46                    }
47                }
48            }
49            push_directive(tokens, "b1024");
50            match &self.type_ {
51                Type::B32 => {
52                    push_directive(tokens, "b32");
53                }
54                Type::B64 => {
55                    push_directive(tokens, "b64");
56                }
57            }
58            self.addr.unparse_tokens(tokens);
59            tokens.push(PtxToken::Comma);
60            self.new_val.unparse_tokens(tokens);
61            tokens.push(PtxToken::Semicolon);
62        }
63    }
64
65    impl PtxUnparser for TensormapReplaceModeField2SsB1024Type {
66        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
67            push_opcode(tokens, "tensormap");
68            push_directive(tokens, "replace");
69            match &self.mode {
70                Mode::Tile => {
71                    push_directive(tokens, "tile");
72                }
73            }
74            match &self.field2 {
75                Field2::ElementStride => {
76                    push_directive(tokens, "element_stride");
77                }
78                Field2::GlobalStride => {
79                    push_directive(tokens, "global_stride");
80                }
81                Field2::GlobalDim => {
82                    push_directive(tokens, "global_dim");
83                }
84                Field2::BoxDim => {
85                    push_directive(tokens, "box_dim");
86                }
87            }
88            if let Some(ss_1) = self.ss.as_ref() {
89                match ss_1 {
90                    Ss::SharedCta => {
91                        push_directive(tokens, "shared::cta");
92                    }
93                    Ss::Global => {
94                        push_directive(tokens, "global");
95                    }
96                }
97            }
98            push_directive(tokens, "b1024");
99            match &self.type_ {
100                Type::B32 => {
101                    push_directive(tokens, "b32");
102                }
103                Type::B64 => {
104                    push_directive(tokens, "b64");
105                }
106            }
107            self.addr.unparse_tokens(tokens);
108            tokens.push(PtxToken::Comma);
109            self.ord.unparse_tokens(tokens);
110            tokens.push(PtxToken::Comma);
111            self.new_val.unparse_tokens(tokens);
112            tokens.push(PtxToken::Semicolon);
113        }
114    }
115
116    impl PtxUnparser for TensormapReplaceModeField3SsB1024Type {
117        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
118            push_opcode(tokens, "tensormap");
119            push_directive(tokens, "replace");
120            match &self.mode {
121                Mode::Tile => {
122                    push_directive(tokens, "tile");
123                }
124            }
125            match &self.field3 {
126                Field3::InterleaveLayout => {
127                    push_directive(tokens, "interleave_layout");
128                }
129                Field3::SwizzleAtomicity => {
130                    push_directive(tokens, "swizzle_atomicity");
131                }
132                Field3::SwizzleMode => {
133                    push_directive(tokens, "swizzle_mode");
134                }
135                Field3::FillMode => {
136                    push_directive(tokens, "fill_mode");
137                }
138                Field3::Elemtype => {
139                    push_directive(tokens, "elemtype");
140                }
141            }
142            if let Some(ss_2) = self.ss.as_ref() {
143                match ss_2 {
144                    Ss::SharedCta => {
145                        push_directive(tokens, "shared::cta");
146                    }
147                    Ss::Global => {
148                        push_directive(tokens, "global");
149                    }
150                }
151            }
152            push_directive(tokens, "b1024");
153            match &self.type_ {
154                Type::B32 => {
155                    push_directive(tokens, "b32");
156                }
157                Type::B64 => {
158                    push_directive(tokens, "b64");
159                }
160            }
161            self.addr.unparse_tokens(tokens);
162            tokens.push(PtxToken::Comma);
163            self.new_val.unparse_tokens(tokens);
164            tokens.push(PtxToken::Semicolon);
165        }
166    }
167}