[commit: ghc] master: Remove some CPP in nativeGen/X86/Regs.hs (23efe66)
Ian Lynagh
igloo at earth.li
Wed Aug 22 02:39:28 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/23efe668b1dbd7a8a2b9c3a3ce3ad0ec84a3e464
>---------------------------------------------------------------
commit 23efe668b1dbd7a8a2b9c3a3ce3ad0ec84a3e464
Author: Ian Lynagh <ian at well-typed.com>
Date: Wed Aug 22 00:40:58 2012 +0100
Remove some CPP in nativeGen/X86/Regs.hs
>---------------------------------------------------------------
compiler/nativeGen/X86/CodeGen.hs | 12 +++++-----
compiler/nativeGen/X86/Regs.hs | 42 +++++++++++++++---------------------
2 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs
index 63a4576..a8bbcbb 100644
--- a/compiler/nativeGen/X86/CodeGen.hs
+++ b/compiler/nativeGen/X86/CodeGen.hs
@@ -1978,11 +1978,11 @@ genCCall64' platform target dest_regs args = do
(stack_args, int_regs_used, fp_regs_used, load_args_code)
<-
if platformOS platform == OSMinGW32
- then load_args_win args [] [] allArgRegs nilOL
+ then load_args_win args [] [] (allArgRegs platform) nilOL
else do (stack_args, aregs, fregs, load_args_code)
- <- load_args args allIntArgRegs allFPArgRegs nilOL
- let fp_regs_used = reverse (drop (length fregs) (reverse allFPArgRegs))
- int_regs_used = reverse (drop (length aregs) (reverse allIntArgRegs))
+ <- load_args args (allIntArgRegs platform) (allFPArgRegs platform) nilOL
+ let fp_regs_used = reverse (drop (length fregs) (reverse (allFPArgRegs platform)))
+ int_regs_used = reverse (drop (length aregs) (reverse (allIntArgRegs platform)))
return (stack_args, int_regs_used, fp_regs_used, load_args_code)
let
@@ -1991,7 +1991,7 @@ genCCall64' platform target dest_regs args = do
-- for annotating the call instruction with
sse_regs = length fp_regs_used
arg_stack_slots = if platformOS platform == OSMinGW32
- then length stack_args + length allArgRegs
+ then length stack_args + length (allArgRegs platform)
else length stack_args
tot_arg_size = arg_size * arg_stack_slots
@@ -2014,7 +2014,7 @@ genCCall64' platform target dest_regs args = do
-- On Win64, we also have to leave stack space for the arguments
-- that we are passing in registers
lss_code <- if platformOS platform == OSMinGW32
- then leaveStackSpace (length allArgRegs)
+ then leaveStackSpace (length (allArgRegs platform))
else return nilOL
delta <- getDeltaNat
diff --git a/compiler/nativeGen/X86/Regs.hs b/compiler/nativeGen/X86/Regs.hs
index ab9b778..b0e5acf 100644
--- a/compiler/nativeGen/X86/Regs.hs
+++ b/compiler/nativeGen/X86/Regs.hs
@@ -421,11 +421,26 @@ xmm n = regSingle (firstxmm+n)
-- horror show -----------------------------------------------------------------
freeReg :: RegNo -> FastBool
globalRegMaybe :: GlobalReg -> Maybe RealReg
-allArgRegs :: [(Reg, Reg)]
-allIntArgRegs :: [Reg]
-allFPArgRegs :: [Reg]
callClobberedRegs :: Platform -> [Reg]
+allArgRegs :: Platform -> [(Reg, Reg)]
+allArgRegs platform
+ | platformOS platform == OSMinGW32 = zip [rcx,rdx,r8,r9]
+ (map regSingle [firstxmm ..])
+ | otherwise = panic "X86.Regs.allArgRegs: not defined for this arch"
+
+allIntArgRegs :: Platform -> [Reg]
+allIntArgRegs platform
+ | (platformOS platform == OSMinGW32) || target32Bit platform
+ = panic "X86.Regs.allIntArgRegs: not defined for this platform"
+ | otherwise = [rdi,rsi,rdx,rcx,r8,r9]
+
+allFPArgRegs :: Platform -> [Reg]
+allFPArgRegs platform
+ | platformOS platform == OSMinGW32
+ = panic "X86.Regs.allFPArgRegs: not defined for this platform"
+ | otherwise = map regSingle [firstxmm .. firstxmm+7]
+
#if i386_TARGET_ARCH
#define eax 0
#define ebx 1
@@ -601,27 +616,6 @@ globalRegMaybe _ = Nothing
--
-#if defined(mingw32_HOST_OS)
-
-allArgRegs = zip (map regSingle [rcx,rdx,r8,r9])
- (map regSingle [firstxmm ..])
-allIntArgRegs = panic "X86.Regs.allIntArgRegs: not defined for this platform"
-allFPArgRegs = panic "X86.Regs.allFPArgRegs: not defined for this platform"
-
-#elif i386_TARGET_ARCH
-
-allArgRegs = panic "X86.Regs.allArgRegs: not defined for this arch"
-allIntArgRegs = panic "X86.Regs.allIntArgRegs: should not be used!"
-allFPArgRegs = map regSingle [firstxmm .. firstxmm+7]
-
-#else
-
-allArgRegs = panic "X86.Regs.allArgRegs: not defined for this arch"
-allIntArgRegs = map regSingle [rdi,rsi,rdx,rcx,r8,r9]
-allFPArgRegs = map regSingle [firstxmm .. firstxmm+7]
-
-#endif
-
-- All machine registers that are used for argument-passing to Haskell functions
allHaskellArgRegs :: [Reg]
allHaskellArgRegs = [ RegReal r | Just r <- map globalRegMaybe globalArgRegs ]
More information about the Cvs-ghc
mailing list