ptx_parser/parser/instruction/
popc.rs1#![allow(unused)]
7
8use crate::lexer::PtxToken;
9use crate::parser::{PtxParseError, PtxParser, PtxTokenStream, Span};
10use crate::r#type::common::*;
11
12pub mod section_0 {
13 use super::*;
14 use crate::r#type::instruction::popc::section_0::*;
15
16 impl PtxParser for Type {
21 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
22 {
24 let saved_pos = stream.position();
25 if stream.expect_string(".b32").is_ok() {
26 return Ok(Type::B32);
27 }
28 stream.set_position(saved_pos);
29 }
30 let saved_pos = stream.position();
31 {
33 let saved_pos = stream.position();
34 if stream.expect_string(".b64").is_ok() {
35 return Ok(Type::B64);
36 }
37 stream.set_position(saved_pos);
38 }
39 stream.set_position(saved_pos);
40 let span = stream
41 .peek()
42 .map(|(_, s)| s.clone())
43 .unwrap_or(Span { start: 0, end: 0 });
44 let expected = &[".b32", ".b64"];
45 let found = stream
46 .peek()
47 .map(|(t, _)| format!("{:?}", t))
48 .unwrap_or_else(|_| "<end of input>".to_string());
49 Err(crate::parser::unexpected_value(span, expected, found))
50 }
51 }
52
53 impl PtxParser for PopcType {
54 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
55 stream.expect_string("popc")?;
56 let type_ = Type::parse(stream)?;
57 stream.expect_complete()?;
58 let d = GeneralOperand::parse(stream)?;
59 stream.expect_complete()?;
60 stream.expect(&PtxToken::Comma)?;
61 let a = GeneralOperand::parse(stream)?;
62 stream.expect_complete()?;
63 stream.expect_complete()?;
64 stream.expect(&PtxToken::Semicolon)?;
65 Ok(PopcType { type_, d, a })
66 }
67 }
68}