X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=compiler%2Fvectorise%2FVectUtils.hs;h=718db856d2200d700cbf7d40af76aef8df5018df;hb=29df68c2801bd9aad3e1b55a46bd0c91b802648f;hp=d6569e70cd8892e5bbf55dccd04520588b5a5205;hpb=ce39c447ab47ac1616cea079210c7651f486f425;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectUtils.hs b/compiler/vectorise/VectUtils.hs index d6569e7..718db85 100644 --- a/compiler/vectorise/VectUtils.hs +++ b/compiler/vectorise/VectUtils.hs @@ -8,7 +8,8 @@ module VectUtils ( polyAbstract, polyApply, polyVApply, lookupPArrayFamInst, hoistExpr, hoistPolyVExpr, takeHoisted, - buildClosure, buildClosures + buildClosure, buildClosures, + mkClosureApp ) where #include "HsVersions.h" @@ -239,7 +240,6 @@ takeHoisted setGEnv $ env { global_bindings = [] } return $ global_bindings env - mkClosure :: Type -> Type -> Type -> VExpr -> VExpr -> VM VExpr mkClosure arg_ty res_ty env_ty (vfn,lfn) (venv,lenv) = do @@ -249,6 +249,16 @@ mkClosure arg_ty res_ty env_ty (vfn,lfn) (venv,lenv) return (Var mkv `mkTyApps` [arg_ty, res_ty, env_ty] `mkApps` [dict, vfn, lfn, venv], Var mkl `mkTyApps` [arg_ty, res_ty, env_ty] `mkApps` [dict, vfn, lfn, lenv]) +mkClosureApp :: VExpr -> VExpr -> VM VExpr +mkClosureApp (vclo, lclo) (varg, larg) + = do + vapply <- builtin applyClosureVar + lapply <- builtin applyClosurePVar + return (Var vapply `mkTyApps` [arg_ty, res_ty] `mkApps` [vclo, varg], + Var lapply `mkTyApps` [arg_ty, res_ty] `mkApps` [lclo, larg]) + where + (arg_ty, res_ty) = splitClosureTy (exprType vclo) + buildClosures :: [TyVar] -> Var -> [VVar] -> [Type] -> Type -> VM VExpr -> VM VExpr buildClosures tvs lc vars [arg_ty] res_ty mk_body = buildClosure tvs lc vars arg_ty res_ty mk_body