2 -- | Free regs map for i386 and x86_64
3 module RegAlloc.Linear.X86.FreeRegs
17 noFreeRegs :: FreeRegs
20 releaseReg :: RealReg -> FreeRegs -> FreeRegs
21 releaseReg (RealRegSingle n) f
22 = f .|. (1 `shiftL` n)
25 = panic "RegAlloc.Linear.X86.FreeRegs.realeaseReg: no reg"
27 initFreeRegs :: FreeRegs
29 = foldr releaseReg noFreeRegs allocatableRegs
31 getFreeRegs :: RegClass -> FreeRegs -> [RealReg] -- lazilly
32 getFreeRegs cls f = go f 0
36 | n .&. 1 /= 0 && classOfRealReg (RealRegSingle m) == cls
37 = RealRegSingle m : (go (n `shiftR` 1) $! (m+1))
40 = go (n `shiftR` 1) $! (m+1)
41 -- ToDo: there's no point looking through all the integer registers
42 -- in order to find a floating-point one.
44 allocateReg :: RealReg -> FreeRegs -> FreeRegs
45 allocateReg (RealRegSingle r) f
46 = f .&. complement (1 `shiftL` fromIntegral r)
49 = panic "RegAlloc.Linear.X86.FreeRegs.allocateReg: no reg"