X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FsimplCore%2FSATMonad.lhs;h=7c3f243758109d95ce7cb404d6642a5ff387866b;hb=432ec49f1fbaefc54f03bc3378f63fbd1e75d44b;hp=029d856a0ae1ffcb5b37b78483dddfe97ac2bf48;hpb=e7498a3ee1d0484d02a9e86633cc179c76ebf36e;p=ghc-hetmet.git diff --git a/ghc/compiler/simplCore/SATMonad.lhs b/ghc/compiler/simplCore/SATMonad.lhs index 029d856..7c3f243 100644 --- a/ghc/compiler/simplCore/SATMonad.lhs +++ b/ghc/compiler/simplCore/SATMonad.lhs @@ -1,5 +1,5 @@ % -% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996 +% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % %************************************************************************ %* * @@ -10,12 +10,11 @@ 96/03: We aren't using the static-argument transformation right now. \begin{code} -#include "HsVersions.h" - module SATMonad where -IMP_Ubiq(){-uitous-} -import Util ( panic ) +#include "HsVersions.h" + +import Panic ( panic ) junk_from_SATMonad = panic "SATMonad.junk" @@ -30,15 +29,13 @@ module SATMonad ( SATEnv(..), isStatic, dropStatics ) where -import Type ( mkTyVarTy, mkSigmaTy, TyVarTemplate, - splitSigmaTy, splitFunTy, - glueTyArgs, instantiateTy, TauType(..), - Class, ThetaType(..), SigmaType(..), +import Type ( mkTyVarTy, mkSigmaTy, + splitSigmaTy, splitFunTys, + glueTyArgs, substTy, InstTyEnv(..) ) -import Id ( mkSysLocal, idType ) -import Maybes ( Maybe(..) ) -import SrcLoc ( SrcLoc, mkUnknownSrcLoc ) +import MkId ( mkSysLocal ) +import Id ( idType, idName, mkLocalId ) import UniqSupply import Util @@ -60,7 +57,7 @@ data Arg a = Static a | NotStatic deriving Eq delOneFromSAEnv v us env - = ((), delOneFromIdEnv env v) + = ((), delVarEnv env v) updSAEnv :: Maybe (Id,SATInfo) -> SatM () updSAEnv Nothing @@ -84,7 +81,7 @@ notStatics n = nOfThem n NotStatic insSAEnv :: Id -> SATInfo -> SatM () insSAEnv b info us env - = ((), addOneToIdEnv env b info) + = ((), extendVarEnv env b info) \end{code} %************************************************************************ @@ -101,7 +98,7 @@ type SatM result initSAT :: SatM a -> UniqSupply -> a -initSAT f us = fst (f us nullIdEnv) +initSAT f us = fst (f us emptyVarEnv) thenSAT m k us env = case splitUniqSupply us of { (s1, s2) -> @@ -114,7 +111,7 @@ thenSAT_ m k us env k s2 menv }} emptyEnvSAT :: SatM () -emptyEnvSAT us _ = ((), nullIdEnv) +emptyEnvSAT us _ = ((), emptyVarEnv) returnSAT v us env = (v, env) @@ -134,19 +131,20 @@ mapSAT f (x:xs) \begin{code} getSATInfo :: Id -> SatM (Maybe SATInfo) getSATInfo var us env - = (lookupIdEnv env var, env) + = (lookupVarEnv env var, env) newSATName :: Id -> Type -> SatM Id newSATName id ty us env = case (getUnique us) of { unique -> - (mkSysLocal new_str unique ty mkUnknownSrcLoc, env) } - where - new_str = panic "SATMonad.newSATName (ToDo)" -- getOccName id _APPEND_ SLIT("_sat") + let + new_name = mkCompoundName SLIT("$sat") unique (idName id) + in + (mkLocalId new_name ty, env) } getArgLists :: CoreExpr -> ([Arg Type],[Arg Id]) getArgLists expr = let - (uvs, tvs, lambda_bounds, body) = collectBinders expr + (tvs, lambda_bounds, body) = collectBinders expr in ([ Static (mkTyVarTy tv) | tv <- tvs ], [ Static v | v <- lambda_bounds ]) @@ -215,11 +213,9 @@ saTransform binder rhs -- top-level or exported somehow.) -- A better fix is to use binder directly but with the TopLevel -- tag (or Exported tag) modified. - fake_binder = mkSysLocal - (getOccName binder _APPEND_ SLIT("_fsat")) - (uniqueOf binder) + fake_binder = mkSysLocal SLIT("sat") + (getUnique binder) (idType binder) - mkUnknownSrcLoc rec_body = mkValLam non_static_args ( Let (NonRec fake_binder nonrec_rhs) {-in-} (dropArgs rhs)) @@ -235,12 +231,12 @@ saTransform binder rhs origLams' _ e' = e' new_ty tyargs args - = instantiateTy (mk_inst_tyenv tyargs tv_tmpl) + = substTy (mk_inst_tyenv tyargs tv_tmpl) (mkSigmaTy tv_tmpl' dict_tys' tau_ty') where -- get type info for the local function: (tv_tmpl, dict_tys, tau_ty) = (splitSigmaTy . idType) binder - (reg_arg_tys, res_type) = splitFunTy tau_ty + (reg_arg_tys, res_type) = splitFunTys tau_ty -- now, we drop the ones that are -- static, that is, the ones we will not pass to the local function @@ -250,8 +246,8 @@ saTransform binder rhs reg_arg_tys' = dropStatics (drop l args) reg_arg_tys tau_ty' = glueTyArgs reg_arg_tys' res_type - mk_inst_tyenv [] _ = [] - mk_inst_tyenv (Static s:args) (t:ts) = (t,s) : mk_inst_tyenv args ts + mk_inst_tyenv [] _ = emptyVarEnv + mk_inst_tyenv (Static s:args) (t:ts) = extendVarEnv (mk_inst_tyenv args ts) t s mk_inst_tyenv (_:args) (_:ts) = mk_inst_tyenv args ts dropStatics [] t = t