X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectUtils.hs;h=5c099c0fd306f0277d763f2380eb75050b82926a;hb=8612b9a9f60161f65e656f65df8b679008911b3a;hp=bdee5ea87c608715972fd928e4052e3592971217;hpb=51ad52d4f7d259b500543404f419ff62456e2097;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectUtils.hs b/compiler/vectorise/VectUtils.hs index bdee5ea..5c099c0 100644 --- a/compiler/vectorise/VectUtils.hs +++ b/compiler/vectorise/VectUtils.hs @@ -18,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, @@ -259,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 @@ -338,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 @@ -434,7 +455,7 @@ mkLiftEnv lc tys vs 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 @@ -445,6 +466,9 @@ mkLiftEnv lc tys vs where vty = mkCoreTupTy tys + args | null vs = [Var unitDataConId] + | otherwise = map Var vs + bndrs | null vs = [mkWildId unitTy] | otherwise = vs