Copyright | (c) Mateusz Kłoczko 2016 |
---|---|
License | MIT |
Maintainer | mateusz.p.kloczko@gmail.com |
Stability | experimental |
Portability | GHC-only |
Safe Haskell | None |
Language | Haskell2010 |
The core of compile and substitute optimisations.
Synopsis
- compileExpr :: HscEnv -> CoreExpr -> SrcSpan -> IO a
- tryCompileExpr :: Id -> CoreExpr -> CoreM (Either Error a)
- intToExpr :: Type -> Int -> CoreExpr
- intSubstitution :: CoreBind -> CoreM (Either Error CoreBind)
- offsetSubstitution :: CoreBind -> CoreM (Either Error CoreBind)
- offsetSubstitutionTree :: [OffsetScope] -> CoreExpr -> CoreM (Either Error CoreExpr)
- data OffsetScope
- getScopeId :: OffsetScope -> Id
- getScopeExpr :: OffsetScope -> CoreExpr
- intListExpr :: [Int] -> CoreExpr
- exprToIntList :: Id -> CoreExpr -> CoreM (Either Error OffsetScope)
- isLitOrGlobal :: CoreExpr -> Maybe CoreExpr
- inScopeAll :: [OffsetScope] -> CoreExpr -> Maybe CoreExpr
- isIndexer :: Id -> Bool
- caseExprIndex :: [OffsetScope] -> CoreExpr -> Maybe CoreExpr
- compileGStorableBind :: CoreBind -> CoreM (Either Error CoreBind)
- lintBind :: CoreBind -> CoreBind -> CoreM (Either Error CoreBind)
- replaceIdsBind :: [CoreBind] -> [CoreBind] -> CoreBind -> CoreBind
- compileGroups :: Flags -> [[CoreBind]] -> [CoreBind] -> CoreM [CoreBind]
Documentation
tryCompileExpr :: Id -> CoreExpr -> CoreM (Either Error a) Source #
Try to compile an expression. Perhaps return an error.
intSubstitution :: CoreBind -> CoreM (Either Error CoreBind) Source #
For gsizeOf and galignment - calculate the variables.
offsetSubstitution :: CoreBind -> CoreM (Either Error CoreBind) Source #
Try to substitute the offsets.
offsetSubstitutionTree :: [OffsetScope] -> CoreExpr -> CoreM (Either Error CoreExpr) Source #
Substitute the offsets in a tree. All top-level local ids should be alread in place. Now try to compile selected expressions (See note [Offset substitution])
data OffsetScope Source #
Scoped variables for optimising offsets.
Instances
Outputable OffsetScope Source # | |
Defined in Foreign.Storable.Generic.Plugin.Internal.Compile ppr :: OffsetScope -> SDoc # pprPrec :: Rational -> OffsetScope -> SDoc # |
getScopeId :: OffsetScope -> Id Source #
Get Id
from OffsetScope
getScopeExpr :: OffsetScope -> CoreExpr Source #
Get CoreExpr
from OffsetScope
intListExpr :: [Int] -> CoreExpr Source #
Create a list expression from Haskell list.
exprToIntList :: Id -> CoreExpr -> CoreM (Either Error OffsetScope) Source #
Compile expression to list and then write it back to core expr.
isLitOrGlobal :: CoreExpr -> Maybe CoreExpr Source #
Return the expression if it's a literal or global.
inScopeAll :: [OffsetScope] -> CoreExpr -> Maybe CoreExpr Source #
Check whether the given CoreExpr is an id, and if yes - substitute it.
caseExprIndex :: [OffsetScope] -> CoreExpr -> Maybe CoreExpr Source #
Try to create a compileable version of case expr body. For !! @Int offsets val expressions.
compileGStorableBind :: CoreBind -> CoreM (Either Error CoreBind) Source #
Compile the expression in Core Bind and replace it.
:: CoreBind | Core binding to use when returning CompilationError |
-> CoreBind | Core binding to check |
-> CoreM (Either Error CoreBind) | Success or failure |
Lint a binding