Safe Haskell | None |
---|---|
Language | Haskell98 |
LLVM.Internal.Module
Contents
Description
This Haskell module is for/of functions for handling LLVM modules.
- newtype Module = Module (IORef (Ptr Module))
- newModule :: Ptr Module -> IO Module
- readModule :: MonadIO m => Module -> m (Ptr Module)
- deleteModule :: Module -> IO ()
- newtype File = File FilePath
- linkModules :: Module -> Module -> ExceptT String IO ()
- class LLVMAssemblyInput s where
- withModuleFromLLVMAssembly :: LLVMAssemblyInput s => Context -> s -> (Module -> IO a) -> ExceptT String IO a
- moduleLLVMAssembly :: Module -> IO String
- writeLLVMAssemblyToFile :: File -> Module -> ExceptT String IO ()
- class BitcodeInput b where
- withModuleFromBitcode :: BitcodeInput b => Context -> b -> (Module -> IO a) -> ExceptT String IO a
- moduleBitcode :: Module -> IO ByteString
- writeBitcodeToFile :: File -> Module -> ExceptT String IO ()
- targetMachineEmit :: CodeGenFileType -> TargetMachine -> Module -> Ptr RawPWriteStream -> ExceptT String IO ()
- emitToFile :: CodeGenFileType -> TargetMachine -> File -> Module -> ExceptT String IO ()
- emitToByteString :: CodeGenFileType -> TargetMachine -> Module -> ExceptT String IO ByteString
- writeTargetAssemblyToFile :: TargetMachine -> File -> Module -> ExceptT String IO ()
- moduleTargetAssembly :: TargetMachine -> Module -> ExceptT String IO String
- moduleObject :: TargetMachine -> Module -> ExceptT String IO ByteString
- writeObjectToFile :: TargetMachine -> File -> Module -> ExceptT String IO ()
- setTargetTriple :: Ptr Module -> String -> EncodeAST ()
- getTargetTriple :: Ptr Module -> IO (Maybe String)
- setDataLayout :: Ptr Module -> DataLayout -> EncodeAST ()
- getDataLayout :: Ptr Module -> IO (Maybe DataLayout)
- withModuleFromAST :: Context -> Module -> (Module -> IO a) -> ExceptT String IO a
- decodeGlobalVariables :: Ptr Module -> DecodeAST (DecodeAST [Global])
- decodeGlobalAliases :: Ptr Module -> DecodeAST (DecodeAST [Global])
- decodeFunctions :: Ptr Module -> DecodeAST (DecodeAST [Global])
- decodeNamedMetadataDefinitions :: Ptr Module -> DecodeAST [Definition]
- moduleAST :: Module -> IO Module
Documentation
deleteModule :: Module -> IO () Source #
Signal that a module does no longer exist and thus must not be disposed. It is the responsibility of the caller to ensure that the module has been disposed. If you use only the functions provided by llvm-hs you should never call this yourself.
A newtype to distinguish strings used for paths from other strings
Arguments
:: Module | The module into which to link |
-> Module | The module to link into the other (this module is destroyed) |
-> ExceptT 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). The source module is destroyed.
class LLVMAssemblyInput s where Source #
Minimal complete definition
Methods
llvmAssemblyMemoryBuffer :: (Inject String e, MonadError e m, MonadIO m, MonadAnyCont IO m) => s -> m (OwnerTransfered (Ptr MemoryBuffer)) Source #
Instances
withModuleFromLLVMAssembly :: LLVMAssemblyInput s => Context -> s -> (Module -> IO a) -> ExceptT String IO a Source #
parse Module
from LLVM assembly
writeLLVMAssemblyToFile :: File -> Module -> ExceptT String IO () Source #
write LLVM assembly for a Module
to a file
class BitcodeInput b where Source #
Minimal complete definition
Methods
bitcodeMemoryBuffer :: (Inject String e, MonadError e m, MonadIO m, MonadAnyCont IO m) => b -> m (Ptr MemoryBuffer) Source #
Instances
withModuleFromBitcode :: BitcodeInput b => Context -> b -> (Module -> IO a) -> ExceptT String IO a Source #
parse Module
from LLVM bitcode
moduleBitcode :: Module -> IO ByteString Source #
generate LLVM bitcode from a Module
writeBitcodeToFile :: File -> Module -> ExceptT String IO () Source #
write LLVM bitcode from a Module
into a file
targetMachineEmit :: CodeGenFileType -> TargetMachine -> Module -> Ptr RawPWriteStream -> ExceptT String IO () Source #
emitToFile :: CodeGenFileType -> TargetMachine -> File -> Module -> ExceptT String IO () Source #
emitToByteString :: CodeGenFileType -> TargetMachine -> Module -> ExceptT String IO ByteString Source #
writeTargetAssemblyToFile :: TargetMachine -> File -> Module -> ExceptT String IO () Source #
write target-specific assembly directly into a file
moduleTargetAssembly :: TargetMachine -> Module -> ExceptT String IO String Source #
produce target-specific assembly as a String
moduleObject :: TargetMachine -> Module -> ExceptT String IO ByteString Source #
produce target-specific object code as a ByteString
writeObjectToFile :: TargetMachine -> File -> Module -> ExceptT String IO () Source #
write target-specific object code directly into a file
setDataLayout :: Ptr Module -> DataLayout -> EncodeAST () Source #
getDataLayout :: Ptr Module -> IO (Maybe DataLayout) Source #
withModuleFromAST :: Context -> Module -> (Module -> IO a) -> ExceptT String IO a Source #
This function will call disposeModule after the callback
exits. Calling deleteModule
prevents double free errors. As long
as you only call functions provided by llvm-hs this should not
be necessary since llvm-hs takes care of this.