Skip to main content

ptx_parser/type/instruction/
max.rs

1//! Original PTX specification:
2//!
3//! max.atype         d, a, b;
4//! max{.relu}.btype  d, a, b;
5//! .atype = { .u16, .u32, .u64,
6//! .u16x2, .s16, .s64 };
7//! .btype = { .s16x2, .s32 };
8//!
9//! max{.ftz}{.NaN}{.xorsign.abs}.f32  d, a, b;
10//! max{.ftz}{.NaN}{.abs}.f32          d, a, b, c;
11//! max.f64                            d, a, b;
12//!
13//! max{.ftz}{.NaN}{.xorsign.abs}.f16      d, a, b;
14//! max{.ftz}{.NaN}{.xorsign.abs}.f16x2    d, a, b;
15//! max{.NaN}{.xorsign.abs}.bf16           d, a, b;
16//! max{.NaN}{.xorsign.abs}.bf16x2         d, a, b;
17
18#![allow(unused)]
19use crate::r#type::common::*;
20
21pub mod section_0 {
22    use crate::Spanned;
23    use crate::parser::Span;
24    use crate::r#type::common::*;
25
26    use serde::Serialize;
27
28    #[derive(Debug, Clone, PartialEq, Serialize)]
29    pub enum Atype {
30        U16x2, // .u16x2
31        U16,   // .u16
32        U32,   // .u32
33        U64,   // .u64
34        S16,   // .s16
35        S64,   // .s64
36    }
37
38    #[derive(Debug, Clone, PartialEq, Serialize)]
39    pub enum Btype {
40        S16x2, // .s16x2
41        S32,   // .s32
42    }
43
44    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
45    pub struct MaxAtype {
46        pub atype: Atype,      // .atype
47        pub d: GeneralOperand, // d
48        pub a: GeneralOperand, // a
49        pub b: GeneralOperand, // b
50        pub span: Span,
51    }
52
53    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
54    pub struct MaxReluBtype {
55        pub relu: bool,        // {.relu}
56        pub btype: Btype,      // .btype
57        pub d: GeneralOperand, // d
58        pub a: GeneralOperand, // a
59        pub b: GeneralOperand, // b
60        pub span: Span,
61    }
62
63    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
64    pub struct MaxFtzNanXorsignAbsF32 {
65        pub ftz: bool,         // {.ftz}
66        pub nan: bool,         // {.NaN}
67        pub xorsign_abs: bool, // {.xorsign.abs}
68        pub f32: (),           // .f32
69        pub d: GeneralOperand, // d
70        pub a: GeneralOperand, // a
71        pub b: GeneralOperand, // b
72        pub span: Span,
73    }
74
75    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
76    pub struct MaxFtzNanAbsF32 {
77        pub ftz: bool,         // {.ftz}
78        pub nan: bool,         // {.NaN}
79        pub abs: bool,         // {.abs}
80        pub f32: (),           // .f32
81        pub d: GeneralOperand, // d
82        pub a: GeneralOperand, // a
83        pub b: GeneralOperand, // b
84        pub c: GeneralOperand, // c
85        pub span: Span,
86    }
87
88    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
89    pub struct MaxF64 {
90        pub f64: (),           // .f64
91        pub d: GeneralOperand, // d
92        pub a: GeneralOperand, // a
93        pub b: GeneralOperand, // b
94        pub span: Span,
95    }
96
97    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
98    pub struct MaxFtzNanXorsignAbsF16 {
99        pub ftz: bool,         // {.ftz}
100        pub nan: bool,         // {.NaN}
101        pub xorsign_abs: bool, // {.xorsign.abs}
102        pub f16: (),           // .f16
103        pub d: GeneralOperand, // d
104        pub a: GeneralOperand, // a
105        pub b: GeneralOperand, // b
106        pub span: Span,
107    }
108
109    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
110    pub struct MaxFtzNanXorsignAbsF16x2 {
111        pub ftz: bool,         // {.ftz}
112        pub nan: bool,         // {.NaN}
113        pub xorsign_abs: bool, // {.xorsign.abs}
114        pub f16x2: (),         // .f16x2
115        pub d: GeneralOperand, // d
116        pub a: GeneralOperand, // a
117        pub b: GeneralOperand, // b
118        pub span: Span,
119    }
120
121    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
122    pub struct MaxNanXorsignAbsBf16 {
123        pub nan: bool,         // {.NaN}
124        pub xorsign_abs: bool, // {.xorsign.abs}
125        pub bf16: (),          // .bf16
126        pub d: GeneralOperand, // d
127        pub a: GeneralOperand, // a
128        pub b: GeneralOperand, // b
129        pub span: Span,
130    }
131
132    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
133    pub struct MaxNanXorsignAbsBf16x2 {
134        pub nan: bool,         // {.NaN}
135        pub xorsign_abs: bool, // {.xorsign.abs}
136        pub bf16x2: (),        // .bf16x2
137        pub d: GeneralOperand, // d
138        pub a: GeneralOperand, // a
139        pub b: GeneralOperand, // b
140        pub span: Span,
141    }
142}
143
144// Re-export types with section suffixes to avoid naming conflicts
145// e.g., Type0 for section_0::Type, Type1 for section_1::Type
146pub use section_0::Atype as Atype0;
147pub use section_0::Btype as Btype0;
148pub use section_0::MaxAtype;
149pub use section_0::MaxF64;
150pub use section_0::MaxFtzNanAbsF32;
151pub use section_0::MaxFtzNanXorsignAbsF16;
152pub use section_0::MaxFtzNanXorsignAbsF16x2;
153pub use section_0::MaxFtzNanXorsignAbsF32;
154pub use section_0::MaxNanXorsignAbsBf16;
155pub use section_0::MaxNanXorsignAbsBf16x2;
156pub use section_0::MaxReluBtype;