Skip to main content

ptx_parser/unparser/instruction/
match_sync.rs

1//! Original PTX specification:
2//!
3//! match.any.sync.type  d, a, membermask;
4//! match.all.sync.type  d{|p}, a, membermask;
5//! .type = { .b32, .b64 };
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::match_sync::section_0::*;
15
16    impl PtxUnparser for MatchAnySyncType {
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, "match");
22            push_directive(tokens, "any");
23            push_directive(tokens, "sync");
24            match &self.type_ {
25                Type::B32 => {
26                    push_directive(tokens, "b32");
27                }
28                Type::B64 => {
29                    push_directive(tokens, "b64");
30                }
31            }
32            if spaced {
33                tokens.push(PtxToken::Space);
34            }
35            self.d.unparse_tokens_mode(tokens, spaced);
36            tokens.push(PtxToken::Comma);
37            if spaced {
38                tokens.push(PtxToken::Space);
39            }
40            self.a.unparse_tokens_mode(tokens, spaced);
41            tokens.push(PtxToken::Comma);
42            if spaced {
43                tokens.push(PtxToken::Space);
44            }
45            self.membermask.unparse_tokens_mode(tokens, spaced);
46            tokens.push(PtxToken::Semicolon);
47            if spaced {
48                tokens.push(PtxToken::Newline);
49            }
50        }
51    }
52
53    impl PtxUnparser for MatchAllSyncType {
54        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
55            self.unparse_tokens_mode(tokens, false);
56        }
57        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
58            push_opcode(tokens, "match");
59            push_directive(tokens, "all");
60            push_directive(tokens, "sync");
61            match &self.type_ {
62                Type::B32 => {
63                    push_directive(tokens, "b32");
64                }
65                Type::B64 => {
66                    push_directive(tokens, "b64");
67                }
68            }
69            if spaced {
70                tokens.push(PtxToken::Space);
71            }
72            self.d.unparse_tokens_mode(tokens, spaced);
73            if let Some(p_0) = self.p.as_ref() {
74                tokens.push(PtxToken::Pipe);
75                p_0.unparse_tokens_mode(tokens, spaced);
76            }
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::Comma);
83            if spaced {
84                tokens.push(PtxToken::Space);
85            }
86            self.membermask.unparse_tokens_mode(tokens, spaced);
87            tokens.push(PtxToken::Semicolon);
88            if spaced {
89                tokens.push(PtxToken::Newline);
90            }
91        }
92    }
93}