Vectorise.Builtins

ghc-7.0.4: The GHC API

Vectorise.Builtins

Contents

- Builtins
- Wrapped selectors
- Initialisation
- Lookup

Description

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.

Synopsis

- 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

data Builtins

Holds the names of the builtin types and functions used by the vectoriser.

Constructors

Builtins |
Fields dphModules :: Modules parrayTyCon :: TyCon PArray parrayDataCon :: DataCon PArray pdataTyCon :: TyCon PData paTyCon :: TyCon PA paDataCon :: DataCon PA preprTyCon :: TyCon PRepr prTyCon :: TyCon PR prDataCon :: DataCon PR replicatePDVar :: Var replicatePD emptyPDVar :: Var emptyPD packByTagPDVar :: Var packByTagPD combinePDVars :: Array Int Var combinePD scalarClass :: Class Scalar closureTyCon :: TyCon :-> closureVar :: Var closure applyVar :: Var $: liftedClosureVar :: Var liftedClosure liftedApplyVar :: Var liftedApply closureCtrFuns :: Array Int Var closure1 .. closure2 voidTyCon :: TyCon Void wrapTyCon :: TyCon Wrap sumTyCons :: Array Int TyCon Sum2 .. Sum3 voidVar :: Var void pvoidVar :: Var pvoid fromVoidVar :: Var fromVoid punitVar :: Var punit selTys :: Array Int Type Sel2 selReplicates :: Array Int CoreExpr replicate2 selPicks :: Array Int CoreExpr pick2 selTagss :: Array Int CoreExpr tagsSel2 selEls :: Array (Int, Int) CoreExpr elementsSel2_0 .. elementsSel_2_1 scalarZips :: Array Int Var map, zipWith, zipWith3 liftingContext :: Var lc

indexBuiltin

Arguments

:: (Ix i, Outputable i) |
=> String | Name of the selector we've used, for panic messages.
-> (Builtins -> Array i a) | Field selector for the `Builtins`.
-> 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

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

# Initialisation

initBuiltins

Arguments

:: PackageId | package id the builtins are in, eg dph-common
-> DsM Builtins |

Create the initial map of builtin types and functions.

initBuiltinVars :: Builtins -> DsM [(Var, Var)]

Get the mapping of names in the Prelude to names in the DPH library.

initBuiltinTyCons :: Builtins -> DsM [(Name, TyCon)]

Get a list of names to `TyCon`s in the mock prelude.

initBuiltinDataCons :: Builtins -> [(Name, DataCon)]

Get a list of names to `DataCon`s in the mock prelude.

initBuiltinPAs :: Builtins -> (InstEnv, InstEnv) -> DsM [(Name, Var)]

Get the names of all buildin instance functions for the PA class.

initBuiltinPRs :: Builtins -> (InstEnv, InstEnv) -> DsM [(Name, Var)]

Get the names of all builtin instance functions for the PR class.

initBuiltinBoxedTyCons :: Builtins -> DsM [(Name, TyCon)]

Get a list of boxed `TyCons` in the mock prelude. This is Int only.

initBuiltinScalars :: Builtins -> DsM [Var]

Get a list of all scalar functions in the mock prelude.

# Lookup

primMethod :: TyCon -> String -> Builtins -> DsM (Maybe Var)

Lookup a method function given its name and instance type.

primPArray :: TyCon -> Builtins -> DsM (Maybe TyCon)

Lookup the representation type we use for PArrays that contain a given element type.