Move code
authorRoman Leshchinskiy <rl@cse.unsw.edu.au>
Fri, 24 Aug 2007 03:29:30 +0000 (03:29 +0000)
committerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Fri, 24 Aug 2007 03:29:30 +0000 (03:29 +0000)
compiler/vectorise/VectType.hs

index 6f6fca8..fafc2fe 100644 (file)
@@ -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