X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectType.hs;h=46c32676d62dfde4a358e73a06975c064e71d65c;hb=c6eadadbefe2ec5709e9d31893f79c4ff78754b4;hp=29b68435dee817c2d97c60b3bc637b3459cbe853;hpb=ae7dacf4c3b014fa0ec6f94ac5b2e0a19b1b2f45;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectType.hs b/compiler/vectorise/VectType.hs index 29b6843..46c3267 100644 --- a/compiler/vectorise/VectType.hs +++ b/compiler/vectorise/VectType.hs @@ -1,4 +1,4 @@ -module VectType ( vectTyCon, vectType ) +module VectType ( vectTyCon, vectType, vectTypeEnv ) where #include "HsVersions.h" @@ -6,6 +6,7 @@ where import VectMonad import VectUtils +import HscTypes ( TypeEnv, extendTypeEnvList, typeEnvTyCons ) import DataCon import TyCon import Type @@ -13,7 +14,9 @@ import TypeRep import OccName import MkId import BasicTypes ( StrictnessMark(..), boolToRecFlag ) +import NameEnv +import Unique import UniqFM import UniqSet import Digraph ( SCC(..), stronglyConnComp ) @@ -60,6 +63,29 @@ vectType ty = pprPanic "vectType:" (ppr ty) type TyConGroup = ([TyCon], UniqSet TyCon) +vectTypeEnv :: TypeEnv -> VM TypeEnv +vectTypeEnv env + = do + cs <- readGEnv $ mk_map . global_tycons + let (conv_tcs, keep_tcs) = classifyTyCons cs groups + keep_dcs = concatMap tyConDataCons keep_tcs + zipWithM_ defTyCon keep_tcs keep_tcs + zipWithM_ defDataCon keep_dcs keep_dcs + new_tcs <- vectTyConDecls conv_tcs + return $ extendTypeEnvList env + (map ATyCon new_tcs ++ [ADataCon dc | tc <- new_tcs + , dc <- tyConDataCons tc]) + where + tycons = typeEnvTyCons env + groups = tyConGroups tycons + + mk_map env = listToUFM_Directly [(u, getUnique n /= u) | (u,n) <- nameEnvUniqueElts env] + + keep_tc tc = let dcs = tyConDataCons tc + in + defTyCon tc tc >> zipWithM_ defDataCon dcs dcs + + vectTyConDecls :: [TyCon] -> VM [TyCon] vectTyConDecls tcs = fixV $ \tcs' -> do @@ -183,7 +209,13 @@ tyConsOfType :: Type -> UniqSet TyCon tyConsOfType ty | Just ty' <- coreView ty = tyConsOfType ty' tyConsOfType (TyVarTy v) = emptyUniqSet -tyConsOfType (TyConApp tc tys) = tyConsOfTypes tys `addOneToUniqSet` tc +tyConsOfType (TyConApp tc tys) = extend (tyConsOfTypes tys) + where + extend | isUnLiftedTyCon tc + || isTupleTyCon tc = id + + | otherwise = (`addOneToUniqSet` tc) + tyConsOfType (AppTy a b) = tyConsOfType a `unionUniqSets` tyConsOfType b tyConsOfType (FunTy a b) = (tyConsOfType a `unionUniqSets` tyConsOfType b) `addOneToUniqSet` funTyCon