Skip to main content

ptx_parser/type/instruction/
add.rs

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