Skip to main content

ptx_parser/type/instruction/
div.rs

1//! Original PTX specification:
2//!
3//! div.type  d, a, b;
4//! .type = { .u16, .u32, .u64,
5//! .s16, .s32, .s64 };
6//!
7//! div.approx{.ftz}.f32  d, a, b;  // fast, approximate divide
8//! div.full{.ftz}.f32    d, a, b;  // full-range approximate divide
9//! div.rnd{.ftz}.f32     d, a, b;  // IEEE 754 compliant rounding
10//! div.rnd.f64           d, a, b;  // IEEE 754 compliant rounding
11//! .rnd = { .rn, .rz, .rm, .rp };
12
13#![allow(unused)]
14use crate::r#type::common::*;
15
16pub mod section_0 {
17    use crate::Spanned;
18    use crate::parser::Span;
19    use crate::r#type::common::*;
20
21    use serde::Serialize;
22
23    #[derive(Debug, Clone, PartialEq, Serialize)]
24    pub enum Type {
25        U16, // .u16
26        U32, // .u32
27        U64, // .u64
28        S16, // .s16
29        S32, // .s32
30        S64, // .s64
31    }
32
33    #[derive(Debug, Clone, PartialEq, Serialize)]
34    pub enum Rnd {
35        Rn, // .rn
36        Rz, // .rz
37        Rm, // .rm
38        Rp, // .rp
39    }
40
41    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
42    pub struct DivType {
43        pub type_: Type,       // .type
44        pub d: GeneralOperand, // d
45        pub a: GeneralOperand, // a
46        pub b: GeneralOperand, // b
47        pub span: Span,
48    }
49
50    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
51    pub struct DivApproxFtzF32 {
52        pub approx: (),        // .approx
53        pub ftz: bool,         // {.ftz}
54        pub f32: (),           // .f32
55        pub d: GeneralOperand, // d
56        pub a: GeneralOperand, // a
57        pub b: GeneralOperand, // b
58        pub span: Span,
59    }
60
61    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
62    pub struct DivFullFtzF32 {
63        pub full: (),          // .full
64        pub ftz: bool,         // {.ftz}
65        pub f32: (),           // .f32
66        pub d: GeneralOperand, // d
67        pub a: GeneralOperand, // a
68        pub b: GeneralOperand, // b
69        pub span: Span,
70    }
71
72    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
73    pub struct DivRndFtzF32 {
74        pub rnd: Rnd,          // .rnd
75        pub ftz: bool,         // {.ftz}
76        pub f32: (),           // .f32
77        pub d: GeneralOperand, // d
78        pub a: GeneralOperand, // a
79        pub b: GeneralOperand, // b
80        pub span: Span,
81    }
82
83    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
84    pub struct DivRndF64 {
85        pub rnd: Rnd,          // .rnd
86        pub f64: (),           // .f64
87        pub d: GeneralOperand, // d
88        pub a: GeneralOperand, // a
89        pub b: GeneralOperand, // b
90        pub span: Span,
91    }
92}
93
94// Re-export types with section suffixes to avoid naming conflicts
95// e.g., Type0 for section_0::Type, Type1 for section_1::Type
96pub use section_0::DivApproxFtzF32;
97pub use section_0::DivFullFtzF32;
98pub use section_0::DivRndF64;
99pub use section_0::DivRndFtzF32;
100pub use section_0::DivType;
101pub use section_0::Rnd as Rnd0;
102pub use section_0::Type as Type0;