Follow vreg/hreg patch in x86 NCG
[ghc-hetmet.git] / compiler / nativeGen / RegAlloc / Linear / X86 / FreeRegs.hs
index 2b69da0..db3d8a3 100644 (file)
@@ -6,6 +6,7 @@ where
 import X86.Regs
 import RegClass
 import Reg
+import Panic
 
 import Data.Word
 import Data.Bits
@@ -17,26 +18,35 @@ type FreeRegs
 noFreeRegs :: FreeRegs
 noFreeRegs = 0
 
-releaseReg :: RegNo -> FreeRegs -> FreeRegs
-releaseReg n f = f .|. (1 `shiftL` n)
+releaseReg :: RealReg -> FreeRegs -> FreeRegs
+releaseReg (RealRegSingle n) f 
+       = f .|. (1 `shiftL` n)
+
+releaseReg _ _ 
+       = panic "RegAlloc.Linear.X86.FreeRegs.realeaseReg: no reg"
 
 initFreeRegs :: FreeRegs
-initFreeRegs = foldr releaseReg noFreeRegs allocatableRegs
+initFreeRegs 
+       = foldr releaseReg noFreeRegs allocatableRegs
 
-getFreeRegs :: RegClass -> FreeRegs -> [RegNo] -- lazilly
+getFreeRegs :: RegClass -> FreeRegs -> [RealReg]       -- lazilly
 getFreeRegs cls f = go f 0
 
   where go 0 _ = []
         go n m 
-         | n .&. 1 /= 0 && regClass (regSingle m) == cls
-         = m : (go (n `shiftR` 1) $! (m+1))
+         | n .&. 1 /= 0 && classOfRealReg (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.
 
-allocateReg :: RegNo -> FreeRegs -> FreeRegs
-allocateReg r f = f .&. complement (1 `shiftL` fromIntegral r)
+allocateReg :: RealReg -> FreeRegs -> FreeRegs
+allocateReg (RealRegSingle r) f 
+       = f .&. complement (1 `shiftL` fromIntegral r)
+
+allocateReg _ _
+       = panic "RegAlloc.Linear.X86.FreeRegs.allocateReg: no reg"