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() { tokens.push(PtxToken::Comma); }
34                    if let Some(opt_0) = self.b.as_ref() {
35                        opt_0.unparse_tokens(tokens);
36                    }
37            tokens.push(PtxToken::Semicolon);
38        }
39    }
40
41    impl PtxUnparser for BarrierCtaArriveAligned {
42        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
43            push_opcode(tokens, "barrier");
44                    if self.cta {
45                            push_directive(tokens, "cta");
46                    }
47                    push_directive(tokens, "arrive");
48                    if self.aligned {
49                            push_directive(tokens, "aligned");
50                    }
51                    self.a.unparse_tokens(tokens);
52            tokens.push(PtxToken::Comma);
53                    self.b.unparse_tokens(tokens);
54            tokens.push(PtxToken::Semicolon);
55        }
56    }
57
58    impl PtxUnparser for BarrierCtaRedPopcAlignedU32 {
59        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
60            push_opcode(tokens, "barrier");
61                    if self.cta {
62                            push_directive(tokens, "cta");
63                    }
64                    push_directive(tokens, "red");
65                    push_directive(tokens, "popc");
66                    if self.aligned {
67                            push_directive(tokens, "aligned");
68                    }
69                    push_directive(tokens, "u32");
70                    self.d.unparse_tokens(tokens);
71            tokens.push(PtxToken::Comma);
72                    self.a.unparse_tokens(tokens);
73            if self.b.is_some() { tokens.push(PtxToken::Comma); }
74                    if let Some(opt_1) = self.b.as_ref() {
75                        opt_1.unparse_tokens(tokens);
76                    }
77            tokens.push(PtxToken::Comma);
78            if self.c_op { tokens.push(PtxToken::Exclaim); }
79                    self.c.unparse_tokens(tokens);
80            tokens.push(PtxToken::Semicolon);
81        }
82    }
83
84    impl PtxUnparser for BarrierCtaRedOpAlignedPred {
85        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
86            push_opcode(tokens, "barrier");
87                    if self.cta {
88                            push_directive(tokens, "cta");
89                    }
90                    push_directive(tokens, "red");
91                    match &self.op {
92                            Op::And => {
93                                    push_directive(tokens, "and");
94                            }
95                            Op::Or => {
96                                    push_directive(tokens, "or");
97                            }
98                    }
99                    if self.aligned {
100                            push_directive(tokens, "aligned");
101                    }
102                    push_directive(tokens, "pred");
103                    self.p.unparse_tokens(tokens);
104            tokens.push(PtxToken::Comma);
105                    self.a.unparse_tokens(tokens);
106            if self.b.is_some() { tokens.push(PtxToken::Comma); }
107                    if let Some(opt_2) = self.b.as_ref() {
108                        opt_2.unparse_tokens(tokens);
109                    }
110            tokens.push(PtxToken::Comma);
111            if self.c_op { tokens.push(PtxToken::Exclaim); }
112                    self.c.unparse_tokens(tokens);
113            tokens.push(PtxToken::Semicolon);
114        }
115    }
116
117    impl PtxUnparser for BarCtaSync {
118        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
119            push_opcode(tokens, "bar");
120                    if self.cta {
121                            push_directive(tokens, "cta");
122                    }
123                    push_directive(tokens, "sync");
124                    self.a.unparse_tokens(tokens);
125            if self.b.is_some() { tokens.push(PtxToken::Comma); }
126                    if let Some(opt_3) = self.b.as_ref() {
127                        opt_3.unparse_tokens(tokens);
128                    }
129            tokens.push(PtxToken::Semicolon);
130        }
131    }
132
133    impl PtxUnparser for BarCtaArrive {
134        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
135            push_opcode(tokens, "bar");
136                    if self.cta {
137                            push_directive(tokens, "cta");
138                    }
139                    push_directive(tokens, "arrive");
140                    self.a.unparse_tokens(tokens);
141            tokens.push(PtxToken::Comma);
142                    self.b.unparse_tokens(tokens);
143            tokens.push(PtxToken::Semicolon);
144        }
145    }
146
147    impl PtxUnparser for BarCtaRedPopcU32 {
148        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
149            push_opcode(tokens, "bar");
150                    if self.cta {
151                            push_directive(tokens, "cta");
152                    }
153                    push_directive(tokens, "red");
154                    push_directive(tokens, "popc");
155                    push_directive(tokens, "u32");
156                    self.d.unparse_tokens(tokens);
157            tokens.push(PtxToken::Comma);
158                    self.a.unparse_tokens(tokens);
159            if self.b.is_some() { tokens.push(PtxToken::Comma); }
160                    if let Some(opt_4) = self.b.as_ref() {
161                        opt_4.unparse_tokens(tokens);
162                    }
163            tokens.push(PtxToken::Comma);
164            if self.c_op { tokens.push(PtxToken::Exclaim); }
165                    self.c.unparse_tokens(tokens);
166            tokens.push(PtxToken::Semicolon);
167        }
168    }
169
170    impl PtxUnparser for BarCtaRedOpPred {
171        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
172            push_opcode(tokens, "bar");
173                    if self.cta {
174                            push_directive(tokens, "cta");
175                    }
176                    push_directive(tokens, "red");
177                    match &self.op {
178                            Op::And => {
179                                    push_directive(tokens, "and");
180                            }
181                            Op::Or => {
182                                    push_directive(tokens, "or");
183                            }
184                    }
185                    push_directive(tokens, "pred");
186                    self.p.unparse_tokens(tokens);
187            tokens.push(PtxToken::Comma);
188                    self.a.unparse_tokens(tokens);
189            if self.b.is_some() { tokens.push(PtxToken::Comma); }
190                    if let Some(opt_5) = self.b.as_ref() {
191                        opt_5.unparse_tokens(tokens);
192                    }
193            tokens.push(PtxToken::Comma);
194            if self.c_op { tokens.push(PtxToken::Exclaim); }
195                    self.c.unparse_tokens(tokens);
196            tokens.push(PtxToken::Semicolon);
197        }
198    }
199
200}
201