Commit 7231f88b authored by chak@cse.unsw.edu.au.'s avatar chak@cse.unsw.edu.au.

Wibbles

parent 9097e67b
......@@ -17,6 +17,7 @@ module Vectorise.Var (
vectPolyVar,
vectLiteral
) where
import Vectorise.Utils
import Vectorise.Monad
import Vectorise.Env
......@@ -32,6 +33,7 @@ import Control.Monad
-- Binders ----------------------------------------------------------------------------------------
-- | Vectorise a binder variable, along with its attached type.
vectBndr :: Var -> VM VVar
vectBndr v
......@@ -45,7 +47,6 @@ vectBndr v
where
mapTo vv lv env = env { local_vars = extendVarEnv (local_vars env) v (vv, lv) }
-- | Vectorise a binder variable, along with its attached type,
-- but give the result a new name.
vectBndrNew :: Var -> FastString -> VM VVar
......@@ -57,7 +58,6 @@ vectBndrNew v fs
where
upd vv env = env { local_vars = extendVarEnv (local_vars env) v vv }
-- | Vectorise a binder then run a computation with that binder in scope.
vectBndrIn :: Var -> VM a -> VM (VVar, a)
vectBndrIn v p
......@@ -66,7 +66,6 @@ vectBndrIn v p
x <- p
return (vv, x)
-- | Vectorise a binder, give it a new name, then run a computation with that binder in scope.
vectBndrNewIn :: Var -> FastString -> VM a -> VM (VVar, a)
vectBndrNewIn v fs p
......@@ -75,7 +74,6 @@ vectBndrNewIn v fs p
x <- p
return (vv, x)
-- | Vectorise some binders, then run a computation with them in scope.
vectBndrsIn :: [Var] -> VM a -> VM ([VVar], a)
vectBndrsIn vs p
......@@ -86,6 +84,7 @@ vectBndrsIn vs p
-- Variables --------------------------------------------------------------------------------------
-- | Vectorise a variable, producing the vectorised and lifted versions.
vectVar :: Var -> VM VExpr
vectVar v
......@@ -105,8 +104,9 @@ vectVar v
lexpr <- liftPD vexpr
return (vexpr, lexpr)
-- | Like `vectVar` but also add type applications to the variables.
-- FIXME: 'vectVar' is really just a special case, which 'vectPolyVar' should handle fine as well —
-- MERGE the two functions!
vectPolyVar :: Var -> [Type] -> VM VExpr
vectPolyVar v tys
= do vtys <- mapM vectType tys
......@@ -123,6 +123,7 @@ vectPolyVar v tys
-- Literals ---------------------------------------------------------------------------------------
-- | Lifted literals are created by replicating them
-- We use the the integer context in the `VM` state for the number
-- of elements in the output array.
......@@ -130,4 +131,3 @@ vectLiteral :: Literal -> VM VExpr
vectLiteral lit
= do lexpr <- liftPD (Lit lit)
return (Lit lit, lexpr)
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