Skip to main content

ptx_parser/type/instruction/
fma.rs

1//! Original PTX specification:
2//!
3//! fma.rnd{.ftz}{.sat}.f32  d, a, b, c;
4//! fma.rnd{.ftz}.f32x2      d, a, b, c;
5//! fma.rnd.f64              d, a, b, c;
6//! .rnd = { .rn, .rz, .rm, .rp };
7//! ---------------------------------------------
8//! fma.rnd{.ftz}{.sat}.f16     d, a, b, c;
9//! fma.rnd{.ftz}{.sat}.f16x2   d, a, b, c;
10//! fma.rnd{.ftz}.relu.f16      d, a, b, c;
11//! fma.rnd{.ftz}.relu.f16x2    d, a, b, c;
12//! fma.rnd{.relu}.bf16         d, a, b, c;
13//! fma.rnd{.relu}.bf16x2       d, a, b, c;
14//! fma.rnd.oob{.relu}.type     d, a, b, c;
15//! .rnd = { .rn };
16//! ---------------------------------------------
17//! fma.rnd{.sat}.f32.abtype  d, a, b, c;
18//! .abtype = { .f16, .bf16};
19//! .rnd    = { .rn, .rz, .rm, .rp };
20
21#![allow(unused)]
22use crate::r#type::common::*;
23
24pub mod section_0 {
25    use crate::Spanned;
26    use crate::parser::Span;
27    use crate::r#type::common::*;
28
29    use serde::Serialize;
30
31    #[derive(Debug, Clone, PartialEq, Serialize)]
32    pub enum Rnd {
33        Rn, // .rn
34        Rz, // .rz
35        Rm, // .rm
36        Rp, // .rp
37    }
38
39    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
40    pub struct FmaRndFtzSatF32 {
41        pub rnd: Rnd,          // .rnd
42        pub ftz: bool,         // {.ftz}
43        pub sat: bool,         // {.sat}
44        pub f32: (),           // .f32
45        pub d: GeneralOperand, // d
46        pub a: GeneralOperand, // a
47        pub b: GeneralOperand, // b
48        pub c: GeneralOperand, // c
49        pub span: Span,
50    }
51
52    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
53    pub struct FmaRndFtzF32x2 {
54        pub rnd: Rnd,          // .rnd
55        pub ftz: bool,         // {.ftz}
56        pub f32x2: (),         // .f32x2
57        pub d: GeneralOperand, // d
58        pub a: GeneralOperand, // a
59        pub b: GeneralOperand, // b
60        pub c: GeneralOperand, // c
61        pub span: Span,
62    }
63
64    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
65    pub struct FmaRndF64 {
66        pub rnd: Rnd,          // .rnd
67        pub f64: (),           // .f64
68        pub d: GeneralOperand, // d
69        pub a: GeneralOperand, // a
70        pub b: GeneralOperand, // b
71        pub c: GeneralOperand, // c
72        pub span: Span,
73    }
74}
75
76pub mod section_1 {
77    use crate::Spanned;
78    use crate::parser::Span;
79    use crate::r#type::common::*;
80
81    use serde::Serialize;
82
83    #[derive(Debug, Clone, PartialEq, Serialize)]
84    pub enum Rnd {
85        Rn, // .rn
86    }
87
88    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
89    pub struct FmaRndFtzSatF16 {
90        pub rnd: Rnd,          // .rnd
91        pub ftz: bool,         // {.ftz}
92        pub sat: bool,         // {.sat}
93        pub f16: (),           // .f16
94        pub d: GeneralOperand, // d
95        pub a: GeneralOperand, // a
96        pub b: GeneralOperand, // b
97        pub c: GeneralOperand, // c
98        pub span: Span,
99    }
100
101    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
102    pub struct FmaRndFtzSatF16x2 {
103        pub rnd: Rnd,          // .rnd
104        pub ftz: bool,         // {.ftz}
105        pub sat: bool,         // {.sat}
106        pub f16x2: (),         // .f16x2
107        pub d: GeneralOperand, // d
108        pub a: GeneralOperand, // a
109        pub b: GeneralOperand, // b
110        pub c: GeneralOperand, // c
111        pub span: Span,
112    }
113
114    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
115    pub struct FmaRndFtzReluF16 {
116        pub rnd: Rnd,          // .rnd
117        pub ftz: bool,         // {.ftz}
118        pub relu: (),          // .relu
119        pub f16: (),           // .f16
120        pub d: GeneralOperand, // d
121        pub a: GeneralOperand, // a
122        pub b: GeneralOperand, // b
123        pub c: GeneralOperand, // c
124        pub span: Span,
125    }
126
127    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
128    pub struct FmaRndFtzReluF16x2 {
129        pub rnd: Rnd,          // .rnd
130        pub ftz: bool,         // {.ftz}
131        pub relu: (),          // .relu
132        pub f16x2: (),         // .f16x2
133        pub d: GeneralOperand, // d
134        pub a: GeneralOperand, // a
135        pub b: GeneralOperand, // b
136        pub c: GeneralOperand, // c
137        pub span: Span,
138    }
139
140    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
141    pub struct FmaRndReluBf16 {
142        pub rnd: Rnd,          // .rnd
143        pub relu: bool,        // {.relu}
144        pub bf16: (),          // .bf16
145        pub d: GeneralOperand, // d
146        pub a: GeneralOperand, // a
147        pub b: GeneralOperand, // b
148        pub c: GeneralOperand, // c
149        pub span: Span,
150    }
151
152    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
153    pub struct FmaRndReluBf16x2 {
154        pub rnd: Rnd,          // .rnd
155        pub relu: bool,        // {.relu}
156        pub bf16x2: (),        // .bf16x2
157        pub d: GeneralOperand, // d
158        pub a: GeneralOperand, // a
159        pub b: GeneralOperand, // b
160        pub c: GeneralOperand, // c
161        pub span: Span,
162    }
163
164    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
165    pub struct FmaRndOobReluType {
166        pub rnd: Rnd,          // .rnd
167        pub oob: (),           // .oob
168        pub relu: bool,        // {.relu}
169        pub type_: (),         // .type
170        pub d: GeneralOperand, // d
171        pub a: GeneralOperand, // a
172        pub b: GeneralOperand, // b
173        pub c: GeneralOperand, // c
174        pub span: Span,
175    }
176}
177
178pub mod section_2 {
179    use crate::Spanned;
180    use crate::parser::Span;
181    use crate::r#type::common::*;
182
183    use serde::Serialize;
184
185    #[derive(Debug, Clone, PartialEq, Serialize)]
186    pub enum Rnd {
187        Rn, // .rn
188        Rz, // .rz
189        Rm, // .rm
190        Rp, // .rp
191    }
192
193    #[derive(Debug, Clone, PartialEq, Serialize)]
194    pub enum Abtype {
195        Bf16, // .bf16
196        F16,  // .f16
197    }
198
199    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
200    pub struct FmaRndSatF32Abtype {
201        pub rnd: Rnd,          // .rnd
202        pub sat: bool,         // {.sat}
203        pub f32: (),           // .f32
204        pub abtype: Abtype,    // .abtype
205        pub d: GeneralOperand, // d
206        pub a: GeneralOperand, // a
207        pub b: GeneralOperand, // b
208        pub c: GeneralOperand, // c
209        pub span: Span,
210    }
211}
212
213// Re-export types with section suffixes to avoid naming conflicts
214// e.g., Type0 for section_0::Type, Type1 for section_1::Type
215pub use section_0::FmaRndF64;
216pub use section_0::FmaRndFtzF32x2;
217pub use section_0::FmaRndFtzSatF32;
218pub use section_0::Rnd as Rnd0;
219pub use section_1::FmaRndFtzReluF16;
220pub use section_1::FmaRndFtzReluF16x2;
221pub use section_1::FmaRndFtzSatF16;
222pub use section_1::FmaRndFtzSatF16x2;
223pub use section_1::FmaRndOobReluType;
224pub use section_1::FmaRndReluBf16;
225pub use section_1::FmaRndReluBf16x2;
226pub use section_1::Rnd as Rnd1;
227pub use section_2::Abtype as Abtype2;
228pub use section_2::FmaRndSatF32Abtype;
229pub use section_2::Rnd as Rnd2;