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