Skip to main content

ptx_parser/type/instruction/
vop4.rs

1//! Original PTX specification:
2//!
3//! // SIMD instruction with secondary SIMD merge operation
4//! vop4.dtype.atype.btype{.sat}  d{.mask}, a{.asel}, b{.bsel}, c;
5//! // SIMD instruction with secondary accumulate operation
6//! vop4.dtype.atype.btype.add  d{.mask}, a{.asel}, b{.bsel}, c;
7//! vop4  = { vadd4, vsub4, vavrg4, vabsdiff4, vmin4, vmax4 };
8//! .dtype = .atype = .btype = { .u32, .s32 };
9//! .mask  = { .b0,
10//! .b1, .b10,
11//! .b2, .b20, .b21, .b210,
12//! .b3, .b30, .b31, .b310, .b32, .b320, .b321, .b3210 };
13//! // defaults to .b3210
14//! .asel = .bsel = { .b.n.n.n.n };
15//! .n = { 0, 1, 2, 3, 4, 5, 6, 7};
16//! // .asel defaults to .b3210
17//! // .bsel defaults to .b7654
18
19#![allow(unused)]
20use crate::r#type::common::*;
21
22pub mod section_0 {
23    use crate::Spanned;
24    use crate::parser::Span;
25    use crate::r#type::common::*;
26
27    use serde::Serialize;
28
29    #[derive(Debug, Clone, PartialEq, Serialize)]
30    pub enum Dtype {
31        U32, // .u32
32        S32, // .s32
33    }
34
35    #[derive(Debug, Clone, PartialEq, Serialize)]
36    pub enum Atype {
37        U32, // .u32
38        S32, // .s32
39    }
40
41    #[derive(Debug, Clone, PartialEq, Serialize)]
42    pub enum Btype {
43        U32, // .u32
44        S32, // .s32
45    }
46
47    #[derive(Debug, Clone, PartialEq, Serialize)]
48    pub enum Mask {
49        B3210, // .b3210
50        B210,  // .b210
51        B310,  // .b310
52        B320,  // .b320
53        B321,  // .b321
54        B10,   // .b10
55        B20,   // .b20
56        B21,   // .b21
57        B30,   // .b30
58        B31,   // .b31
59        B32,   // .b32
60        B0,    // .b0
61        B1,    // .b1
62        B2,    // .b2
63        B3,    // .b3
64    }
65
66    #[derive(Debug, Clone, PartialEq, Serialize)]
67    pub enum N {
68        _0, // 0
69        _1, // 1
70        _2, // 2
71        _3, // 3
72        _4, // 4
73        _5, // 5
74        _6, // 6
75        _7, // 7
76    }
77
78    #[derive(Debug, Clone, PartialEq, Serialize)]
79    pub enum Asel {
80        BNNNN((), N, N, N, N), // .b.n.n.n.n
81    }
82
83    #[derive(Debug, Clone, PartialEq, Serialize)]
84    pub enum Bsel {
85        BNNNN((), N, N, N, N), // .b.n.n.n.n
86    }
87
88    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
89    pub struct Vadd4DtypeAtypeBtypeSat {
90        pub dtype: Dtype,       // .dtype
91        pub atype: Atype,       // .atype
92        pub btype: Btype,       // .btype
93        pub sat: bool,          // {.sat}
94        pub d: GeneralOperand,  // d
95        pub mask: Option<Mask>, // {.mask}
96        pub a: GeneralOperand,  // a
97        pub asel: Option<Asel>, // {.asel}
98        pub b: GeneralOperand,  // b
99        pub bsel: Option<Bsel>, // {.bsel}
100        pub c: GeneralOperand,  // c
101        pub span: Span,
102    }
103
104    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
105    pub struct Vsub4DtypeAtypeBtypeSat {
106        pub dtype: Dtype,       // .dtype
107        pub atype: Atype,       // .atype
108        pub btype: Btype,       // .btype
109        pub sat: bool,          // {.sat}
110        pub d: GeneralOperand,  // d
111        pub mask: Option<Mask>, // {.mask}
112        pub a: GeneralOperand,  // a
113        pub asel: Option<Asel>, // {.asel}
114        pub b: GeneralOperand,  // b
115        pub bsel: Option<Bsel>, // {.bsel}
116        pub c: GeneralOperand,  // c
117        pub span: Span,
118    }
119
120    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
121    pub struct Vavrg4DtypeAtypeBtypeSat {
122        pub dtype: Dtype,       // .dtype
123        pub atype: Atype,       // .atype
124        pub btype: Btype,       // .btype
125        pub sat: bool,          // {.sat}
126        pub d: GeneralOperand,  // d
127        pub mask: Option<Mask>, // {.mask}
128        pub a: GeneralOperand,  // a
129        pub asel: Option<Asel>, // {.asel}
130        pub b: GeneralOperand,  // b
131        pub bsel: Option<Bsel>, // {.bsel}
132        pub c: GeneralOperand,  // c
133        pub span: Span,
134    }
135
136    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
137    pub struct Vabsdiff4DtypeAtypeBtypeSat {
138        pub dtype: Dtype,       // .dtype
139        pub atype: Atype,       // .atype
140        pub btype: Btype,       // .btype
141        pub sat: bool,          // {.sat}
142        pub d: GeneralOperand,  // d
143        pub mask: Option<Mask>, // {.mask}
144        pub a: GeneralOperand,  // a
145        pub asel: Option<Asel>, // {.asel}
146        pub b: GeneralOperand,  // b
147        pub bsel: Option<Bsel>, // {.bsel}
148        pub c: GeneralOperand,  // c
149        pub span: Span,
150    }
151
152    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
153    pub struct Vmin4DtypeAtypeBtypeSat {
154        pub dtype: Dtype,       // .dtype
155        pub atype: Atype,       // .atype
156        pub btype: Btype,       // .btype
157        pub sat: bool,          // {.sat}
158        pub d: GeneralOperand,  // d
159        pub mask: Option<Mask>, // {.mask}
160        pub a: GeneralOperand,  // a
161        pub asel: Option<Asel>, // {.asel}
162        pub b: GeneralOperand,  // b
163        pub bsel: Option<Bsel>, // {.bsel}
164        pub c: GeneralOperand,  // c
165        pub span: Span,
166    }
167
168    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
169    pub struct Vmax4DtypeAtypeBtypeSat {
170        pub dtype: Dtype,       // .dtype
171        pub atype: Atype,       // .atype
172        pub btype: Btype,       // .btype
173        pub sat: bool,          // {.sat}
174        pub d: GeneralOperand,  // d
175        pub mask: Option<Mask>, // {.mask}
176        pub a: GeneralOperand,  // a
177        pub asel: Option<Asel>, // {.asel}
178        pub b: GeneralOperand,  // b
179        pub bsel: Option<Bsel>, // {.bsel}
180        pub c: GeneralOperand,  // c
181        pub span: Span,
182    }
183
184    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
185    pub struct Vadd4DtypeAtypeBtypeAdd {
186        pub dtype: Dtype,       // .dtype
187        pub atype: Atype,       // .atype
188        pub btype: Btype,       // .btype
189        pub add: (),            // .add
190        pub d: GeneralOperand,  // d
191        pub mask: Option<Mask>, // {.mask}
192        pub a: GeneralOperand,  // a
193        pub asel: Option<Asel>, // {.asel}
194        pub b: GeneralOperand,  // b
195        pub bsel: Option<Bsel>, // {.bsel}
196        pub c: GeneralOperand,  // c
197        pub span: Span,
198    }
199
200    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
201    pub struct Vsub4DtypeAtypeBtypeAdd {
202        pub dtype: Dtype,       // .dtype
203        pub atype: Atype,       // .atype
204        pub btype: Btype,       // .btype
205        pub add: (),            // .add
206        pub d: GeneralOperand,  // d
207        pub mask: Option<Mask>, // {.mask}
208        pub a: GeneralOperand,  // a
209        pub asel: Option<Asel>, // {.asel}
210        pub b: GeneralOperand,  // b
211        pub bsel: Option<Bsel>, // {.bsel}
212        pub c: GeneralOperand,  // c
213        pub span: Span,
214    }
215
216    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
217    pub struct Vavrg4DtypeAtypeBtypeAdd {
218        pub dtype: Dtype,       // .dtype
219        pub atype: Atype,       // .atype
220        pub btype: Btype,       // .btype
221        pub add: (),            // .add
222        pub d: GeneralOperand,  // d
223        pub mask: Option<Mask>, // {.mask}
224        pub a: GeneralOperand,  // a
225        pub asel: Option<Asel>, // {.asel}
226        pub b: GeneralOperand,  // b
227        pub bsel: Option<Bsel>, // {.bsel}
228        pub c: GeneralOperand,  // c
229        pub span: Span,
230    }
231
232    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
233    pub struct Vabsdiff4DtypeAtypeBtypeAdd {
234        pub dtype: Dtype,       // .dtype
235        pub atype: Atype,       // .atype
236        pub btype: Btype,       // .btype
237        pub add: (),            // .add
238        pub d: GeneralOperand,  // d
239        pub mask: Option<Mask>, // {.mask}
240        pub a: GeneralOperand,  // a
241        pub asel: Option<Asel>, // {.asel}
242        pub b: GeneralOperand,  // b
243        pub bsel: Option<Bsel>, // {.bsel}
244        pub c: GeneralOperand,  // c
245        pub span: Span,
246    }
247
248    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
249    pub struct Vmin4DtypeAtypeBtypeAdd {
250        pub dtype: Dtype,       // .dtype
251        pub atype: Atype,       // .atype
252        pub btype: Btype,       // .btype
253        pub add: (),            // .add
254        pub d: GeneralOperand,  // d
255        pub mask: Option<Mask>, // {.mask}
256        pub a: GeneralOperand,  // a
257        pub asel: Option<Asel>, // {.asel}
258        pub b: GeneralOperand,  // b
259        pub bsel: Option<Bsel>, // {.bsel}
260        pub c: GeneralOperand,  // c
261        pub span: Span,
262    }
263
264    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
265    pub struct Vmax4DtypeAtypeBtypeAdd {
266        pub dtype: Dtype,       // .dtype
267        pub atype: Atype,       // .atype
268        pub btype: Btype,       // .btype
269        pub add: (),            // .add
270        pub d: GeneralOperand,  // d
271        pub mask: Option<Mask>, // {.mask}
272        pub a: GeneralOperand,  // a
273        pub asel: Option<Asel>, // {.asel}
274        pub b: GeneralOperand,  // b
275        pub bsel: Option<Bsel>, // {.bsel}
276        pub c: GeneralOperand,  // c
277        pub span: Span,
278    }
279}
280
281// Re-export types with section suffixes to avoid naming conflicts
282// e.g., Type0 for section_0::Type, Type1 for section_1::Type
283pub use section_0::Asel as Asel0;
284pub use section_0::Atype as Atype0;
285pub use section_0::Bsel as Bsel0;
286pub use section_0::Btype as Btype0;
287pub use section_0::Dtype as Dtype0;
288pub use section_0::Mask as Mask0;
289pub use section_0::N as N0;
290pub use section_0::Vabsdiff4DtypeAtypeBtypeAdd;
291pub use section_0::Vabsdiff4DtypeAtypeBtypeSat;
292pub use section_0::Vadd4DtypeAtypeBtypeAdd;
293pub use section_0::Vadd4DtypeAtypeBtypeSat;
294pub use section_0::Vavrg4DtypeAtypeBtypeAdd;
295pub use section_0::Vavrg4DtypeAtypeBtypeSat;
296pub use section_0::Vmax4DtypeAtypeBtypeAdd;
297pub use section_0::Vmax4DtypeAtypeBtypeSat;
298pub use section_0::Vmin4DtypeAtypeBtypeAdd;
299pub use section_0::Vmin4DtypeAtypeBtypeSat;
300pub use section_0::Vsub4DtypeAtypeBtypeAdd;
301pub use section_0::Vsub4DtypeAtypeBtypeSat;