ptx_parser/parser/instruction/
createpolicy.rs1#![allow(unused)]
16
17use crate::parser::{
18 PtxParseError, PtxParser, PtxTokenStream, Span,
19 util::{
20 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
21 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
22 },
23};
24use crate::r#type::common::*;
25use crate::{alt, ok, seq_n};
26
27pub mod section_0 {
28 use super::*;
29 use crate::r#type::instruction::createpolicy::section_0::*;
30
31 impl PtxParser for LevelPrimaryPriority {
36 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
37 alt!(
38 map(string_p(".L2::evict_unchanged"), |_, _span| {
39 LevelPrimaryPriority::L2EvictUnchanged
40 }),
41 map(string_p(".L2::evict_normal"), |_, _span| {
42 LevelPrimaryPriority::L2EvictNormal
43 }),
44 map(string_p(".L2::evict_first"), |_, _span| {
45 LevelPrimaryPriority::L2EvictFirst
46 }),
47 map(string_p(".L2::evict_last"), |_, _span| {
48 LevelPrimaryPriority::L2EvictLast
49 })
50 )
51 }
52 }
53
54 impl PtxParser for LevelSecondaryPriority {
55 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
56 alt!(
57 map(string_p(".L2::evict_unchanged"), |_, _span| {
58 LevelSecondaryPriority::L2EvictUnchanged
59 }),
60 map(string_p(".L2::evict_first"), |_, _span| {
61 LevelSecondaryPriority::L2EvictFirst
62 })
63 )
64 }
65 }
66
67 impl PtxParser for CreatepolicyRangeGlobalLevelPrimaryPriorityLevelSecondaryPriorityB64 {
68 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
69 try_map(
70 seq_n!(
71 string_p("createpolicy"),
72 string_p(".range"),
73 map(optional(string_p(".global")), |value, _| value.is_some()),
74 LevelPrimaryPriority::parse(),
75 optional(LevelSecondaryPriority::parse()),
76 string_p(".b64"),
77 GeneralOperand::parse(),
78 comma_p(),
79 AddressOperand::parse(),
80 comma_p(),
81 GeneralOperand::parse(),
82 comma_p(),
83 GeneralOperand::parse(),
84 semicolon_p()
85 ),
86 |(
87 _,
88 range,
89 global,
90 level_primary_priority,
91 level_secondary_priority,
92 b64,
93 cache_policy,
94 _,
95 a,
96 _,
97 primary_size,
98 _,
99 total_size,
100 _,
101 ),
102 span| {
103 ok!(CreatepolicyRangeGlobalLevelPrimaryPriorityLevelSecondaryPriorityB64 {
104 range = range,
105 global = global,
106 level_primary_priority = level_primary_priority,
107 level_secondary_priority = level_secondary_priority,
108 b64 = b64,
109 cache_policy = cache_policy,
110 a = a,
111 primary_size = primary_size,
112 total_size = total_size,
113
114 })
115 },
116 )
117 }
118 }
119
120 impl PtxParser for CreatepolicyFractionalLevelPrimaryPriorityLevelSecondaryPriorityB64 {
121 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
122 try_map(
123 seq_n!(
124 string_p("createpolicy"),
125 string_p(".fractional"),
126 LevelPrimaryPriority::parse(),
127 optional(LevelSecondaryPriority::parse()),
128 string_p(".b64"),
129 GeneralOperand::parse(),
130 map(
131 optional(seq_n!(comma_p(), GeneralOperand::parse())),
132 |value, _| value.map(|(_, operand)| operand)
133 ),
134 semicolon_p()
135 ),
136 |(
137 _,
138 fractional,
139 level_primary_priority,
140 level_secondary_priority,
141 b64,
142 cache_policy,
143 fraction,
144 _,
145 ),
146 span| {
147 ok!(CreatepolicyFractionalLevelPrimaryPriorityLevelSecondaryPriorityB64 {
148 fractional = fractional,
149 level_primary_priority = level_primary_priority,
150 level_secondary_priority = level_secondary_priority,
151 b64 = b64,
152 cache_policy = cache_policy,
153 fraction = fraction,
154
155 })
156 },
157 )
158 }
159 }
160
161 impl PtxParser for CreatepolicyCvtL2B64 {
162 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
163 try_map(
164 seq_n!(
165 string_p("createpolicy"),
166 string_p(".cvt"),
167 string_p(".L2"),
168 string_p(".b64"),
169 GeneralOperand::parse(),
170 comma_p(),
171 GeneralOperand::parse(),
172 semicolon_p()
173 ),
174 |(_, cvt, l2, b64, cache_policy, _, access_property, _), span| {
175 ok!(CreatepolicyCvtL2B64 {
176 cvt = cvt,
177 l2 = l2,
178 b64 = b64,
179 cache_policy = cache_policy,
180 access_property = access_property,
181
182 })
183 },
184 )
185 }
186 }
187}