Skip to main content

ptx_parser/unparser/instruction/
selp.rs

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