Split Reg into vreg/hreg and add register pairs
[ghc-hetmet.git] / compiler / nativeGen / X86 / RegInfo.hs
index 58d063b..48d983c 100644 (file)
@@ -5,10 +5,6 @@ module X86.RegInfo (
         JumpDest, 
        canShortcut, 
        shortcutJump, 
-
-       spillSlotSize,
-       maxSpillSlots,
-       spillSlotToOffset,
        
        shortcutStatic,
        regDotColor
@@ -29,16 +25,20 @@ import Cmm
 import CLabel
 import BlockId
 import Outputable
-import Constants       ( rESERVED_C_STACK_BYTES )
 import Unique
 
+#if i386_TARGET_ARCH || x86_64_TARGET_ARCH
+import UniqFM
+#endif
+
+
 mkVReg :: Unique -> Size -> Reg
 mkVReg u size
-   | not (isFloatSize size) = VirtualRegI u
+   | not (isFloatSize size) = RegVirtual (VirtualRegI u)
    | otherwise
    = case size of
-        FF32   -> VirtualRegD u
-        FF64   -> VirtualRegD u
+        FF32   -> RegVirtual (VirtualRegD u)
+        FF64   -> RegVirtual (VirtualRegD u)
        _       -> panic "mkVReg"
 
 
@@ -51,34 +51,17 @@ canShortcut (JMP (OpImm imm))       = Just (DestImm imm)
 canShortcut _                  = Nothing
 
 
+-- The helper ensures that we don't follow cycles.
 shortcutJump :: (BlockId -> Maybe JumpDest) -> Instr -> Instr
-shortcutJump fn insn@(JXX cc id) = 
-  case fn id of
-    Nothing                -> insn
-    Just (DestBlockId id') -> shortcutJump fn (JXX cc id')
-    Just (DestImm imm)     -> shortcutJump fn (JXX_GBL cc imm)
-
-shortcutJump _ other = other
-
-
-
-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)
+shortcutJump fn insn = shortcutJump' fn emptyBlockSet insn
+  where shortcutJump' fn seen insn@(JXX cc id) =
+          if elemBlockSet id seen then insn
+          else case fn id of
+                 Nothing                -> insn
+                 Just (DestBlockId id') -> shortcutJump' fn seen' (JXX cc id')
+                 Just (DestImm imm)     -> shortcutJump' fn seen' (JXX_GBL cc imm)
+               where seen' = extendBlockSet seen id
+        shortcutJump' _ _ other = other
 
 
 -- Here because it knows about JumpDest
@@ -116,6 +99,7 @@ regDotColor reg
  = let Just    str     = lookupUFM regColors reg
    in  text str
 
+regColors :: UniqFM [Char]
 regColors
  = listToUFM
  $     [ (eax, "#00ff00")
@@ -138,6 +122,7 @@ regDotColor reg
  = let Just    str     = lookupUFM regColors reg
    in  text str
 
+regColors :: UniqFM [Char]
 regColors
  = listToUFM
  $     [ (rax, "#00ff00"), (eax, "#00ff00")