X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectUtils.hs;h=533a8e769409987e37ee088e1d5642c0df1ffc43;hb=d8b2f9e9f169442e20c7ae22006767f948a27b41;hp=ebb2718f757f56ae2fc8f18198ae4cedc9e750b1;hpb=fd399de26f49a14431a07ed4a1351f41781b80ec;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectUtils.hs b/compiler/vectorise/VectUtils.hs index ebb2718..533a8e7 100644 --- a/compiler/vectorise/VectUtils.hs +++ b/compiler/vectorise/VectUtils.hs @@ -8,7 +8,9 @@ module VectUtils ( collectAnnTypeBinders, collectAnnTypeArgs, isAnnTypeArg, collectAnnValBinders, - mkDataConTag, mkDataConTagLit, + dataConTagZ, mkDataConTag, mkDataConTagLit, + + newLocalVVar, mkBuiltinCo, mkPADictType, mkPArrayType, mkPReprType, @@ -16,7 +18,7 @@ module VectUtils ( parrayReprTyCon, parrayReprDataCon, mkVScrut, prDFunOfTyCon, paDictArgType, paDictOfType, paDFunType, - paMethod, mkPR, lengthPA, replicatePA, emptyPA, packPA, liftPA, + paMethod, mkPR, lengthPA, replicatePA, emptyPA, packPA, combinePA, liftPA, polyAbstract, polyApply, polyVApply, hoistBinding, hoistExpr, hoistPolyVExpr, takeHoisted, buildClosure, buildClosures, @@ -74,12 +76,14 @@ isAnnTypeArg :: AnnExpr b ann -> Bool isAnnTypeArg (_, AnnType t) = True isAnnTypeArg _ = False +dataConTagZ :: DataCon -> Int +dataConTagZ con = dataConTag con - fIRST_TAG + mkDataConTagLit :: DataCon -> Literal -mkDataConTagLit con - = mkMachInt . toInteger $ dataConTag con - fIRST_TAG +mkDataConTagLit = mkMachInt . toInteger . dataConTagZ mkDataConTag :: DataCon -> CoreExpr -mkDataConTag con = mkIntLitInt (dataConTag con - fIRST_TAG) +mkDataConTag = mkIntLitInt . dataConTagZ splitPrimTyCon :: Type -> Maybe TyCon splitPrimTyCon ty @@ -255,9 +259,17 @@ emptyPA :: Type -> VM CoreExpr emptyPA = paMethod pa_empty packPA :: Type -> CoreExpr -> CoreExpr -> CoreExpr -> VM CoreExpr -packPA ty xs len sel = liftM (`mkApps` [len, sel]) +packPA ty xs len sel = liftM (`mkApps` [xs, len, sel]) (paMethod pa_pack ty) +combinePA :: Type -> CoreExpr -> CoreExpr -> CoreExpr -> [CoreExpr] + -> VM CoreExpr +combinePA ty len sel is xs + = liftM (`mkApps` (len : sel : is : xs)) + (paMethod (combinePAVar n, "combine" ++ show n ++ "PA") ty) + where + n = length xs + liftPA :: CoreExpr -> VM CoreExpr liftPA x = do @@ -334,6 +346,19 @@ takeHoisted setGEnv $ env { global_bindings = [] } return $ global_bindings env +boxExpr :: Type -> VExpr -> VM VExpr +boxExpr ty (vexpr, lexpr) + | Just (tycon, []) <- splitTyConApp_maybe ty + , isUnLiftedTyCon tycon + = do + r <- lookupBoxedTyCon tycon + case r of + Just tycon' -> let [dc] = tyConDataCons tycon' + in + return (mkConApp dc [vexpr], lexpr) + Nothing -> return (vexpr, lexpr) + + mkClosure :: Type -> Type -> Type -> VExpr -> VExpr -> VM VExpr mkClosure arg_ty res_ty env_ty (vfn,lfn) (venv,lenv) = do @@ -426,11 +451,16 @@ mkLiftEnv lc [ty] [v] mkLiftEnv lc tys vs = do (env_tc, env_tyargs) <- parrayReprTyCon vty + + bndrs <- if null vs then do + v <- newDummyVar unitTy + return [v] + else return vs let [env_con] = tyConDataCons env_tc env = Var (dataConWrapId env_con) `mkTyApps` env_tyargs - `mkVarApps` (lc : vs) + `mkApps` (Var lc : args) bind env body = let scrut = unwrapFamInstScrut env_tc env_tyargs env in @@ -441,6 +471,6 @@ mkLiftEnv lc tys vs where vty = mkCoreTupTy tys - bndrs | null vs = [mkWildId unitTy] - | otherwise = vs + args | null vs = [Var unitDataConId] + | otherwise = map Var vs