llvm-hs-6.0.0: General purpose LLVM bindings

Safe HaskellNone
LanguageHaskell98

LLVM.OrcJIT

Contents

Synopsis

CompileLayer

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

findSymbol :: CompileLayer l => l -> MangledSymbol -> Bool -> IO JITSymbol Source #

findSymbol layer symbol exportedSymbolsOnly searches for symbol in all modules added to layer. If exportedSymbolsOnly is True only exported symbols are searched.

findSymbolIn :: CompileLayer l => l -> ModuleHandle -> MangledSymbol -> Bool -> IO JITSymbol Source #

findSymbolIn layer handle symbol exportedSymbolsOnly searches for symbol in the context of the module represented by handle. If exportedSymbolsOnly is True only exported symbols are searched.

data JITSymbol Source #

Constructors

JITSymbol 

Fields

data SymbolResolver Source #

Specifies how external symbols in a module added to a CompielLayer should be resolved.

Constructors

SymbolResolver 

Fields

Symbol mangling

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.

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.

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.

newCompileOnDemandLayer Source #

Arguments

:: 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 #

Arguments

:: CompileLayer l 
=> l 
-> TargetMachine 
-> (Ptr Function -> IO [Ptr Function])

partitioning function

-> JITCompileCallbackManager 
-> IndirectStubsManagerBuilder 
-> Bool

clone stubs into partitions

-> (CompileOnDemandLayer l -> IO a) 
-> IO a 

IRTRansformLayer

data IRTransformLayer baseLayer Source #

IRTransformLayer allows transforming modules before handing off compilation to the underlying CompileLayer.

newIRTransformLayer Source #

Arguments

:: 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.

withIRTransformLayer Source #

Arguments

:: CompileLayer l 
=> l 
-> TargetMachine 
-> (Ptr Module -> IO (Ptr Module))

module transformation

-> (IRTransformLayer l -> IO a) 
-> IO a 

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.

Minimal complete definition

getLinkingLayer

Create linking layers

newObjectLinkingLayer :: IO ObjectLinkingLayer Source #

Create a new ObjectLinkingLayer. This should be disposed using disposeLinkingLayer when it is no longer needed.

Dispose of linking layers

JITCompileCallbackManager

data JITCompileCallbackManager Source #

This is used by CompileOnDemandLayer to create callback that compile functions when they are called.

newJITCompileCallbackManager Source #

Arguments

:: 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.

withJITCompileCallbackManager Source #

Arguments

:: 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 #

Arguments

:: ShortByteString

target triple

-> IO IndirectStubsManagerBuilder 

Create a new IndirectStubsManagerBuilder.

When the stubs manager is no longer needed, it should be freed using disposeIndirectStubsManagerBuilder.