Skip to main content

ptx_parser/parser/instruction/
lop3.rs

1//! Original PTX specification:
2//!
3//! lop3.b32 d, a, b, c, immLut;
4//! lop3.BoolOp.b32 d|p, a, b, c, immLut, q;
5//! .BoolOp   = { .or , .and };
6
7#![allow(unused)]
8
9use crate::parser::{
10    PtxParseError, PtxParser, PtxTokenStream, Span,
11    util::{
12        between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
13        pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
14    },
15};
16use crate::r#type::common::*;
17use crate::{alt, ok, seq_n};
18
19pub mod section_0 {
20    use super::*;
21    use crate::r#type::instruction::lop3::section_0::*;
22
23    // ============================================================================
24    // Generated enum parsers
25    // ============================================================================
26
27    impl PtxParser for Boolop {
28        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
29            alt!(
30                map(string_p(".and"), |_, _span| Boolop::And),
31                map(string_p(".or"), |_, _span| Boolop::Or)
32            )
33        }
34    }
35
36    impl PtxParser for Lop3B32 {
37        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
38            try_map(
39                seq_n!(
40                    string_p("lop3"),
41                    string_p(".b32"),
42                    GeneralOperand::parse(),
43                    comma_p(),
44                    GeneralOperand::parse(),
45                    comma_p(),
46                    GeneralOperand::parse(),
47                    comma_p(),
48                    GeneralOperand::parse(),
49                    comma_p(),
50                    GeneralOperand::parse(),
51                    semicolon_p()
52                ),
53                |(_, b32, d, _, a, _, b, _, c, _, immlut, _), span| {
54                    ok!(Lop3B32 {
55                        b32 = b32,
56                        d = d,
57                        a = a,
58                        b = b,
59                        c = c,
60                        immlut = immlut,
61
62                    })
63                },
64            )
65        }
66    }
67
68    impl PtxParser for Lop3BoolopB32 {
69        fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
70            try_map(
71                seq_n!(
72                    string_p("lop3"),
73                    Boolop::parse(),
74                    string_p(".b32"),
75                    GeneralOperand::parse(),
76                    pipe_p(),
77                    GeneralOperand::parse(),
78                    comma_p(),
79                    GeneralOperand::parse(),
80                    comma_p(),
81                    GeneralOperand::parse(),
82                    comma_p(),
83                    GeneralOperand::parse(),
84                    comma_p(),
85                    GeneralOperand::parse(),
86                    comma_p(),
87                    GeneralOperand::parse(),
88                    semicolon_p()
89                ),
90                |(_, boolop, b32, d, _, p, _, a, _, b, _, c, _, immlut, _, q, _), span| {
91                    ok!(Lop3BoolopB32 {
92                        boolop = boolop,
93                        b32 = b32,
94                        d = d,
95                        p = p,
96                        a = a,
97                        b = b,
98                        c = c,
99                        immlut = immlut,
100                        q = q,
101
102                    })
103                },
104            )
105        }
106    }
107}