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
57pub mod section_1 {
58    use super::*;
59    use crate::r#type::instruction::redux_sync::section_1::*;
60
61    impl PtxUnparser for ReduxSyncOpB32 {
62        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
63            push_opcode(tokens, "redux");
64            push_directive(tokens, "sync");
65            match &self.op {
66                Op::And => {
67                    push_directive(tokens, "and");
68                }
69                Op::Xor => {
70                    push_directive(tokens, "xor");
71                }
72                Op::Or => {
73                    push_directive(tokens, "or");
74                }
75            }
76            push_directive(tokens, "b32");
77            self.dst.unparse_tokens(tokens);
78            tokens.push(PtxToken::Comma);
79            self.src.unparse_tokens(tokens);
80            tokens.push(PtxToken::Comma);
81            self.membermask.unparse_tokens(tokens);
82            tokens.push(PtxToken::Semicolon);
83        }
84    }
85}
86
87pub mod section_2 {
88    use super::*;
89    use crate::r#type::instruction::redux_sync::section_2::*;
90
91    impl PtxUnparser for ReduxSyncOpAbsNanF32 {
92        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
93            push_opcode(tokens, "redux");
94            push_directive(tokens, "sync");
95            match &self.op {
96                Op::Min => {
97                    push_directive(tokens, "min");
98                }
99                Op::Max => {
100                    push_directive(tokens, "max");
101                }
102            }
103            if self.abs {
104                push_directive(tokens, "abs");
105            }
106            if self.nan {
107                push_directive(tokens, "NaN");
108            }
109            push_directive(tokens, "f32");
110            self.dst.unparse_tokens(tokens);
111            tokens.push(PtxToken::Comma);
112            self.src.unparse_tokens(tokens);
113            tokens.push(PtxToken::Comma);
114            self.membermask.unparse_tokens(tokens);
115            tokens.push(PtxToken::Semicolon);
116        }
117    }
118}