Skip to main content

ptx_parser/type/instruction/
st.rs

1//! Original PTX specification:
2//!
3//! st{.weak}{.ss}{.cop}{.level::cache_hint}{.vec}.type   [a], b{, cache-policy};
4//! st{.weak}{.ss}{.level1::eviction_priority}{.level2::eviction_priority}{.level::cache_hint}{.vec}.type [a], b{, cache-policy};
5//! st.volatile{.ss}{.vec}.type                           [a], b;
6//! st.relaxed.scope{.ss}{.level1::eviction_priority}{.level2::eviction_priority}{.level::cache_hint}{.vec}.type [a], b{, cache-policy};
7//! st.release.scope{.ss}{.level1::eviction_priority}{.level2::eviction_priority}{.level::cache_hint}{.vec}.type [a], b{, cache-policy};
8//! st.mmio.relaxed.sys{.global}.type         [a], b;
9//! .ss =                       { .global, .local, .param, .param::func, .shared, .shared::cta, .shared::cluster};
10//! .level1::eviction_priority = { .L1::evict_normal, .L1::evict_unchanged,
11//! .L1::evict_first, .L1::evict_last, .L1::no_allocate };
12//! .level2::eviction_priority = { .L2::evict_normal, .L2::evict_first, .L2::evict_last };
13//! .level::cache_hint =        { .L2::cache_hint };
14//! .cop =                      { .wb, .cg, .cs, .wt };
15//! .sem =                      { .relaxed, .release };
16//! .scope =                    { .cta, .cluster, .gpu, .sys };
17//! .vec =                      { .v2, .v4, .v8 };
18//! .type =                     { .b8, .b16, .b32, .b64, .b128,
19//! .u8, .u16, .u32, .u64,
20//! .s8, .s16, .s32, .s64,
21//! .f32, .f64 };
22
23#![allow(unused)]
24use crate::r#type::common::*;
25
26pub mod section_0 {
27    use crate::Spanned;
28    use crate::parser::Span;
29    use crate::r#type::common::*;
30
31    use serde::Serialize;
32
33    #[derive(Debug, Clone, PartialEq, Serialize)]
34    pub enum Ss {
35        SharedCluster, // .shared::cluster
36        ParamFunc,     // .param::func
37        SharedCta,     // .shared::cta
38        Global,        // .global
39        Shared,        // .shared
40        Local,         // .local
41        Param,         // .param
42    }
43
44    #[derive(Debug, Clone, PartialEq, Serialize)]
45    pub enum Cop {
46        Wb, // .wb
47        Cg, // .cg
48        Cs, // .cs
49        Wt, // .wt
50    }
51
52    #[derive(Debug, Clone, PartialEq, Serialize)]
53    pub enum LevelCacheHint {
54        L2CacheHint, // .L2::cache_hint
55    }
56
57    #[derive(Debug, Clone, PartialEq, Serialize)]
58    pub enum Vec {
59        V2, // .v2
60        V4, // .v4
61        V8, // .v8
62    }
63
64    #[derive(Debug, Clone, PartialEq, Serialize)]
65    pub enum Type {
66        B128, // .b128
67        B16,  // .b16
68        B32,  // .b32
69        B64,  // .b64
70        U16,  // .u16
71        U32,  // .u32
72        U64,  // .u64
73        S16,  // .s16
74        S32,  // .s32
75        S64,  // .s64
76        F32,  // .f32
77        F64,  // .f64
78        B8,   // .b8
79        U8,   // .u8
80        S8,   // .s8
81    }
82
83    #[derive(Debug, Clone, PartialEq, Serialize)]
84    pub enum Level1EvictionPriority {
85        L1EvictUnchanged, // .L1::evict_unchanged
86        L1EvictNormal,    // .L1::evict_normal
87        L1EvictFirst,     // .L1::evict_first
88        L1NoAllocate,     // .L1::no_allocate
89        L1EvictLast,      // .L1::evict_last
90    }
91
92    #[derive(Debug, Clone, PartialEq, Serialize)]
93    pub enum Level2EvictionPriority {
94        L2EvictNormal, // .L2::evict_normal
95        L2EvictFirst,  // .L2::evict_first
96        L2EvictLast,   // .L2::evict_last
97    }
98
99    #[derive(Debug, Clone, PartialEq, Serialize)]
100    pub enum Scope {
101        Cluster, // .cluster
102        Cta,     // .cta
103        Gpu,     // .gpu
104        Sys,     // .sys
105    }
106
107    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
108    pub struct StWeakSsCopLevelCacheHintVecType {
109        pub weak: bool,                               // {.weak}
110        pub ss: Option<Ss>,                           // {.ss}
111        pub cop: Option<Cop>,                         // {.cop}
112        pub level_cache_hint: Option<LevelCacheHint>, // {.level::cache_hint}
113        pub vec: Option<Vec>,                         // {.vec}
114        pub type_: Type,                              // .type
115        pub a: AddressOperand,                        // [a]
116        pub b: GeneralOperand,                        // b
117        pub cache_policy: Option<GeneralOperand>,     // {, cache-policy}
118        pub span: Span,
119    }
120
121    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
122    pub struct StWeakSsLevel1EvictionPriorityLevel2EvictionPriorityLevelCacheHintVecType {
123        pub weak: bool,                                               // {.weak}
124        pub ss: Option<Ss>,                                           // {.ss}
125        pub level1_eviction_priority: Option<Level1EvictionPriority>, // {.level1::eviction_priority}
126        pub level2_eviction_priority: Option<Level2EvictionPriority>, // {.level2::eviction_priority}
127        pub level_cache_hint: Option<LevelCacheHint>,                 // {.level::cache_hint}
128        pub vec: Option<Vec>,                                         // {.vec}
129        pub type_: Type,                                              // .type
130        pub a: AddressOperand,                                        // [a]
131        pub b: GeneralOperand,                                        // b
132        pub cache_policy: Option<GeneralOperand>,                     // {, cache-policy}
133        pub span: Span,
134    }
135
136    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
137    pub struct StVolatileSsVecType {
138        pub volatile: (),      // .volatile
139        pub ss: Option<Ss>,    // {.ss}
140        pub vec: Option<Vec>,  // {.vec}
141        pub type_: Type,       // .type
142        pub a: AddressOperand, // [a]
143        pub b: GeneralOperand, // b
144        pub span: Span,
145    }
146
147    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
148    pub struct StRelaxedScopeSsLevel1EvictionPriorityLevel2EvictionPriorityLevelCacheHintVecType {
149        pub relaxed: (),                                              // .relaxed
150        pub scope: Scope,                                             // .scope
151        pub ss: Option<Ss>,                                           // {.ss}
152        pub level1_eviction_priority: Option<Level1EvictionPriority>, // {.level1::eviction_priority}
153        pub level2_eviction_priority: Option<Level2EvictionPriority>, // {.level2::eviction_priority}
154        pub level_cache_hint: Option<LevelCacheHint>,                 // {.level::cache_hint}
155        pub vec: Option<Vec>,                                         // {.vec}
156        pub type_: Type,                                              // .type
157        pub a: AddressOperand,                                        // [a]
158        pub b: GeneralOperand,                                        // b
159        pub cache_policy: Option<GeneralOperand>,                     // {, cache-policy}
160        pub span: Span,
161    }
162
163    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
164    pub struct StReleaseScopeSsLevel1EvictionPriorityLevel2EvictionPriorityLevelCacheHintVecType {
165        pub release: (),                                              // .release
166        pub scope: Scope,                                             // .scope
167        pub ss: Option<Ss>,                                           // {.ss}
168        pub level1_eviction_priority: Option<Level1EvictionPriority>, // {.level1::eviction_priority}
169        pub level2_eviction_priority: Option<Level2EvictionPriority>, // {.level2::eviction_priority}
170        pub level_cache_hint: Option<LevelCacheHint>,                 // {.level::cache_hint}
171        pub vec: Option<Vec>,                                         // {.vec}
172        pub type_: Type,                                              // .type
173        pub a: AddressOperand,                                        // [a]
174        pub b: GeneralOperand,                                        // b
175        pub cache_policy: Option<GeneralOperand>,                     // {, cache-policy}
176        pub span: Span,
177    }
178
179    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
180    pub struct StMmioRelaxedSysGlobalType {
181        pub mmio: (),          // .mmio
182        pub relaxed: (),       // .relaxed
183        pub sys: (),           // .sys
184        pub global: bool,      // {.global}
185        pub type_: Type,       // .type
186        pub a: AddressOperand, // [a]
187        pub b: GeneralOperand, // b
188        pub span: Span,
189    }
190}
191
192// Re-export types with section suffixes to avoid naming conflicts
193// e.g., Type0 for section_0::Type, Type1 for section_1::Type
194pub use section_0::Cop as Cop0;
195pub use section_0::Level1EvictionPriority as Level1EvictionPriority0;
196pub use section_0::Level2EvictionPriority as Level2EvictionPriority0;
197pub use section_0::LevelCacheHint as LevelCacheHint0;
198pub use section_0::Scope as Scope0;
199pub use section_0::Ss as Ss0;
200pub use section_0::StMmioRelaxedSysGlobalType;
201pub use section_0::StRelaxedScopeSsLevel1EvictionPriorityLevel2EvictionPriorityLevelCacheHintVecType;
202pub use section_0::StReleaseScopeSsLevel1EvictionPriorityLevel2EvictionPriorityLevelCacheHintVecType;
203pub use section_0::StVolatileSsVecType;
204pub use section_0::StWeakSsCopLevelCacheHintVecType;
205pub use section_0::StWeakSsLevel1EvictionPriorityLevel2EvictionPriorityLevelCacheHintVecType;
206pub use section_0::Type as Type0;
207pub use section_0::Vec as Vec0;