X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FsimplCore%2FSATMonad.lhs;h=0c33a915d71c4a8d0e95a9d4aa337f9af5880545;hb=438596897ebbe25a07e1c82085cfbc5bdb00f09e;hp=e37a9fd9750fdff8c8c0f4c599458fee251d6a18;hpb=26741ec416bae2c502ef00a2ba0e79050a32cb67;p=ghc-hetmet.git diff --git a/ghc/compiler/simplCore/SATMonad.lhs b/ghc/compiler/simplCore/SATMonad.lhs index e37a9fd..0c33a91 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,11 +10,10 @@ 96/03: We aren't using the static-argument transformation right now. \begin{code} -#include "HsVersions.h" - module SATMonad where -IMP_Ubiq(){-uitous-} +#include "HsVersions.h" + import Util ( panic ) junk_from_SATMonad = panic "SATMonad.junk" @@ -30,14 +29,13 @@ module SATMonad ( SATEnv(..), isStatic, dropStatics ) where -import Type ( mkTyVarTy, mkSigmaTy, TyVarTemplate, - splitSigmaTy, splitFunTy, - glueTyArgs, instantiateTy, SYN_IE(TauType), - Class, SYN_IE(ThetaType), SYN_IE(SigmaType), +import Type ( mkTyVarTy, mkSigmaTy, + splitSigmaTy, splitFunTys, + glueTyArgs, substTy, InstTyEnv(..) ) -import Id ( mkSysLocal, idType ) -import SrcLoc ( SrcLoc, mkUnknownSrcLoc ) +import MkId ( mkSysLocal ) +import Id ( idType, idName, mkUserId ) import UniqSupply import Util @@ -59,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 @@ -83,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} %************************************************************************ @@ -100,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) -> @@ -113,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) @@ -133,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 + (mkUserId 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,10 +214,8 @@ saTransform binder rhs -- 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) + (getUnique binder) (idType binder) - mkUnknownSrcLoc rec_body = mkValLam non_static_args ( Let (NonRec fake_binder nonrec_rhs) {-in-} (dropArgs rhs)) @@ -234,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 @@ -249,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