X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectUtils.hs;h=caa4f4055d102f5484b6c448457f3615bd9f3043;hb=a139addf4890fc2167949680ead07ab809a9d98b;hp=8121c0627e662e4db1317d2c22bbfcf109293cfb;hpb=39a924f10cb4fed95d8fc0caf209876a693ab1f9;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectUtils.hs b/compiler/vectorise/VectUtils.hs index 8121c06..caa4f40 100644 --- a/compiler/vectorise/VectUtils.hs +++ b/compiler/vectorise/VectUtils.hs @@ -5,13 +5,13 @@ module VectUtils ( newLocalVVar, - mkBuiltinCo, voidType, + mkBuiltinCo, voidType, mkWrapType, mkPADictType, mkPArrayType, mkPDataType, mkPReprType, mkPArray, pdataReprTyCon, pdataReprDataCon, mkVScrut, - prDFunOfTyCon, + prDictOfType, prDFunOfTyCon, paDictArgType, paDictOfType, paDFunType, - paMethod, mkPR, replicatePD, emptyPD, packPD, + paMethod, wrapPR, replicatePD, emptyPD, packPD, combinePD, liftPD, zipScalars, scalarClosure, @@ -100,6 +100,9 @@ mkBuiltinTyConApps get_tc tys ty voidType :: VM Type voidType = mkBuiltinTyConApp voidTyCon [] +mkWrapType :: Type -> VM Type +mkWrapType ty = mkBuiltinTyConApp wrapTyCon [ty] + mkClosureTypes :: [Type] -> Type -> VM Type mkClosureTypes = mkBuiltinTyConApps closureTyCon @@ -228,12 +231,32 @@ paMethod method _ ty dict <- paDictOfType ty return $ mkApps (Var fn) [Type ty, dict] -mkPR :: Type -> VM CoreExpr -mkPR ty +prDictOfType :: Type -> VM CoreExpr +prDictOfType ty = prDictOfTyApp ty_fn ty_args + where + (ty_fn, ty_args) = splitAppTys ty + +prDictOfTyApp :: Type -> [Type] -> VM CoreExpr +prDictOfTyApp ty_fn ty_args + | Just ty_fn' <- coreView ty_fn = prDictOfTyApp ty_fn' ty_args +prDictOfTyApp (TyConApp tc _) ty_args = do - fn <- builtin mkPRVar - dict <- paDictOfType ty - return $ mkApps (Var fn) [Type ty, dict] + dfun <- prDFunOfTyCon tc + prDFunApply dfun ty_args +prDictOfTyApp ty _ = noV + +prDFunApply :: CoreExpr -> [Type] -> VM CoreExpr +prDFunApply dfun tys + = do + dicts <- mapM prDictOfType tys + return $ mkApps (mkTyApps dfun tys) dicts + +wrapPR :: Type -> VM CoreExpr +wrapPR ty + = do + pa_dict <- paDictOfType ty + pr_dfun <- prDFunOfTyCon =<< builtin wrapTyCon + return $ mkApps pr_dfun [Type ty, pa_dict] replicatePD :: CoreExpr -> CoreExpr -> VM CoreExpr replicatePD len x = liftM (`mkApps` [len,x])