Skip to main content

ptx_parser/type/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)]
14use crate::r#type::common::*;
15
16pub mod section_0 {
17    use crate::Spanned;
18    use crate::parser::Span;
19    use crate::r#type::common::*;
20
21    use serde::Serialize;
22
23    #[derive(Debug, Clone, PartialEq, Serialize)]
24    pub enum Op {
25        And, // .and
26        Or,  // .or
27    }
28
29    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
30    pub struct BarrierCtaSyncAligned {
31        pub cta: bool,                 // {.cta}
32        pub sync: (),                  // .sync
33        pub aligned: bool,             // {.aligned}
34        pub a: GeneralOperand,         // a
35        pub b: Option<GeneralOperand>, // {, b}
36        pub span: Span,
37    }
38
39    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
40    pub struct BarrierCtaArriveAligned {
41        pub cta: bool,         // {.cta}
42        pub arrive: (),        // .arrive
43        pub aligned: bool,     // {.aligned}
44        pub a: GeneralOperand, // a
45        pub b: GeneralOperand, // b
46        pub span: Span,
47    }
48
49    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
50    pub struct BarrierCtaRedPopcAlignedU32 {
51        pub cta: bool,                 // {.cta}
52        pub red: (),                   // .red
53        pub popc: (),                  // .popc
54        pub aligned: bool,             // {.aligned}
55        pub u32: (),                   // .u32
56        pub d: GeneralOperand,         // d
57        pub a: GeneralOperand,         // a
58        pub b: Option<GeneralOperand>, // {, b}
59        pub c_op: bool,                // {!} operator
60        pub c: GeneralOperand,         // {!}c
61        pub span: Span,
62    }
63
64    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
65    pub struct BarrierCtaRedOpAlignedPred {
66        pub cta: bool,                 // {.cta}
67        pub red: (),                   // .red
68        pub op: Op,                    // .op
69        pub aligned: bool,             // {.aligned}
70        pub pred: (),                  // .pred
71        pub p: GeneralOperand,         // p
72        pub a: GeneralOperand,         // a
73        pub b: Option<GeneralOperand>, // {, b}
74        pub c_op: bool,                // {!} operator
75        pub c: GeneralOperand,         // {!}c
76        pub span: Span,
77    }
78
79    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
80    pub struct BarCtaSync {
81        pub cta: bool,                 // {.cta}
82        pub sync: (),                  // .sync
83        pub a: GeneralOperand,         // a
84        pub b: Option<GeneralOperand>, // {, b}
85        pub span: Span,
86    }
87
88    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
89    pub struct BarCtaArrive {
90        pub cta: bool,         // {.cta}
91        pub arrive: (),        // .arrive
92        pub a: GeneralOperand, // a
93        pub b: GeneralOperand, // b
94        pub span: Span,
95    }
96
97    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
98    pub struct BarCtaRedPopcU32 {
99        pub cta: bool,                 // {.cta}
100        pub red: (),                   // .red
101        pub popc: (),                  // .popc
102        pub u32: (),                   // .u32
103        pub d: GeneralOperand,         // d
104        pub a: GeneralOperand,         // a
105        pub b: Option<GeneralOperand>, // {, b}
106        pub c_op: bool,                // {!} operator
107        pub c: GeneralOperand,         // {!}c
108        pub span: Span,
109    }
110
111    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
112    pub struct BarCtaRedOpPred {
113        pub cta: bool,                 // {.cta}
114        pub red: (),                   // .red
115        pub op: Op,                    // .op
116        pub pred: (),                  // .pred
117        pub p: GeneralOperand,         // p
118        pub a: GeneralOperand,         // a
119        pub b: Option<GeneralOperand>, // {, b}
120        pub c_op: bool,                // {!} operator
121        pub c: GeneralOperand,         // {!}c
122        pub span: Span,
123    }
124}
125
126// Re-export types with section suffixes to avoid naming conflicts
127// e.g., Type0 for section_0::Type, Type1 for section_1::Type
128pub use section_0::BarCtaArrive;
129pub use section_0::BarCtaRedOpPred;
130pub use section_0::BarCtaRedPopcU32;
131pub use section_0::BarCtaSync;
132pub use section_0::BarrierCtaArriveAligned;
133pub use section_0::BarrierCtaRedOpAlignedPred;
134pub use section_0::BarrierCtaRedPopcAlignedU32;
135pub use section_0::BarrierCtaSyncAligned;
136pub use section_0::Op as Op0;