X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectMonad.hs;h=1bd450e237331ced4cade4dc7f226569ea933597;hb=51ad52d4f7d259b500543404f419ff62456e2097;hp=6bc2f4d656c5ec35d5ec811df6f35d5f58992091;hpb=097ce0211ba8fc7aef8cd7fefc33f21f92e559ea;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectMonad.hs b/compiler/vectorise/VectMonad.hs index 6bc2f4d..1bd450e 100644 --- a/compiler/vectorise/VectMonad.hs +++ b/compiler/vectorise/VectMonad.hs @@ -1,14 +1,21 @@ +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module VectMonad ( Scope(..), VM, noV, tryV, maybeV, traceMaybeV, orElseV, fixV, localV, closedV, initV, liftDs, - cloneName, cloneId, + cloneName, cloneId, cloneVar, newExportedVar, newLocalVar, newDummyVar, newTyVar, - Builtins(..), - builtin, + Builtins(..), sumTyCon, prodTyCon, + builtin, builtins, GlobalEnv(..), setFamInstEnv, @@ -24,6 +31,7 @@ module VectMonad ( lookupDataCon, defDataCon, lookupTyConPA, defTyConPA, defTyConPAs, lookupTyConPR, + lookupPrimMethod, lookupPrimPArray, lookupTyVarPA, defLocalTyVar, defLocalTyVarWithPA, localTyVars, {-lookupInst,-} lookupFamInst @@ -133,7 +141,7 @@ initGlobalEnv info instEnvs famInstEnvs , global_tycons = mapNameEnv snd $ vectInfoTyCon info , global_datacons = mapNameEnv snd $ vectInfoDataCon info , global_pa_funs = mapNameEnv snd $ vectInfoPADFun info - , global_pr_funs = emptyVarEnv + , global_pr_funs = emptyNameEnv , global_inst_env = instEnvs , global_fam_inst_env = famInstEnvs , global_bindings = [] @@ -240,6 +248,9 @@ liftDs p = VM $ \bi genv lenv -> do { x <- p; return (Yes genv lenv x) } builtin :: (Builtins -> a) -> VM a builtin f = VM $ \bi genv lenv -> return (Yes genv lenv (f bi)) +builtins :: (a -> Builtins -> b) -> VM (a -> b) +builtins f = VM $ \bi genv lenv -> return (Yes genv lenv (`f` bi)) + readGEnv :: (GlobalEnv -> a) -> VM a readGEnv f = VM $ \bi genv lenv -> return (Yes genv lenv (f genv)) @@ -290,6 +301,9 @@ cloneId mk_occ id ty | otherwise = Id.mkLocalId name ty return id' +cloneVar :: Var -> VM Var +cloneVar var = liftM (setIdUnique var) (liftDs newUnique) + newExportedVar :: OccName -> Type -> VM Var newExportedVar occ_name ty = do @@ -351,6 +365,12 @@ defDataCon :: DataCon -> DataCon -> VM () defDataCon dc dc' = updGEnv $ \env -> env { global_datacons = extendNameEnv (global_datacons env) (dataConName dc) dc' } +lookupPrimPArray :: TyCon -> VM (Maybe TyCon) +lookupPrimPArray = liftDs . primPArray + +lookupPrimMethod :: TyCon -> String -> VM (Maybe Var) +lookupPrimMethod tycon = liftDs . primMethod tycon + lookupTyConPA :: TyCon -> VM (Maybe Var) lookupTyConPA tc = readGEnv $ \env -> lookupNameEnv (global_pa_funs env) (tyConName tc) @@ -452,9 +472,9 @@ initV hsc_env guts info p go = do builtins <- initBuiltins - builtin_tycons <- initBuiltinTyCons - builtin_pas <- initBuiltinPAs - builtin_prs <- initBuiltinPRs + let builtin_tycons = initBuiltinTyCons builtins + builtin_pas <- initBuiltinPAs builtins + builtin_prs <- initBuiltinPRs builtins eps <- ioToIOEnv $ hscEPS hsc_env let famInstEnvs = (eps_fam_inst_env eps, mg_fam_inst_env guts)