Skip to main content

ptx_parser/unparser/instruction/
barrier_cluster.rs

1//! Original PTX specification:
2//!
3//! barrier.cluster.arrive{.sem}{.aligned};
4//! barrier.cluster.wait{.acquire}{.aligned};
5//! .sem = {.release, .relaxed};
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::barrier_cluster::section_0::*;
15
16    impl PtxUnparser for BarrierClusterArriveSemAligned {
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, "barrier");
22            push_directive(tokens, "cluster");
23            push_directive(tokens, "arrive");
24            if let Some(sem_0) = self.sem.as_ref() {
25                match sem_0 {
26                    Sem::Release => {
27                        push_directive(tokens, "release");
28                    }
29                    Sem::Relaxed => {
30                        push_directive(tokens, "relaxed");
31                    }
32                }
33            }
34            if self.aligned {
35                push_directive(tokens, "aligned");
36            }
37            tokens.push(PtxToken::Semicolon);
38            if spaced {
39                tokens.push(PtxToken::Newline);
40            }
41        }
42    }
43
44    impl PtxUnparser for BarrierClusterWaitAcquireAligned {
45        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
46            self.unparse_tokens_mode(tokens, false);
47        }
48        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
49            push_opcode(tokens, "barrier");
50            push_directive(tokens, "cluster");
51            push_directive(tokens, "wait");
52            if self.acquire {
53                push_directive(tokens, "acquire");
54            }
55            if self.aligned {
56                push_directive(tokens, "aligned");
57            }
58            tokens.push(PtxToken::Semicolon);
59            if spaced {
60                tokens.push(PtxToken::Newline);
61            }
62        }
63    }
64}