Commit 51ad52d4 authored by rl@cse.unsw.edu.au's avatar rl@cse.unsw.edu.au
Browse files

Vectorisation utilities

parent fd399de2
......@@ -11,7 +11,7 @@ module VectMonad (
noV, tryV, maybeV, traceMaybeV, orElseV, fixV, localV, closedV, initV,
liftDs,
cloneName, cloneId,
cloneName, cloneId, cloneVar,
newExportedVar, newLocalVar, newDummyVar, newTyVar,
Builtins(..), sumTyCon, prodTyCon,
......@@ -301,6 +301,9 @@ cloneId mk_occ id ty
| otherwise = Id.mkLocalId name ty
return id'
cloneVar :: Var -> VM Var
cloneVar var = liftM (setIdUnique var) (liftDs newUnique)
newExportedVar :: OccName -> Type -> VM Var
newExportedVar occ_name ty
= do
......
......@@ -6,6 +6,7 @@
-- for details
module VectType ( vectTyCon, vectType, vectTypeEnv,
mkRepr, arrShapeTys, arrShapeVars, arrSelector,
PAInstance, buildPADict )
where
......@@ -362,6 +363,10 @@ replicateShape (IdRepr _) _ _ = return []
replicateShape (VoidRepr {}) len _ = return [len]
replicateShape (EnumRepr {}) len _ = return [len]
arrSelector :: Repr -> [a] -> a
arrSelector (SumRepr {}) [_, sel, _] = sel
arrSelector _ _ = panic "arrSelector"
emptyArrRepr :: Repr -> VM [CoreExpr]
emptyArrRepr (SumRepr { sum_components = prods })
= liftM concat $ mapM emptyArrRepr prods
......
......@@ -8,7 +8,9 @@
module VectUtils (
collectAnnTypeBinders, collectAnnTypeArgs, isAnnTypeArg,
collectAnnValBinders,
mkDataConTag, mkDataConTagLit,
dataConTagZ, mkDataConTag, mkDataConTagLit,
newLocalVVar,
mkBuiltinCo,
mkPADictType, mkPArrayType, mkPReprType,
......@@ -74,12 +76,14 @@ isAnnTypeArg :: AnnExpr b ann -> Bool
isAnnTypeArg (_, AnnType t) = True
isAnnTypeArg _ = False
dataConTagZ :: DataCon -> Int
dataConTagZ con = dataConTag con - fIRST_TAG
mkDataConTagLit :: DataCon -> Literal
mkDataConTagLit con
= mkMachInt . toInteger $ dataConTag con - fIRST_TAG
mkDataConTagLit = mkMachInt . toInteger . dataConTagZ
mkDataConTag :: DataCon -> CoreExpr
mkDataConTag con = mkIntLitInt (dataConTag con - fIRST_TAG)
mkDataConTag = mkIntLitInt . dataConTagZ
splitPrimTyCon :: Type -> Maybe TyCon
splitPrimTyCon ty
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment