2 Vect, VVar, VExpr, VBind,
9 vVar, vType, vNote, vLet,
10 vLams, vLamsWithoutLC, vVarApps,
11 vCaseDEFAULT, vCaseProd
14 #include "HsVersions.h"
17 import CoreUtils ( exprType )
18 import DataCon ( DataCon )
20 import Id ( mkWildId )
25 type VExpr = Vect CoreExpr
26 type VBind = Vect CoreBind
28 vectorised :: Vect a -> a
34 mapVect :: (a -> b) -> Vect a -> Vect b
35 mapVect f (x,y) = (f x, f y)
37 zipWithVect :: (a -> b -> c) -> Vect a -> Vect b -> Vect c
38 zipWithVect f (x1,y1) (x2,y2) = (f x1 x2, f y1 y2)
43 vType :: Type -> VExpr
44 vType ty = (Type ty, Type ty)
46 vNote :: Note -> VExpr -> VExpr
47 vNote = mapVect . Note
49 vNonRec :: VVar -> VExpr -> VBind
50 vNonRec = zipWithVect NonRec
52 vRec :: [VVar] -> [VExpr] -> VBind
53 vRec vs es = (Rec (zip vvs ves), Rec (zip lvs les))
58 vLet :: VBind -> VExpr -> VExpr
59 vLet = zipWithVect Let
61 vLams :: Var -> [VVar] -> VExpr -> VExpr
62 vLams lc vs (ve, le) = (mkLams vvs ve, mkLams (lc:lvs) le)
66 vLamsWithoutLC :: [VVar] -> VExpr -> VExpr
67 vLamsWithoutLC vvs (ve,le) = (mkLams vs ve, mkLams ls le)
71 vVarApps :: Var -> VExpr -> [VVar] -> VExpr
72 vVarApps lc (ve, le) vvs = (ve `mkVarApps` vs, le `mkVarApps` (lc : ls))
76 vCaseDEFAULT :: VExpr -> VVar -> Type -> Type -> VExpr -> VExpr
77 vCaseDEFAULT (vscrut, lscrut) (vbndr, lbndr) vty lty (vbody, lbody)
78 = (Case vscrut vbndr vty (mkDEFAULT vbody),
79 Case lscrut lbndr lty (mkDEFAULT lbody))
81 mkDEFAULT e = [(DEFAULT, [], e)]
83 vCaseProd :: VExpr -> Type -> Type
84 -> DataCon -> DataCon -> [Var] -> [VVar] -> VExpr -> VExpr
85 vCaseProd (vscrut, lscrut) vty lty vdc ldc sh_bndrs bndrs
87 = (Case vscrut (mkWildId $ exprType vscrut) vty
88 [(DataAlt vdc, vbndrs, vbody)],
89 Case lscrut (mkWildId $ exprType lscrut) lty
90 [(DataAlt ldc, sh_bndrs ++ lbndrs, lbody)])
92 (vbndrs, lbndrs) = unzip bndrs