Skip to main content

ptx_parser/type/instruction/
mov.rs

1//! Original PTX specification:
2//!
3//! mov.type  d, a;
4//! // mov.type  d, sreg;
5//! // mov.type  d, avar;       // get address of variable
6//! // mov.type  d, avar+imm;   // get address of variable with offset
7//! mov.u32   d, fname;      // get address of device function
8//! mov.u64   d, fname;      // get address of device function
9//! mov.u32   d, kernel;     // get address of entry function
10//! mov.u64   d, kernel;     // get address of entry function
11//! .type = { .pred,
12//! .b16, .b32, .b64,
13//! .u16, .u32, .u64,
14//! .s16, .s32, .s64,
15//! .f32, .f64 };
16//! ----------------------------------------------
17//! mov.type  d, a;
18//! .type = { .b16, .b32, .b64, .b128 };
19
20#![allow(unused)]
21use crate::r#type::common::*;
22
23pub mod section_0 {
24    use crate::Spanned;
25    use crate::parser::Span;
26    use crate::r#type::common::*;
27
28    use serde::Serialize;
29
30    #[derive(Debug, Clone, PartialEq, Serialize)]
31    pub enum Type {
32        Pred, // .pred
33        B16,  // .b16
34        B32,  // .b32
35        B64,  // .b64
36        U16,  // .u16
37        U32,  // .u32
38        U64,  // .u64
39        S16,  // .s16
40        S32,  // .s32
41        S64,  // .s64
42        F32,  // .f32
43        F64,  // .f64
44    }
45
46    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
47    pub struct MovType {
48        pub type_: Type,       // .type
49        pub d: GeneralOperand, // d
50        pub a: GeneralOperand, // a
51        pub span: Span,
52    }
53
54    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
55    pub struct MovU32 {
56        pub u32: (),               // .u32
57        pub d: GeneralOperand,     // d
58        pub fname: GeneralOperand, // fname
59        pub span: Span,
60    }
61
62    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
63    pub struct MovU64 {
64        pub u64: (),               // .u64
65        pub d: GeneralOperand,     // d
66        pub fname: GeneralOperand, // fname
67        pub span: Span,
68    }
69
70    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
71    pub struct MovU321 {
72        pub u32: (),                // .u32
73        pub d: GeneralOperand,      // d
74        pub kernel: GeneralOperand, // kernel
75        pub span: Span,
76    }
77
78    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
79    pub struct MovU641 {
80        pub u64: (),                // .u64
81        pub d: GeneralOperand,      // d
82        pub kernel: GeneralOperand, // kernel
83        pub span: Span,
84    }
85}
86
87pub mod section_1 {
88    use crate::Spanned;
89    use crate::parser::Span;
90    use crate::r#type::common::*;
91
92    use serde::Serialize;
93
94    #[derive(Debug, Clone, PartialEq, Serialize)]
95    pub enum Type {
96        B128, // .b128
97        B16,  // .b16
98        B32,  // .b32
99        B64,  // .b64
100    }
101
102    #[derive(Debug, Clone, PartialEq, Spanned, Serialize)]
103    pub struct MovType1 {
104        pub type_: Type,       // .type
105        pub d: GeneralOperand, // d
106        pub a: GeneralOperand, // a
107        pub span: Span,
108    }
109}
110
111// Re-export types with section suffixes to avoid naming conflicts
112// e.g., Type0 for section_0::Type, Type1 for section_1::Type
113pub use section_0::MovType;
114pub use section_0::MovU32;
115pub use section_0::MovU64;
116pub use section_0::MovU321;
117pub use section_0::MovU641;
118pub use section_0::Type as Type0;
119pub use section_1::MovType1;
120pub use section_1::Type as Type1;