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