llvm-hs-6.3.0: General purpose LLVM bindings

Safe HaskellNone
LanguageHaskell2010

LLVM.OrcJIT

Contents

Synopsis

CompileLayer

class CompileLayer l Source #

There are two main types of operations provided by instances of CompileLayer.

  1. You can add / remove modules using addModule / removeModuleSet.
  2. You can search for symbols using findSymbol / findSymbolIn in the previously added modules.

Minimal complete definition

getCompileLayer, getDataLayout, getCleanups

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

data JITSymbol Source #

Constructors

JITSymbol 

Fields

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.

Constructors

JITSymbolFlags 

Fields

data SymbolResolver Source #

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

Constructors

SymbolResolver 

Fields

Instances
MonadIO m => EncodeM m SymbolResolver (IORef [IO ()] -> IO (Ptr LambdaResolver)) Source # 
Instance details

Defined in LLVM.Internal.OrcJIT

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.

Instances
Eq (IRCompileLayer linkingLayer) Source # 
Instance details

Defined in LLVM.Internal.OrcJIT.IRCompileLayer

Methods

(==) :: IRCompileLayer linkingLayer -> IRCompileLayer linkingLayer -> Bool #

(/=) :: IRCompileLayer linkingLayer -> IRCompileLayer linkingLayer -> Bool #

CompileLayer (IRCompileLayer l) Source # 
Instance details

Defined in LLVM.Internal.OrcJIT.IRCompileLayer

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, getCleanups

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

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 #

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.