ptx_parser/unparser/instruction/
slct.rs

1//! Original PTX specification:
2//!
3//! slct.dtype.s32        d, a, b, c;
4//! slct{.ftz}.dtype.f32  d, a, b, c;
5//! .dtype = { .b16, .b32, .b64,
6//! .u16, .u32, .u64,
7//! .s16, .s32, .s64,
8//! .f32, .f64 };
9
10#![allow(unused)]
11
12use crate::lexer::PtxToken;
13use crate::unparser::{PtxUnparser, common::*};
14
15pub mod section_0 {
16    use super::*;
17    use crate::r#type::instruction::slct::section_0::*;
18
19    impl PtxUnparser for SlctDtypeS32 {
20        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
21            push_opcode(tokens, "slct");
22            match &self.dtype {
23                Dtype::B16 => {
24                    push_directive(tokens, "b16");
25                }
26                Dtype::B32 => {
27                    push_directive(tokens, "b32");
28                }
29                Dtype::B64 => {
30                    push_directive(tokens, "b64");
31                }
32                Dtype::U16 => {
33                    push_directive(tokens, "u16");
34                }
35                Dtype::U32 => {
36                    push_directive(tokens, "u32");
37                }
38                Dtype::U64 => {
39                    push_directive(tokens, "u64");
40                }
41                Dtype::S16 => {
42                    push_directive(tokens, "s16");
43                }
44                Dtype::S32 => {
45                    push_directive(tokens, "s32");
46                }
47                Dtype::S64 => {
48                    push_directive(tokens, "s64");
49                }
50                Dtype::F32 => {
51                    push_directive(tokens, "f32");
52                }
53                Dtype::F64 => {
54                    push_directive(tokens, "f64");
55                }
56            }
57            push_directive(tokens, "s32");
58            self.d.unparse_tokens(tokens);
59            tokens.push(PtxToken::Comma);
60            self.a.unparse_tokens(tokens);
61            tokens.push(PtxToken::Comma);
62            self.b.unparse_tokens(tokens);
63            tokens.push(PtxToken::Comma);
64            self.c.unparse_tokens(tokens);
65            tokens.push(PtxToken::Semicolon);
66        }
67    }
68
69    impl PtxUnparser for SlctFtzDtypeF32 {
70        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
71            push_opcode(tokens, "slct");
72            if self.ftz {
73                push_directive(tokens, "ftz");
74            }
75            match &self.dtype {
76                Dtype::B16 => {
77                    push_directive(tokens, "b16");
78                }
79                Dtype::B32 => {
80                    push_directive(tokens, "b32");
81                }
82                Dtype::B64 => {
83                    push_directive(tokens, "b64");
84                }
85                Dtype::U16 => {
86                    push_directive(tokens, "u16");
87                }
88                Dtype::U32 => {
89                    push_directive(tokens, "u32");
90                }
91                Dtype::U64 => {
92                    push_directive(tokens, "u64");
93                }
94                Dtype::S16 => {
95                    push_directive(tokens, "s16");
96                }
97                Dtype::S32 => {
98                    push_directive(tokens, "s32");
99                }
100                Dtype::S64 => {
101                    push_directive(tokens, "s64");
102                }
103                Dtype::F32 => {
104                    push_directive(tokens, "f32");
105                }
106                Dtype::F64 => {
107                    push_directive(tokens, "f64");
108                }
109            }
110            push_directive(tokens, "f32");
111            self.d.unparse_tokens(tokens);
112            tokens.push(PtxToken::Comma);
113            self.a.unparse_tokens(tokens);
114            tokens.push(PtxToken::Comma);
115            self.b.unparse_tokens(tokens);
116            tokens.push(PtxToken::Comma);
117            self.c.unparse_tokens(tokens);
118            tokens.push(PtxToken::Semicolon);
119        }
120    }
121}