ptx_parser/parser/instruction/
rcp.rs1#![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::rcp::section_0::*;
17
18 impl PtxParser for Rnd {
23 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
24 {
26 let saved_pos = stream.position();
27 if stream.expect_string(".rn").is_ok() {
28 return Ok(Rnd::Rn);
29 }
30 stream.set_position(saved_pos);
31 }
32 let saved_pos = stream.position();
33 {
35 let saved_pos = stream.position();
36 if stream.expect_string(".rz").is_ok() {
37 return Ok(Rnd::Rz);
38 }
39 stream.set_position(saved_pos);
40 }
41 stream.set_position(saved_pos);
42 let saved_pos = stream.position();
43 {
45 let saved_pos = stream.position();
46 if stream.expect_string(".rm").is_ok() {
47 return Ok(Rnd::Rm);
48 }
49 stream.set_position(saved_pos);
50 }
51 stream.set_position(saved_pos);
52 let saved_pos = stream.position();
53 {
55 let saved_pos = stream.position();
56 if stream.expect_string(".rp").is_ok() {
57 return Ok(Rnd::Rp);
58 }
59 stream.set_position(saved_pos);
60 }
61 stream.set_position(saved_pos);
62 let span = stream.peek().map(|(_, s)| s.clone()).unwrap_or(Span { start: 0, end: 0 });
63 let expected = &[".rn", ".rz", ".rm", ".rp"];
64 let found = stream.peek().map(|(t, _)| format!("{:?}", t)).unwrap_or_else(|_| "<end of input>".to_string());
65 Err(crate::parser::unexpected_value(span, expected, found))
66 }
67 }
68
69 impl PtxParser for RcpApproxFtzF32 {
70 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
71 stream.expect_string("rcp")?;
72 stream.expect_string(".approx")?;
73 let approx = ();
74 stream.expect_complete()?;
75 let saved_pos = stream.position();
76 let ftz = stream.expect_string(".ftz").is_ok();
77 if !ftz {
78 stream.set_position(saved_pos);
79 }
80 stream.expect_complete()?;
81 stream.expect_string(".f32")?;
82 let f32 = ();
83 stream.expect_complete()?;
84 let d = GeneralOperand::parse(stream)?;
85 stream.expect_complete()?;
86 stream.expect(&PtxToken::Comma)?;
87 let a = GeneralOperand::parse(stream)?;
88 stream.expect_complete()?;
89 stream.expect_complete()?;
90 stream.expect(&PtxToken::Semicolon)?;
91 Ok(RcpApproxFtzF32 {
92 approx,
93 ftz,
94 f32,
95 d,
96 a,
97 })
98 }
99 }
100
101
102 impl PtxParser for RcpRndFtzF32 {
103 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
104 stream.expect_string("rcp")?;
105 let rnd = Rnd::parse(stream)?;
106 stream.expect_complete()?;
107 let saved_pos = stream.position();
108 let ftz = stream.expect_string(".ftz").is_ok();
109 if !ftz {
110 stream.set_position(saved_pos);
111 }
112 stream.expect_complete()?;
113 stream.expect_string(".f32")?;
114 let f32 = ();
115 stream.expect_complete()?;
116 let d = GeneralOperand::parse(stream)?;
117 stream.expect_complete()?;
118 stream.expect(&PtxToken::Comma)?;
119 let a = GeneralOperand::parse(stream)?;
120 stream.expect_complete()?;
121 stream.expect_complete()?;
122 stream.expect(&PtxToken::Semicolon)?;
123 Ok(RcpRndFtzF32 {
124 rnd,
125 ftz,
126 f32,
127 d,
128 a,
129 })
130 }
131 }
132
133
134 impl PtxParser for RcpRndF64 {
135 fn parse(stream: &mut PtxTokenStream) -> Result<Self, PtxParseError> {
136 stream.expect_string("rcp")?;
137 let rnd = Rnd::parse(stream)?;
138 stream.expect_complete()?;
139 stream.expect_string(".f64")?;
140 let f64 = ();
141 stream.expect_complete()?;
142 let d = GeneralOperand::parse(stream)?;
143 stream.expect_complete()?;
144 stream.expect(&PtxToken::Comma)?;
145 let a = GeneralOperand::parse(stream)?;
146 stream.expect_complete()?;
147 stream.expect_complete()?;
148 stream.expect(&PtxToken::Semicolon)?;
149 Ok(RcpRndF64 {
150 rnd,
151 f64,
152 d,
153 a,
154 })
155 }
156 }
157
158
159}
160