ptx_parser/unparser/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)]
13
14use crate::lexer::PtxToken;
15use crate::unparser::{PtxUnparser, common::*};
16
17pub mod section_0 {
18    use super::*;
19    use crate::r#type::instruction::prefetch::section_0::*;
20
21    impl PtxUnparser for PrefetchSpaceLevel {
22        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
23            push_opcode(tokens, "prefetch");
24                    if let Some(space_0) = self.space.as_ref() {
25                            match space_0 {
26                                    Space::Global => {
27                                            push_directive(tokens, "global");
28                                    }
29                                    Space::Local => {
30                                            push_directive(tokens, "local");
31                                    }
32                            }
33                    }
34                    match &self.level {
35                            Level::L1 => {
36                                    push_directive(tokens, "L1");
37                            }
38                            Level::L2 => {
39                                    push_directive(tokens, "L2");
40                            }
41                    }
42                    self.a.unparse_tokens(tokens);
43            tokens.push(PtxToken::Semicolon);
44        }
45    }
46
47    impl PtxUnparser for PrefetchGlobalLevelEvictionPriority {
48        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
49            push_opcode(tokens, "prefetch");
50                    push_directive(tokens, "global");
51                    match &self.level_eviction_priority {
52                            LevelEvictionPriority::L2EvictNormal => {
53                                    push_directive(tokens, "L2::evict_normal");
54                            }
55                            LevelEvictionPriority::L2EvictLast => {
56                                    push_directive(tokens, "L2::evict_last");
57                            }
58                    }
59                    self.a.unparse_tokens(tokens);
60            tokens.push(PtxToken::Semicolon);
61        }
62    }
63
64    impl PtxUnparser for PrefetchuL1 {
65        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
66            push_opcode(tokens, "prefetchu");
67                    push_directive(tokens, "L1");
68                    self.a.unparse_tokens(tokens);
69            tokens.push(PtxToken::Semicolon);
70        }
71    }
72
73    impl PtxUnparser for PrefetchTensormapSpaceTensormap {
74        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
75            push_opcode(tokens, "prefetch");
76                    if let Some(tensormap_space_1) = self.tensormap_space.as_ref() {
77                            match tensormap_space_1 {
78                                    TensormapSpace::Const => {
79                                            push_directive(tokens, "const");
80                                    }
81                                    TensormapSpace::Param => {
82                                            push_directive(tokens, "param");
83                                    }
84                            }
85                    }
86                    push_directive(tokens, "tensormap");
87                    self.a.unparse_tokens(tokens);
88            tokens.push(PtxToken::Semicolon);
89        }
90    }
91
92}
93