Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class CompileLayer l
- data ModuleHandle
- addModule :: CompileLayer l => l -> Module -> SymbolResolver -> IO ModuleHandle
- removeModule :: CompileLayer l => l -> ModuleHandle -> IO ()
- withModule :: CompileLayer l => l -> Module -> SymbolResolver -> (ModuleHandle -> IO a) -> IO a
- data JITSymbol = JITSymbol {}
- data JITSymbolError = JITSymbolError ShortByteString
- data JITSymbolFlags = JITSymbolFlags {
- jitSymbolWeak :: !Bool
- jitSymbolCommon :: !Bool
- jitSymbolAbsolute :: !Bool
- jitSymbolExported :: !Bool
- defaultJITSymbolFlags :: JITSymbolFlags
- data SymbolResolver = SymbolResolver {}
- data MangledSymbol
- mangleSymbol :: CompileLayer l => l -> ShortByteString -> IO MangledSymbol
- data IRCompileLayer linkingLayer
- newIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> IO (IRCompileLayer l)
- withIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> (IRCompileLayer l -> IO a) -> IO a
- data CompileOnDemandLayer baseLayer
- newCompileOnDemandLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Function -> IO [Ptr Function]) -> JITCompileCallbackManager -> IndirectStubsManagerBuilder -> Bool -> IO (CompileOnDemandLayer l)
- withCompileOnDemandLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Function -> IO [Ptr Function]) -> JITCompileCallbackManager -> IndirectStubsManagerBuilder -> Bool -> (CompileOnDemandLayer l -> IO a) -> IO a
- data IRTransformLayer baseLayer
- newIRTransformLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Module -> IO (Ptr Module)) -> IO (IRTransformLayer l)
- withIRTransformLayer :: CompileLayer l => l -> TargetMachine -> (Ptr Module -> IO (Ptr Module)) -> (IRTransformLayer l -> IO a) -> IO a
- disposeCompileLayer :: CompileLayer l => l -> IO ()
- class LinkingLayer l
- data ObjectLinkingLayer
- newObjectLinkingLayer :: IO ObjectLinkingLayer
- withObjectLinkingLayer :: (ObjectLinkingLayer -> IO a) -> IO a
- disposeLinkingLayer :: LinkingLayer l => l -> IO ()
- addObjectFile :: LinkingLayer l => l -> ObjectFile -> SymbolResolver -> IO ObjectHandle
- data JITCompileCallbackManager
- newJITCompileCallbackManager :: ShortByteString -> Maybe (IO ()) -> IO JITCompileCallbackManager
- disposeJITCompileCallbackManager :: JITCompileCallbackManager -> IO ()
- withJITCompileCallbackManager :: ShortByteString -> Maybe (IO ()) -> (JITCompileCallbackManager -> IO a) -> IO a
- data IndirectStubsManagerBuilder
- newIndirectStubsManagerBuilder :: ShortByteString -> IO IndirectStubsManagerBuilder
- disposeIndirectStubsManagerBuilder :: IndirectStubsManagerBuilder -> IO ()
- withIndirectStubsManagerBuilder :: ShortByteString -> (IndirectStubsManagerBuilder -> IO a) -> IO a
CompileLayer
class CompileLayer l Source #
There are two main types of operations provided by instances of CompileLayer
.
- You can add / remove modules using
addModule
/removeModuleSet
. - You can search for symbols using
findSymbol
/findSymbolIn
in the previously added modules.
Instances
CompileLayer (IRTransformLayer l) Source # | |
Defined in LLVM.Internal.OrcJIT.IRTransformLayer getCompileLayer :: IRTransformLayer l -> Ptr CompileLayer Source # getDataLayout :: IRTransformLayer l -> Ptr DataLayout Source # getCleanups :: IRTransformLayer l -> IORef [IO ()] Source # | |
CompileLayer (IRCompileLayer l) Source # | |
Defined in LLVM.Internal.OrcJIT.IRCompileLayer getCompileLayer :: IRCompileLayer l -> Ptr CompileLayer Source # getDataLayout :: IRCompileLayer l -> Ptr DataLayout Source # getCleanups :: IRCompileLayer l -> IORef [IO ()] Source # | |
CompileLayer (CompileOnDemandLayer l) Source # | |
Defined in LLVM.Internal.OrcJIT.CompileOnDemandLayer getCompileLayer :: CompileOnDemandLayer l -> Ptr CompileLayer Source # getDataLayout :: CompileOnDemandLayer l -> Ptr DataLayout Source # getCleanups :: CompileOnDemandLayer l -> IORef [IO ()] Source # |
Add/remove modules
data ModuleHandle Source #
Abstract type representing a module in a CompileLayer
.
addModule :: CompileLayer l => l -> Module -> SymbolResolver -> IO ModuleHandle Source #
Add a module to the CompileLayer
. The SymbolResolver
is used
to resolve external symbols in the module.
Note: This function consumes the module passed to it and it must not be used after calling this method.
removeModule :: CompileLayer l => l -> ModuleHandle -> IO () Source #
Remove a previously added module.
withModule :: CompileLayer l => l -> Module -> SymbolResolver -> (ModuleHandle -> IO a) -> IO a Source #
bracket
-style wrapper around addModule
and removeModule
.
Note: This function consumes the module passed to it and it must not be used after calling this method.
Search for symbols
JITSymbol | |
|
Instances
Eq JITSymbol Source # | |
Ord JITSymbol Source # | |
Defined in LLVM.Internal.OrcJIT | |
Show JITSymbol Source # | |
MonadIO m => EncodeM m SymbolResolverFn (FunPtr SymbolResolverFn) Source # | |
Defined in LLVM.Internal.OrcJIT encodeM :: SymbolResolverFn -> m (FunPtr SymbolResolverFn0) Source # | |
(MonadIO m, MonadAnyCont IO m) => DecodeM m (Either JITSymbolError JITSymbol) (Ptr JITSymbol) Source # | |
Defined in LLVM.Internal.OrcJIT decodeM :: Ptr JITSymbol0 -> m (Either JITSymbolError JITSymbol) Source # | |
MonadIO m => EncodeM m (Either JITSymbolError JITSymbol) (Ptr JITSymbol -> IO ()) Source # | |
Defined in LLVM.Internal.OrcJIT encodeM :: Either JITSymbolError JITSymbol -> m (Ptr JITSymbol0 -> IO ()) Source # |
data JITSymbolError Source #
Instances
Eq JITSymbolError Source # | |
Defined in LLVM.Internal.OrcJIT (==) :: JITSymbolError -> JITSymbolError -> Bool # (/=) :: JITSymbolError -> JITSymbolError -> Bool # | |
Show JITSymbolError Source # | |
Defined in LLVM.Internal.OrcJIT showsPrec :: Int -> JITSymbolError -> ShowS # show :: JITSymbolError -> String # showList :: [JITSymbolError] -> ShowS # | |
MonadIO m => EncodeM m SymbolResolverFn (FunPtr SymbolResolverFn) Source # | |
Defined in LLVM.Internal.OrcJIT encodeM :: SymbolResolverFn -> m (FunPtr SymbolResolverFn0) Source # | |
(MonadIO m, MonadAnyCont IO m) => DecodeM m (Either JITSymbolError JITSymbol) (Ptr JITSymbol) Source # | |
Defined in LLVM.Internal.OrcJIT decodeM :: Ptr JITSymbol0 -> m (Either JITSymbolError JITSymbol) Source # | |
MonadIO m => EncodeM m (Either JITSymbolError JITSymbol) (Ptr JITSymbol -> IO ()) Source # | |
Defined in LLVM.Internal.OrcJIT encodeM :: Either JITSymbolError JITSymbol -> m (Ptr JITSymbol0 -> IO ()) Source # |
data JITSymbolFlags Source #
Contrary to the C++ interface, we do not store the HasError flag here. Instead decoding a JITSymbol produces a sumtype based on whether that flag is set or not.
JITSymbolFlags | |
|
Instances
data SymbolResolver Source #
Specifies how external symbols in a module added to a
CompielLayer
should be resolved.
SymbolResolver | |
|
Instances
MonadIO m => EncodeM m SymbolResolver (IORef [IO ()] -> IO (Ptr LambdaResolver)) Source # | |
Defined in LLVM.Internal.OrcJIT encodeM :: SymbolResolver -> m (IORef [IO ()] -> IO (Ptr LambdaResolver)) Source # |
Symbol mangling
data MangledSymbol Source #
A mangled symbol which can be used in findSymbol
. This can be
created using mangleSymbol
.
Instances
mangleSymbol :: CompileLayer l => l -> ShortByteString -> IO MangledSymbol Source #
Mangle a symbol according to the data layout stored in the
CompileLayer
.
IRCompileLayer
data IRCompileLayer linkingLayer Source #
IRCompileLayer
compiles modules immediately when they are
added. It parametrized by a LinkingLayer
which handles linking of
the generated object files.
Instances
Eq (IRCompileLayer linkingLayer) Source # | |
Defined in LLVM.Internal.OrcJIT.IRCompileLayer (==) :: IRCompileLayer linkingLayer -> IRCompileLayer linkingLayer -> Bool # (/=) :: IRCompileLayer linkingLayer -> IRCompileLayer linkingLayer -> Bool # | |
CompileLayer (IRCompileLayer l) Source # | |
Defined in LLVM.Internal.OrcJIT.IRCompileLayer getCompileLayer :: IRCompileLayer l -> Ptr CompileLayer Source # getDataLayout :: IRCompileLayer l -> Ptr DataLayout Source # getCleanups :: IRCompileLayer l -> IORef [IO ()] Source # |
newIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> IO (IRCompileLayer l) Source #
Create a new IRCompileLayer
.
When the layer is no longer needed, it should be disposed using 'disposeCompileLayer.
withIRCompileLayer :: LinkingLayer l => l -> TargetMachine -> (IRCompileLayer l -> IO a) -> IO a Source #
bracket
-style wrapper around newIRCompileLayer
and disposeCompileLayer
.
CompileOnDemandLayer
data CompileOnDemandLayer baseLayer Source #
Adding a module to a CompileOnDemandLayer
creates stubs for its
functions definitions. When one of those stubs is called, the
corresponding function body is extracted and compiled.
Instances
Eq (CompileOnDemandLayer baseLayer) Source # | |
Defined in LLVM.Internal.OrcJIT.CompileOnDemandLayer (==) :: CompileOnDemandLayer baseLayer -> CompileOnDemandLayer baseLayer -> Bool # (/=) :: CompileOnDemandLayer baseLayer -> CompileOnDemandLayer baseLayer -> Bool # | |
CompileLayer (CompileOnDemandLayer l) Source # | |
Defined in LLVM.Internal.OrcJIT.CompileOnDemandLayer getCompileLayer :: CompileOnDemandLayer l -> Ptr CompileLayer Source # getDataLayout :: CompileOnDemandLayer l -> Ptr DataLayout Source # getCleanups :: CompileOnDemandLayer l -> IORef [IO ()] Source # |
newCompileOnDemandLayer Source #
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Function -> IO [Ptr Function]) | partitioning function |
-> JITCompileCallbackManager | |
-> IndirectStubsManagerBuilder | |
-> Bool | clone stubs into partitions |
-> IO (CompileOnDemandLayer l) |
Create a new CompileOnDemandLayer
. The partitioning function
specifies which functions should be compiled when a function is
called.
When the layer is no longer needed, it should be disposed using disposeCompileLayer
.
withCompileOnDemandLayer Source #
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Function -> IO [Ptr Function]) | partitioning function |
-> JITCompileCallbackManager | |
-> IndirectStubsManagerBuilder | |
-> Bool | clone stubs into partitions |
-> (CompileOnDemandLayer l -> IO a) | |
-> IO a |
bracket
-style wrapper around newCompileOnDemandLayer
and disposeCompileLayer
.
IRTRansformLayer
data IRTransformLayer baseLayer Source #
IRTransformLayer
allows transforming modules before handing off
compilation to the underlying CompileLayer
.
Instances
Eq (IRTransformLayer baseLayer) Source # | |
Defined in LLVM.Internal.OrcJIT.IRTransformLayer (==) :: IRTransformLayer baseLayer -> IRTransformLayer baseLayer -> Bool # (/=) :: IRTransformLayer baseLayer -> IRTransformLayer baseLayer -> Bool # | |
CompileLayer (IRTransformLayer l) Source # | |
Defined in LLVM.Internal.OrcJIT.IRTransformLayer getCompileLayer :: IRTransformLayer l -> Ptr CompileLayer Source # getDataLayout :: IRTransformLayer l -> Ptr DataLayout Source # getCleanups :: IRTransformLayer l -> IORef [IO ()] Source # |
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Module -> IO (Ptr Module)) | module transformation |
-> IO (IRTransformLayer l) |
Create a new IRTransformLayer
.
When the layer is no longer needed, it should be disposed using disposeCompileLayer
.
:: CompileLayer l | |
=> l | |
-> TargetMachine | |
-> (Ptr Module -> IO (Ptr Module)) | module transformation |
-> (IRTransformLayer l -> IO a) | |
-> IO a |
bracket
-style wrapper around newIRTransformLayer
and disposeCompileLayer
.
Dispose of compile layers
disposeCompileLayer :: CompileLayer l => l -> IO () Source #
Dispose of a CompileLayer
. This should called when the
CompileLayer
is not needed anymore.
LinkingLayer
class LinkingLayer l Source #
After a CompileLayer
has compiled the modules to object code,
it passes the resulting object files to a LinkingLayer
.
Instances
LinkingLayer ObjectLinkingLayer Source # | |
Defined in LLVM.Internal.OrcJIT.LinkingLayer getLinkingLayer :: ObjectLinkingLayer -> Ptr LinkingLayer Source # getCleanups :: ObjectLinkingLayer -> IORef [IO ()] Source # |
Create linking layers
data ObjectLinkingLayer Source #
Bare bones implementation of a LinkingLayer
.
Instances
LinkingLayer ObjectLinkingLayer Source # | |
Defined in LLVM.Internal.OrcJIT.LinkingLayer getLinkingLayer :: ObjectLinkingLayer -> Ptr LinkingLayer Source # getCleanups :: ObjectLinkingLayer -> IORef [IO ()] Source # |
newObjectLinkingLayer :: IO ObjectLinkingLayer Source #
Create a new ObjectLinkingLayer
. This should be disposed using
disposeLinkingLayer
when it is no longer needed.
withObjectLinkingLayer :: (ObjectLinkingLayer -> IO a) -> IO a Source #
bracket
-style wrapper around newObjectLinkingLayer
and disposeLinkingLayer
.
Dispose of linking layers
disposeLinkingLayer :: LinkingLayer l => l -> IO () Source #
Dispose of a LinkingLayer
.
Add an object file
addObjectFile :: LinkingLayer l => l -> ObjectFile -> SymbolResolver -> IO ObjectHandle Source #
Add an object file to the LinkingLayer
. The SymbolResolver
is used
to resolve external symbols in the module.
JITCompileCallbackManager
data JITCompileCallbackManager Source #
This is used by CompileOnDemandLayer
to create callback that
compile functions when they are called.
newJITCompileCallbackManager Source #
:: ShortByteString | target triple |
-> Maybe (IO ()) | called on compilation errors |
-> IO JITCompileCallbackManager |
Create a new JITCompileCallbackManager
.
When the callback manager is no longer needed, it should be freed
using disposeJITCompileCallbackManager
.
disposeJITCompileCallbackManager :: JITCompileCallbackManager -> IO () Source #
Dispose of a JITCompileCallbackManager
.
withJITCompileCallbackManager Source #
:: ShortByteString | target triple |
-> Maybe (IO ()) | called on compilation errors |
-> (JITCompileCallbackManager -> IO a) | |
-> IO a |
Execute a computation using a new JITCompileCallbackManager
.
IndirectStubsManagerBuilder
data IndirectStubsManagerBuilder Source #
This is used by CompileOnDemandLayer
to manage the stubs
created for function definitions that have not yet been compiled.
newIndirectStubsManagerBuilder Source #
:: ShortByteString | target triple |
-> IO IndirectStubsManagerBuilder |
Create a new IndirectStubsManagerBuilder
.
When the stubs manager is no longer needed, it should be freed
using disposeIndirectStubsManagerBuilder
.
disposeIndirectStubsManagerBuilder :: IndirectStubsManagerBuilder -> IO () Source #
Dispose of an IndirectStubsManagerBuilder
.
withIndirectStubsManagerBuilder Source #
:: ShortByteString | target triple |
-> (IndirectStubsManagerBuilder -> IO a) | |
-> IO a |
bracket
-style wrapper around newIndirectStubsManagerBuilder
and disposeIndirectStubsManagerBuilder
.