Skip to main content

ptx_parser/type/instruction/
cvt.rs

1//! Original PTX specification:
2//!
3//! cvt{.irnd}{.ftz}{.sat}.dtype.atype         d, a;  // integer rounding
4//! cvt{.frnd}{.ftz}{.sat}.dtype.atype         d, a;  // fp rounding
5//! cvt.frnd2{.relu}{.satfinite}.f16.f32       d, a;
6//! cvt.frnd2{.relu}{.satfinite}.f16x2.f32     d, a, b;
7//! cvt.rs{.relu}{.satfinite}.f16x2.f32        d, a, b, rbits;
8//! cvt.frnd2{.relu}{.satfinite}.bf16.f32      d, a;
9//! cvt.frnd2{.relu}{.satfinite}.bf16x2.f32    d, a, b;
10//! cvt.rs{.relu}{.satfinite}.bf16x2.f32       d, a, b, rbits;
11//! cvt.rna{.satfinite}.tf32.f32               d, a;
12//! cvt.frnd2{.satfinite}{.relu}.tf32.f32      d, a;
13//! cvt.rn.satfinite{.relu}.f8x2type.f32       d, a, b;
14//! cvt.rn.satfinite{.relu}.f8x2type.f16x2     d, a;
15//! cvt.rn{.relu}.f16x2.f8x2type              d, a;
16//! cvt.rs{.relu}.satfinite.f8x4type.f32       d, {a, b, e, f}, rbits;
17//! cvt.rn.satfinite{.relu}.f4x2type.f32       d, a, b;
18//! cvt.rn{.relu}.f16x2.f4x2type               d, a;
19//! cvt.rs{.relu}.satfinite.f4x4type.f32       d, {a, b, e, f}, rbits;
20//! cvt.rn.satfinite{.relu}.f6x2type.f32       d, a, b;
21//! cvt.rn{.relu}.f16x2.f6x2type               d, a;
22//! cvt.rs{.relu}.satfinite.f6x4type.f32       d, {a, b, e, f}, rbits;
23//! cvt.frnd3{.satfinite}.ue8m0x2.f32          d, a, b;
24//! cvt.frnd3{.satfinite}.ue8m0x2.bf16x2       d, a;
25//! cvt.rn.bf16x2.ue8m0x2                      d, a;
26//! .irnd   = { .rni, .rzi, .rmi, .rpi };
27//! .frnd   = { .rn,  .rz,  .rm,  .rp  };
28//! .frnd2  = { .rn,  .rz };
29//! .frnd3  = { .rz,  .rp };
30//! .dtype = .atype = { .u8,   .u16, .u32, .u64,
31//! .s8,   .s16, .s32, .s64,
32//! .bf16, .f16, .f32, .f64 };
33//! .f8x2type = { .e4m3x2, .e5m2x2 };
34//! .f4x2type = { .e2m1x2 };
35//! .f6x2type = { .e2m3x2, .e3m2x2 };
36//! .f4x4type = { .e2m1x4 };
37//! .f8x4type = { .e4m3x4, .e5m2x4 };
38//! .f6x4type = { .e2m3x4, .e3m2x4 };
39
40#![allow(unused)]
41use crate::r#type::common::*;
42
43pub mod section_0 {
44    use crate::Spanned;
45    use crate::parser::Span;
46    use crate::r#type::common::*;
47
48    use serde::Serialize;
49
50    #[derive(Debug, Clone, PartialEq, Serialize)]
51    pub enum Irnd {
52        Rni, // .rni
53        Rzi, // .rzi
54        Rmi, // .rmi
55        Rpi, // .rpi
56    }
57
58    #[derive(Debug, Clone, PartialEq, Serialize)]
59    pub enum Dtype {
60        Bf16, // .bf16
61        U16,  // .u16
62        U32,  // .u32
63        U64,  // .u64
64        S16,  // .s16
65        S32,  // .s32
66        S64,  // .s64
67        F16,  // .f16
68        F32,  // .f32
69        F64,  // .f64
70        U8,   // .u8
71        S8,   // .s8
72    }
73
74    #[derive(Debug, Clone, PartialEq, Serialize)]
75    pub enum Atype {
76        Bf16, // .bf16
77        U16,  // .u16
78        U32,  // .u32
79        U64,  // .u64
80        S16,  // .s16
81        S32,  // .s32
82        S64,  // .s64
83        F16,  // .f16
84        F32,  // .f32
85        F64,  // .f64
86        U8,   // .u8
87        S8,   // .s8
88    }
89
90    #[derive(Debug, Clone, PartialEq, Serialize)]
91    pub enum Frnd {
92        Rn, // .rn
93        Rz, // .rz
94        Rm, // .rm
95        Rp, // .rp
96    }
97
98    #[derive(Debug, Clone, PartialEq, Serialize)]
99    pub enum Frnd2 {
100        Rn, // .rn
101        Rz, // .rz
102    }
103
104    #[derive(Debug, Clone, PartialEq, Serialize)]
105    pub enum F8x2type {
106        E4m3x2, // .e4m3x2
107        E5m2x2, // .e5m2x2
108    }
109
110    #[derive(Debug, Clone, PartialEq, Serialize)]
111    pub enum F8x4type {
112        E4m3x4, // .e4m3x4
113        E5m2x4, // .e5m2x4
114    }
115
116    #[derive(Debug, Clone, PartialEq, Serialize)]
117    pub enum F4x2type {
118        E2m1x2, // .e2m1x2
119    }
120
121    #[derive(Debug, Clone, PartialEq, Serialize)]
122    pub enum F4x4type {
123        E2m1x4, // .e2m1x4
124    }
125
126    #[derive(Debug, Clone, PartialEq, Serialize)]
127    pub enum F6x2type {
128        E2m3x2, // .e2m3x2
129        E3m2x2, // .e3m2x2
130    }
131
132    #[derive(Debug, Clone, PartialEq, Serialize)]
133    pub enum F6x4type {
134        E2m3x4, // .e2m3x4
135        E3m2x4, // .e3m2x4
136    }
137
138    #[derive(Debug, Clone, PartialEq, Serialize)]
139    pub enum Frnd3 {
140        Rz, // .rz
141        Rp, // .rp
142    }
143
144    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
145    pub struct CvtIrndFtzSatDtypeAtype {
146        pub irnd: Option<Irnd>, // {.irnd}
147        pub ftz: bool,          // {.ftz}
148        pub sat: bool,          // {.sat}
149        pub dtype: Dtype,       // .dtype
150        pub atype: Atype,       // .atype
151        pub d: GeneralOperand,  // d
152        pub a: GeneralOperand,  // a
153        pub span: Span,
154    }
155
156    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
157    pub struct CvtFrndFtzSatDtypeAtype {
158        pub frnd: Option<Frnd>, // {.frnd}
159        pub ftz: bool,          // {.ftz}
160        pub sat: bool,          // {.sat}
161        pub dtype: Dtype,       // .dtype
162        pub atype: Atype,       // .atype
163        pub d: GeneralOperand,  // d
164        pub a: GeneralOperand,  // a
165        pub span: Span,
166    }
167
168    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
169    pub struct CvtFrnd2ReluSatfiniteF16F32 {
170        pub frnd2: Frnd2,      // .frnd2
171        pub relu: bool,        // {.relu}
172        pub satfinite: bool,   // {.satfinite}
173        pub f16: (),           // .f16
174        pub f32: (),           // .f32
175        pub d: GeneralOperand, // d
176        pub a: GeneralOperand, // a
177        pub span: Span,
178    }
179
180    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
181    pub struct CvtFrnd2ReluSatfiniteF16x2F32 {
182        pub frnd2: Frnd2,      // .frnd2
183        pub relu: bool,        // {.relu}
184        pub satfinite: bool,   // {.satfinite}
185        pub f16x2: (),         // .f16x2
186        pub f32: (),           // .f32
187        pub d: GeneralOperand, // d
188        pub a: GeneralOperand, // a
189        pub b: GeneralOperand, // b
190        pub span: Span,
191    }
192
193    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
194    pub struct CvtRsReluSatfiniteF16x2F32 {
195        pub rs: (),                // .rs
196        pub relu: bool,            // {.relu}
197        pub satfinite: bool,       // {.satfinite}
198        pub f16x2: (),             // .f16x2
199        pub f32: (),               // .f32
200        pub d: GeneralOperand,     // d
201        pub a: GeneralOperand,     // a
202        pub b: GeneralOperand,     // b
203        pub rbits: GeneralOperand, // rbits
204        pub span: Span,
205    }
206
207    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
208    pub struct CvtFrnd2ReluSatfiniteBf16F32 {
209        pub frnd2: Frnd2,      // .frnd2
210        pub relu: bool,        // {.relu}
211        pub satfinite: bool,   // {.satfinite}
212        pub bf16: (),          // .bf16
213        pub f32: (),           // .f32
214        pub d: GeneralOperand, // d
215        pub a: GeneralOperand, // a
216        pub span: Span,
217    }
218
219    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
220    pub struct CvtFrnd2ReluSatfiniteBf16x2F32 {
221        pub frnd2: Frnd2,      // .frnd2
222        pub relu: bool,        // {.relu}
223        pub satfinite: bool,   // {.satfinite}
224        pub bf16x2: (),        // .bf16x2
225        pub f32: (),           // .f32
226        pub d: GeneralOperand, // d
227        pub a: GeneralOperand, // a
228        pub b: GeneralOperand, // b
229        pub span: Span,
230    }
231
232    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
233    pub struct CvtRsReluSatfiniteBf16x2F32 {
234        pub rs: (),                // .rs
235        pub relu: bool,            // {.relu}
236        pub satfinite: bool,       // {.satfinite}
237        pub bf16x2: (),            // .bf16x2
238        pub f32: (),               // .f32
239        pub d: GeneralOperand,     // d
240        pub a: GeneralOperand,     // a
241        pub b: GeneralOperand,     // b
242        pub rbits: GeneralOperand, // rbits
243        pub span: Span,
244    }
245
246    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
247    pub struct CvtRnaSatfiniteTf32F32 {
248        pub rna: (),           // .rna
249        pub satfinite: bool,   // {.satfinite}
250        pub tf32: (),          // .tf32
251        pub f32: (),           // .f32
252        pub d: GeneralOperand, // d
253        pub a: GeneralOperand, // a
254        pub span: Span,
255    }
256
257    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
258    pub struct CvtFrnd2SatfiniteReluTf32F32 {
259        pub frnd2: Frnd2,      // .frnd2
260        pub satfinite: bool,   // {.satfinite}
261        pub relu: bool,        // {.relu}
262        pub tf32: (),          // .tf32
263        pub f32: (),           // .f32
264        pub d: GeneralOperand, // d
265        pub a: GeneralOperand, // a
266        pub span: Span,
267    }
268
269    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
270    pub struct CvtRnSatfiniteReluF8x2typeF32 {
271        pub rn: (),             // .rn
272        pub satfinite: (),      // .satfinite
273        pub relu: bool,         // {.relu}
274        pub f8x2type: F8x2type, // .f8x2type
275        pub f32: (),            // .f32
276        pub d: GeneralOperand,  // d
277        pub a: GeneralOperand,  // a
278        pub b: GeneralOperand,  // b
279        pub span: Span,
280    }
281
282    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
283    pub struct CvtRnSatfiniteReluF8x2typeF16x2 {
284        pub rn: (),             // .rn
285        pub satfinite: (),      // .satfinite
286        pub relu: bool,         // {.relu}
287        pub f8x2type: F8x2type, // .f8x2type
288        pub f16x2: (),          // .f16x2
289        pub d: GeneralOperand,  // d
290        pub a: GeneralOperand,  // a
291        pub span: Span,
292    }
293
294    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
295    pub struct CvtRnReluF16x2F8x2type {
296        pub rn: (),             // .rn
297        pub relu: bool,         // {.relu}
298        pub f16x2: (),          // .f16x2
299        pub f8x2type: F8x2type, // .f8x2type
300        pub d: GeneralOperand,  // d
301        pub a: GeneralOperand,  // a
302        pub span: Span,
303    }
304
305    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
306    pub struct CvtRsReluSatfiniteF8x4typeF32 {
307        pub rs: (),                // .rs
308        pub relu: bool,            // {.relu}
309        pub satfinite: (),         // .satfinite
310        pub f8x4type: F8x4type,    // .f8x4type
311        pub f32: (),               // .f32
312        pub d: GeneralOperand,     // d
313        pub a: VectorOperand,      // {a, b, e, f}
314        pub rbits: GeneralOperand, // rbits
315        pub span: Span,
316    }
317
318    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
319    pub struct CvtRnSatfiniteReluF4x2typeF32 {
320        pub rn: (),             // .rn
321        pub satfinite: (),      // .satfinite
322        pub relu: bool,         // {.relu}
323        pub f4x2type: F4x2type, // .f4x2type
324        pub f32: (),            // .f32
325        pub d: GeneralOperand,  // d
326        pub a: GeneralOperand,  // a
327        pub b: GeneralOperand,  // b
328        pub span: Span,
329    }
330
331    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
332    pub struct CvtRnReluF16x2F4x2type {
333        pub rn: (),             // .rn
334        pub relu: bool,         // {.relu}
335        pub f16x2: (),          // .f16x2
336        pub f4x2type: F4x2type, // .f4x2type
337        pub d: GeneralOperand,  // d
338        pub a: GeneralOperand,  // a
339        pub span: Span,
340    }
341
342    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
343    pub struct CvtRsReluSatfiniteF4x4typeF32 {
344        pub rs: (),                // .rs
345        pub relu: bool,            // {.relu}
346        pub satfinite: (),         // .satfinite
347        pub f4x4type: F4x4type,    // .f4x4type
348        pub f32: (),               // .f32
349        pub d: GeneralOperand,     // d
350        pub a: VectorOperand,      // {a, b, e, f}
351        pub rbits: GeneralOperand, // rbits
352        pub span: Span,
353    }
354
355    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
356    pub struct CvtRnSatfiniteReluF6x2typeF32 {
357        pub rn: (),             // .rn
358        pub satfinite: (),      // .satfinite
359        pub relu: bool,         // {.relu}
360        pub f6x2type: F6x2type, // .f6x2type
361        pub f32: (),            // .f32
362        pub d: GeneralOperand,  // d
363        pub a: GeneralOperand,  // a
364        pub b: GeneralOperand,  // b
365        pub span: Span,
366    }
367
368    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
369    pub struct CvtRnReluF16x2F6x2type {
370        pub rn: (),             // .rn
371        pub relu: bool,         // {.relu}
372        pub f16x2: (),          // .f16x2
373        pub f6x2type: F6x2type, // .f6x2type
374        pub d: GeneralOperand,  // d
375        pub a: GeneralOperand,  // a
376        pub span: Span,
377    }
378
379    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
380    pub struct CvtRsReluSatfiniteF6x4typeF32 {
381        pub rs: (),                // .rs
382        pub relu: bool,            // {.relu}
383        pub satfinite: (),         // .satfinite
384        pub f6x4type: F6x4type,    // .f6x4type
385        pub f32: (),               // .f32
386        pub d: GeneralOperand,     // d
387        pub a: VectorOperand,      // {a, b, e, f}
388        pub rbits: GeneralOperand, // rbits
389        pub span: Span,
390    }
391
392    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
393    pub struct CvtFrnd3SatfiniteUe8m0x2F32 {
394        pub frnd3: Frnd3,      // .frnd3
395        pub satfinite: bool,   // {.satfinite}
396        pub ue8m0x2: (),       // .ue8m0x2
397        pub f32: (),           // .f32
398        pub d: GeneralOperand, // d
399        pub a: GeneralOperand, // a
400        pub b: GeneralOperand, // b
401        pub span: Span,
402    }
403
404    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
405    pub struct CvtFrnd3SatfiniteUe8m0x2Bf16x2 {
406        pub frnd3: Frnd3,      // .frnd3
407        pub satfinite: bool,   // {.satfinite}
408        pub ue8m0x2: (),       // .ue8m0x2
409        pub bf16x2: (),        // .bf16x2
410        pub d: GeneralOperand, // d
411        pub a: GeneralOperand, // a
412        pub span: Span,
413    }
414
415    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
416    pub struct CvtRnBf16x2Ue8m0x2 {
417        pub rn: (),            // .rn
418        pub bf16x2: (),        // .bf16x2
419        pub ue8m0x2: (),       // .ue8m0x2
420        pub d: GeneralOperand, // d
421        pub a: GeneralOperand, // a
422        pub span: Span,
423    }
424}
425
426// Re-export types with section suffixes to avoid naming conflicts
427// e.g., Type0 for section_0::Type, Type1 for section_1::Type
428pub use section_0::Atype as Atype0;
429pub use section_0::CvtFrnd2ReluSatfiniteBf16F32;
430pub use section_0::CvtFrnd2ReluSatfiniteBf16x2F32;
431pub use section_0::CvtFrnd2ReluSatfiniteF16F32;
432pub use section_0::CvtFrnd2ReluSatfiniteF16x2F32;
433pub use section_0::CvtFrnd2SatfiniteReluTf32F32;
434pub use section_0::CvtFrnd3SatfiniteUe8m0x2Bf16x2;
435pub use section_0::CvtFrnd3SatfiniteUe8m0x2F32;
436pub use section_0::CvtFrndFtzSatDtypeAtype;
437pub use section_0::CvtIrndFtzSatDtypeAtype;
438pub use section_0::CvtRnBf16x2Ue8m0x2;
439pub use section_0::CvtRnReluF16x2F4x2type;
440pub use section_0::CvtRnReluF16x2F6x2type;
441pub use section_0::CvtRnReluF16x2F8x2type;
442pub use section_0::CvtRnSatfiniteReluF4x2typeF32;
443pub use section_0::CvtRnSatfiniteReluF6x2typeF32;
444pub use section_0::CvtRnSatfiniteReluF8x2typeF16x2;
445pub use section_0::CvtRnSatfiniteReluF8x2typeF32;
446pub use section_0::CvtRnaSatfiniteTf32F32;
447pub use section_0::CvtRsReluSatfiniteBf16x2F32;
448pub use section_0::CvtRsReluSatfiniteF4x4typeF32;
449pub use section_0::CvtRsReluSatfiniteF6x4typeF32;
450pub use section_0::CvtRsReluSatfiniteF8x4typeF32;
451pub use section_0::CvtRsReluSatfiniteF16x2F32;
452pub use section_0::Dtype as Dtype0;
453pub use section_0::F4x2type as F4x2type0;
454pub use section_0::F4x4type as F4x4type0;
455pub use section_0::F6x2type as F6x2type0;
456pub use section_0::F6x4type as F6x4type0;
457pub use section_0::F8x2type as F8x2type0;
458pub use section_0::F8x4type as F8x4type0;
459pub use section_0::Frnd as Frnd0;
460pub use section_0::Frnd2 as Frnd20;
461pub use section_0::Frnd3 as Frnd30;
462pub use section_0::Irnd as Irnd0;