ptx_parser/unparser/instruction/
suld.rs

1//! Original PTX specification:
2//!
3//! suld.b.geom{.cop}.vec.dtype{.mode}  d, [a, b];  // unformatted
4//!
5//! .geom  = { .1d, .2d, .3d, .a1d, .a2d };
6//! .cop   = { .ca, .cg, .cs, .cv };               // cache operation
7//! .vec   = { none, .v2, .v4 };
8//! .dtype = { .b8 , .b16, .b32, .b64 };
9//! .mode = { .trap, .clamp, .zero };
10
11#![allow(unused)]
12
13use crate::lexer::PtxToken;
14use crate::unparser::{PtxUnparser, common::*};
15
16pub mod section_0 {
17    use super::*;
18    use crate::r#type::instruction::suld::section_0::*;
19
20    impl PtxUnparser for SuldBGeomCopVecDtypeMode {
21        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
22            push_opcode(tokens, "suld");
23            push_directive(tokens, "b");
24            match &self.geom {
25                Geom::A1d => {
26                    push_directive(tokens, "a1d");
27                }
28                Geom::A2d => {
29                    push_directive(tokens, "a2d");
30                }
31                Geom::_1d => {
32                    push_directive(tokens, "1d");
33                }
34                Geom::_2d => {
35                    push_directive(tokens, "2d");
36                }
37                Geom::_3d => {
38                    push_directive(tokens, "3d");
39                }
40            }
41            if let Some(cop_0) = self.cop.as_ref() {
42                match cop_0 {
43                    Cop::Ca => {
44                        push_directive(tokens, "ca");
45                    }
46                    Cop::Cg => {
47                        push_directive(tokens, "cg");
48                    }
49                    Cop::Cs => {
50                        push_directive(tokens, "cs");
51                    }
52                    Cop::Cv => {
53                        push_directive(tokens, "cv");
54                    }
55                }
56            }
57            match &self.vec {
58                Vec::None => {
59                    push_token_from_str(tokens, "none");
60                }
61                Vec::V2 => {
62                    push_directive(tokens, "v2");
63                }
64                Vec::V4 => {
65                    push_directive(tokens, "v4");
66                }
67            }
68            match &self.dtype {
69                Dtype::B16 => {
70                    push_directive(tokens, "b16");
71                }
72                Dtype::B32 => {
73                    push_directive(tokens, "b32");
74                }
75                Dtype::B64 => {
76                    push_directive(tokens, "b64");
77                }
78                Dtype::B8 => {
79                    push_directive(tokens, "b8");
80                }
81            }
82            if let Some(mode_1) = self.mode.as_ref() {
83                match mode_1 {
84                    Mode::Clamp => {
85                        push_directive(tokens, "clamp");
86                    }
87                    Mode::Trap => {
88                        push_directive(tokens, "trap");
89                    }
90                    Mode::Zero => {
91                        push_directive(tokens, "zero");
92                    }
93                }
94            }
95            self.d.unparse_tokens(tokens);
96            tokens.push(PtxToken::Comma);
97            self.a.unparse_tokens(tokens);
98            tokens.push(PtxToken::Semicolon);
99        }
100    }
101}