ptx_parser/parser/instruction/
stmatrix.rs1#![allow(unused)]
10
11use crate::parser::{
12 PtxParseError, PtxParser, PtxTokenStream, Span,
13 util::{
14 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
15 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
16 },
17};
18use crate::r#type::common::*;
19use crate::{alt, ok, seq_n};
20
21pub mod section_0 {
22 use super::*;
23 use crate::r#type::instruction::stmatrix::section_0::*;
24
25 impl PtxParser for Num {
30 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
31 alt!(
32 map(string_p(".x1"), |_, _span| Num::X1),
33 map(string_p(".x2"), |_, _span| Num::X2),
34 map(string_p(".x4"), |_, _span| Num::X4)
35 )
36 }
37 }
38
39 impl PtxParser for Shape {
40 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
41 alt!(
42 map(string_p(".m16n8"), |_, _span| Shape::M16n8),
43 map(string_p(".m8n8"), |_, _span| Shape::M8n8)
44 )
45 }
46 }
47
48 impl PtxParser for Ss {
49 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
50 alt!(
51 map(string_p(".shared::cta"), |_, _span| Ss::SharedCta),
52 map(string_p(".shared"), |_, _span| Ss::Shared)
53 )
54 }
55 }
56
57 impl PtxParser for Type {
58 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
59 alt!(
60 map(string_p(".b16"), |_, _span| Type::B16),
61 map(string_p(".b8"), |_, _span| Type::B8)
62 )
63 }
64 }
65
66 impl PtxParser for StmatrixSyncAlignedShapeNumTransSsType {
67 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
68 try_map(
69 seq_n!(
70 string_p("stmatrix"),
71 string_p(".sync"),
72 string_p(".aligned"),
73 Shape::parse(),
74 Num::parse(),
75 map(optional(string_p(".trans")), |value, _| value.is_some()),
76 optional(Ss::parse()),
77 Type::parse(),
78 AddressOperand::parse(),
79 comma_p(),
80 GeneralOperand::parse(),
81 semicolon_p()
82 ),
83 |(_, sync, aligned, shape, num, trans, ss, type_, p, _, r, _), span| {
84 ok!(StmatrixSyncAlignedShapeNumTransSsType {
85 sync = sync,
86 aligned = aligned,
87 shape = shape,
88 num = num,
89 trans = trans,
90 ss = ss,
91 type_ = type_,
92 p = p,
93 r = r,
94
95 })
96 },
97 )
98 }
99 }
100}