Split Reg into vreg/hreg and add register pairs
[ghc-hetmet.git] / compiler / nativeGen / X86 / Instr.hs
index b4b6fb5..dbec540 100644 (file)
@@ -23,6 +23,8 @@ import BlockId
 import Cmm
 import FastString
 import FastBool
+import Outputable
+import Constants       (rESERVED_C_STACK_BYTES)
 
 import CLabel
 import Panic
@@ -441,12 +443,9 @@ x86_regUsageOfInstr instr
              dst' = filter interesting dst
 
 interesting :: Reg -> Bool
-interesting (VirtualRegI  _)  = True
-interesting (VirtualRegHi _)  = True
-interesting (VirtualRegF  _)  = True
-interesting (VirtualRegD  _)  = True
-interesting (RealReg i)       = isFastTrue (freeReg i)
-
+interesting (RegVirtual _)             = True
+interesting (RegReal (RealRegSingle i))        = isFastTrue (freeReg i)
+interesting (RegReal (RealRegPair{}))  = panic "X86.interesting: no reg pairs on this arch"
 
 
 
@@ -655,6 +654,23 @@ x86_mkLoadInstr _ _ _
        = panic "X86.RegInfo.mkLoadInstr: not defined for this architecture."
 #endif
 
+spillSlotSize :: Int
+spillSlotSize = IF_ARCH_i386(12, 8)
+
+maxSpillSlots :: Int
+maxSpillSlots = ((rESERVED_C_STACK_BYTES - 64) `div` spillSlotSize) - 1
+
+-- convert a spill slot number to a *byte* offset, with no sign:
+-- decide on a per arch basis whether you are spilling above or below
+-- the C stack pointer.
+spillSlotToOffset :: Int -> Int
+spillSlotToOffset slot
+   | slot >= 0 && slot < maxSpillSlots
+   = 64 + spillSlotSize * slot
+   | otherwise
+   = pprPanic "spillSlotToOffset:" 
+              (   text "invalid spill location: " <> int slot
+             $$  text "maxSpillSlots:          " <> int maxSpillSlots)
 
 --------------------------------------------------------------------------------