X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fvectorise%2FVectCore.hs;h=248bcb62e10fced651139bcce77cdf8ce67df56c;hb=6bd4bdcbb35bb49728a025cf3b4b2a87793dbe8e;hp=23fe0e4064de42b669e0c5188efb4518c7e1b6fb;hpb=0a21de62e274acc8e8e260298da4f6c1ee18ecc2;p=ghc-hetmet.git diff --git a/compiler/vectorise/VectCore.hs b/compiler/vectorise/VectCore.hs index 23fe0e4..248bcb6 100644 --- a/compiler/vectorise/VectCore.hs +++ b/compiler/vectorise/VectCore.hs @@ -1,3 +1,10 @@ +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module VectCore ( Vect, VVar, VExpr, VBind, @@ -7,14 +14,17 @@ module VectCore ( vNonRec, vRec, vVar, vType, vNote, vLet, - vLams, - mkVLams, mkVVarApps + vLams, vLamsWithoutLC, vVarApps, + vCaseDEFAULT, vCaseProd ) where #include "HsVersions.h" import CoreSyn +import CoreUtils ( exprType ) +import DataCon ( DataCon ) import Type ( Type ) +import Id ( mkWildId ) import Var type Vect a = (a,a) @@ -60,14 +70,30 @@ vLams lc vs (ve, le) = (mkLams vvs ve, mkLams (lc:lvs) le) where (vvs,lvs) = unzip vs -mkVLams :: [VVar] -> VExpr -> VExpr -mkVLams vvs (ve,le) = (mkLams vs ve, mkLams ls le) +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)] + +vCaseProd :: VExpr -> Type -> Type + -> DataCon -> DataCon -> [Var] -> [VVar] -> VExpr -> VExpr +vCaseProd (vscrut, lscrut) vty lty vdc ldc sh_bndrs bndrs + (vbody,lbody) + = (Case vscrut (mkWildId $ exprType vscrut) vty + [(DataAlt vdc, vbndrs, vbody)], + Case lscrut (mkWildId $ exprType lscrut) lty + [(DataAlt ldc, sh_bndrs ++ lbndrs, lbody)]) + where + (vbndrs, lbndrs) = unzip bndrs