Skip to main content

ptx_parser/unparser/instruction/
dp4a.rs

1//! Original PTX specification:
2//!
3//! dp4a.atype.btype  d, a, b, c;
4//! .atype = .btype = { .u32, .s32 };
5
6#![allow(unused)]
7
8use crate::lexer::PtxToken;
9use crate::unparser::{PtxUnparser, common::*};
10
11pub mod section_0 {
12    use super::*;
13    use crate::r#type::instruction::dp4a::section_0::*;
14
15    impl PtxUnparser for Dp4aAtypeBtype {
16        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
17            self.unparse_tokens_mode(tokens, false);
18        }
19        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
20            push_opcode(tokens, "dp4a");
21            match &self.atype {
22                Atype::U32 => {
23                    push_directive(tokens, "u32");
24                }
25                Atype::S32 => {
26                    push_directive(tokens, "s32");
27                }
28            }
29            match &self.btype {
30                Btype::U32 => {
31                    push_directive(tokens, "u32");
32                }
33                Btype::S32 => {
34                    push_directive(tokens, "s32");
35                }
36            }
37            if spaced {
38                tokens.push(PtxToken::Space);
39            }
40            self.d.unparse_tokens_mode(tokens, spaced);
41            tokens.push(PtxToken::Comma);
42            if spaced {
43                tokens.push(PtxToken::Space);
44            }
45            self.a.unparse_tokens_mode(tokens, spaced);
46            tokens.push(PtxToken::Comma);
47            if spaced {
48                tokens.push(PtxToken::Space);
49            }
50            self.b.unparse_tokens_mode(tokens, spaced);
51            tokens.push(PtxToken::Comma);
52            if spaced {
53                tokens.push(PtxToken::Space);
54            }
55            self.c.unparse_tokens_mode(tokens, spaced);
56            tokens.push(PtxToken::Semicolon);
57            if spaced {
58                tokens.push(PtxToken::Newline);
59            }
60        }
61    }
62}