Skip to main content

ptx_parser/type/instruction/
set.rs

1//! Original PTX specification:
2//!
3//! set.CmpOp{.ftz}.dtype.stype         d, a, b;
4//! set.CmpOp.BoolOp{.ftz}.dtype.stype  d, a, b, {!}c;
5//! .CmpOp  = { .eq, .ne, .lt, .le, .gt, .ge, .lo, .ls, .hi, .hs,
6//! .equ, .neu, .ltu, .leu, .gtu, .geu, .num, .nan };
7//! .BoolOp = { .and, .or, .xor };
8//! .dtype  = { .u32, .s32, .f32 };
9//! .stype  = { .b16, .b32, .b64,
10//! .u16, .u32, .u64,
11//! .s16, .s32, .s64,
12//! .f32, .f64 };
13//! -------------------------------------------------------------
14//! set.CmpOp{.ftz}.f16.stype            d, a, b;
15//! set.CmpOp.BoolOp{.ftz}.f16.stype     d, a, b, {!}c;
16//! set.CmpOp.bf16.stype                 d, a, b;
17//! set.CmpOp.BoolOp.bf16.stype          d, a, b, {!}c;
18//! set.CmpOp{.ftz}.dtype.f16            d, a, b;
19//! set.CmpOp.BoolOp{.ftz}.dtype.f16     d, a, b, {!}c;
20//! .dtype  = { .u16, .s16, .u32, .s32};
21//! ----------------------------------------------------
22//! // Alternate floating point type:
23//! set.CmpOp.dtype.bf16                 d, a, b;
24//! set.CmpOp.BoolOp.dtype.bf16          d, a, b, {!}c;
25//! .dtype  = { .u16, .s16, .u32, .s32};
26//! ----------------------------------------------------
27//! // Alternate floating point type:
28//! set.CmpOp{.ftz}.dtype.f16x2          d, a, b;
29//! set.CmpOp.BoolOp{.ftz}.dtype.f16x2   d, a, b, {!}c;
30//! .dtype  = { .f16x2, .u32, .s32};
31//! ----------------------------------------------------
32//! // Alternate floating point type:
33//! set.CmpOp.dtype.bf16x2               d, a, b;
34//! set.CmpOp.BoolOp.dtype.bf16x2        d, a, b, {!}c;
35//! .dtype  = { .bf16x2, .u32, .s32};
36//! .CmpOp  = { .eq, .ne, .lt, .le, .gt, .ge,
37//! .equ, .neu, .ltu, .leu, .gtu, .geu, .num, .nan };
38//! .BoolOp = { .and, .or, .xor };
39//! .stype  = { .b16, .b32, .b64,
40//! .u16, .u32, .u64,
41//! .s16, .s32, .s64,
42//! .f16, .f32, .f64};
43
44#![allow(unused)]
45use crate::r#type::common::*;
46
47pub mod section_0 {
48    use crate::Spanned;
49    use crate::parser::Span;
50    use crate::r#type::common::*;
51
52    use serde::Serialize;
53
54    #[derive(Debug, Clone, PartialEq, Serialize)]
55    pub enum Cmpop {
56        Equ, // .equ
57        Neu, // .neu
58        Ltu, // .ltu
59        Leu, // .leu
60        Gtu, // .gtu
61        Geu, // .geu
62        Num, // .num
63        Nan, // .nan
64        Eq,  // .eq
65        Ne,  // .ne
66        Lt,  // .lt
67        Le,  // .le
68        Gt,  // .gt
69        Ge,  // .ge
70        Lo,  // .lo
71        Ls,  // .ls
72        Hi,  // .hi
73        Hs,  // .hs
74    }
75
76    #[derive(Debug, Clone, PartialEq, Serialize)]
77    pub enum Dtype {
78        U32, // .u32
79        S32, // .s32
80        F32, // .f32
81    }
82
83    #[derive(Debug, Clone, PartialEq, Serialize)]
84    pub enum Stype {
85        B16, // .b16
86        B32, // .b32
87        B64, // .b64
88        U16, // .u16
89        U32, // .u32
90        U64, // .u64
91        S16, // .s16
92        S32, // .s32
93        S64, // .s64
94        F32, // .f32
95        F64, // .f64
96    }
97
98    #[derive(Debug, Clone, PartialEq, Serialize)]
99    pub enum Boolop {
100        And, // .and
101        Xor, // .xor
102        Or,  // .or
103    }
104
105    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
106    pub struct SetCmpopFtzDtypeStype {
107        pub cmpop: Cmpop,      // .CmpOp
108        pub ftz: bool,         // {.ftz}
109        pub dtype: Dtype,      // .dtype
110        pub stype: Stype,      // .stype
111        pub d: GeneralOperand, // d
112        pub a: GeneralOperand, // a
113        pub b: GeneralOperand, // b
114        pub span: Span,
115    }
116
117    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
118    pub struct SetCmpopBoolopFtzDtypeStype {
119        pub cmpop: Cmpop,      // .CmpOp
120        pub boolop: Boolop,    // .BoolOp
121        pub ftz: bool,         // {.ftz}
122        pub dtype: Dtype,      // .dtype
123        pub stype: Stype,      // .stype
124        pub d: GeneralOperand, // d
125        pub a: GeneralOperand, // a
126        pub b: GeneralOperand, // b
127        pub c_op: bool,        // {!} operator
128        pub c: GeneralOperand, // {!}c
129        pub span: Span,
130    }
131}
132
133pub mod section_1 {
134    use crate::Spanned;
135    use crate::parser::Span;
136    use crate::r#type::common::*;
137
138    use serde::Serialize;
139
140    #[derive(Debug, Clone, PartialEq, Serialize)]
141    pub enum Cmpop {
142        Equ, // .equ
143        Neu, // .neu
144        Ltu, // .ltu
145        Leu, // .leu
146        Gtu, // .gtu
147        Geu, // .geu
148        Num, // .num
149        Nan, // .nan
150        Eq,  // .eq
151        Ne,  // .ne
152        Lt,  // .lt
153        Le,  // .le
154        Gt,  // .gt
155        Ge,  // .ge
156        Lo,  // .lo
157        Ls,  // .ls
158        Hi,  // .hi
159        Hs,  // .hs
160    }
161
162    #[derive(Debug, Clone, PartialEq, Serialize)]
163    pub enum Stype {
164        B16, // .b16
165        B32, // .b32
166        B64, // .b64
167        U16, // .u16
168        U32, // .u32
169        U64, // .u64
170        S16, // .s16
171        S32, // .s32
172        S64, // .s64
173        F32, // .f32
174        F64, // .f64
175    }
176
177    #[derive(Debug, Clone, PartialEq, Serialize)]
178    pub enum Boolop {
179        And, // .and
180        Xor, // .xor
181        Or,  // .or
182    }
183
184    #[derive(Debug, Clone, PartialEq, Serialize)]
185    pub enum Dtype {
186        U16, // .u16
187        S16, // .s16
188        U32, // .u32
189        S32, // .s32
190    }
191
192    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
193    pub struct SetCmpopFtzF16Stype {
194        pub cmpop: Cmpop,      // .CmpOp
195        pub ftz: bool,         // {.ftz}
196        pub f16: (),           // .f16
197        pub stype: Stype,      // .stype
198        pub d: GeneralOperand, // d
199        pub a: GeneralOperand, // a
200        pub b: GeneralOperand, // b
201        pub span: Span,
202    }
203
204    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
205    pub struct SetCmpopBoolopFtzF16Stype {
206        pub cmpop: Cmpop,      // .CmpOp
207        pub boolop: Boolop,    // .BoolOp
208        pub ftz: bool,         // {.ftz}
209        pub f16: (),           // .f16
210        pub stype: Stype,      // .stype
211        pub d: GeneralOperand, // d
212        pub a: GeneralOperand, // a
213        pub b: GeneralOperand, // b
214        pub c_op: bool,        // {!} operator
215        pub c: GeneralOperand, // {!}c
216        pub span: Span,
217    }
218
219    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
220    pub struct SetCmpopBf16Stype {
221        pub cmpop: Cmpop,      // .CmpOp
222        pub bf16: (),          // .bf16
223        pub stype: Stype,      // .stype
224        pub d: GeneralOperand, // d
225        pub a: GeneralOperand, // a
226        pub b: GeneralOperand, // b
227        pub span: Span,
228    }
229
230    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
231    pub struct SetCmpopBoolopBf16Stype {
232        pub cmpop: Cmpop,      // .CmpOp
233        pub boolop: Boolop,    // .BoolOp
234        pub bf16: (),          // .bf16
235        pub stype: Stype,      // .stype
236        pub d: GeneralOperand, // d
237        pub a: GeneralOperand, // a
238        pub b: GeneralOperand, // b
239        pub c_op: bool,        // {!} operator
240        pub c: GeneralOperand, // {!}c
241        pub span: Span,
242    }
243
244    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
245    pub struct SetCmpopFtzDtypeF16 {
246        pub cmpop: Cmpop,      // .CmpOp
247        pub ftz: bool,         // {.ftz}
248        pub dtype: Dtype,      // .dtype
249        pub f16: (),           // .f16
250        pub d: GeneralOperand, // d
251        pub a: GeneralOperand, // a
252        pub b: GeneralOperand, // b
253        pub span: Span,
254    }
255
256    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
257    pub struct SetCmpopBoolopFtzDtypeF16 {
258        pub cmpop: Cmpop,      // .CmpOp
259        pub boolop: Boolop,    // .BoolOp
260        pub ftz: bool,         // {.ftz}
261        pub dtype: Dtype,      // .dtype
262        pub f16: (),           // .f16
263        pub d: GeneralOperand, // d
264        pub a: GeneralOperand, // a
265        pub b: GeneralOperand, // b
266        pub c_op: bool,        // {!} operator
267        pub c: GeneralOperand, // {!}c
268        pub span: Span,
269    }
270}
271
272pub mod section_2 {
273    use crate::Spanned;
274    use crate::parser::Span;
275    use crate::r#type::common::*;
276
277    use serde::Serialize;
278
279    #[derive(Debug, Clone, PartialEq, Serialize)]
280    pub enum Cmpop {
281        Equ, // .equ
282        Neu, // .neu
283        Ltu, // .ltu
284        Leu, // .leu
285        Gtu, // .gtu
286        Geu, // .geu
287        Num, // .num
288        Nan, // .nan
289        Eq,  // .eq
290        Ne,  // .ne
291        Lt,  // .lt
292        Le,  // .le
293        Gt,  // .gt
294        Ge,  // .ge
295        Lo,  // .lo
296        Ls,  // .ls
297        Hi,  // .hi
298        Hs,  // .hs
299    }
300
301    #[derive(Debug, Clone, PartialEq, Serialize)]
302    pub enum Dtype {
303        U16, // .u16
304        S16, // .s16
305        U32, // .u32
306        S32, // .s32
307    }
308
309    #[derive(Debug, Clone, PartialEq, Serialize)]
310    pub enum Boolop {
311        And, // .and
312        Xor, // .xor
313        Or,  // .or
314    }
315
316    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
317    pub struct SetCmpopDtypeBf16 {
318        pub cmpop: Cmpop,      // .CmpOp
319        pub dtype: Dtype,      // .dtype
320        pub bf16: (),          // .bf16
321        pub d: GeneralOperand, // d
322        pub a: GeneralOperand, // a
323        pub b: GeneralOperand, // b
324        pub span: Span,
325    }
326
327    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
328    pub struct SetCmpopBoolopDtypeBf16 {
329        pub cmpop: Cmpop,      // .CmpOp
330        pub boolop: Boolop,    // .BoolOp
331        pub dtype: Dtype,      // .dtype
332        pub bf16: (),          // .bf16
333        pub d: GeneralOperand, // d
334        pub a: GeneralOperand, // a
335        pub b: GeneralOperand, // b
336        pub c_op: bool,        // {!} operator
337        pub c: GeneralOperand, // {!}c
338        pub span: Span,
339    }
340}
341
342pub mod section_3 {
343    use crate::Spanned;
344    use crate::parser::Span;
345    use crate::r#type::common::*;
346
347    use serde::Serialize;
348
349    #[derive(Debug, Clone, PartialEq, Serialize)]
350    pub enum Cmpop {
351        Equ, // .equ
352        Neu, // .neu
353        Ltu, // .ltu
354        Leu, // .leu
355        Gtu, // .gtu
356        Geu, // .geu
357        Num, // .num
358        Nan, // .nan
359        Eq,  // .eq
360        Ne,  // .ne
361        Lt,  // .lt
362        Le,  // .le
363        Gt,  // .gt
364        Ge,  // .ge
365        Lo,  // .lo
366        Ls,  // .ls
367        Hi,  // .hi
368        Hs,  // .hs
369    }
370
371    #[derive(Debug, Clone, PartialEq, Serialize)]
372    pub enum Dtype {
373        F16x2, // .f16x2
374        U32,   // .u32
375        S32,   // .s32
376    }
377
378    #[derive(Debug, Clone, PartialEq, Serialize)]
379    pub enum Boolop {
380        And, // .and
381        Xor, // .xor
382        Or,  // .or
383    }
384
385    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
386    pub struct SetCmpopFtzDtypeF16x2 {
387        pub cmpop: Cmpop,      // .CmpOp
388        pub ftz: bool,         // {.ftz}
389        pub dtype: Dtype,      // .dtype
390        pub f16x2: (),         // .f16x2
391        pub d: GeneralOperand, // d
392        pub a: GeneralOperand, // a
393        pub b: GeneralOperand, // b
394        pub span: Span,
395    }
396
397    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
398    pub struct SetCmpopBoolopFtzDtypeF16x2 {
399        pub cmpop: Cmpop,      // .CmpOp
400        pub boolop: Boolop,    // .BoolOp
401        pub ftz: bool,         // {.ftz}
402        pub dtype: Dtype,      // .dtype
403        pub f16x2: (),         // .f16x2
404        pub d: GeneralOperand, // d
405        pub a: GeneralOperand, // a
406        pub b: GeneralOperand, // b
407        pub c_op: bool,        // {!} operator
408        pub c: GeneralOperand, // {!}c
409        pub span: Span,
410    }
411}
412
413pub mod section_4 {
414    use crate::Spanned;
415    use crate::parser::Span;
416    use crate::r#type::common::*;
417
418    use serde::Serialize;
419
420    #[derive(Debug, Clone, PartialEq, Serialize)]
421    pub enum Cmpop {
422        Equ, // .equ
423        Neu, // .neu
424        Ltu, // .ltu
425        Leu, // .leu
426        Gtu, // .gtu
427        Geu, // .geu
428        Num, // .num
429        Nan, // .nan
430        Eq,  // .eq
431        Ne,  // .ne
432        Lt,  // .lt
433        Le,  // .le
434        Gt,  // .gt
435        Ge,  // .ge
436    }
437
438    #[derive(Debug, Clone, PartialEq, Serialize)]
439    pub enum Dtype {
440        Bf16x2, // .bf16x2
441        U32,    // .u32
442        S32,    // .s32
443    }
444
445    #[derive(Debug, Clone, PartialEq, Serialize)]
446    pub enum Boolop {
447        And, // .and
448        Xor, // .xor
449        Or,  // .or
450    }
451
452    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
453    pub struct SetCmpopDtypeBf16x2 {
454        pub cmpop: Cmpop,      // .CmpOp
455        pub dtype: Dtype,      // .dtype
456        pub bf16x2: (),        // .bf16x2
457        pub d: GeneralOperand, // d
458        pub a: GeneralOperand, // a
459        pub b: GeneralOperand, // b
460        pub span: Span,
461    }
462
463    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
464    pub struct SetCmpopBoolopDtypeBf16x2 {
465        pub cmpop: Cmpop,      // .CmpOp
466        pub boolop: Boolop,    // .BoolOp
467        pub dtype: Dtype,      // .dtype
468        pub bf16x2: (),        // .bf16x2
469        pub d: GeneralOperand, // d
470        pub a: GeneralOperand, // a
471        pub b: GeneralOperand, // b
472        pub c_op: bool,        // {!} operator
473        pub c: GeneralOperand, // {!}c
474        pub span: Span,
475    }
476}
477
478// Re-export types with section suffixes to avoid naming conflicts
479// e.g., Type0 for section_0::Type, Type1 for section_1::Type
480pub use section_0::Boolop as Boolop0;
481pub use section_0::Cmpop as Cmpop0;
482pub use section_0::Dtype as Dtype0;
483pub use section_0::SetCmpopBoolopFtzDtypeStype;
484pub use section_0::SetCmpopFtzDtypeStype;
485pub use section_0::Stype as Stype0;
486pub use section_1::Boolop as Boolop1;
487pub use section_1::Cmpop as Cmpop1;
488pub use section_1::Dtype as Dtype1;
489pub use section_1::SetCmpopBf16Stype;
490pub use section_1::SetCmpopBoolopBf16Stype;
491pub use section_1::SetCmpopBoolopFtzDtypeF16;
492pub use section_1::SetCmpopBoolopFtzF16Stype;
493pub use section_1::SetCmpopFtzDtypeF16;
494pub use section_1::SetCmpopFtzF16Stype;
495pub use section_1::Stype as Stype1;
496pub use section_2::Boolop as Boolop2;
497pub use section_2::Cmpop as Cmpop2;
498pub use section_2::Dtype as Dtype2;
499pub use section_2::SetCmpopBoolopDtypeBf16;
500pub use section_2::SetCmpopDtypeBf16;
501pub use section_3::Boolop as Boolop3;
502pub use section_3::Cmpop as Cmpop3;
503pub use section_3::Dtype as Dtype3;
504pub use section_3::SetCmpopBoolopFtzDtypeF16x2;
505pub use section_3::SetCmpopFtzDtypeF16x2;
506pub use section_4::Boolop as Boolop4;
507pub use section_4::Cmpop as Cmpop4;
508pub use section_4::Dtype as Dtype4;
509pub use section_4::SetCmpopBoolopDtypeBf16x2;
510pub use section_4::SetCmpopDtypeBf16x2;