ptx_parser/parser/instruction/
sub_cc.rs

1//! Original PTX specification:
2//!
3//! sub.cc.type  d, a, b;
4//! .type = { .u32, .s32, .u64, .s64 };
5
6#![allow(unused)]
7
8use crate::parser::{
9    PtxParseError, PtxParser, PtxTokenStream, Span,
10    util::{
11        between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
12        pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
13    },
14};
15use crate::r#type::common::*;
16use crate::{alt, ok, seq_n};
17
18pub mod section_0 {
19    use super::*;
20    use crate::r#type::instruction::sub_cc::section_0::*;
21
22    // ============================================================================
23    // Generated enum parsers
24    // ============================================================================
25
26    impl PtxParser for Type {
27        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
28            alt!(
29                map(string_p(".u32"), |_, _span| Type::U32),
30                map(string_p(".s32"), |_, _span| Type::S32),
31                map(string_p(".u64"), |_, _span| Type::U64),
32                map(string_p(".s64"), |_, _span| Type::S64)
33            )
34        }
35    }
36
37    impl PtxParser for SubCcType {
38        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
39            try_map(
40                seq_n!(
41                    string_p("sub"),
42                    string_p(".cc"),
43                    Type::parse(),
44                    GeneralOperand::parse(),
45                    comma_p(),
46                    GeneralOperand::parse(),
47                    comma_p(),
48                    GeneralOperand::parse(),
49                    semicolon_p()
50                ),
51                |(_, cc, type_, d, _, a, _, b, _), span| {
52                    ok!(SubCcType {
53                        cc = cc,
54                        type_ = type_,
55                        d = d,
56                        a = a,
57                        b = b,
58
59                    })
60                },
61            )
62        }
63    }
64}