Skip to main content

ptx_parser/type/instruction/
vop2.rs

1//! Original PTX specification:
2//!
3//! // SIMD instruction with secondary SIMD merge operation
4//! vop2.dtype.atype.btype{.sat}  d{.mask}, a{.asel}, b{.bsel}, c;
5//! // SIMD instruction with secondary accumulate operation
6//! vop2.dtype.atype.btype.add  d{.mask}, a{.asel}, b{.bsel}, c;
7//! vop2  = { vadd2, vsub2, vavrg2, vabsdiff2, vmin2, vmax2 };
8//! .dtype = .atype = .btype = { .u32, .s32 };
9//! .mask  = { .h0, .h1, .h10 };  // defaults to .h10
10//! .asel  = .bsel  = { .h00, .h01, .h02, .h03, .h10, .h11, .h12, .h13, .h20, .h21, .h22, .h23, .h30, .h31, .h32, .h33 };
11//! // .asel defaults to .h10
12//! // .bsel defaults to .h32
13
14#![allow(unused)]
15use crate::r#type::common::*;
16
17pub mod section_0 {
18    use crate::Spanned;
19    use crate::parser::Span;
20    use crate::r#type::common::*;
21
22    use serde::Serialize;
23
24    #[derive(Debug, Clone, PartialEq, Serialize)]
25    pub enum Dtype {
26        U32, // .u32
27        S32, // .s32
28    }
29
30    #[derive(Debug, Clone, PartialEq, Serialize)]
31    pub enum Atype {
32        U32, // .u32
33        S32, // .s32
34    }
35
36    #[derive(Debug, Clone, PartialEq, Serialize)]
37    pub enum Btype {
38        U32, // .u32
39        S32, // .s32
40    }
41
42    #[derive(Debug, Clone, PartialEq, Serialize)]
43    pub enum Mask {
44        H10, // .h10
45        H0,  // .h0
46        H1,  // .h1
47    }
48
49    #[derive(Debug, Clone, PartialEq, Serialize)]
50    pub enum Asel {
51        H00, // .h00
52        H01, // .h01
53        H02, // .h02
54        H03, // .h03
55        H10, // .h10
56        H11, // .h11
57        H12, // .h12
58        H13, // .h13
59        H20, // .h20
60        H21, // .h21
61        H22, // .h22
62        H23, // .h23
63        H30, // .h30
64        H31, // .h31
65        H32, // .h32
66        H33, // .h33
67    }
68
69    #[derive(Debug, Clone, PartialEq, Serialize)]
70    pub enum Bsel {
71        H00, // .h00
72        H01, // .h01
73        H02, // .h02
74        H03, // .h03
75        H10, // .h10
76        H11, // .h11
77        H12, // .h12
78        H13, // .h13
79        H20, // .h20
80        H21, // .h21
81        H22, // .h22
82        H23, // .h23
83        H30, // .h30
84        H31, // .h31
85        H32, // .h32
86        H33, // .h33
87    }
88
89    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
90    pub struct Vadd2DtypeAtypeBtypeSat {
91        pub dtype: Dtype,       // .dtype
92        pub atype: Atype,       // .atype
93        pub btype: Btype,       // .btype
94        pub sat: bool,          // {.sat}
95        pub d: GeneralOperand,  // d
96        pub mask: Option<Mask>, // {.mask}
97        pub a: GeneralOperand,  // a
98        pub asel: Option<Asel>, // {.asel}
99        pub b: GeneralOperand,  // b
100        pub bsel: Option<Bsel>, // {.bsel}
101        pub c: GeneralOperand,  // c
102        pub span: Span,
103    }
104
105    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
106    pub struct Vsub2DtypeAtypeBtypeSat {
107        pub dtype: Dtype,       // .dtype
108        pub atype: Atype,       // .atype
109        pub btype: Btype,       // .btype
110        pub sat: bool,          // {.sat}
111        pub d: GeneralOperand,  // d
112        pub mask: Option<Mask>, // {.mask}
113        pub a: GeneralOperand,  // a
114        pub asel: Option<Asel>, // {.asel}
115        pub b: GeneralOperand,  // b
116        pub bsel: Option<Bsel>, // {.bsel}
117        pub c: GeneralOperand,  // c
118        pub span: Span,
119    }
120
121    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
122    pub struct Vavrg2DtypeAtypeBtypeSat {
123        pub dtype: Dtype,       // .dtype
124        pub atype: Atype,       // .atype
125        pub btype: Btype,       // .btype
126        pub sat: bool,          // {.sat}
127        pub d: GeneralOperand,  // d
128        pub mask: Option<Mask>, // {.mask}
129        pub a: GeneralOperand,  // a
130        pub asel: Option<Asel>, // {.asel}
131        pub b: GeneralOperand,  // b
132        pub bsel: Option<Bsel>, // {.bsel}
133        pub c: GeneralOperand,  // c
134        pub span: Span,
135    }
136
137    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
138    pub struct Vabsdiff2DtypeAtypeBtypeSat {
139        pub dtype: Dtype,       // .dtype
140        pub atype: Atype,       // .atype
141        pub btype: Btype,       // .btype
142        pub sat: bool,          // {.sat}
143        pub d: GeneralOperand,  // d
144        pub mask: Option<Mask>, // {.mask}
145        pub a: GeneralOperand,  // a
146        pub asel: Option<Asel>, // {.asel}
147        pub b: GeneralOperand,  // b
148        pub bsel: Option<Bsel>, // {.bsel}
149        pub c: GeneralOperand,  // c
150        pub span: Span,
151    }
152
153    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
154    pub struct Vmin2DtypeAtypeBtypeSat {
155        pub dtype: Dtype,       // .dtype
156        pub atype: Atype,       // .atype
157        pub btype: Btype,       // .btype
158        pub sat: bool,          // {.sat}
159        pub d: GeneralOperand,  // d
160        pub mask: Option<Mask>, // {.mask}
161        pub a: GeneralOperand,  // a
162        pub asel: Option<Asel>, // {.asel}
163        pub b: GeneralOperand,  // b
164        pub bsel: Option<Bsel>, // {.bsel}
165        pub c: GeneralOperand,  // c
166        pub span: Span,
167    }
168
169    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
170    pub struct Vmax2DtypeAtypeBtypeSat {
171        pub dtype: Dtype,       // .dtype
172        pub atype: Atype,       // .atype
173        pub btype: Btype,       // .btype
174        pub sat: bool,          // {.sat}
175        pub d: GeneralOperand,  // d
176        pub mask: Option<Mask>, // {.mask}
177        pub a: GeneralOperand,  // a
178        pub asel: Option<Asel>, // {.asel}
179        pub b: GeneralOperand,  // b
180        pub bsel: Option<Bsel>, // {.bsel}
181        pub c: GeneralOperand,  // c
182        pub span: Span,
183    }
184
185    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
186    pub struct Vadd2DtypeAtypeBtypeAdd {
187        pub dtype: Dtype,       // .dtype
188        pub atype: Atype,       // .atype
189        pub btype: Btype,       // .btype
190        pub add: (),            // .add
191        pub d: GeneralOperand,  // d
192        pub mask: Option<Mask>, // {.mask}
193        pub a: GeneralOperand,  // a
194        pub asel: Option<Asel>, // {.asel}
195        pub b: GeneralOperand,  // b
196        pub bsel: Option<Bsel>, // {.bsel}
197        pub c: GeneralOperand,  // c
198        pub span: Span,
199    }
200
201    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
202    pub struct Vsub2DtypeAtypeBtypeAdd {
203        pub dtype: Dtype,       // .dtype
204        pub atype: Atype,       // .atype
205        pub btype: Btype,       // .btype
206        pub add: (),            // .add
207        pub d: GeneralOperand,  // d
208        pub mask: Option<Mask>, // {.mask}
209        pub a: GeneralOperand,  // a
210        pub asel: Option<Asel>, // {.asel}
211        pub b: GeneralOperand,  // b
212        pub bsel: Option<Bsel>, // {.bsel}
213        pub c: GeneralOperand,  // c
214        pub span: Span,
215    }
216
217    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
218    pub struct Vavrg2DtypeAtypeBtypeAdd {
219        pub dtype: Dtype,       // .dtype
220        pub atype: Atype,       // .atype
221        pub btype: Btype,       // .btype
222        pub add: (),            // .add
223        pub d: GeneralOperand,  // d
224        pub mask: Option<Mask>, // {.mask}
225        pub a: GeneralOperand,  // a
226        pub asel: Option<Asel>, // {.asel}
227        pub b: GeneralOperand,  // b
228        pub bsel: Option<Bsel>, // {.bsel}
229        pub c: GeneralOperand,  // c
230        pub span: Span,
231    }
232
233    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
234    pub struct Vabsdiff2DtypeAtypeBtypeAdd {
235        pub dtype: Dtype,       // .dtype
236        pub atype: Atype,       // .atype
237        pub btype: Btype,       // .btype
238        pub add: (),            // .add
239        pub d: GeneralOperand,  // d
240        pub mask: Option<Mask>, // {.mask}
241        pub a: GeneralOperand,  // a
242        pub asel: Option<Asel>, // {.asel}
243        pub b: GeneralOperand,  // b
244        pub bsel: Option<Bsel>, // {.bsel}
245        pub c: GeneralOperand,  // c
246        pub span: Span,
247    }
248
249    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
250    pub struct Vmin2DtypeAtypeBtypeAdd {
251        pub dtype: Dtype,       // .dtype
252        pub atype: Atype,       // .atype
253        pub btype: Btype,       // .btype
254        pub add: (),            // .add
255        pub d: GeneralOperand,  // d
256        pub mask: Option<Mask>, // {.mask}
257        pub a: GeneralOperand,  // a
258        pub asel: Option<Asel>, // {.asel}
259        pub b: GeneralOperand,  // b
260        pub bsel: Option<Bsel>, // {.bsel}
261        pub c: GeneralOperand,  // c
262        pub span: Span,
263    }
264
265    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
266    pub struct Vmax2DtypeAtypeBtypeAdd {
267        pub dtype: Dtype,       // .dtype
268        pub atype: Atype,       // .atype
269        pub btype: Btype,       // .btype
270        pub add: (),            // .add
271        pub d: GeneralOperand,  // d
272        pub mask: Option<Mask>, // {.mask}
273        pub a: GeneralOperand,  // a
274        pub asel: Option<Asel>, // {.asel}
275        pub b: GeneralOperand,  // b
276        pub bsel: Option<Bsel>, // {.bsel}
277        pub c: GeneralOperand,  // c
278        pub span: Span,
279    }
280}
281
282// Re-export types with section suffixes to avoid naming conflicts
283// e.g., Type0 for section_0::Type, Type1 for section_1::Type
284pub use section_0::Asel as Asel0;
285pub use section_0::Atype as Atype0;
286pub use section_0::Bsel as Bsel0;
287pub use section_0::Btype as Btype0;
288pub use section_0::Dtype as Dtype0;
289pub use section_0::Mask as Mask0;
290pub use section_0::Vabsdiff2DtypeAtypeBtypeAdd;
291pub use section_0::Vabsdiff2DtypeAtypeBtypeSat;
292pub use section_0::Vadd2DtypeAtypeBtypeAdd;
293pub use section_0::Vadd2DtypeAtypeBtypeSat;
294pub use section_0::Vavrg2DtypeAtypeBtypeAdd;
295pub use section_0::Vavrg2DtypeAtypeBtypeSat;
296pub use section_0::Vmax2DtypeAtypeBtypeAdd;
297pub use section_0::Vmax2DtypeAtypeBtypeSat;
298pub use section_0::Vmin2DtypeAtypeBtypeAdd;
299pub use section_0::Vmin2DtypeAtypeBtypeSat;
300pub use section_0::Vsub2DtypeAtypeBtypeAdd;
301pub use section_0::Vsub2DtypeAtypeBtypeSat;