Skip to main content

ptx_parser/unparser/instruction/
shr.rs

1//! Original PTX specification:
2//!
3//! shr.type d, a, b;
4//! .type = { .b16, .b32, .b64,
5//! .u16, .u32, .u64,
6//! .s16, .s32, .s64 };
7
8#![allow(unused)]
9
10use crate::lexer::PtxToken;
11use crate::unparser::{PtxUnparser, common::*};
12
13pub mod section_0 {
14    use super::*;
15    use crate::r#type::instruction::shr::section_0::*;
16
17    impl PtxUnparser for ShrType {
18        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
19            self.unparse_tokens_mode(tokens, false);
20        }
21        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
22            push_opcode(tokens, "shr");
23            match &self.type_ {
24                Type::B16 => {
25                    push_directive(tokens, "b16");
26                }
27                Type::B32 => {
28                    push_directive(tokens, "b32");
29                }
30                Type::B64 => {
31                    push_directive(tokens, "b64");
32                }
33                Type::U16 => {
34                    push_directive(tokens, "u16");
35                }
36                Type::U32 => {
37                    push_directive(tokens, "u32");
38                }
39                Type::U64 => {
40                    push_directive(tokens, "u64");
41                }
42                Type::S16 => {
43                    push_directive(tokens, "s16");
44                }
45                Type::S32 => {
46                    push_directive(tokens, "s32");
47                }
48                Type::S64 => {
49                    push_directive(tokens, "s64");
50                }
51            }
52            if spaced {
53                tokens.push(PtxToken::Space);
54            }
55            self.d.unparse_tokens_mode(tokens, spaced);
56            tokens.push(PtxToken::Comma);
57            if spaced {
58                tokens.push(PtxToken::Space);
59            }
60            self.a.unparse_tokens_mode(tokens, spaced);
61            tokens.push(PtxToken::Comma);
62            if spaced {
63                tokens.push(PtxToken::Space);
64            }
65            self.b.unparse_tokens_mode(tokens, spaced);
66            tokens.push(PtxToken::Semicolon);
67            if spaced {
68                tokens.push(PtxToken::Newline);
69            }
70        }
71    }
72}