ptx_parser/parser/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)]
41
42use crate::parser::{
43    PtxParseError, PtxParser, PtxTokenStream, Span,
44    util::{
45        between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
46        pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
47    },
48};
49use crate::r#type::common::*;
50use crate::{alt, ok, seq_n};
51
52pub mod section_0 {
53    use super::*;
54    use crate::r#type::instruction::cvt::section_0::*;
55
56    // ============================================================================
57    // Generated enum parsers
58    // ============================================================================
59
60    impl PtxParser for Atype {
61        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
62            alt!(
63                map(string_p(".bf16"), |_, _span| Atype::Bf16),
64                map(string_p(".u16"), |_, _span| Atype::U16),
65                map(string_p(".u32"), |_, _span| Atype::U32),
66                map(string_p(".u64"), |_, _span| Atype::U64),
67                map(string_p(".s16"), |_, _span| Atype::S16),
68                map(string_p(".s32"), |_, _span| Atype::S32),
69                map(string_p(".s64"), |_, _span| Atype::S64),
70                map(string_p(".f16"), |_, _span| Atype::F16),
71                map(string_p(".f32"), |_, _span| Atype::F32),
72                map(string_p(".f64"), |_, _span| Atype::F64),
73                map(string_p(".u8"), |_, _span| Atype::U8),
74                map(string_p(".s8"), |_, _span| Atype::S8)
75            )
76        }
77    }
78
79    impl PtxParser for Dtype {
80        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
81            alt!(
82                map(string_p(".bf16"), |_, _span| Dtype::Bf16),
83                map(string_p(".u16"), |_, _span| Dtype::U16),
84                map(string_p(".u32"), |_, _span| Dtype::U32),
85                map(string_p(".u64"), |_, _span| Dtype::U64),
86                map(string_p(".s16"), |_, _span| Dtype::S16),
87                map(string_p(".s32"), |_, _span| Dtype::S32),
88                map(string_p(".s64"), |_, _span| Dtype::S64),
89                map(string_p(".f16"), |_, _span| Dtype::F16),
90                map(string_p(".f32"), |_, _span| Dtype::F32),
91                map(string_p(".f64"), |_, _span| Dtype::F64),
92                map(string_p(".u8"), |_, _span| Dtype::U8),
93                map(string_p(".s8"), |_, _span| Dtype::S8)
94            )
95        }
96    }
97
98    impl PtxParser for F4x2type {
99        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
100            alt!(map(string_p(".e2m1x2"), |_, _span| F4x2type::E2m1x2))
101        }
102    }
103
104    impl PtxParser for F4x4type {
105        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
106            alt!(map(string_p(".e2m1x4"), |_, _span| F4x4type::E2m1x4))
107        }
108    }
109
110    impl PtxParser for F6x2type {
111        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
112            alt!(
113                map(string_p(".e2m3x2"), |_, _span| F6x2type::E2m3x2),
114                map(string_p(".e3m2x2"), |_, _span| F6x2type::E3m2x2)
115            )
116        }
117    }
118
119    impl PtxParser for F6x4type {
120        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
121            alt!(
122                map(string_p(".e2m3x4"), |_, _span| F6x4type::E2m3x4),
123                map(string_p(".e3m2x4"), |_, _span| F6x4type::E3m2x4)
124            )
125        }
126    }
127
128    impl PtxParser for F8x2type {
129        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
130            alt!(
131                map(string_p(".e4m3x2"), |_, _span| F8x2type::E4m3x2),
132                map(string_p(".e5m2x2"), |_, _span| F8x2type::E5m2x2)
133            )
134        }
135    }
136
137    impl PtxParser for F8x4type {
138        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
139            alt!(
140                map(string_p(".e4m3x4"), |_, _span| F8x4type::E4m3x4),
141                map(string_p(".e5m2x4"), |_, _span| F8x4type::E5m2x4)
142            )
143        }
144    }
145
146    impl PtxParser for Frnd {
147        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
148            alt!(
149                map(string_p(".rn"), |_, _span| Frnd::Rn),
150                map(string_p(".rz"), |_, _span| Frnd::Rz),
151                map(string_p(".rm"), |_, _span| Frnd::Rm),
152                map(string_p(".rp"), |_, _span| Frnd::Rp)
153            )
154        }
155    }
156
157    impl PtxParser for Frnd2 {
158        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
159            alt!(
160                map(string_p(".rn"), |_, _span| Frnd2::Rn),
161                map(string_p(".rz"), |_, _span| Frnd2::Rz)
162            )
163        }
164    }
165
166    impl PtxParser for Frnd3 {
167        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
168            alt!(
169                map(string_p(".rz"), |_, _span| Frnd3::Rz),
170                map(string_p(".rp"), |_, _span| Frnd3::Rp)
171            )
172        }
173    }
174
175    impl PtxParser for Irnd {
176        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
177            alt!(
178                map(string_p(".rni"), |_, _span| Irnd::Rni),
179                map(string_p(".rzi"), |_, _span| Irnd::Rzi),
180                map(string_p(".rmi"), |_, _span| Irnd::Rmi),
181                map(string_p(".rpi"), |_, _span| Irnd::Rpi)
182            )
183        }
184    }
185
186    impl PtxParser for CvtIrndFtzSatDtypeAtype {
187        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
188            try_map(
189                seq_n!(
190                    string_p("cvt"),
191                    optional(Irnd::parse()),
192                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
193                    map(optional(string_p(".sat")), |value, _| value.is_some()),
194                    Dtype::parse(),
195                    Atype::parse(),
196                    GeneralOperand::parse(),
197                    comma_p(),
198                    GeneralOperand::parse(),
199                    semicolon_p()
200                ),
201                |(_, irnd, ftz, sat, dtype, atype, d, _, a, _), span| {
202                    ok!(CvtIrndFtzSatDtypeAtype {
203                        irnd = irnd,
204                        ftz = ftz,
205                        sat = sat,
206                        dtype = dtype,
207                        atype = atype,
208                        d = d,
209                        a = a,
210
211                    })
212                },
213            )
214        }
215    }
216
217    impl PtxParser for CvtFrndFtzSatDtypeAtype {
218        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
219            try_map(
220                seq_n!(
221                    string_p("cvt"),
222                    optional(Frnd::parse()),
223                    map(optional(string_p(".ftz")), |value, _| value.is_some()),
224                    map(optional(string_p(".sat")), |value, _| value.is_some()),
225                    Dtype::parse(),
226                    Atype::parse(),
227                    GeneralOperand::parse(),
228                    comma_p(),
229                    GeneralOperand::parse(),
230                    semicolon_p()
231                ),
232                |(_, frnd, ftz, sat, dtype, atype, d, _, a, _), span| {
233                    ok!(CvtFrndFtzSatDtypeAtype {
234                        frnd = frnd,
235                        ftz = ftz,
236                        sat = sat,
237                        dtype = dtype,
238                        atype = atype,
239                        d = d,
240                        a = a,
241
242                    })
243                },
244            )
245        }
246    }
247
248    impl PtxParser for CvtFrnd2ReluSatfiniteF16F32 {
249        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
250            try_map(
251                seq_n!(
252                    string_p("cvt"),
253                    Frnd2::parse(),
254                    map(optional(string_p(".relu")), |value, _| value.is_some()),
255                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
256                    string_p(".f16"),
257                    string_p(".f32"),
258                    GeneralOperand::parse(),
259                    comma_p(),
260                    GeneralOperand::parse(),
261                    semicolon_p()
262                ),
263                |(_, frnd2, relu, satfinite, f16, f32, d, _, a, _), span| {
264                    ok!(CvtFrnd2ReluSatfiniteF16F32 {
265                        frnd2 = frnd2,
266                        relu = relu,
267                        satfinite = satfinite,
268                        f16 = f16,
269                        f32 = f32,
270                        d = d,
271                        a = a,
272
273                    })
274                },
275            )
276        }
277    }
278
279    impl PtxParser for CvtFrnd2ReluSatfiniteF16x2F32 {
280        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
281            try_map(
282                seq_n!(
283                    string_p("cvt"),
284                    Frnd2::parse(),
285                    map(optional(string_p(".relu")), |value, _| value.is_some()),
286                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
287                    string_p(".f16x2"),
288                    string_p(".f32"),
289                    GeneralOperand::parse(),
290                    comma_p(),
291                    GeneralOperand::parse(),
292                    comma_p(),
293                    GeneralOperand::parse(),
294                    semicolon_p()
295                ),
296                |(_, frnd2, relu, satfinite, f16x2, f32, d, _, a, _, b, _), span| {
297                    ok!(CvtFrnd2ReluSatfiniteF16x2F32 {
298                        frnd2 = frnd2,
299                        relu = relu,
300                        satfinite = satfinite,
301                        f16x2 = f16x2,
302                        f32 = f32,
303                        d = d,
304                        a = a,
305                        b = b,
306
307                    })
308                },
309            )
310        }
311    }
312
313    impl PtxParser for CvtRsReluSatfiniteF16x2F32 {
314        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
315            try_map(
316                seq_n!(
317                    string_p("cvt"),
318                    string_p(".rs"),
319                    map(optional(string_p(".relu")), |value, _| value.is_some()),
320                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
321                    string_p(".f16x2"),
322                    string_p(".f32"),
323                    GeneralOperand::parse(),
324                    comma_p(),
325                    GeneralOperand::parse(),
326                    comma_p(),
327                    GeneralOperand::parse(),
328                    comma_p(),
329                    GeneralOperand::parse(),
330                    semicolon_p()
331                ),
332                |(_, rs, relu, satfinite, f16x2, f32, d, _, a, _, b, _, rbits, _), span| {
333                    ok!(CvtRsReluSatfiniteF16x2F32 {
334                        rs = rs,
335                        relu = relu,
336                        satfinite = satfinite,
337                        f16x2 = f16x2,
338                        f32 = f32,
339                        d = d,
340                        a = a,
341                        b = b,
342                        rbits = rbits,
343
344                    })
345                },
346            )
347        }
348    }
349
350    impl PtxParser for CvtFrnd2ReluSatfiniteBf16F32 {
351        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
352            try_map(
353                seq_n!(
354                    string_p("cvt"),
355                    Frnd2::parse(),
356                    map(optional(string_p(".relu")), |value, _| value.is_some()),
357                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
358                    string_p(".bf16"),
359                    string_p(".f32"),
360                    GeneralOperand::parse(),
361                    comma_p(),
362                    GeneralOperand::parse(),
363                    semicolon_p()
364                ),
365                |(_, frnd2, relu, satfinite, bf16, f32, d, _, a, _), span| {
366                    ok!(CvtFrnd2ReluSatfiniteBf16F32 {
367                        frnd2 = frnd2,
368                        relu = relu,
369                        satfinite = satfinite,
370                        bf16 = bf16,
371                        f32 = f32,
372                        d = d,
373                        a = a,
374
375                    })
376                },
377            )
378        }
379    }
380
381    impl PtxParser for CvtFrnd2ReluSatfiniteBf16x2F32 {
382        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
383            try_map(
384                seq_n!(
385                    string_p("cvt"),
386                    Frnd2::parse(),
387                    map(optional(string_p(".relu")), |value, _| value.is_some()),
388                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
389                    string_p(".bf16x2"),
390                    string_p(".f32"),
391                    GeneralOperand::parse(),
392                    comma_p(),
393                    GeneralOperand::parse(),
394                    comma_p(),
395                    GeneralOperand::parse(),
396                    semicolon_p()
397                ),
398                |(_, frnd2, relu, satfinite, bf16x2, f32, d, _, a, _, b, _), span| {
399                    ok!(CvtFrnd2ReluSatfiniteBf16x2F32 {
400                        frnd2 = frnd2,
401                        relu = relu,
402                        satfinite = satfinite,
403                        bf16x2 = bf16x2,
404                        f32 = f32,
405                        d = d,
406                        a = a,
407                        b = b,
408
409                    })
410                },
411            )
412        }
413    }
414
415    impl PtxParser for CvtRsReluSatfiniteBf16x2F32 {
416        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
417            try_map(
418                seq_n!(
419                    string_p("cvt"),
420                    string_p(".rs"),
421                    map(optional(string_p(".relu")), |value, _| value.is_some()),
422                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
423                    string_p(".bf16x2"),
424                    string_p(".f32"),
425                    GeneralOperand::parse(),
426                    comma_p(),
427                    GeneralOperand::parse(),
428                    comma_p(),
429                    GeneralOperand::parse(),
430                    comma_p(),
431                    GeneralOperand::parse(),
432                    semicolon_p()
433                ),
434                |(_, rs, relu, satfinite, bf16x2, f32, d, _, a, _, b, _, rbits, _), span| {
435                    ok!(CvtRsReluSatfiniteBf16x2F32 {
436                        rs = rs,
437                        relu = relu,
438                        satfinite = satfinite,
439                        bf16x2 = bf16x2,
440                        f32 = f32,
441                        d = d,
442                        a = a,
443                        b = b,
444                        rbits = rbits,
445
446                    })
447                },
448            )
449        }
450    }
451
452    impl PtxParser for CvtRnaSatfiniteTf32F32 {
453        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
454            try_map(
455                seq_n!(
456                    string_p("cvt"),
457                    string_p(".rna"),
458                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
459                    string_p(".tf32"),
460                    string_p(".f32"),
461                    GeneralOperand::parse(),
462                    comma_p(),
463                    GeneralOperand::parse(),
464                    semicolon_p()
465                ),
466                |(_, rna, satfinite, tf32, f32, d, _, a, _), span| {
467                    ok!(CvtRnaSatfiniteTf32F32 {
468                        rna = rna,
469                        satfinite = satfinite,
470                        tf32 = tf32,
471                        f32 = f32,
472                        d = d,
473                        a = a,
474
475                    })
476                },
477            )
478        }
479    }
480
481    impl PtxParser for CvtFrnd2SatfiniteReluTf32F32 {
482        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
483            try_map(
484                seq_n!(
485                    string_p("cvt"),
486                    Frnd2::parse(),
487                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
488                    map(optional(string_p(".relu")), |value, _| value.is_some()),
489                    string_p(".tf32"),
490                    string_p(".f32"),
491                    GeneralOperand::parse(),
492                    comma_p(),
493                    GeneralOperand::parse(),
494                    semicolon_p()
495                ),
496                |(_, frnd2, satfinite, relu, tf32, f32, d, _, a, _), span| {
497                    ok!(CvtFrnd2SatfiniteReluTf32F32 {
498                        frnd2 = frnd2,
499                        satfinite = satfinite,
500                        relu = relu,
501                        tf32 = tf32,
502                        f32 = f32,
503                        d = d,
504                        a = a,
505
506                    })
507                },
508            )
509        }
510    }
511
512    impl PtxParser for CvtRnSatfiniteReluF8x2typeF32 {
513        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
514            try_map(
515                seq_n!(
516                    string_p("cvt"),
517                    string_p(".rn"),
518                    string_p(".satfinite"),
519                    map(optional(string_p(".relu")), |value, _| value.is_some()),
520                    F8x2type::parse(),
521                    string_p(".f32"),
522                    GeneralOperand::parse(),
523                    comma_p(),
524                    GeneralOperand::parse(),
525                    comma_p(),
526                    GeneralOperand::parse(),
527                    semicolon_p()
528                ),
529                |(_, rn, satfinite, relu, f8x2type, f32, d, _, a, _, b, _), span| {
530                    ok!(CvtRnSatfiniteReluF8x2typeF32 {
531                        rn = rn,
532                        satfinite = satfinite,
533                        relu = relu,
534                        f8x2type = f8x2type,
535                        f32 = f32,
536                        d = d,
537                        a = a,
538                        b = b,
539
540                    })
541                },
542            )
543        }
544    }
545
546    impl PtxParser for CvtRnSatfiniteReluF8x2typeF16x2 {
547        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
548            try_map(
549                seq_n!(
550                    string_p("cvt"),
551                    string_p(".rn"),
552                    string_p(".satfinite"),
553                    map(optional(string_p(".relu")), |value, _| value.is_some()),
554                    F8x2type::parse(),
555                    string_p(".f16x2"),
556                    GeneralOperand::parse(),
557                    comma_p(),
558                    GeneralOperand::parse(),
559                    semicolon_p()
560                ),
561                |(_, rn, satfinite, relu, f8x2type, f16x2, d, _, a, _), span| {
562                    ok!(CvtRnSatfiniteReluF8x2typeF16x2 {
563                        rn = rn,
564                        satfinite = satfinite,
565                        relu = relu,
566                        f8x2type = f8x2type,
567                        f16x2 = f16x2,
568                        d = d,
569                        a = a,
570
571                    })
572                },
573            )
574        }
575    }
576
577    impl PtxParser for CvtRnReluF16x2F8x2type {
578        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
579            try_map(
580                seq_n!(
581                    string_p("cvt"),
582                    string_p(".rn"),
583                    map(optional(string_p(".relu")), |value, _| value.is_some()),
584                    string_p(".f16x2"),
585                    F8x2type::parse(),
586                    GeneralOperand::parse(),
587                    comma_p(),
588                    GeneralOperand::parse(),
589                    semicolon_p()
590                ),
591                |(_, rn, relu, f16x2, f8x2type, d, _, a, _), span| {
592                    ok!(CvtRnReluF16x2F8x2type {
593                        rn = rn,
594                        relu = relu,
595                        f16x2 = f16x2,
596                        f8x2type = f8x2type,
597                        d = d,
598                        a = a,
599
600                    })
601                },
602            )
603        }
604    }
605
606    impl PtxParser for CvtRsReluSatfiniteF8x4typeF32 {
607        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
608            try_map(
609                seq_n!(
610                    string_p("cvt"),
611                    string_p(".rs"),
612                    map(optional(string_p(".relu")), |value, _| value.is_some()),
613                    string_p(".satfinite"),
614                    F8x4type::parse(),
615                    string_p(".f32"),
616                    GeneralOperand::parse(),
617                    comma_p(),
618                    VectorOperand::parse(),
619                    comma_p(),
620                    GeneralOperand::parse(),
621                    semicolon_p()
622                ),
623                |(_, rs, relu, satfinite, f8x4type, f32, d, _, a, _, rbits, _), span| {
624                    ok!(CvtRsReluSatfiniteF8x4typeF32 {
625                        rs = rs,
626                        relu = relu,
627                        satfinite = satfinite,
628                        f8x4type = f8x4type,
629                        f32 = f32,
630                        d = d,
631                        a = a,
632                        rbits = rbits,
633
634                    })
635                },
636            )
637        }
638    }
639
640    impl PtxParser for CvtRnSatfiniteReluF4x2typeF32 {
641        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
642            try_map(
643                seq_n!(
644                    string_p("cvt"),
645                    string_p(".rn"),
646                    string_p(".satfinite"),
647                    map(optional(string_p(".relu")), |value, _| value.is_some()),
648                    F4x2type::parse(),
649                    string_p(".f32"),
650                    GeneralOperand::parse(),
651                    comma_p(),
652                    GeneralOperand::parse(),
653                    comma_p(),
654                    GeneralOperand::parse(),
655                    semicolon_p()
656                ),
657                |(_, rn, satfinite, relu, f4x2type, f32, d, _, a, _, b, _), span| {
658                    ok!(CvtRnSatfiniteReluF4x2typeF32 {
659                        rn = rn,
660                        satfinite = satfinite,
661                        relu = relu,
662                        f4x2type = f4x2type,
663                        f32 = f32,
664                        d = d,
665                        a = a,
666                        b = b,
667
668                    })
669                },
670            )
671        }
672    }
673
674    impl PtxParser for CvtRnReluF16x2F4x2type {
675        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
676            try_map(
677                seq_n!(
678                    string_p("cvt"),
679                    string_p(".rn"),
680                    map(optional(string_p(".relu")), |value, _| value.is_some()),
681                    string_p(".f16x2"),
682                    F4x2type::parse(),
683                    GeneralOperand::parse(),
684                    comma_p(),
685                    GeneralOperand::parse(),
686                    semicolon_p()
687                ),
688                |(_, rn, relu, f16x2, f4x2type, d, _, a, _), span| {
689                    ok!(CvtRnReluF16x2F4x2type {
690                        rn = rn,
691                        relu = relu,
692                        f16x2 = f16x2,
693                        f4x2type = f4x2type,
694                        d = d,
695                        a = a,
696
697                    })
698                },
699            )
700        }
701    }
702
703    impl PtxParser for CvtRsReluSatfiniteF4x4typeF32 {
704        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
705            try_map(
706                seq_n!(
707                    string_p("cvt"),
708                    string_p(".rs"),
709                    map(optional(string_p(".relu")), |value, _| value.is_some()),
710                    string_p(".satfinite"),
711                    F4x4type::parse(),
712                    string_p(".f32"),
713                    GeneralOperand::parse(),
714                    comma_p(),
715                    VectorOperand::parse(),
716                    comma_p(),
717                    GeneralOperand::parse(),
718                    semicolon_p()
719                ),
720                |(_, rs, relu, satfinite, f4x4type, f32, d, _, a, _, rbits, _), span| {
721                    ok!(CvtRsReluSatfiniteF4x4typeF32 {
722                        rs = rs,
723                        relu = relu,
724                        satfinite = satfinite,
725                        f4x4type = f4x4type,
726                        f32 = f32,
727                        d = d,
728                        a = a,
729                        rbits = rbits,
730
731                    })
732                },
733            )
734        }
735    }
736
737    impl PtxParser for CvtRnSatfiniteReluF6x2typeF32 {
738        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
739            try_map(
740                seq_n!(
741                    string_p("cvt"),
742                    string_p(".rn"),
743                    string_p(".satfinite"),
744                    map(optional(string_p(".relu")), |value, _| value.is_some()),
745                    F6x2type::parse(),
746                    string_p(".f32"),
747                    GeneralOperand::parse(),
748                    comma_p(),
749                    GeneralOperand::parse(),
750                    comma_p(),
751                    GeneralOperand::parse(),
752                    semicolon_p()
753                ),
754                |(_, rn, satfinite, relu, f6x2type, f32, d, _, a, _, b, _), span| {
755                    ok!(CvtRnSatfiniteReluF6x2typeF32 {
756                        rn = rn,
757                        satfinite = satfinite,
758                        relu = relu,
759                        f6x2type = f6x2type,
760                        f32 = f32,
761                        d = d,
762                        a = a,
763                        b = b,
764
765                    })
766                },
767            )
768        }
769    }
770
771    impl PtxParser for CvtRnReluF16x2F6x2type {
772        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
773            try_map(
774                seq_n!(
775                    string_p("cvt"),
776                    string_p(".rn"),
777                    map(optional(string_p(".relu")), |value, _| value.is_some()),
778                    string_p(".f16x2"),
779                    F6x2type::parse(),
780                    GeneralOperand::parse(),
781                    comma_p(),
782                    GeneralOperand::parse(),
783                    semicolon_p()
784                ),
785                |(_, rn, relu, f16x2, f6x2type, d, _, a, _), span| {
786                    ok!(CvtRnReluF16x2F6x2type {
787                        rn = rn,
788                        relu = relu,
789                        f16x2 = f16x2,
790                        f6x2type = f6x2type,
791                        d = d,
792                        a = a,
793
794                    })
795                },
796            )
797        }
798    }
799
800    impl PtxParser for CvtRsReluSatfiniteF6x4typeF32 {
801        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
802            try_map(
803                seq_n!(
804                    string_p("cvt"),
805                    string_p(".rs"),
806                    map(optional(string_p(".relu")), |value, _| value.is_some()),
807                    string_p(".satfinite"),
808                    F6x4type::parse(),
809                    string_p(".f32"),
810                    GeneralOperand::parse(),
811                    comma_p(),
812                    VectorOperand::parse(),
813                    comma_p(),
814                    GeneralOperand::parse(),
815                    semicolon_p()
816                ),
817                |(_, rs, relu, satfinite, f6x4type, f32, d, _, a, _, rbits, _), span| {
818                    ok!(CvtRsReluSatfiniteF6x4typeF32 {
819                        rs = rs,
820                        relu = relu,
821                        satfinite = satfinite,
822                        f6x4type = f6x4type,
823                        f32 = f32,
824                        d = d,
825                        a = a,
826                        rbits = rbits,
827
828                    })
829                },
830            )
831        }
832    }
833
834    impl PtxParser for CvtFrnd3SatfiniteUe8m0x2F32 {
835        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
836            try_map(
837                seq_n!(
838                    string_p("cvt"),
839                    Frnd3::parse(),
840                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
841                    string_p(".ue8m0x2"),
842                    string_p(".f32"),
843                    GeneralOperand::parse(),
844                    comma_p(),
845                    GeneralOperand::parse(),
846                    comma_p(),
847                    GeneralOperand::parse(),
848                    semicolon_p()
849                ),
850                |(_, frnd3, satfinite, ue8m0x2, f32, d, _, a, _, b, _), span| {
851                    ok!(CvtFrnd3SatfiniteUe8m0x2F32 {
852                        frnd3 = frnd3,
853                        satfinite = satfinite,
854                        ue8m0x2 = ue8m0x2,
855                        f32 = f32,
856                        d = d,
857                        a = a,
858                        b = b,
859
860                    })
861                },
862            )
863        }
864    }
865
866    impl PtxParser for CvtFrnd3SatfiniteUe8m0x2Bf16x2 {
867        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
868            try_map(
869                seq_n!(
870                    string_p("cvt"),
871                    Frnd3::parse(),
872                    map(optional(string_p(".satfinite")), |value, _| value.is_some()),
873                    string_p(".ue8m0x2"),
874                    string_p(".bf16x2"),
875                    GeneralOperand::parse(),
876                    comma_p(),
877                    GeneralOperand::parse(),
878                    semicolon_p()
879                ),
880                |(_, frnd3, satfinite, ue8m0x2, bf16x2, d, _, a, _), span| {
881                    ok!(CvtFrnd3SatfiniteUe8m0x2Bf16x2 {
882                        frnd3 = frnd3,
883                        satfinite = satfinite,
884                        ue8m0x2 = ue8m0x2,
885                        bf16x2 = bf16x2,
886                        d = d,
887                        a = a,
888
889                    })
890                },
891            )
892        }
893    }
894
895    impl PtxParser for CvtRnBf16x2Ue8m0x2 {
896        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
897            try_map(
898                seq_n!(
899                    string_p("cvt"),
900                    string_p(".rn"),
901                    string_p(".bf16x2"),
902                    string_p(".ue8m0x2"),
903                    GeneralOperand::parse(),
904                    comma_p(),
905                    GeneralOperand::parse(),
906                    semicolon_p()
907                ),
908                |(_, rn, bf16x2, ue8m0x2, d, _, a, _), span| {
909                    ok!(CvtRnBf16x2Ue8m0x2 {
910                        rn = rn,
911                        bf16x2 = bf16x2,
912                        ue8m0x2 = ue8m0x2,
913                        d = d,
914                        a = a,
915
916                    })
917                },
918            )
919        }
920    }
921}