ptx_parser/parser/instruction/
clusterlaunchcontrol_query_cancel.rs

1//! Original PTX specification:
2//!
3//! clusterlaunchcontrol.query_cancel.is_canceled.pred.b128 pred, try_cancel_response;
4//! clusterlaunchcontrol.query_cancel.get_first_ctaid.v4.b32.b128 {xdim, ydim, zdim, _},  try_cancel_response;
5//! clusterlaunchcontrol.query_cancel{.get_first_ctaid::dimension}.b32.b128 reg, try_cancel_response;
6//! .get_first_ctaid::dimension = { .get_first_ctaid::x, .get_first_ctaid::y, .get_first_ctaid::z };
7
8#![allow(unused)]
9
10use crate::lexer::PtxToken;
11use crate::parser::{PtxParseError, PtxParser, PtxTokenStream, Span};
12use crate::r#type::common::*;
13
14pub mod section_0 {
15    use super::*;
16    use crate::r#type::instruction::clusterlaunchcontrol_query_cancel::section_0::*;
17
18    // ============================================================================
19    // Generated enum parsers
20    // ============================================================================
21
22    impl PtxParser for GetFirstCtaidDimension {
23        fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
24            // Try GetFirstCtaidX
25            {
26                let saved_pos = stream.position();
27                if stream.expect_string(".get_first_ctaid::x").is_ok() {
28                    return Ok(GetFirstCtaidDimension::GetFirstCtaidX);
29                }
30                stream.set_position(saved_pos);
31            }
32            let saved_pos = stream.position();
33            // Try GetFirstCtaidY
34            {
35                let saved_pos = stream.position();
36                if stream.expect_string(".get_first_ctaid::y").is_ok() {
37                    return Ok(GetFirstCtaidDimension::GetFirstCtaidY);
38                }
39                stream.set_position(saved_pos);
40            }
41            stream.set_position(saved_pos);
42            let saved_pos = stream.position();
43            // Try GetFirstCtaidZ
44            {
45                let saved_pos = stream.position();
46                if stream.expect_string(".get_first_ctaid::z").is_ok() {
47                    return Ok(GetFirstCtaidDimension::GetFirstCtaidZ);
48                }
49                stream.set_position(saved_pos);
50            }
51            stream.set_position(saved_pos);
52            let span = stream
53                .peek()
54                .map(|(_, s)| s.clone())
55                .unwrap_or(Span { start: 0, end: 0 });
56            let expected = &[
57                ".get_first_ctaid::x",
58                ".get_first_ctaid::y",
59                ".get_first_ctaid::z",
60            ];
61            let found = stream
62                .peek()
63                .map(|(t, _)| format!("{:?}", t))
64                .unwrap_or_else(|_| "<end of input>".to_string());
65            Err(crate::parser::unexpected_value(span, expected, found))
66        }
67    }
68
69    impl PtxParser for ClusterlaunchcontrolQueryCancelIsCanceledPredB128 {
70        fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
71            stream.expect_string("clusterlaunchcontrol")?;
72            stream.expect_string(".query_cancel")?;
73            let query_cancel = ();
74            stream.expect_complete()?;
75            stream.expect_string(".is_canceled")?;
76            let is_canceled = ();
77            stream.expect_complete()?;
78            stream.expect_string(".pred")?;
79            let pred = ();
80            stream.expect_complete()?;
81            stream.expect_string(".b128")?;
82            let b128 = ();
83            stream.expect_complete()?;
84            let pred2 = GeneralOperand::parse(stream)?;
85            stream.expect_complete()?;
86            stream.expect(&PtxToken::Comma)?;
87            let try_cancel_response = GeneralOperand::parse(stream)?;
88            stream.expect_complete()?;
89            stream.expect_complete()?;
90            stream.expect(&PtxToken::Semicolon)?;
91            Ok(ClusterlaunchcontrolQueryCancelIsCanceledPredB128 {
92                query_cancel,
93                is_canceled,
94                pred,
95                b128,
96                pred2,
97                try_cancel_response,
98            })
99        }
100    }
101
102    impl PtxParser for ClusterlaunchcontrolQueryCancelGetFirstCtaidV4B32B128 {
103        fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
104            stream.expect_string("clusterlaunchcontrol")?;
105            stream.expect_string(".query_cancel")?;
106            let query_cancel = ();
107            stream.expect_complete()?;
108            stream.expect_string(".get_first_ctaid")?;
109            let get_first_ctaid = ();
110            stream.expect_complete()?;
111            stream.expect_string(".v4")?;
112            let v4 = ();
113            stream.expect_complete()?;
114            stream.expect_string(".b32")?;
115            let b32 = ();
116            stream.expect_complete()?;
117            stream.expect_string(".b128")?;
118            let b128 = ();
119            stream.expect_complete()?;
120            let xdim = VectorOperand::parse(stream)?;
121            stream.expect_complete()?;
122            stream.expect(&PtxToken::Comma)?;
123            let try_cancel_response = GeneralOperand::parse(stream)?;
124            stream.expect_complete()?;
125            stream.expect_complete()?;
126            stream.expect(&PtxToken::Semicolon)?;
127            Ok(ClusterlaunchcontrolQueryCancelGetFirstCtaidV4B32B128 {
128                query_cancel,
129                get_first_ctaid,
130                v4,
131                b32,
132                b128,
133                xdim,
134                try_cancel_response,
135            })
136        }
137    }
138
139    impl PtxParser for ClusterlaunchcontrolQueryCancelGetFirstCtaidDimensionB32B128 {
140        fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
141            stream.expect_string("clusterlaunchcontrol")?;
142            stream.expect_string(".query_cancel")?;
143            let query_cancel = ();
144            stream.expect_complete()?;
145            let saved_pos = stream.position();
146            let get_first_ctaid_dimension = match GetFirstCtaidDimension::parse(stream) {
147                Ok(val) => Some(val),
148                Err(_) => {
149                    stream.set_position(saved_pos);
150                    None
151                }
152            };
153            stream.expect_complete()?;
154            stream.expect_string(".b32")?;
155            let b32 = ();
156            stream.expect_complete()?;
157            stream.expect_string(".b128")?;
158            let b128 = ();
159            stream.expect_complete()?;
160            let reg = GeneralOperand::parse(stream)?;
161            stream.expect_complete()?;
162            stream.expect(&PtxToken::Comma)?;
163            let try_cancel_response = GeneralOperand::parse(stream)?;
164            stream.expect_complete()?;
165            stream.expect_complete()?;
166            stream.expect(&PtxToken::Semicolon)?;
167            Ok(
168                ClusterlaunchcontrolQueryCancelGetFirstCtaidDimensionB32B128 {
169                    query_cancel,
170                    get_first_ctaid_dimension,
171                    b32,
172                    b128,
173                    reg,
174                    try_cancel_response,
175                },
176            )
177        }
178    }
179}