Skip to main content

ptx_parser/unparser/instruction/
add_cc.rs

1//! Original PTX specification:
2//!
3//! add.cc.type  d, a, b;
4//! .type = { .u32, .s32, .u64, .s64 };
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::add_cc::section_0::*;
14
15    impl PtxUnparser for AddCcType {
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, "add");
21            push_directive(tokens, "cc");
22            match &self.type_ {
23                Type::U32 => {
24                    push_directive(tokens, "u32");
25                }
26                Type::S32 => {
27                    push_directive(tokens, "s32");
28                }
29                Type::U64 => {
30                    push_directive(tokens, "u64");
31                }
32                Type::S64 => {
33                    push_directive(tokens, "s64");
34                }
35            }
36            if spaced {
37                tokens.push(PtxToken::Space);
38            }
39            self.d.unparse_tokens_mode(tokens, spaced);
40            tokens.push(PtxToken::Comma);
41            if spaced {
42                tokens.push(PtxToken::Space);
43            }
44            self.a.unparse_tokens_mode(tokens, spaced);
45            tokens.push(PtxToken::Comma);
46            if spaced {
47                tokens.push(PtxToken::Space);
48            }
49            self.b.unparse_tokens_mode(tokens, spaced);
50            tokens.push(PtxToken::Semicolon);
51            if spaced {
52                tokens.push(PtxToken::Newline);
53            }
54        }
55    }
56}