Skip to main content

ptx_parser/type/instruction/
vmad.rs

1//! Original PTX specification:
2//!
3//! // 32-bit scalar operation
4//! vmad.dtype.atype.btype{.sat}{.scale}     d, {-}a{.asel}, {-}b{.bsel},
5//! {-}c;
6//! vmad.dtype.atype.btype.po{.sat}{.scale}  d, a{.asel}, b{.bsel}, c;
7//! .dtype = .atype = .btype = { .u32, .s32 };
8//! .asel  = .bsel  = { .b0, .b1, .b2, .b3, .h0, .h1 };
9//! .scale = { .shr7, .shr15 };
10
11#![allow(unused)]
12use crate::r#type::common::*;
13
14pub mod section_0 {
15    use crate::Spanned;
16    use crate::parser::Span;
17    use crate::r#type::common::*;
18
19    use serde::Serialize;
20
21    #[derive(Debug, Clone, PartialEq, Serialize)]
22    pub enum Dtype {
23        U32, // .u32
24        S32, // .s32
25    }
26
27    #[derive(Debug, Clone, PartialEq, Serialize)]
28    pub enum Atype {
29        U32, // .u32
30        S32, // .s32
31    }
32
33    #[derive(Debug, Clone, PartialEq, Serialize)]
34    pub enum Btype {
35        U32, // .u32
36        S32, // .s32
37    }
38
39    #[derive(Debug, Clone, PartialEq, Serialize)]
40    pub enum Scale {
41        Shr15, // .shr15
42        Shr7,  // .shr7
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, Spanned, Serialize)]
66    pub struct VmadDtypeAtypeBtypeSatScale {
67        pub dtype: Dtype,         // .dtype
68        pub atype: Atype,         // .atype
69        pub btype: Btype,         // .btype
70        pub sat: bool,            // {.sat}
71        pub scale: Option<Scale>, // {.scale}
72        pub d: GeneralOperand,    // d
73        pub a_op: bool,           // {-} operator
74        pub a: GeneralOperand,    // {-}a
75        pub asel: Option<Asel>,   // {.asel}
76        pub b_op: bool,           // {-} operator
77        pub b: GeneralOperand,    // {-}b
78        pub bsel: Option<Bsel>,   // {.bsel}
79        pub c_op: bool,           // {-} operator
80        pub c: GeneralOperand,    // {-}c
81        pub span: Span,
82    }
83
84    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
85    pub struct VmadDtypeAtypeBtypePoSatScale {
86        pub dtype: Dtype,         // .dtype
87        pub atype: Atype,         // .atype
88        pub btype: Btype,         // .btype
89        pub po: (),               // .po
90        pub sat: bool,            // {.sat}
91        pub scale: Option<Scale>, // {.scale}
92        pub d: GeneralOperand,    // d
93        pub a: GeneralOperand,    // a
94        pub asel: Option<Asel>,   // {.asel}
95        pub b: GeneralOperand,    // b
96        pub bsel: Option<Bsel>,   // {.bsel}
97        pub c: GeneralOperand,    // c
98        pub span: Span,
99    }
100}
101
102// Re-export types with section suffixes to avoid naming conflicts
103// e.g., Type0 for section_0::Type, Type1 for section_1::Type
104pub use section_0::Asel as Asel0;
105pub use section_0::Atype as Atype0;
106pub use section_0::Bsel as Bsel0;
107pub use section_0::Btype as Btype0;
108pub use section_0::Dtype as Dtype0;
109pub use section_0::Scale as Scale0;
110pub use section_0::VmadDtypeAtypeBtypePoSatScale;
111pub use section_0::VmadDtypeAtypeBtypeSatScale;