X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FsimplCore%2FSimplEnv.lhs;h=d9eea39ed69e7bb1d76820ee0af5e4e532dc9086;hb=b187c221cc97679e28118ae8ac2997d6a686ba14;hp=865acdc98df9420d4766571c36c7bc3ac9fa7ca7;hpb=f95a95425727fd0086df26f7d47f79c911e04b34;p=ghc-hetmet.git diff --git a/compiler/simplCore/SimplEnv.lhs b/compiler/simplCore/SimplEnv.lhs index 865acdc..d9eea39 100644 --- a/compiler/simplCore/SimplEnv.lhs +++ b/compiler/simplCore/SimplEnv.lhs @@ -1,5 +1,5 @@ % -% (c) The AQUA Project, Glasgow University, 1993-1998 +o% (c) The AQUA Project, Glasgow University, 1993-1998 % \section[SimplMonad]{The simplifier Monad} @@ -12,18 +12,14 @@ module SimplEnv ( -- The simplifier mode setMode, getMode, updMode, - -- Switch checker - SwitchChecker, SwitchResult(..), getSwitchChecker, getSimplIntSwitch, - isAmongSimpl, intSwitchSet, switchIsOn, - - setEnclosingCC, getEnclosingCC, + setEnclosingCC, getEnclosingCC, -- Environments SimplEnv(..), StaticEnv, pprSimplEnv, -- Temp not abstract mkSimplEnv, extendIdSubst, SimplEnv.extendTvSubst, zapSubstEnv, setSubstEnv, getInScope, setInScope, setInScopeSet, modifyInScope, addNewInScopeIds, - getSimplRules, inGentleMode, + getSimplRules, SimplSR(..), mkContEx, substId, lookupRecBndr, @@ -50,6 +46,8 @@ import VarEnv import VarSet import OrdList import Id +import MkCore +import TysWiredIn import qualified CoreSubst import qualified Type ( substTy, substTyVarBndr, substTyVar ) import Type hiding ( substTy, substTyVarBndr, substTyVar ) @@ -106,8 +104,7 @@ data SimplEnv -- wrt the original expression seMode :: SimplifierMode, - seChkr :: SwitchChecker, - seCC :: CostCentreStack, -- The enclosing CCS (when profiling) + seCC :: CostCentreStack, -- The enclosing CCS (when profiling) -- The current substitution seTvSubst :: TvSubstEnv, -- InTyVar |--> OutType @@ -223,19 +220,40 @@ seIdSubst: \begin{code} -mkSimplEnv :: SwitchChecker -> SimplifierMode -> SimplEnv -mkSimplEnv switches mode - = SimplEnv { seChkr = switches, seCC = subsumedCCS, - seMode = mode, seInScope = emptyInScopeSet, - seFloats = emptyFloats, - seTvSubst = emptyVarEnv, seIdSubst = emptyVarEnv } +mkSimplEnv :: SimplifierMode -> SimplEnv +mkSimplEnv mode + = SimplEnv { seCC = subsumedCCS + , seMode = mode + , seInScope = init_in_scope + , seFloats = emptyFloats + , seTvSubst = emptyVarEnv + , seIdSubst = emptyVarEnv } -- The top level "enclosing CC" is "SUBSUMED". ---------------------- -getSwitchChecker :: SimplEnv -> SwitchChecker -getSwitchChecker env = seChkr env +init_in_scope :: InScopeSet +init_in_scope = mkInScopeSet (unitVarSet (mkWildValBinder unitTy)) + -- See Note [WildCard binders] +\end{code} ---------------------- +Note [WildCard binders] +~~~~~~~~~~~~~~~~~~~~~~~ +The program to be simplified may have wild binders + case e of wild { p -> ... } +We want to *rename* them away, so that there are no +occurrences of 'wild-id' (with wildCardKey). The easy +way to do that is to start of with a representative +Id in the in-scope set + +There can be be *occurrences* of wild-id. For example, +MkCore.mkCoreApp transforms + e (a /# b) --> case (a /# b) of wild { DEFAULT -> e wild } +This is ok provided 'wild' isn't free in 'e', and that's the delicate +thing. Generally, you want to run the simplifier to get rid of the +wild-ids before doing much else. + +It's a very dark corner of GHC. Maybe it should be cleaned up. + +\begin{code} getMode :: SimplEnv -> SimplifierMode getMode env = seMode env @@ -245,11 +263,6 @@ setMode mode env = env { seMode = mode } updMode :: (SimplifierMode -> SimplifierMode) -> SimplEnv -> SimplEnv updMode upd env = env { seMode = upd (seMode env) } -inGentleMode :: SimplEnv -> Bool -inGentleMode env = case seMode env of - SimplGently {} -> True - _other -> False - --------------------- getEnclosingCC :: SimplEnv -> CostCentreStack getEnclosingCC env = seCC env