2 Vect, VVar, VExpr, VBind,
11 vVar, vType, vNote, vLet,
12 vLams, vLamsWithoutLC, vVarApps,
13 vCaseDEFAULT, vInlineMe
16 #include "HsVersions.h"
19 import CoreUtils ( mkInlineMe )
20 import MkCore ( mkWildCase )
21 import CoreUtils ( exprType )
22 import DataCon ( DataCon )
28 type VExpr = Vect CoreExpr
29 type VBind = Vect CoreBind
31 vectorised :: Vect a -> a
37 mapVect :: (a -> b) -> Vect a -> Vect b
38 mapVect f (x,y) = (f x, f y)
40 zipWithVect :: (a -> b -> c) -> Vect a -> Vect b -> Vect c
41 zipWithVect f (x1,y1) (x2,y2) = (f x1 x2, f y1 y2)
43 vVarType :: VVar -> Type
44 vVarType = varType . vectorised
49 vType :: Type -> VExpr
50 vType ty = (Type ty, Type ty)
52 vNote :: Note -> VExpr -> VExpr
53 vNote = mapVect . Note
55 vNonRec :: VVar -> VExpr -> VBind
56 vNonRec = zipWithVect NonRec
58 vRec :: [VVar] -> [VExpr] -> VBind
59 vRec vs es = (Rec (zip vvs ves), Rec (zip lvs les))
64 vLet :: VBind -> VExpr -> VExpr
65 vLet = zipWithVect Let
67 vLams :: Var -> [VVar] -> VExpr -> VExpr
68 vLams lc vs (ve, le) = (mkLams vvs ve, mkLams (lc:lvs) le)
72 vLamsWithoutLC :: [VVar] -> VExpr -> VExpr
73 vLamsWithoutLC vvs (ve,le) = (mkLams vs ve, mkLams ls le)
77 vVarApps :: Var -> VExpr -> [VVar] -> VExpr
78 vVarApps lc (ve, le) vvs = (ve `mkVarApps` vs, le `mkVarApps` (lc : ls))
82 vCaseDEFAULT :: VExpr -> VVar -> Type -> Type -> VExpr -> VExpr
83 vCaseDEFAULT (vscrut, lscrut) (vbndr, lbndr) vty lty (vbody, lbody)
84 = (Case vscrut vbndr vty (mkDEFAULT vbody),
85 Case lscrut lbndr lty (mkDEFAULT lbody))
87 mkDEFAULT e = [(DEFAULT, [], e)]
89 vInlineMe :: VExpr -> VExpr
90 vInlineMe (vexpr, lexpr) = (mkInlineMe vexpr, mkInlineMe lexpr)