Skip to main content

ptx_parser/type/instruction/
sub.rs

1//! Original PTX specification:
2//!
3//! sub.type       d, a, b;
4//! sub{.sat}.s32  d, a, b;     // .sat applies only to .s32
5//! .type = { .u16, .u32, .u64,
6//! .s16, .s32, .s64 };
7//! --------------------------------------------
8//! sub{.rnd}{.ftz}{.sat}.f32  d, a, b;
9//! sub{.rnd}{.ftz}.f32x2      d, a, b;
10//! sub{.rnd}.f64              d, a, b;
11//! .rnd = { .rn, .rz, .rm, .rp };
12//! --------------------------------------------
13//! sub{.rnd}{.ftz}{.sat}.f16   d, a, b;
14//! sub{.rnd}{.ftz}{.sat}.f16x2 d, a, b;
15//! sub{.rnd}.bf16   d, a, b;
16//! sub{.rnd}.bf16x2 d, a, b;
17//! .rnd = { .rn };
18//! --------------------------------------------
19//! sub{.rnd}{.sat}.f32.atype  d, a, c;
20//! .atype = { .f16, .bf16};
21//! .rnd   = { .rn, .rz, .rm, .rp };
22
23#![allow(unused)]
24use crate::r#type::common::*;
25
26pub mod section_0 {
27    use crate::Spanned;
28    use crate::parser::Span;
29    use crate::r#type::common::*;
30
31    use serde::Serialize;
32
33    #[derive(Debug, Clone, PartialEq, Serialize)]
34    pub enum Type {
35        U16, // .u16
36        U32, // .u32
37        U64, // .u64
38        S16, // .s16
39        S32, // .s32
40        S64, // .s64
41    }
42
43    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
44    pub struct SubType {
45        pub type_: Type,       // .type
46        pub d: GeneralOperand, // d
47        pub a: GeneralOperand, // a
48        pub b: GeneralOperand, // b
49        pub span: Span,
50    }
51
52    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
53    pub struct SubSatS32 {
54        pub sat: bool,         // {.sat}
55        pub s32: (),           // .s32
56        pub d: GeneralOperand, // d
57        pub a: GeneralOperand, // a
58        pub b: GeneralOperand, // b
59        pub span: Span,
60    }
61}
62
63pub mod section_1 {
64    use crate::Spanned;
65    use crate::parser::Span;
66    use crate::r#type::common::*;
67
68    use serde::Serialize;
69
70    #[derive(Debug, Clone, PartialEq, Serialize)]
71    pub enum Rnd {
72        Rn, // .rn
73        Rz, // .rz
74        Rm, // .rm
75        Rp, // .rp
76    }
77
78    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
79    pub struct SubRndFtzSatF32 {
80        pub rnd: Option<Rnd>,  // {.rnd}
81        pub ftz: bool,         // {.ftz}
82        pub sat: bool,         // {.sat}
83        pub f32: (),           // .f32
84        pub d: GeneralOperand, // d
85        pub a: GeneralOperand, // a
86        pub b: GeneralOperand, // b
87        pub span: Span,
88    }
89
90    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
91    pub struct SubRndFtzF32x2 {
92        pub rnd: Option<Rnd>,  // {.rnd}
93        pub ftz: bool,         // {.ftz}
94        pub f32x2: (),         // .f32x2
95        pub d: GeneralOperand, // d
96        pub a: GeneralOperand, // a
97        pub b: GeneralOperand, // b
98        pub span: Span,
99    }
100
101    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
102    pub struct SubRndF64 {
103        pub rnd: Option<Rnd>,  // {.rnd}
104        pub f64: (),           // .f64
105        pub d: GeneralOperand, // d
106        pub a: GeneralOperand, // a
107        pub b: GeneralOperand, // b
108        pub span: Span,
109    }
110}
111
112pub mod section_2 {
113    use crate::Spanned;
114    use crate::parser::Span;
115    use crate::r#type::common::*;
116
117    use serde::Serialize;
118
119    #[derive(Debug, Clone, PartialEq, Serialize)]
120    pub enum Rnd {
121        Rn, // .rn
122    }
123
124    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
125    pub struct SubRndFtzSatF16 {
126        pub rnd: Option<Rnd>,  // {.rnd}
127        pub ftz: bool,         // {.ftz}
128        pub sat: bool,         // {.sat}
129        pub f16: (),           // .f16
130        pub d: GeneralOperand, // d
131        pub a: GeneralOperand, // a
132        pub b: GeneralOperand, // b
133        pub span: Span,
134    }
135
136    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
137    pub struct SubRndFtzSatF16x2 {
138        pub rnd: Option<Rnd>,  // {.rnd}
139        pub ftz: bool,         // {.ftz}
140        pub sat: bool,         // {.sat}
141        pub f16x2: (),         // .f16x2
142        pub d: GeneralOperand, // d
143        pub a: GeneralOperand, // a
144        pub b: GeneralOperand, // b
145        pub span: Span,
146    }
147
148    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
149    pub struct SubRndBf16 {
150        pub rnd: Option<Rnd>,  // {.rnd}
151        pub bf16: (),          // .bf16
152        pub d: GeneralOperand, // d
153        pub a: GeneralOperand, // a
154        pub b: GeneralOperand, // b
155        pub span: Span,
156    }
157
158    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
159    pub struct SubRndBf16x2 {
160        pub rnd: Option<Rnd>,  // {.rnd}
161        pub bf16x2: (),        // .bf16x2
162        pub d: GeneralOperand, // d
163        pub a: GeneralOperand, // a
164        pub b: GeneralOperand, // b
165        pub span: Span,
166    }
167}
168
169pub mod section_3 {
170    use crate::Spanned;
171    use crate::parser::Span;
172    use crate::r#type::common::*;
173
174    use serde::Serialize;
175
176    #[derive(Debug, Clone, PartialEq, Serialize)]
177    pub enum Rnd {
178        Rn, // .rn
179        Rz, // .rz
180        Rm, // .rm
181        Rp, // .rp
182    }
183
184    #[derive(Debug, Clone, PartialEq, Serialize)]
185    pub enum Atype {
186        Bf16, // .bf16
187        F16,  // .f16
188    }
189
190    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
191    pub struct SubRndSatF32Atype {
192        pub rnd: Option<Rnd>,  // {.rnd}
193        pub sat: bool,         // {.sat}
194        pub f32: (),           // .f32
195        pub atype: Atype,      // .atype
196        pub d: GeneralOperand, // d
197        pub a: GeneralOperand, // a
198        pub c: GeneralOperand, // c
199        pub span: Span,
200    }
201}
202
203// Re-export types with section suffixes to avoid naming conflicts
204// e.g., Type0 for section_0::Type, Type1 for section_1::Type
205pub use section_0::SubSatS32;
206pub use section_0::SubType;
207pub use section_0::Type as Type0;
208pub use section_1::Rnd as Rnd1;
209pub use section_1::SubRndF64;
210pub use section_1::SubRndFtzF32x2;
211pub use section_1::SubRndFtzSatF32;
212pub use section_2::Rnd as Rnd2;
213pub use section_2::SubRndBf16;
214pub use section_2::SubRndBf16x2;
215pub use section_2::SubRndFtzSatF16;
216pub use section_2::SubRndFtzSatF16x2;
217pub use section_3::Atype as Atype3;
218pub use section_3::Rnd as Rnd3;
219pub use section_3::SubRndSatF32Atype;