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