Ticket #7083: 0001-Reduce-the-likelihood-of-x64-x86-64-changes-breaking.2.patch

File 0001-Reduce-the-likelihood-of-x64-x86-64-changes-breaking.2.patch, 4.0 KB (added by erikd, 20 months ago)

Updated version of the patch.

  • compiler/nativeGen/X86/Regs.hs

    From 326a4c23846a979e197ed5a971fc9dd4a328e0b9 Mon Sep 17 00:00:00 2001
    From: Erik de Castro Lopo <erikd@mega-nerd.com>
    Date: Wed, 8 Aug 2012 06:44:00 +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 4405258..9e36b08 100644
    a b where 
    5151#include "nativeGen/NCG.h" 
    5252#include "HsVersions.h" 
    5353 
     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 
    5465#include "../includes/stg/HaskellMachRegs.h" 
    5566 
    5667import Reg 
    allIntArgRegs :: [Reg] 
    411422allFPArgRegs            :: [Reg] 
    412423callClobberedRegs       :: [Reg] 
    413424 
    414 #if defined(i386_TARGET_ARCH) || defined(x86_64_TARGET_ARCH) 
    415  
    416425#if i386_TARGET_ARCH 
    417426#define eax 0 
    418427#define ebx 1 
    globalRegMaybe _ = Nothing 
    588597 
    589598-- 
    590599 
    591 #if defined(mingw32_HOST_OS) && x86_64_TARGET_ARCH 
     600#if defined(mingw32_HOST_OS) 
    592601 
    593602allArgRegs = zip (map regSingle [rcx,rdx,r8,r9]) 
    594603                 (map regSingle [firstxmm ..]) 
    595604allIntArgRegs = panic "X86.Regs.allIntArgRegs: not defined for this platform" 
    596605allFPArgRegs = panic "X86.Regs.allFPArgRegs: not defined for this platform" 
    597606 
    598 #else 
     607#elif i386_TARGET_ARCH 
    599608 
    600609allArgRegs = panic "X86.Regs.allArgRegs: not defined for this arch" 
    601  
    602 # if   i386_TARGET_ARCH 
    603610allIntArgRegs = 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 
     611allFPArgRegs    = map regSingle [firstxmm .. firstxmm+7] 
     612 
     613#else 
    609614 
     615allArgRegs = panic "X86.Regs.allArgRegs: not defined for this arch" 
     616allIntArgRegs = map regSingle [rdi,rsi,rdx,rcx,r8,r9] 
    610617allFPArgRegs    = map regSingle [firstxmm .. firstxmm+7] 
    611618 
    612619#endif 
    allHaskellArgRegs = [ RegReal r | Just r <- map globalRegMaybe globalArgRegs ] 
    621628instrClobberedRegs :: [RealReg] 
    622629#if   i386_TARGET_ARCH 
    623630instrClobberedRegs = map RealRegSingle [ eax, ecx, edx ] 
    624 #elif x86_64_TARGET_ARCH 
     631#else 
    625632instrClobberedRegs = map RealRegSingle [ rax, rcx, rdx ] 
    626633#endif 
    627634 
    instrClobberedRegs = map RealRegSingle [ rax, rcx, rdx ] 
    632639callClobberedRegs 
    633640  = map regSingle ([eax,ecx,edx]  ++ floatregnos) 
    634641 
    635 #elif x86_64_TARGET_ARCH 
     642#else 
    636643-- all xmm regs are caller-saves 
    637644-- caller-saves registers 
    638645callClobberedRegs 
    639646  = map regSingle ([rax,rcx,rdx,rsi,rdi,r8,r9,r10,r11] ++ floatregnos) 
    640647 
    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  
    664648#endif 
    665649 
    666650-- allocatableRegs is allMachRegNos with the fixed-use regs removed.