libFirm
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
gen_ia32_regalloc_if.c
1 
11 #include "gen_ia32_regalloc_if.h"
12 #include "bearch_ia32_t.h"
13 
14 const arch_register_req_t ia32_class_reg_req_flags = {
15  .cls = &ia32_reg_classes[CLASS_ia32_flags],
16  .width = 1,
17 };
18 static const unsigned ia32_limited_flags_eflags[] = { (1U << REG_FLAGS_EFLAGS) };
19 const arch_register_req_t ia32_single_reg_req_flags_eflags = {
20  .cls = &ia32_reg_classes[CLASS_ia32_flags],
21  .limited = ia32_limited_flags_eflags,
22  .width = 1,
23 };
24 const arch_register_req_t ia32_class_reg_req_fp = {
25  .cls = &ia32_reg_classes[CLASS_ia32_fp],
26  .width = 1,
27 };
28 static const unsigned ia32_limited_fp_st0[] = { (1U << REG_FP_ST0) };
29 const arch_register_req_t ia32_single_reg_req_fp_st0 = {
30  .cls = &ia32_reg_classes[CLASS_ia32_fp],
31  .limited = ia32_limited_fp_st0,
32  .width = 1,
33 };
34 static const unsigned ia32_limited_fp_st1[] = { (1U << REG_FP_ST1) };
35 const arch_register_req_t ia32_single_reg_req_fp_st1 = {
36  .cls = &ia32_reg_classes[CLASS_ia32_fp],
37  .limited = ia32_limited_fp_st1,
38  .width = 1,
39 };
40 static const unsigned ia32_limited_fp_st2[] = { (1U << REG_FP_ST2) };
41 const arch_register_req_t ia32_single_reg_req_fp_st2 = {
42  .cls = &ia32_reg_classes[CLASS_ia32_fp],
43  .limited = ia32_limited_fp_st2,
44  .width = 1,
45 };
46 static const unsigned ia32_limited_fp_st3[] = { (1U << REG_FP_ST3) };
47 const arch_register_req_t ia32_single_reg_req_fp_st3 = {
48  .cls = &ia32_reg_classes[CLASS_ia32_fp],
49  .limited = ia32_limited_fp_st3,
50  .width = 1,
51 };
52 static const unsigned ia32_limited_fp_st4[] = { (1U << REG_FP_ST4) };
53 const arch_register_req_t ia32_single_reg_req_fp_st4 = {
54  .cls = &ia32_reg_classes[CLASS_ia32_fp],
55  .limited = ia32_limited_fp_st4,
56  .width = 1,
57 };
58 static const unsigned ia32_limited_fp_st5[] = { (1U << REG_FP_ST5) };
59 const arch_register_req_t ia32_single_reg_req_fp_st5 = {
60  .cls = &ia32_reg_classes[CLASS_ia32_fp],
61  .limited = ia32_limited_fp_st5,
62  .width = 1,
63 };
64 static const unsigned ia32_limited_fp_st6[] = { (1U << REG_FP_ST6) };
65 const arch_register_req_t ia32_single_reg_req_fp_st6 = {
66  .cls = &ia32_reg_classes[CLASS_ia32_fp],
67  .limited = ia32_limited_fp_st6,
68  .width = 1,
69 };
70 static const unsigned ia32_limited_fp_st7[] = { (1U << REG_FP_ST7) };
71 const arch_register_req_t ia32_single_reg_req_fp_st7 = {
72  .cls = &ia32_reg_classes[CLASS_ia32_fp],
73  .limited = ia32_limited_fp_st7,
74  .width = 1,
75 };
76 static const unsigned ia32_limited_fp_fp_NOREG[] = { (1U << REG_FP_FP_NOREG) };
77 const arch_register_req_t ia32_single_reg_req_fp_fp_NOREG = {
78  .cls = &ia32_reg_classes[CLASS_ia32_fp],
79  .limited = ia32_limited_fp_fp_NOREG,
80  .width = 1,
81 };
82 const arch_register_req_t ia32_class_reg_req_fp_cw = {
83  .cls = &ia32_reg_classes[CLASS_ia32_fp_cw],
84  .width = 1,
85 };
86 static const unsigned ia32_limited_fp_cw_fpcw[] = { (1U << REG_FP_CW_FPCW) };
87 const arch_register_req_t ia32_single_reg_req_fp_cw_fpcw = {
88  .cls = &ia32_reg_classes[CLASS_ia32_fp_cw],
89  .limited = ia32_limited_fp_cw_fpcw,
90  .width = 1,
91 };
92 const arch_register_req_t ia32_class_reg_req_gp = {
93  .cls = &ia32_reg_classes[CLASS_ia32_gp],
94  .width = 1,
95 };
96 static const unsigned ia32_limited_gp_edx[] = { (1U << REG_GP_EDX) };
97 const arch_register_req_t ia32_single_reg_req_gp_edx = {
98  .cls = &ia32_reg_classes[CLASS_ia32_gp],
99  .limited = ia32_limited_gp_edx,
100  .width = 1,
101 };
102 static const unsigned ia32_limited_gp_ecx[] = { (1U << REG_GP_ECX) };
103 const arch_register_req_t ia32_single_reg_req_gp_ecx = {
104  .cls = &ia32_reg_classes[CLASS_ia32_gp],
105  .limited = ia32_limited_gp_ecx,
106  .width = 1,
107 };
108 static const unsigned ia32_limited_gp_eax[] = { (1U << REG_GP_EAX) };
109 const arch_register_req_t ia32_single_reg_req_gp_eax = {
110  .cls = &ia32_reg_classes[CLASS_ia32_gp],
111  .limited = ia32_limited_gp_eax,
112  .width = 1,
113 };
114 static const unsigned ia32_limited_gp_ebx[] = { (1U << REG_GP_EBX) };
115 const arch_register_req_t ia32_single_reg_req_gp_ebx = {
116  .cls = &ia32_reg_classes[CLASS_ia32_gp],
117  .limited = ia32_limited_gp_ebx,
118  .width = 1,
119 };
120 static const unsigned ia32_limited_gp_esi[] = { (1U << REG_GP_ESI) };
121 const arch_register_req_t ia32_single_reg_req_gp_esi = {
122  .cls = &ia32_reg_classes[CLASS_ia32_gp],
123  .limited = ia32_limited_gp_esi,
124  .width = 1,
125 };
126 static const unsigned ia32_limited_gp_edi[] = { (1U << REG_GP_EDI) };
127 const arch_register_req_t ia32_single_reg_req_gp_edi = {
128  .cls = &ia32_reg_classes[CLASS_ia32_gp],
129  .limited = ia32_limited_gp_edi,
130  .width = 1,
131 };
132 static const unsigned ia32_limited_gp_ebp[] = { (1U << REG_GP_EBP) };
133 const arch_register_req_t ia32_single_reg_req_gp_ebp = {
134  .cls = &ia32_reg_classes[CLASS_ia32_gp],
135  .limited = ia32_limited_gp_ebp,
136  .width = 1,
137 };
138 static const unsigned ia32_limited_gp_esp[] = { (1U << REG_GP_ESP) };
139 const arch_register_req_t ia32_single_reg_req_gp_esp = {
140  .cls = &ia32_reg_classes[CLASS_ia32_gp],
141  .limited = ia32_limited_gp_esp,
142  .width = 1,
143 };
144 static const unsigned ia32_limited_gp_gp_NOREG[] = { (1U << REG_GP_GP_NOREG) };
145 const arch_register_req_t ia32_single_reg_req_gp_gp_NOREG = {
146  .cls = &ia32_reg_classes[CLASS_ia32_gp],
147  .limited = ia32_limited_gp_gp_NOREG,
148  .width = 1,
149 };
150 const arch_register_req_t ia32_class_reg_req_xmm = {
151  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
152  .width = 1,
153 };
154 static const unsigned ia32_limited_xmm_xmm0[] = { (1U << REG_XMM_XMM0) };
155 const arch_register_req_t ia32_single_reg_req_xmm_xmm0 = {
156  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
157  .limited = ia32_limited_xmm_xmm0,
158  .width = 1,
159 };
160 static const unsigned ia32_limited_xmm_xmm1[] = { (1U << REG_XMM_XMM1) };
161 const arch_register_req_t ia32_single_reg_req_xmm_xmm1 = {
162  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
163  .limited = ia32_limited_xmm_xmm1,
164  .width = 1,
165 };
166 static const unsigned ia32_limited_xmm_xmm2[] = { (1U << REG_XMM_XMM2) };
167 const arch_register_req_t ia32_single_reg_req_xmm_xmm2 = {
168  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
169  .limited = ia32_limited_xmm_xmm2,
170  .width = 1,
171 };
172 static const unsigned ia32_limited_xmm_xmm3[] = { (1U << REG_XMM_XMM3) };
173 const arch_register_req_t ia32_single_reg_req_xmm_xmm3 = {
174  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
175  .limited = ia32_limited_xmm_xmm3,
176  .width = 1,
177 };
178 static const unsigned ia32_limited_xmm_xmm4[] = { (1U << REG_XMM_XMM4) };
179 const arch_register_req_t ia32_single_reg_req_xmm_xmm4 = {
180  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
181  .limited = ia32_limited_xmm_xmm4,
182  .width = 1,
183 };
184 static const unsigned ia32_limited_xmm_xmm5[] = { (1U << REG_XMM_XMM5) };
185 const arch_register_req_t ia32_single_reg_req_xmm_xmm5 = {
186  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
187  .limited = ia32_limited_xmm_xmm5,
188  .width = 1,
189 };
190 static const unsigned ia32_limited_xmm_xmm6[] = { (1U << REG_XMM_XMM6) };
191 const arch_register_req_t ia32_single_reg_req_xmm_xmm6 = {
192  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
193  .limited = ia32_limited_xmm_xmm6,
194  .width = 1,
195 };
196 static const unsigned ia32_limited_xmm_xmm7[] = { (1U << REG_XMM_XMM7) };
197 const arch_register_req_t ia32_single_reg_req_xmm_xmm7 = {
198  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
199  .limited = ia32_limited_xmm_xmm7,
200  .width = 1,
201 };
202 static const unsigned ia32_limited_xmm_xmm_NOREG[] = { (1U << REG_XMM_XMM_NOREG) };
203 const arch_register_req_t ia32_single_reg_req_xmm_xmm_NOREG = {
204  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
205  .limited = ia32_limited_xmm_xmm_NOREG,
206  .width = 1,
207 };
208 
209 
210 arch_register_class_t ia32_reg_classes[] = {
211  {
212  .name = "ia32_flags",
213  .mode = NULL,
214  .regs = &ia32_registers[REG_EFLAGS],
215  .class_req = &ia32_class_reg_req_flags,
216  .index = CLASS_ia32_flags,
217  .n_regs = 1,
218  .manual_ra = true,
219  },
220  {
221  .name = "ia32_fp",
222  .mode = NULL,
223  .regs = &ia32_registers[REG_ST0],
224  .class_req = &ia32_class_reg_req_fp,
225  .index = CLASS_ia32_fp,
226  .n_regs = 9,
227  .manual_ra = false,
228  },
229  {
230  .name = "ia32_fp_cw",
231  .mode = NULL,
232  .regs = &ia32_registers[REG_FPCW],
233  .class_req = &ia32_class_reg_req_fp_cw,
234  .index = CLASS_ia32_fp_cw,
235  .n_regs = 1,
236  .manual_ra = true,
237  },
238  {
239  .name = "ia32_gp",
240  .mode = NULL,
241  .regs = &ia32_registers[REG_EDX],
242  .class_req = &ia32_class_reg_req_gp,
243  .index = CLASS_ia32_gp,
244  .n_regs = 9,
245  .manual_ra = false,
246  },
247  {
248  .name = "ia32_xmm",
249  .mode = NULL,
250  .regs = &ia32_registers[REG_XMM0],
251  .class_req = &ia32_class_reg_req_xmm,
252  .index = CLASS_ia32_xmm,
253  .n_regs = 9,
254  .manual_ra = false,
255  },
256 
257 };
258 
260 const arch_register_t ia32_registers[] = {
261  {
262  .name = "eflags",
263  .cls = &ia32_reg_classes[CLASS_ia32_flags],
264  .single_req = &ia32_single_reg_req_flags_eflags,
265  .index = REG_FLAGS_EFLAGS,
266  .global_index = REG_EFLAGS,
267  .dwarf_number = 9,
268  .encoding = REG_FLAGS_EFLAGS,
269  .is_virtual = false,
270  },
271  {
272  .name = "st",
273  .cls = &ia32_reg_classes[CLASS_ia32_fp],
274  .single_req = &ia32_single_reg_req_fp_st0,
275  .index = REG_FP_ST0,
276  .global_index = REG_ST0,
277  .dwarf_number = 11,
278  .encoding = 0,
279  .is_virtual = false,
280  },
281  {
282  .name = "st(1)",
283  .cls = &ia32_reg_classes[CLASS_ia32_fp],
284  .single_req = &ia32_single_reg_req_fp_st1,
285  .index = REG_FP_ST1,
286  .global_index = REG_ST1,
287  .dwarf_number = 12,
288  .encoding = 1,
289  .is_virtual = false,
290  },
291  {
292  .name = "st(2)",
293  .cls = &ia32_reg_classes[CLASS_ia32_fp],
294  .single_req = &ia32_single_reg_req_fp_st2,
295  .index = REG_FP_ST2,
296  .global_index = REG_ST2,
297  .dwarf_number = 13,
298  .encoding = 2,
299  .is_virtual = false,
300  },
301  {
302  .name = "st(3)",
303  .cls = &ia32_reg_classes[CLASS_ia32_fp],
304  .single_req = &ia32_single_reg_req_fp_st3,
305  .index = REG_FP_ST3,
306  .global_index = REG_ST3,
307  .dwarf_number = 14,
308  .encoding = 3,
309  .is_virtual = false,
310  },
311  {
312  .name = "st(4)",
313  .cls = &ia32_reg_classes[CLASS_ia32_fp],
314  .single_req = &ia32_single_reg_req_fp_st4,
315  .index = REG_FP_ST4,
316  .global_index = REG_ST4,
317  .dwarf_number = 15,
318  .encoding = 4,
319  .is_virtual = false,
320  },
321  {
322  .name = "st(5)",
323  .cls = &ia32_reg_classes[CLASS_ia32_fp],
324  .single_req = &ia32_single_reg_req_fp_st5,
325  .index = REG_FP_ST5,
326  .global_index = REG_ST5,
327  .dwarf_number = 16,
328  .encoding = 5,
329  .is_virtual = false,
330  },
331  {
332  .name = "st(6)",
333  .cls = &ia32_reg_classes[CLASS_ia32_fp],
334  .single_req = &ia32_single_reg_req_fp_st6,
335  .index = REG_FP_ST6,
336  .global_index = REG_ST6,
337  .dwarf_number = 17,
338  .encoding = 6,
339  .is_virtual = false,
340  },
341  {
342  .name = "st(7)",
343  .cls = &ia32_reg_classes[CLASS_ia32_fp],
344  .single_req = &ia32_single_reg_req_fp_st7,
345  .index = REG_FP_ST7,
346  .global_index = REG_ST7,
347  .dwarf_number = 18,
348  .encoding = 7,
349  .is_virtual = false,
350  },
351  {
352  .name = "fp_NOREG",
353  .cls = &ia32_reg_classes[CLASS_ia32_fp],
354  .single_req = &ia32_single_reg_req_fp_fp_NOREG,
355  .index = REG_FP_FP_NOREG,
356  .global_index = REG_FP_NOREG,
357  .dwarf_number = 0,
358  .encoding = REG_FP_FP_NOREG,
359  .is_virtual = true,
360  },
361  {
362  .name = "fpcw",
363  .cls = &ia32_reg_classes[CLASS_ia32_fp_cw],
364  .single_req = &ia32_single_reg_req_fp_cw_fpcw,
365  .index = REG_FP_CW_FPCW,
366  .global_index = REG_FPCW,
367  .dwarf_number = 37,
368  .encoding = REG_FP_CW_FPCW,
369  .is_virtual = false,
370  },
371  {
372  .name = "edx",
373  .cls = &ia32_reg_classes[CLASS_ia32_gp],
374  .single_req = &ia32_single_reg_req_gp_edx,
375  .index = REG_GP_EDX,
376  .global_index = REG_EDX,
377  .dwarf_number = 2,
378  .encoding = 2,
379  .is_virtual = false,
380  },
381  {
382  .name = "ecx",
383  .cls = &ia32_reg_classes[CLASS_ia32_gp],
384  .single_req = &ia32_single_reg_req_gp_ecx,
385  .index = REG_GP_ECX,
386  .global_index = REG_ECX,
387  .dwarf_number = 1,
388  .encoding = 1,
389  .is_virtual = false,
390  },
391  {
392  .name = "eax",
393  .cls = &ia32_reg_classes[CLASS_ia32_gp],
394  .single_req = &ia32_single_reg_req_gp_eax,
395  .index = REG_GP_EAX,
396  .global_index = REG_EAX,
397  .dwarf_number = 0,
398  .encoding = 0,
399  .is_virtual = false,
400  },
401  {
402  .name = "ebx",
403  .cls = &ia32_reg_classes[CLASS_ia32_gp],
404  .single_req = &ia32_single_reg_req_gp_ebx,
405  .index = REG_GP_EBX,
406  .global_index = REG_EBX,
407  .dwarf_number = 3,
408  .encoding = 3,
409  .is_virtual = false,
410  },
411  {
412  .name = "esi",
413  .cls = &ia32_reg_classes[CLASS_ia32_gp],
414  .single_req = &ia32_single_reg_req_gp_esi,
415  .index = REG_GP_ESI,
416  .global_index = REG_ESI,
417  .dwarf_number = 6,
418  .encoding = 6,
419  .is_virtual = false,
420  },
421  {
422  .name = "edi",
423  .cls = &ia32_reg_classes[CLASS_ia32_gp],
424  .single_req = &ia32_single_reg_req_gp_edi,
425  .index = REG_GP_EDI,
426  .global_index = REG_EDI,
427  .dwarf_number = 7,
428  .encoding = 7,
429  .is_virtual = false,
430  },
431  {
432  .name = "ebp",
433  .cls = &ia32_reg_classes[CLASS_ia32_gp],
434  .single_req = &ia32_single_reg_req_gp_ebp,
435  .index = REG_GP_EBP,
436  .global_index = REG_EBP,
437  .dwarf_number = 5,
438  .encoding = 5,
439  .is_virtual = false,
440  },
441  {
442  .name = "esp",
443  .cls = &ia32_reg_classes[CLASS_ia32_gp],
444  .single_req = &ia32_single_reg_req_gp_esp,
445  .index = REG_GP_ESP,
446  .global_index = REG_ESP,
447  .dwarf_number = 4,
448  .encoding = 4,
449  .is_virtual = false,
450  },
451  {
452  .name = "gp_NOREG",
453  .cls = &ia32_reg_classes[CLASS_ia32_gp],
454  .single_req = &ia32_single_reg_req_gp_gp_NOREG,
455  .index = REG_GP_GP_NOREG,
456  .global_index = REG_GP_NOREG,
457  .dwarf_number = 0,
458  .encoding = REG_GP_GP_NOREG,
459  .is_virtual = true,
460  },
461  {
462  .name = "xmm0",
463  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
464  .single_req = &ia32_single_reg_req_xmm_xmm0,
465  .index = REG_XMM_XMM0,
466  .global_index = REG_XMM0,
467  .dwarf_number = 21,
468  .encoding = REG_XMM_XMM0,
469  .is_virtual = false,
470  },
471  {
472  .name = "xmm1",
473  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
474  .single_req = &ia32_single_reg_req_xmm_xmm1,
475  .index = REG_XMM_XMM1,
476  .global_index = REG_XMM1,
477  .dwarf_number = 22,
478  .encoding = REG_XMM_XMM1,
479  .is_virtual = false,
480  },
481  {
482  .name = "xmm2",
483  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
484  .single_req = &ia32_single_reg_req_xmm_xmm2,
485  .index = REG_XMM_XMM2,
486  .global_index = REG_XMM2,
487  .dwarf_number = 23,
488  .encoding = REG_XMM_XMM2,
489  .is_virtual = false,
490  },
491  {
492  .name = "xmm3",
493  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
494  .single_req = &ia32_single_reg_req_xmm_xmm3,
495  .index = REG_XMM_XMM3,
496  .global_index = REG_XMM3,
497  .dwarf_number = 24,
498  .encoding = REG_XMM_XMM3,
499  .is_virtual = false,
500  },
501  {
502  .name = "xmm4",
503  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
504  .single_req = &ia32_single_reg_req_xmm_xmm4,
505  .index = REG_XMM_XMM4,
506  .global_index = REG_XMM4,
507  .dwarf_number = 25,
508  .encoding = REG_XMM_XMM4,
509  .is_virtual = false,
510  },
511  {
512  .name = "xmm5",
513  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
514  .single_req = &ia32_single_reg_req_xmm_xmm5,
515  .index = REG_XMM_XMM5,
516  .global_index = REG_XMM5,
517  .dwarf_number = 26,
518  .encoding = REG_XMM_XMM5,
519  .is_virtual = false,
520  },
521  {
522  .name = "xmm6",
523  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
524  .single_req = &ia32_single_reg_req_xmm_xmm6,
525  .index = REG_XMM_XMM6,
526  .global_index = REG_XMM6,
527  .dwarf_number = 27,
528  .encoding = REG_XMM_XMM6,
529  .is_virtual = false,
530  },
531  {
532  .name = "xmm7",
533  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
534  .single_req = &ia32_single_reg_req_xmm_xmm7,
535  .index = REG_XMM_XMM7,
536  .global_index = REG_XMM7,
537  .dwarf_number = 28,
538  .encoding = REG_XMM_XMM7,
539  .is_virtual = false,
540  },
541  {
542  .name = "xmm_NOREG",
543  .cls = &ia32_reg_classes[CLASS_ia32_xmm],
544  .single_req = &ia32_single_reg_req_xmm_xmm_NOREG,
545  .index = REG_XMM_XMM_NOREG,
546  .global_index = REG_XMM_NOREG,
547  .dwarf_number = 0,
548  .encoding = REG_XMM_XMM_NOREG,
549  .is_virtual = true,
550  },
551 
552 };
553 
557 void ia32_register_init(void)
558 {
559  ia32_reg_classes[CLASS_ia32_flags].mode = ia32_mode_flags;
560  ia32_reg_classes[CLASS_ia32_fp].mode = x86_mode_E;
561  ia32_reg_classes[CLASS_ia32_fp_cw].mode = ia32_mode_fpcw;
562  ia32_reg_classes[CLASS_ia32_gp].mode = ia32_mode_gp;
563  ia32_reg_classes[CLASS_ia32_xmm].mode = ia32_mode_float64;
564 
565 }