ptx_parser/unparser/instruction/sured.rs
1//! Original PTX specification:
2//!
3//! sured.b.op.geom.ctype.mode [a,b],c; // byte addressing
4//! .op = { .add, .min, .max, .and, .or };
5//! .geom = { .1d, .2d, .3d };
6//! .ctype = { .u32, .u64, .s32, .b32, .s64 }; // for sured.b
7//! .mode = { .trap, .clamp, .zero };
8//! ----------------------------------------------------
9//! sured.p.op.geom.ctype.mode [a,b],c; // sample addressing
10//! .op = { .add, .min, .max, .and, .or };
11//! .geom = { .1d, .2d, .3d };
12//! .ctype = { .b32, .b64 }; // for sured.p
13//! .mode = { .trap, .clamp, .zero };
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::sured::section_0::*;
23
24 impl PtxUnparser for SuredBOpGeomCtypeMode {
25 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
26 push_opcode(tokens, "sured");
27 push_directive(tokens, "b");
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 Op::And => {
39 push_directive(tokens, "and");
40 }
41 Op::Or => {
42 push_directive(tokens, "or");
43 }
44 }
45 match &self.geom {
46 Geom::_1d => {
47 push_directive(tokens, "1d");
48 }
49 Geom::_2d => {
50 push_directive(tokens, "2d");
51 }
52 Geom::_3d => {
53 push_directive(tokens, "3d");
54 }
55 }
56 match &self.ctype {
57 Ctype::U32 => {
58 push_directive(tokens, "u32");
59 }
60 Ctype::U64 => {
61 push_directive(tokens, "u64");
62 }
63 Ctype::S32 => {
64 push_directive(tokens, "s32");
65 }
66 Ctype::B32 => {
67 push_directive(tokens, "b32");
68 }
69 Ctype::S64 => {
70 push_directive(tokens, "s64");
71 }
72 }
73 match &self.mode {
74 Mode::Clamp => {
75 push_directive(tokens, "clamp");
76 }
77 Mode::Trap => {
78 push_directive(tokens, "trap");
79 }
80 Mode::Zero => {
81 push_directive(tokens, "zero");
82 }
83 }
84 self.a.unparse_tokens(tokens);
85 tokens.push(PtxToken::Comma);
86 self.c.unparse_tokens(tokens);
87 tokens.push(PtxToken::Semicolon);
88 }
89 }
90
91}
92
93pub mod section_1 {
94 use super::*;
95 use crate::r#type::instruction::sured::section_1::*;
96
97 impl PtxUnparser for SuredPOpGeomCtypeMode {
98 fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
99 push_opcode(tokens, "sured");
100 push_directive(tokens, "p");
101 match &self.op {
102 Op::Add => {
103 push_directive(tokens, "add");
104 }
105 Op::Min => {
106 push_directive(tokens, "min");
107 }
108 Op::Max => {
109 push_directive(tokens, "max");
110 }
111 Op::And => {
112 push_directive(tokens, "and");
113 }
114 Op::Or => {
115 push_directive(tokens, "or");
116 }
117 }
118 match &self.geom {
119 Geom::_1d => {
120 push_directive(tokens, "1d");
121 }
122 Geom::_2d => {
123 push_directive(tokens, "2d");
124 }
125 Geom::_3d => {
126 push_directive(tokens, "3d");
127 }
128 }
129 match &self.ctype {
130 Ctype::B32 => {
131 push_directive(tokens, "b32");
132 }
133 Ctype::B64 => {
134 push_directive(tokens, "b64");
135 }
136 }
137 match &self.mode {
138 Mode::Clamp => {
139 push_directive(tokens, "clamp");
140 }
141 Mode::Trap => {
142 push_directive(tokens, "trap");
143 }
144 Mode::Zero => {
145 push_directive(tokens, "zero");
146 }
147 }
148 self.a.unparse_tokens(tokens);
149 tokens.push(PtxToken::Comma);
150 self.c.unparse_tokens(tokens);
151 tokens.push(PtxToken::Semicolon);
152 }
153 }
154
155}
156