Skip to main content

ptx_parser/unparser/instruction/
madc.rs

1//! Original PTX specification:
2//!
3//! madc.hilo{.cc}.type  d, a, b, c;
4//! .type = { .u32, .s32, .u64, .s64 };
5//! .hilo = { .hi, .lo };
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::madc::section_0::*;
15
16    impl PtxUnparser for MadcHiloCcType {
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, "madc");
22            match &self.hilo {
23                Hilo::Hi => {
24                    push_directive(tokens, "hi");
25                }
26                Hilo::Lo => {
27                    push_directive(tokens, "lo");
28                }
29            }
30            if self.cc {
31                push_directive(tokens, "cc");
32            }
33            match &self.type_ {
34                Type::U32 => {
35                    push_directive(tokens, "u32");
36                }
37                Type::S32 => {
38                    push_directive(tokens, "s32");
39                }
40                Type::U64 => {
41                    push_directive(tokens, "u64");
42                }
43                Type::S64 => {
44                    push_directive(tokens, "s64");
45                }
46            }
47            if spaced {
48                tokens.push(PtxToken::Space);
49            }
50            self.d.unparse_tokens_mode(tokens, spaced);
51            tokens.push(PtxToken::Comma);
52            if spaced {
53                tokens.push(PtxToken::Space);
54            }
55            self.a.unparse_tokens_mode(tokens, spaced);
56            tokens.push(PtxToken::Comma);
57            if spaced {
58                tokens.push(PtxToken::Space);
59            }
60            self.b.unparse_tokens_mode(tokens, spaced);
61            tokens.push(PtxToken::Comma);
62            if spaced {
63                tokens.push(PtxToken::Space);
64            }
65            self.c.unparse_tokens_mode(tokens, spaced);
66            tokens.push(PtxToken::Semicolon);
67            if spaced {
68                tokens.push(PtxToken::Newline);
69            }
70        }
71    }
72}