Skip to main content

ptx_parser/unparser/instruction/
redux_sync.rs

1//! Original PTX specification:
2//!
3//! redux.sync.op.type dst, src, membermask;
4//! .op   = {.add, .min, .max};
5//! .type = {.u32, .s32};
6//! ----------------------------------------------------
7//! // Alternate floating point type:
8//! redux.sync.op.b32 dst, src, membermask;
9//! .op   = {.and, .or, .xor};
10//! ----------------------------------------------------
11//! // Alternate floating point type:
12//! redux.sync.op{.abs}{.NaN}.f32 dst, src, membermask;
13//! .op   = { .min, .max };
14
15#![allow(unused)]
16
17use crate::lexer::PtxToken;
18use crate::unparser::{PtxUnparser, common::*};
19
20pub mod section_0 {
21    use super::*;
22    use crate::r#type::instruction::redux_sync::section_0::*;
23
24    impl PtxUnparser for ReduxSyncOpType {
25        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
26            self.unparse_tokens_mode(tokens, false);
27        }
28        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
29            push_opcode(tokens, "redux");
30            push_directive(tokens, "sync");
31            match &self.op {
32                Op::Add => {
33                    push_directive(tokens, "add");
34                }
35                Op::Min => {
36                    push_directive(tokens, "min");
37                }
38                Op::Max => {
39                    push_directive(tokens, "max");
40                }
41            }
42            match &self.type_ {
43                Type::U32 => {
44                    push_directive(tokens, "u32");
45                }
46                Type::S32 => {
47                    push_directive(tokens, "s32");
48                }
49            }
50            if spaced {
51                tokens.push(PtxToken::Space);
52            }
53            self.dst.unparse_tokens_mode(tokens, spaced);
54            tokens.push(PtxToken::Comma);
55            if spaced {
56                tokens.push(PtxToken::Space);
57            }
58            self.src.unparse_tokens_mode(tokens, spaced);
59            tokens.push(PtxToken::Comma);
60            if spaced {
61                tokens.push(PtxToken::Space);
62            }
63            self.membermask.unparse_tokens_mode(tokens, spaced);
64            tokens.push(PtxToken::Semicolon);
65            if spaced {
66                tokens.push(PtxToken::Newline);
67            }
68        }
69    }
70}
71
72pub mod section_1 {
73    use super::*;
74    use crate::r#type::instruction::redux_sync::section_1::*;
75
76    impl PtxUnparser for ReduxSyncOpB32 {
77        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
78            self.unparse_tokens_mode(tokens, false);
79        }
80        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
81            push_opcode(tokens, "redux");
82            push_directive(tokens, "sync");
83            match &self.op {
84                Op::And => {
85                    push_directive(tokens, "and");
86                }
87                Op::Xor => {
88                    push_directive(tokens, "xor");
89                }
90                Op::Or => {
91                    push_directive(tokens, "or");
92                }
93            }
94            push_directive(tokens, "b32");
95            if spaced {
96                tokens.push(PtxToken::Space);
97            }
98            self.dst.unparse_tokens_mode(tokens, spaced);
99            tokens.push(PtxToken::Comma);
100            if spaced {
101                tokens.push(PtxToken::Space);
102            }
103            self.src.unparse_tokens_mode(tokens, spaced);
104            tokens.push(PtxToken::Comma);
105            if spaced {
106                tokens.push(PtxToken::Space);
107            }
108            self.membermask.unparse_tokens_mode(tokens, spaced);
109            tokens.push(PtxToken::Semicolon);
110            if spaced {
111                tokens.push(PtxToken::Newline);
112            }
113        }
114    }
115}
116
117pub mod section_2 {
118    use super::*;
119    use crate::r#type::instruction::redux_sync::section_2::*;
120
121    impl PtxUnparser for ReduxSyncOpAbsNanF32 {
122        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
123            self.unparse_tokens_mode(tokens, false);
124        }
125        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
126            push_opcode(tokens, "redux");
127            push_directive(tokens, "sync");
128            match &self.op {
129                Op::Min => {
130                    push_directive(tokens, "min");
131                }
132                Op::Max => {
133                    push_directive(tokens, "max");
134                }
135            }
136            if self.abs {
137                push_directive(tokens, "abs");
138            }
139            if self.nan {
140                push_directive(tokens, "NaN");
141            }
142            push_directive(tokens, "f32");
143            if spaced {
144                tokens.push(PtxToken::Space);
145            }
146            self.dst.unparse_tokens_mode(tokens, spaced);
147            tokens.push(PtxToken::Comma);
148            if spaced {
149                tokens.push(PtxToken::Space);
150            }
151            self.src.unparse_tokens_mode(tokens, spaced);
152            tokens.push(PtxToken::Comma);
153            if spaced {
154                tokens.push(PtxToken::Space);
155            }
156            self.membermask.unparse_tokens_mode(tokens, spaced);
157            tokens.push(PtxToken::Semicolon);
158            if spaced {
159                tokens.push(PtxToken::Newline);
160            }
161        }
162    }
163}