Big collection of patches for the new codegen branch.
[ghc-hetmet.git] / compiler / cmm / OptimizationFuel.hs
index 7ec9d48..7de398a 100644 (file)
@@ -5,24 +5,17 @@ module OptimizationFuel
     , FuelConsumer
     , FuelUsingMonad, FuelState
     , lastFuelPass, fuelExhausted, fuelRemaining, fuelDecrement, fuelDec1
-    --, lastFuelPassInState , fuelExhaustedInState, fuelRemainingInState
-    --, fuelDecrementState
-    --, runFuel
-    , runFuelIO
-    --, runFuelWithLastPass
-    , fuelConsumingPass
+    , runFuelIO, fuelConsumingPass
     , FuelMonad
     , liftUniq
     , lGraphOfGraph -- needs to be able to create a unique ID...
     )
 where
 
-import StackSlot
+import BlockId
 import ZipCfg
-
 --import GHC.Exts (State#)
 import Panic
-
 import Data.IORef
 import Monad
 import StaticFlags (opt_Fuel)
@@ -66,7 +59,7 @@ diffFuel (OptimizationFuel f) (OptimizationFuel f') = f - f'
 -- type OptimizationFuel = State# () -- would like this, but it won't work
 data OptimizationFuel = OptimizationFuel
   deriving Show
-tankFilledTo _ = undefined -- should be impossible to evaluate
+tankFilledTo _ = panic "tankFilledTo" -- should be impossible to evaluate
   -- realWorld# might come in handy, too...
 canRewriteWithFuel OptimizationFuel = True
 maybeRewriteWithFuel _ ma = ma
@@ -135,32 +128,8 @@ fuelDecrementState new_optimizer old new s =
         optimizer = if diffFuel old new > 0 then new_optimizer else fs_lastpass s
 
 -- lGraphOfGraph is here because we need uniques to implement it.
-lGraphOfGraph :: Graph m l -> FuelMonad (LGraph m l)
-lGraphOfGraph (Graph tail blocks) =
+lGraphOfGraph :: Graph m l -> Int -> FuelMonad (LGraph m l)
+lGraphOfGraph (Graph tail blocks) args =
   do entry <- liftM BlockId $ getUniqueM
-     return $ LGraph entry (insertBlock (Block entry tail) blocks)
-
-
--- JD: I'm not sure what NR's plans are for the following code.
--- Perhaps these functions will be useful in the future, or perhaps I've made
--- them obsoltete.
-
---initialFuelState :: OptimizationFuel -> FuelState
---initialFuelState fuel = FuelState fuel "unoptimized program"
---runFuel             :: FuelMonad a -> FuelConsumer a
---runFuelWithLastPass :: FuelMonad a -> FuelConsumer (a, String)
-
---runFuel             (FuelMonad f) fuel = let (a, s) = f $ initialFuelState fuel
---                                         in (a, fs_fuellimit s)
---runFuelWithLastPass (FuelMonad f) fuel = let (a, s) = f $ initialFuelState fuel
---                                         in ((a, fs_lastpass s), fs_fuellimit s)
-
--- lastFuelPassInState :: FuelState -> String
--- lastFuelPassInState = fs_lastpass
-
--- fuelExhaustedInState :: FuelState -> Bool
--- fuelExhaustedInState = canRewriteWithFuel . fs_fuellimit
-
--- fuelRemainingInState :: FuelState -> OptimizationFuel
--- fuelRemainingInState = fs_fuellimit
-
+     return $ LGraph entry args
+                     (insertBlock (Block entry emptyStackInfo tail) blocks)