X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectCore.hs;h=d651526ddf33c50f9a1356db4b803d84980e5a50;hb=cfccfa67393fcf8cb43aaa465d421b67c7117580;hp=9118214b4ce02a368e8cb53905099adaf73d707f;hpb=02cff9dfe0e5f6b9a92949ee988989e16d764f8b;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectCore.hs b/compiler/vectorise/VectCore.hs index 9118214..d651526 100644 --- a/compiler/vectorise/VectCore.hs +++ b/compiler/vectorise/VectCore.hs @@ -4,10 +4,13 @@ module VectCore ( vectorised, lifted, mapVect, + vVarType, + vNonRec, vRec, vVar, vType, vNote, vLet, - mkVLams, mkVVarApps + vLams, vLamsWithoutLC, vVarApps, + vCaseDEFAULT, vInlineMe ) where #include "HsVersions.h" @@ -15,6 +18,7 @@ module VectCore ( import CoreSyn import Type ( Type ) import Var +import Outputable type Vect a = (a,a) type VVar = Vect Var @@ -33,6 +37,9 @@ mapVect f (x,y) = (f x, f y) zipWithVect :: (a -> b -> c) -> Vect a -> Vect b -> Vect c zipWithVect f (x1,y1) (x2,y2) = (f x1 x2, f y1 y2) +vVarType :: VVar -> Type +vVarType = varType . vectorised + vVar :: VVar -> VExpr vVar = mapVect Var @@ -54,14 +61,30 @@ vRec vs es = (Rec (zip vvs ves), Rec (zip lvs les)) vLet :: VBind -> VExpr -> VExpr vLet = zipWithVect Let -mkVLams :: [VVar] -> VExpr -> VExpr -mkVLams vvs (ve,le) = (mkLams vs ve, mkLams ls le) +vLams :: Var -> [VVar] -> VExpr -> VExpr +vLams lc vs (ve, le) = (mkLams vvs ve, mkLams (lc:lvs) le) + where + (vvs,lvs) = unzip vs + +vLamsWithoutLC :: [VVar] -> VExpr -> VExpr +vLamsWithoutLC vvs (ve,le) = (mkLams vs ve, mkLams ls le) where (vs,ls) = unzip vvs -mkVVarApps :: Var -> VExpr -> [VVar] -> VExpr -mkVVarApps lc (ve, le) vvs = (ve `mkVarApps` vs, le `mkVarApps` (lc : ls)) +vVarApps :: Var -> VExpr -> [VVar] -> VExpr +vVarApps lc (ve, le) vvs = (ve `mkVarApps` vs, le `mkVarApps` (lc : ls)) where (vs,ls) = unzip vvs +vCaseDEFAULT :: VExpr -> VVar -> Type -> Type -> VExpr -> VExpr +vCaseDEFAULT (vscrut, lscrut) (vbndr, lbndr) vty lty (vbody, lbody) + = (Case vscrut vbndr vty (mkDEFAULT vbody), + Case lscrut lbndr lty (mkDEFAULT lbody)) + where + mkDEFAULT e = [(DEFAULT, [], e)] + +vInlineMe :: VExpr -> VExpr +vInlineMe (vexpr, lexpr) = (mkInlineMe vexpr, mkInlineMe lexpr) +mkInlineMe :: CoreExpr -> CoreExpr +mkInlineMe = pprTrace "VectCore.mkInlineMe" (text "Roman: need to replace mkInlineMe with an InlineRule somehow")