module Vectorise.Builtins (
Builtins(..),
indexBuiltin,
selTy,
selReplicate,
selPick,
selTags,
selElements,
sumTyCon,
prodTyCon,
prodDataCon,
combinePDVar,
scalarZip,
closureCtrFun,
initBuiltins, initBuiltinVars, initBuiltinTyCons, initBuiltinDataCons,
initBuiltinPAs, initBuiltinPRs,
initBuiltinBoxedTyCons,
primMethod,
primPArray
) where
import Vectorise.Builtins.Base
import Vectorise.Builtins.Modules
import Vectorise.Builtins.Initialise
import TysPrim
import IfaceEnv
import TyCon
import DsMonad
import NameEnv
import Name
import Var
import Control.Monad
primMethod :: TyCon -> String -> Builtins -> DsM (Maybe Var)
primMethod tycon method (Builtins { dphModules = mods })
| Just suffix <- lookupNameEnv prim_ty_cons (tyConName tycon)
= liftM Just
$ dsLookupGlobalId =<< lookupOrig (dph_Unboxed mods)
(mkVarOcc $ method ++ suffix)
| otherwise = return Nothing
primPArray :: TyCon -> Builtins -> DsM (Maybe TyCon)
primPArray tycon (Builtins { dphModules = mods })
| Just suffix <- lookupNameEnv prim_ty_cons (tyConName tycon)
= liftM Just
$ dsLookupTyCon =<< lookupOrig (dph_Unboxed mods)
(mkTcOcc $ "PArray" ++ suffix)
| otherwise = return Nothing
prim_ty_cons :: NameEnv String
prim_ty_cons = mkNameEnv [mk_prim intPrimTyCon]
where
mk_prim tycon = (tyConName tycon, '_' : getOccString tycon)