ptx_parser/parser/instruction/
slct.rs1#![allow(unused)]
11
12use crate::parser::{
13 PtxParseError, PtxParser, PtxTokenStream, Span,
14 util::{
15 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
16 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
17 },
18};
19use crate::r#type::common::*;
20use crate::{alt, ok, seq_n};
21
22pub mod section_0 {
23 use super::*;
24 use crate::r#type::instruction::slct::section_0::*;
25
26 impl PtxParser for Dtype {
31 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
32 alt!(
33 map(string_p(".b16"), |_, _span| Dtype::B16),
34 map(string_p(".b32"), |_, _span| Dtype::B32),
35 map(string_p(".b64"), |_, _span| Dtype::B64),
36 map(string_p(".u16"), |_, _span| Dtype::U16),
37 map(string_p(".u32"), |_, _span| Dtype::U32),
38 map(string_p(".u64"), |_, _span| Dtype::U64),
39 map(string_p(".s16"), |_, _span| Dtype::S16),
40 map(string_p(".s32"), |_, _span| Dtype::S32),
41 map(string_p(".s64"), |_, _span| Dtype::S64),
42 map(string_p(".f32"), |_, _span| Dtype::F32),
43 map(string_p(".f64"), |_, _span| Dtype::F64)
44 )
45 }
46 }
47
48 impl PtxParser for SlctDtypeS32 {
49 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
50 try_map(
51 seq_n!(
52 string_p("slct"),
53 Dtype::parse(),
54 string_p(".s32"),
55 GeneralOperand::parse(),
56 comma_p(),
57 GeneralOperand::parse(),
58 comma_p(),
59 GeneralOperand::parse(),
60 comma_p(),
61 GeneralOperand::parse(),
62 semicolon_p()
63 ),
64 |(_, dtype, s32, d, _, a, _, b, _, c, _), span| {
65 ok!(SlctDtypeS32 {
66 dtype = dtype,
67 s32 = s32,
68 d = d,
69 a = a,
70 b = b,
71 c = c,
72
73 })
74 },
75 )
76 }
77 }
78
79 impl PtxParser for SlctFtzDtypeF32 {
80 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
81 try_map(
82 seq_n!(
83 string_p("slct"),
84 map(optional(string_p(".ftz")), |value, _| value.is_some()),
85 Dtype::parse(),
86 string_p(".f32"),
87 GeneralOperand::parse(),
88 comma_p(),
89 GeneralOperand::parse(),
90 comma_p(),
91 GeneralOperand::parse(),
92 comma_p(),
93 GeneralOperand::parse(),
94 semicolon_p()
95 ),
96 |(_, ftz, dtype, f32, d, _, a, _, b, _, c, _), span| {
97 ok!(SlctFtzDtypeF32 {
98 ftz = ftz,
99 dtype = dtype,
100 f32 = f32,
101 d = d,
102 a = a,
103 b = b,
104 c = c,
105
106 })
107 },
108 )
109 }
110 }
111}