derive-storable-plugin-0.2.3.0: GHC core plugin supporting the derive-storable package.

Copyright(c) Mateusz Kłoczko 2016
LicenseMIT
Maintainermateusz.p.kloczko@gmail.com
Stabilityexperimental
PortabilityGHC-only
Safe HaskellNone
LanguageHaskell2010

Foreign.Storable.Generic.Plugin.Internal.Compile

Description

The core of compile and substitute optimisations.

Synopsis

Documentation

compileExpr :: HscEnv -> CoreExpr -> SrcSpan -> IO a Source #

Compile an expression.

tryCompileExpr :: Id -> CoreExpr -> CoreM (Either Error a) Source #

Try to compile an expression. Perhaps return an error.

intToExpr :: Type -> Int -> CoreExpr Source #

Create an expression of form: x -> 16

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.

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.

isIndexer :: Id -> Bool Source #

Is an "$w!!" identifier

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.

lintBind Source #

Arguments

:: CoreBind

Core binding to use when returning CompilationError

-> CoreBind

Core binding to check

-> CoreM (Either Error CoreBind)

Success or failure

Lint a binding

replaceIdsBind Source #

Arguments

:: [CoreBind]

Replace with - for GStorable bindings

-> [CoreBind]

Replace with - for other top-bindings

-> CoreBind

Binding which will have ids replaced.

-> CoreBind

Binding with replaced ids.

Substitutes the localIds inside the bindings with bodies of provided bindings.

compileGroups Source #

Arguments

:: Flags

Error handling.

-> [[CoreBind]]

Ordered gstorable bindings.

-> [CoreBind]

Non-gstorable bindings, used for replacing ids.

-> CoreM [CoreBind]

The compiled (or not) bindings.

Compile ordered binding.