Skip to main content

ptx_parser/unparser/instruction/
getctarank.rs

1//! Original PTX specification:
2//!
3//! getctarank{.space}.type d, a;
4//! // Get cta rank from source shared memory address in register a.
5//! getctarank.shared::cluster.type d, a;
6//! // // Get cta rank from shared memory variable.
7//! // getctarank.shared::cluster.type d, var;
8//! // // Get cta rank from shared memory variable+offset.
9//! // getctarank.shared::cluster.type d, var + imm;
10//! // Get cta rank from generic address of shared memory variable in register a.
11//! getctarank.type d, a;
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::getctarank::section_0::*;
23
24    impl PtxUnparser for GetctarankSpaceType {
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, "getctarank");
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::Semicolon);
55            if spaced {
56                tokens.push(PtxToken::Newline);
57            }
58        }
59    }
60
61    impl PtxUnparser for GetctarankSharedClusterType {
62        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
63            self.unparse_tokens_mode(tokens, false);
64        }
65        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
66            push_opcode(tokens, "getctarank");
67            push_directive(tokens, "shared::cluster");
68            match &self.type_ {
69                Type::U32 => {
70                    push_directive(tokens, "u32");
71                }
72                Type::U64 => {
73                    push_directive(tokens, "u64");
74                }
75            }
76            if spaced {
77                tokens.push(PtxToken::Space);
78            }
79            self.d.unparse_tokens_mode(tokens, spaced);
80            tokens.push(PtxToken::Comma);
81            if spaced {
82                tokens.push(PtxToken::Space);
83            }
84            self.a.unparse_tokens_mode(tokens, spaced);
85            tokens.push(PtxToken::Semicolon);
86            if spaced {
87                tokens.push(PtxToken::Newline);
88            }
89        }
90    }
91
92    impl PtxUnparser for GetctarankType {
93        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
94            self.unparse_tokens_mode(tokens, false);
95        }
96        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
97            push_opcode(tokens, "getctarank");
98            match &self.type_ {
99                Type::U32 => {
100                    push_directive(tokens, "u32");
101                }
102                Type::U64 => {
103                    push_directive(tokens, "u64");
104                }
105            }
106            if spaced {
107                tokens.push(PtxToken::Space);
108            }
109            self.d.unparse_tokens_mode(tokens, spaced);
110            tokens.push(PtxToken::Comma);
111            if spaced {
112                tokens.push(PtxToken::Space);
113            }
114            self.a.unparse_tokens_mode(tokens, spaced);
115            tokens.push(PtxToken::Semicolon);
116            if spaced {
117                tokens.push(PtxToken::Newline);
118            }
119        }
120    }
121}