1#![allow(unused)]
15
16use crate::parser::{
17 PtxParseError, PtxParser, PtxTokenStream, Span,
18 util::{
19 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
20 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
21 },
22};
23use crate::r#type::common::*;
24use crate::{alt, ok, seq_n};
25
26pub mod section_0 {
27 use super::*;
28 use crate::r#type::instruction::neg::section_0::*;
29
30 impl PtxParser for Type {
35 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
36 alt!(
37 map(string_p(".s16"), |_, _span| Type::S16),
38 map(string_p(".s32"), |_, _span| Type::S32),
39 map(string_p(".s64"), |_, _span| Type::S64)
40 )
41 }
42 }
43
44 impl PtxParser for NegType {
45 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
46 try_map(
47 seq_n!(
48 string_p("neg"),
49 Type::parse(),
50 GeneralOperand::parse(),
51 comma_p(),
52 GeneralOperand::parse(),
53 semicolon_p()
54 ),
55 |(_, type_, d, _, a, _), span| {
56 ok!(NegType {
57 type_ = type_,
58 d = d,
59 a = a,
60
61 })
62 },
63 )
64 }
65 }
66
67 impl PtxParser for NegFtzF32 {
68 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
69 try_map(
70 seq_n!(
71 string_p("neg"),
72 map(optional(string_p(".ftz")), |value, _| value.is_some()),
73 string_p(".f32"),
74 GeneralOperand::parse(),
75 comma_p(),
76 GeneralOperand::parse(),
77 semicolon_p()
78 ),
79 |(_, ftz, f32, d, _, a, _), span| {
80 ok!(NegFtzF32 {
81 ftz = ftz,
82 f32 = f32,
83 d = d,
84 a = a,
85
86 })
87 },
88 )
89 }
90 }
91
92 impl PtxParser for NegF64 {
93 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
94 try_map(
95 seq_n!(
96 string_p("neg"),
97 string_p(".f64"),
98 GeneralOperand::parse(),
99 comma_p(),
100 GeneralOperand::parse(),
101 semicolon_p()
102 ),
103 |(_, f64, d, _, a, _), span| {
104 ok!(NegF64 {
105 f64 = f64,
106 d = d,
107 a = a,
108
109 })
110 },
111 )
112 }
113 }
114
115 impl PtxParser for NegFtzF16 {
116 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
117 try_map(
118 seq_n!(
119 string_p("neg"),
120 map(optional(string_p(".ftz")), |value, _| value.is_some()),
121 string_p(".f16"),
122 GeneralOperand::parse(),
123 comma_p(),
124 GeneralOperand::parse(),
125 semicolon_p()
126 ),
127 |(_, ftz, f16, d, _, a, _), span| {
128 ok!(NegFtzF16 {
129 ftz = ftz,
130 f16 = f16,
131 d = d,
132 a = a,
133
134 })
135 },
136 )
137 }
138 }
139
140 impl PtxParser for NegFtzF16x2 {
141 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
142 try_map(
143 seq_n!(
144 string_p("neg"),
145 map(optional(string_p(".ftz")), |value, _| value.is_some()),
146 string_p(".f16x2"),
147 GeneralOperand::parse(),
148 comma_p(),
149 GeneralOperand::parse(),
150 semicolon_p()
151 ),
152 |(_, ftz, f16x2, d, _, a, _), span| {
153 ok!(NegFtzF16x2 {
154 ftz = ftz,
155 f16x2 = f16x2,
156 d = d,
157 a = a,
158
159 })
160 },
161 )
162 }
163 }
164
165 impl PtxParser for NegBf16 {
166 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
167 try_map(
168 seq_n!(
169 string_p("neg"),
170 string_p(".bf16"),
171 GeneralOperand::parse(),
172 comma_p(),
173 GeneralOperand::parse(),
174 semicolon_p()
175 ),
176 |(_, bf16, d, _, a, _), span| {
177 ok!(NegBf16 {
178 bf16 = bf16,
179 d = d,
180 a = a,
181
182 })
183 },
184 )
185 }
186 }
187
188 impl PtxParser for NegBf16x2 {
189 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
190 try_map(
191 seq_n!(
192 string_p("neg"),
193 string_p(".bf16x2"),
194 GeneralOperand::parse(),
195 comma_p(),
196 GeneralOperand::parse(),
197 semicolon_p()
198 ),
199 |(_, bf16x2, d, _, a, _), span| {
200 ok!(NegBf16x2 {
201 bf16x2 = bf16x2,
202 d = d,
203 a = a,
204
205 })
206 },
207 )
208 }
209 }
210}