Skip to main content

ptx_parser/unparser/instruction/
subc.rs

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