1#![allow(unused)]
27
28use crate::parser::{
29 PtxParseError, PtxParser, PtxTokenStream, Span,
30 util::{
31 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
32 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
33 },
34};
35use crate::r#type::common::*;
36use crate::{alt, ok, seq_n};
37
38pub mod section_0 {
39 use super::*;
40 use crate::r#type::instruction::vset4::section_0::*;
41
42 impl PtxParser for Atype {
47 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
48 alt!(
49 map(string_p(".u32"), |_, _span| Atype::U32),
50 map(string_p(".s32"), |_, _span| Atype::S32)
51 )
52 }
53 }
54
55 impl PtxParser for Bsel {
56 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
57 alt!(
58 map(string_p(".b00"), |_, _span| Bsel::B00),
59 map(string_p(".b01"), |_, _span| Bsel::B01),
60 map(string_p(".b02"), |_, _span| Bsel::B02),
61 map(string_p(".b03"), |_, _span| Bsel::B03),
62 map(string_p(".b04"), |_, _span| Bsel::B04),
63 map(string_p(".b05"), |_, _span| Bsel::B05),
64 map(string_p(".b06"), |_, _span| Bsel::B06),
65 map(string_p(".b07"), |_, _span| Bsel::B07),
66 map(string_p(".b10"), |_, _span| Bsel::B10),
67 map(string_p(".b11"), |_, _span| Bsel::B11),
68 map(string_p(".b12"), |_, _span| Bsel::B12),
69 map(string_p(".b13"), |_, _span| Bsel::B13),
70 map(string_p(".b14"), |_, _span| Bsel::B14),
71 map(string_p(".b15"), |_, _span| Bsel::B15),
72 map(string_p(".b16"), |_, _span| Bsel::B16),
73 map(string_p(".b17"), |_, _span| Bsel::B17),
74 map(string_p(".b20"), |_, _span| Bsel::B20),
75 map(string_p(".b21"), |_, _span| Bsel::B21),
76 map(string_p(".b22"), |_, _span| Bsel::B22),
77 map(string_p(".b23"), |_, _span| Bsel::B23),
78 map(string_p(".b24"), |_, _span| Bsel::B24),
79 map(string_p(".b25"), |_, _span| Bsel::B25),
80 map(string_p(".b26"), |_, _span| Bsel::B26),
81 map(string_p(".b27"), |_, _span| Bsel::B27),
82 map(string_p(".b30"), |_, _span| Bsel::B30),
83 map(string_p(".b31"), |_, _span| Bsel::B31),
84 map(string_p(".b32"), |_, _span| Bsel::B32),
85 map(string_p(".b33"), |_, _span| Bsel::B33),
86 map(string_p(".b34"), |_, _span| Bsel::B34),
87 map(string_p(".b35"), |_, _span| Bsel::B35),
88 map(string_p(".b36"), |_, _span| Bsel::B36),
89 map(string_p(".b37"), |_, _span| Bsel::B37),
90 map(string_p(".b40"), |_, _span| Bsel::B40),
91 map(string_p(".b41"), |_, _span| Bsel::B41),
92 map(string_p(".b42"), |_, _span| Bsel::B42),
93 map(string_p(".b43"), |_, _span| Bsel::B43),
94 map(string_p(".b44"), |_, _span| Bsel::B44),
95 map(string_p(".b45"), |_, _span| Bsel::B45),
96 map(string_p(".b46"), |_, _span| Bsel::B46),
97 map(string_p(".b47"), |_, _span| Bsel::B47),
98 map(string_p(".b50"), |_, _span| Bsel::B50),
99 map(string_p(".b51"), |_, _span| Bsel::B51),
100 map(string_p(".b52"), |_, _span| Bsel::B52),
101 map(string_p(".b53"), |_, _span| Bsel::B53),
102 map(string_p(".b54"), |_, _span| Bsel::B54),
103 map(string_p(".b55"), |_, _span| Bsel::B55),
104 map(string_p(".b56"), |_, _span| Bsel::B56),
105 map(string_p(".b57"), |_, _span| Bsel::B57),
106 map(string_p(".b60"), |_, _span| Bsel::B60),
107 map(string_p(".b61"), |_, _span| Bsel::B61),
108 map(string_p(".b62"), |_, _span| Bsel::B62),
109 map(string_p(".b63"), |_, _span| Bsel::B63),
110 map(string_p(".b64"), |_, _span| Bsel::B64),
111 map(string_p(".b65"), |_, _span| Bsel::B65),
112 map(string_p(".b66"), |_, _span| Bsel::B66),
113 map(string_p(".b67"), |_, _span| Bsel::B67),
114 map(string_p(".b70"), |_, _span| Bsel::B70),
115 map(string_p(".b71"), |_, _span| Bsel::B71),
116 map(string_p(".b72"), |_, _span| Bsel::B72),
117 map(string_p(".b73"), |_, _span| Bsel::B73),
118 map(string_p(".b74"), |_, _span| Bsel::B74),
119 map(string_p(".b75"), |_, _span| Bsel::B75),
120 map(string_p(".b76"), |_, _span| Bsel::B76),
121 map(string_p(".b77"), |_, _span| Bsel::B77)
122 )
123 }
124 }
125
126 impl PtxParser for Btype {
127 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
128 alt!(
129 map(string_p(".u32"), |_, _span| Btype::U32),
130 map(string_p(".s32"), |_, _span| Btype::S32)
131 )
132 }
133 }
134
135 impl PtxParser for Cmp {
136 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
137 alt!(
138 map(string_p(".eq"), |_, _span| Cmp::Eq),
139 map(string_p(".ne"), |_, _span| Cmp::Ne),
140 map(string_p(".lt"), |_, _span| Cmp::Lt),
141 map(string_p(".le"), |_, _span| Cmp::Le),
142 map(string_p(".gt"), |_, _span| Cmp::Gt),
143 map(string_p(".ge"), |_, _span| Cmp::Ge)
144 )
145 }
146 }
147
148 impl PtxParser for Mask {
149 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
150 alt!(
151 map(string_p(".b10.b2"), |_, _span| Mask::B10B2),
152 map(string_p(".b3210"), |_, _span| Mask::B3210),
153 map(string_p(".b210"), |_, _span| Mask::B210),
154 map(string_p(".b310"), |_, _span| Mask::B310),
155 map(string_p(".b320"), |_, _span| Mask::B320),
156 map(string_p(".b321"), |_, _span| Mask::B321),
157 map(string_p(".b20"), |_, _span| Mask::B20),
158 map(string_p(".b21"), |_, _span| Mask::B21),
159 map(string_p(".b30"), |_, _span| Mask::B30),
160 map(string_p(".b31"), |_, _span| Mask::B31),
161 map(string_p(".b32"), |_, _span| Mask::B32),
162 map(string_p(".b0"), |_, _span| Mask::B0),
163 map(string_p(".b1"), |_, _span| Mask::B1),
164 map(string_p(".b3"), |_, _span| Mask::B3)
165 )
166 }
167 }
168
169 impl PtxParser for Vset4AtypeBtypeCmp {
170 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
171 try_map(
172 seq_n!(
173 string_p("vset4"),
174 Atype::parse(),
175 Btype::parse(),
176 Cmp::parse(),
177 GeneralOperand::parse(),
178 optional(Mask::parse()),
179 comma_p(),
180 GeneralOperand::parse(),
181 map(optional(string_p(".asel")), |value, _| value.is_some()),
182 comma_p(),
183 GeneralOperand::parse(),
184 optional(Bsel::parse()),
185 comma_p(),
186 GeneralOperand::parse(),
187 semicolon_p()
188 ),
189 |(_, atype, btype, cmp, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
190 ok!(Vset4AtypeBtypeCmp {
191 atype = atype,
192 btype = btype,
193 cmp = cmp,
194 d = d,
195 mask = mask,
196 a = a,
197 asel = asel,
198 b = b,
199 bsel = bsel,
200 c = c,
201
202 })
203 },
204 )
205 }
206 }
207
208 impl PtxParser for Vset4AtypeBtypeCmpAdd {
209 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
210 try_map(
211 seq_n!(
212 string_p("vset4"),
213 Atype::parse(),
214 Btype::parse(),
215 Cmp::parse(),
216 string_p(".add"),
217 GeneralOperand::parse(),
218 optional(Mask::parse()),
219 comma_p(),
220 GeneralOperand::parse(),
221 map(optional(string_p(".asel")), |value, _| value.is_some()),
222 comma_p(),
223 GeneralOperand::parse(),
224 optional(Bsel::parse()),
225 comma_p(),
226 GeneralOperand::parse(),
227 semicolon_p()
228 ),
229 |(_, atype, btype, cmp, add, d, mask, _, a, asel, _, b, bsel, _, c, _), span| {
230 ok!(Vset4AtypeBtypeCmpAdd {
231 atype = atype,
232 btype = btype,
233 cmp = cmp,
234 add = add,
235 d = d,
236 mask = mask,
237 a = a,
238 asel = asel,
239 b = b,
240 bsel = bsel,
241 c = c,
242
243 })
244 },
245 )
246 }
247 }
248}