summaryrefslogtreecommitdiff
path: root/compiler/nativeGen
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2012-08-22 00:51:09 +0100
committerIan Lynagh <ian@well-typed.com>2012-08-22 00:51:09 +0100
commitf26027ee187c643b74ce19c7719376e6c987d8ae (patch)
tree619f24da0f026bc7d147a968661f4f1760d402d9 /compiler/nativeGen
parentf1f1659da0b6c43c46eef2109e456f84e6956a52 (diff)
downloadhaskell-f26027ee187c643b74ce19c7719376e6c987d8ae.tar.gz
More CPP removal in nativeGen/X86/Regs.hs
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r--compiler/nativeGen/X86/CodeGen.hs4
-rw-r--r--compiler/nativeGen/X86/Regs.hs18
2 files changed, 10 insertions, 12 deletions
diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs
index a8bbcbb07d..c00a0d544a 100644
--- a/compiler/nativeGen/X86/CodeGen.hs
+++ b/compiler/nativeGen/X86/CodeGen.hs
@@ -926,6 +926,7 @@ getByteReg expr = do
-- be modified by code to evaluate an arbitrary expression.
getNonClobberedReg :: CmmExpr -> NatM (Reg, InstrBlock)
getNonClobberedReg expr = do
+ dflags <- getDynFlags
r <- getRegister expr
case r of
Any rep code -> do
@@ -933,8 +934,7 @@ getNonClobberedReg expr = do
return (tmp, code tmp)
Fixed rep reg code
-- only certain regs can be clobbered
- | RegReal real <- reg
- , real `elem` instrClobberedRegs
+ | reg `elem` instrClobberedRegs (targetPlatform dflags)
-> do
tmp <- getNewRegNat rep
return (tmp, code `snocOL` reg2reg rep reg tmp)
diff --git a/compiler/nativeGen/X86/Regs.hs b/compiler/nativeGen/X86/Regs.hs
index 1affca7480..15f20a2a58 100644
--- a/compiler/nativeGen/X86/Regs.hs
+++ b/compiler/nativeGen/X86/Regs.hs
@@ -451,6 +451,14 @@ allFPArgRegs platform
= panic "X86.Regs.allFPArgRegs: not defined for this platform"
| otherwise = map regSingle [firstxmm .. firstxmm+7]
+-- Machine registers which might be clobbered by instructions that
+-- generate results into fixed registers, or need arguments in a fixed
+-- register.
+instrClobberedRegs :: Platform -> [Reg]
+instrClobberedRegs platform
+ | target32Bit platform = [ eax, ecx, edx ]
+ | otherwise = [ rax, rcx, rdx ]
+
#if i386_TARGET_ARCH
#define eax 0
#define ebx 1
@@ -630,16 +638,6 @@ globalRegMaybe _ = Nothing
allHaskellArgRegs :: [Reg]
allHaskellArgRegs = [ RegReal r | Just r <- map globalRegMaybe globalArgRegs ]
--- Machine registers which might be clobbered by instructions that
--- generate results into fixed registers, or need arguments in a fixed
--- register.
-instrClobberedRegs :: [RealReg]
-#if i386_TARGET_ARCH
-instrClobberedRegs = map RealRegSingle [ eax, ecx, edx ]
-#else
-instrClobberedRegs = map RealRegSingle [ rax, rcx, rdx ]
-#endif
-
-- allocatableRegs is allMachRegNos with the fixed-use regs removed.
-- i.e., these are the regs for which we are prepared to allow the
-- register allocator to attempt to map VRegs to.