2 -- | Free regs map for i386 and x86_64
3 module RegAlloc.Linear.X86.FreeRegs
15 noFreeRegs :: FreeRegs
18 releaseReg :: RegNo -> FreeRegs -> FreeRegs
19 releaseReg n f = f .|. (1 `shiftL` n)
21 initFreeRegs :: FreeRegs
22 initFreeRegs = foldr releaseReg noFreeRegs allocatableRegs
24 getFreeRegs :: RegClass -> FreeRegs -> [RegNo] -- lazilly
25 getFreeRegs cls f = go f 0
29 | n .&. 1 /= 0 && regClass (RealReg m) == cls
30 = m : (go (n `shiftR` 1) $! (m+1))
33 = go (n `shiftR` 1) $! (m+1)
34 -- ToDo: there's no point looking through all the integer registers
35 -- in order to find a floating-point one.
37 allocateReg :: RegNo -> FreeRegs -> FreeRegs
38 allocateReg r f = f .&. complement (1 `shiftL` fromIntegral r)