Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class CompileLayer l
- data ModuleKey
- addModule :: CompileLayer l => l -> ModuleKey -> Module -> IO ()
- removeModule :: CompileLayer l => l -> ModuleKey -> IO ()
- withModule :: CompileLayer l => l -> ModuleKey -> Module -> IO a -> IO a
- data JITSymbol = JITSymbol {}
- data JITSymbolError = JITSymbolError ShortByteString
- data JITSymbolFlags = JITSymbolFlags {
- jitSymbolWeak :: !Bool
- jitSymbolCommon :: !Bool
- jitSymbolAbsolute :: !Bool
- jitSymbolExported :: !Bool
- defaultJITSymbolFlags :: JITSymbolFlags
- newtype SymbolResolver = SymbolResolver (MangledSymbol -> IO (Either JITSymbolError JITSymbol))
- withSymbolResolver :: ExecutionSession -> SymbolResolver -> (Ptr SymbolResolver -> IO a) -> IO a
- data MangledSymbol
- mangleSymbol :: CompileLayer l => l -> ShortByteString -> IO MangledSymbol
- data ExecutionSession
- createExecutionSession :: IO ExecutionSession
- disposeExecutionSession :: ExecutionSession -> IO ()
- withExecutionSession :: (ExecutionSession -> IO a) -> IO a
- allocateModuleKey :: ExecutionSession -> IO ModuleKey
- releaseModuleKey :: ExecutionSession -> ModuleKey -> IO ()
- withModuleKey :: ExecutionSession -> (ModuleKey -> IO a) -> IO a
- 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 => ExecutionSession -> l -> TargetMachine -> (ModuleKey -> IO (Ptr SymbolResolver)) -> (ModuleKey -> Ptr SymbolResolver -> IO ()) -> (Ptr Function -> IO [Ptr Function]) -> JITCompileCallbackManager -> IndirectStubsManagerBuilder -> Bool -> IO (CompileOnDemandLayer l)
- withCompileOnDemandLayer :: CompileLayer l => ExecutionSession -> l -> TargetMachine -> (ModuleKey -> IO (Ptr SymbolResolver)) -> (ModuleKey -> Ptr SymbolResolver -> IO ()) -> (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 :: ExecutionSession -> (ModuleKey -> IO (Ptr SymbolResolver)) -> IO ObjectLinkingLayer
- withObjectLinkingLayer :: ExecutionSession -> (ModuleKey -> IO (Ptr SymbolResolver)) -> (ObjectLinkingLayer -> IO a) -> IO a
- disposeLinkingLayer :: LinkingLayer l => l -> IO ()
- addObjectFile :: LinkingLayer l => l -> ModuleKey -> ObjectFile -> IO ()
- data JITCompileCallbackManager
- newJITCompileCallbackManager :: ExecutionSession -> ShortByteString -> Maybe (IO ()) -> IO JITCompileCallbackManager
- disposeJITCompileCallbackManager :: JITCompileCallbackManager -> IO ()
- withJITCompileCallbackManager :: ExecutionSession -> 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
Abstract type used as the identifier for a module.
addModule :: CompileLayer l => l -> ModuleKey -> Module -> IO () 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 -> ModuleKey -> IO () Source #
Remove a previously added module.
withModule :: CompileLayer l => l -> ModuleKey -> Module -> 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, 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 (MangledSymbol -> IO (Either JITSymbolError JITSymbol)) (FunPtr SymbolResolverFn) Source # | |
Defined in LLVM.Internal.OrcJIT encodeM :: (MangledSymbol -> IO (Either JITSymbolError JITSymbol)) -> m (FunPtr SymbolResolverFn) 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
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
newtype SymbolResolver Source #
Specifies how external symbols in a module added to a
CompileLayer
should be resolved.
Instances
MonadIO m => EncodeM m SymbolResolver (IORef [IO ()] -> Ptr ExecutionSession -> IO (Ptr SymbolResolver)) Source # | |
Defined in LLVM.Internal.OrcJIT encodeM :: SymbolResolver -> m (IORef [IO ()] -> Ptr ExecutionSession -> IO (Ptr SymbolResolver0)) Source # |
withSymbolResolver :: ExecutionSession -> SymbolResolver -> (Ptr SymbolResolver -> IO a) -> IO a Source #
Create a SymbolResolver
that can be used with the JIT.
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
.
ExecutionSession
data ExecutionSession Source #
createExecutionSession :: IO ExecutionSession Source #
Create a new ExecutionSession
.
disposeExecutionSession :: ExecutionSession -> IO () Source #
Dispose of an ExecutionSession
. This should be called when the
ExecutionSession
is not needed anymore.
withExecutionSession :: (ExecutionSession -> IO a) -> IO a Source #
bracket
-style wrapper around createExecutionSession
and
disposeExecutionSession
.
allocateModuleKey :: ExecutionSession -> IO ModuleKey Source #
Allocate a module key for a new module to add to the JIT.
releaseModuleKey :: ExecutionSession -> ModuleKey -> IO () Source #
Return a module key to the ExecutionSession
so that it can be
re-used.
withModuleKey :: ExecutionSession -> (ModuleKey -> IO a) -> IO a Source #
bracket
-style wrapper around allocateModuleKey
and
releaseModuleKey
.
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 | |
=> ExecutionSession | |
-> l | |
-> TargetMachine | |
-> (ModuleKey -> IO (Ptr SymbolResolver)) | |
-> (ModuleKey -> Ptr SymbolResolver -> IO ()) | |
-> (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 | |
=> ExecutionSession | |
-> l | |
-> TargetMachine | |
-> (ModuleKey -> IO (Ptr SymbolResolver)) | |
-> (ModuleKey -> Ptr SymbolResolver -> IO ()) | |
-> (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 :: ExecutionSession -> (ModuleKey -> IO (Ptr SymbolResolver)) -> IO ObjectLinkingLayer Source #
Create a new ObjectLinkingLayer
. This should be disposed using
disposeLinkingLayer
when it is no longer needed.
withObjectLinkingLayer :: ExecutionSession -> (ModuleKey -> IO (Ptr SymbolResolver)) -> (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 -> ModuleKey -> ObjectFile -> IO () Source #
Add an object file to the LinkingLayer
.
JITCompileCallbackManager
data JITCompileCallbackManager Source #
This is used by CompileOnDemandLayer
to create callback that
compile functions when they are called.
newJITCompileCallbackManager Source #
:: ExecutionSession | |
-> 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 #
:: ExecutionSession | |
-> 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
.