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            push_opcode(tokens, "redux");
27                    push_directive(tokens, "sync");
28                    match &self.op {
29                            Op::Add => {
30                                    push_directive(tokens, "add");
31                            }
32                            Op::Min => {
33                                    push_directive(tokens, "min");
34                            }
35                            Op::Max => {
36                                    push_directive(tokens, "max");
37                            }
38                    }
39                    match &self.type_ {
40                            Type::U32 => {
41                                    push_directive(tokens, "u32");
42                            }
43                            Type::S32 => {
44                                    push_directive(tokens, "s32");
45                            }
46                    }
47                    self.dst.unparse_tokens(tokens);
48            tokens.push(PtxToken::Comma);
49                    self.src.unparse_tokens(tokens);
50            tokens.push(PtxToken::Comma);
51                    self.membermask.unparse_tokens(tokens);
52            tokens.push(PtxToken::Semicolon);
53        }
54    }
55
56}
57
58pub mod section_1 {
59    use super::*;
60    use crate::r#type::instruction::redux_sync::section_1::*;
61
62    impl PtxUnparser for ReduxSyncOpB32 {
63        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
64            push_opcode(tokens, "redux");
65                    push_directive(tokens, "sync");
66                    match &self.op {
67                            Op::And => {
68                                    push_directive(tokens, "and");
69                            }
70                            Op::Xor => {
71                                    push_directive(tokens, "xor");
72                            }
73                            Op::Or => {
74                                    push_directive(tokens, "or");
75                            }
76                    }
77                    push_directive(tokens, "b32");
78                    self.dst.unparse_tokens(tokens);
79            tokens.push(PtxToken::Comma);
80                    self.src.unparse_tokens(tokens);
81            tokens.push(PtxToken::Comma);
82                    self.membermask.unparse_tokens(tokens);
83            tokens.push(PtxToken::Semicolon);
84        }
85    }
86
87}
88
89pub mod section_2 {
90    use super::*;
91    use crate::r#type::instruction::redux_sync::section_2::*;
92
93    impl PtxUnparser for ReduxSyncOpAbsNanF32 {
94        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
95            push_opcode(tokens, "redux");
96                    push_directive(tokens, "sync");
97                    match &self.op {
98                            Op::Min => {
99                                    push_directive(tokens, "min");
100                            }
101                            Op::Max => {
102                                    push_directive(tokens, "max");
103                            }
104                    }
105                    if self.abs {
106                            push_directive(tokens, "abs");
107                    }
108                    if self.nan {
109                            push_directive(tokens, "NaN");
110                    }
111                    push_directive(tokens, "f32");
112                    self.dst.unparse_tokens(tokens);
113            tokens.push(PtxToken::Comma);
114                    self.src.unparse_tokens(tokens);
115            tokens.push(PtxToken::Comma);
116                    self.membermask.unparse_tokens(tokens);
117            tokens.push(PtxToken::Semicolon);
118        }
119    }
120
121}
122