ptx_parser/parser/instruction/
redux_sync.rs1#![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::redux_sync::section_0::*;
30
31 impl PtxParser for Op {
36 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
37 alt!(
38 map(string_p(".add"), |_, _span| Op::Add),
39 map(string_p(".min"), |_, _span| Op::Min),
40 map(string_p(".max"), |_, _span| Op::Max)
41 )
42 }
43 }
44
45 impl PtxParser for Type {
46 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
47 alt!(
48 map(string_p(".u32"), |_, _span| Type::U32),
49 map(string_p(".s32"), |_, _span| Type::S32)
50 )
51 }
52 }
53
54 impl PtxParser for ReduxSyncOpType {
55 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
56 try_map(
57 seq_n!(
58 string_p("redux"),
59 string_p(".sync"),
60 Op::parse(),
61 Type::parse(),
62 GeneralOperand::parse(),
63 comma_p(),
64 GeneralOperand::parse(),
65 comma_p(),
66 GeneralOperand::parse(),
67 semicolon_p()
68 ),
69 |(_, sync, op, type_, dst, _, src, _, membermask, _), span| {
70 ok!(ReduxSyncOpType {
71 sync = sync,
72 op = op,
73 type_ = type_,
74 dst = dst,
75 src = src,
76 membermask = membermask,
77
78 })
79 },
80 )
81 }
82 }
83}
84
85pub mod section_1 {
86 use super::*;
87 use crate::r#type::instruction::redux_sync::section_1::*;
88
89 impl PtxParser for Op {
94 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
95 alt!(
96 map(string_p(".and"), |_, _span| Op::And),
97 map(string_p(".xor"), |_, _span| Op::Xor),
98 map(string_p(".or"), |_, _span| Op::Or)
99 )
100 }
101 }
102
103 impl PtxParser for ReduxSyncOpB32 {
104 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
105 try_map(
106 seq_n!(
107 string_p("redux"),
108 string_p(".sync"),
109 Op::parse(),
110 string_p(".b32"),
111 GeneralOperand::parse(),
112 comma_p(),
113 GeneralOperand::parse(),
114 comma_p(),
115 GeneralOperand::parse(),
116 semicolon_p()
117 ),
118 |(_, sync, op, b32, dst, _, src, _, membermask, _), span| {
119 ok!(ReduxSyncOpB32 {
120 sync = sync,
121 op = op,
122 b32 = b32,
123 dst = dst,
124 src = src,
125 membermask = membermask,
126
127 })
128 },
129 )
130 }
131 }
132}
133
134pub mod section_2 {
135 use super::*;
136 use crate::r#type::instruction::redux_sync::section_2::*;
137
138 impl PtxParser for Op {
143 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
144 alt!(
145 map(string_p(".min"), |_, _span| Op::Min),
146 map(string_p(".max"), |_, _span| Op::Max)
147 )
148 }
149 }
150
151 impl PtxParser for ReduxSyncOpAbsNanF32 {
152 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
153 try_map(
154 seq_n!(
155 string_p("redux"),
156 string_p(".sync"),
157 Op::parse(),
158 map(optional(string_p(".abs")), |value, _| value.is_some()),
159 map(optional(string_p(".NaN")), |value, _| value.is_some()),
160 string_p(".f32"),
161 GeneralOperand::parse(),
162 comma_p(),
163 GeneralOperand::parse(),
164 comma_p(),
165 GeneralOperand::parse(),
166 semicolon_p()
167 ),
168 |(_, sync, op, abs, nan, f32, dst, _, src, _, membermask, _), span| {
169 ok!(ReduxSyncOpAbsNanF32 {
170 sync = sync,
171 op = op,
172 abs = abs,
173 nan = nan,
174 f32 = f32,
175 dst = dst,
176 src = src,
177 membermask = membermask,
178
179 })
180 },
181 )
182 }
183 }
184}