Move vectorisation-related smart constructors into a separate module
[ghc-hetmet.git] / compiler / vectorise / VectCore.hs
1 module VectCore (
2   Vect, VVar, VExpr,
3
4   vectorised, lifted,
5   mapVect,
6
7   vVar, mkVLams, mkVVarApps
8 ) where
9
10 #include "HsVersions.h"
11
12 import CoreSyn
13 import Var
14
15 type Vect a = (a,a)
16 type VVar   = Vect Var
17 type VExpr  = Vect CoreExpr
18
19 vectorised :: Vect a -> a
20 vectorised = fst
21
22 lifted :: Vect a -> a
23 lifted = snd
24
25 mapVect :: (a -> b) -> Vect a -> Vect b
26 mapVect f (x,y) = (f x, f y)
27
28 vVar :: VVar -> VExpr
29 vVar = mapVect Var
30
31 mkVLams :: [VVar] -> VExpr -> VExpr
32 mkVLams vvs (ve,le) = (mkLams vs ve, mkLams ls le)
33   where
34     (vs,ls) = unzip vvs
35
36 mkVVarApps :: Var -> VExpr -> [VVar] -> VExpr
37 mkVVarApps lc (ve, le) vvs = (ve `mkVarApps` vs, le `mkVarApps` (lc : ls))
38   where
39     (vs,ls) = unzip vvs 
40
41