Skip to main content

ptx_parser/type/instruction/
mad.rs

1//! Original PTX specification:
2//!
3//! mad.mode.type  d, a, b, c;
4//! mad.hi.sat.s32 d, a, b, c;
5//! .mode = { .hi, .lo, .wide };
6//! .type = { .u16, .u32, .u64,
7//! .s16, .s32, .s64 };
8//!
9//! mad{.ftz}{.sat}.f32      d, a, b, c;    // .target sm_1x
10//! mad.rnd{.ftz}{.sat}.f32  d, a, b, c;    // .target sm_20
11//! mad.rnd.f64              d, a, b, c;    // .target sm_13 and higher
12//! .rnd = { .rn, .rz, .rm, .rp };
13
14#![allow(unused)]
15use crate::r#type::common::*;
16
17pub mod section_0 {
18    use crate::Spanned;
19    use crate::parser::Span;
20    use crate::r#type::common::*;
21
22    use serde::Serialize;
23
24    #[derive(Debug, Clone, PartialEq, Serialize)]
25    pub enum Mode {
26        Wide, // .wide
27        Hi,   // .hi
28        Lo,   // .lo
29    }
30
31    #[derive(Debug, Clone, PartialEq, Serialize)]
32    pub enum Type {
33        U16, // .u16
34        U32, // .u32
35        U64, // .u64
36        S16, // .s16
37        S32, // .s32
38        S64, // .s64
39    }
40
41    #[derive(Debug, Clone, PartialEq, Serialize)]
42    pub enum Rnd {
43        Rn, // .rn
44        Rz, // .rz
45        Rm, // .rm
46        Rp, // .rp
47    }
48
49    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
50    pub struct MadModeType {
51        pub mode: Mode,        // .mode
52        pub type_: Type,       // .type
53        pub d: GeneralOperand, // d
54        pub a: GeneralOperand, // a
55        pub b: GeneralOperand, // b
56        pub c: GeneralOperand, // c
57        pub span: Span,
58    }
59
60    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
61    pub struct MadHiSatS32 {
62        pub hi: (),            // .hi
63        pub sat: (),           // .sat
64        pub s32: (),           // .s32
65        pub d: GeneralOperand, // d
66        pub a: GeneralOperand, // a
67        pub b: GeneralOperand, // b
68        pub c: GeneralOperand, // c
69        pub span: Span,
70    }
71
72    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
73    pub struct MadFtzSatF32 {
74        pub ftz: bool,         // {.ftz}
75        pub sat: bool,         // {.sat}
76        pub f32: (),           // .f32
77        pub d: GeneralOperand, // d
78        pub a: GeneralOperand, // a
79        pub b: GeneralOperand, // b
80        pub c: GeneralOperand, // c
81        pub span: Span,
82    }
83
84    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
85    pub struct MadRndFtzSatF32 {
86        pub rnd: Rnd,          // .rnd
87        pub ftz: bool,         // {.ftz}
88        pub sat: bool,         // {.sat}
89        pub f32: (),           // .f32
90        pub d: GeneralOperand, // d
91        pub a: GeneralOperand, // a
92        pub b: GeneralOperand, // b
93        pub c: GeneralOperand, // c
94        pub span: Span,
95    }
96
97    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
98    pub struct MadRndF64 {
99        pub rnd: Rnd,          // .rnd
100        pub f64: (),           // .f64
101        pub d: GeneralOperand, // d
102        pub a: GeneralOperand, // a
103        pub b: GeneralOperand, // b
104        pub c: GeneralOperand, // c
105        pub span: Span,
106    }
107}
108
109// Re-export types with section suffixes to avoid naming conflicts
110// e.g., Type0 for section_0::Type, Type1 for section_1::Type
111pub use section_0::MadFtzSatF32;
112pub use section_0::MadHiSatS32;
113pub use section_0::MadModeType;
114pub use section_0::MadRndF64;
115pub use section_0::MadRndFtzSatF32;
116pub use section_0::Mode as Mode0;
117pub use section_0::Rnd as Rnd0;
118pub use section_0::Type as Type0;