llvm-base-util- Utilities for bindings to the LLVM compiler toolkit.

Safe HaskellNone




Module handling

newtype Module Source

Type of top level modules.



destroyModule :: Module -> IO ()Source

Free all storage related to a module. *Note*, this is a dangerous call, since referring to the module after this call is an error. The reason for the explicit call to free the module instead of an automatic lifetime management is that modules have a somewhat complicated ownership. Handing a module to a module provider changes the ownership of the module, and the module provider will free the module when necessary.

writeBitcodeToFile :: String -> Module -> IO ()Source

Write a module to a file.

readBitcodeFromFile :: String -> IO ModuleSource

Read a module from a file.

valueHasType :: Value -> Type -> BoolSource

Module provider handling

newtype ModuleProvider Source

A module provider is used by the code generator to get access to a module.

createModuleProviderForExistingModule :: Module -> IO ModuleProviderSource

Turn a module into a module provider.

Pass manager handling

newtype PassManager Source

Manage compile passes.

createPassManager :: IO PassManagerSource

Create a pass manager.

createFunctionPassManager :: ModuleProvider -> IO PassManagerSource

Create a pass manager for a module.

Instruction builder

newtype Builder Source



Basic blocks

getBasicBlocks :: Value -> IO [(String, Value)]Source


getParam :: Function -> Int -> ValueSource

getParams :: Value -> IO [(String, Value)]Source


structType :: [Type] -> Bool -> TypeSource


addGlobal :: Module -> Linkage -> String -> Type -> IO ValueSource

constVector :: Int -> [Value] -> ValueSource

constArray :: Type -> Int -> [Value] -> ValueSource

constStruct :: [Value] -> Bool -> ValueSource


makeCall :: Function -> BuilderRef -> [Value] -> IO ValueSource

withValue :: Value -> (Value -> IO a) -> IO aSource

getInstructions :: Value -> IO [(String, Value)]Source

getOperands :: Value -> IO [(String, Value)]Source

Uses and Users

hasUsers :: Value -> IO BoolSource

getUsers :: [Use] -> IO [(String, Value)]Source

getUses :: Value -> IO [Use]Source

getUser :: Use -> IO ValueSource


type CString = Ptr CChar

A C string is a reference to an array of C characters terminated by NUL.

withArrayLen :: Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b

Like withArray, but the action gets the number of values as an additional parameter

functionType :: Bool -> Type -> [Type] -> TypeSource

buildEmptyPhi :: BuilderRef -> Type -> IO ValueSource

addPhiIns :: Value -> [(Value, BasicBlock)] -> IO ()Source

getObjList :: (t1 -> (t2 -> IO [Ptr a]) -> t) -> (t2 -> IO (Ptr a)) -> (Ptr a -> IO (Ptr a)) -> t1 -> tSource

annotateValueList :: [Value] -> IO [(String, Value)]Source

Transformation passes

addCFGSimplificationPass :: PassManager -> IO ()Source

Add a control flow graph simplification pass to the manager.

addConstantPropagationPass :: PassManager -> IO ()Source

Add a constant propagation pass to the manager.

addGVNPass :: PassManager -> IO ()Source

Add a global value numbering pass to the manager.