Skip to main content

ptx_parser/unparser/instruction/
dp2a.rs

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