summaryrefslogtreecommitdiff
path: root/compiler/vectorise
diff options
context:
space:
mode:
authorRoman Leshchinskiy <rl@cse.unsw.edu.au>2007-08-31 01:26:38 +0000
committerRoman Leshchinskiy <rl@cse.unsw.edu.au>2007-08-31 01:26:38 +0000
commit17bf0a5763b2a94ee88f8bebfe61c84f20cc9d05 (patch)
tree0e91d5d6f2cae8b41e62d002989e50bcec9307ae /compiler/vectorise
parentfacf3d6c3a2eefb66ec0ecefb0e8b390ca59ac8c (diff)
downloadhaskell-17bf0a5763b2a94ee88f8bebfe61c84f20cc9d05.tar.gz
Refactoring
Diffstat (limited to 'compiler/vectorise')
-rw-r--r--compiler/vectorise/VectType.hs48
1 files changed, 27 insertions, 21 deletions
diff --git a/compiler/vectorise/VectType.hs b/compiler/vectorise/VectType.hs
index ca5f0c8279..6e10deec45 100644
--- a/compiler/vectorise/VectType.hs
+++ b/compiler/vectorise/VectType.hs
@@ -231,17 +231,23 @@ data Repr = ProdRepr {
, void_bottom :: CoreExpr
}
-mkVoid :: VM Repr
-mkVoid = do
- tycon <- builtin voidTyCon
- var <- builtin voidVar
- return $ VoidRepr {
- void_tycon = tycon
- , void_bottom = Var var
- }
-
-mkProduct :: [Type] -> VM Repr
-mkProduct tys
+voidRepr :: VM Repr
+voidRepr
+ = do
+ tycon <- builtin voidTyCon
+ var <- builtin voidVar
+ return $ VoidRepr {
+ void_tycon = tycon
+ , void_bottom = Var var
+ }
+
+unboxedProductRepr :: [Type] -> VM Repr
+unboxedProductRepr [] = voidRepr
+unboxedProductRepr [ty] = return $ IdRepr ty
+unboxedProductRepr tys = boxedProductRepr tys
+
+boxedProductRepr :: [Type] -> VM Repr
+boxedProductRepr tys
= do
tycon <- builtin (prodTyCon arity)
let [data_con] = tyConDataCons tycon
@@ -259,14 +265,10 @@ mkProduct tys
where
arity = length tys
-mkSubProduct :: [Type] -> VM Repr
-mkSubProduct [] = mkVoid
-mkSubProduct [ty] = return $ IdRepr ty
-mkSubProduct tys = mkProduct tys
-
-mkSum :: [Repr] -> VM Repr
-mkSum [repr] = return repr
-mkSum reprs
+sumRepr :: [Repr] -> VM Repr
+sumRepr [] = voidRepr
+sumRepr [repr] = boxRepr repr
+sumRepr reprs
= do
tycon <- builtin (sumTyCon arity)
(arr_tycon, _) <- parrayReprTyCon
@@ -284,6 +286,11 @@ mkSum reprs
where
arity = length reprs
+boxRepr :: Repr -> VM Repr
+boxRepr (VoidRepr {}) = boxedProductRepr []
+boxRepr (IdRepr ty) = boxedProductRepr [ty]
+boxRepr repr = return repr
+
reprType :: Repr -> Type
reprType (ProdRepr { prod_tycon = tycon, prod_components = tys })
= mkTyConApp tycon tys
@@ -347,8 +354,7 @@ arrReprVars repr
mkRepr :: TyCon -> VM Repr
mkRepr vect_tc
- | [tys] <- rep_tys = mkProduct tys
- | otherwise = mkSum =<< mapM mkSubProduct rep_tys
+ = sumRepr =<< mapM unboxedProductRepr rep_tys
where
rep_tys = map dataConRepArgTys $ tyConDataCons vect_tc