Skip to main content

ptx_parser/type/instruction/
vsh.rs

1//! Original PTX specification:
2//!
3//! // 32-bit scalar operation, with optional secondary operation
4//! vop.dtype.atype.u32{.sat}.mode       d, a{.asel}, b{.bsel};
5//! vop.dtype.atype.u32{.sat}.mode.op2   d, a{.asel}, b{.bsel}, c;
6//! // 32-bit scalar operation, with optional data merge
7//! vop.dtype.atype.u32{.sat}.mode  d.dsel, a{.asel}, b{.bsel}, c;
8//! vop   = { vshl, vshr };
9//! .dtype = .atype = { .u32, .s32 };
10//! .mode  = { .clamp, .wrap };
11//! .dsel  = .asel  = .bsel  = { .b0, .b1, .b2, .b3, .h0, .h1 };
12//! .op2   = { .add, .min, .max };
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 Mode {
38        Clamp, // .clamp
39        Wrap,  // .wrap
40    }
41
42    #[derive(Debug, Clone, PartialEq, Serialize)]
43    pub enum Asel {
44        B0, // .b0
45        B1, // .b1
46        B2, // .b2
47        B3, // .b3
48        H0, // .h0
49        H1, // .h1
50    }
51
52    #[derive(Debug, Clone, PartialEq, Serialize)]
53    pub enum Bsel {
54        B0, // .b0
55        B1, // .b1
56        B2, // .b2
57        B3, // .b3
58        H0, // .h0
59        H1, // .h1
60    }
61
62    #[derive(Debug, Clone, PartialEq, Serialize)]
63    pub enum Op2 {
64        Add, // .add
65        Min, // .min
66        Max, // .max
67    }
68
69    #[derive(Debug, Clone, PartialEq, Serialize)]
70    pub enum Dsel {
71        B0, // .b0
72        B1, // .b1
73        B2, // .b2
74        B3, // .b3
75        H0, // .h0
76        H1, // .h1
77    }
78
79    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
80    pub struct VshlDtypeAtypeU32SatMode {
81        pub dtype: Dtype,       // .dtype
82        pub atype: Atype,       // .atype
83        pub u32: (),            // .u32
84        pub sat: bool,          // {.sat}
85        pub mode: Mode,         // .mode
86        pub d: GeneralOperand,  // d
87        pub a: GeneralOperand,  // a
88        pub asel: Option<Asel>, // {.asel}
89        pub b: GeneralOperand,  // b
90        pub bsel: Option<Bsel>, // {.bsel}
91        pub span: Span,
92    }
93
94    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
95    pub struct VshrDtypeAtypeU32SatMode {
96        pub dtype: Dtype,       // .dtype
97        pub atype: Atype,       // .atype
98        pub u32: (),            // .u32
99        pub sat: bool,          // {.sat}
100        pub mode: Mode,         // .mode
101        pub d: GeneralOperand,  // d
102        pub a: GeneralOperand,  // a
103        pub asel: Option<Asel>, // {.asel}
104        pub b: GeneralOperand,  // b
105        pub bsel: Option<Bsel>, // {.bsel}
106        pub span: Span,
107    }
108
109    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
110    pub struct VshlDtypeAtypeU32SatModeOp2 {
111        pub dtype: Dtype,       // .dtype
112        pub atype: Atype,       // .atype
113        pub u32: (),            // .u32
114        pub sat: bool,          // {.sat}
115        pub mode: Mode,         // .mode
116        pub op2: Op2,           // .op2
117        pub d: GeneralOperand,  // d
118        pub a: GeneralOperand,  // a
119        pub asel: Option<Asel>, // {.asel}
120        pub b: GeneralOperand,  // b
121        pub bsel: Option<Bsel>, // {.bsel}
122        pub c: GeneralOperand,  // c
123        pub span: Span,
124    }
125
126    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
127    pub struct VshrDtypeAtypeU32SatModeOp2 {
128        pub dtype: Dtype,       // .dtype
129        pub atype: Atype,       // .atype
130        pub u32: (),            // .u32
131        pub sat: bool,          // {.sat}
132        pub mode: Mode,         // .mode
133        pub op2: Op2,           // .op2
134        pub d: GeneralOperand,  // d
135        pub a: GeneralOperand,  // a
136        pub asel: Option<Asel>, // {.asel}
137        pub b: GeneralOperand,  // b
138        pub bsel: Option<Bsel>, // {.bsel}
139        pub c: GeneralOperand,  // c
140        pub span: Span,
141    }
142
143    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
144    pub struct VshlDtypeAtypeU32SatMode1 {
145        pub dtype: Dtype,       // .dtype
146        pub atype: Atype,       // .atype
147        pub u32: (),            // .u32
148        pub sat: bool,          // {.sat}
149        pub mode: Mode,         // .mode
150        pub d: GeneralOperand,  // d
151        pub dsel: Dsel,         // .dsel
152        pub a: GeneralOperand,  // a
153        pub asel: Option<Asel>, // {.asel}
154        pub b: GeneralOperand,  // b
155        pub bsel: Option<Bsel>, // {.bsel}
156        pub c: GeneralOperand,  // c
157        pub span: Span,
158    }
159
160    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
161    pub struct VshrDtypeAtypeU32SatMode1 {
162        pub dtype: Dtype,       // .dtype
163        pub atype: Atype,       // .atype
164        pub u32: (),            // .u32
165        pub sat: bool,          // {.sat}
166        pub mode: Mode,         // .mode
167        pub d: GeneralOperand,  // d
168        pub dsel: Dsel,         // .dsel
169        pub a: GeneralOperand,  // a
170        pub asel: Option<Asel>, // {.asel}
171        pub b: GeneralOperand,  // b
172        pub bsel: Option<Bsel>, // {.bsel}
173        pub c: GeneralOperand,  // c
174        pub span: Span,
175    }
176}
177
178// Re-export types with section suffixes to avoid naming conflicts
179// e.g., Type0 for section_0::Type, Type1 for section_1::Type
180pub use section_0::Asel as Asel0;
181pub use section_0::Atype as Atype0;
182pub use section_0::Bsel as Bsel0;
183pub use section_0::Dsel as Dsel0;
184pub use section_0::Dtype as Dtype0;
185pub use section_0::Mode as Mode0;
186pub use section_0::Op2 as Op20;
187pub use section_0::VshlDtypeAtypeU32SatMode;
188pub use section_0::VshlDtypeAtypeU32SatMode1;
189pub use section_0::VshlDtypeAtypeU32SatModeOp2;
190pub use section_0::VshrDtypeAtypeU32SatMode;
191pub use section_0::VshrDtypeAtypeU32SatMode1;
192pub use section_0::VshrDtypeAtypeU32SatModeOp2;