Skip to main content

ptx_parser/unparser/instruction/
bfind.rs

1//! Original PTX specification:
2//!
3//! bfind.type           d, a;
4//! bfind.shiftamt.type  d, a;
5//! .type = { .u32, .u64, .s32, .s64 };
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::bfind::section_0::*;
15
16    impl PtxUnparser for BfindType {
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, "bfind");
22            match &self.type_ {
23                Type::U32 => {
24                    push_directive(tokens, "u32");
25                }
26                Type::U64 => {
27                    push_directive(tokens, "u64");
28                }
29                Type::S32 => {
30                    push_directive(tokens, "s32");
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::Semicolon);
46            if spaced {
47                tokens.push(PtxToken::Newline);
48            }
49        }
50    }
51
52    impl PtxUnparser for BfindShiftamtType {
53        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
54            self.unparse_tokens_mode(tokens, false);
55        }
56        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
57            push_opcode(tokens, "bfind");
58            push_directive(tokens, "shiftamt");
59            match &self.type_ {
60                Type::U32 => {
61                    push_directive(tokens, "u32");
62                }
63                Type::U64 => {
64                    push_directive(tokens, "u64");
65                }
66                Type::S32 => {
67                    push_directive(tokens, "s32");
68                }
69                Type::S64 => {
70                    push_directive(tokens, "s64");
71                }
72            }
73            if spaced {
74                tokens.push(PtxToken::Space);
75            }
76            self.d.unparse_tokens_mode(tokens, spaced);
77            tokens.push(PtxToken::Comma);
78            if spaced {
79                tokens.push(PtxToken::Space);
80            }
81            self.a.unparse_tokens_mode(tokens, spaced);
82            tokens.push(PtxToken::Semicolon);
83            if spaced {
84                tokens.push(PtxToken::Newline);
85            }
86        }
87    }
88}