Skip to main content

ptx_parser/type/instruction/
vset2.rs

1//! Original PTX specification:
2//!
3//! // SIMD instruction with secondary SIMD merge operation
4//! vset2.atype.btype.cmp  d{.mask}, a{.asel}, b{.bsel}, c;
5//! // SIMD instruction with secondary accumulate operation
6//! vset2.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  = { .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 }; // { .hxy, where x,y are from { 0, 1, 2, 3 } };
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 Atype {
26        U32, // .u32
27        S32, // .s32
28    }
29
30    #[derive(Debug, Clone, PartialEq, Serialize)]
31    pub enum Btype {
32        U32, // .u32
33        S32, // .s32
34    }
35
36    #[derive(Debug, Clone, PartialEq, Serialize)]
37    pub enum Cmp {
38        Eq, // .eq
39        Ne, // .ne
40        Lt, // .lt
41        Le, // .le
42        Gt, // .gt
43        Ge, // .ge
44    }
45
46    #[derive(Debug, Clone, PartialEq, Serialize)]
47    pub enum Mask {
48        H10, // .h10
49        H0,  // .h0
50        H1,  // .h1
51    }
52
53    #[derive(Debug, Clone, PartialEq, Serialize)]
54    pub enum Asel {
55        H00, // .h00
56        H01, // .h01
57        H02, // .h02
58        H03, // .h03
59        H10, // .h10
60        H11, // .h11
61        H12, // .h12
62        H13, // .h13
63        H20, // .h20
64        H21, // .h21
65        H22, // .h22
66        H23, // .h23
67        H30, // .h30
68        H31, // .h31
69        H32, // .h32
70        H33, // .h33
71    }
72
73    #[derive(Debug, Clone, PartialEq, Serialize)]
74    pub enum Bsel {
75        H00, // .h00
76        H01, // .h01
77        H02, // .h02
78        H03, // .h03
79        H10, // .h10
80        H11, // .h11
81        H12, // .h12
82        H13, // .h13
83        H20, // .h20
84        H21, // .h21
85        H22, // .h22
86        H23, // .h23
87        H30, // .h30
88        H31, // .h31
89        H32, // .h32
90        H33, // .h33
91    }
92
93    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
94    pub struct Vset2AtypeBtypeCmp {
95        pub atype: Atype,       // .atype
96        pub btype: Btype,       // .btype
97        pub cmp: Cmp,           // .cmp
98        pub d: GeneralOperand,  // d
99        pub mask: Option<Mask>, // {.mask}
100        pub a: GeneralOperand,  // a
101        pub asel: Option<Asel>, // {.asel}
102        pub b: GeneralOperand,  // b
103        pub bsel: Option<Bsel>, // {.bsel}
104        pub c: GeneralOperand,  // c
105        pub span: Span,
106    }
107
108    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
109    pub struct Vset2AtypeBtypeCmpAdd {
110        pub atype: Atype,       // .atype
111        pub btype: Btype,       // .btype
112        pub cmp: Cmp,           // .cmp
113        pub add: (),            // .add
114        pub d: GeneralOperand,  // d
115        pub mask: Option<Mask>, // {.mask}
116        pub a: GeneralOperand,  // a
117        pub asel: Option<Asel>, // {.asel}
118        pub b: GeneralOperand,  // b
119        pub bsel: Option<Bsel>, // {.bsel}
120        pub c: GeneralOperand,  // c
121        pub span: Span,
122    }
123}
124
125// Re-export types with section suffixes to avoid naming conflicts
126// e.g., Type0 for section_0::Type, Type1 for section_1::Type
127pub use section_0::Asel as Asel0;
128pub use section_0::Atype as Atype0;
129pub use section_0::Bsel as Bsel0;
130pub use section_0::Btype as Btype0;
131pub use section_0::Cmp as Cmp0;
132pub use section_0::Mask as Mask0;
133pub use section_0::Vset2AtypeBtypeCmp;
134pub use section_0::Vset2AtypeBtypeCmpAdd;