ptx_parser/unparser/instruction/
bar.rs

1//! Original PTX specification:
2//!
3//! barrier{.cta}.sync{.aligned}      a{, b};
4//! barrier{.cta}.arrive{.aligned}    a, b;
5//! barrier{.cta}.red.popc{.aligned}.u32  d, a{, b}, {!}c;
6//! barrier{.cta}.red.op{.aligned}.pred   p, a{, b}, {!}c;
7//! bar{.cta}.sync      a{, b};
8//! bar{.cta}.arrive    a, b;
9//! bar{.cta}.red.popc.u32  d, a{, b}, {!}c;
10//! bar{.cta}.red.op.pred   p, a{, b}, {!}c;
11//! .op = { .and, .or };
12
13#![allow(unused)]
14
15use crate::lexer::PtxToken;
16use crate::unparser::{PtxUnparser, common::*};
17
18pub mod section_0 {
19    use super::*;
20    use crate::r#type::instruction::bar::section_0::*;
21
22    impl PtxUnparser for BarrierCtaSyncAligned {
23        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
24            push_opcode(tokens, "barrier");
25            if self.cta {
26                push_directive(tokens, "cta");
27            }
28            push_directive(tokens, "sync");
29            if self.aligned {
30                push_directive(tokens, "aligned");
31            }
32            self.a.unparse_tokens(tokens);
33            if self.b.is_some() {
34                tokens.push(PtxToken::Comma);
35            }
36            if let Some(opt_0) = self.b.as_ref() {
37                opt_0.unparse_tokens(tokens);
38            }
39            tokens.push(PtxToken::Semicolon);
40        }
41    }
42
43    impl PtxUnparser for BarrierCtaArriveAligned {
44        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
45            push_opcode(tokens, "barrier");
46            if self.cta {
47                push_directive(tokens, "cta");
48            }
49            push_directive(tokens, "arrive");
50            if self.aligned {
51                push_directive(tokens, "aligned");
52            }
53            self.a.unparse_tokens(tokens);
54            tokens.push(PtxToken::Comma);
55            self.b.unparse_tokens(tokens);
56            tokens.push(PtxToken::Semicolon);
57        }
58    }
59
60    impl PtxUnparser for BarrierCtaRedPopcAlignedU32 {
61        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
62            push_opcode(tokens, "barrier");
63            if self.cta {
64                push_directive(tokens, "cta");
65            }
66            push_directive(tokens, "red");
67            push_directive(tokens, "popc");
68            if self.aligned {
69                push_directive(tokens, "aligned");
70            }
71            push_directive(tokens, "u32");
72            self.d.unparse_tokens(tokens);
73            tokens.push(PtxToken::Comma);
74            self.a.unparse_tokens(tokens);
75            if self.b.is_some() {
76                tokens.push(PtxToken::Comma);
77            }
78            if let Some(opt_1) = self.b.as_ref() {
79                opt_1.unparse_tokens(tokens);
80            }
81            tokens.push(PtxToken::Comma);
82            if self.c_op {
83                tokens.push(PtxToken::Exclaim);
84            }
85            self.c.unparse_tokens(tokens);
86            tokens.push(PtxToken::Semicolon);
87        }
88    }
89
90    impl PtxUnparser for BarrierCtaRedOpAlignedPred {
91        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
92            push_opcode(tokens, "barrier");
93            if self.cta {
94                push_directive(tokens, "cta");
95            }
96            push_directive(tokens, "red");
97            match &self.op {
98                Op::And => {
99                    push_directive(tokens, "and");
100                }
101                Op::Or => {
102                    push_directive(tokens, "or");
103                }
104            }
105            if self.aligned {
106                push_directive(tokens, "aligned");
107            }
108            push_directive(tokens, "pred");
109            self.p.unparse_tokens(tokens);
110            tokens.push(PtxToken::Comma);
111            self.a.unparse_tokens(tokens);
112            if self.b.is_some() {
113                tokens.push(PtxToken::Comma);
114            }
115            if let Some(opt_2) = self.b.as_ref() {
116                opt_2.unparse_tokens(tokens);
117            }
118            tokens.push(PtxToken::Comma);
119            if self.c_op {
120                tokens.push(PtxToken::Exclaim);
121            }
122            self.c.unparse_tokens(tokens);
123            tokens.push(PtxToken::Semicolon);
124        }
125    }
126
127    impl PtxUnparser for BarCtaSync {
128        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
129            push_opcode(tokens, "bar");
130            if self.cta {
131                push_directive(tokens, "cta");
132            }
133            push_directive(tokens, "sync");
134            self.a.unparse_tokens(tokens);
135            if self.b.is_some() {
136                tokens.push(PtxToken::Comma);
137            }
138            if let Some(opt_3) = self.b.as_ref() {
139                opt_3.unparse_tokens(tokens);
140            }
141            tokens.push(PtxToken::Semicolon);
142        }
143    }
144
145    impl PtxUnparser for BarCtaArrive {
146        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
147            push_opcode(tokens, "bar");
148            if self.cta {
149                push_directive(tokens, "cta");
150            }
151            push_directive(tokens, "arrive");
152            self.a.unparse_tokens(tokens);
153            tokens.push(PtxToken::Comma);
154            self.b.unparse_tokens(tokens);
155            tokens.push(PtxToken::Semicolon);
156        }
157    }
158
159    impl PtxUnparser for BarCtaRedPopcU32 {
160        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
161            push_opcode(tokens, "bar");
162            if self.cta {
163                push_directive(tokens, "cta");
164            }
165            push_directive(tokens, "red");
166            push_directive(tokens, "popc");
167            push_directive(tokens, "u32");
168            self.d.unparse_tokens(tokens);
169            tokens.push(PtxToken::Comma);
170            self.a.unparse_tokens(tokens);
171            if self.b.is_some() {
172                tokens.push(PtxToken::Comma);
173            }
174            if let Some(opt_4) = self.b.as_ref() {
175                opt_4.unparse_tokens(tokens);
176            }
177            tokens.push(PtxToken::Comma);
178            if self.c_op {
179                tokens.push(PtxToken::Exclaim);
180            }
181            self.c.unparse_tokens(tokens);
182            tokens.push(PtxToken::Semicolon);
183        }
184    }
185
186    impl PtxUnparser for BarCtaRedOpPred {
187        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
188            push_opcode(tokens, "bar");
189            if self.cta {
190                push_directive(tokens, "cta");
191            }
192            push_directive(tokens, "red");
193            match &self.op {
194                Op::And => {
195                    push_directive(tokens, "and");
196                }
197                Op::Or => {
198                    push_directive(tokens, "or");
199                }
200            }
201            push_directive(tokens, "pred");
202            self.p.unparse_tokens(tokens);
203            tokens.push(PtxToken::Comma);
204            self.a.unparse_tokens(tokens);
205            if self.b.is_some() {
206                tokens.push(PtxToken::Comma);
207            }
208            if let Some(opt_5) = self.b.as_ref() {
209                opt_5.unparse_tokens(tokens);
210            }
211            tokens.push(PtxToken::Comma);
212            if self.c_op {
213                tokens.push(PtxToken::Exclaim);
214            }
215            self.c.unparse_tokens(tokens);
216            tokens.push(PtxToken::Semicolon);
217        }
218    }
219}