From 2b63f556718d02f9d7b323e6bb545fdd9c705c34 Mon Sep 17 00:00:00 2001 From: Roman Leshchinskiy Date: Fri, 24 Aug 2007 03:29:30 +0000 Subject: [PATCH] Move code --- compiler/vectorise/VectType.hs | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/compiler/vectorise/VectType.hs b/compiler/vectorise/VectType.hs index 6f6fca8..fafc2fe 100644 --- a/compiler/vectorise/VectType.hs +++ b/compiler/vectorise/VectType.hs @@ -250,6 +250,24 @@ buildToPRepr (TyConRepr { where [dc] = tyConDataCons tc +buildFromPRepr :: TyConRepr -> TyCon -> TyCon -> TyCon -> VM CoreExpr +buildFromPRepr _ vect_tc prepr_tc _ + = do + arg_ty <- mkPReprType res_ty + arg <- newLocalVar FSLIT("x") arg_ty + alts <- mapM mk_alt data_cons + body <- mkFromPRepr (unwrapFamInstScrut prepr_tc var_tys (Var arg)) + res_ty alts + return $ Lam arg body + where + var_tys = mkTyVarTys $ tyConTyVars vect_tc + res_ty = mkTyConApp vect_tc var_tys + data_cons = tyConDataCons vect_tc + + mk_alt dc = do + bndrs <- mapM (newLocalVar FSLIT("x")) $ dataConRepArgTys dc + return (bndrs, mkConApp dc (map Type var_tys ++ map Var bndrs)) + buildToArrPRepr :: TyConRepr -> TyCon -> TyCon -> TyCon -> VM CoreExpr buildToArrPRepr _ vect_tc prepr_tc arr_tc = do @@ -286,25 +304,6 @@ buildToArrPRepr _ vect_tc prepr_tc arr_tc has_selector | [_] <- data_cons = False | otherwise = True - -buildFromPRepr :: TyConRepr -> TyCon -> TyCon -> TyCon -> VM CoreExpr -buildFromPRepr _ vect_tc prepr_tc _ - = do - arg_ty <- mkPReprType res_ty - arg <- newLocalVar FSLIT("x") arg_ty - alts <- mapM mk_alt data_cons - body <- mkFromPRepr (unwrapFamInstScrut prepr_tc var_tys (Var arg)) - res_ty alts - return $ Lam arg body - where - var_tys = mkTyVarTys $ tyConTyVars vect_tc - res_ty = mkTyConApp vect_tc var_tys - data_cons = tyConDataCons vect_tc - - mk_alt dc = do - bndrs <- mapM (newLocalVar FSLIT("x")) $ dataConRepArgTys dc - return (bndrs, mkConApp dc (map Type var_tys ++ map Var bndrs)) - buildFromArrPRepr :: TyConRepr -> TyCon -> TyCon -> TyCon -> VM CoreExpr buildFromArrPRepr _ vect_tc prepr_tc arr_tc = mkFromArrPRepr undefined undefined undefined undefined undefined undefined -- 1.7.10.4