X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectMonad.hs;h=d4fa8f8116487c82f9321124d4f6d8aacdae7c94;hb=b0c46848af7e431a2898af1a8aa1fbb0d2499137;hp=56189f6130fffa85ce345564d8bffe1f560a46f3;hpb=98abc79ce8b23f79c34c93bf3779c040a7b11058;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectMonad.hs b/compiler/vectorise/VectMonad.hs index 56189f6..d4fa8f8 100644 --- a/compiler/vectorise/VectMonad.hs +++ b/compiler/vectorise/VectMonad.hs @@ -1,7 +1,7 @@ module VectMonad ( VM, - noV, tryV, maybeV, orElseV, localV, initV, + noV, tryV, maybeV, orElseV, localV, closedV, initV, newLocalVar, newTyVar, Builtins(..), paDictTyCon, @@ -13,7 +13,8 @@ module VectMonad ( LocalEnv(..), readLEnv, setLEnv, updLEnv, - lookupTyCon, extendTyVarPA, deleteTyVarPA, + lookupTyCon, + lookupTyVarPA, extendTyVarPA, deleteTyVarPA, lookupInst, lookupFamInst ) where @@ -123,15 +124,18 @@ data LocalEnv = LocalEnv { -- Mapping from tyvars to their PA dictionaries , local_tyvar_pa :: VarEnv CoreExpr + + -- Hoisted bindings + , local_bindings :: [(Var, CoreExpr)] } initGlobalEnv :: VectInfo -> (InstEnv, InstEnv) -> FamInstEnvs -> GlobalEnv initGlobalEnv info instEnvs famInstEnvs = GlobalEnv { - global_vars = mapVarEnv (Var . snd) $ vectInfoCCVar info + global_vars = mapVarEnv (Var . snd) $ vectInfoVar info , global_exported_vars = emptyVarEnv - , global_tycons = mapNameEnv snd $ vectInfoCCTyCon info + , global_tycons = mapNameEnv snd $ vectInfoTyCon info , global_tycon_pa = emptyNameEnv , global_inst_env = instEnvs , global_fam_inst_env = famInstEnvs @@ -140,14 +144,15 @@ initGlobalEnv info instEnvs famInstEnvs emptyLocalEnv = LocalEnv { local_vars = emptyVarEnv , local_tyvar_pa = emptyVarEnv + , local_bindings = [] } -- FIXME updVectInfo :: GlobalEnv -> TypeEnv -> VectInfo -> VectInfo updVectInfo env tyenv info = info { - vectInfoCCVar = global_exported_vars env - , vectInfoCCTyCon = tc_env + vectInfoVar = global_exported_vars env + , vectInfoTyCon = tc_env } where tc_env = mkNameEnv [(tc_name, (tc,tc')) @@ -191,6 +196,14 @@ localV p = do setLEnv env return x +closedV :: VM a -> VM a +closedV p = do + env <- readLEnv id + setLEnv emptyLocalEnv + x <- p + setLEnv env + return x + liftDs :: DsM a -> VM a liftDs p = VM $ \bi genv lenv -> do { x <- p; return (Yes genv lenv x) } @@ -236,6 +249,9 @@ newTyVar fs k lookupTyCon :: TyCon -> VM (Maybe TyCon) lookupTyCon tc = readGEnv $ \env -> lookupNameEnv (global_tycons env) (tyConName tc) +lookupTyVarPA :: Var -> VM (Maybe CoreExpr) +lookupTyVarPA tv = readLEnv $ \env -> lookupVarEnv (local_tyvar_pa env) tv + extendTyVarPA :: Var -> CoreExpr -> VM () extendTyVarPA tv pa = updLEnv $ \env -> env { local_tyvar_pa = extendVarEnv (local_tyvar_pa env) tv pa } @@ -262,9 +278,7 @@ lookupInst cls tys where inst_tys' = [ty | Right ty <- inst_tys] noFlexiVar = all isRight inst_tys - _other -> - pprPanic "VectMonad.lookupInst: not found: " - (ppr $ mkTyConApp (classTyCon cls) tys) + _other -> noV } where isRight (Left _) = False