add another way to run in the fuel monad (this is a mess right now)
authorNorman Ramsey <nr@eecs.harvard.edu>
Sat, 15 Sep 2007 21:51:38 +0000 (21:51 +0000)
committerNorman Ramsey <nr@eecs.harvard.edu>
Sat, 15 Sep 2007 21:51:38 +0000 (21:51 +0000)
compiler/cmm/DFMonad.hs

index e8afab4..970cdcb 100644 (file)
@@ -2,6 +2,7 @@
 module DFMonad
     ( OptimizationFuel
     , DFTx, runDFTx, lastTxPass, txDecrement, txRemaining, txExhausted
 module DFMonad
     ( OptimizationFuel
     , DFTx, runDFTx, lastTxPass, txDecrement, txRemaining, txExhausted
+    , functionalDFTx
 
     , DataflowLattice(..)
     , DataflowAnalysis
 
     , DataflowLattice(..)
     , DataflowAnalysis
@@ -108,6 +109,11 @@ runDFA lattice (DFA f) = fst $ f lattice initDFAState
 -- XXX DFTx really needs to be in IO, so we can dump programs in
 -- intermediate states of optimization ---NR
 
 -- XXX DFTx really needs to be in IO, so we can dump programs in
 -- intermediate states of optimization ---NR
 
+functionalDFTx :: String -> (OptimizationFuel -> (a, OptimizationFuel)) -> DFTx a
+functionalDFTx name pass = DFTx f
+    where f s = let (a, fuel) = pass (df_txlimit s)
+                in  (a, DFTxState fuel name)
+
 runDFTx :: OptimizationFuel -> DFTx a -> a  --- should only be called once per program!
 runDFTx lim (DFTx f) = fst $ f $ DFTxState lim "<none>"
 
 runDFTx :: OptimizationFuel -> DFTx a -> a  --- should only be called once per program!
 runDFTx lim (DFTx f) = fst $ f $ DFTxState lim "<none>"