Skip to main content

ptx_parser/unparser/instruction/
mapa.rs

1//! Original PTX specification:
2//!
3//! mapa{.space}.type          d, a, b;
4//! // Maps shared memory address in register a into CTA b.
5//! // mapa.shared::cluster.type  d, a, b;
6//! // Maps shared memory variable into CTA b.
7//! // mapa.shared::cluster.type  d, sh, b;
8//! // Maps shared memory variable into CTA b.
9//! // mapa.shared::cluster.type  d, sh + imm, b;
10//! // Maps generic address in register a into CTA b.
11//! // mapa.type                  d, a, b;
12//! .space = { .shared::cluster };
13//! .type  = { .u32, .u64 };
14
15#![allow(unused)]
16
17use crate::lexer::PtxToken;
18use crate::unparser::{PtxUnparser, common::*};
19
20pub mod section_0 {
21    use super::*;
22    use crate::r#type::instruction::mapa::section_0::*;
23
24    impl PtxUnparser for MapaSpaceType {
25        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
26            self.unparse_tokens_mode(tokens, false);
27        }
28        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
29            push_opcode(tokens, "mapa");
30            if let Some(space_0) = self.space.as_ref() {
31                match space_0 {
32                    Space::SharedCluster => {
33                        push_directive(tokens, "shared::cluster");
34                    }
35                }
36            }
37            match &self.type_ {
38                Type::U32 => {
39                    push_directive(tokens, "u32");
40                }
41                Type::U64 => {
42                    push_directive(tokens, "u64");
43                }
44            }
45            if spaced {
46                tokens.push(PtxToken::Space);
47            }
48            self.d.unparse_tokens_mode(tokens, spaced);
49            tokens.push(PtxToken::Comma);
50            if spaced {
51                tokens.push(PtxToken::Space);
52            }
53            self.a.unparse_tokens_mode(tokens, spaced);
54            tokens.push(PtxToken::Comma);
55            if spaced {
56                tokens.push(PtxToken::Space);
57            }
58            self.b.unparse_tokens_mode(tokens, spaced);
59            tokens.push(PtxToken::Semicolon);
60            if spaced {
61                tokens.push(PtxToken::Newline);
62            }
63        }
64    }
65}