Commit 7252309c authored by ian@well-typed.com's avatar ian@well-typed.com

Whitespace only in nativeGen/RegAlloc/Linear/X86/FreeRegs.hs

parent eb9b4e54
{-# OPTIONS -fno-warn-tabs #-}
-- The above warning supression flag is a temporary kludge.
-- While working on this module you are encouraged to remove it and
-- detab the module (please do the detabbing in a separate patch). See
-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
-- for details
-- | Free regs map for i386 and x86_64
module RegAlloc.Linear.X86.FreeRegs
where
......@@ -19,45 +12,45 @@ import Platform
import Data.Word
import Data.Bits
type FreeRegs
type FreeRegs
#ifdef i386_TARGET_ARCH
= Word32
= Word32
#else
= Word64
= Word64
#endif
noFreeRegs :: FreeRegs
noFreeRegs = 0
releaseReg :: RealReg -> FreeRegs -> FreeRegs
releaseReg (RealRegSingle n) f
= f .|. (1 `shiftL` n)
releaseReg (RealRegSingle n) f
= f .|. (1 `shiftL` n)
releaseReg _ _
= panic "RegAlloc.Linear.X86.FreeRegs.realeaseReg: no reg"
releaseReg _ _
= panic "RegAlloc.Linear.X86.FreeRegs.realeaseReg: no reg"
initFreeRegs :: Platform -> FreeRegs
initFreeRegs platform
= foldr releaseReg noFreeRegs (allocatableRegs platform)
= foldr releaseReg noFreeRegs (allocatableRegs platform)
getFreeRegs :: Platform -> RegClass -> FreeRegs -> [RealReg] -- lazilly
getFreeRegs platform cls f = go f 0
where go 0 _ = []
go n m
| n .&. 1 /= 0 && classOfRealReg platform (RealRegSingle m) == cls
= RealRegSingle m : (go (n `shiftR` 1) $! (m+1))
go n m
| n .&. 1 /= 0 && classOfRealReg platform (RealRegSingle m) == cls
= RealRegSingle m : (go (n `shiftR` 1) $! (m+1))
| otherwise
= go (n `shiftR` 1) $! (m+1)
-- ToDo: there's no point looking through all the integer registers
-- in order to find a floating-point one.
| otherwise
= go (n `shiftR` 1) $! (m+1)
-- ToDo: there's no point looking through all the integer registers
-- in order to find a floating-point one.
allocateReg :: RealReg -> FreeRegs -> FreeRegs
allocateReg (RealRegSingle r) f
allocateReg (RealRegSingle r) f
= f .&. complement (1 `shiftL` r)
allocateReg _ _
= panic "RegAlloc.Linear.X86.FreeRegs.allocateReg: no reg"
= panic "RegAlloc.Linear.X86.FreeRegs.allocateReg: no reg"
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