Skip to main content

ptx_parser/type/instruction/
vset.rs

1//! Original PTX specification:
2//!
3//! // 32-bit scalar operation, with optional secondary operation
4//! vset.atype.btype.cmp       d, a{.asel}, b{.bsel};
5//! vset.atype.btype.cmp.op2   d, a{.asel}, b{.bsel}, c;
6//! // 32-bit scalar operation, with optional data merge
7//! vset.atype.btype.cmp  d.dsel, a{.asel}, b{.bsel}, c;
8//! .atype = .btype = { .u32, .s32 };
9//! .cmp   = { .eq, .ne, .lt, .le, .gt, .ge };
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 Atype {
25        U32, // .u32
26        S32, // .s32
27    }
28
29    #[derive(Debug, Clone, PartialEq, Serialize)]
30    pub enum Btype {
31        U32, // .u32
32        S32, // .s32
33    }
34
35    #[derive(Debug, Clone, PartialEq, Serialize)]
36    pub enum Cmp {
37        Eq, // .eq
38        Ne, // .ne
39        Lt, // .lt
40        Le, // .le
41        Gt, // .gt
42        Ge, // .ge
43    }
44
45    #[derive(Debug, Clone, PartialEq, Serialize)]
46    pub enum Asel {
47        B0, // .b0
48        B1, // .b1
49        B2, // .b2
50        B3, // .b3
51        H0, // .h0
52        H1, // .h1
53    }
54
55    #[derive(Debug, Clone, PartialEq, Serialize)]
56    pub enum Bsel {
57        B0, // .b0
58        B1, // .b1
59        B2, // .b2
60        B3, // .b3
61        H0, // .h0
62        H1, // .h1
63    }
64
65    #[derive(Debug, Clone, PartialEq, Serialize)]
66    pub enum Op2 {
67        Add, // .add
68        Min, // .min
69        Max, // .max
70    }
71
72    #[derive(Debug, Clone, PartialEq, Serialize)]
73    pub enum Dsel {
74        B0, // .b0
75        B1, // .b1
76        B2, // .b2
77        B3, // .b3
78        H0, // .h0
79        H1, // .h1
80    }
81
82    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
83    pub struct VsetAtypeBtypeCmp {
84        pub atype: Atype,       // .atype
85        pub btype: Btype,       // .btype
86        pub cmp: Cmp,           // .cmp
87        pub d: GeneralOperand,  // d
88        pub a: GeneralOperand,  // a
89        pub asel: Option<Asel>, // {.asel}
90        pub b: GeneralOperand,  // b
91        pub bsel: Option<Bsel>, // {.bsel}
92        pub span: Span,
93    }
94
95    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
96    pub struct VsetAtypeBtypeCmpOp2 {
97        pub atype: Atype,       // .atype
98        pub btype: Btype,       // .btype
99        pub cmp: Cmp,           // .cmp
100        pub op2: Op2,           // .op2
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 c: GeneralOperand,  // c
107        pub span: Span,
108    }
109
110    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
111    pub struct VsetAtypeBtypeCmp1 {
112        pub atype: Atype,       // .atype
113        pub btype: Btype,       // .btype
114        pub cmp: Cmp,           // .cmp
115        pub d: GeneralOperand,  // d
116        pub dsel: Dsel,         // .dsel
117        pub a: GeneralOperand,  // a
118        pub asel: Option<Asel>, // {.asel}
119        pub b: GeneralOperand,  // b
120        pub bsel: Option<Bsel>, // {.bsel}
121        pub c: GeneralOperand,  // c
122        pub span: Span,
123    }
124}
125
126// Re-export types with section suffixes to avoid naming conflicts
127// e.g., Type0 for section_0::Type, Type1 for section_1::Type
128pub use section_0::Asel as Asel0;
129pub use section_0::Atype as Atype0;
130pub use section_0::Bsel as Bsel0;
131pub use section_0::Btype as Btype0;
132pub use section_0::Cmp as Cmp0;
133pub use section_0::Dsel as Dsel0;
134pub use section_0::Op2 as Op20;
135pub use section_0::VsetAtypeBtypeCmp;
136pub use section_0::VsetAtypeBtypeCmp1;
137pub use section_0::VsetAtypeBtypeCmpOp2;