2 Vect, VVar, VExpr, VBind,
9 vVar, vType, vNote, vLet,
10 vLams, vLamsWithoutLC, vVarApps,
11 vCaseDEFAULT, vCaseProd, vInlineMe
14 #include "HsVersions.h"
17 import CoreUtils ( mkInlineMe )
18 import MkCore ( mkWildCase )
19 import CoreUtils ( exprType )
20 import DataCon ( DataCon )
26 type VExpr = Vect CoreExpr
27 type VBind = Vect CoreBind
29 vectorised :: Vect a -> a
35 mapVect :: (a -> b) -> Vect a -> Vect b
36 mapVect f (x,y) = (f x, f y)
38 zipWithVect :: (a -> b -> c) -> Vect a -> Vect b -> Vect c
39 zipWithVect f (x1,y1) (x2,y2) = (f x1 x2, f y1 y2)
44 vType :: Type -> VExpr
45 vType ty = (Type ty, Type ty)
47 vNote :: Note -> VExpr -> VExpr
48 vNote = mapVect . Note
50 vNonRec :: VVar -> VExpr -> VBind
51 vNonRec = zipWithVect NonRec
53 vRec :: [VVar] -> [VExpr] -> VBind
54 vRec vs es = (Rec (zip vvs ves), Rec (zip lvs les))
59 vLet :: VBind -> VExpr -> VExpr
60 vLet = zipWithVect Let
62 vLams :: Var -> [VVar] -> VExpr -> VExpr
63 vLams lc vs (ve, le) = (mkLams vvs ve, mkLams (lc:lvs) le)
67 vLamsWithoutLC :: [VVar] -> VExpr -> VExpr
68 vLamsWithoutLC vvs (ve,le) = (mkLams vs ve, mkLams ls le)
72 vVarApps :: Var -> VExpr -> [VVar] -> VExpr
73 vVarApps lc (ve, le) vvs = (ve `mkVarApps` vs, le `mkVarApps` (lc : ls))
77 vCaseDEFAULT :: VExpr -> VVar -> Type -> Type -> VExpr -> VExpr
78 vCaseDEFAULT (vscrut, lscrut) (vbndr, lbndr) vty lty (vbody, lbody)
79 = (Case vscrut vbndr vty (mkDEFAULT vbody),
80 Case lscrut lbndr lty (mkDEFAULT lbody))
82 mkDEFAULT e = [(DEFAULT, [], e)]
84 vCaseProd :: VExpr -> Type -> Type
85 -> DataCon -> DataCon -> [Var] -> [VVar] -> VExpr -> VExpr
86 vCaseProd (vscrut, lscrut) vty lty vdc ldc sh_bndrs bndrs
88 = (mkWildCase vscrut (exprType vscrut) vty
89 [(DataAlt vdc, vbndrs, vbody)],
90 mkWildCase lscrut (exprType lscrut) lty
91 [(DataAlt ldc, sh_bndrs ++ lbndrs, lbody)])
93 (vbndrs, lbndrs) = unzip bndrs
95 vInlineMe :: VExpr -> VExpr
96 vInlineMe (vexpr, lexpr) = (mkInlineMe vexpr, mkInlineMe lexpr)