Builtin types and functions used by the vectoriser. The source program uses functions from GHC.PArr, which the vectoriser rewrites to use equivalent vectorised versions in the DPH backend packages.
The Builtins
structure holds the name of all the things in the DPH packages
we will need. We can get specific things using the selectors, which print a
civilized panic message if the specified thing cannot be found.
- data Builtins = Builtins {
- dphModules :: Modules
- parrayTyCon :: TyCon
- parrayDataCon :: DataCon
- pdataTyCon :: TyCon
- paTyCon :: TyCon
- paDataCon :: DataCon
- preprTyCon :: TyCon
- prTyCon :: TyCon
- prDataCon :: DataCon
- replicatePDVar :: Var
- emptyPDVar :: Var
- packByTagPDVar :: Var
- combinePDVars :: Array Int Var
- scalarClass :: Class
- closureTyCon :: TyCon
- closureVar :: Var
- applyVar :: Var
- liftedClosureVar :: Var
- liftedApplyVar :: Var
- closureCtrFuns :: Array Int Var
- voidTyCon :: TyCon
- wrapTyCon :: TyCon
- sumTyCons :: Array Int TyCon
- voidVar :: Var
- pvoidVar :: Var
- fromVoidVar :: Var
- punitVar :: Var
- selTys :: Array Int Type
- selReplicates :: Array Int CoreExpr
- selPicks :: Array Int CoreExpr
- selTagss :: Array Int CoreExpr
- selEls :: Array (Int, Int) CoreExpr
- scalarZips :: Array Int Var
- liftingContext :: Var
- indexBuiltin :: (Ix i, Outputable i) => String -> (Builtins -> Array i a) -> i -> Builtins -> a
- selTy :: Int -> Builtins -> Type
- selReplicate :: Int -> Builtins -> CoreExpr
- selPick :: Int -> Builtins -> CoreExpr
- selTags :: Int -> Builtins -> CoreExpr
- selElements :: Int -> Int -> Builtins -> CoreExpr
- sumTyCon :: Int -> Builtins -> TyCon
- prodTyCon :: Int -> Builtins -> TyCon
- prodDataCon :: Int -> Builtins -> DataCon
- combinePDVar :: Int -> Builtins -> Var
- scalarZip :: Int -> Builtins -> Var
- closureCtrFun :: Int -> Builtins -> Var
- initBuiltins :: PackageId -> DsM Builtins
- initBuiltinVars :: Builtins -> DsM [(Var, Var)]
- initBuiltinTyCons :: Builtins -> DsM [(Name, TyCon)]
- initBuiltinDataCons :: Builtins -> [(Name, DataCon)]
- initBuiltinPAs :: Builtins -> (InstEnv, InstEnv) -> DsM [(Name, Var)]
- initBuiltinPRs :: Builtins -> (InstEnv, InstEnv) -> DsM [(Name, Var)]
- initBuiltinBoxedTyCons :: Builtins -> DsM [(Name, TyCon)]
- initBuiltinScalars :: Builtins -> DsM [Var]
- primMethod :: TyCon -> String -> Builtins -> DsM (Maybe Var)
- primPArray :: TyCon -> Builtins -> DsM (Maybe TyCon)
Builtins
Holds the names of the builtin types and functions used by the vectoriser.
:: (Ix i, Outputable i) | |
=> String | Name of the selector we've used, for panic messages. |
-> (Builtins -> Array i a) | Field selector for the |
-> i | Index into the array. |
-> Builtins | |
-> a |
Get an element from one of the arrays of contained by a Builtins
.
If the indexed thing is not in the array then panic.
Wrapped selectors
selReplicate :: Int -> Builtins -> CoreExprSource
prodDataCon :: Int -> Builtins -> DataConSource
combinePDVar :: Int -> Builtins -> VarSource
closureCtrFun :: Int -> Builtins -> VarSource
Initialisation
Create the initial map of builtin types and functions.
initBuiltinVars :: Builtins -> DsM [(Var, Var)]Source
Get the mapping of names in the Prelude to names in the DPH library.
initBuiltinTyCons :: Builtins -> DsM [(Name, TyCon)]Source
Get a list of names to TyCon
s in the mock prelude.
initBuiltinDataCons :: Builtins -> [(Name, DataCon)]Source
Get a list of names to DataCon
s in the mock prelude.
initBuiltinPAs :: Builtins -> (InstEnv, InstEnv) -> DsM [(Name, Var)]Source
Get the names of all buildin instance functions for the PA class.
initBuiltinPRs :: Builtins -> (InstEnv, InstEnv) -> DsM [(Name, Var)]Source
Get the names of all builtin instance functions for the PR class.
initBuiltinBoxedTyCons :: Builtins -> DsM [(Name, TyCon)]Source
Get a list of boxed TyCons
in the mock prelude. This is Int only.
initBuiltinScalars :: Builtins -> DsM [Var]Source
Get a list of all scalar functions in the mock prelude.