ptx_parser/parser/instruction/
bfind.rs1#![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::bfind::section_0::*;
22
23 impl PtxParser for Type {
28 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
29 alt!(
30 map(string_p(".u32"), |_, _span| Type::U32),
31 map(string_p(".u64"), |_, _span| Type::U64),
32 map(string_p(".s32"), |_, _span| Type::S32),
33 map(string_p(".s64"), |_, _span| Type::S64)
34 )
35 }
36 }
37
38 impl PtxParser for BfindType {
39 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
40 try_map(
41 seq_n!(
42 string_p("bfind"),
43 Type::parse(),
44 GeneralOperand::parse(),
45 comma_p(),
46 GeneralOperand::parse(),
47 semicolon_p()
48 ),
49 |(_, type_, d, _, a, _), span| {
50 ok!(BfindType {
51 type_ = type_,
52 d = d,
53 a = a,
54
55 })
56 },
57 )
58 }
59 }
60
61 impl PtxParser for BfindShiftamtType {
62 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
63 try_map(
64 seq_n!(
65 string_p("bfind"),
66 string_p(".shiftamt"),
67 Type::parse(),
68 GeneralOperand::parse(),
69 comma_p(),
70 GeneralOperand::parse(),
71 semicolon_p()
72 ),
73 |(_, shiftamt, type_, d, _, a, _), span| {
74 ok!(BfindShiftamtType {
75 shiftamt = shiftamt,
76 type_ = type_,
77 d = d,
78 a = a,
79
80 })
81 },
82 )
83 }
84 }
85}