Skip to main content

ptx_parser/type/instruction/
mul.rs

1//! Original PTX specification:
2//!
3//! mul.mode.type  d, a, b;
4//! .mode = { .hi, .lo, .wide };
5//! .type = { .u16, .u32, .u64,
6//! .s16, .s32, .s64 };
7//! --------------------------------------------
8//! mul{.rnd}{.ftz}{.sat}.f32  d, a, b;
9//! mul{.rnd}{.ftz}.f32x2      d, a, b;
10//! mul{.rnd}.f64              d, a, b;
11//! .rnd = { .rn, .rz, .rm, .rp };
12//! --------------------------------------------
13//! mul{.rnd}{.ftz}{.sat}.f16   d, a, b;
14//! mul{.rnd}{.ftz}{.sat}.f16x2 d, a, b;
15//! mul{.rnd}.bf16   d, a, b;
16//! mul{.rnd}.bf16x2 d, a, b;
17//! .rnd = { .rn };
18
19#![allow(unused)]
20use crate::r#type::common::*;
21
22pub mod section_0 {
23    use crate::Spanned;
24    use crate::parser::Span;
25    use crate::r#type::common::*;
26
27    use serde::Serialize;
28
29    #[derive(Debug, Clone, PartialEq, Serialize)]
30    pub enum Mode {
31        Wide, // .wide
32        Hi,   // .hi
33        Lo,   // .lo
34    }
35
36    #[derive(Debug, Clone, PartialEq, Serialize)]
37    pub enum Type {
38        U16, // .u16
39        U32, // .u32
40        U64, // .u64
41        S16, // .s16
42        S32, // .s32
43        S64, // .s64
44    }
45
46    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
47    pub struct MulModeType {
48        pub mode: Mode,        // .mode
49        pub type_: Type,       // .type
50        pub d: GeneralOperand, // d
51        pub a: GeneralOperand, // a
52        pub b: GeneralOperand, // b
53        pub span: Span,
54    }
55}
56
57pub mod section_1 {
58    use crate::Spanned;
59    use crate::parser::Span;
60    use crate::r#type::common::*;
61
62    use serde::Serialize;
63
64    #[derive(Debug, Clone, PartialEq, Serialize)]
65    pub enum Rnd {
66        Rn, // .rn
67        Rz, // .rz
68        Rm, // .rm
69        Rp, // .rp
70    }
71
72    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
73    pub struct MulRndFtzSatF32 {
74        pub rnd: Option<Rnd>,  // {.rnd}
75        pub ftz: bool,         // {.ftz}
76        pub sat: bool,         // {.sat}
77        pub f32: (),           // .f32
78        pub d: GeneralOperand, // d
79        pub a: GeneralOperand, // a
80        pub b: GeneralOperand, // b
81        pub span: Span,
82    }
83
84    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
85    pub struct MulRndFtzF32x2 {
86        pub rnd: Option<Rnd>,  // {.rnd}
87        pub ftz: bool,         // {.ftz}
88        pub f32x2: (),         // .f32x2
89        pub d: GeneralOperand, // d
90        pub a: GeneralOperand, // a
91        pub b: GeneralOperand, // b
92        pub span: Span,
93    }
94
95    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
96    pub struct MulRndF64 {
97        pub rnd: Option<Rnd>,  // {.rnd}
98        pub f64: (),           // .f64
99        pub d: GeneralOperand, // d
100        pub a: GeneralOperand, // a
101        pub b: GeneralOperand, // b
102        pub span: Span,
103    }
104}
105
106pub mod section_2 {
107    use crate::Spanned;
108    use crate::parser::Span;
109    use crate::r#type::common::*;
110
111    use serde::Serialize;
112
113    #[derive(Debug, Clone, PartialEq, Serialize)]
114    pub enum Rnd {
115        Rn, // .rn
116    }
117
118    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
119    pub struct MulRndFtzSatF16 {
120        pub rnd: Option<Rnd>,  // {.rnd}
121        pub ftz: bool,         // {.ftz}
122        pub sat: bool,         // {.sat}
123        pub f16: (),           // .f16
124        pub d: GeneralOperand, // d
125        pub a: GeneralOperand, // a
126        pub b: GeneralOperand, // b
127        pub span: Span,
128    }
129
130    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
131    pub struct MulRndFtzSatF16x2 {
132        pub rnd: Option<Rnd>,  // {.rnd}
133        pub ftz: bool,         // {.ftz}
134        pub sat: bool,         // {.sat}
135        pub f16x2: (),         // .f16x2
136        pub d: GeneralOperand, // d
137        pub a: GeneralOperand, // a
138        pub b: GeneralOperand, // b
139        pub span: Span,
140    }
141
142    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
143    pub struct MulRndBf16 {
144        pub rnd: Option<Rnd>,  // {.rnd}
145        pub bf16: (),          // .bf16
146        pub d: GeneralOperand, // d
147        pub a: GeneralOperand, // a
148        pub b: GeneralOperand, // b
149        pub span: Span,
150    }
151
152    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
153    pub struct MulRndBf16x2 {
154        pub rnd: Option<Rnd>,  // {.rnd}
155        pub bf16x2: (),        // .bf16x2
156        pub d: GeneralOperand, // d
157        pub a: GeneralOperand, // a
158        pub b: GeneralOperand, // b
159        pub span: Span,
160    }
161}
162
163// Re-export types with section suffixes to avoid naming conflicts
164// e.g., Type0 for section_0::Type, Type1 for section_1::Type
165pub use section_0::Mode as Mode0;
166pub use section_0::MulModeType;
167pub use section_0::Type as Type0;
168pub use section_1::MulRndF64;
169pub use section_1::MulRndFtzF32x2;
170pub use section_1::MulRndFtzSatF32;
171pub use section_1::Rnd as Rnd1;
172pub use section_2::MulRndBf16;
173pub use section_2::MulRndBf16x2;
174pub use section_2::MulRndFtzSatF16;
175pub use section_2::MulRndFtzSatF16x2;
176pub use section_2::Rnd as Rnd2;