1#ifdef GET_BANKEDREG_DECL
2enum BankedRegValues {
3 elr_hyp = 0,
4 lr_abt = 1,
5 lr_fiq = 2,
6 lr_irq = 3,
7 lr_mon = 4,
8 lr_svc = 5,
9 lr_und = 6,
10 lr_usr = 7,
11 r10_fiq = 8,
12 r10_usr = 9,
13 r11_fiq = 10,
14 r11_usr = 11,
15 r12_fiq = 12,
16 r12_usr = 13,
17 r8_fiq = 14,
18 r8_usr = 15,
19 r9_fiq = 16,
20 r9_usr = 17,
21 sp_abt = 18,
22 sp_fiq = 19,
23 sp_hyp = 20,
24 sp_irq = 21,
25 sp_mon = 22,
26 sp_svc = 23,
27 sp_und = 24,
28 sp_usr = 25,
29 spsr_abt = 26,
30 spsr_fiq = 27,
31 spsr_hyp = 28,
32 spsr_irq = 29,
33 spsr_mon = 30,
34 spsr_svc = 31,
35 spsr_und = 32,
36};
37#endif
38
39#ifdef GET_MCLASSSYSREG_DECL
40enum MClassSysRegValues {
41 apsr_g = 1024,
42 apsr_nzcvqg = 3072,
43 iapsr_g = 1025,
44 iapsr_nzcvqg = 3073,
45 eapsr_g = 1026,
46 eapsr_nzcvqg = 3074,
47 xpsr_g = 1027,
48 xpsr_nzcvqg = 3075,
49 apsr = 2048,
50 apsr_nzcvq = 2048,
51 iapsr = 2049,
52 iapsr_nzcvq = 2049,
53 eapsr = 2050,
54 eapsr_nzcvq = 2050,
55 xpsr = 2051,
56 xpsr_nzcvq = 2051,
57 ipsr = 2053,
58 epsr = 2054,
59 iepsr = 2055,
60 msp = 2056,
61 psp = 2057,
62 msplim = 2058,
63 psplim = 2059,
64 primask = 2064,
65 basepri = 2065,
66 basepri_max = 2066,
67 faultmask = 2067,
68 control = 2068,
69 msp_ns = 2184,
70 psp_ns = 2185,
71 msplim_ns = 2186,
72 psplim_ns = 2187,
73 primask_ns = 2192,
74 basepri_ns = 2193,
75 faultmask_ns = 2195,
76 control_ns = 2196,
77 sp_ns = 2200,
78 pac_key_p_0 = 2080,
79 pac_key_p_1 = 2081,
80 pac_key_p_2 = 2082,
81 pac_key_p_3 = 2083,
82 pac_key_u_0 = 2084,
83 pac_key_u_1 = 2085,
84 pac_key_u_2 = 2086,
85 pac_key_u_3 = 2087,
86 pac_key_p_0_ns = 2208,
87 pac_key_p_1_ns = 2209,
88 pac_key_p_2_ns = 2210,
89 pac_key_p_3_ns = 2211,
90 pac_key_u_0_ns = 2212,
91 pac_key_u_1_ns = 2213,
92 pac_key_u_2_ns = 2214,
93 pac_key_u_3_ns = 2215,
94};
95#endif
96
97#ifdef GET_BANKEDREG_DECL
98const BankedReg *lookupBankedRegByName(StringRef Name);
99const BankedReg *lookupBankedRegByEncoding(uint8_t Encoding);
100#endif
101
102#ifdef GET_BANKEDREG_IMPL
103constexpr BankedReg BankedRegsList[] = {
104 { "elr_hyp", 0x1E }, // 0
105 { "lr_abt", 0x14 }, // 1
106 { "lr_fiq", 0xE }, // 2
107 { "lr_irq", 0x10 }, // 3
108 { "lr_mon", 0x1C }, // 4
109 { "lr_svc", 0x12 }, // 5
110 { "lr_und", 0x16 }, // 6
111 { "lr_usr", 0x6 }, // 7
112 { "r10_fiq", 0xA }, // 8
113 { "r10_usr", 0x2 }, // 9
114 { "r11_fiq", 0xB }, // 10
115 { "r11_usr", 0x3 }, // 11
116 { "r12_fiq", 0xC }, // 12
117 { "r12_usr", 0x4 }, // 13
118 { "r8_fiq", 0x8 }, // 14
119 { "r8_usr", 0x0 }, // 15
120 { "r9_fiq", 0x9 }, // 16
121 { "r9_usr", 0x1 }, // 17
122 { "spsr_abt", 0x34 }, // 18
123 { "spsr_fiq", 0x2E }, // 19
124 { "spsr_hyp", 0x3E }, // 20
125 { "spsr_irq", 0x30 }, // 21
126 { "spsr_mon", 0x3C }, // 22
127 { "spsr_svc", 0x32 }, // 23
128 { "spsr_und", 0x36 }, // 24
129 { "sp_abt", 0x15 }, // 25
130 { "sp_fiq", 0xD }, // 26
131 { "sp_hyp", 0x1F }, // 27
132 { "sp_irq", 0x11 }, // 28
133 { "sp_mon", 0x1D }, // 29
134 { "sp_svc", 0x13 }, // 30
135 { "sp_und", 0x17 }, // 31
136 { "sp_usr", 0x5 }, // 32
137 };
138
139const BankedReg *lookupBankedRegByName(StringRef Name) {
140 struct IndexType {
141 const char * Name;
142 unsigned _index;
143 };
144 static const struct IndexType Index[] = {
145 { "ELR_HYP", 0 },
146 { "LR_ABT", 1 },
147 { "LR_FIQ", 2 },
148 { "LR_IRQ", 3 },
149 { "LR_MON", 4 },
150 { "LR_SVC", 5 },
151 { "LR_UND", 6 },
152 { "LR_USR", 7 },
153 { "R10_FIQ", 8 },
154 { "R10_USR", 9 },
155 { "R11_FIQ", 10 },
156 { "R11_USR", 11 },
157 { "R12_FIQ", 12 },
158 { "R12_USR", 13 },
159 { "R8_FIQ", 14 },
160 { "R8_USR", 15 },
161 { "R9_FIQ", 16 },
162 { "R9_USR", 17 },
163 { "SPSR_ABT", 18 },
164 { "SPSR_FIQ", 19 },
165 { "SPSR_HYP", 20 },
166 { "SPSR_IRQ", 21 },
167 { "SPSR_MON", 22 },
168 { "SPSR_SVC", 23 },
169 { "SPSR_UND", 24 },
170 { "SP_ABT", 25 },
171 { "SP_FIQ", 26 },
172 { "SP_HYP", 27 },
173 { "SP_IRQ", 28 },
174 { "SP_MON", 29 },
175 { "SP_SVC", 30 },
176 { "SP_UND", 31 },
177 { "SP_USR", 32 },
178 };
179
180 struct KeyType {
181 std::string Name;
182 };
183 KeyType Key = {Name.upper()};
184 struct Comp {
185 bool operator()(const IndexType &LHS, const KeyType &RHS) const {
186 int CmpName = StringRef(LHS.Name).compare(RHS.Name);
187 if (CmpName < 0) return true;
188 if (CmpName > 0) return false;
189 return false;
190 }
191 };
192 auto Table = ArrayRef(Index);
193 auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp());
194 if (Idx == Table.end() ||
195 Key.Name != Idx->Name)
196 return nullptr;
197
198 return &BankedRegsList[Idx->_index];
199}
200
201const BankedReg *lookupBankedRegByEncoding(uint8_t Encoding) {
202 struct IndexType {
203 uint8_t Encoding;
204 unsigned _index;
205 };
206 static const struct IndexType Index[] = {
207 { 0x0, 15 },
208 { 0x1, 17 },
209 { 0x2, 9 },
210 { 0x3, 11 },
211 { 0x4, 13 },
212 { 0x5, 32 },
213 { 0x6, 7 },
214 { 0x8, 14 },
215 { 0x9, 16 },
216 { 0xA, 8 },
217 { 0xB, 10 },
218 { 0xC, 12 },
219 { 0xD, 26 },
220 { 0xE, 2 },
221 { 0x10, 3 },
222 { 0x11, 28 },
223 { 0x12, 5 },
224 { 0x13, 30 },
225 { 0x14, 1 },
226 { 0x15, 25 },
227 { 0x16, 6 },
228 { 0x17, 31 },
229 { 0x1C, 4 },
230 { 0x1D, 29 },
231 { 0x1E, 0 },
232 { 0x1F, 27 },
233 { 0x2E, 19 },
234 { 0x30, 21 },
235 { 0x32, 23 },
236 { 0x34, 18 },
237 { 0x36, 24 },
238 { 0x3C, 22 },
239 { 0x3E, 20 },
240 };
241
242 struct KeyType {
243 uint8_t Encoding;
244 };
245 KeyType Key = {Encoding};
246 struct Comp {
247 bool operator()(const IndexType &LHS, const KeyType &RHS) const {
248 if (LHS.Encoding < RHS.Encoding)
249 return true;
250 if (LHS.Encoding > RHS.Encoding)
251 return false;
252 return false;
253 }
254 };
255 auto Table = ArrayRef(Index);
256 auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp());
257 if (Idx == Table.end() ||
258 Key.Encoding != Idx->Encoding)
259 return nullptr;
260
261 return &BankedRegsList[Idx->_index];
262}
263#endif
264
265#ifdef GET_MCLASSSYSREG_DECL
266const MClassSysReg *lookupMClassSysRegByName(StringRef Name);
267const MClassSysReg *lookupMClassSysRegByM1Encoding12(uint16_t M1Encoding12);
268const MClassSysReg *lookupMClassSysRegByM2M3Encoding8(uint16_t M2M3Encoding8);
269const MClassSysReg *lookupMClassSysRegByEncoding(uint16_t Encoding);
270#endif
271
272#ifdef GET_MCLASSSYSREG_IMPL
273constexpr MClassSysReg MClassSysRegsList[] = {
274 { "apsr", 0x800, 0x100, 0x800, {} }, // 0
275 { "apsr_g", 0x400, 0x0, 0x400, {ARM::FeatureDSP} }, // 1
276 { "apsr_nzcvq", 0x1800, 0x200, 0x800, {} }, // 2
277 { "apsr_nzcvqg", 0xC00, 0x300, 0xC00, {ARM::FeatureDSP} }, // 3
278 { "basepri", 0x811, 0x111, 0x811, {ARM::HasV7Ops} }, // 4
279 { "basepri_max", 0x812, 0x112, 0x812, {ARM::HasV7Ops} }, // 5
280 { "basepri_ns", 0x891, 0x191, 0x891, {ARM::Feature8MSecExt, ARM::HasV7Ops} }, // 6
281 { "control", 0x814, 0x114, 0x814, {} }, // 7
282 { "control_ns", 0x894, 0x194, 0x894, {ARM::Feature8MSecExt} }, // 8
283 { "eapsr", 0x802, 0x102, 0x802, {} }, // 9
284 { "eapsr_g", 0x402, 0x2, 0x402, {ARM::FeatureDSP} }, // 10
285 { "eapsr_nzcvq", 0x1802, 0x202, 0x802, {} }, // 11
286 { "eapsr_nzcvqg", 0xC02, 0x302, 0xC02, {ARM::FeatureDSP} }, // 12
287 { "epsr", 0x806, 0x106, 0x806, {} }, // 13
288 { "faultmask", 0x813, 0x113, 0x813, {ARM::HasV7Ops} }, // 14
289 { "faultmask_ns", 0x893, 0x193, 0x893, {ARM::Feature8MSecExt, ARM::HasV7Ops} }, // 15
290 { "iapsr", 0x801, 0x101, 0x801, {} }, // 16
291 { "iapsr_g", 0x401, 0x1, 0x401, {ARM::FeatureDSP} }, // 17
292 { "iapsr_nzcvq", 0x1801, 0x201, 0x801, {} }, // 18
293 { "iapsr_nzcvqg", 0xC01, 0x301, 0xC01, {ARM::FeatureDSP} }, // 19
294 { "iepsr", 0x807, 0x107, 0x807, {} }, // 20
295 { "ipsr", 0x805, 0x105, 0x805, {} }, // 21
296 { "msp", 0x808, 0x108, 0x808, {} }, // 22
297 { "msplim", 0x80A, 0x10A, 0x80A, {ARM::HasV8MBaselineOps} }, // 23
298 { "msplim_ns", 0x88A, 0x18A, 0x88A, {ARM::Feature8MSecExt, ARM::HasV8MBaselineOps} }, // 24
299 { "msp_ns", 0x888, 0x188, 0x888, {ARM::Feature8MSecExt} }, // 25
300 { "pac_key_p_0", 0x820, 0x120, 0x820, {ARM::FeaturePACBTI} }, // 26
301 { "pac_key_p_0_ns", 0x8A0, 0x1A0, 0x8A0, {ARM::FeaturePACBTI} }, // 27
302 { "pac_key_p_1", 0x821, 0x121, 0x821, {ARM::FeaturePACBTI} }, // 28
303 { "pac_key_p_1_ns", 0x8A1, 0x1A1, 0x8A1, {ARM::FeaturePACBTI} }, // 29
304 { "pac_key_p_2", 0x822, 0x122, 0x822, {ARM::FeaturePACBTI} }, // 30
305 { "pac_key_p_2_ns", 0x8A2, 0x1A2, 0x8A2, {ARM::FeaturePACBTI} }, // 31
306 { "pac_key_p_3", 0x823, 0x123, 0x823, {ARM::FeaturePACBTI} }, // 32
307 { "pac_key_p_3_ns", 0x8A3, 0x1A3, 0x8A3, {ARM::FeaturePACBTI} }, // 33
308 { "pac_key_u_0", 0x824, 0x124, 0x824, {ARM::FeaturePACBTI} }, // 34
309 { "pac_key_u_0_ns", 0x8A4, 0x1A4, 0x8A4, {ARM::FeaturePACBTI} }, // 35
310 { "pac_key_u_1", 0x825, 0x125, 0x825, {ARM::FeaturePACBTI} }, // 36
311 { "pac_key_u_1_ns", 0x8A5, 0x1A5, 0x8A5, {ARM::FeaturePACBTI} }, // 37
312 { "pac_key_u_2", 0x826, 0x126, 0x826, {ARM::FeaturePACBTI} }, // 38
313 { "pac_key_u_2_ns", 0x8A6, 0x1A6, 0x8A6, {ARM::FeaturePACBTI} }, // 39
314 { "pac_key_u_3", 0x827, 0x127, 0x827, {ARM::FeaturePACBTI} }, // 40
315 { "pac_key_u_3_ns", 0x8A7, 0x1A7, 0x8A7, {ARM::FeaturePACBTI} }, // 41
316 { "primask", 0x810, 0x110, 0x810, {} }, // 42
317 { "primask_ns", 0x890, 0x190, 0x890, {} }, // 43
318 { "psp", 0x809, 0x109, 0x809, {} }, // 44
319 { "psplim", 0x80B, 0x10B, 0x80B, {ARM::HasV8MBaselineOps} }, // 45
320 { "psplim_ns", 0x88B, 0x18B, 0x88B, {ARM::Feature8MSecExt, ARM::HasV8MBaselineOps} }, // 46
321 { "psp_ns", 0x889, 0x189, 0x889, {ARM::Feature8MSecExt} }, // 47
322 { "sp_ns", 0x898, 0x198, 0x898, {ARM::Feature8MSecExt} }, // 48
323 { "xpsr", 0x803, 0x103, 0x803, {} }, // 49
324 { "xpsr_g", 0x403, 0x3, 0x403, {ARM::FeatureDSP} }, // 50
325 { "xpsr_nzcvq", 0x1803, 0x203, 0x803, {} }, // 51
326 { "xpsr_nzcvqg", 0xC03, 0x303, 0xC03, {ARM::FeatureDSP} }, // 52
327 };
328
329const MClassSysReg *lookupMClassSysRegByName(StringRef Name) {
330 struct IndexType {
331 const char * Name;
332 unsigned _index;
333 };
334 static const struct IndexType Index[] = {
335 { "APSR", 0 },
336 { "APSR_G", 1 },
337 { "APSR_NZCVQ", 2 },
338 { "APSR_NZCVQG", 3 },
339 { "BASEPRI", 4 },
340 { "BASEPRI_MAX", 5 },
341 { "BASEPRI_NS", 6 },
342 { "CONTROL", 7 },
343 { "CONTROL_NS", 8 },
344 { "EAPSR", 9 },
345 { "EAPSR_G", 10 },
346 { "EAPSR_NZCVQ", 11 },
347 { "EAPSR_NZCVQG", 12 },
348 { "EPSR", 13 },
349 { "FAULTMASK", 14 },
350 { "FAULTMASK_NS", 15 },
351 { "IAPSR", 16 },
352 { "IAPSR_G", 17 },
353 { "IAPSR_NZCVQ", 18 },
354 { "IAPSR_NZCVQG", 19 },
355 { "IEPSR", 20 },
356 { "IPSR", 21 },
357 { "MSP", 22 },
358 { "MSPLIM", 23 },
359 { "MSPLIM_NS", 24 },
360 { "MSP_NS", 25 },
361 { "PAC_KEY_P_0", 26 },
362 { "PAC_KEY_P_0_NS", 27 },
363 { "PAC_KEY_P_1", 28 },
364 { "PAC_KEY_P_1_NS", 29 },
365 { "PAC_KEY_P_2", 30 },
366 { "PAC_KEY_P_2_NS", 31 },
367 { "PAC_KEY_P_3", 32 },
368 { "PAC_KEY_P_3_NS", 33 },
369 { "PAC_KEY_U_0", 34 },
370 { "PAC_KEY_U_0_NS", 35 },
371 { "PAC_KEY_U_1", 36 },
372 { "PAC_KEY_U_1_NS", 37 },
373 { "PAC_KEY_U_2", 38 },
374 { "PAC_KEY_U_2_NS", 39 },
375 { "PAC_KEY_U_3", 40 },
376 { "PAC_KEY_U_3_NS", 41 },
377 { "PRIMASK", 42 },
378 { "PRIMASK_NS", 43 },
379 { "PSP", 44 },
380 { "PSPLIM", 45 },
381 { "PSPLIM_NS", 46 },
382 { "PSP_NS", 47 },
383 { "SP_NS", 48 },
384 { "XPSR", 49 },
385 { "XPSR_G", 50 },
386 { "XPSR_NZCVQ", 51 },
387 { "XPSR_NZCVQG", 52 },
388 };
389
390 struct KeyType {
391 std::string Name;
392 };
393 KeyType Key = {Name.upper()};
394 struct Comp {
395 bool operator()(const IndexType &LHS, const KeyType &RHS) const {
396 int CmpName = StringRef(LHS.Name).compare(RHS.Name);
397 if (CmpName < 0) return true;
398 if (CmpName > 0) return false;
399 return false;
400 }
401 };
402 auto Table = ArrayRef(Index);
403 auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp());
404 if (Idx == Table.end() ||
405 Key.Name != Idx->Name)
406 return nullptr;
407
408 return &MClassSysRegsList[Idx->_index];
409}
410
411const MClassSysReg *lookupMClassSysRegByM1Encoding12(uint16_t M1Encoding12) {
412 struct IndexType {
413 uint16_t M1Encoding12;
414 unsigned _index;
415 };
416 static const struct IndexType Index[] = {
417 { 0x400, 1 },
418 { 0x401, 17 },
419 { 0x402, 10 },
420 { 0x403, 50 },
421 { 0x800, 0 },
422 { 0x801, 16 },
423 { 0x802, 9 },
424 { 0x803, 49 },
425 { 0x805, 21 },
426 { 0x806, 13 },
427 { 0x807, 20 },
428 { 0x808, 22 },
429 { 0x809, 44 },
430 { 0x80A, 23 },
431 { 0x80B, 45 },
432 { 0x810, 42 },
433 { 0x811, 4 },
434 { 0x812, 5 },
435 { 0x813, 14 },
436 { 0x814, 7 },
437 { 0x820, 26 },
438 { 0x821, 28 },
439 { 0x822, 30 },
440 { 0x823, 32 },
441 { 0x824, 34 },
442 { 0x825, 36 },
443 { 0x826, 38 },
444 { 0x827, 40 },
445 { 0x888, 25 },
446 { 0x889, 47 },
447 { 0x88A, 24 },
448 { 0x88B, 46 },
449 { 0x890, 43 },
450 { 0x891, 6 },
451 { 0x893, 15 },
452 { 0x894, 8 },
453 { 0x898, 48 },
454 { 0x8A0, 27 },
455 { 0x8A1, 29 },
456 { 0x8A2, 31 },
457 { 0x8A3, 33 },
458 { 0x8A4, 35 },
459 { 0x8A5, 37 },
460 { 0x8A6, 39 },
461 { 0x8A7, 41 },
462 { 0xC00, 3 },
463 { 0xC01, 19 },
464 { 0xC02, 12 },
465 { 0xC03, 52 },
466 { 0x1800, 2 },
467 { 0x1801, 18 },
468 { 0x1802, 11 },
469 { 0x1803, 51 },
470 };
471
472 struct KeyType {
473 uint16_t M1Encoding12;
474 };
475 KeyType Key = {M1Encoding12};
476 struct Comp {
477 bool operator()(const IndexType &LHS, const KeyType &RHS) const {
478 if (LHS.M1Encoding12 < RHS.M1Encoding12)
479 return true;
480 if (LHS.M1Encoding12 > RHS.M1Encoding12)
481 return false;
482 return false;
483 }
484 };
485 auto Table = ArrayRef(Index);
486 auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp());
487 if (Idx == Table.end() ||
488 Key.M1Encoding12 != Idx->M1Encoding12)
489 return nullptr;
490
491 return &MClassSysRegsList[Idx->_index];
492}
493
494const MClassSysReg *lookupMClassSysRegByM2M3Encoding8(uint16_t M2M3Encoding8) {
495 struct IndexType {
496 uint16_t M2M3Encoding8;
497 unsigned _index;
498 };
499 static const struct IndexType Index[] = {
500 { 0x0, 1 },
501 { 0x1, 17 },
502 { 0x2, 10 },
503 { 0x3, 50 },
504 { 0x100, 0 },
505 { 0x101, 16 },
506 { 0x102, 9 },
507 { 0x103, 49 },
508 { 0x105, 21 },
509 { 0x106, 13 },
510 { 0x107, 20 },
511 { 0x108, 22 },
512 { 0x109, 44 },
513 { 0x10A, 23 },
514 { 0x10B, 45 },
515 { 0x110, 42 },
516 { 0x111, 4 },
517 { 0x112, 5 },
518 { 0x113, 14 },
519 { 0x114, 7 },
520 { 0x120, 26 },
521 { 0x121, 28 },
522 { 0x122, 30 },
523 { 0x123, 32 },
524 { 0x124, 34 },
525 { 0x125, 36 },
526 { 0x126, 38 },
527 { 0x127, 40 },
528 { 0x188, 25 },
529 { 0x189, 47 },
530 { 0x18A, 24 },
531 { 0x18B, 46 },
532 { 0x190, 43 },
533 { 0x191, 6 },
534 { 0x193, 15 },
535 { 0x194, 8 },
536 { 0x198, 48 },
537 { 0x1A0, 27 },
538 { 0x1A1, 29 },
539 { 0x1A2, 31 },
540 { 0x1A3, 33 },
541 { 0x1A4, 35 },
542 { 0x1A5, 37 },
543 { 0x1A6, 39 },
544 { 0x1A7, 41 },
545 { 0x200, 2 },
546 { 0x201, 18 },
547 { 0x202, 11 },
548 { 0x203, 51 },
549 { 0x300, 3 },
550 { 0x301, 19 },
551 { 0x302, 12 },
552 { 0x303, 52 },
553 };
554
555 struct KeyType {
556 uint16_t M2M3Encoding8;
557 };
558 KeyType Key = {M2M3Encoding8};
559 struct Comp {
560 bool operator()(const IndexType &LHS, const KeyType &RHS) const {
561 if (LHS.M2M3Encoding8 < RHS.M2M3Encoding8)
562 return true;
563 if (LHS.M2M3Encoding8 > RHS.M2M3Encoding8)
564 return false;
565 return false;
566 }
567 };
568 auto Table = ArrayRef(Index);
569 auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp());
570 if (Idx == Table.end() ||
571 Key.M2M3Encoding8 != Idx->M2M3Encoding8)
572 return nullptr;
573
574 return &MClassSysRegsList[Idx->_index];
575}
576
577const MClassSysReg *lookupMClassSysRegByEncoding(uint16_t Encoding) {
578 struct IndexType {
579 uint16_t Encoding;
580 unsigned _index;
581 };
582 static const struct IndexType Index[] = {
583 { 0x400, 1 },
584 { 0x401, 17 },
585 { 0x402, 10 },
586 { 0x403, 50 },
587 { 0x800, 0 },
588 { 0x800, 2 },
589 { 0x801, 16 },
590 { 0x801, 18 },
591 { 0x802, 9 },
592 { 0x802, 11 },
593 { 0x803, 49 },
594 { 0x803, 51 },
595 { 0x805, 21 },
596 { 0x806, 13 },
597 { 0x807, 20 },
598 { 0x808, 22 },
599 { 0x809, 44 },
600 { 0x80A, 23 },
601 { 0x80B, 45 },
602 { 0x810, 42 },
603 { 0x811, 4 },
604 { 0x812, 5 },
605 { 0x813, 14 },
606 { 0x814, 7 },
607 { 0x820, 26 },
608 { 0x821, 28 },
609 { 0x822, 30 },
610 { 0x823, 32 },
611 { 0x824, 34 },
612 { 0x825, 36 },
613 { 0x826, 38 },
614 { 0x827, 40 },
615 { 0x888, 25 },
616 { 0x889, 47 },
617 { 0x88A, 24 },
618 { 0x88B, 46 },
619 { 0x890, 43 },
620 { 0x891, 6 },
621 { 0x893, 15 },
622 { 0x894, 8 },
623 { 0x898, 48 },
624 { 0x8A0, 27 },
625 { 0x8A1, 29 },
626 { 0x8A2, 31 },
627 { 0x8A3, 33 },
628 { 0x8A4, 35 },
629 { 0x8A5, 37 },
630 { 0x8A6, 39 },
631 { 0x8A7, 41 },
632 { 0xC00, 3 },
633 { 0xC01, 19 },
634 { 0xC02, 12 },
635 { 0xC03, 52 },
636 };
637
638 struct KeyType {
639 uint16_t Encoding;
640 };
641 KeyType Key = {Encoding};
642 struct Comp {
643 bool operator()(const IndexType &LHS, const KeyType &RHS) const {
644 if (LHS.Encoding < RHS.Encoding)
645 return true;
646 if (LHS.Encoding > RHS.Encoding)
647 return false;
648 return false;
649 }
650 };
651 auto Table = ArrayRef(Index);
652 auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, Comp());
653 if (Idx == Table.end() ||
654 Key.Encoding != Idx->Encoding)
655 return nullptr;
656
657 return &MClassSysRegsList[Idx->_index];
658}
659#endif
660
661#undef GET_BANKEDREG_DECL
662#undef GET_BANKEDREG_IMPL
663#undef GET_MCLASSSYSREG_DECL
664#undef GET_MCLASSSYSREG_IMPL
665