Skip to main content

ptx_parser/unparser/instruction/
discard.rs

1//! Original PTX specification:
2//!
3//! discard{.global}.level  [a], size;
4//! .level = { .L2 };
5
6#![allow(unused)]
7
8use crate::lexer::PtxToken;
9use crate::unparser::{PtxUnparser, common::*};
10
11pub mod section_0 {
12    use super::*;
13    use crate::r#type::instruction::discard::section_0::*;
14
15    impl PtxUnparser for DiscardGlobalLevel {
16        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
17            self.unparse_tokens_mode(tokens, false);
18        }
19        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
20            push_opcode(tokens, "discard");
21            if self.global {
22                push_directive(tokens, "global");
23            }
24            match &self.level {
25                Level::L2 => {
26                    push_directive(tokens, "L2");
27                }
28            }
29            if spaced {
30                tokens.push(PtxToken::Space);
31            }
32            self.a.unparse_tokens_mode(tokens, spaced);
33            tokens.push(PtxToken::Comma);
34            if spaced {
35                tokens.push(PtxToken::Space);
36            }
37            self.size.unparse_tokens_mode(tokens, spaced);
38            tokens.push(PtxToken::Semicolon);
39            if spaced {
40                tokens.push(PtxToken::Newline);
41            }
42        }
43    }
44}