2 Vect, VVar, VExpr, VBind,
9 vVar, vType, vNote, vLet,
10 vLams, vLamsWithoutLC, vVarApps,
11 vCaseDEFAULT, vCaseProd
14 -- XXX This define is a bit of a hack, and should be done more nicely
15 #define FAST_STRING_NOT_NEEDED 1
16 #include "HsVersions.h"
19 import CoreUtils ( exprType )
20 import DataCon ( DataCon )
22 import Id ( mkWildId )
27 type VExpr = Vect CoreExpr
28 type VBind = Vect CoreBind
30 vectorised :: Vect a -> a
36 mapVect :: (a -> b) -> Vect a -> Vect b
37 mapVect f (x,y) = (f x, f y)
39 zipWithVect :: (a -> b -> c) -> Vect a -> Vect b -> Vect c
40 zipWithVect f (x1,y1) (x2,y2) = (f x1 x2, f y1 y2)
45 vType :: Type -> VExpr
46 vType ty = (Type ty, Type ty)
48 vNote :: Note -> VExpr -> VExpr
49 vNote = mapVect . Note
51 vNonRec :: VVar -> VExpr -> VBind
52 vNonRec = zipWithVect NonRec
54 vRec :: [VVar] -> [VExpr] -> VBind
55 vRec vs es = (Rec (zip vvs ves), Rec (zip lvs les))
60 vLet :: VBind -> VExpr -> VExpr
61 vLet = zipWithVect Let
63 vLams :: Var -> [VVar] -> VExpr -> VExpr
64 vLams lc vs (ve, le) = (mkLams vvs ve, mkLams (lc:lvs) le)
68 vLamsWithoutLC :: [VVar] -> VExpr -> VExpr
69 vLamsWithoutLC vvs (ve,le) = (mkLams vs ve, mkLams ls le)
73 vVarApps :: Var -> VExpr -> [VVar] -> VExpr
74 vVarApps lc (ve, le) vvs = (ve `mkVarApps` vs, le `mkVarApps` (lc : ls))
78 vCaseDEFAULT :: VExpr -> VVar -> Type -> Type -> VExpr -> VExpr
79 vCaseDEFAULT (vscrut, lscrut) (vbndr, lbndr) vty lty (vbody, lbody)
80 = (Case vscrut vbndr vty (mkDEFAULT vbody),
81 Case lscrut lbndr lty (mkDEFAULT lbody))
83 mkDEFAULT e = [(DEFAULT, [], e)]
85 vCaseProd :: VExpr -> Type -> Type
86 -> DataCon -> DataCon -> [Var] -> [VVar] -> VExpr -> VExpr
87 vCaseProd (vscrut, lscrut) vty lty vdc ldc sh_bndrs bndrs
89 = (Case vscrut (mkWildId $ exprType vscrut) vty
90 [(DataAlt vdc, vbndrs, vbody)],
91 Case lscrut (mkWildId $ exprType lscrut) lty
92 [(DataAlt ldc, sh_bndrs ++ lbndrs, lbody)])
94 (vbndrs, lbndrs) = unzip bndrs