X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fvectorise%2FVectUtils.hs;h=5c014610c5581dec4814544fb602ab8e9f0545a0;hp=7aef39b6b959ca76c2d37266d96ee141a5955315;hb=28bb3c3c8c1467ca31db59f0b3d1a21df6607742;hpb=7106cd1bb3633ee274673cd0d1ea82315ca8b56d diff --git a/compiler/vectorise/VectUtils.hs b/compiler/vectorise/VectUtils.hs index 7aef39b..5c01461 100644 --- a/compiler/vectorise/VectUtils.hs +++ b/compiler/vectorise/VectUtils.hs @@ -12,6 +12,7 @@ module VectUtils ( prDFunOfTyCon, paDictArgType, paDictOfType, paDFunType, paMethod, mkPR, lengthPA, replicatePA, emptyPA, packPA, combinePA, liftPA, + zipScalars, scalarClosure, polyAbstract, polyApply, polyVApply, hoistBinding, hoistExpr, hoistPolyVExpr, takeHoisted, buildClosure, buildClosures, @@ -270,6 +271,24 @@ liftPA x lc <- builtin liftingContext replicatePA (Var lc) x +zipScalars :: [Type] -> Type -> VM CoreExpr +zipScalars arg_tys res_ty + = do + scalar <- builtin scalarClass + (dfuns, _) <- mapAndUnzipM (\ty -> lookupInst scalar [ty]) ty_args + zipf <- builtin (scalarZip $ length arg_tys) + return $ Var zipf `mkTyApps` ty_args `mkApps` map Var dfuns + where + ty_args = arg_tys ++ [res_ty] + +scalarClosure :: [Type] -> Type -> CoreExpr -> CoreExpr -> VM CoreExpr +scalarClosure arg_tys res_ty scalar_fun array_fun + = do + ctr <- builtin (closureCtrFun $ length arg_tys) + pas <- mapM paDictOfType (init arg_tys) + return $ Var ctr `mkTyApps` (arg_tys ++ [res_ty]) + `mkApps` (pas ++ [scalar_fun, array_fun]) + newLocalVVar :: FastString -> Type -> VM VVar newLocalVVar fs vty = do