Skip to main content

ptx_parser/unparser/instruction/
mad_cc.rs

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