Skip to main content

ptx_parser/type/instruction/
prefetch.rs

1//! Original PTX specification:
2//!
3//! prefetch{.space}.level                    [a];   // prefetch to data cache
4//! prefetch.global.level::eviction_priority  [a];   // prefetch to data cache
5//! prefetchu.L1  [a];             // prefetch to uniform cache
6//! prefetch{.tensormap_space}.tensormap [a];  // prefetch the tensormap
7//! .space =                    { .global, .local };
8//! .level =                    { .L1, .L2 };
9//! .level::eviction_priority = { .L2::evict_last, .L2::evict_normal };
10//! .tensormap_space =          { .const, .param };
11
12#![allow(unused)]
13use crate::r#type::common::*;
14
15pub mod section_0 {
16    use crate::Spanned;
17    use crate::parser::Span;
18    use crate::r#type::common::*;
19
20    use serde::Serialize;
21
22    #[derive(Debug, Clone, PartialEq, Serialize)]
23    pub enum Space {
24        Global, // .global
25        Local,  // .local
26    }
27
28    #[derive(Debug, Clone, PartialEq, Serialize)]
29    pub enum Level {
30        L1, // .L1
31        L2, // .L2
32    }
33
34    #[derive(Debug, Clone, PartialEq, Serialize)]
35    pub enum LevelEvictionPriority {
36        L2EvictNormal, // .L2::evict_normal
37        L2EvictLast,   // .L2::evict_last
38    }
39
40    #[derive(Debug, Clone, PartialEq, Serialize)]
41    pub enum TensormapSpace {
42        Const, // .const
43        Param, // .param
44    }
45
46    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
47    pub struct PrefetchSpaceLevel {
48        pub space: Option<Space>, // {.space}
49        pub level: Level,         // .level
50        pub a: AddressOperand,    // [a]
51        pub span: Span,
52    }
53
54    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
55    pub struct PrefetchGlobalLevelEvictionPriority {
56        pub global: (),                                     // .global
57        pub level_eviction_priority: LevelEvictionPriority, // .level::eviction_priority
58        pub a: AddressOperand,                              // [a]
59        pub span: Span,
60    }
61
62    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
63    pub struct PrefetchuL1 {
64        pub l1: (),            // .L1
65        pub a: AddressOperand, // [a]
66        pub span: Span,
67    }
68
69    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
70    pub struct PrefetchTensormapSpaceTensormap {
71        pub tensormap_space: Option<TensormapSpace>, // {.tensormap_space}
72        pub tensormap: (),                           // .tensormap
73        pub a: AddressOperand,                       // [a]
74        pub span: Span,
75    }
76}
77
78// Re-export types with section suffixes to avoid naming conflicts
79// e.g., Type0 for section_0::Type, Type1 for section_1::Type
80pub use section_0::Level as Level0;
81pub use section_0::LevelEvictionPriority as LevelEvictionPriority0;
82pub use section_0::PrefetchGlobalLevelEvictionPriority;
83pub use section_0::PrefetchSpaceLevel;
84pub use section_0::PrefetchTensormapSpaceTensormap;
85pub use section_0::PrefetchuL1;
86pub use section_0::Space as Space0;
87pub use section_0::TensormapSpace as TensormapSpace0;