2 -- | Free regs map for i386 and x86_64
3 module RegAlloc.Linear.X86.FreeRegs
17 noFreeRegs :: FreeRegs
20 releaseReg :: RegNo -> FreeRegs -> FreeRegs
21 releaseReg n f = f .|. (1 `shiftL` n)
23 initFreeRegs :: FreeRegs
24 initFreeRegs = foldr releaseReg noFreeRegs allocatableRegs
26 getFreeRegs :: RegClass -> FreeRegs -> [RegNo] -- lazilly
27 getFreeRegs cls f = go f 0
31 | n .&. 1 /= 0 && regClass (RealReg m) == cls
32 = m : (go (n `shiftR` 1) $! (m+1))
35 = go (n `shiftR` 1) $! (m+1)
36 -- ToDo: there's no point looking through all the integer registers
37 -- in order to find a floating-point one.
39 allocateReg :: RegNo -> FreeRegs -> FreeRegs
40 allocateReg r f = f .&. complement (1 `shiftL` fromIntegral r)