llvm-general-3.3.11.1: General purpose LLVM bindings

Safe HaskellNone

LLVM.General.Module

Description

A Module holds a C++ LLVM IR module. Modules may be converted to or from strings or Haskell ASTs, or added to an ExecutionEngine and so JIT compiled to get function pointers.

Synopsis

Documentation

newtype File

A newtype to distinguish strings used for paths from other strings

Constructors

File FilePath 

Instances

withModuleFromAST :: Context -> Module -> (Module -> IO a) -> ErrorT String IO a

Build an LLVM.General.Module from a LLVM.General.AST.Module - i.e. lower an AST from Haskell into C++ objects.

moduleAST :: Module -> IO Module

Get an LLVM.General.AST.Module from a LLVM.General.Module - i.e. raise C++ objects into an Haskell AST.

withModuleFromLLVMAssembly :: LLVMAssemblyInput s => Context -> s -> (Module -> IO a) -> ErrorT (Either String Diagnostic) IO a

parse Module from LLVM assembly

moduleLLVMAssembly :: Module -> IO String

generate LLVM assembly from a Module

writeLLVMAssemblyToFile :: File -> Module -> ErrorT String IO ()

write LLVM assembly for a Module to a file

withModuleFromBitcode :: BitcodeInput b => Context -> b -> (Module -> IO a) -> ErrorT String IO a

parse Module from LLVM bitcode

moduleBitcode :: Module -> IO ByteString

generate LLVM bitcode from a Module

writeBitcodeToFile :: File -> Module -> ErrorT String IO ()

write LLVM bitcode from a Module into a file

moduleTargetAssembly :: TargetMachine -> Module -> ErrorT String IO String

produce target-specific assembly as a String

writeTargetAssemblyToFile :: TargetMachine -> File -> Module -> ErrorT String IO ()

write target-specific assembly directly into a file

moduleObject :: TargetMachine -> Module -> ErrorT String IO ByteString

produce target-specific object code as a ByteString

writeObjectToFile :: TargetMachine -> File -> Module -> ErrorT String IO ()

write target-specific object code directly into a file

linkModules

Arguments

:: Bool

True to leave the right module unmodified, False to cannibalize it (for efficiency's sake).

-> Module

The module into which to link

-> Module

The module to link into the other (and cannibalize or not)

-> ErrorT String IO () 

link LLVM modules - move or copy parts of a source module into a destination module. Note that this operation is not commutative - not only concretely (e.g. the destination module is modified, becoming the result) but abstractly (e.g. unused private globals in the source module do not appear in the result, but similar globals in the destination remain).