Commit f26027ee authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

More CPP removal in nativeGen/X86/Regs.hs

parent f1f1659d
......@@ -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)
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment