From 3a27875a3d20a11ce973fb1e2701b98f2c9dc07f Mon Sep 17 00:00:00 2001
From: Erik de Castro Lopo <erikd@mega-nerd.com>
Date: Fri, 20 Jul 2012 11:56:19 +1000
Subject: [PATCH] Reduce the likelihood of x64/x86-64 changes breaking the
build on other arches (#7083).
Code that needs to differentiate between i386 and x86-64 should now
be written as if x86-64 is the default and i386 is the special case.
Eg:
# if i386_TARGET_ARCH
someFuncion = .....
# else
someFuncion = .....
# endif
---
compiler/nativeGen/X86/Regs.hs | 56 ++++++++++++++--------------------------
1 file changed, 20 insertions(+), 36 deletions(-)
diff --git a/compiler/nativeGen/X86/Regs.hs b/compiler/nativeGen/X86/Regs.hs
index 854df0d..a3a257f 100644
|
a
|
b
|
|
| 51 | 51 | #include "nativeGen/NCG.h" |
| 52 | 52 | #include "HsVersions.h" |
| 53 | 53 | |
| | 54 | #if i386_TARGET_ARCH == 0 && x86_64_TARGET_ARCH == 0 |
| | 55 | -- Compiling for some arch other than Intel so we choose x86-64 as default. |
| | 56 | #undef arm_TARGET_ARCH |
| | 57 | #undef powerpc_TARGET_ARCH |
| | 58 | #undef powerpc64_TARGET_ARCH |
| | 59 | #undef sparc_TARGET_ARCH |
| | 60 | |
| | 61 | #undef x86_64_TARGET_ARCH |
| | 62 | #define x86_64_TARGET_ARCH 1 |
| | 63 | #endif |
| | 64 | |
| 54 | 65 | #include "../includes/stg/MachRegs.h" |
| 55 | 66 | |
| 56 | 67 | import Reg |
| … |
… |
|
| 411 | 422 | allFPArgRegs :: [Reg] |
| 412 | 423 | callClobberedRegs :: [Reg] |
| 413 | 424 | |
| 414 | | #if defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH) |
| 415 | | |
| 416 | 425 | #if i386_TARGET_ARCH |
| 417 | 426 | #define eax 0 |
| 418 | 427 | #define ebx 1 |
| … |
… |
|
| 588 | 597 | |
| 589 | 598 | -- |
| 590 | 599 | |
| 591 | | #if defined(mingw32_HOST_OS) && x86_64_TARGET_ARCH |
| | 600 | #if defined(mingw32_HOST_OS) |
| 592 | 601 | |
| 593 | 602 | allArgRegs = zip (map regSingle [rcx,rdx,r8,r9]) |
| 594 | 603 | (map regSingle [firstxmm ..]) |
| 595 | 604 | allIntArgRegs = panic "X86.Regs.allIntArgRegs: not defined for this platform" |
| 596 | 605 | allFPArgRegs = panic "X86.Regs.allFPArgRegs: not defined for this platform" |
| 597 | 606 | |
| 598 | | #else |
| | 607 | #elif i386_TARGET_ARCH |
| 599 | 608 | |
| 600 | 609 | allArgRegs = panic "X86.Regs.allArgRegs: not defined for this arch" |
| 601 | | |
| 602 | | # if i386_TARGET_ARCH |
| 603 | 610 | allIntArgRegs = panic "X86.Regs.allIntArgRegs: should not be used!" |
| 604 | | # elif x86_64_TARGET_ARCH |
| 605 | | allIntArgRegs = map regSingle [rdi,rsi,rdx,rcx,r8,r9] |
| 606 | | # else |
| 607 | | allIntArgRegs = panic "X86.Regs.allIntArgRegs: not defined for this arch" |
| 608 | | # endif |
| | 611 | allFPArgRegs = map regSingle [firstxmm .. firstxmm+7] |
| | 612 | |
| | 613 | #else |
| 609 | 614 | |
| | 615 | allArgRegs = panic "X86.Regs.allArgRegs: not defined for this arch" |
| | 616 | allIntArgRegs = map regSingle [rdi,rsi,rdx,rcx,r8,r9] |
| 610 | 617 | allFPArgRegs = map regSingle [firstxmm .. firstxmm+7] |
| 611 | 618 | |
| 612 | 619 | #endif |
| … |
… |
|
| 621 | 628 | instrClobberedRegs :: [RealReg] |
| 622 | 629 | #if i386_TARGET_ARCH |
| 623 | 630 | instrClobberedRegs = map RealRegSingle [ eax, ecx, edx ] |
| 624 | | #elif x86_64_TARGET_ARCH |
| | 631 | #else |
| 625 | 632 | instrClobberedRegs = map RealRegSingle [ rax, rcx, rdx ] |
| 626 | 633 | #endif |
| 627 | 634 | |
| … |
… |
|
| 632 | 639 | callClobberedRegs |
| 633 | 640 | = map regSingle ([eax,ecx,edx] ++ floatregnos) |
| 634 | 641 | |
| 635 | | #elif x86_64_TARGET_ARCH |
| | 642 | #else |
| 636 | 643 | -- all xmm regs are caller-saves |
| 637 | 644 | -- caller-saves registers |
| 638 | 645 | callClobberedRegs |
| 639 | 646 | = map regSingle ([rax,rcx,rdx,rsi,rdi,r8,r9,r10,r11] ++ floatregnos) |
| 640 | 647 | |
| 641 | | #else |
| 642 | | callClobberedRegs |
| 643 | | = panic "X86.Regs.callClobberedRegs: not defined for this architecture" |
| 644 | | #endif |
| 645 | | |
| 646 | | #else /* i386_TARGET_ARCH || x86_64_TARGET_ARCH */ |
| 647 | | |
| 648 | | |
| 649 | | |
| 650 | | freeReg _ = 0# |
| 651 | | globalRegMaybe _ = panic "X86.Regs.globalRegMaybe: not defined" |
| 652 | | |
| 653 | | allArgRegs = panic "X86.Regs.allArgRegs: not defined" |
| 654 | | allIntArgRegs = panic "X86.Regs.allIntArgRegs: not defined" |
| 655 | | allFPArgRegs = panic "X86.Regs.allFPArgRegs: not defined" |
| 656 | | callClobberedRegs = panic "X86.Regs.callClobberedRegs: not defined" |
| 657 | | |
| 658 | | instrClobberedRegs :: [RealReg] |
| 659 | | instrClobberedRegs = panic "X86.Regs.instrClobberedRegs: not defined for this arch" |
| 660 | | |
| 661 | | allHaskellArgRegs :: [Reg] |
| 662 | | allHaskellArgRegs = panic "X86.Regs.allHaskellArgRegs: not defined for this arch" |
| 663 | | |
| 664 | 648 | #endif |
| 665 | 649 | |
| 666 | 650 | -- allocatableRegs is allMachRegNos with the fixed-use regs removed. |