1use crate::enums::kind_a_64::KindA64;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4#[repr(C)]
5pub struct RegisterA64 {
6 pub(crate) bits: u8,
7}
8
9#[allow(non_upper_case_globals)]
14impl RegisterA64 {
15 pub(crate) const KIND_MASK: u8 = 0x07;
16 pub(crate) const INDEX_MASK: u8 = 0xF8;
17 pub(crate) const INDEX_SHIFT: u32 = 3;
18
19 const fn make(kind: KindA64, index: u8) -> Self {
20 RegisterA64 {
21 bits: (index << Self::INDEX_SHIFT) | (kind as u8),
22 }
23 }
24
25 pub fn kind(&self) -> KindA64 {
26 match self.bits & Self::KIND_MASK {
34 0 => KindA64::none,
35 1 => KindA64::w,
36 2 => KindA64::x,
37 3 => KindA64::s,
38 4 => KindA64::d,
39 5 => KindA64::q,
40 _ => KindA64::none,
41 }
42 }
43
44 pub fn index(&self) -> u8 {
45 (self.bits & Self::INDEX_MASK) >> Self::INDEX_SHIFT
46 }
47
48 pub const noreg: RegisterA64 = Self::make(KindA64::none, 0);
50 pub const w0: RegisterA64 = Self::make(KindA64::w, 0);
51 pub const w1: RegisterA64 = Self::make(KindA64::w, 1);
52 pub const w2: RegisterA64 = Self::make(KindA64::w, 2);
53 pub const w3: RegisterA64 = Self::make(KindA64::w, 3);
54 pub const w4: RegisterA64 = Self::make(KindA64::w, 4);
55 pub const w5: RegisterA64 = Self::make(KindA64::w, 5);
56 pub const w6: RegisterA64 = Self::make(KindA64::w, 6);
57 pub const w7: RegisterA64 = Self::make(KindA64::w, 7);
58 pub const w8: RegisterA64 = Self::make(KindA64::w, 8);
59 pub const w9: RegisterA64 = Self::make(KindA64::w, 9);
60 pub const w10: RegisterA64 = Self::make(KindA64::w, 10);
61 pub const w11: RegisterA64 = Self::make(KindA64::w, 11);
62 pub const w12: RegisterA64 = Self::make(KindA64::w, 12);
63 pub const w13: RegisterA64 = Self::make(KindA64::w, 13);
64 pub const w14: RegisterA64 = Self::make(KindA64::w, 14);
65 pub const w15: RegisterA64 = Self::make(KindA64::w, 15);
66 pub const w16: RegisterA64 = Self::make(KindA64::w, 16);
67 pub const w17: RegisterA64 = Self::make(KindA64::w, 17);
68 pub const w18: RegisterA64 = Self::make(KindA64::w, 18);
69 pub const w19: RegisterA64 = Self::make(KindA64::w, 19);
70 pub const w20: RegisterA64 = Self::make(KindA64::w, 20);
71 pub const w21: RegisterA64 = Self::make(KindA64::w, 21);
72 pub const w22: RegisterA64 = Self::make(KindA64::w, 22);
73 pub const w23: RegisterA64 = Self::make(KindA64::w, 23);
74 pub const w24: RegisterA64 = Self::make(KindA64::w, 24);
75 pub const w25: RegisterA64 = Self::make(KindA64::w, 25);
76 pub const w26: RegisterA64 = Self::make(KindA64::w, 26);
77 pub const w27: RegisterA64 = Self::make(KindA64::w, 27);
78 pub const w28: RegisterA64 = Self::make(KindA64::w, 28);
79 pub const w29: RegisterA64 = Self::make(KindA64::w, 29);
80 pub const w30: RegisterA64 = Self::make(KindA64::w, 30);
81 pub const wzr: RegisterA64 = Self::make(KindA64::w, 31);
82 pub const x0: RegisterA64 = Self::make(KindA64::x, 0);
83 pub const x1: RegisterA64 = Self::make(KindA64::x, 1);
84 pub const x2: RegisterA64 = Self::make(KindA64::x, 2);
85 pub const x3: RegisterA64 = Self::make(KindA64::x, 3);
86 pub const x4: RegisterA64 = Self::make(KindA64::x, 4);
87 pub const x5: RegisterA64 = Self::make(KindA64::x, 5);
88 pub const x6: RegisterA64 = Self::make(KindA64::x, 6);
89 pub const x7: RegisterA64 = Self::make(KindA64::x, 7);
90 pub const x8: RegisterA64 = Self::make(KindA64::x, 8);
91 pub const x9: RegisterA64 = Self::make(KindA64::x, 9);
92 pub const x10: RegisterA64 = Self::make(KindA64::x, 10);
93 pub const x11: RegisterA64 = Self::make(KindA64::x, 11);
94 pub const x12: RegisterA64 = Self::make(KindA64::x, 12);
95 pub const x13: RegisterA64 = Self::make(KindA64::x, 13);
96 pub const x14: RegisterA64 = Self::make(KindA64::x, 14);
97 pub const x15: RegisterA64 = Self::make(KindA64::x, 15);
98 pub const x16: RegisterA64 = Self::make(KindA64::x, 16);
99 pub const x17: RegisterA64 = Self::make(KindA64::x, 17);
100 pub const x18: RegisterA64 = Self::make(KindA64::x, 18);
101 pub const x19: RegisterA64 = Self::make(KindA64::x, 19);
102 pub const x20: RegisterA64 = Self::make(KindA64::x, 20);
103 pub const x21: RegisterA64 = Self::make(KindA64::x, 21);
104 pub const x22: RegisterA64 = Self::make(KindA64::x, 22);
105 pub const x23: RegisterA64 = Self::make(KindA64::x, 23);
106 pub const x24: RegisterA64 = Self::make(KindA64::x, 24);
107 pub const x25: RegisterA64 = Self::make(KindA64::x, 25);
108 pub const x26: RegisterA64 = Self::make(KindA64::x, 26);
109 pub const x27: RegisterA64 = Self::make(KindA64::x, 27);
110 pub const x28: RegisterA64 = Self::make(KindA64::x, 28);
111 pub const x29: RegisterA64 = Self::make(KindA64::x, 29);
112 pub const x30: RegisterA64 = Self::make(KindA64::x, 30);
113 pub const xzr: RegisterA64 = Self::make(KindA64::x, 31);
114 pub const sp: RegisterA64 = Self::make(KindA64::none, 31);
115 pub const s0: RegisterA64 = Self::make(KindA64::s, 0);
116 pub const s1: RegisterA64 = Self::make(KindA64::s, 1);
117 pub const s2: RegisterA64 = Self::make(KindA64::s, 2);
118 pub const s3: RegisterA64 = Self::make(KindA64::s, 3);
119 pub const s4: RegisterA64 = Self::make(KindA64::s, 4);
120 pub const s5: RegisterA64 = Self::make(KindA64::s, 5);
121 pub const s6: RegisterA64 = Self::make(KindA64::s, 6);
122 pub const s7: RegisterA64 = Self::make(KindA64::s, 7);
123 pub const s8: RegisterA64 = Self::make(KindA64::s, 8);
124 pub const s9: RegisterA64 = Self::make(KindA64::s, 9);
125 pub const s10: RegisterA64 = Self::make(KindA64::s, 10);
126 pub const s11: RegisterA64 = Self::make(KindA64::s, 11);
127 pub const s12: RegisterA64 = Self::make(KindA64::s, 12);
128 pub const s13: RegisterA64 = Self::make(KindA64::s, 13);
129 pub const s14: RegisterA64 = Self::make(KindA64::s, 14);
130 pub const s15: RegisterA64 = Self::make(KindA64::s, 15);
131 pub const s16: RegisterA64 = Self::make(KindA64::s, 16);
132 pub const s17: RegisterA64 = Self::make(KindA64::s, 17);
133 pub const s18: RegisterA64 = Self::make(KindA64::s, 18);
134 pub const s19: RegisterA64 = Self::make(KindA64::s, 19);
135 pub const s20: RegisterA64 = Self::make(KindA64::s, 20);
136 pub const s21: RegisterA64 = Self::make(KindA64::s, 21);
137 pub const s22: RegisterA64 = Self::make(KindA64::s, 22);
138 pub const s23: RegisterA64 = Self::make(KindA64::s, 23);
139 pub const s24: RegisterA64 = Self::make(KindA64::s, 24);
140 pub const s25: RegisterA64 = Self::make(KindA64::s, 25);
141 pub const s26: RegisterA64 = Self::make(KindA64::s, 26);
142 pub const s27: RegisterA64 = Self::make(KindA64::s, 27);
143 pub const s28: RegisterA64 = Self::make(KindA64::s, 28);
144 pub const s29: RegisterA64 = Self::make(KindA64::s, 29);
145 pub const s30: RegisterA64 = Self::make(KindA64::s, 30);
146 pub const s31: RegisterA64 = Self::make(KindA64::s, 31);
147 pub const d0: RegisterA64 = Self::make(KindA64::d, 0);
148 pub const d1: RegisterA64 = Self::make(KindA64::d, 1);
149 pub const d2: RegisterA64 = Self::make(KindA64::d, 2);
150 pub const d3: RegisterA64 = Self::make(KindA64::d, 3);
151 pub const d4: RegisterA64 = Self::make(KindA64::d, 4);
152 pub const d5: RegisterA64 = Self::make(KindA64::d, 5);
153 pub const d6: RegisterA64 = Self::make(KindA64::d, 6);
154 pub const d7: RegisterA64 = Self::make(KindA64::d, 7);
155 pub const d8: RegisterA64 = Self::make(KindA64::d, 8);
156 pub const d9: RegisterA64 = Self::make(KindA64::d, 9);
157 pub const d10: RegisterA64 = Self::make(KindA64::d, 10);
158 pub const d11: RegisterA64 = Self::make(KindA64::d, 11);
159 pub const d12: RegisterA64 = Self::make(KindA64::d, 12);
160 pub const d13: RegisterA64 = Self::make(KindA64::d, 13);
161 pub const d14: RegisterA64 = Self::make(KindA64::d, 14);
162 pub const d15: RegisterA64 = Self::make(KindA64::d, 15);
163 pub const d16: RegisterA64 = Self::make(KindA64::d, 16);
164 pub const d17: RegisterA64 = Self::make(KindA64::d, 17);
165 pub const d18: RegisterA64 = Self::make(KindA64::d, 18);
166 pub const d19: RegisterA64 = Self::make(KindA64::d, 19);
167 pub const d20: RegisterA64 = Self::make(KindA64::d, 20);
168 pub const d21: RegisterA64 = Self::make(KindA64::d, 21);
169 pub const d22: RegisterA64 = Self::make(KindA64::d, 22);
170 pub const d23: RegisterA64 = Self::make(KindA64::d, 23);
171 pub const d24: RegisterA64 = Self::make(KindA64::d, 24);
172 pub const d25: RegisterA64 = Self::make(KindA64::d, 25);
173 pub const d26: RegisterA64 = Self::make(KindA64::d, 26);
174 pub const d27: RegisterA64 = Self::make(KindA64::d, 27);
175 pub const d28: RegisterA64 = Self::make(KindA64::d, 28);
176 pub const d29: RegisterA64 = Self::make(KindA64::d, 29);
177 pub const d30: RegisterA64 = Self::make(KindA64::d, 30);
178 pub const d31: RegisterA64 = Self::make(KindA64::d, 31);
179 pub const q0: RegisterA64 = Self::make(KindA64::q, 0);
180 pub const q1: RegisterA64 = Self::make(KindA64::q, 1);
181 pub const q2: RegisterA64 = Self::make(KindA64::q, 2);
182 pub const q3: RegisterA64 = Self::make(KindA64::q, 3);
183 pub const q4: RegisterA64 = Self::make(KindA64::q, 4);
184 pub const q5: RegisterA64 = Self::make(KindA64::q, 5);
185 pub const q6: RegisterA64 = Self::make(KindA64::q, 6);
186 pub const q7: RegisterA64 = Self::make(KindA64::q, 7);
187 pub const q8: RegisterA64 = Self::make(KindA64::q, 8);
188 pub const q9: RegisterA64 = Self::make(KindA64::q, 9);
189 pub const q10: RegisterA64 = Self::make(KindA64::q, 10);
190 pub const q11: RegisterA64 = Self::make(KindA64::q, 11);
191 pub const q12: RegisterA64 = Self::make(KindA64::q, 12);
192 pub const q13: RegisterA64 = Self::make(KindA64::q, 13);
193 pub const q14: RegisterA64 = Self::make(KindA64::q, 14);
194 pub const q15: RegisterA64 = Self::make(KindA64::q, 15);
195 pub const q16: RegisterA64 = Self::make(KindA64::q, 16);
196 pub const q17: RegisterA64 = Self::make(KindA64::q, 17);
197 pub const q18: RegisterA64 = Self::make(KindA64::q, 18);
198 pub const q19: RegisterA64 = Self::make(KindA64::q, 19);
199 pub const q20: RegisterA64 = Self::make(KindA64::q, 20);
200 pub const q21: RegisterA64 = Self::make(KindA64::q, 21);
201 pub const q22: RegisterA64 = Self::make(KindA64::q, 22);
202 pub const q23: RegisterA64 = Self::make(KindA64::q, 23);
203 pub const q24: RegisterA64 = Self::make(KindA64::q, 24);
204 pub const q25: RegisterA64 = Self::make(KindA64::q, 25);
205 pub const q26: RegisterA64 = Self::make(KindA64::q, 26);
206 pub const q27: RegisterA64 = Self::make(KindA64::q, 27);
207 pub const q28: RegisterA64 = Self::make(KindA64::q, 28);
208 pub const q29: RegisterA64 = Self::make(KindA64::q, 29);
209 pub const q30: RegisterA64 = Self::make(KindA64::q, 30);
210 pub const q31: RegisterA64 = Self::make(KindA64::q, 31);
211}
212
213impl Default for RegisterA64 {
214 fn default() -> Self {
215 Self {
216 bits: KindA64::none as u8,
217 }
218 }
219}