ptx_parser/parser/instruction/
szext.rs1#![allow(unused)]
8
9use crate::parser::{
10 PtxParseError, PtxParser, PtxTokenStream, Span,
11 util::{
12 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
13 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
14 },
15};
16use crate::r#type::common::*;
17use crate::{alt, ok, seq_n};
18
19pub mod section_0 {
20 use super::*;
21 use crate::r#type::instruction::szext::section_0::*;
22
23 impl PtxParser for Mode {
28 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
29 alt!(
30 map(string_p(".clamp"), |_, _span| Mode::Clamp),
31 map(string_p(".wrap"), |_, _span| Mode::Wrap)
32 )
33 }
34 }
35
36 impl PtxParser for Type {
37 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
38 alt!(
39 map(string_p(".u32"), |_, _span| Type::U32),
40 map(string_p(".s32"), |_, _span| Type::S32)
41 )
42 }
43 }
44
45 impl PtxParser for SzextModeType {
46 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
47 try_map(
48 seq_n!(
49 string_p("szext"),
50 Mode::parse(),
51 Type::parse(),
52 GeneralOperand::parse(),
53 comma_p(),
54 GeneralOperand::parse(),
55 comma_p(),
56 GeneralOperand::parse(),
57 semicolon_p()
58 ),
59 |(_, mode, type_, d, _, a, _, b, _), span| {
60 ok!(SzextModeType {
61 mode = mode,
62 type_ = type_,
63 d = d,
64 a = a,
65 b = b,
66
67 })
68 },
69 )
70 }
71 }
72}