ptx_parser/parser/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)]
45
46use crate::parser::{
47    PtxParseError, PtxParser, PtxTokenStream, Span,
48    util::{
49        between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
50        pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
51    },
52};
53use crate::r#type::common::*;
54use crate::{alt, ok, seq_n};
55
56pub mod section_0 {
57    use super::*;
58    use crate::r#type::instruction::set::section_0::*;
59
60    // ============================================================================
61    // Generated enum parsers
62    // ============================================================================
63
64    impl PtxParser for Boolop {
65        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
66            alt!(
67                map(string_p(".and"), |_, _span| Boolop::And),
68                map(string_p(".xor"), |_, _span| Boolop::Xor),
69                map(string_p(".or"), |_, _span| Boolop::Or)
70            )
71        }
72    }
73
74    impl PtxParser for Cmpop {
75        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
76            alt!(
77                map(string_p(".equ"), |_, _span| Cmpop::Equ),
78                map(string_p(".neu"), |_, _span| Cmpop::Neu),
79                map(string_p(".ltu"), |_, _span| Cmpop::Ltu),
80                map(string_p(".leu"), |_, _span| Cmpop::Leu),
81                map(string_p(".gtu"), |_, _span| Cmpop::Gtu),
82                map(string_p(".geu"), |_, _span| Cmpop::Geu),
83                map(string_p(".num"), |_, _span| Cmpop::Num),
84                map(string_p(".nan"), |_, _span| Cmpop::Nan),
85                map(string_p(".eq"), |_, _span| Cmpop::Eq),
86                map(string_p(".ne"), |_, _span| Cmpop::Ne),
87                map(string_p(".lt"), |_, _span| Cmpop::Lt),
88                map(string_p(".le"), |_, _span| Cmpop::Le),
89                map(string_p(".gt"), |_, _span| Cmpop::Gt),
90                map(string_p(".ge"), |_, _span| Cmpop::Ge),
91                map(string_p(".lo"), |_, _span| Cmpop::Lo),
92                map(string_p(".ls"), |_, _span| Cmpop::Ls),
93                map(string_p(".hi"), |_, _span| Cmpop::Hi),
94                map(string_p(".hs"), |_, _span| Cmpop::Hs)
95            )
96        }
97    }
98
99    impl PtxParser for Dtype {
100        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
101            alt!(
102                map(string_p(".u32"), |_, _span| Dtype::U32),
103                map(string_p(".s32"), |_, _span| Dtype::S32),
104                map(string_p(".f32"), |_, _span| Dtype::F32)
105            )
106        }
107    }
108
109    impl PtxParser for Stype {
110        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
111            alt!(
112                map(string_p(".b16"), |_, _span| Stype::B16),
113                map(string_p(".b32"), |_, _span| Stype::B32),
114                map(string_p(".b64"), |_, _span| Stype::B64),
115                map(string_p(".u16"), |_, _span| Stype::U16),
116                map(string_p(".u32"), |_, _span| Stype::U32),
117                map(string_p(".u64"), |_, _span| Stype::U64),
118                map(string_p(".s16"), |_, _span| Stype::S16),
119                map(string_p(".s32"), |_, _span| Stype::S32),
120                map(string_p(".s64"), |_, _span| Stype::S64),
121                map(string_p(".f32"), |_, _span| Stype::F32),
122                map(string_p(".f64"), |_, _span| Stype::F64)
123            )
124        }
125    }
126
127    impl PtxParser for SetCmpopFtzDtypeStype {
128        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
129            try_map(
130                seq_n!(
131                    string_p("set"),
132                    Cmpop::parse(),
133                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
134                    Dtype::parse(),
135                    Stype::parse(),
136                    GeneralOperand::parse(),
137                    comma_p(),
138                    GeneralOperand::parse(),
139                    comma_p(),
140                    GeneralOperand::parse(),
141                    semicolon_p()
142                ),
143                |(_, cmpop, ftz, dtype, stype, d, _, a, _, b, _), span| {
144                    ok!(SetCmpopFtzDtypeStype {
145                        cmpop = cmpop,
146                        ftz = ftz,
147                        dtype = dtype,
148                        stype = stype,
149                        d = d,
150                        a = a,
151                        b = b,
152
153                    })
154                },
155            )
156        }
157    }
158
159    impl PtxParser for SetCmpopBoolopFtzDtypeStype {
160        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
161            try_map(
162                seq_n!(
163                    string_p("set"),
164                    Cmpop::parse(),
165                    Boolop::parse(),
166                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
167                    Dtype::parse(),
168                    Stype::parse(),
169                    GeneralOperand::parse(),
170                    comma_p(),
171                    GeneralOperand::parse(),
172                    comma_p(),
173                    GeneralOperand::parse(),
174                    comma_p(),
175                    map(optional(exclamation_p()), |value, _| value.is_some()),
176                    GeneralOperand::parse(),
177                    semicolon_p()
178                ),
179                |(_, cmpop, boolop, ftz, dtype, stype, d, _, a, _, b, _, c_op, c, _), span| {
180                    ok!(SetCmpopBoolopFtzDtypeStype {
181                        cmpop = cmpop,
182                        boolop = boolop,
183                        ftz = ftz,
184                        dtype = dtype,
185                        stype = stype,
186                        d = d,
187                        a = a,
188                        b = b,
189                        c_op = c_op,
190                        c = c,
191
192                    })
193                },
194            )
195        }
196    }
197}
198
199pub mod section_1 {
200    use super::*;
201    use crate::r#type::instruction::set::section_1::*;
202
203    // ============================================================================
204    // Generated enum parsers
205    // ============================================================================
206
207    impl PtxParser for Boolop {
208        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
209            alt!(
210                map(string_p(".and"), |_, _span| Boolop::And),
211                map(string_p(".xor"), |_, _span| Boolop::Xor),
212                map(string_p(".or"), |_, _span| Boolop::Or)
213            )
214        }
215    }
216
217    impl PtxParser for Cmpop {
218        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
219            alt!(
220                map(string_p(".equ"), |_, _span| Cmpop::Equ),
221                map(string_p(".neu"), |_, _span| Cmpop::Neu),
222                map(string_p(".ltu"), |_, _span| Cmpop::Ltu),
223                map(string_p(".leu"), |_, _span| Cmpop::Leu),
224                map(string_p(".gtu"), |_, _span| Cmpop::Gtu),
225                map(string_p(".geu"), |_, _span| Cmpop::Geu),
226                map(string_p(".num"), |_, _span| Cmpop::Num),
227                map(string_p(".nan"), |_, _span| Cmpop::Nan),
228                map(string_p(".eq"), |_, _span| Cmpop::Eq),
229                map(string_p(".ne"), |_, _span| Cmpop::Ne),
230                map(string_p(".lt"), |_, _span| Cmpop::Lt),
231                map(string_p(".le"), |_, _span| Cmpop::Le),
232                map(string_p(".gt"), |_, _span| Cmpop::Gt),
233                map(string_p(".ge"), |_, _span| Cmpop::Ge),
234                map(string_p(".lo"), |_, _span| Cmpop::Lo),
235                map(string_p(".ls"), |_, _span| Cmpop::Ls),
236                map(string_p(".hi"), |_, _span| Cmpop::Hi),
237                map(string_p(".hs"), |_, _span| Cmpop::Hs)
238            )
239        }
240    }
241
242    impl PtxParser for Dtype {
243        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
244            alt!(
245                map(string_p(".u16"), |_, _span| Dtype::U16),
246                map(string_p(".s16"), |_, _span| Dtype::S16),
247                map(string_p(".u32"), |_, _span| Dtype::U32),
248                map(string_p(".s32"), |_, _span| Dtype::S32)
249            )
250        }
251    }
252
253    impl PtxParser for Stype {
254        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
255            alt!(
256                map(string_p(".b16"), |_, _span| Stype::B16),
257                map(string_p(".b32"), |_, _span| Stype::B32),
258                map(string_p(".b64"), |_, _span| Stype::B64),
259                map(string_p(".u16"), |_, _span| Stype::U16),
260                map(string_p(".u32"), |_, _span| Stype::U32),
261                map(string_p(".u64"), |_, _span| Stype::U64),
262                map(string_p(".s16"), |_, _span| Stype::S16),
263                map(string_p(".s32"), |_, _span| Stype::S32),
264                map(string_p(".s64"), |_, _span| Stype::S64),
265                map(string_p(".f32"), |_, _span| Stype::F32),
266                map(string_p(".f64"), |_, _span| Stype::F64)
267            )
268        }
269    }
270
271    impl PtxParser for SetCmpopFtzF16Stype {
272        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
273            try_map(
274                seq_n!(
275                    string_p("set"),
276                    Cmpop::parse(),
277                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
278                    string_p(".f16"),
279                    Stype::parse(),
280                    GeneralOperand::parse(),
281                    comma_p(),
282                    GeneralOperand::parse(),
283                    comma_p(),
284                    GeneralOperand::parse(),
285                    semicolon_p()
286                ),
287                |(_, cmpop, ftz, f16, stype, d, _, a, _, b, _), span| {
288                    ok!(SetCmpopFtzF16Stype {
289                        cmpop = cmpop,
290                        ftz = ftz,
291                        f16 = f16,
292                        stype = stype,
293                        d = d,
294                        a = a,
295                        b = b,
296
297                    })
298                },
299            )
300        }
301    }
302
303    impl PtxParser for SetCmpopBoolopFtzF16Stype {
304        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
305            try_map(
306                seq_n!(
307                    string_p("set"),
308                    Cmpop::parse(),
309                    Boolop::parse(),
310                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
311                    string_p(".f16"),
312                    Stype::parse(),
313                    GeneralOperand::parse(),
314                    comma_p(),
315                    GeneralOperand::parse(),
316                    comma_p(),
317                    GeneralOperand::parse(),
318                    comma_p(),
319                    map(optional(exclamation_p()), |value, _| value.is_some()),
320                    GeneralOperand::parse(),
321                    semicolon_p()
322                ),
323                |(_, cmpop, boolop, ftz, f16, stype, d, _, a, _, b, _, c_op, c, _), span| {
324                    ok!(SetCmpopBoolopFtzF16Stype {
325                        cmpop = cmpop,
326                        boolop = boolop,
327                        ftz = ftz,
328                        f16 = f16,
329                        stype = stype,
330                        d = d,
331                        a = a,
332                        b = b,
333                        c_op = c_op,
334                        c = c,
335
336                    })
337                },
338            )
339        }
340    }
341
342    impl PtxParser for SetCmpopBf16Stype {
343        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
344            try_map(
345                seq_n!(
346                    string_p("set"),
347                    Cmpop::parse(),
348                    string_p(".bf16"),
349                    Stype::parse(),
350                    GeneralOperand::parse(),
351                    comma_p(),
352                    GeneralOperand::parse(),
353                    comma_p(),
354                    GeneralOperand::parse(),
355                    semicolon_p()
356                ),
357                |(_, cmpop, bf16, stype, d, _, a, _, b, _), span| {
358                    ok!(SetCmpopBf16Stype {
359                        cmpop = cmpop,
360                        bf16 = bf16,
361                        stype = stype,
362                        d = d,
363                        a = a,
364                        b = b,
365
366                    })
367                },
368            )
369        }
370    }
371
372    impl PtxParser for SetCmpopBoolopBf16Stype {
373        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
374            try_map(
375                seq_n!(
376                    string_p("set"),
377                    Cmpop::parse(),
378                    Boolop::parse(),
379                    string_p(".bf16"),
380                    Stype::parse(),
381                    GeneralOperand::parse(),
382                    comma_p(),
383                    GeneralOperand::parse(),
384                    comma_p(),
385                    GeneralOperand::parse(),
386                    comma_p(),
387                    map(optional(exclamation_p()), |value, _| value.is_some()),
388                    GeneralOperand::parse(),
389                    semicolon_p()
390                ),
391                |(_, cmpop, boolop, bf16, stype, d, _, a, _, b, _, c_op, c, _), span| {
392                    ok!(SetCmpopBoolopBf16Stype {
393                        cmpop = cmpop,
394                        boolop = boolop,
395                        bf16 = bf16,
396                        stype = stype,
397                        d = d,
398                        a = a,
399                        b = b,
400                        c_op = c_op,
401                        c = c,
402
403                    })
404                },
405            )
406        }
407    }
408
409    impl PtxParser for SetCmpopFtzDtypeF16 {
410        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
411            try_map(
412                seq_n!(
413                    string_p("set"),
414                    Cmpop::parse(),
415                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
416                    Dtype::parse(),
417                    string_p(".f16"),
418                    GeneralOperand::parse(),
419                    comma_p(),
420                    GeneralOperand::parse(),
421                    comma_p(),
422                    GeneralOperand::parse(),
423                    semicolon_p()
424                ),
425                |(_, cmpop, ftz, dtype, f16, d, _, a, _, b, _), span| {
426                    ok!(SetCmpopFtzDtypeF16 {
427                        cmpop = cmpop,
428                        ftz = ftz,
429                        dtype = dtype,
430                        f16 = f16,
431                        d = d,
432                        a = a,
433                        b = b,
434
435                    })
436                },
437            )
438        }
439    }
440
441    impl PtxParser for SetCmpopBoolopFtzDtypeF16 {
442        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
443            try_map(
444                seq_n!(
445                    string_p("set"),
446                    Cmpop::parse(),
447                    Boolop::parse(),
448                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
449                    Dtype::parse(),
450                    string_p(".f16"),
451                    GeneralOperand::parse(),
452                    comma_p(),
453                    GeneralOperand::parse(),
454                    comma_p(),
455                    GeneralOperand::parse(),
456                    comma_p(),
457                    map(optional(exclamation_p()), |value, _| value.is_some()),
458                    GeneralOperand::parse(),
459                    semicolon_p()
460                ),
461                |(_, cmpop, boolop, ftz, dtype, f16, d, _, a, _, b, _, c_op, c, _), span| {
462                    ok!(SetCmpopBoolopFtzDtypeF16 {
463                        cmpop = cmpop,
464                        boolop = boolop,
465                        ftz = ftz,
466                        dtype = dtype,
467                        f16 = f16,
468                        d = d,
469                        a = a,
470                        b = b,
471                        c_op = c_op,
472                        c = c,
473
474                    })
475                },
476            )
477        }
478    }
479}
480
481pub mod section_2 {
482    use super::*;
483    use crate::r#type::instruction::set::section_2::*;
484
485    // ============================================================================
486    // Generated enum parsers
487    // ============================================================================
488
489    impl PtxParser for Boolop {
490        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
491            alt!(
492                map(string_p(".and"), |_, _span| Boolop::And),
493                map(string_p(".xor"), |_, _span| Boolop::Xor),
494                map(string_p(".or"), |_, _span| Boolop::Or)
495            )
496        }
497    }
498
499    impl PtxParser for Cmpop {
500        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
501            alt!(
502                map(string_p(".equ"), |_, _span| Cmpop::Equ),
503                map(string_p(".neu"), |_, _span| Cmpop::Neu),
504                map(string_p(".ltu"), |_, _span| Cmpop::Ltu),
505                map(string_p(".leu"), |_, _span| Cmpop::Leu),
506                map(string_p(".gtu"), |_, _span| Cmpop::Gtu),
507                map(string_p(".geu"), |_, _span| Cmpop::Geu),
508                map(string_p(".num"), |_, _span| Cmpop::Num),
509                map(string_p(".nan"), |_, _span| Cmpop::Nan),
510                map(string_p(".eq"), |_, _span| Cmpop::Eq),
511                map(string_p(".ne"), |_, _span| Cmpop::Ne),
512                map(string_p(".lt"), |_, _span| Cmpop::Lt),
513                map(string_p(".le"), |_, _span| Cmpop::Le),
514                map(string_p(".gt"), |_, _span| Cmpop::Gt),
515                map(string_p(".ge"), |_, _span| Cmpop::Ge),
516                map(string_p(".lo"), |_, _span| Cmpop::Lo),
517                map(string_p(".ls"), |_, _span| Cmpop::Ls),
518                map(string_p(".hi"), |_, _span| Cmpop::Hi),
519                map(string_p(".hs"), |_, _span| Cmpop::Hs)
520            )
521        }
522    }
523
524    impl PtxParser for Dtype {
525        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
526            alt!(
527                map(string_p(".u16"), |_, _span| Dtype::U16),
528                map(string_p(".s16"), |_, _span| Dtype::S16),
529                map(string_p(".u32"), |_, _span| Dtype::U32),
530                map(string_p(".s32"), |_, _span| Dtype::S32)
531            )
532        }
533    }
534
535    impl PtxParser for SetCmpopDtypeBf16 {
536        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
537            try_map(
538                seq_n!(
539                    string_p("set"),
540                    Cmpop::parse(),
541                    Dtype::parse(),
542                    string_p(".bf16"),
543                    GeneralOperand::parse(),
544                    comma_p(),
545                    GeneralOperand::parse(),
546                    comma_p(),
547                    GeneralOperand::parse(),
548                    semicolon_p()
549                ),
550                |(_, cmpop, dtype, bf16, d, _, a, _, b, _), span| {
551                    ok!(SetCmpopDtypeBf16 {
552                        cmpop = cmpop,
553                        dtype = dtype,
554                        bf16 = bf16,
555                        d = d,
556                        a = a,
557                        b = b,
558
559                    })
560                },
561            )
562        }
563    }
564
565    impl PtxParser for SetCmpopBoolopDtypeBf16 {
566        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
567            try_map(
568                seq_n!(
569                    string_p("set"),
570                    Cmpop::parse(),
571                    Boolop::parse(),
572                    Dtype::parse(),
573                    string_p(".bf16"),
574                    GeneralOperand::parse(),
575                    comma_p(),
576                    GeneralOperand::parse(),
577                    comma_p(),
578                    GeneralOperand::parse(),
579                    comma_p(),
580                    map(optional(exclamation_p()), |value, _| value.is_some()),
581                    GeneralOperand::parse(),
582                    semicolon_p()
583                ),
584                |(_, cmpop, boolop, dtype, bf16, d, _, a, _, b, _, c_op, c, _), span| {
585                    ok!(SetCmpopBoolopDtypeBf16 {
586                        cmpop = cmpop,
587                        boolop = boolop,
588                        dtype = dtype,
589                        bf16 = bf16,
590                        d = d,
591                        a = a,
592                        b = b,
593                        c_op = c_op,
594                        c = c,
595
596                    })
597                },
598            )
599        }
600    }
601}
602
603pub mod section_3 {
604    use super::*;
605    use crate::r#type::instruction::set::section_3::*;
606
607    // ============================================================================
608    // Generated enum parsers
609    // ============================================================================
610
611    impl PtxParser for Boolop {
612        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
613            alt!(
614                map(string_p(".and"), |_, _span| Boolop::And),
615                map(string_p(".xor"), |_, _span| Boolop::Xor),
616                map(string_p(".or"), |_, _span| Boolop::Or)
617            )
618        }
619    }
620
621    impl PtxParser for Cmpop {
622        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
623            alt!(
624                map(string_p(".equ"), |_, _span| Cmpop::Equ),
625                map(string_p(".neu"), |_, _span| Cmpop::Neu),
626                map(string_p(".ltu"), |_, _span| Cmpop::Ltu),
627                map(string_p(".leu"), |_, _span| Cmpop::Leu),
628                map(string_p(".gtu"), |_, _span| Cmpop::Gtu),
629                map(string_p(".geu"), |_, _span| Cmpop::Geu),
630                map(string_p(".num"), |_, _span| Cmpop::Num),
631                map(string_p(".nan"), |_, _span| Cmpop::Nan),
632                map(string_p(".eq"), |_, _span| Cmpop::Eq),
633                map(string_p(".ne"), |_, _span| Cmpop::Ne),
634                map(string_p(".lt"), |_, _span| Cmpop::Lt),
635                map(string_p(".le"), |_, _span| Cmpop::Le),
636                map(string_p(".gt"), |_, _span| Cmpop::Gt),
637                map(string_p(".ge"), |_, _span| Cmpop::Ge),
638                map(string_p(".lo"), |_, _span| Cmpop::Lo),
639                map(string_p(".ls"), |_, _span| Cmpop::Ls),
640                map(string_p(".hi"), |_, _span| Cmpop::Hi),
641                map(string_p(".hs"), |_, _span| Cmpop::Hs)
642            )
643        }
644    }
645
646    impl PtxParser for Dtype {
647        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
648            alt!(
649                map(string_p(".f16x2"), |_, _span| Dtype::F16x2),
650                map(string_p(".u32"), |_, _span| Dtype::U32),
651                map(string_p(".s32"), |_, _span| Dtype::S32)
652            )
653        }
654    }
655
656    impl PtxParser for SetCmpopFtzDtypeF16x2 {
657        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
658            try_map(
659                seq_n!(
660                    string_p("set"),
661                    Cmpop::parse(),
662                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
663                    Dtype::parse(),
664                    string_p(".f16x2"),
665                    GeneralOperand::parse(),
666                    comma_p(),
667                    GeneralOperand::parse(),
668                    comma_p(),
669                    GeneralOperand::parse(),
670                    semicolon_p()
671                ),
672                |(_, cmpop, ftz, dtype, f16x2, d, _, a, _, b, _), span| {
673                    ok!(SetCmpopFtzDtypeF16x2 {
674                        cmpop = cmpop,
675                        ftz = ftz,
676                        dtype = dtype,
677                        f16x2 = f16x2,
678                        d = d,
679                        a = a,
680                        b = b,
681
682                    })
683                },
684            )
685        }
686    }
687
688    impl PtxParser for SetCmpopBoolopFtzDtypeF16x2 {
689        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
690            try_map(
691                seq_n!(
692                    string_p("set"),
693                    Cmpop::parse(),
694                    Boolop::parse(),
695                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
696                    Dtype::parse(),
697                    string_p(".f16x2"),
698                    GeneralOperand::parse(),
699                    comma_p(),
700                    GeneralOperand::parse(),
701                    comma_p(),
702                    GeneralOperand::parse(),
703                    comma_p(),
704                    map(optional(exclamation_p()), |value, _| value.is_some()),
705                    GeneralOperand::parse(),
706                    semicolon_p()
707                ),
708                |(_, cmpop, boolop, ftz, dtype, f16x2, d, _, a, _, b, _, c_op, c, _), span| {
709                    ok!(SetCmpopBoolopFtzDtypeF16x2 {
710                        cmpop = cmpop,
711                        boolop = boolop,
712                        ftz = ftz,
713                        dtype = dtype,
714                        f16x2 = f16x2,
715                        d = d,
716                        a = a,
717                        b = b,
718                        c_op = c_op,
719                        c = c,
720
721                    })
722                },
723            )
724        }
725    }
726}
727
728pub mod section_4 {
729    use super::*;
730    use crate::r#type::instruction::set::section_4::*;
731
732    // ============================================================================
733    // Generated enum parsers
734    // ============================================================================
735
736    impl PtxParser for Boolop {
737        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
738            alt!(
739                map(string_p(".and"), |_, _span| Boolop::And),
740                map(string_p(".xor"), |_, _span| Boolop::Xor),
741                map(string_p(".or"), |_, _span| Boolop::Or)
742            )
743        }
744    }
745
746    impl PtxParser for Cmpop {
747        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
748            alt!(
749                map(string_p(".equ"), |_, _span| Cmpop::Equ),
750                map(string_p(".neu"), |_, _span| Cmpop::Neu),
751                map(string_p(".ltu"), |_, _span| Cmpop::Ltu),
752                map(string_p(".leu"), |_, _span| Cmpop::Leu),
753                map(string_p(".gtu"), |_, _span| Cmpop::Gtu),
754                map(string_p(".geu"), |_, _span| Cmpop::Geu),
755                map(string_p(".num"), |_, _span| Cmpop::Num),
756                map(string_p(".nan"), |_, _span| Cmpop::Nan),
757                map(string_p(".eq"), |_, _span| Cmpop::Eq),
758                map(string_p(".ne"), |_, _span| Cmpop::Ne),
759                map(string_p(".lt"), |_, _span| Cmpop::Lt),
760                map(string_p(".le"), |_, _span| Cmpop::Le),
761                map(string_p(".gt"), |_, _span| Cmpop::Gt),
762                map(string_p(".ge"), |_, _span| Cmpop::Ge)
763            )
764        }
765    }
766
767    impl PtxParser for Dtype {
768        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
769            alt!(
770                map(string_p(".bf16x2"), |_, _span| Dtype::Bf16x2),
771                map(string_p(".u32"), |_, _span| Dtype::U32),
772                map(string_p(".s32"), |_, _span| Dtype::S32)
773            )
774        }
775    }
776
777    impl PtxParser for SetCmpopDtypeBf16x2 {
778        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
779            try_map(
780                seq_n!(
781                    string_p("set"),
782                    Cmpop::parse(),
783                    Dtype::parse(),
784                    string_p(".bf16x2"),
785                    GeneralOperand::parse(),
786                    comma_p(),
787                    GeneralOperand::parse(),
788                    comma_p(),
789                    GeneralOperand::parse(),
790                    semicolon_p()
791                ),
792                |(_, cmpop, dtype, bf16x2, d, _, a, _, b, _), span| {
793                    ok!(SetCmpopDtypeBf16x2 {
794                        cmpop = cmpop,
795                        dtype = dtype,
796                        bf16x2 = bf16x2,
797                        d = d,
798                        a = a,
799                        b = b,
800
801                    })
802                },
803            )
804        }
805    }
806
807    impl PtxParser for SetCmpopBoolopDtypeBf16x2 {
808        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
809            try_map(
810                seq_n!(
811                    string_p("set"),
812                    Cmpop::parse(),
813                    Boolop::parse(),
814                    Dtype::parse(),
815                    string_p(".bf16x2"),
816                    GeneralOperand::parse(),
817                    comma_p(),
818                    GeneralOperand::parse(),
819                    comma_p(),
820                    GeneralOperand::parse(),
821                    comma_p(),
822                    map(optional(exclamation_p()), |value, _| value.is_some()),
823                    GeneralOperand::parse(),
824                    semicolon_p()
825                ),
826                |(_, cmpop, boolop, dtype, bf16x2, d, _, a, _, b, _, c_op, c, _), span| {
827                    ok!(SetCmpopBoolopDtypeBf16x2 {
828                        cmpop = cmpop,
829                        boolop = boolop,
830                        dtype = dtype,
831                        bf16x2 = bf16x2,
832                        d = d,
833                        a = a,
834                        b = b,
835                        c_op = c_op,
836                        c = c,
837
838                    })
839                },
840            )
841        }
842    }
843}