fix a mistyped label that caused a stray reference
[ghc.git] / includes / CodeGen.Platform.hs
1
2 import CmmExpr
3 import FastBool
4 #if !(MACHREGS_i386 || MACHREGS_x86_64 || MACHREGS_sparc || MACHREGS_powerpc)
5 import Panic
6 #endif
7 import Reg
8
9 #include "ghcautoconf.h"
10 #include "stg/MachRegs.h"
11
12 #if MACHREGS_i386 || MACHREGS_x86_64
13
14 # if MACHREGS_i386
15 # define eax 0
16 # define ebx 1
17 # define ecx 2
18 # define edx 3
19 # define esi 4
20 # define edi 5
21 # define ebp 6
22 # define esp 7
23 # endif
24
25 # if MACHREGS_x86_64
26 # define rax 0
27 # define rbx 1
28 # define rcx 2
29 # define rdx 3
30 # define rsi 4
31 # define rdi 5
32 # define rbp 6
33 # define rsp 7
34 # define r8 8
35 # define r9 9
36 # define r10 10
37 # define r11 11
38 # define r12 12
39 # define r13 13
40 # define r14 14
41 # define r15 15
42 # endif
43
44 # define fake0 16
45 # define fake1 17
46 # define fake2 18
47 # define fake3 19
48 # define fake4 20
49 # define fake5 21
50
51 # define xmm0 24
52 # define xmm1 25
53 # define xmm2 26
54 # define xmm3 27
55 # define xmm4 28
56 # define xmm5 29
57 # define xmm6 30
58 # define xmm7 31
59 # define xmm8 32
60 # define xmm9 33
61 # define xmm10 34
62 # define xmm11 35
63 # define xmm12 36
64 # define xmm13 37
65 # define xmm14 38
66 # define xmm15 39
67
68 # define ymm0 40
69 # define ymm1 41
70 # define ymm2 42
71 # define ymm3 43
72 # define ymm4 44
73 # define ymm5 45
74 # define ymm6 46
75 # define ymm7 47
76 # define ymm8 48
77 # define ymm9 49
78 # define ymm10 50
79 # define ymm11 51
80 # define ymm12 52
81 # define ymm13 53
82 # define ymm14 54
83 # define ymm15 55
84
85 # define zmm0 56
86 # define zmm1 57
87 # define zmm2 58
88 # define zmm3 59
89 # define zmm4 60
90 # define zmm5 61
91 # define zmm6 62
92 # define zmm7 63
93 # define zmm8 64
94 # define zmm9 65
95 # define zmm10 66
96 # define zmm11 67
97 # define zmm12 68
98 # define zmm13 69
99 # define zmm14 70
100 # define zmm15 71
101
102 #elif MACHREGS_powerpc
103
104 # define r0 0
105 # define r1 1
106 # define r2 2
107 # define r3 3
108 # define r4 4
109 # define r5 5
110 # define r6 6
111 # define r7 7
112 # define r8 8
113 # define r9 9
114 # define r10 10
115 # define r11 11
116 # define r12 12
117 # define r13 13
118 # define r14 14
119 # define r15 15
120 # define r16 16
121 # define r17 17
122 # define r18 18
123 # define r19 19
124 # define r20 20
125 # define r21 21
126 # define r22 22
127 # define r23 23
128 # define r24 24
129 # define r25 25
130 # define r26 26
131 # define r27 27
132 # define r28 28
133 # define r29 29
134 # define r30 30
135 # define r31 31
136
137 # if MACHREGS_darwin
138 # define f0 32
139 # define f1 33
140 # define f2 34
141 # define f3 35
142 # define f4 36
143 # define f5 37
144 # define f6 38
145 # define f7 39
146 # define f8 40
147 # define f9 41
148 # define f10 42
149 # define f11 43
150 # define f12 44
151 # define f13 45
152 # define f14 46
153 # define f15 47
154 # define f16 48
155 # define f17 49
156 # define f18 50
157 # define f19 51
158 # define f20 52
159 # define f21 53
160 # define f22 54
161 # define f23 55
162 # define f24 56
163 # define f25 57
164 # define f26 58
165 # define f27 59
166 # define f28 60
167 # define f29 61
168 # define f30 62
169 # define f31 63
170 # else
171 # define fr0 32
172 # define fr1 33
173 # define fr2 34
174 # define fr3 35
175 # define fr4 36
176 # define fr5 37
177 # define fr6 38
178 # define fr7 39
179 # define fr8 40
180 # define fr9 41
181 # define fr10 42
182 # define fr11 43
183 # define fr12 44
184 # define fr13 45
185 # define fr14 46
186 # define fr15 47
187 # define fr16 48
188 # define fr17 49
189 # define fr18 50
190 # define fr19 51
191 # define fr20 52
192 # define fr21 53
193 # define fr22 54
194 # define fr23 55
195 # define fr24 56
196 # define fr25 57
197 # define fr26 58
198 # define fr27 59
199 # define fr28 60
200 # define fr29 61
201 # define fr30 62
202 # define fr31 63
203 # endif
204
205 #elif MACHREGS_sparc
206
207 # define g0 0
208 # define g1 1
209 # define g2 2
210 # define g3 3
211 # define g4 4
212 # define g5 5
213 # define g6 6
214 # define g7 7
215
216 # define o0 8
217 # define o1 9
218 # define o2 10
219 # define o3 11
220 # define o4 12
221 # define o5 13
222 # define o6 14
223 # define o7 15
224
225 # define l0 16
226 # define l1 17
227 # define l2 18
228 # define l3 19
229 # define l4 20
230 # define l5 21
231 # define l6 22
232 # define l7 23
233
234 # define i0 24
235 # define i1 25
236 # define i2 26
237 # define i3 27
238 # define i4 28
239 # define i5 29
240 # define i6 30
241 # define i7 31
242
243 # define f0 32
244 # define f1 33
245 # define f2 34
246 # define f3 35
247 # define f4 36
248 # define f5 37
249 # define f6 38
250 # define f7 39
251 # define f8 40
252 # define f9 41
253 # define f10 42
254 # define f11 43
255 # define f12 44
256 # define f13 45
257 # define f14 46
258 # define f15 47
259 # define f16 48
260 # define f17 49
261 # define f18 50
262 # define f19 51
263 # define f20 52
264 # define f21 53
265 # define f22 54
266 # define f23 55
267 # define f24 56
268 # define f25 57
269 # define f26 58
270 # define f27 59
271 # define f28 60
272 # define f29 61
273 # define f30 62
274 # define f31 63
275
276 #endif
277
278 callerSaves :: GlobalReg -> Bool
279 #ifdef CALLER_SAVES_Base
280 callerSaves BaseReg = True
281 #endif
282 #ifdef CALLER_SAVES_R1
283 callerSaves (VanillaReg 1 _) = True
284 #endif
285 #ifdef CALLER_SAVES_R2
286 callerSaves (VanillaReg 2 _) = True
287 #endif
288 #ifdef CALLER_SAVES_R3
289 callerSaves (VanillaReg 3 _) = True
290 #endif
291 #ifdef CALLER_SAVES_R4
292 callerSaves (VanillaReg 4 _) = True
293 #endif
294 #ifdef CALLER_SAVES_R5
295 callerSaves (VanillaReg 5 _) = True
296 #endif
297 #ifdef CALLER_SAVES_R6
298 callerSaves (VanillaReg 6 _) = True
299 #endif
300 #ifdef CALLER_SAVES_R7
301 callerSaves (VanillaReg 7 _) = True
302 #endif
303 #ifdef CALLER_SAVES_R8
304 callerSaves (VanillaReg 8 _) = True
305 #endif
306 #ifdef CALLER_SAVES_R9
307 callerSaves (VanillaReg 9 _) = True
308 #endif
309 #ifdef CALLER_SAVES_R10
310 callerSaves (VanillaReg 10 _) = True
311 #endif
312 #ifdef CALLER_SAVES_F1
313 callerSaves (FloatReg 1) = True
314 #endif
315 #ifdef CALLER_SAVES_F2
316 callerSaves (FloatReg 2) = True
317 #endif
318 #ifdef CALLER_SAVES_F3
319 callerSaves (FloatReg 3) = True
320 #endif
321 #ifdef CALLER_SAVES_F4
322 callerSaves (FloatReg 4) = True
323 #endif
324 #ifdef CALLER_SAVES_F5
325 callerSaves (FloatReg 5) = True
326 #endif
327 #ifdef CALLER_SAVES_F6
328 callerSaves (FloatReg 6) = True
329 #endif
330 #ifdef CALLER_SAVES_D1
331 callerSaves (DoubleReg 1) = True
332 #endif
333 #ifdef CALLER_SAVES_D2
334 callerSaves (DoubleReg 2) = True
335 #endif
336 #ifdef CALLER_SAVES_D3
337 callerSaves (DoubleReg 3) = True
338 #endif
339 #ifdef CALLER_SAVES_D4
340 callerSaves (DoubleReg 4) = True
341 #endif
342 #ifdef CALLER_SAVES_D5
343 callerSaves (DoubleReg 5) = True
344 #endif
345 #ifdef CALLER_SAVES_D6
346 callerSaves (DoubleReg 6) = True
347 #endif
348 #ifdef CALLER_SAVES_L1
349 callerSaves (LongReg 1) = True
350 #endif
351 #ifdef CALLER_SAVES_Sp
352 callerSaves Sp = True
353 #endif
354 #ifdef CALLER_SAVES_SpLim
355 callerSaves SpLim = True
356 #endif
357 #ifdef CALLER_SAVES_Hp
358 callerSaves Hp = True
359 #endif
360 #ifdef CALLER_SAVES_HpLim
361 callerSaves HpLim = True
362 #endif
363 #ifdef CALLER_SAVES_CCCS
364 callerSaves CCCS = True
365 #endif
366 #ifdef CALLER_SAVES_CurrentTSO
367 callerSaves CurrentTSO = True
368 #endif
369 #ifdef CALLER_SAVES_CurrentNursery
370 callerSaves CurrentNursery = True
371 #endif
372 callerSaves _ = False
373
374 activeStgRegs :: [GlobalReg]
375 activeStgRegs = [
376 #ifdef REG_Base
377 BaseReg
378 #endif
379 #ifdef REG_Sp
380 ,Sp
381 #endif
382 #ifdef REG_Hp
383 ,Hp
384 #endif
385 #ifdef REG_R1
386 ,VanillaReg 1 VGcPtr
387 #endif
388 #ifdef REG_R2
389 ,VanillaReg 2 VGcPtr
390 #endif
391 #ifdef REG_R3
392 ,VanillaReg 3 VGcPtr
393 #endif
394 #ifdef REG_R4
395 ,VanillaReg 4 VGcPtr
396 #endif
397 #ifdef REG_R5
398 ,VanillaReg 5 VGcPtr
399 #endif
400 #ifdef REG_R6
401 ,VanillaReg 6 VGcPtr
402 #endif
403 #ifdef REG_R7
404 ,VanillaReg 7 VGcPtr
405 #endif
406 #ifdef REG_R8
407 ,VanillaReg 8 VGcPtr
408 #endif
409 #ifdef REG_R9
410 ,VanillaReg 9 VGcPtr
411 #endif
412 #ifdef REG_R10
413 ,VanillaReg 10 VGcPtr
414 #endif
415 #ifdef REG_SpLim
416 ,SpLim
417 #endif
418 #if MAX_REAL_XMM_REG != 0
419 #ifdef REG_F1
420 ,FloatReg 1
421 #endif
422 #ifdef REG_D1
423 ,DoubleReg 1
424 #endif
425 #ifdef REG_XMM1
426 ,XmmReg 1
427 #endif
428 #ifdef REG_YMM1
429 ,YmmReg 1
430 #endif
431 #ifdef REG_ZMM1
432 ,ZmmReg 1
433 #endif
434 #ifdef REG_F2
435 ,FloatReg 2
436 #endif
437 #ifdef REG_D2
438 ,DoubleReg 2
439 #endif
440 #ifdef REG_XMM2
441 ,XmmReg 2
442 #endif
443 #ifdef REG_YMM2
444 ,YmmReg 2
445 #endif
446 #ifdef REG_ZMM2
447 ,ZmmReg 2
448 #endif
449 #ifdef REG_F3
450 ,FloatReg 3
451 #endif
452 #ifdef REG_D3
453 ,DoubleReg 3
454 #endif
455 #ifdef REG_XMM3
456 ,XmmReg 3
457 #endif
458 #ifdef REG_YMM3
459 ,YmmReg 3
460 #endif
461 #ifdef REG_ZMM3
462 ,ZmmReg 3
463 #endif
464 #ifdef REG_F4
465 ,FloatReg 4
466 #endif
467 #ifdef REG_D4
468 ,DoubleReg 4
469 #endif
470 #ifdef REG_XMM4
471 ,XmmReg 4
472 #endif
473 #ifdef REG_YMM4
474 ,YmmReg 4
475 #endif
476 #ifdef REG_ZMM4
477 ,ZmmReg 4
478 #endif
479 #ifdef REG_F5
480 ,FloatReg 5
481 #endif
482 #ifdef REG_D5
483 ,DoubleReg 5
484 #endif
485 #ifdef REG_XMM5
486 ,XmmReg 5
487 #endif
488 #ifdef REG_YMM5
489 ,YmmReg 5
490 #endif
491 #ifdef REG_ZMM5
492 ,ZmmReg 5
493 #endif
494 #ifdef REG_F6
495 ,FloatReg 6
496 #endif
497 #ifdef REG_D6
498 ,DoubleReg 6
499 #endif
500 #ifdef REG_XMM6
501 ,XmmReg 6
502 #endif
503 #ifdef REG_YMM6
504 ,YmmReg 6
505 #endif
506 #ifdef REG_ZMM6
507 ,ZmmReg 6
508 #endif
509 #else /* MAX_REAL_XMM_REG == 0 */
510 #ifdef REG_F1
511 ,FloatReg 1
512 #endif
513 #ifdef REG_F2
514 ,FloatReg 2
515 #endif
516 #ifdef REG_F3
517 ,FloatReg 3
518 #endif
519 #ifdef REG_F4
520 ,FloatReg 4
521 #endif
522 #ifdef REG_F5
523 ,FloatReg 5
524 #endif
525 #ifdef REG_F6
526 ,FloatReg 6
527 #endif
528 #ifdef REG_D1
529 ,DoubleReg 1
530 #endif
531 #ifdef REG_D2
532 ,DoubleReg 2
533 #endif
534 #ifdef REG_D3
535 ,DoubleReg 3
536 #endif
537 #ifdef REG_D4
538 ,DoubleReg 4
539 #endif
540 #ifdef REG_D5
541 ,DoubleReg 5
542 #endif
543 #ifdef REG_D6
544 ,DoubleReg 6
545 #endif
546 #endif /* MAX_REAL_XMM_REG == 0 */
547 ]
548
549 haveRegBase :: Bool
550 #ifdef REG_Base
551 haveRegBase = True
552 #else
553 haveRegBase = False
554 #endif
555
556 -- | Returns 'Nothing' if this global register is not stored
557 -- in a real machine register, otherwise returns @'Just' reg@, where
558 -- reg is the machine register it is stored in.
559 globalRegMaybe :: GlobalReg -> Maybe RealReg
560 #if MACHREGS_i386 || MACHREGS_x86_64 || MACHREGS_sparc || MACHREGS_powerpc
561 # ifdef REG_Base
562 globalRegMaybe BaseReg = Just (RealRegSingle REG_Base)
563 # endif
564 # ifdef REG_R1
565 globalRegMaybe (VanillaReg 1 _) = Just (RealRegSingle REG_R1)
566 # endif
567 # ifdef REG_R2
568 globalRegMaybe (VanillaReg 2 _) = Just (RealRegSingle REG_R2)
569 # endif
570 # ifdef REG_R3
571 globalRegMaybe (VanillaReg 3 _) = Just (RealRegSingle REG_R3)
572 # endif
573 # ifdef REG_R4
574 globalRegMaybe (VanillaReg 4 _) = Just (RealRegSingle REG_R4)
575 # endif
576 # ifdef REG_R5
577 globalRegMaybe (VanillaReg 5 _) = Just (RealRegSingle REG_R5)
578 # endif
579 # ifdef REG_R6
580 globalRegMaybe (VanillaReg 6 _) = Just (RealRegSingle REG_R6)
581 # endif
582 # ifdef REG_R7
583 globalRegMaybe (VanillaReg 7 _) = Just (RealRegSingle REG_R7)
584 # endif
585 # ifdef REG_R8
586 globalRegMaybe (VanillaReg 8 _) = Just (RealRegSingle REG_R8)
587 # endif
588 # ifdef REG_R9
589 globalRegMaybe (VanillaReg 9 _) = Just (RealRegSingle REG_R9)
590 # endif
591 # ifdef REG_R10
592 globalRegMaybe (VanillaReg 10 _) = Just (RealRegSingle REG_R10)
593 # endif
594 # ifdef REG_F1
595 globalRegMaybe (FloatReg 1) = Just (RealRegSingle REG_F1)
596 # endif
597 # ifdef REG_F2
598 globalRegMaybe (FloatReg 2) = Just (RealRegSingle REG_F2)
599 # endif
600 # ifdef REG_F3
601 globalRegMaybe (FloatReg 3) = Just (RealRegSingle REG_F3)
602 # endif
603 # ifdef REG_F4
604 globalRegMaybe (FloatReg 4) = Just (RealRegSingle REG_F4)
605 # endif
606 # ifdef REG_F5
607 globalRegMaybe (FloatReg 5) = Just (RealRegSingle REG_F5)
608 # endif
609 # ifdef REG_F6
610 globalRegMaybe (FloatReg 6) = Just (RealRegSingle REG_F6)
611 # endif
612 # ifdef REG_D1
613 globalRegMaybe (DoubleReg 1) =
614 # if MACHREGS_sparc
615 Just (RealRegPair REG_D1 (REG_D1 + 1))
616 # else
617 Just (RealRegSingle REG_D1)
618 # endif
619 # endif
620 # ifdef REG_D2
621 globalRegMaybe (DoubleReg 2) =
622 # if MACHREGS_sparc
623 Just (RealRegPair REG_D2 (REG_D2 + 1))
624 # else
625 Just (RealRegSingle REG_D2)
626 # endif
627 # endif
628 # ifdef REG_D3
629 globalRegMaybe (DoubleReg 3) =
630 # if MACHREGS_sparc
631 Just (RealRegPair REG_D3 (REG_D3 + 1))
632 # else
633 Just (RealRegSingle REG_D3)
634 # endif
635 # endif
636 # ifdef REG_D4
637 globalRegMaybe (DoubleReg 4) =
638 # if MACHREGS_sparc
639 Just (RealRegPair REG_D4 (REG_D4 + 1))
640 # else
641 Just (RealRegSingle REG_D4)
642 # endif
643 # endif
644 # ifdef REG_D5
645 globalRegMaybe (DoubleReg 5) =
646 # if MACHREGS_sparc
647 Just (RealRegPair REG_D5 (REG_D5 + 1))
648 # else
649 Just (RealRegSingle REG_D5)
650 # endif
651 # endif
652 # ifdef REG_D6
653 globalRegMaybe (DoubleReg 6) =
654 # if MACHREGS_sparc
655 Just (RealRegPair REG_D6 (REG_D6 + 1))
656 # else
657 Just (RealRegSingle REG_D6)
658 # endif
659 # endif
660 # if MAX_REAL_XMM_REG != 0
661 # ifdef REG_XMM1
662 globalRegMaybe (XmmReg 1) = Just (RealRegSingle REG_XMM1)
663 # endif
664 # ifdef REG_XMM2
665 globalRegMaybe (XmmReg 2) = Just (RealRegSingle REG_XMM2)
666 # endif
667 # ifdef REG_XMM3
668 globalRegMaybe (XmmReg 3) = Just (RealRegSingle REG_XMM3)
669 # endif
670 # ifdef REG_XMM4
671 globalRegMaybe (XmmReg 4) = Just (RealRegSingle REG_XMM4)
672 # endif
673 # ifdef REG_XMM5
674 globalRegMaybe (XmmReg 5) = Just (RealRegSingle REG_XMM5)
675 # endif
676 # ifdef REG_XMM6
677 globalRegMaybe (XmmReg 6) = Just (RealRegSingle REG_XMM6)
678 # endif
679 # endif
680 # if MAX_REAL_YMM_REG != 0
681 # ifdef REG_YMM1
682 globalRegMaybe (YmmReg 1) = Just (RealRegSingle REG_YMM1)
683 # endif
684 # ifdef REG_YMM2
685 globalRegMaybe (YmmReg 2) = Just (RealRegSingle REG_YMM2)
686 # endif
687 # ifdef REG_YMM3
688 globalRegMaybe (YmmReg 3) = Just (RealRegSingle REG_YMM3)
689 # endif
690 # ifdef REG_YMM4
691 globalRegMaybe (YmmReg 4) = Just (RealRegSingle REG_YMM4)
692 # endif
693 # ifdef REG_YMM5
694 globalRegMaybe (YmmReg 5) = Just (RealRegSingle REG_YMM5)
695 # endif
696 # ifdef REG_YMM6
697 globalRegMaybe (YmmReg 6) = Just (RealRegSingle REG_YMM6)
698 # endif
699 # endif
700 # if MAX_REAL_ZMM_REG != 0
701 # ifdef REG_ZMM1
702 globalRegMaybe (ZmmReg 1) = Just (RealRegSingle REG_ZMM1)
703 # endif
704 # ifdef REG_ZMM2
705 globalRegMaybe (ZmmReg 2) = Just (RealRegSingle REG_ZMM2)
706 # endif
707 # ifdef REG_ZMM3
708 globalRegMaybe (ZmmReg 3) = Just (RealRegSingle REG_ZMM3)
709 # endif
710 # ifdef REG_ZMM4
711 globalRegMaybe (ZmmReg 4) = Just (RealRegSingle REG_ZMM4)
712 # endif
713 # ifdef REG_ZMM5
714 globalRegMaybe (ZmmReg 5) = Just (RealRegSingle REG_ZMM5)
715 # endif
716 # ifdef REG_ZMM6
717 globalRegMaybe (ZmmReg 6) = Just (RealRegSingle REG_ZMM6)
718 # endif
719 # endif
720 # ifdef REG_Sp
721 globalRegMaybe Sp = Just (RealRegSingle REG_Sp)
722 # endif
723 # ifdef REG_Lng1
724 globalRegMaybe (LongReg 1) = Just (RealRegSingle REG_Lng1)
725 # endif
726 # ifdef REG_Lng2
727 globalRegMaybe (LongReg 2) = Just (RealRegSingle REG_Lng2)
728 # endif
729 # ifdef REG_SpLim
730 globalRegMaybe SpLim = Just (RealRegSingle REG_SpLim)
731 # endif
732 # ifdef REG_Hp
733 globalRegMaybe Hp = Just (RealRegSingle REG_Hp)
734 # endif
735 # ifdef REG_HpLim
736 globalRegMaybe HpLim = Just (RealRegSingle REG_HpLim)
737 # endif
738 # ifdef REG_CurrentTSO
739 globalRegMaybe CurrentTSO = Just (RealRegSingle REG_CurrentTSO)
740 # endif
741 # ifdef REG_CurrentNursery
742 globalRegMaybe CurrentNursery = Just (RealRegSingle REG_CurrentNursery)
743 # endif
744 globalRegMaybe _ = Nothing
745 #else
746 globalRegMaybe = panic "globalRegMaybe not defined for this platform"
747 #endif
748
749 freeReg :: RegNo -> FastBool
750
751 #if MACHREGS_i386 || MACHREGS_x86_64
752
753 # if MACHREGS_i386
754 freeReg esp = fastBool False -- %esp is the C stack pointer
755 freeReg esi = fastBool False -- Note [esi/edi not allocatable]
756 freeReg edi = fastBool False
757 # endif
758 # if MACHREGS_x86_64
759 freeReg rsp = fastBool False -- %rsp is the C stack pointer
760 # endif
761
762 {-
763 Note [esi/edi not allocatable]
764
765 %esi is mapped to R1, so %esi would normally be allocatable while it
766 is not being used for R1. However, %esi has no 8-bit version on x86,
767 and the linear register allocator is not sophisticated enough to
768 handle this irregularity (we need more RegClasses). The
769 graph-colouring allocator also cannot handle this - it was designed
770 with more flexibility in mind, but the current implementation is
771 restricted to the same set of classes as the linear allocator.
772
773 Hence, on x86 esi and edi are treated as not allocatable.
774 -}
775
776 -- split patterns in two functions to prevent overlaps
777 freeReg r = freeRegBase r
778
779 freeRegBase :: RegNo -> FastBool
780 # ifdef REG_Base
781 freeRegBase REG_Base = fastBool False
782 # endif
783 # ifdef REG_Sp
784 freeRegBase REG_Sp = fastBool False
785 # endif
786 # ifdef REG_SpLim
787 freeRegBase REG_SpLim = fastBool False
788 # endif
789 # ifdef REG_Hp
790 freeRegBase REG_Hp = fastBool False
791 # endif
792 # ifdef REG_HpLim
793 freeRegBase REG_HpLim = fastBool False
794 # endif
795 -- All other regs are considered to be "free", because we can track
796 -- their liveness accurately.
797 freeRegBase _ = fastBool True
798
799 #elif MACHREGS_powerpc
800
801 freeReg 0 = fastBool False -- Hack: r0 can't be used in all insns,
802 -- but it's actually free
803 freeReg 1 = fastBool False -- The Stack Pointer
804 # if !MACHREGS_darwin
805 -- most non-darwin powerpc OSes use r2 as a TOC pointer or something like that
806 freeReg 2 = fastBool False
807 # endif
808 # ifdef REG_Base
809 freeReg REG_Base = fastBool False
810 # endif
811 # ifdef REG_R1
812 freeReg REG_R1 = fastBool False
813 # endif
814 # ifdef REG_R2
815 freeReg REG_R2 = fastBool False
816 # endif
817 # ifdef REG_R3
818 freeReg REG_R3 = fastBool False
819 # endif
820 # ifdef REG_R4
821 freeReg REG_R4 = fastBool False
822 # endif
823 # ifdef REG_R5
824 freeReg REG_R5 = fastBool False
825 # endif
826 # ifdef REG_R6
827 freeReg REG_R6 = fastBool False
828 # endif
829 # ifdef REG_R7
830 freeReg REG_R7 = fastBool False
831 # endif
832 # ifdef REG_R8
833 freeReg REG_R8 = fastBool False
834 # endif
835 # ifdef REG_R9
836 freeReg REG_R9 = fastBool False
837 # endif
838 # ifdef REG_R10
839 freeReg REG_R10 = fastBool False
840 # endif
841 # ifdef REG_F1
842 freeReg REG_F1 = fastBool False
843 # endif
844 # ifdef REG_F2
845 freeReg REG_F2 = fastBool False
846 # endif
847 # ifdef REG_F3
848 freeReg REG_F3 = fastBool False
849 # endif
850 # ifdef REG_F4
851 freeReg REG_F4 = fastBool False
852 # endif
853 # ifdef REG_F5
854 freeReg REG_F5 = fastBool False
855 # endif
856 # ifdef REG_F6
857 freeReg REG_F6 = fastBool False
858 # endif
859 # ifdef REG_D1
860 freeReg REG_D1 = fastBool False
861 # endif
862 # ifdef REG_D2
863 freeReg REG_D2 = fastBool False
864 # endif
865 # ifdef REG_D3
866 freeReg REG_D3 = fastBool False
867 # endif
868 # ifdef REG_D4
869 freeReg REG_D4 = fastBool False
870 # endif
871 # ifdef REG_D5
872 freeReg REG_D5 = fastBool False
873 # endif
874 # ifdef REG_D6
875 freeReg REG_D6 = fastBool False
876 # endif
877 # ifdef REG_Sp
878 freeReg REG_Sp = fastBool False
879 # endif
880 # ifdef REG_Su
881 freeReg REG_Su = fastBool False
882 # endif
883 # ifdef REG_SpLim
884 freeReg REG_SpLim = fastBool False
885 # endif
886 # ifdef REG_Hp
887 freeReg REG_Hp = fastBool False
888 # endif
889 # ifdef REG_HpLim
890 freeReg REG_HpLim = fastBool False
891 # endif
892 freeReg _ = fastBool True
893
894 #elif MACHREGS_sparc
895
896 -- SPARC regs used by the OS / ABI
897 -- %g0(r0) is always zero
898 freeReg g0 = fastBool False
899
900 -- %g5(r5) - %g7(r7)
901 -- are reserved for the OS
902 freeReg g5 = fastBool False
903 freeReg g6 = fastBool False
904 freeReg g7 = fastBool False
905
906 -- %o6(r14)
907 -- is the C stack pointer
908 freeReg o6 = fastBool False
909
910 -- %o7(r15)
911 -- holds the C return address
912 freeReg o7 = fastBool False
913
914 -- %i6(r30)
915 -- is the C frame pointer
916 freeReg i6 = fastBool False
917
918 -- %i7(r31)
919 -- is used for C return addresses
920 freeReg i7 = fastBool False
921
922 -- %f0(r32) - %f1(r32)
923 -- are C floating point return regs
924 freeReg f0 = fastBool False
925 freeReg f1 = fastBool False
926
927 {-
928 freeReg regNo
929 -- don't release high half of double regs
930 | regNo >= f0
931 , regNo < NCG_FirstFloatReg
932 , regNo `mod` 2 /= 0
933 = fastBool False
934 -}
935
936 # ifdef REG_Base
937 freeReg REG_Base = fastBool False
938 # endif
939 # ifdef REG_R1
940 freeReg REG_R1 = fastBool False
941 # endif
942 # ifdef REG_R2
943 freeReg REG_R2 = fastBool False
944 # endif
945 # ifdef REG_R3
946 freeReg REG_R3 = fastBool False
947 # endif
948 # ifdef REG_R4
949 freeReg REG_R4 = fastBool False
950 # endif
951 # ifdef REG_R5
952 freeReg REG_R5 = fastBool False
953 # endif
954 # ifdef REG_R6
955 freeReg REG_R6 = fastBool False
956 # endif
957 # ifdef REG_R7
958 freeReg REG_R7 = fastBool False
959 # endif
960 # ifdef REG_R8
961 freeReg REG_R8 = fastBool False
962 # endif
963 # ifdef REG_R9
964 freeReg REG_R9 = fastBool False
965 # endif
966 # ifdef REG_R10
967 freeReg REG_R10 = fastBool False
968 # endif
969 # ifdef REG_F1
970 freeReg REG_F1 = fastBool False
971 # endif
972 # ifdef REG_F2
973 freeReg REG_F2 = fastBool False
974 # endif
975 # ifdef REG_F3
976 freeReg REG_F3 = fastBool False
977 # endif
978 # ifdef REG_F4
979 freeReg REG_F4 = fastBool False
980 # endif
981 # ifdef REG_F5
982 freeReg REG_F5 = fastBool False
983 # endif
984 # ifdef REG_F6
985 freeReg REG_F6 = fastBool False
986 # endif
987 # ifdef REG_D1
988 freeReg REG_D1 = fastBool False
989 # endif
990 # ifdef REG_D1_2
991 freeReg REG_D1_2 = fastBool False
992 # endif
993 # ifdef REG_D2
994 freeReg REG_D2 = fastBool False
995 # endif
996 # ifdef REG_D2_2
997 freeReg REG_D2_2 = fastBool False
998 # endif
999 # ifdef REG_D3
1000 freeReg REG_D3 = fastBool False
1001 # endif
1002 # ifdef REG_D3_2
1003 freeReg REG_D3_2 = fastBool False
1004 # endif
1005 # ifdef REG_D4
1006 freeReg REG_D4 = fastBool False
1007 # endif
1008 # ifdef REG_D4_2
1009 freeReg REG_D4_2 = fastBool False
1010 # endif
1011 # ifdef REG_D5
1012 freeReg REG_D5 = fastBool False
1013 # endif
1014 # ifdef REG_D5_2
1015 freeReg REG_D5_2 = fastBool False
1016 # endif
1017 # ifdef REG_D6
1018 freeReg REG_D6 = fastBool False
1019 # endif
1020 # ifdef REG_D6_2
1021 freeReg REG_D6_2 = fastBool False
1022 # endif
1023 # ifdef REG_Sp
1024 freeReg REG_Sp = fastBool False
1025 # endif
1026 # ifdef REG_Su
1027 freeReg REG_Su = fastBool False
1028 # endif
1029 # ifdef REG_SpLim
1030 freeReg REG_SpLim = fastBool False
1031 # endif
1032 # ifdef REG_Hp
1033 freeReg REG_Hp = fastBool False
1034 # endif
1035 # ifdef REG_HpLim
1036 freeReg REG_HpLim = fastBool False
1037 # endif
1038 freeReg _ = fastBool True
1039
1040 #else
1041
1042 freeReg = panic "freeReg not defined for this platform"
1043
1044 #endif
1045