Skip to main content

ptx_parser/type/instruction/
sured.rs

1//! Original PTX specification:
2//!
3//! sured.b.op.geom.ctype.mode [a,b],c; // byte addressing
4//! .op    = { .add, .min, .max, .and, .or };
5//! .geom  = { .1d, .2d, .3d };
6//! .ctype = { .u32, .u64, .s32, .b32, .s64 };  // for sured.b
7//! .mode  = { .trap, .clamp, .zero };
8//! ----------------------------------------------------
9//! sured.p.op.geom.ctype.mode [a,b],c; // sample addressing
10//! .op    = { .add, .min, .max, .and, .or };
11//! .geom  = { .1d, .2d, .3d };
12//! .ctype = { .b32, .b64 };                    // for sured.p
13//! .mode  = { .trap, .clamp, .zero };
14
15#![allow(unused)]
16use crate::r#type::common::*;
17
18pub mod section_0 {
19    use crate::Spanned;
20    use crate::parser::Span;
21    use crate::r#type::common::*;
22
23    use serde::Serialize;
24
25    #[derive(Debug, Clone, PartialEq, Serialize)]
26    pub enum Op {
27        Add, // .add
28        Min, // .min
29        Max, // .max
30        And, // .and
31        Or,  // .or
32    }
33
34    #[derive(Debug, Clone, PartialEq, Serialize)]
35    pub enum Geom {
36        _1d, // .1d
37        _2d, // .2d
38        _3d, // .3d
39    }
40
41    #[derive(Debug, Clone, PartialEq, Serialize)]
42    pub enum Ctype {
43        U32, // .u32
44        U64, // .u64
45        S32, // .s32
46        B32, // .b32
47        S64, // .s64
48    }
49
50    #[derive(Debug, Clone, PartialEq, Serialize)]
51    pub enum Mode {
52        Clamp, // .clamp
53        Trap,  // .trap
54        Zero,  // .zero
55    }
56
57    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
58    pub struct SuredBOpGeomCtypeMode {
59        pub b: (),             // .b
60        pub op: Op,            // .op
61        pub geom: Geom,        // .geom
62        pub ctype: Ctype,      // .ctype
63        pub mode: Mode,        // .mode
64        pub a: TexHandler2,    // [a, b]
65        pub c: GeneralOperand, // c
66        pub span: Span,
67    }
68}
69
70pub mod section_1 {
71    use crate::Spanned;
72    use crate::parser::Span;
73    use crate::r#type::common::*;
74
75    use serde::Serialize;
76
77    #[derive(Debug, Clone, PartialEq, Serialize)]
78    pub enum Op {
79        Add, // .add
80        Min, // .min
81        Max, // .max
82        And, // .and
83        Or,  // .or
84    }
85
86    #[derive(Debug, Clone, PartialEq, Serialize)]
87    pub enum Geom {
88        _1d, // .1d
89        _2d, // .2d
90        _3d, // .3d
91    }
92
93    #[derive(Debug, Clone, PartialEq, Serialize)]
94    pub enum Ctype {
95        B32, // .b32
96        B64, // .b64
97    }
98
99    #[derive(Debug, Clone, PartialEq, Serialize)]
100    pub enum Mode {
101        Clamp, // .clamp
102        Trap,  // .trap
103        Zero,  // .zero
104    }
105
106    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
107    pub struct SuredPOpGeomCtypeMode {
108        pub p: (),             // .p
109        pub op: Op,            // .op
110        pub geom: Geom,        // .geom
111        pub ctype: Ctype,      // .ctype
112        pub mode: Mode,        // .mode
113        pub a: TexHandler2,    // [a, b]
114        pub c: GeneralOperand, // c
115        pub span: Span,
116    }
117}
118
119// Re-export types with section suffixes to avoid naming conflicts
120// e.g., Type0 for section_0::Type, Type1 for section_1::Type
121pub use section_0::Ctype as Ctype0;
122pub use section_0::Geom as Geom0;
123pub use section_0::Mode as Mode0;
124pub use section_0::Op as Op0;
125pub use section_0::SuredBOpGeomCtypeMode;
126pub use section_1::Ctype as Ctype1;
127pub use section_1::Geom as Geom1;
128pub use section_1::Mode as Mode1;
129pub use section_1::Op as Op1;
130pub use section_1::SuredPOpGeomCtypeMode;