Skip to main content

ptx_parser/type/instruction/
vop.rs

1//! Original PTX specification:
2//!
3//! // 32-bit scalar operation, with optional secondary operation
4//! vop.dtype.atype.btype{.sat}       d, a{.asel}, b{.bsel};
5//! vop.dtype.atype.btype{.sat}.op2   d, a{.asel}, b{.bsel}, c;
6//! // 32-bit scalar operation, with optional data merge
7//! vop.dtype.atype.btype{.sat}  d.dsel, a{.asel}, b{.bsel}, c;
8//! vop   = { vadd, vsub, vabsdiff, vmin, vmax };
9//! .dtype = .atype = .btype = { .u32, .s32 };
10//! .dsel  = .asel  = .bsel  = { .b0, .b1, .b2, .b3, .h0, .h1 };
11//! .op2   = { .add, .min, .max };
12
13#![allow(unused)]
14use crate::r#type::common::*;
15
16pub mod section_0 {
17    use crate::Spanned;
18    use crate::parser::Span;
19    use crate::r#type::common::*;
20
21    use serde::Serialize;
22
23    #[derive(Debug, Clone, PartialEq, Serialize)]
24    pub enum Dtype {
25        U32, // .u32
26        S32, // .s32
27    }
28
29    #[derive(Debug, Clone, PartialEq, Serialize)]
30    pub enum Atype {
31        U32, // .u32
32        S32, // .s32
33    }
34
35    #[derive(Debug, Clone, PartialEq, Serialize)]
36    pub enum Btype {
37        U32, // .u32
38        S32, // .s32
39    }
40
41    #[derive(Debug, Clone, PartialEq, Serialize)]
42    pub enum Asel {
43        B0, // .b0
44        B1, // .b1
45        B2, // .b2
46        B3, // .b3
47        H0, // .h0
48        H1, // .h1
49    }
50
51    #[derive(Debug, Clone, PartialEq, Serialize)]
52    pub enum Bsel {
53        B0, // .b0
54        B1, // .b1
55        B2, // .b2
56        B3, // .b3
57        H0, // .h0
58        H1, // .h1
59    }
60
61    #[derive(Debug, Clone, PartialEq, Serialize)]
62    pub enum Op2 {
63        Add, // .add
64        Min, // .min
65        Max, // .max
66    }
67
68    #[derive(Debug, Clone, PartialEq, Serialize)]
69    pub enum Dsel {
70        B0, // .b0
71        B1, // .b1
72        B2, // .b2
73        B3, // .b3
74        H0, // .h0
75        H1, // .h1
76    }
77
78    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
79    pub struct VaddDtypeAtypeBtypeSat {
80        pub dtype: Dtype,       // .dtype
81        pub atype: Atype,       // .atype
82        pub btype: Btype,       // .btype
83        pub sat: bool,          // {.sat}
84        pub d: GeneralOperand,  // d
85        pub a: GeneralOperand,  // a
86        pub asel: Option<Asel>, // {.asel}
87        pub b: GeneralOperand,  // b
88        pub bsel: Option<Bsel>, // {.bsel}
89        pub span: Span,
90    }
91
92    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
93    pub struct VsubDtypeAtypeBtypeSat {
94        pub dtype: Dtype,       // .dtype
95        pub atype: Atype,       // .atype
96        pub btype: Btype,       // .btype
97        pub sat: bool,          // {.sat}
98        pub d: GeneralOperand,  // d
99        pub a: GeneralOperand,  // a
100        pub asel: Option<Asel>, // {.asel}
101        pub b: GeneralOperand,  // b
102        pub bsel: Option<Bsel>, // {.bsel}
103        pub span: Span,
104    }
105
106    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
107    pub struct VabsdiffDtypeAtypeBtypeSat {
108        pub dtype: Dtype,       // .dtype
109        pub atype: Atype,       // .atype
110        pub btype: Btype,       // .btype
111        pub sat: bool,          // {.sat}
112        pub d: GeneralOperand,  // d
113        pub a: GeneralOperand,  // a
114        pub asel: Option<Asel>, // {.asel}
115        pub b: GeneralOperand,  // b
116        pub bsel: Option<Bsel>, // {.bsel}
117        pub span: Span,
118    }
119
120    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
121    pub struct VminDtypeAtypeBtypeSat {
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 a: GeneralOperand,  // a
128        pub asel: Option<Asel>, // {.asel}
129        pub b: GeneralOperand,  // b
130        pub bsel: Option<Bsel>, // {.bsel}
131        pub span: Span,
132    }
133
134    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
135    pub struct VmaxDtypeAtypeBtypeSat {
136        pub dtype: Dtype,       // .dtype
137        pub atype: Atype,       // .atype
138        pub btype: Btype,       // .btype
139        pub sat: bool,          // {.sat}
140        pub d: GeneralOperand,  // d
141        pub a: GeneralOperand,  // a
142        pub asel: Option<Asel>, // {.asel}
143        pub b: GeneralOperand,  // b
144        pub bsel: Option<Bsel>, // {.bsel}
145        pub span: Span,
146    }
147
148    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
149    pub struct VaddDtypeAtypeBtypeSatOp2 {
150        pub dtype: Dtype,       // .dtype
151        pub atype: Atype,       // .atype
152        pub btype: Btype,       // .btype
153        pub sat: bool,          // {.sat}
154        pub op2: Op2,           // .op2
155        pub d: GeneralOperand,  // d
156        pub a: GeneralOperand,  // a
157        pub asel: Option<Asel>, // {.asel}
158        pub b: GeneralOperand,  // b
159        pub bsel: Option<Bsel>, // {.bsel}
160        pub c: GeneralOperand,  // c
161        pub span: Span,
162    }
163
164    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
165    pub struct VsubDtypeAtypeBtypeSatOp2 {
166        pub dtype: Dtype,       // .dtype
167        pub atype: Atype,       // .atype
168        pub btype: Btype,       // .btype
169        pub sat: bool,          // {.sat}
170        pub op2: Op2,           // .op2
171        pub d: GeneralOperand,  // d
172        pub a: GeneralOperand,  // a
173        pub asel: Option<Asel>, // {.asel}
174        pub b: GeneralOperand,  // b
175        pub bsel: Option<Bsel>, // {.bsel}
176        pub c: GeneralOperand,  // c
177        pub span: Span,
178    }
179
180    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
181    pub struct VabsdiffDtypeAtypeBtypeSatOp2 {
182        pub dtype: Dtype,       // .dtype
183        pub atype: Atype,       // .atype
184        pub btype: Btype,       // .btype
185        pub sat: bool,          // {.sat}
186        pub op2: Op2,           // .op2
187        pub d: GeneralOperand,  // d
188        pub a: GeneralOperand,  // a
189        pub asel: Option<Asel>, // {.asel}
190        pub b: GeneralOperand,  // b
191        pub bsel: Option<Bsel>, // {.bsel}
192        pub c: GeneralOperand,  // c
193        pub span: Span,
194    }
195
196    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
197    pub struct VminDtypeAtypeBtypeSatOp2 {
198        pub dtype: Dtype,       // .dtype
199        pub atype: Atype,       // .atype
200        pub btype: Btype,       // .btype
201        pub sat: bool,          // {.sat}
202        pub op2: Op2,           // .op2
203        pub d: GeneralOperand,  // d
204        pub a: GeneralOperand,  // a
205        pub asel: Option<Asel>, // {.asel}
206        pub b: GeneralOperand,  // b
207        pub bsel: Option<Bsel>, // {.bsel}
208        pub c: GeneralOperand,  // c
209        pub span: Span,
210    }
211
212    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
213    pub struct VmaxDtypeAtypeBtypeSatOp2 {
214        pub dtype: Dtype,       // .dtype
215        pub atype: Atype,       // .atype
216        pub btype: Btype,       // .btype
217        pub sat: bool,          // {.sat}
218        pub op2: Op2,           // .op2
219        pub d: GeneralOperand,  // d
220        pub a: GeneralOperand,  // a
221        pub asel: Option<Asel>, // {.asel}
222        pub b: GeneralOperand,  // b
223        pub bsel: Option<Bsel>, // {.bsel}
224        pub c: GeneralOperand,  // c
225        pub span: Span,
226    }
227
228    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
229    pub struct VaddDtypeAtypeBtypeSat1 {
230        pub dtype: Dtype,       // .dtype
231        pub atype: Atype,       // .atype
232        pub btype: Btype,       // .btype
233        pub sat: bool,          // {.sat}
234        pub d: GeneralOperand,  // d
235        pub dsel: Dsel,         // .dsel
236        pub a: GeneralOperand,  // a
237        pub asel: Option<Asel>, // {.asel}
238        pub b: GeneralOperand,  // b
239        pub bsel: Option<Bsel>, // {.bsel}
240        pub c: GeneralOperand,  // c
241        pub span: Span,
242    }
243
244    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
245    pub struct VsubDtypeAtypeBtypeSat1 {
246        pub dtype: Dtype,       // .dtype
247        pub atype: Atype,       // .atype
248        pub btype: Btype,       // .btype
249        pub sat: bool,          // {.sat}
250        pub d: GeneralOperand,  // d
251        pub dsel: Dsel,         // .dsel
252        pub a: GeneralOperand,  // a
253        pub asel: Option<Asel>, // {.asel}
254        pub b: GeneralOperand,  // b
255        pub bsel: Option<Bsel>, // {.bsel}
256        pub c: GeneralOperand,  // c
257        pub span: Span,
258    }
259
260    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
261    pub struct VabsdiffDtypeAtypeBtypeSat1 {
262        pub dtype: Dtype,       // .dtype
263        pub atype: Atype,       // .atype
264        pub btype: Btype,       // .btype
265        pub sat: bool,          // {.sat}
266        pub d: GeneralOperand,  // d
267        pub dsel: Dsel,         // .dsel
268        pub a: GeneralOperand,  // a
269        pub asel: Option<Asel>, // {.asel}
270        pub b: GeneralOperand,  // b
271        pub bsel: Option<Bsel>, // {.bsel}
272        pub c: GeneralOperand,  // c
273        pub span: Span,
274    }
275
276    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
277    pub struct VminDtypeAtypeBtypeSat1 {
278        pub dtype: Dtype,       // .dtype
279        pub atype: Atype,       // .atype
280        pub btype: Btype,       // .btype
281        pub sat: bool,          // {.sat}
282        pub d: GeneralOperand,  // d
283        pub dsel: Dsel,         // .dsel
284        pub a: GeneralOperand,  // a
285        pub asel: Option<Asel>, // {.asel}
286        pub b: GeneralOperand,  // b
287        pub bsel: Option<Bsel>, // {.bsel}
288        pub c: GeneralOperand,  // c
289        pub span: Span,
290    }
291
292    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
293    pub struct VmaxDtypeAtypeBtypeSat1 {
294        pub dtype: Dtype,       // .dtype
295        pub atype: Atype,       // .atype
296        pub btype: Btype,       // .btype
297        pub sat: bool,          // {.sat}
298        pub d: GeneralOperand,  // d
299        pub dsel: Dsel,         // .dsel
300        pub a: GeneralOperand,  // a
301        pub asel: Option<Asel>, // {.asel}
302        pub b: GeneralOperand,  // b
303        pub bsel: Option<Bsel>, // {.bsel}
304        pub c: GeneralOperand,  // c
305        pub span: Span,
306    }
307}
308
309// Re-export types with section suffixes to avoid naming conflicts
310// e.g., Type0 for section_0::Type, Type1 for section_1::Type
311pub use section_0::Asel as Asel0;
312pub use section_0::Atype as Atype0;
313pub use section_0::Bsel as Bsel0;
314pub use section_0::Btype as Btype0;
315pub use section_0::Dsel as Dsel0;
316pub use section_0::Dtype as Dtype0;
317pub use section_0::Op2 as Op20;
318pub use section_0::VabsdiffDtypeAtypeBtypeSat;
319pub use section_0::VabsdiffDtypeAtypeBtypeSat1;
320pub use section_0::VabsdiffDtypeAtypeBtypeSatOp2;
321pub use section_0::VaddDtypeAtypeBtypeSat;
322pub use section_0::VaddDtypeAtypeBtypeSat1;
323pub use section_0::VaddDtypeAtypeBtypeSatOp2;
324pub use section_0::VmaxDtypeAtypeBtypeSat;
325pub use section_0::VmaxDtypeAtypeBtypeSat1;
326pub use section_0::VmaxDtypeAtypeBtypeSatOp2;
327pub use section_0::VminDtypeAtypeBtypeSat;
328pub use section_0::VminDtypeAtypeBtypeSat1;
329pub use section_0::VminDtypeAtypeBtypeSatOp2;
330pub use section_0::VsubDtypeAtypeBtypeSat;
331pub use section_0::VsubDtypeAtypeBtypeSat1;
332pub use section_0::VsubDtypeAtypeBtypeSatOp2;