Skip to main content

ptx_parser/unparser/instruction/
testp.rs

1//! Original PTX specification:
2//!
3//! testp.op.type  p, a;  // result is .pred
4//! .op   = { .finite, .infinite,
5//! .number, .notanumber,
6//! .normal, .subnormal };
7//! .type = { .f32, .f64 };
8
9#![allow(unused)]
10
11use crate::lexer::PtxToken;
12use crate::unparser::{PtxUnparser, common::*};
13
14pub mod section_0 {
15    use super::*;
16    use crate::r#type::instruction::testp::section_0::*;
17
18    impl PtxUnparser for TestpOpType {
19        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
20            self.unparse_tokens_mode(tokens, false);
21        }
22        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
23            push_opcode(tokens, "testp");
24            match &self.op {
25                Op::Notanumber => {
26                    push_directive(tokens, "notanumber");
27                }
28                Op::Subnormal => {
29                    push_directive(tokens, "subnormal");
30                }
31                Op::Infinite => {
32                    push_directive(tokens, "infinite");
33                }
34                Op::Finite => {
35                    push_directive(tokens, "finite");
36                }
37                Op::Number => {
38                    push_directive(tokens, "number");
39                }
40                Op::Normal => {
41                    push_directive(tokens, "normal");
42                }
43            }
44            match &self.type_ {
45                Type::F32 => {
46                    push_directive(tokens, "f32");
47                }
48                Type::F64 => {
49                    push_directive(tokens, "f64");
50                }
51            }
52            if spaced {
53                tokens.push(PtxToken::Space);
54            }
55            self.p.unparse_tokens_mode(tokens, spaced);
56            tokens.push(PtxToken::Comma);
57            if spaced {
58                tokens.push(PtxToken::Space);
59            }
60            self.a.unparse_tokens_mode(tokens, spaced);
61            tokens.push(PtxToken::Semicolon);
62            if spaced {
63                tokens.push(PtxToken::Newline);
64            }
65        }
66    }
67}