ptx_parser/parser/instruction/
barrier_cluster.rs1#![allow(unused)]
8
9use crate::parser::{
10 PtxParseError, PtxParser, PtxTokenStream, Span,
11 util::{
12 between, comma_p, directive_p, exclamation_p, lbracket_p, lparen_p, map, minus_p, optional,
13 pipe_p, rbracket_p, rparen_p, semicolon_p, sep_by, string_p, try_map,
14 },
15};
16use crate::r#type::common::*;
17use crate::{alt, ok, seq_n};
18
19pub mod section_0 {
20 use super::*;
21 use crate::r#type::instruction::barrier_cluster::section_0::*;
22
23 impl PtxParser for Sem {
28 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
29 alt!(
30 map(string_p(".release"), |_, _span| Sem::Release),
31 map(string_p(".relaxed"), |_, _span| Sem::Relaxed)
32 )
33 }
34 }
35
36 impl PtxParser for BarrierClusterArriveSemAligned {
37 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
38 try_map(
39 seq_n!(
40 string_p("barrier"),
41 string_p(".cluster"),
42 string_p(".arrive"),
43 optional(Sem::parse()),
44 map(optional(string_p(".aligned")), |value, _| value.is_some()),
45 semicolon_p()
46 ),
47 |(_, cluster, arrive, sem, aligned, _), span| {
48 ok!(BarrierClusterArriveSemAligned {
49 cluster = cluster,
50 arrive = arrive,
51 sem = sem,
52 aligned = aligned,
53
54 })
55 },
56 )
57 }
58 }
59
60 impl PtxParser for BarrierClusterWaitAcquireAligned {
61 fn parse() -> impl Fn(&mut PtxTokenStream) -> Result<(Self, Span), PtxParseError> {
62 try_map(
63 seq_n!(
64 string_p("barrier"),
65 string_p(".cluster"),
66 string_p(".wait"),
67 map(optional(string_p(".acquire")), |value, _| value.is_some()),
68 map(optional(string_p(".aligned")), |value, _| value.is_some()),
69 semicolon_p()
70 ),
71 |(_, cluster, wait, acquire, aligned, _), span| {
72 ok!(BarrierClusterWaitAcquireAligned {
73 cluster = cluster,
74 wait = wait,
75 acquire = acquire,
76 aligned = aligned,
77
78 })
79 },
80 )
81 }
82 }
83}