11 #include "gen_amd64_regalloc_if.h" 13 #include "amd64_bearch_t.h" 15 const arch_register_req_t amd64_class_reg_req_flags = {
16 .cls = &amd64_reg_classes[CLASS_amd64_flags],
19 static const unsigned amd64_limited_flags_eflags[] = { (1U << REG_FLAGS_EFLAGS) };
20 const arch_register_req_t amd64_single_reg_req_flags_eflags = {
21 .cls = &amd64_reg_classes[CLASS_amd64_flags],
22 .limited = amd64_limited_flags_eflags,
25 const arch_register_req_t amd64_class_reg_req_gp = {
26 .cls = &amd64_reg_classes[CLASS_amd64_gp],
29 static const unsigned amd64_limited_gp_rax[] = { (1U << REG_GP_RAX) };
30 const arch_register_req_t amd64_single_reg_req_gp_rax = {
31 .cls = &amd64_reg_classes[CLASS_amd64_gp],
32 .limited = amd64_limited_gp_rax,
35 static const unsigned amd64_limited_gp_rcx[] = { (1U << REG_GP_RCX) };
36 const arch_register_req_t amd64_single_reg_req_gp_rcx = {
37 .cls = &amd64_reg_classes[CLASS_amd64_gp],
38 .limited = amd64_limited_gp_rcx,
41 static const unsigned amd64_limited_gp_rdx[] = { (1U << REG_GP_RDX) };
42 const arch_register_req_t amd64_single_reg_req_gp_rdx = {
43 .cls = &amd64_reg_classes[CLASS_amd64_gp],
44 .limited = amd64_limited_gp_rdx,
47 static const unsigned amd64_limited_gp_rsi[] = { (1U << REG_GP_RSI) };
48 const arch_register_req_t amd64_single_reg_req_gp_rsi = {
49 .cls = &amd64_reg_classes[CLASS_amd64_gp],
50 .limited = amd64_limited_gp_rsi,
53 static const unsigned amd64_limited_gp_rdi[] = { (1U << REG_GP_RDI) };
54 const arch_register_req_t amd64_single_reg_req_gp_rdi = {
55 .cls = &amd64_reg_classes[CLASS_amd64_gp],
56 .limited = amd64_limited_gp_rdi,
59 static const unsigned amd64_limited_gp_rbx[] = { (1U << REG_GP_RBX) };
60 const arch_register_req_t amd64_single_reg_req_gp_rbx = {
61 .cls = &amd64_reg_classes[CLASS_amd64_gp],
62 .limited = amd64_limited_gp_rbx,
65 static const unsigned amd64_limited_gp_rbp[] = { (1U << REG_GP_RBP) };
66 const arch_register_req_t amd64_single_reg_req_gp_rbp = {
67 .cls = &amd64_reg_classes[CLASS_amd64_gp],
68 .limited = amd64_limited_gp_rbp,
71 static const unsigned amd64_limited_gp_rsp[] = { (1U << REG_GP_RSP) };
72 const arch_register_req_t amd64_single_reg_req_gp_rsp = {
73 .cls = &amd64_reg_classes[CLASS_amd64_gp],
74 .limited = amd64_limited_gp_rsp,
77 static const unsigned amd64_limited_gp_r8[] = { (1U << REG_GP_R8) };
78 const arch_register_req_t amd64_single_reg_req_gp_r8 = {
79 .cls = &amd64_reg_classes[CLASS_amd64_gp],
80 .limited = amd64_limited_gp_r8,
83 static const unsigned amd64_limited_gp_r9[] = { (1U << REG_GP_R9) };
84 const arch_register_req_t amd64_single_reg_req_gp_r9 = {
85 .cls = &amd64_reg_classes[CLASS_amd64_gp],
86 .limited = amd64_limited_gp_r9,
89 static const unsigned amd64_limited_gp_r10[] = { (1U << REG_GP_R10) };
90 const arch_register_req_t amd64_single_reg_req_gp_r10 = {
91 .cls = &amd64_reg_classes[CLASS_amd64_gp],
92 .limited = amd64_limited_gp_r10,
95 static const unsigned amd64_limited_gp_r11[] = { (1U << REG_GP_R11) };
96 const arch_register_req_t amd64_single_reg_req_gp_r11 = {
97 .cls = &amd64_reg_classes[CLASS_amd64_gp],
98 .limited = amd64_limited_gp_r11,
101 static const unsigned amd64_limited_gp_r12[] = { (1U << REG_GP_R12) };
102 const arch_register_req_t amd64_single_reg_req_gp_r12 = {
103 .cls = &amd64_reg_classes[CLASS_amd64_gp],
104 .limited = amd64_limited_gp_r12,
107 static const unsigned amd64_limited_gp_r13[] = { (1U << REG_GP_R13) };
108 const arch_register_req_t amd64_single_reg_req_gp_r13 = {
109 .cls = &amd64_reg_classes[CLASS_amd64_gp],
110 .limited = amd64_limited_gp_r13,
113 static const unsigned amd64_limited_gp_r14[] = { (1U << REG_GP_R14) };
114 const arch_register_req_t amd64_single_reg_req_gp_r14 = {
115 .cls = &amd64_reg_classes[CLASS_amd64_gp],
116 .limited = amd64_limited_gp_r14,
119 static const unsigned amd64_limited_gp_r15[] = { (1U << REG_GP_R15) };
120 const arch_register_req_t amd64_single_reg_req_gp_r15 = {
121 .cls = &amd64_reg_classes[CLASS_amd64_gp],
122 .limited = amd64_limited_gp_r15,
125 const arch_register_req_t amd64_class_reg_req_x87 = {
126 .cls = &amd64_reg_classes[CLASS_amd64_x87],
129 static const unsigned amd64_limited_x87_st0[] = { (1U << REG_X87_ST0) };
130 const arch_register_req_t amd64_single_reg_req_x87_st0 = {
131 .cls = &amd64_reg_classes[CLASS_amd64_x87],
132 .limited = amd64_limited_x87_st0,
135 static const unsigned amd64_limited_x87_st1[] = { (1U << REG_X87_ST1) };
136 const arch_register_req_t amd64_single_reg_req_x87_st1 = {
137 .cls = &amd64_reg_classes[CLASS_amd64_x87],
138 .limited = amd64_limited_x87_st1,
141 static const unsigned amd64_limited_x87_st2[] = { (1U << REG_X87_ST2) };
142 const arch_register_req_t amd64_single_reg_req_x87_st2 = {
143 .cls = &amd64_reg_classes[CLASS_amd64_x87],
144 .limited = amd64_limited_x87_st2,
147 static const unsigned amd64_limited_x87_st3[] = { (1U << REG_X87_ST3) };
148 const arch_register_req_t amd64_single_reg_req_x87_st3 = {
149 .cls = &amd64_reg_classes[CLASS_amd64_x87],
150 .limited = amd64_limited_x87_st3,
153 static const unsigned amd64_limited_x87_st4[] = { (1U << REG_X87_ST4) };
154 const arch_register_req_t amd64_single_reg_req_x87_st4 = {
155 .cls = &amd64_reg_classes[CLASS_amd64_x87],
156 .limited = amd64_limited_x87_st4,
159 static const unsigned amd64_limited_x87_st5[] = { (1U << REG_X87_ST5) };
160 const arch_register_req_t amd64_single_reg_req_x87_st5 = {
161 .cls = &amd64_reg_classes[CLASS_amd64_x87],
162 .limited = amd64_limited_x87_st5,
165 static const unsigned amd64_limited_x87_st6[] = { (1U << REG_X87_ST6) };
166 const arch_register_req_t amd64_single_reg_req_x87_st6 = {
167 .cls = &amd64_reg_classes[CLASS_amd64_x87],
168 .limited = amd64_limited_x87_st6,
171 static const unsigned amd64_limited_x87_st7[] = { (1U << REG_X87_ST7) };
172 const arch_register_req_t amd64_single_reg_req_x87_st7 = {
173 .cls = &amd64_reg_classes[CLASS_amd64_x87],
174 .limited = amd64_limited_x87_st7,
177 const arch_register_req_t amd64_class_reg_req_xmm = {
178 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
181 static const unsigned amd64_limited_xmm_xmm0[] = { (1U << REG_XMM_XMM0) };
182 const arch_register_req_t amd64_single_reg_req_xmm_xmm0 = {
183 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
184 .limited = amd64_limited_xmm_xmm0,
187 static const unsigned amd64_limited_xmm_xmm1[] = { (1U << REG_XMM_XMM1) };
188 const arch_register_req_t amd64_single_reg_req_xmm_xmm1 = {
189 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
190 .limited = amd64_limited_xmm_xmm1,
193 static const unsigned amd64_limited_xmm_xmm2[] = { (1U << REG_XMM_XMM2) };
194 const arch_register_req_t amd64_single_reg_req_xmm_xmm2 = {
195 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
196 .limited = amd64_limited_xmm_xmm2,
199 static const unsigned amd64_limited_xmm_xmm3[] = { (1U << REG_XMM_XMM3) };
200 const arch_register_req_t amd64_single_reg_req_xmm_xmm3 = {
201 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
202 .limited = amd64_limited_xmm_xmm3,
205 static const unsigned amd64_limited_xmm_xmm4[] = { (1U << REG_XMM_XMM4) };
206 const arch_register_req_t amd64_single_reg_req_xmm_xmm4 = {
207 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
208 .limited = amd64_limited_xmm_xmm4,
211 static const unsigned amd64_limited_xmm_xmm5[] = { (1U << REG_XMM_XMM5) };
212 const arch_register_req_t amd64_single_reg_req_xmm_xmm5 = {
213 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
214 .limited = amd64_limited_xmm_xmm5,
217 static const unsigned amd64_limited_xmm_xmm6[] = { (1U << REG_XMM_XMM6) };
218 const arch_register_req_t amd64_single_reg_req_xmm_xmm6 = {
219 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
220 .limited = amd64_limited_xmm_xmm6,
223 static const unsigned amd64_limited_xmm_xmm7[] = { (1U << REG_XMM_XMM7) };
224 const arch_register_req_t amd64_single_reg_req_xmm_xmm7 = {
225 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
226 .limited = amd64_limited_xmm_xmm7,
229 static const unsigned amd64_limited_xmm_xmm8[] = { (1U << REG_XMM_XMM8) };
230 const arch_register_req_t amd64_single_reg_req_xmm_xmm8 = {
231 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
232 .limited = amd64_limited_xmm_xmm8,
235 static const unsigned amd64_limited_xmm_xmm9[] = { (1U << REG_XMM_XMM9) };
236 const arch_register_req_t amd64_single_reg_req_xmm_xmm9 = {
237 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
238 .limited = amd64_limited_xmm_xmm9,
241 static const unsigned amd64_limited_xmm_xmm10[] = { (1U << REG_XMM_XMM10) };
242 const arch_register_req_t amd64_single_reg_req_xmm_xmm10 = {
243 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
244 .limited = amd64_limited_xmm_xmm10,
247 static const unsigned amd64_limited_xmm_xmm11[] = { (1U << REG_XMM_XMM11) };
248 const arch_register_req_t amd64_single_reg_req_xmm_xmm11 = {
249 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
250 .limited = amd64_limited_xmm_xmm11,
253 static const unsigned amd64_limited_xmm_xmm12[] = { (1U << REG_XMM_XMM12) };
254 const arch_register_req_t amd64_single_reg_req_xmm_xmm12 = {
255 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
256 .limited = amd64_limited_xmm_xmm12,
259 static const unsigned amd64_limited_xmm_xmm13[] = { (1U << REG_XMM_XMM13) };
260 const arch_register_req_t amd64_single_reg_req_xmm_xmm13 = {
261 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
262 .limited = amd64_limited_xmm_xmm13,
265 static const unsigned amd64_limited_xmm_xmm14[] = { (1U << REG_XMM_XMM14) };
266 const arch_register_req_t amd64_single_reg_req_xmm_xmm14 = {
267 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
268 .limited = amd64_limited_xmm_xmm14,
271 static const unsigned amd64_limited_xmm_xmm15[] = { (1U << REG_XMM_XMM15) };
272 const arch_register_req_t amd64_single_reg_req_xmm_xmm15 = {
273 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
274 .limited = amd64_limited_xmm_xmm15,
279 arch_register_class_t amd64_reg_classes[] = {
281 .name =
"amd64_flags",
283 .regs = &amd64_registers[REG_EFLAGS],
284 .class_req = &amd64_class_reg_req_flags,
285 .index = CLASS_amd64_flags,
292 .regs = &amd64_registers[REG_RAX],
293 .class_req = &amd64_class_reg_req_gp,
294 .index = CLASS_amd64_gp,
301 .regs = &amd64_registers[REG_ST0],
302 .class_req = &amd64_class_reg_req_x87,
303 .index = CLASS_amd64_x87,
310 .regs = &amd64_registers[REG_XMM0],
311 .class_req = &amd64_class_reg_req_xmm,
312 .index = CLASS_amd64_xmm,
320 const arch_register_t amd64_registers[] = {
323 .cls = &amd64_reg_classes[CLASS_amd64_flags],
324 .single_req = &amd64_single_reg_req_flags_eflags,
325 .index = REG_FLAGS_EFLAGS,
326 .global_index = REG_EFLAGS,
328 .encoding = REG_FLAGS_EFLAGS,
333 .cls = &amd64_reg_classes[CLASS_amd64_gp],
334 .single_req = &amd64_single_reg_req_gp_rax,
336 .global_index = REG_RAX,
338 .encoding = REG_GP_RAX,
343 .cls = &amd64_reg_classes[CLASS_amd64_gp],
344 .single_req = &amd64_single_reg_req_gp_rcx,
346 .global_index = REG_RCX,
348 .encoding = REG_GP_RCX,
353 .cls = &amd64_reg_classes[CLASS_amd64_gp],
354 .single_req = &amd64_single_reg_req_gp_rdx,
356 .global_index = REG_RDX,
358 .encoding = REG_GP_RDX,
363 .cls = &amd64_reg_classes[CLASS_amd64_gp],
364 .single_req = &amd64_single_reg_req_gp_rsi,
366 .global_index = REG_RSI,
368 .encoding = REG_GP_RSI,
373 .cls = &amd64_reg_classes[CLASS_amd64_gp],
374 .single_req = &amd64_single_reg_req_gp_rdi,
376 .global_index = REG_RDI,
378 .encoding = REG_GP_RDI,
383 .cls = &amd64_reg_classes[CLASS_amd64_gp],
384 .single_req = &amd64_single_reg_req_gp_rbx,
386 .global_index = REG_RBX,
388 .encoding = REG_GP_RBX,
393 .cls = &amd64_reg_classes[CLASS_amd64_gp],
394 .single_req = &amd64_single_reg_req_gp_rbp,
396 .global_index = REG_RBP,
398 .encoding = REG_GP_RBP,
403 .cls = &amd64_reg_classes[CLASS_amd64_gp],
404 .single_req = &amd64_single_reg_req_gp_rsp,
406 .global_index = REG_RSP,
408 .encoding = REG_GP_RSP,
413 .cls = &amd64_reg_classes[CLASS_amd64_gp],
414 .single_req = &amd64_single_reg_req_gp_r8,
416 .global_index = REG_R8,
418 .encoding = REG_GP_R8,
423 .cls = &amd64_reg_classes[CLASS_amd64_gp],
424 .single_req = &amd64_single_reg_req_gp_r9,
426 .global_index = REG_R9,
428 .encoding = REG_GP_R9,
433 .cls = &amd64_reg_classes[CLASS_amd64_gp],
434 .single_req = &amd64_single_reg_req_gp_r10,
436 .global_index = REG_R10,
438 .encoding = REG_GP_R10,
443 .cls = &amd64_reg_classes[CLASS_amd64_gp],
444 .single_req = &amd64_single_reg_req_gp_r11,
446 .global_index = REG_R11,
448 .encoding = REG_GP_R11,
453 .cls = &amd64_reg_classes[CLASS_amd64_gp],
454 .single_req = &amd64_single_reg_req_gp_r12,
456 .global_index = REG_R12,
458 .encoding = REG_GP_R12,
463 .cls = &amd64_reg_classes[CLASS_amd64_gp],
464 .single_req = &amd64_single_reg_req_gp_r13,
466 .global_index = REG_R13,
468 .encoding = REG_GP_R13,
473 .cls = &amd64_reg_classes[CLASS_amd64_gp],
474 .single_req = &amd64_single_reg_req_gp_r14,
476 .global_index = REG_R14,
478 .encoding = REG_GP_R14,
483 .cls = &amd64_reg_classes[CLASS_amd64_gp],
484 .single_req = &amd64_single_reg_req_gp_r15,
486 .global_index = REG_R15,
488 .encoding = REG_GP_R15,
493 .cls = &amd64_reg_classes[CLASS_amd64_x87],
494 .single_req = &amd64_single_reg_req_x87_st0,
495 .index = REG_X87_ST0,
496 .global_index = REG_ST0,
503 .cls = &amd64_reg_classes[CLASS_amd64_x87],
504 .single_req = &amd64_single_reg_req_x87_st1,
505 .index = REG_X87_ST1,
506 .global_index = REG_ST1,
513 .cls = &amd64_reg_classes[CLASS_amd64_x87],
514 .single_req = &amd64_single_reg_req_x87_st2,
515 .index = REG_X87_ST2,
516 .global_index = REG_ST2,
523 .cls = &amd64_reg_classes[CLASS_amd64_x87],
524 .single_req = &amd64_single_reg_req_x87_st3,
525 .index = REG_X87_ST3,
526 .global_index = REG_ST3,
533 .cls = &amd64_reg_classes[CLASS_amd64_x87],
534 .single_req = &amd64_single_reg_req_x87_st4,
535 .index = REG_X87_ST4,
536 .global_index = REG_ST4,
543 .cls = &amd64_reg_classes[CLASS_amd64_x87],
544 .single_req = &amd64_single_reg_req_x87_st5,
545 .index = REG_X87_ST5,
546 .global_index = REG_ST5,
553 .cls = &amd64_reg_classes[CLASS_amd64_x87],
554 .single_req = &amd64_single_reg_req_x87_st6,
555 .index = REG_X87_ST6,
556 .global_index = REG_ST6,
563 .cls = &amd64_reg_classes[CLASS_amd64_x87],
564 .single_req = &amd64_single_reg_req_x87_st7,
565 .index = REG_X87_ST7,
566 .global_index = REG_ST7,
573 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
574 .single_req = &amd64_single_reg_req_xmm_xmm0,
575 .index = REG_XMM_XMM0,
576 .global_index = REG_XMM0,
578 .encoding = REG_XMM_XMM0,
583 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
584 .single_req = &amd64_single_reg_req_xmm_xmm1,
585 .index = REG_XMM_XMM1,
586 .global_index = REG_XMM1,
588 .encoding = REG_XMM_XMM1,
593 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
594 .single_req = &amd64_single_reg_req_xmm_xmm2,
595 .index = REG_XMM_XMM2,
596 .global_index = REG_XMM2,
598 .encoding = REG_XMM_XMM2,
603 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
604 .single_req = &amd64_single_reg_req_xmm_xmm3,
605 .index = REG_XMM_XMM3,
606 .global_index = REG_XMM3,
608 .encoding = REG_XMM_XMM3,
613 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
614 .single_req = &amd64_single_reg_req_xmm_xmm4,
615 .index = REG_XMM_XMM4,
616 .global_index = REG_XMM4,
618 .encoding = REG_XMM_XMM4,
623 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
624 .single_req = &amd64_single_reg_req_xmm_xmm5,
625 .index = REG_XMM_XMM5,
626 .global_index = REG_XMM5,
628 .encoding = REG_XMM_XMM5,
633 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
634 .single_req = &amd64_single_reg_req_xmm_xmm6,
635 .index = REG_XMM_XMM6,
636 .global_index = REG_XMM6,
638 .encoding = REG_XMM_XMM6,
643 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
644 .single_req = &amd64_single_reg_req_xmm_xmm7,
645 .index = REG_XMM_XMM7,
646 .global_index = REG_XMM7,
648 .encoding = REG_XMM_XMM7,
653 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
654 .single_req = &amd64_single_reg_req_xmm_xmm8,
655 .index = REG_XMM_XMM8,
656 .global_index = REG_XMM8,
658 .encoding = REG_XMM_XMM8,
663 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
664 .single_req = &amd64_single_reg_req_xmm_xmm9,
665 .index = REG_XMM_XMM9,
666 .global_index = REG_XMM9,
668 .encoding = REG_XMM_XMM9,
673 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
674 .single_req = &amd64_single_reg_req_xmm_xmm10,
675 .index = REG_XMM_XMM10,
676 .global_index = REG_XMM10,
678 .encoding = REG_XMM_XMM10,
683 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
684 .single_req = &amd64_single_reg_req_xmm_xmm11,
685 .index = REG_XMM_XMM11,
686 .global_index = REG_XMM11,
688 .encoding = REG_XMM_XMM11,
693 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
694 .single_req = &amd64_single_reg_req_xmm_xmm12,
695 .index = REG_XMM_XMM12,
696 .global_index = REG_XMM12,
698 .encoding = REG_XMM_XMM12,
703 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
704 .single_req = &amd64_single_reg_req_xmm_xmm13,
705 .index = REG_XMM_XMM13,
706 .global_index = REG_XMM13,
708 .encoding = REG_XMM_XMM13,
713 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
714 .single_req = &amd64_single_reg_req_xmm_xmm14,
715 .index = REG_XMM_XMM14,
716 .global_index = REG_XMM14,
718 .encoding = REG_XMM_XMM14,
723 .cls = &amd64_reg_classes[CLASS_amd64_xmm],
724 .single_req = &amd64_single_reg_req_xmm_xmm15,
725 .index = REG_XMM_XMM15,
726 .global_index = REG_XMM15,
728 .encoding = REG_XMM_XMM15,
737 void amd64_register_init(
void)
739 amd64_reg_classes[CLASS_amd64_flags].mode =
mode_Iu;
740 amd64_reg_classes[CLASS_amd64_gp].mode =
mode_Lu;
741 amd64_reg_classes[CLASS_amd64_x87].mode = x86_mode_E;
742 amd64_reg_classes[CLASS_amd64_xmm].mode = amd64_mode_xmm;