X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fcmm%2FOptimizationFuel.hs;h=175dcd09b18a4c602cb9531796d0f4b7abf89673;hb=7fc01c4671980ea3c66d549c0ece4d82fd3f5ade;hp=7ec9d488554c603870de9b52c788f53d5fd80c5c;hpb=25628e2771424cae1b3366322e8ce6f8a85440f9;p=ghc-hetmet.git diff --git a/compiler/cmm/OptimizationFuel.hs b/compiler/cmm/OptimizationFuel.hs index 7ec9d48..175dcd0 100644 --- a/compiler/cmm/OptimizationFuel.hs +++ b/compiler/cmm/OptimizationFuel.hs @@ -1,30 +1,29 @@ +-- | Optimisation fuel is used to control the amount of work the optimiser does. +-- +-- Every optimisation step consumes a certain amount of fuel and stops when +-- it runs out of fuel. This can be used e.g. to debug optimiser bugs: Run +-- the optimiser with varying amount of fuel to find out the exact number of +-- steps where a bug is introduced in the output. module OptimizationFuel - ( OptimizationFuel , canRewriteWithFuel, maybeRewriteWithFuel, oneLessFuel + ( OptimizationFuel, canRewriteWithFuel, maybeRewriteWithFuel, oneLessFuel , OptFuelState, initOptFuelState --, setTotalFuel , tankFilledTo, diffFuel , 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 Control.Monad import StaticFlags (opt_Fuel) import UniqSupply @@ -66,7 +65,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 @@ -139,28 +138,3 @@ lGraphOfGraph :: Graph m l -> FuelMonad (LGraph m l) lGraphOfGraph (Graph tail blocks) = 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 -