11 #include "gen_amd64_regalloc_if.h"
12 #include "bearch_amd64_t.h"
14 const arch_register_req_t amd64_class_reg_req_flags = {
15 .cls = &amd64_reg_classes[CLASS_amd64_flags],
18 static const unsigned amd64_limited_flags_eflags[] = { (1U << REG_FLAGS_EFLAGS) };
19 const arch_register_req_t amd64_single_reg_req_flags_eflags = {
20 .cls = &amd64_reg_classes[CLASS_amd64_flags],
21 .limited = amd64_limited_flags_eflags,
24 const arch_register_req_t amd64_class_reg_req_gp = {
25 .cls = &amd64_reg_classes[CLASS_amd64_gp],
28 static const unsigned amd64_limited_gp_rax[] = { (1U << REG_GP_RAX) };
29 const arch_register_req_t amd64_single_reg_req_gp_rax = {
30 .cls = &amd64_reg_classes[CLASS_amd64_gp],
31 .limited = amd64_limited_gp_rax,
34 static const unsigned amd64_limited_gp_rcx[] = { (1U << REG_GP_RCX) };
35 const arch_register_req_t amd64_single_reg_req_gp_rcx = {
36 .cls = &amd64_reg_classes[CLASS_amd64_gp],
37 .limited = amd64_limited_gp_rcx,
40 static const unsigned amd64_limited_gp_rdx[] = { (1U << REG_GP_RDX) };
41 const arch_register_req_t amd64_single_reg_req_gp_rdx = {
42 .cls = &amd64_reg_classes[CLASS_amd64_gp],
43 .limited = amd64_limited_gp_rdx,
46 static const unsigned amd64_limited_gp_rsi[] = { (1U << REG_GP_RSI) };
47 const arch_register_req_t amd64_single_reg_req_gp_rsi = {
48 .cls = &amd64_reg_classes[CLASS_amd64_gp],
49 .limited = amd64_limited_gp_rsi,
52 static const unsigned amd64_limited_gp_rdi[] = { (1U << REG_GP_RDI) };
53 const arch_register_req_t amd64_single_reg_req_gp_rdi = {
54 .cls = &amd64_reg_classes[CLASS_amd64_gp],
55 .limited = amd64_limited_gp_rdi,
58 static const unsigned amd64_limited_gp_rbx[] = { (1U << REG_GP_RBX) };
59 const arch_register_req_t amd64_single_reg_req_gp_rbx = {
60 .cls = &amd64_reg_classes[CLASS_amd64_gp],
61 .limited = amd64_limited_gp_rbx,
64 static const unsigned amd64_limited_gp_rbp[] = { (1U << REG_GP_RBP) };
65 const arch_register_req_t amd64_single_reg_req_gp_rbp = {
66 .cls = &amd64_reg_classes[CLASS_amd64_gp],
67 .limited = amd64_limited_gp_rbp,
70 static const unsigned amd64_limited_gp_rsp[] = { (1U << REG_GP_RSP) };
71 const arch_register_req_t amd64_single_reg_req_gp_rsp = {
72 .cls = &amd64_reg_classes[CLASS_amd64_gp],
73 .limited = amd64_limited_gp_rsp,
76 static const unsigned amd64_limited_gp_r8[] = { (1U << REG_GP_R8) };
77 const arch_register_req_t amd64_single_reg_req_gp_r8 = {
78 .cls = &amd64_reg_classes[CLASS_amd64_gp],
79 .limited = amd64_limited_gp_r8,
82 static const unsigned amd64_limited_gp_r9[] = { (1U << REG_GP_R9) };
83 const arch_register_req_t amd64_single_reg_req_gp_r9 = {
84 .cls = &amd64_reg_classes[CLASS_amd64_gp],
85 .limited = amd64_limited_gp_r9,
88 static const unsigned amd64_limited_gp_r10[] = { (1U << REG_GP_R10) };
89 const arch_register_req_t amd64_single_reg_req_gp_r10 = {
90 .cls = &amd64_reg_classes[CLASS_amd64_gp],
91 .limited = amd64_limited_gp_r10,
94 static const unsigned amd64_limited_gp_r11[] = { (1U << REG_GP_R11) };
95 const arch_register_req_t amd64_single_reg_req_gp_r11 = {
96 .cls = &amd64_reg_classes[CLASS_amd64_gp],
97 .limited = amd64_limited_gp_r11,
100 static const unsigned amd64_limited_gp_r12[] = { (1U << REG_GP_R12) };
101 const arch_register_req_t amd64_single_reg_req_gp_r12 = {
102 .cls = &amd64_reg_classes[CLASS_amd64_gp],
103 .limited = amd64_limited_gp_r12,
106 static const unsigned amd64_limited_gp_r13[] = { (1U << REG_GP_R13) };
107 const arch_register_req_t amd64_single_reg_req_gp_r13 = {
108 .cls = &amd64_reg_classes[CLASS_amd64_gp],
109 .limited = amd64_limited_gp_r13,
112 static const unsigned amd64_limited_gp_r14[] = { (1U << REG_GP_R14) };
113 const arch_register_req_t amd64_single_reg_req_gp_r14 = {
114 .cls = &amd64_reg_classes[CLASS_amd64_gp],
115 .limited = amd64_limited_gp_r14,
118 static const unsigned amd64_limited_gp_r15[] = { (1U << REG_GP_R15) };
119 const arch_register_req_t amd64_single_reg_req_gp_r15 = {
120 .cls = &amd64_reg_classes[CLASS_amd64_gp],
121 .limited = amd64_limited_gp_r15,
124 const arch_register_req_t amd64_class_reg_req_x87 = {
125 .cls = &amd64_reg_classes[CLASS_amd64_x87],
128 static const unsigned amd64_limited_x87_st0[] = { (1U << REG_X87_ST0) };
129 const arch_register_req_t amd64_single_reg_req_x87_st0 = {
130 .cls = &amd64_reg_classes[CLASS_amd64_x87],
131 .limited = amd64_limited_x87_st0,
134 static const unsigned amd64_limited_x87_st1[] = { (1U << REG_X87_ST1) };
135 const arch_register_req_t amd64_single_reg_req_x87_st1 = {
136 .cls = &amd64_reg_classes[CLASS_amd64_x87],
137 .limited = amd64_limited_x87_st1,
140 static const unsigned amd64_limited_x87_st2[] = { (1U << REG_X87_ST2) };
141 const arch_register_req_t amd64_single_reg_req_x87_st2 = {
142 .cls = &amd64_reg_classes[CLASS_amd64_x87],
143 .limited = amd64_limited_x87_st2,
146 static const unsigned amd64_limited_x87_st3[] = { (1U << REG_X87_ST3) };
147 const arch_register_req_t amd64_single_reg_req_x87_st3 = {
148 .cls = &amd64_reg_classes[CLASS_amd64_x87],
149 .limited = amd64_limited_x87_st3,
152 static const unsigned amd64_limited_x87_st4[] = { (1U << REG_X87_ST4) };
153 const arch_register_req_t amd64_single_reg_req_x87_st4 = {
154 .cls = &amd64_reg_classes[CLASS_amd64_x87],
155 .limited = amd64_limited_x87_st4,
158 static const unsigned amd64_limited_x87_st5[] = { (1U << REG_X87_ST5) };
159 const arch_register_req_t amd64_single_reg_req_x87_st5 = {
160 .cls = &amd64_reg_classes[CLASS_amd64_x87],
161 .limited = amd64_limited_x87_st5,
164 static const unsigned amd64_limited_x87_st6[] = { (1U << REG_X87_ST6) };
165 const arch_register_req_t amd64_single_reg_req_x87_st6 = {
166 .cls = &amd64_reg_classes[CLASS_amd64_x87],
167 .limited = amd64_limited_x87_st6,
170 static const unsigned amd64_limited_x87_st7[] = { (1U << REG_X87_ST7) };
171 const arch_register_req_t amd64_single_reg_req_x87_st7 = {
172 .cls = &amd64_reg_classes[CLASS_amd64_x87],
173 .limited = amd64_limited_x87_st7,
176 const arch_register_req_t amd64_class_reg_req_xmm = {
177 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
180 static const unsigned amd64_limited_xmm_xmm0[] = { (1U << REG_XMM_XMM0) };
181 const arch_register_req_t amd64_single_reg_req_xmm_xmm0 = {
182 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
183 .limited = amd64_limited_xmm_xmm0,
186 static const unsigned amd64_limited_xmm_xmm1[] = { (1U << REG_XMM_XMM1) };
187 const arch_register_req_t amd64_single_reg_req_xmm_xmm1 = {
188 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
189 .limited = amd64_limited_xmm_xmm1,
192 static const unsigned amd64_limited_xmm_xmm2[] = { (1U << REG_XMM_XMM2) };
193 const arch_register_req_t amd64_single_reg_req_xmm_xmm2 = {
194 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
195 .limited = amd64_limited_xmm_xmm2,
198 static const unsigned amd64_limited_xmm_xmm3[] = { (1U << REG_XMM_XMM3) };
199 const arch_register_req_t amd64_single_reg_req_xmm_xmm3 = {
200 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
201 .limited = amd64_limited_xmm_xmm3,
204 static const unsigned amd64_limited_xmm_xmm4[] = { (1U << REG_XMM_XMM4) };
205 const arch_register_req_t amd64_single_reg_req_xmm_xmm4 = {
206 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
207 .limited = amd64_limited_xmm_xmm4,
210 static const unsigned amd64_limited_xmm_xmm5[] = { (1U << REG_XMM_XMM5) };
211 const arch_register_req_t amd64_single_reg_req_xmm_xmm5 = {
212 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
213 .limited = amd64_limited_xmm_xmm5,
216 static const unsigned amd64_limited_xmm_xmm6[] = { (1U << REG_XMM_XMM6) };
217 const arch_register_req_t amd64_single_reg_req_xmm_xmm6 = {
218 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
219 .limited = amd64_limited_xmm_xmm6,
222 static const unsigned amd64_limited_xmm_xmm7[] = { (1U << REG_XMM_XMM7) };
223 const arch_register_req_t amd64_single_reg_req_xmm_xmm7 = {
224 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
225 .limited = amd64_limited_xmm_xmm7,
228 static const unsigned amd64_limited_xmm_xmm8[] = { (1U << REG_XMM_XMM8) };
229 const arch_register_req_t amd64_single_reg_req_xmm_xmm8 = {
230 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
231 .limited = amd64_limited_xmm_xmm8,
234 static const unsigned amd64_limited_xmm_xmm9[] = { (1U << REG_XMM_XMM9) };
235 const arch_register_req_t amd64_single_reg_req_xmm_xmm9 = {
236 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
237 .limited = amd64_limited_xmm_xmm9,
240 static const unsigned amd64_limited_xmm_xmm10[] = { (1U << REG_XMM_XMM10) };
241 const arch_register_req_t amd64_single_reg_req_xmm_xmm10 = {
242 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
243 .limited = amd64_limited_xmm_xmm10,
246 static const unsigned amd64_limited_xmm_xmm11[] = { (1U << REG_XMM_XMM11) };
247 const arch_register_req_t amd64_single_reg_req_xmm_xmm11 = {
248 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
249 .limited = amd64_limited_xmm_xmm11,
252 static const unsigned amd64_limited_xmm_xmm12[] = { (1U << REG_XMM_XMM12) };
253 const arch_register_req_t amd64_single_reg_req_xmm_xmm12 = {
254 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
255 .limited = amd64_limited_xmm_xmm12,
258 static const unsigned amd64_limited_xmm_xmm13[] = { (1U << REG_XMM_XMM13) };
259 const arch_register_req_t amd64_single_reg_req_xmm_xmm13 = {
260 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
261 .limited = amd64_limited_xmm_xmm13,
264 static const unsigned amd64_limited_xmm_xmm14[] = { (1U << REG_XMM_XMM14) };
265 const arch_register_req_t amd64_single_reg_req_xmm_xmm14 = {
266 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
267 .limited = amd64_limited_xmm_xmm14,
270 static const unsigned amd64_limited_xmm_xmm15[] = { (1U << REG_XMM_XMM15) };
271 const arch_register_req_t amd64_single_reg_req_xmm_xmm15 = {
272 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
273 .limited = amd64_limited_xmm_xmm15,
278 arch_register_class_t amd64_reg_classes[] = {
280 .name =
"amd64_flags",
282 .regs = &amd64_registers[REG_EFLAGS],
283 .class_req = &amd64_class_reg_req_flags,
284 .index = CLASS_amd64_flags,
291 .regs = &amd64_registers[REG_RAX],
292 .class_req = &amd64_class_reg_req_gp,
293 .index = CLASS_amd64_gp,
300 .regs = &amd64_registers[REG_ST0],
301 .class_req = &amd64_class_reg_req_x87,
302 .index = CLASS_amd64_x87,
309 .regs = &amd64_registers[REG_XMM0],
310 .class_req = &amd64_class_reg_req_xmm,
311 .index = CLASS_amd64_xmm,
319 const arch_register_t amd64_registers[] = {
322 .cls = &amd64_reg_classes[CLASS_amd64_flags],
323 .single_req = &amd64_single_reg_req_flags_eflags,
324 .index = REG_FLAGS_EFLAGS,
325 .global_index = REG_EFLAGS,
327 .encoding = REG_FLAGS_EFLAGS,
332 .cls = &amd64_reg_classes[CLASS_amd64_gp],
333 .single_req = &amd64_single_reg_req_gp_rax,
335 .global_index = REG_RAX,
337 .encoding = REG_GP_RAX,
342 .cls = &amd64_reg_classes[CLASS_amd64_gp],
343 .single_req = &amd64_single_reg_req_gp_rcx,
345 .global_index = REG_RCX,
347 .encoding = REG_GP_RCX,
352 .cls = &amd64_reg_classes[CLASS_amd64_gp],
353 .single_req = &amd64_single_reg_req_gp_rdx,
355 .global_index = REG_RDX,
357 .encoding = REG_GP_RDX,
362 .cls = &amd64_reg_classes[CLASS_amd64_gp],
363 .single_req = &amd64_single_reg_req_gp_rsi,
365 .global_index = REG_RSI,
367 .encoding = REG_GP_RSI,
372 .cls = &amd64_reg_classes[CLASS_amd64_gp],
373 .single_req = &amd64_single_reg_req_gp_rdi,
375 .global_index = REG_RDI,
377 .encoding = REG_GP_RDI,
382 .cls = &amd64_reg_classes[CLASS_amd64_gp],
383 .single_req = &amd64_single_reg_req_gp_rbx,
385 .global_index = REG_RBX,
387 .encoding = REG_GP_RBX,
392 .cls = &amd64_reg_classes[CLASS_amd64_gp],
393 .single_req = &amd64_single_reg_req_gp_rbp,
395 .global_index = REG_RBP,
397 .encoding = REG_GP_RBP,
402 .cls = &amd64_reg_classes[CLASS_amd64_gp],
403 .single_req = &amd64_single_reg_req_gp_rsp,
405 .global_index = REG_RSP,
407 .encoding = REG_GP_RSP,
412 .cls = &amd64_reg_classes[CLASS_amd64_gp],
413 .single_req = &amd64_single_reg_req_gp_r8,
415 .global_index = REG_R8,
417 .encoding = REG_GP_R8,
422 .cls = &amd64_reg_classes[CLASS_amd64_gp],
423 .single_req = &amd64_single_reg_req_gp_r9,
425 .global_index = REG_R9,
427 .encoding = REG_GP_R9,
432 .cls = &amd64_reg_classes[CLASS_amd64_gp],
433 .single_req = &amd64_single_reg_req_gp_r10,
435 .global_index = REG_R10,
437 .encoding = REG_GP_R10,
442 .cls = &amd64_reg_classes[CLASS_amd64_gp],
443 .single_req = &amd64_single_reg_req_gp_r11,
445 .global_index = REG_R11,
447 .encoding = REG_GP_R11,
452 .cls = &amd64_reg_classes[CLASS_amd64_gp],
453 .single_req = &amd64_single_reg_req_gp_r12,
455 .global_index = REG_R12,
457 .encoding = REG_GP_R12,
462 .cls = &amd64_reg_classes[CLASS_amd64_gp],
463 .single_req = &amd64_single_reg_req_gp_r13,
465 .global_index = REG_R13,
467 .encoding = REG_GP_R13,
472 .cls = &amd64_reg_classes[CLASS_amd64_gp],
473 .single_req = &amd64_single_reg_req_gp_r14,
475 .global_index = REG_R14,
477 .encoding = REG_GP_R14,
482 .cls = &amd64_reg_classes[CLASS_amd64_gp],
483 .single_req = &amd64_single_reg_req_gp_r15,
485 .global_index = REG_R15,
487 .encoding = REG_GP_R15,
492 .cls = &amd64_reg_classes[CLASS_amd64_x87],
493 .single_req = &amd64_single_reg_req_x87_st0,
494 .index = REG_X87_ST0,
495 .global_index = REG_ST0,
502 .cls = &amd64_reg_classes[CLASS_amd64_x87],
503 .single_req = &amd64_single_reg_req_x87_st1,
504 .index = REG_X87_ST1,
505 .global_index = REG_ST1,
512 .cls = &amd64_reg_classes[CLASS_amd64_x87],
513 .single_req = &amd64_single_reg_req_x87_st2,
514 .index = REG_X87_ST2,
515 .global_index = REG_ST2,
522 .cls = &amd64_reg_classes[CLASS_amd64_x87],
523 .single_req = &amd64_single_reg_req_x87_st3,
524 .index = REG_X87_ST3,
525 .global_index = REG_ST3,
532 .cls = &amd64_reg_classes[CLASS_amd64_x87],
533 .single_req = &amd64_single_reg_req_x87_st4,
534 .index = REG_X87_ST4,
535 .global_index = REG_ST4,
542 .cls = &amd64_reg_classes[CLASS_amd64_x87],
543 .single_req = &amd64_single_reg_req_x87_st5,
544 .index = REG_X87_ST5,
545 .global_index = REG_ST5,
552 .cls = &amd64_reg_classes[CLASS_amd64_x87],
553 .single_req = &amd64_single_reg_req_x87_st6,
554 .index = REG_X87_ST6,
555 .global_index = REG_ST6,
562 .cls = &amd64_reg_classes[CLASS_amd64_x87],
563 .single_req = &amd64_single_reg_req_x87_st7,
564 .index = REG_X87_ST7,
565 .global_index = REG_ST7,
572 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
573 .single_req = &amd64_single_reg_req_xmm_xmm0,
574 .index = REG_XMM_XMM0,
575 .global_index = REG_XMM0,
577 .encoding = REG_XMM_XMM0,
582 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
583 .single_req = &amd64_single_reg_req_xmm_xmm1,
584 .index = REG_XMM_XMM1,
585 .global_index = REG_XMM1,
587 .encoding = REG_XMM_XMM1,
592 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
593 .single_req = &amd64_single_reg_req_xmm_xmm2,
594 .index = REG_XMM_XMM2,
595 .global_index = REG_XMM2,
597 .encoding = REG_XMM_XMM2,
602 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
603 .single_req = &amd64_single_reg_req_xmm_xmm3,
604 .index = REG_XMM_XMM3,
605 .global_index = REG_XMM3,
607 .encoding = REG_XMM_XMM3,
612 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
613 .single_req = &amd64_single_reg_req_xmm_xmm4,
614 .index = REG_XMM_XMM4,
615 .global_index = REG_XMM4,
617 .encoding = REG_XMM_XMM4,
622 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
623 .single_req = &amd64_single_reg_req_xmm_xmm5,
624 .index = REG_XMM_XMM5,
625 .global_index = REG_XMM5,
627 .encoding = REG_XMM_XMM5,
632 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
633 .single_req = &amd64_single_reg_req_xmm_xmm6,
634 .index = REG_XMM_XMM6,
635 .global_index = REG_XMM6,
637 .encoding = REG_XMM_XMM6,
642 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
643 .single_req = &amd64_single_reg_req_xmm_xmm7,
644 .index = REG_XMM_XMM7,
645 .global_index = REG_XMM7,
647 .encoding = REG_XMM_XMM7,
652 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
653 .single_req = &amd64_single_reg_req_xmm_xmm8,
654 .index = REG_XMM_XMM8,
655 .global_index = REG_XMM8,
657 .encoding = REG_XMM_XMM8,
662 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
663 .single_req = &amd64_single_reg_req_xmm_xmm9,
664 .index = REG_XMM_XMM9,
665 .global_index = REG_XMM9,
667 .encoding = REG_XMM_XMM9,
672 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
673 .single_req = &amd64_single_reg_req_xmm_xmm10,
674 .index = REG_XMM_XMM10,
675 .global_index = REG_XMM10,
677 .encoding = REG_XMM_XMM10,
682 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
683 .single_req = &amd64_single_reg_req_xmm_xmm11,
684 .index = REG_XMM_XMM11,
685 .global_index = REG_XMM11,
687 .encoding = REG_XMM_XMM11,
692 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
693 .single_req = &amd64_single_reg_req_xmm_xmm12,
694 .index = REG_XMM_XMM12,
695 .global_index = REG_XMM12,
697 .encoding = REG_XMM_XMM12,
702 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
703 .single_req = &amd64_single_reg_req_xmm_xmm13,
704 .index = REG_XMM_XMM13,
705 .global_index = REG_XMM13,
707 .encoding = REG_XMM_XMM13,
712 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
713 .single_req = &amd64_single_reg_req_xmm_xmm14,
714 .index = REG_XMM_XMM14,
715 .global_index = REG_XMM14,
717 .encoding = REG_XMM_XMM14,
722 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
723 .single_req = &amd64_single_reg_req_xmm_xmm15,
724 .index = REG_XMM_XMM15,
725 .global_index = REG_XMM15,
727 .encoding = REG_XMM_XMM15,
736 void amd64_register_init(
void)
738 amd64_reg_classes[CLASS_amd64_flags].mode =
mode_Iu;
739 amd64_reg_classes[CLASS_amd64_gp].mode =
mode_Lu;
740 amd64_reg_classes[CLASS_amd64_x87].mode = x86_mode_E;
741 amd64_reg_classes[CLASS_amd64_xmm].mode = amd64_mode_xmm;