Skip to main content

ptx_parser/type/instruction/
vset4.rs

1//! Original PTX specification:
2//!
3//! // SIMD instruction with secondary SIMD merge operation
4//! vset4.atype.btype.cmp  d{.mask}, a{.asel}, b{.bsel}, c;
5//! // SIMD instruction with secondary accumulate operation
6//! vset4.atype.btype.cmp.add  d{.mask}, a{.asel}, b{.bsel}, c;
7//! .atype = .btype = { .u32, .s32 };
8//! .cmp   = { .eq, .ne, .lt, .le, .gt, .ge };
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 = { .b00, .b01, .b02, .b03, .b04, .b05, .b06, .b07,
15//!                   .b10, .b11, .b12, .b13, .b14, .b15, .b16, .b17,
16//!                   .b20, .b21, .b22, .b23, .b24, .b25, .b26, .b27,
17//!                   .b30, .b31, .b32, .b33, .b34, .b35, .b36, .b37,
18//!                   .b40, .b41, .b42, .b43, .b44, .b45, .b46, .b47,
19//!                   .b50, .b51, .b52, .b53, .b54, .b55, .b56, .b57,
20//!                   .b60, .b61, .b62, .b63, .b64, .b65, .b66, .b67,
21//!                   .b70, .b71, .b72, .b73, .b74, .b75, .b76, .b77
22//!                   } //.bxyzw, where x,y,z,w are from { 0, ..., 7 };
23//! // .asel defaults to .b3210
24//! // .bsel defaults to .b7654
25
26#![allow(unused)]
27use crate::r#type::common::*;
28
29pub mod section_0 {
30    use crate::Spanned;
31    use crate::parser::Span;
32    use crate::r#type::common::*;
33
34    use serde::Serialize;
35
36    #[derive(Debug, Clone, PartialEq, Serialize)]
37    pub enum Atype {
38        U32, // .u32
39        S32, // .s32
40    }
41
42    #[derive(Debug, Clone, PartialEq, Serialize)]
43    pub enum Btype {
44        U32, // .u32
45        S32, // .s32
46    }
47
48    #[derive(Debug, Clone, PartialEq, Serialize)]
49    pub enum Cmp {
50        Eq, // .eq
51        Ne, // .ne
52        Lt, // .lt
53        Le, // .le
54        Gt, // .gt
55        Ge, // .ge
56    }
57
58    #[derive(Debug, Clone, PartialEq, Serialize)]
59    pub enum Mask {
60        B10B2, // .b10.b2
61        B3210, // .b3210
62        B210,  // .b210
63        B310,  // .b310
64        B320,  // .b320
65        B321,  // .b321
66        B20,   // .b20
67        B21,   // .b21
68        B30,   // .b30
69        B31,   // .b31
70        B32,   // .b32
71        B0,    // .b0
72        B1,    // .b1
73        B3,    // .b3
74    }
75
76    #[derive(Debug, Clone, PartialEq, Serialize)]
77    pub enum Bsel {
78        B00, // .b00
79        B01, // .b01
80        B02, // .b02
81        B03, // .b03
82        B04, // .b04
83        B05, // .b05
84        B06, // .b06
85        B07, // .b07
86        B10, // .b10
87        B11, // .b11
88        B12, // .b12
89        B13, // .b13
90        B14, // .b14
91        B15, // .b15
92        B16, // .b16
93        B17, // .b17
94        B20, // .b20
95        B21, // .b21
96        B22, // .b22
97        B23, // .b23
98        B24, // .b24
99        B25, // .b25
100        B26, // .b26
101        B27, // .b27
102        B30, // .b30
103        B31, // .b31
104        B32, // .b32
105        B33, // .b33
106        B34, // .b34
107        B35, // .b35
108        B36, // .b36
109        B37, // .b37
110        B40, // .b40
111        B41, // .b41
112        B42, // .b42
113        B43, // .b43
114        B44, // .b44
115        B45, // .b45
116        B46, // .b46
117        B47, // .b47
118        B50, // .b50
119        B51, // .b51
120        B52, // .b52
121        B53, // .b53
122        B54, // .b54
123        B55, // .b55
124        B56, // .b56
125        B57, // .b57
126        B60, // .b60
127        B61, // .b61
128        B62, // .b62
129        B63, // .b63
130        B64, // .b64
131        B65, // .b65
132        B66, // .b66
133        B67, // .b67
134        B70, // .b70
135        B71, // .b71
136        B72, // .b72
137        B73, // .b73
138        B74, // .b74
139        B75, // .b75
140        B76, // .b76
141        B77, // .b77
142    }
143
144    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
145    pub struct Vset4AtypeBtypeCmp {
146        pub atype: Atype,       // .atype
147        pub btype: Btype,       // .btype
148        pub cmp: Cmp,           // .cmp
149        pub d: GeneralOperand,  // d
150        pub mask: Option<Mask>, // {.mask}
151        pub a: GeneralOperand,  // a
152        pub asel: bool,         // {.asel}
153        pub b: GeneralOperand,  // b
154        pub bsel: Option<Bsel>, // {.bsel}
155        pub c: GeneralOperand,  // c
156        pub span: Span,
157    }
158
159    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
160    pub struct Vset4AtypeBtypeCmpAdd {
161        pub atype: Atype,       // .atype
162        pub btype: Btype,       // .btype
163        pub cmp: Cmp,           // .cmp
164        pub add: (),            // .add
165        pub d: GeneralOperand,  // d
166        pub mask: Option<Mask>, // {.mask}
167        pub a: GeneralOperand,  // a
168        pub asel: bool,         // {.asel}
169        pub b: GeneralOperand,  // b
170        pub bsel: Option<Bsel>, // {.bsel}
171        pub c: GeneralOperand,  // c
172        pub span: Span,
173    }
174}
175
176// Re-export types with section suffixes to avoid naming conflicts
177// e.g., Type0 for section_0::Type, Type1 for section_1::Type
178pub use section_0::Atype as Atype0;
179pub use section_0::Bsel as Bsel0;
180pub use section_0::Btype as Btype0;
181pub use section_0::Cmp as Cmp0;
182pub use section_0::Mask as Mask0;
183pub use section_0::Vset4AtypeBtypeCmp;
184pub use section_0::Vset4AtypeBtypeCmpAdd;