ptx_parser/parser/instruction/
match_sync.rs1#![allow(unused)]
8
9use crate::lexer::PtxToken;
10use crate::parser::{PtxParseError, PtxParser, PtxTokenStream, Span};
11use crate::r#type::common::*;
12
13pub mod section_0 {
14 use super::*;
15 use crate::r#type::instruction::match_sync::section_0::*;
16
17 impl PtxParser for Type {
22 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
23 {
25 let saved_pos = stream.position();
26 if stream.expect_string(".b32").is_ok() {
27 return Ok(Type::B32);
28 }
29 stream.set_position(saved_pos);
30 }
31 let saved_pos = stream.position();
32 {
34 let saved_pos = stream.position();
35 if stream.expect_string(".b64").is_ok() {
36 return Ok(Type::B64);
37 }
38 stream.set_position(saved_pos);
39 }
40 stream.set_position(saved_pos);
41 let span = stream.peek().map(|(_, s)| s.clone()).unwrap_or(Span { start: 0, end: 0 });
42 let expected = &[".b32", ".b64"];
43 let found = stream.peek().map(|(t, _)| format!("{:?}", t)).unwrap_or_else(|_| "<end of input>".to_string());
44 Err(crate::parser::unexpected_value(span, expected, found))
45 }
46 }
47
48 impl PtxParser for MatchAnySyncType {
49 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
50 stream.expect_string("match")?;
51 stream.expect_string(".any")?;
52 let any = ();
53 stream.expect_complete()?;
54 stream.expect_string(".sync")?;
55 let sync = ();
56 stream.expect_complete()?;
57 let type_ = Type::parse(stream)?;
58 stream.expect_complete()?;
59 let d = GeneralOperand::parse(stream)?;
60 stream.expect_complete()?;
61 stream.expect(&PtxToken::Comma)?;
62 let a = GeneralOperand::parse(stream)?;
63 stream.expect_complete()?;
64 stream.expect(&PtxToken::Comma)?;
65 let membermask = GeneralOperand::parse(stream)?;
66 stream.expect_complete()?;
67 stream.expect_complete()?;
68 stream.expect(&PtxToken::Semicolon)?;
69 Ok(MatchAnySyncType {
70 any,
71 sync,
72 type_,
73 d,
74 a,
75 membermask,
76 })
77 }
78 }
79
80
81 impl PtxParser for MatchAllSyncType {
82 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
83 stream.expect_string("match")?;
84 stream.expect_string(".all")?;
85 let all = ();
86 stream.expect_complete()?;
87 stream.expect_string(".sync")?;
88 let sync = ();
89 stream.expect_complete()?;
90 let type_ = Type::parse(stream)?;
91 stream.expect_complete()?;
92 let d = GeneralOperand::parse(stream)?;
93 let saved_pos = stream.position();
94 let p = if stream.consume_if(|t| matches!(t, PtxToken::Pipe)).is_some() {
95 Some(GeneralOperand::parse(stream)?)
96 } else {
97 stream.set_position(saved_pos);
98 None
99 };
100 stream.expect_complete()?;
101 stream.expect(&PtxToken::Comma)?;
102 let a = GeneralOperand::parse(stream)?;
103 stream.expect_complete()?;
104 stream.expect(&PtxToken::Comma)?;
105 let membermask = GeneralOperand::parse(stream)?;
106 stream.expect_complete()?;
107 stream.expect_complete()?;
108 stream.expect(&PtxToken::Semicolon)?;
109 Ok(MatchAllSyncType {
110 all,
111 sync,
112 type_,
113 d,
114 p,
115 a,
116 membermask,
117 })
118 }
119 }
120
121
122}
123