Line data Source code
1 : #ifdef GET_BANKEDREG_DECL
2 : enum 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
40 : enum 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 : };
79 : #endif
80 :
81 : #ifdef GET_BANKEDREG_DECL
82 : const BankedReg *lookupBankedRegByName(StringRef Name);
83 : const BankedReg *lookupBankedRegByEncoding(uint8_t Encoding);
84 : #endif
85 :
86 : #ifdef GET_BANKEDREG_IMPL
87 : const BankedReg BankedRegsList[] = {
88 : { "r8_usr", 0x0 }, // 0
89 : { "r9_usr", 0x1 }, // 1
90 : { "r10_usr", 0x2 }, // 2
91 : { "r11_usr", 0x3 }, // 3
92 : { "r12_usr", 0x4 }, // 4
93 : { "sp_usr", 0x5 }, // 5
94 : { "lr_usr", 0x6 }, // 6
95 : { "r8_fiq", 0x8 }, // 7
96 : { "r9_fiq", 0x9 }, // 8
97 : { "r10_fiq", 0xA }, // 9
98 : { "r11_fiq", 0xB }, // 10
99 : { "r12_fiq", 0xC }, // 11
100 : { "sp_fiq", 0xD }, // 12
101 : { "lr_fiq", 0xE }, // 13
102 : { "lr_irq", 0x10 }, // 14
103 : { "sp_irq", 0x11 }, // 15
104 : { "lr_svc", 0x12 }, // 16
105 : { "sp_svc", 0x13 }, // 17
106 : { "lr_abt", 0x14 }, // 18
107 : { "sp_abt", 0x15 }, // 19
108 : { "lr_und", 0x16 }, // 20
109 : { "sp_und", 0x17 }, // 21
110 : { "lr_mon", 0x1C }, // 22
111 : { "sp_mon", 0x1D }, // 23
112 : { "elr_hyp", 0x1E }, // 24
113 : { "sp_hyp", 0x1F }, // 25
114 : { "spsr_fiq", 0x2E }, // 26
115 : { "spsr_irq", 0x30 }, // 27
116 : { "spsr_svc", 0x32 }, // 28
117 : { "spsr_abt", 0x34 }, // 29
118 : { "spsr_und", 0x36 }, // 30
119 : { "spsr_mon", 0x3C }, // 31
120 : { "spsr_hyp", 0x3E }, // 32
121 : };
122 :
123 357 : const BankedReg *lookupBankedRegByName(StringRef Name) {
124 : struct IndexType {
125 : const char * Name;
126 : unsigned _index;
127 : };
128 : static const struct IndexType Index[] = {
129 : { "ELR_HYP", 24 },
130 : { "LR_ABT", 18 },
131 : { "LR_FIQ", 13 },
132 : { "LR_IRQ", 14 },
133 : { "LR_MON", 22 },
134 : { "LR_SVC", 16 },
135 : { "LR_UND", 20 },
136 : { "LR_USR", 6 },
137 : { "R10_FIQ", 9 },
138 : { "R10_USR", 2 },
139 : { "R11_FIQ", 10 },
140 : { "R11_USR", 3 },
141 : { "R12_FIQ", 11 },
142 : { "R12_USR", 4 },
143 : { "R8_FIQ", 7 },
144 : { "R8_USR", 0 },
145 : { "R9_FIQ", 8 },
146 : { "R9_USR", 1 },
147 : { "SPSR_ABT", 29 },
148 : { "SPSR_FIQ", 26 },
149 : { "SPSR_HYP", 32 },
150 : { "SPSR_IRQ", 27 },
151 : { "SPSR_MON", 31 },
152 : { "SPSR_SVC", 28 },
153 : { "SPSR_UND", 30 },
154 : { "SP_ABT", 19 },
155 : { "SP_FIQ", 12 },
156 : { "SP_HYP", 25 },
157 : { "SP_IRQ", 15 },
158 : { "SP_MON", 23 },
159 : { "SP_SVC", 17 },
160 : { "SP_UND", 21 },
161 : { "SP_USR", 5 },
162 : };
163 :
164 : struct KeyType {
165 : std::string Name;
166 : };
167 357 : KeyType Key = { Name.upper() };
168 : auto Table = makeArrayRef(Index);
169 : auto Idx = std::lower_bound(Table.begin(), Table.end(), Key,
170 : [](const IndexType &LHS, const KeyType &RHS) {
171 : int CmpName = StringRef(LHS.Name).compare(RHS.Name);
172 : if (CmpName < 0) return true;
173 : if (CmpName > 0) return false;
174 : return false;
175 : });
176 :
177 699 : if (Idx == Table.end() ||
178 342 : Key.Name != Idx->Name)
179 225 : return nullptr;
180 132 : return &BankedRegsList[Idx->_index];
181 : }
182 :
183 402 : const BankedReg *lookupBankedRegByEncoding(uint8_t Encoding) {
184 : struct IndexType {
185 : uint8_t Encoding;
186 : unsigned _index;
187 : };
188 : static const struct IndexType Index[] = {
189 : { 0x0, 0 },
190 : { 0x1, 1 },
191 : { 0x2, 2 },
192 : { 0x3, 3 },
193 : { 0x4, 4 },
194 : { 0x5, 5 },
195 : { 0x6, 6 },
196 : { 0x8, 7 },
197 : { 0x9, 8 },
198 : { 0xA, 9 },
199 : { 0xB, 10 },
200 : { 0xC, 11 },
201 : { 0xD, 12 },
202 : { 0xE, 13 },
203 : { 0x10, 14 },
204 : { 0x11, 15 },
205 : { 0x12, 16 },
206 : { 0x13, 17 },
207 : { 0x14, 18 },
208 : { 0x15, 19 },
209 : { 0x16, 20 },
210 : { 0x17, 21 },
211 : { 0x1C, 22 },
212 : { 0x1D, 23 },
213 : { 0x1E, 24 },
214 : { 0x1F, 25 },
215 : { 0x2E, 26 },
216 : { 0x30, 27 },
217 : { 0x32, 28 },
218 : { 0x34, 29 },
219 : { 0x36, 30 },
220 : { 0x3C, 31 },
221 : { 0x3E, 32 },
222 : };
223 :
224 : struct KeyType {
225 : uint8_t Encoding;
226 : };
227 : KeyType Key = { Encoding };
228 : auto Table = makeArrayRef(Index);
229 : auto Idx = std::lower_bound(Table.begin(), Table.end(), Key,
230 : [](const IndexType &LHS, const KeyType &RHS) {
231 2058 : if (LHS.Encoding < RHS.Encoding)
232 : return true;
233 : if (LHS.Encoding > RHS.Encoding)
234 : return false;
235 : return false;
236 : });
237 :
238 402 : if (Idx == Table.end() ||
239 396 : Key.Encoding != Idx->Encoding)
240 : return nullptr;
241 396 : return &BankedRegsList[Idx->_index];
242 : }
243 : #endif
244 :
245 : #ifdef GET_MCLASSSYSREG_DECL
246 : const MClassSysReg *lookupMClassSysRegByName(StringRef Name);
247 : const MClassSysReg *lookupMClassSysRegByM1Encoding12(uint16_t M1Encoding12);
248 : const MClassSysReg *lookupMClassSysRegByM2M3Encoding8(uint16_t M2M3Encoding8);
249 : const MClassSysReg *lookupMClassSysRegByEncoding(uint16_t Encoding);
250 : #endif
251 :
252 : #ifdef GET_MCLASSSYSREG_IMPL
253 : const MClassSysReg MClassSysRegsList[] = {
254 : { "apsr_g", 0x400, 0x0, 0x400, {ARM::FeatureDSP} }, // 0
255 : { "apsr_nzcvqg", 0xC00, 0x300, 0xC00, {ARM::FeatureDSP} }, // 1
256 : { "iapsr_g", 0x401, 0x1, 0x401, {ARM::FeatureDSP} }, // 2
257 : { "iapsr_nzcvqg", 0xC01, 0x301, 0xC01, {ARM::FeatureDSP} }, // 3
258 : { "eapsr_g", 0x402, 0x2, 0x402, {ARM::FeatureDSP} }, // 4
259 : { "eapsr_nzcvqg", 0xC02, 0x302, 0xC02, {ARM::FeatureDSP} }, // 5
260 : { "xpsr_g", 0x403, 0x3, 0x403, {ARM::FeatureDSP} }, // 6
261 : { "xpsr_nzcvqg", 0xC03, 0x303, 0xC03, {ARM::FeatureDSP} }, // 7
262 : { "apsr", 0x800, 0x100, 0x800, {} }, // 8
263 : { "apsr_nzcvq", 0x1800, 0x200, 0x800, {} }, // 9
264 : { "iapsr", 0x801, 0x101, 0x801, {} }, // 10
265 : { "iapsr_nzcvq", 0x1801, 0x201, 0x801, {} }, // 11
266 : { "eapsr", 0x802, 0x102, 0x802, {} }, // 12
267 : { "eapsr_nzcvq", 0x1802, 0x202, 0x802, {} }, // 13
268 : { "xpsr", 0x803, 0x103, 0x803, {} }, // 14
269 : { "xpsr_nzcvq", 0x1803, 0x203, 0x803, {} }, // 15
270 : { "ipsr", 0x805, 0x105, 0x805, {} }, // 16
271 : { "epsr", 0x806, 0x106, 0x806, {} }, // 17
272 : { "iepsr", 0x807, 0x107, 0x807, {} }, // 18
273 : { "msp", 0x808, 0x108, 0x808, {} }, // 19
274 : { "psp", 0x809, 0x109, 0x809, {} }, // 20
275 : { "msplim", 0x80A, 0x10A, 0x80A, {ARM::HasV8MBaselineOps} }, // 21
276 : { "psplim", 0x80B, 0x10B, 0x80B, {ARM::HasV8MBaselineOps} }, // 22
277 : { "primask", 0x810, 0x110, 0x810, {} }, // 23
278 : { "basepri", 0x811, 0x111, 0x811, {ARM::HasV7Ops} }, // 24
279 : { "basepri_max", 0x812, 0x112, 0x812, {ARM::HasV7Ops} }, // 25
280 : { "faultmask", 0x813, 0x113, 0x813, {ARM::HasV7Ops} }, // 26
281 : { "control", 0x814, 0x114, 0x814, {} }, // 27
282 : { "msp_ns", 0x888, 0x188, 0x888, {ARM::Feature8MSecExt} }, // 28
283 : { "psp_ns", 0x889, 0x189, 0x889, {ARM::Feature8MSecExt} }, // 29
284 : { "msplim_ns", 0x88A, 0x18A, 0x88A, {ARM::Feature8MSecExt, ARM::HasV8MBaselineOps} }, // 30
285 : { "psplim_ns", 0x88B, 0x18B, 0x88B, {ARM::Feature8MSecExt, ARM::HasV8MBaselineOps} }, // 31
286 : { "primask_ns", 0x890, 0x190, 0x890, {} }, // 32
287 : { "basepri_ns", 0x891, 0x191, 0x891, {ARM::Feature8MSecExt, ARM::HasV7Ops} }, // 33
288 : { "faultmask_ns", 0x893, 0x193, 0x893, {ARM::Feature8MSecExt, ARM::HasV7Ops} }, // 34
289 : { "control_ns", 0x894, 0x194, 0x894, {ARM::Feature8MSecExt} }, // 35
290 : { "sp_ns", 0x898, 0x198, 0x898, {ARM::Feature8MSecExt} }, // 36
291 : };
292 :
293 297 : const MClassSysReg *lookupMClassSysRegByName(StringRef Name) {
294 : struct IndexType {
295 : const char * Name;
296 : unsigned _index;
297 : };
298 : static const struct IndexType Index[] = {
299 : { "APSR", 8 },
300 : { "APSR_G", 0 },
301 : { "APSR_NZCVQ", 9 },
302 : { "APSR_NZCVQG", 1 },
303 : { "BASEPRI", 24 },
304 : { "BASEPRI_MAX", 25 },
305 : { "BASEPRI_NS", 33 },
306 : { "CONTROL", 27 },
307 : { "CONTROL_NS", 35 },
308 : { "EAPSR", 12 },
309 : { "EAPSR_G", 4 },
310 : { "EAPSR_NZCVQ", 13 },
311 : { "EAPSR_NZCVQG", 5 },
312 : { "EPSR", 17 },
313 : { "FAULTMASK", 26 },
314 : { "FAULTMASK_NS", 34 },
315 : { "IAPSR", 10 },
316 : { "IAPSR_G", 2 },
317 : { "IAPSR_NZCVQ", 11 },
318 : { "IAPSR_NZCVQG", 3 },
319 : { "IEPSR", 18 },
320 : { "IPSR", 16 },
321 : { "MSP", 19 },
322 : { "MSPLIM", 21 },
323 : { "MSPLIM_NS", 30 },
324 : { "MSP_NS", 28 },
325 : { "PRIMASK", 23 },
326 : { "PRIMASK_NS", 32 },
327 : { "PSP", 20 },
328 : { "PSPLIM", 22 },
329 : { "PSPLIM_NS", 31 },
330 : { "PSP_NS", 29 },
331 : { "SP_NS", 36 },
332 : { "XPSR", 14 },
333 : { "XPSR_G", 6 },
334 : { "XPSR_NZCVQ", 15 },
335 : { "XPSR_NZCVQG", 7 },
336 : };
337 :
338 : struct KeyType {
339 : std::string Name;
340 : };
341 297 : KeyType Key = { Name.upper() };
342 : auto Table = makeArrayRef(Index);
343 : auto Idx = std::lower_bound(Table.begin(), Table.end(), Key,
344 : [](const IndexType &LHS, const KeyType &RHS) {
345 : int CmpName = StringRef(LHS.Name).compare(RHS.Name);
346 : if (CmpName < 0) return true;
347 : if (CmpName > 0) return false;
348 : return false;
349 : });
350 :
351 594 : if (Idx == Table.end() ||
352 297 : Key.Name != Idx->Name)
353 1 : return nullptr;
354 296 : return &MClassSysRegsList[Idx->_index];
355 : }
356 :
357 106 : const MClassSysReg *lookupMClassSysRegByM1Encoding12(uint16_t M1Encoding12) {
358 : struct IndexType {
359 : uint16_t M1Encoding12;
360 : unsigned _index;
361 : };
362 : static const struct IndexType Index[] = {
363 : { 0x400, 0 },
364 : { 0x401, 2 },
365 : { 0x402, 4 },
366 : { 0x403, 6 },
367 : { 0x800, 8 },
368 : { 0x801, 10 },
369 : { 0x802, 12 },
370 : { 0x803, 14 },
371 : { 0x805, 16 },
372 : { 0x806, 17 },
373 : { 0x807, 18 },
374 : { 0x808, 19 },
375 : { 0x809, 20 },
376 : { 0x80A, 21 },
377 : { 0x80B, 22 },
378 : { 0x810, 23 },
379 : { 0x811, 24 },
380 : { 0x812, 25 },
381 : { 0x813, 26 },
382 : { 0x814, 27 },
383 : { 0x888, 28 },
384 : { 0x889, 29 },
385 : { 0x88A, 30 },
386 : { 0x88B, 31 },
387 : { 0x890, 32 },
388 : { 0x891, 33 },
389 : { 0x893, 34 },
390 : { 0x894, 35 },
391 : { 0x898, 36 },
392 : { 0xC00, 1 },
393 : { 0xC01, 3 },
394 : { 0xC02, 5 },
395 : { 0xC03, 7 },
396 : { 0x1800, 9 },
397 : { 0x1801, 11 },
398 : { 0x1802, 13 },
399 : { 0x1803, 15 },
400 : };
401 :
402 : struct KeyType {
403 : uint16_t M1Encoding12;
404 : };
405 : KeyType Key = { M1Encoding12 };
406 : auto Table = makeArrayRef(Index);
407 : auto Idx = std::lower_bound(Table.begin(), Table.end(), Key,
408 : [](const IndexType &LHS, const KeyType &RHS) {
409 573 : if (LHS.M1Encoding12 < RHS.M1Encoding12)
410 : return true;
411 : if (LHS.M1Encoding12 > RHS.M1Encoding12)
412 : return false;
413 : return false;
414 : });
415 :
416 106 : if (Idx == Table.end() ||
417 106 : Key.M1Encoding12 != Idx->M1Encoding12)
418 : return nullptr;
419 102 : return &MClassSysRegsList[Idx->_index];
420 : }
421 :
422 381 : const MClassSysReg *lookupMClassSysRegByM2M3Encoding8(uint16_t M2M3Encoding8) {
423 : struct IndexType {
424 : uint16_t M2M3Encoding8;
425 : unsigned _index;
426 : };
427 : static const struct IndexType Index[] = {
428 : { 0x0, 0 },
429 : { 0x1, 2 },
430 : { 0x2, 4 },
431 : { 0x3, 6 },
432 : { 0x100, 8 },
433 : { 0x101, 10 },
434 : { 0x102, 12 },
435 : { 0x103, 14 },
436 : { 0x105, 16 },
437 : { 0x106, 17 },
438 : { 0x107, 18 },
439 : { 0x108, 19 },
440 : { 0x109, 20 },
441 : { 0x10A, 21 },
442 : { 0x10B, 22 },
443 : { 0x110, 23 },
444 : { 0x111, 24 },
445 : { 0x112, 25 },
446 : { 0x113, 26 },
447 : { 0x114, 27 },
448 : { 0x188, 28 },
449 : { 0x189, 29 },
450 : { 0x18A, 30 },
451 : { 0x18B, 31 },
452 : { 0x190, 32 },
453 : { 0x191, 33 },
454 : { 0x193, 34 },
455 : { 0x194, 35 },
456 : { 0x198, 36 },
457 : { 0x200, 9 },
458 : { 0x201, 11 },
459 : { 0x202, 13 },
460 : { 0x203, 15 },
461 : { 0x300, 1 },
462 : { 0x301, 3 },
463 : { 0x302, 5 },
464 : { 0x303, 7 },
465 : };
466 :
467 : struct KeyType {
468 : uint16_t M2M3Encoding8;
469 : };
470 : KeyType Key = { M2M3Encoding8 };
471 : auto Table = makeArrayRef(Index);
472 : auto Idx = std::lower_bound(Table.begin(), Table.end(), Key,
473 : [](const IndexType &LHS, const KeyType &RHS) {
474 2015 : if (LHS.M2M3Encoding8 < RHS.M2M3Encoding8)
475 : return true;
476 : if (LHS.M2M3Encoding8 > RHS.M2M3Encoding8)
477 : return false;
478 : return false;
479 : });
480 :
481 381 : if (Idx == Table.end() ||
482 381 : Key.M2M3Encoding8 != Idx->M2M3Encoding8)
483 : return nullptr;
484 296 : return &MClassSysRegsList[Idx->_index];
485 : }
486 :
487 0 : const MClassSysReg *lookupMClassSysRegByEncoding(uint16_t Encoding) {
488 : struct IndexType {
489 : uint16_t Encoding;
490 : unsigned _index;
491 : };
492 : static const struct IndexType Index[] = {
493 : { 0x400, 0 },
494 : { 0x401, 2 },
495 : { 0x402, 4 },
496 : { 0x403, 6 },
497 : { 0x800, 8 },
498 : { 0x800, 9 },
499 : { 0x801, 10 },
500 : { 0x801, 11 },
501 : { 0x802, 12 },
502 : { 0x802, 13 },
503 : { 0x803, 14 },
504 : { 0x803, 15 },
505 : { 0x805, 16 },
506 : { 0x806, 17 },
507 : { 0x807, 18 },
508 : { 0x808, 19 },
509 : { 0x809, 20 },
510 : { 0x80A, 21 },
511 : { 0x80B, 22 },
512 : { 0x810, 23 },
513 : { 0x811, 24 },
514 : { 0x812, 25 },
515 : { 0x813, 26 },
516 : { 0x814, 27 },
517 : { 0x888, 28 },
518 : { 0x889, 29 },
519 : { 0x88A, 30 },
520 : { 0x88B, 31 },
521 : { 0x890, 32 },
522 : { 0x891, 33 },
523 : { 0x893, 34 },
524 : { 0x894, 35 },
525 : { 0x898, 36 },
526 : { 0xC00, 1 },
527 : { 0xC01, 3 },
528 : { 0xC02, 5 },
529 : { 0xC03, 7 },
530 : };
531 :
532 : struct KeyType {
533 : uint16_t Encoding;
534 : };
535 : KeyType Key = { Encoding };
536 : auto Table = makeArrayRef(Index);
537 : auto Idx = std::lower_bound(Table.begin(), Table.end(), Key,
538 : [](const IndexType &LHS, const KeyType &RHS) {
539 0 : if (LHS.Encoding < RHS.Encoding)
540 : return true;
541 : if (LHS.Encoding > RHS.Encoding)
542 : return false;
543 : return false;
544 : });
545 :
546 0 : if (Idx == Table.end() ||
547 0 : Key.Encoding != Idx->Encoding)
548 : return nullptr;
549 0 : return &MClassSysRegsList[Idx->_index];
550 : }
551 : #endif
552 :
553 : #undef GET_BANKEDREG_DECL
554 : #undef GET_BANKEDREG_IMPL
555 : #undef GET_MCLASSSYSREG_DECL
556 : #undef GET_MCLASSSYSREG_IMPL
|