1#![allow(unused)]
16
17use crate::parser::{
18 PtxParseError, PtxParser, PtxTokenStream, Span,
19 util::{
20 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
21 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
22 },
23};
24use crate::r#type::common::*;
25use crate::{alt, ok, seq_n};
26
27pub mod section_0 {
28 use super::*;
29 use crate::r#type::instruction::sured::section_0::*;
30
31 impl PtxParser for Ctype {
36 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
37 alt!(
38 map(string_p(".u32"), |_, _span| Ctype::U32),
39 map(string_p(".u64"), |_, _span| Ctype::U64),
40 map(string_p(".s32"), |_, _span| Ctype::S32),
41 map(string_p(".b32"), |_, _span| Ctype::B32),
42 map(string_p(".s64"), |_, _span| Ctype::S64)
43 )
44 }
45 }
46
47 impl PtxParser for Geom {
48 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
49 alt!(
50 map(string_p(".1d"), |_, _span| Geom::_1d),
51 map(string_p(".2d"), |_, _span| Geom::_2d),
52 map(string_p(".3d"), |_, _span| Geom::_3d)
53 )
54 }
55 }
56
57 impl PtxParser for Mode {
58 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
59 alt!(
60 map(string_p(".clamp"), |_, _span| Mode::Clamp),
61 map(string_p(".trap"), |_, _span| Mode::Trap),
62 map(string_p(".zero"), |_, _span| Mode::Zero)
63 )
64 }
65 }
66
67 impl PtxParser for Op {
68 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
69 alt!(
70 map(string_p(".add"), |_, _span| Op::Add),
71 map(string_p(".min"), |_, _span| Op::Min),
72 map(string_p(".max"), |_, _span| Op::Max),
73 map(string_p(".and"), |_, _span| Op::And),
74 map(string_p(".or"), |_, _span| Op::Or)
75 )
76 }
77 }
78
79 impl PtxParser for SuredBOpGeomCtypeMode {
80 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
81 try_map(
82 seq_n!(
83 string_p("sured"),
84 string_p(".b"),
85 Op::parse(),
86 Geom::parse(),
87 Ctype::parse(),
88 Mode::parse(),
89 TexHandler2::parse(),
90 comma_p(),
91 GeneralOperand::parse(),
92 semicolon_p()
93 ),
94 |(_, b, op, geom, ctype, mode, a, _, c, _), span| {
95 ok!(SuredBOpGeomCtypeMode {
96 b = b,
97 op = op,
98 geom = geom,
99 ctype = ctype,
100 mode = mode,
101 a = a,
102 c = c,
103
104 })
105 },
106 )
107 }
108 }
109}
110
111pub mod section_1 {
112 use super::*;
113 use crate::r#type::instruction::sured::section_1::*;
114
115 impl PtxParser for Ctype {
120 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
121 alt!(
122 map(string_p(".b32"), |_, _span| Ctype::B32),
123 map(string_p(".b64"), |_, _span| Ctype::B64)
124 )
125 }
126 }
127
128 impl PtxParser for Geom {
129 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
130 alt!(
131 map(string_p(".1d"), |_, _span| Geom::_1d),
132 map(string_p(".2d"), |_, _span| Geom::_2d),
133 map(string_p(".3d"), |_, _span| Geom::_3d)
134 )
135 }
136 }
137
138 impl PtxParser for Mode {
139 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
140 alt!(
141 map(string_p(".clamp"), |_, _span| Mode::Clamp),
142 map(string_p(".trap"), |_, _span| Mode::Trap),
143 map(string_p(".zero"), |_, _span| Mode::Zero)
144 )
145 }
146 }
147
148 impl PtxParser for Op {
149 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
150 alt!(
151 map(string_p(".add"), |_, _span| Op::Add),
152 map(string_p(".min"), |_, _span| Op::Min),
153 map(string_p(".max"), |_, _span| Op::Max),
154 map(string_p(".and"), |_, _span| Op::And),
155 map(string_p(".or"), |_, _span| Op::Or)
156 )
157 }
158 }
159
160 impl PtxParser for SuredPOpGeomCtypeMode {
161 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
162 try_map(
163 seq_n!(
164 string_p("sured"),
165 string_p(".p"),
166 Op::parse(),
167 Geom::parse(),
168 Ctype::parse(),
169 Mode::parse(),
170 TexHandler2::parse(),
171 comma_p(),
172 GeneralOperand::parse(),
173 semicolon_p()
174 ),
175 |(_, p, op, geom, ctype, mode, a, _, c, _), span| {
176 ok!(SuredPOpGeomCtypeMode {
177 p = p,
178 op = op,
179 geom = geom,
180 ctype = ctype,
181 mode = mode,
182 a = a,
183 c = c,
184
185 })
186 },
187 )
188 }
189 }
190}