From: Matthijs Kooijman Date: Wed, 3 Mar 2010 12:20:22 +0000 (+0100) Subject: Copy initial state when specializing functions. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=a3db80162a9733c94ea1358640d71294203da50e;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Copy initial state when specializing functions. --- diff --git "a/c\316\273ash/CLasH/Normalize.hs" "b/c\316\273ash/CLasH/Normalize.hs" index f0f2de2..538b60d 100644 --- "a/c\316\273ash/CLasH/Normalize.hs" +++ "b/c\316\273ash/CLasH/Normalize.hs" @@ -13,7 +13,9 @@ import qualified List import qualified "transformers" Control.Monad.Trans as Trans import qualified Control.Monad as Monad import qualified Control.Monad.Trans.Writer as Writer +import qualified Data.Accessor.Monad.Trans.State as MonadState import qualified Data.Monoid as Monoid +import qualified Data.Map as Map -- GHC API import CoreSyn @@ -576,6 +578,12 @@ argprop expr@(App _ _) | is_var fexpr = do let newbody = MkCore.mkCoreLams newparams (MkCore.mkCoreApps body oldargs) -- Create a new function with the same name but a new body newf <- Trans.lift $ mkFunction f newbody + + Trans.lift $ MonadState.modify tsInitStates (\ismap -> + let init_state_maybe = Map.lookup f ismap in + case init_state_maybe of + Nothing -> ismap + Just init_state -> Map.insert newf init_state ismap) -- Replace the original application with one of the new function to the -- new arguments. change $ MkCore.mkCoreApps (Var newf) newargs