[project @ 2004-08-13 10:45:16 by simonmar]
[ghc-hetmet.git] / ghc / compiler / nativeGen / AsmRegAlloc.lhs
index d9e6cf2..90b379a 100644 (file)
@@ -14,13 +14,12 @@ import PprMach              ( pprInstr )    -- Just for debugging
 import MachRegs
 import RegAllocInfo
 
-import FiniteMap       ( FiniteMap, emptyFM, addListToFM, delListFromFM, 
-                         lookupFM, keysFM, eltsFM, mapFM, addToFM_C, addToFM,
-                         listToFM, fmToList, lookupWithDefaultFM )
-import Unique          ( mkBuiltinUnique )
-import OrdList         ( unitOL, appOL, fromOL, concatOL )
+import FiniteMap       ( FiniteMap, emptyFM, 
+                         lookupFM, eltsFM, addToFM_C, addToFM,
+                         listToFM, fmToList )
+import OrdList         ( fromOL )
 import Outputable
-import Unique          ( Unique, Uniquable(..), mkPseudoUnique3 )
+import Unique          ( mkPseudoUnique3 )
 import CLabel          ( CLabel, pprCLabel )
 import FastTypes
 
@@ -72,7 +71,7 @@ runRegAllocate regs find_reserve_regs instrs
               $$
               (text "code = ")
               $$
-              (vcat (map pprInstr flatInstrs))
+              (vcat (map (docToSDoc.pprInstr) flatInstrs))
             )
     tryGeneral (resv:resvs)
        = case generalAlloc resv of
@@ -272,7 +271,7 @@ spill slot numbers for the uniques.
 insertSpillCode :: [Instr] -> [Instr]
 insertSpillCode insns
    = let uniques_in_insns
-            = map getUnique 
+            = map getVRegUnique 
                   (regSetToList 
                      (foldl unionRegSets emptyRegSet 
                             (map vregs_in_insn insns)))
@@ -280,7 +279,7 @@ insertSpillCode insns
             = case regUsage i of
                  RU rds wrs -> filterRegSet isVirtualReg 
                                              (rds `unionRegSets` wrs)
-         vreg_to_slot_map :: FiniteMap Unique Int
+         vreg_to_slot_map :: FiniteMap VRegUnique Int
          vreg_to_slot_map
             = listToFM (zip uniques_in_insns [0..])
 
@@ -298,7 +297,7 @@ insertSpillCode insns
 -- to the stack pointer, as opposed to the frame pointer.  The other is a 
 -- counter, used to manufacture new temporary register names.
 
-patchInstr :: FiniteMap Unique Int -> (Int,Int) -> Instr -> ((Int,Int), [Instr])
+patchInstr :: FiniteMap VRegUnique Int -> (Int,Int) -> Instr -> ((Int,Int), [Instr])
 patchInstr vreg_to_slot_map (delta,ctr) instr
 
  | null memSrcs && null memDsts 
@@ -331,13 +330,15 @@ patchInstr vreg_to_slot_map (delta,ctr) instr
            | isVirtualReg vreg
            = case [vi | (vreg', vi) <- vreg_env, vreg' == vreg] of
                 [i] -> case regClass vreg of
-                          RcInteger -> VirtualRegI (mkPseudoUnique3 i)
-                          RcFloat   -> VirtualRegF (mkPseudoUnique3 i)
-                          RcDouble  -> VirtualRegD (mkPseudoUnique3 i)
+                          RcInteger -> VirtualRegI (pseudoVReg i)
+                          RcFloat   -> VirtualRegF (pseudoVReg i)
+                          RcDouble  -> VirtualRegD (pseudoVReg i)
                 _   -> pprPanic "patchInstr: unmapped VReg" (ppr vreg)
            | otherwise
            = vreg
 
+        pseudoVReg i = VRegUniqueLo (mkPseudoUnique3 i)
+
        memSrcs   = filter isVirtualReg (regSetToList srcs)
        memDsts   = filter isVirtualReg (regSetToList dsts)