-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Bindings to the LLVM compiler toolkit
--
-- Bindings to the LLVM compiler toolkit
@package llvm
@version 0.4.4.2
-- | This module provides direct access to the LLVM C bindings.
module LLVM.FFI.Core
data Module
type ModuleRef = Ptr Module
moduleCreateWithName :: CString -> IO ModuleRef
disposeModule :: ModuleRef -> IO ()
getDataLayout :: ModuleRef -> IO CString
setDataLayout :: ModuleRef -> CString -> IO ()
getTarget :: ModuleRef -> IO CString
setTarget :: ModuleRef -> CString -> IO ()
data ModuleProvider
type ModuleProviderRef = Ptr ModuleProvider
createModuleProviderForExistingModule :: ModuleRef -> IO ModuleProviderRef
disposeModuleProvider :: ModuleProviderRef -> IO ()
data Type
type TypeRef = Ptr Type
addTypeName :: ModuleRef -> CString -> TypeRef -> IO CInt
deleteTypeName :: ModuleRef -> CString -> IO ()
getTypeKind :: TypeRef -> IO TypeKind
data TypeKind
VoidTypeKind :: TypeKind
FloatTypeKind :: TypeKind
DoubleTypeKind :: TypeKind
X86_FP80TypeKind :: TypeKind
FP128TypeKind :: TypeKind
PPC_FP128TypeKind :: TypeKind
LabelTypeKind :: TypeKind
IntegerTypeKind :: TypeKind
FunctionTypeKind :: TypeKind
StructTypeKind :: TypeKind
ArrayTypeKind :: TypeKind
PointerTypeKind :: TypeKind
OpaqueTypeKind :: TypeKind
VectorTypeKind :: TypeKind
int1Type :: TypeRef
int8Type :: TypeRef
int16Type :: TypeRef
int32Type :: TypeRef
int64Type :: TypeRef
-- | An integer type of the given width.
integerType :: CUInt -> TypeRef
getIntTypeWidth :: TypeRef -> IO CUInt
floatType :: TypeRef
doubleType :: TypeRef
x86FP80Type :: TypeRef
fp128Type :: TypeRef
ppcFP128Type :: TypeRef
-- | Create a function type.
functionType :: TypeRef -> Ptr TypeRef -> CUInt -> CInt -> TypeRef
-- | Indicate whether a function takes varargs.
isFunctionVarArg :: TypeRef -> IO CInt
-- | Give a function's return type.
getReturnType :: TypeRef -> IO TypeRef
-- | Give the number of fixed parameters that a function takes.
countParamTypes :: TypeRef -> IO CUInt
-- | Fill out an array with the types of a function's fixed parameters.
getParamTypes :: TypeRef -> Ptr TypeRef -> IO ()
voidType :: TypeRef
labelType :: IO TypeRef
opaqueType :: IO TypeRef
arrayType :: TypeRef -> CUInt -> TypeRef
pointerType :: TypeRef -> CUInt -> TypeRef
vectorType :: TypeRef -> CUInt -> TypeRef
-- | Get the type of a sequential type's elements.
getElementType :: TypeRef -> IO TypeRef
getArrayLength :: TypeRef -> IO CUInt
getPointerAddressSpace :: TypeRef -> IO CUInt
getVectorSize :: TypeRef -> IO CUInt
structType :: (Ptr TypeRef) -> CUInt -> CInt -> IO TypeRef
countStructElementTypes :: TypeRef -> IO CUInt
getStructElementTypes :: TypeRef -> (Ptr TypeRef) -> IO ()
isPackedStruct :: TypeRef -> IO CInt
createTypeHandle :: TypeRef -> IO TypeHandleRef
refineType :: TypeRef -> TypeRef -> IO ()
resolveTypeHandle :: TypeHandleRef -> IO TypeRef
disposeTypeHandle :: TypeHandleRef -> IO ()
data Value
type ValueRef = Ptr Value
typeOf :: ValueRef -> IO TypeRef
getValueName :: ValueRef -> IO CString
setValueName :: ValueRef -> CString -> IO ()
dumpValue :: ValueRef -> IO ()
constNull :: TypeRef -> ValueRef
constAllOnes :: TypeRef -> ValueRef
getUndef :: TypeRef -> ValueRef
isConstant :: ValueRef -> IO CInt
isNull :: ValueRef -> IO CInt
isUndef :: ValueRef -> IO CInt
type Linkage = CUInt
type Visibility = CUInt
isDeclaration :: ValueRef -> IO CInt
getLinkage :: ValueRef -> IO Linkage
setLinkage :: ValueRef -> Linkage -> IO ()
getSection :: ValueRef -> IO CString
setSection :: ValueRef -> CString -> IO ()
getVisibility :: ValueRef -> IO Visibility
setVisibility :: ValueRef -> Visibility -> IO ()
getAlignment :: ValueRef -> IO CUInt
setAlignment :: ValueRef -> CUInt -> IO ()
addGlobal :: ModuleRef -> TypeRef -> CString -> IO ValueRef
getNamedGlobal :: ModuleRef -> CString -> IO ValueRef
deleteGlobal :: ValueRef -> IO ()
getInitializer :: ValueRef -> IO ValueRef
setInitializer :: ValueRef -> ValueRef -> IO ()
isThreadLocal :: ValueRef -> IO CInt
setThreadLocal :: ValueRef -> CInt -> IO ()
isGlobalConstant :: ValueRef -> IO CInt
setGlobalConstant :: ValueRef -> CInt -> IO ()
getFirstGlobal :: ModuleRef -> IO ValueRef
getNextGlobal :: ValueRef -> IO ValueRef
getPreviousGlobal :: ValueRef -> IO ValueRef
getLastGlobal :: ModuleRef -> IO ValueRef
getGlobalParent :: ValueRef -> IO ModuleRef
addFunction :: ModuleRef -> CString -> TypeRef -> IO ValueRef
getNamedFunction :: ModuleRef -> CString -> IO ValueRef
deleteFunction :: ValueRef -> IO ()
countParams :: ValueRef -> CUInt
getParams :: ValueRef -> Ptr ValueRef -> IO ()
getParam :: ValueRef -> CUInt -> ValueRef
getIntrinsicID :: ValueRef -> CUInt
getGC :: ValueRef -> IO CString
setGC :: ValueRef -> CString -> IO ()
getFirstFunction :: ModuleRef -> IO ValueRef
getNextFunction :: ValueRef -> IO ValueRef
getPreviousFunction :: ValueRef -> IO ValueRef
getLastFunction :: ModuleRef -> IO ValueRef
getFirstParam :: ValueRef -> IO ValueRef
getNextParam :: ValueRef -> IO ValueRef
getPreviousParam :: ValueRef -> IO ValueRef
getLastParam :: ValueRef -> IO ValueRef
getParamParent :: ValueRef -> IO ValueRef
isTailCall :: ValueRef -> IO CInt
setTailCall :: ValueRef -> CInt -> IO ()
addIncoming :: ValueRef -> Ptr ValueRef -> Ptr ValueRef -> CUInt -> IO ()
countIncoming :: ValueRef -> IO CUInt
getIncomingValue :: ValueRef -> CUInt -> IO ValueRef
getIncomingBlock :: ValueRef -> CUInt -> IO BasicBlockRef
data CallingConvention
C :: CallingConvention
Fast :: CallingConvention
Cold :: CallingConvention
X86StdCall :: CallingConvention
X86FastCall :: CallingConvention
fromCallingConvention :: CallingConvention -> CUInt
toCallingConvention :: CUInt -> CallingConvention
getFunctionCallConv :: ValueRef -> IO CUInt
setFunctionCallConv :: ValueRef -> CUInt -> IO ()
getInstructionCallConv :: ValueRef -> IO CUInt
setInstructionCallConv :: ValueRef -> CUInt -> IO ()
constInt :: TypeRef -> CULLong -> CInt -> ValueRef
constReal :: TypeRef -> CDouble -> ValueRef
constArray :: TypeRef -> Ptr ValueRef -> CUInt -> ValueRef
constString :: CString -> CUInt -> CInt -> ValueRef
constStruct :: Ptr ValueRef -> CUInt -> CInt -> ValueRef
constVector :: Ptr ValueRef -> CUInt -> ValueRef
sizeOf :: TypeRef -> IO ValueRef
constNeg :: ValueRef -> ValueRef
constNot :: ValueRef -> ValueRef
constAdd :: ValueRef -> ValueRef -> ValueRef
constSub :: ValueRef -> ValueRef -> ValueRef
constMul :: ValueRef -> ValueRef -> ValueRef
constUDiv :: ValueRef -> ValueRef -> ValueRef
constSDiv :: ValueRef -> ValueRef -> ValueRef
constFDiv :: ValueRef -> ValueRef -> ValueRef
constURem :: ValueRef -> ValueRef -> ValueRef
constSRem :: ValueRef -> ValueRef -> ValueRef
constFRem :: ValueRef -> ValueRef -> ValueRef
constAnd :: ValueRef -> ValueRef -> ValueRef
constOr :: ValueRef -> ValueRef -> ValueRef
constXor :: ValueRef -> ValueRef -> ValueRef
constICmp :: CInt -> ValueRef -> ValueRef -> ValueRef
constFCmp :: CInt -> ValueRef -> ValueRef -> ValueRef
constShl :: ValueRef -> ValueRef -> ValueRef
constLShr :: ValueRef -> ValueRef -> ValueRef
constAShr :: ValueRef -> ValueRef -> ValueRef
constGEP :: ValueRef -> Ptr ValueRef -> CUInt -> ValueRef
constTrunc :: ValueRef -> TypeRef -> ValueRef
constSExt :: ValueRef -> TypeRef -> ValueRef
constZExt :: ValueRef -> TypeRef -> ValueRef
constFPTrunc :: ValueRef -> TypeRef -> ValueRef
constFPExt :: ValueRef -> TypeRef -> ValueRef
constUIToFP :: ValueRef -> TypeRef -> ValueRef
constSIToFP :: ValueRef -> TypeRef -> ValueRef
constFPToUI :: ValueRef -> TypeRef -> ValueRef
constFPToSI :: ValueRef -> TypeRef -> ValueRef
constPtrToInt :: ValueRef -> TypeRef -> ValueRef
constIntToPtr :: ValueRef -> TypeRef -> ValueRef
constBitCast :: ValueRef -> TypeRef -> ValueRef
constSelect :: ValueRef -> ValueRef -> ValueRef -> ValueRef
constExtractElement :: ValueRef -> ValueRef -> ValueRef
constInsertElement :: ValueRef -> ValueRef -> ValueRef -> ValueRef
constShuffleVector :: ValueRef -> ValueRef -> ValueRef -> ValueRef
constRealOfString :: TypeRef -> CString -> IO ValueRef
type BasicBlock = Value
type BasicBlockRef = Ptr BasicBlock
basicBlockAsValue :: BasicBlockRef -> ValueRef
valueIsBasicBlock :: ValueRef -> Bool
valueAsBasicBlock :: ValueRef -> BasicBlockRef
countBasicBlocks :: ValueRef -> IO CUInt
getBasicBlocks :: ValueRef -> Ptr BasicBlockRef -> IO ()
getEntryBasicBlock :: ValueRef -> IO BasicBlockRef
appendBasicBlock :: ValueRef -> CString -> IO BasicBlockRef
insertBasicBlock :: BasicBlockRef -> CString -> IO BasicBlockRef
deleteBasicBlock :: BasicBlockRef -> IO ()
getFirstBasicBlock :: ValueRef -> IO BasicBlockRef
getNextBasicBlock :: BasicBlockRef -> IO BasicBlockRef
getPreviousBasicBlock :: BasicBlockRef -> IO BasicBlockRef
getLastBasicBlock :: ValueRef -> IO BasicBlockRef
getInsertBlock :: BuilderRef -> IO BasicBlockRef
getBasicBlockParent :: BasicBlockRef -> IO ValueRef
data Builder
type BuilderRef = Ptr Builder
createBuilder :: IO BuilderRef
disposeBuilder :: BuilderRef -> IO ()
positionBuilder :: BuilderRef -> BasicBlockRef -> ValueRef -> IO ()
positionBefore :: BuilderRef -> ValueRef -> IO ()
positionAtEnd :: BuilderRef -> BasicBlockRef -> IO ()
getFirstInstruction :: BasicBlockRef -> IO ValueRef
getNextInstruction :: ValueRef -> IO ValueRef
getPreviousInstruction :: ValueRef -> IO ValueRef
getLastInstruction :: BasicBlockRef -> IO ValueRef
getInstructionParent :: ValueRef -> IO BasicBlockRef
buildRetVoid :: BuilderRef -> IO ValueRef
buildRet :: BuilderRef -> ValueRef -> IO ValueRef
buildBr :: BuilderRef -> BasicBlockRef -> IO ValueRef
buildCondBr :: BuilderRef -> ValueRef -> BasicBlockRef -> BasicBlockRef -> IO ValueRef
buildSwitch :: BuilderRef -> ValueRef -> BasicBlockRef -> CUInt -> IO ValueRef
buildInvoke :: BuilderRef -> ValueRef -> Ptr ValueRef -> CUInt -> BasicBlockRef -> BasicBlockRef -> CString -> IO ValueRef
buildUnwind :: BuilderRef -> IO ValueRef
buildUnreachable :: BuilderRef -> IO ValueRef
buildAdd :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildSub :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildMul :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildUDiv :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildSDiv :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildFDiv :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildURem :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildSRem :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildFRem :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildShl :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildLShr :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildAShr :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildAnd :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildOr :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildXor :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildNeg :: BuilderRef -> ValueRef -> CString -> IO ValueRef
buildNot :: BuilderRef -> ValueRef -> CString -> IO ValueRef
buildMalloc :: BuilderRef -> TypeRef -> CString -> IO ValueRef
buildArrayMalloc :: BuilderRef -> TypeRef -> ValueRef -> CString -> IO ValueRef
buildAlloca :: BuilderRef -> TypeRef -> CString -> IO ValueRef
buildArrayAlloca :: BuilderRef -> TypeRef -> ValueRef -> CString -> IO ValueRef
buildFree :: BuilderRef -> ValueRef -> IO ValueRef
buildLoad :: BuilderRef -> ValueRef -> CString -> IO ValueRef
buildStore :: BuilderRef -> ValueRef -> ValueRef -> IO ValueRef
buildGEP :: BuilderRef -> ValueRef -> Ptr ValueRef -> CUInt -> CString -> IO ValueRef
buildTrunc :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildZExt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildSExt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildFPToUI :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildFPToSI :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildUIToFP :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildSIToFP :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildFPTrunc :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildFPExt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildPtrToInt :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildIntToPtr :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildBitCast :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildICmp :: BuilderRef -> CInt -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildFCmp :: BuilderRef -> CInt -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildPhi :: BuilderRef -> TypeRef -> CString -> IO ValueRef
buildCall :: BuilderRef -> ValueRef -> Ptr ValueRef -> CUInt -> CString -> IO ValueRef
buildSelect :: BuilderRef -> ValueRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildVAArg :: BuilderRef -> ValueRef -> TypeRef -> CString -> IO ValueRef
buildExtractElement :: BuilderRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildInsertElement :: BuilderRef -> ValueRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
buildShuffleVector :: BuilderRef -> ValueRef -> ValueRef -> ValueRef -> CString -> IO ValueRef
addCase :: ValueRef -> ValueRef -> BasicBlockRef -> IO ()
data MemoryBuffer
type MemoryBufferRef = Ptr MemoryBuffer
createMemoryBufferWithContentsOfFile :: CString -> Ptr MemoryBufferRef -> Ptr CString -> IO CInt
createMemoryBufferWithSTDIN :: Ptr MemoryBufferRef -> Ptr CString -> IO CInt
disposeMemoryBuffer :: MemoryBufferRef -> IO ()
disposeMessage :: CString -> IO ()
addInstrAttribute :: ValueRef -> CUInt -> Attribute -> IO ()
addAttribute :: ValueRef -> Attribute -> IO ()
removeInstrAttribute :: ValueRef -> CUInt -> Attribute -> IO ()
removeAttribute :: ValueRef -> Attribute -> IO ()
setInstrParamAlignment :: ValueRef -> CUInt -> CUInt -> IO ()
setParamAlignment :: ValueRef -> CUInt -> IO ()
data PassManager
type PassManagerRef = Ptr PassManager
createFunctionPassManager :: ModuleProviderRef -> IO PassManagerRef
createPassManager :: IO PassManagerRef
disposePassManager :: PassManagerRef -> IO ()
finalizeFunctionPassManager :: PassManagerRef -> IO CInt
initializeFunctionPassManager :: PassManagerRef -> IO CInt
runFunctionPassManager :: PassManagerRef -> ValueRef -> IO CInt
runPassManager :: PassManagerRef -> ModuleRef -> IO CInt
dumpModule :: ModuleRef -> IO ()
instance Eq TypeKind
instance Ord TypeKind
instance Enum TypeKind
instance Bounded TypeKind
instance Show TypeKind
instance Read TypeKind
instance Eq CallingConvention
instance Show CallingConvention
module LLVM.FFI.Target
type ByteOrdering = CInt
data TargetData
type TargetDataRef = Ptr TargetData
aBIAlignmentOfType :: TargetDataRef -> TypeRef -> IO CUInt
aBISizeOfType :: TargetDataRef -> TypeRef -> IO CULLong
addTargetData :: TargetDataRef -> PassManagerRef -> IO ()
byteOrder :: TargetDataRef -> IO ByteOrdering
callFrameAlignmentOfType :: TargetDataRef -> TypeRef -> IO CUInt
copyStringRepOfTargetData :: TargetDataRef -> IO CString
createTargetData :: CString -> IO TargetDataRef
disposeTargetData :: TargetDataRef -> IO ()
elementAtOffset :: TargetDataRef -> TypeRef -> CULLong -> IO CUInt
intPtrType :: TargetDataRef -> IO TypeRef
invalidateStructLayout :: TargetDataRef -> TypeRef -> IO ()
offsetOfElement :: TargetDataRef -> TypeRef -> CUInt -> IO CULLong
pointerSize :: TargetDataRef -> IO CUInt
preferredAlignmentOfGlobal :: TargetDataRef -> ValueRef -> IO CUInt
preferredAlignmentOfType :: TargetDataRef -> TypeRef -> IO CUInt
sizeOfTypeInBits :: TargetDataRef -> TypeRef -> IO CULLong
storeSizeOfType :: TargetDataRef -> TypeRef -> IO CULLong
module LLVM.FFI.ExecutionEngine
data ExecutionEngine
createExecutionEngine :: Ptr ExecutionEngineRef -> ModuleProviderRef -> Ptr CString -> IO CInt
disposeExecutionEngine :: ExecutionEngineRef -> IO ()
createInterpreter :: Ptr ExecutionEngineRef -> ModuleProviderRef -> Ptr CString -> IO CInt
createJITCompiler :: Ptr ExecutionEngineRef -> ModuleProviderRef -> Ptr CString -> IO CInt
addModuleProvider :: ExecutionEngineRef -> ModuleProviderRef -> IO ()
removeModuleProvider :: ExecutionEngineRef -> ModuleProviderRef -> Ptr ModuleRef -> Ptr CString -> IO CInt
findFunction :: ExecutionEngineRef -> CString -> Ptr ValueRef -> IO CInt
freeMachineCodeForFunction :: ExecutionEngineRef -> ValueRef -> IO ()
runStaticConstructors :: ExecutionEngineRef -> IO ()
runStaticDestructors :: ExecutionEngineRef -> IO ()
runFunction :: ExecutionEngineRef -> ValueRef -> CUInt -> Ptr GenericValueRef -> IO GenericValueRef
runFunctionAsMain :: ExecutionEngineRef -> ValueRef -> CUInt -> Ptr CString -> Ptr CString -> IO CInt
getExecutionEngineTargetData :: ExecutionEngineRef -> IO TargetDataRef
addGlobalMapping :: ExecutionEngineRef -> ValueRef -> Ptr () -> IO ()
data GenericValue
type GenericValueRef = Ptr GenericValue
createGenericValueOfInt :: TypeRef -> CULLong -> CInt -> IO GenericValueRef
genericValueToInt :: GenericValueRef -> CInt -> CULLong
genericValueIntWidth :: GenericValueRef -> IO CUInt
createGenericValueOfFloat :: TypeRef -> CDouble -> IO GenericValueRef
genericValueToFloat :: TypeRef -> GenericValueRef -> CDouble
createGenericValueOfPointer :: Ptr a -> IO GenericValueRef
genericValueToPointer :: GenericValueRef -> IO (Ptr a)
disposeGenericValue :: GenericValueRef -> IO ()
module LLVM.FFI.Transforms.Scalar
addCFGSimplificationPass :: PassManagerRef -> IO ()
addConstantPropagationPass :: PassManagerRef -> IO ()
addDemoteMemoryToRegisterPass :: PassManagerRef -> IO ()
addGVNPass :: PassManagerRef -> IO ()
addInstructionCombiningPass :: PassManagerRef -> IO ()
addPromoteMemoryToRegisterPass :: PassManagerRef -> IO ()
addReassociatePass :: PassManagerRef -> IO ()
module LLVM.FFI.BitWriter
writeBitcodeToFile :: ModuleRef -> CString -> IO CInt
writeBitcodeToFileHandle :: ModuleRef -> CInt -> IO CInt
module LLVM.FFI.BitReader
getBitcodeModuleProvider :: MemoryBufferRef -> (Ptr ModuleProviderRef) -> (Ptr CString) -> IO CInt
parseBitcode :: MemoryBufferRef -> (Ptr ModuleRef) -> (Ptr CString) -> IO CInt
module LLVM.FFI.Analysis
type VerifierFailureAction = CInt
verifyFunction :: ValueRef -> VerifierFailureAction -> IO CInt
verifyModule :: ModuleRef -> VerifierFailureAction -> (Ptr CString) -> IO CInt
viewFunctionCFG :: ValueRef -> IO ()
viewFunctionCFGOnly :: ValueRef -> IO ()
-- | Type level decimal numbers.
module Data.TypeNumbers
-- | A type level number, i.e., a sequence of type level digits.
class IsTypeNumber ds
-- | Get the numeric value of a type level number. This function does not
-- evaluate its argument.
typeNumber :: (IsTypeNumber ds, Num a) => ds -> a
-- | The D0 - D9 types represent type level digits that form
-- a number by, e.g, D1 (D0 (D5 End)). On the value level a
-- slightly more palatable form can be used, D1$D0$D5$End.
data D0 a
D0 :: a -> D0 a
data D1 a
D1 :: a -> D1 a
data D2 a
D2 :: a -> D2 a
data D3 a
D3 :: a -> D3 a
data D4 a
D4 :: a -> D4 a
data D5 a
D5 :: a -> D5 a
data D6 a
D6 :: a -> D6 a
data D7 a
D7 :: a -> D7 a
data D8 a
D8 :: a -> D8 a
data D9 a
D9 :: a -> D9 a
-- | Mark the end of a digit sequence.
data End
End :: End
instance (IsTypeNumber ds) => IsTypeNumber (D9 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D8 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D7 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D6 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D5 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D4 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D3 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D2 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D1 ds)
instance (IsTypeNumber ds) => IsTypeNumber (D0 ds)
instance IsTypeNumber End
-- | The LLVM (Low Level Virtual Machine) is virtual machine at a machine
-- code level. It supports both stand alone code generation and JITing.
-- The Haskell llvm package is a (relatively) high level interface to the
-- LLVM. The high level interface makes it easy to construct LLVM code.
-- There is also an interface to the raw low level LLVM API as exposed by
-- the LLVM C interface.
--
-- LLVM code is organized into modules (type Module). Each module
-- contains a number of global variables and functions (type
-- Function). Each functions has a number of basic blocks (type
-- BasicBlock). Each basic block has a number instructions, where
-- each instruction produces a value (type Value).
--
-- Unlike assembly code for a real processor the assembly code for LLVM
-- is in SSA (Static Single Assignment) form. This means that each
-- instruction generates a new bound variable which may not be assigned
-- again. A consequence of this is that where control flow joins from
-- several execution paths there has to be a phi pseudo instruction if
-- you want different variables to be joined into one.
--
-- The definition of several of the LLVM entities (Module,
-- Function, and BasicBlock) follow the same pattern. First
-- the entity has to be created using newX (where X is
-- one of Module, Function, or BasicBlock),
-- then at some later point it has to given its definition using
-- defineX. The reason for splitting the creation and definition
-- is that you often need to be able to refer to an entity before giving
-- it's body, e.g., in two mutually recursive functions. The the
-- newX and defineX function can also be done at the
-- same time by using createX. Furthermore, an explicit name can
-- be given to an entity by the newNamedX function; the
-- newX function just generates a fresh name.
module LLVM.Core
-- | Type of top level modules.
data Module
-- | Create a new module.
newModule :: IO Module
-- | Create a new explicitely named module.
newNamedModule :: String -> IO Module
-- | Give the body for a module.
defineModule :: Module -> CodeGenModule a -> IO a
-- | 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.
destroyModule :: Module -> IO ()
-- | Create a new module with the given body.
createModule :: CodeGenModule a -> IO a
-- | A module provider is used by the code generator to get access to a
-- module.
data ModuleProvider
-- | Turn a module into a module provider.
createModuleProviderForExistingModule :: Module -> IO ModuleProvider
-- | Manage compile passes.
data PassManager
-- | Create a pass manager.
createPassManager :: IO PassManager
-- | Create a pass manager for a module.
createFunctionPassManager :: ModuleProvider -> IO PassManager
-- | Write a module to a file.
writeBitcodeToFile :: String -> Module -> IO ()
-- | Read a module from a file.
readBitcodeFromFile :: String -> IO Module
getModuleValues :: Module -> IO [(String, ModuleValue)]
data ModuleValue
castModuleValue :: (IsType a) => ModuleValue -> Maybe (Value a)
-- | Return from the current function with the given value. Use () as the
-- return value for what would be a void function is C.
ret :: (Ret a r) => a -> CodeGenFunction r Terminate
-- | Branch to the first basic block if the boolean is true, otherwise to
-- the second basic block.
condBr :: Value Bool -> BasicBlock -> BasicBlock -> CodeGenFunction r Terminate
-- | Unconditionally branch to the given basic block.
br :: BasicBlock -> CodeGenFunction r Terminate
-- | Branch table instruction.
switch :: (IsInteger a) => Value a -> BasicBlock -> [(ConstValue a, BasicBlock)] -> CodeGenFunction r Terminate
-- | Call a function with exception handling.
invoke :: (CallArgs f g) => BasicBlock -> BasicBlock -> Function f -> g
-- | Unwind the call stack until a function call performed with
-- invoke is reached. I.e., throw a non-local exception.
unwind :: CodeGenFunction r Terminate
-- | Inform the code generator that this code can never be reached.
unreachable :: CodeGenFunction r Terminate
add :: (IsArithmetic c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
sub :: (IsArithmetic c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
mul :: (IsArithmetic c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
neg :: (IsArithmetic a) => Value a -> CodeGenFunction r (Value a)
udiv :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
sdiv :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
-- | Floating point division.
fdiv :: (IsFloating c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
urem :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
srem :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
-- | Floating point remainder.
frem :: (IsFloating c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
shl :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
lshr :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
ashr :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
and :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
or :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
xor :: (IsInteger c, ABinOp a b (v c)) => a -> b -> CodeGenFunction r (v c)
inv :: (IsInteger a) => Value a -> CodeGenFunction r (Value a)
-- | Get a value from a vector.
extractelement :: Value (Vector n a) -> Value Word32 -> CodeGenFunction r (Value a)
-- | Insert a value into a vector, nondescructive.
insertelement :: Value (Vector n a) -> Value a -> Value Word32 -> CodeGenFunction r (Value (Vector n a))
-- | Permute vector.
shufflevector :: Value (Vector n a) -> Value (Vector n a) -> ConstValue (Vector n Word32) -> CodeGenFunction r (Value (Vector n a))
-- | Allocate heap memory.
malloc :: (IsSized a) => CodeGenFunction r (Value (Ptr a))
-- | Allocate heap (array) memory.
arrayMalloc :: (IsSized a, AllocArg s) => s -> CodeGenFunction r (Value (Ptr a))
-- | Allocate stack memory.
alloca :: (IsSized a) => CodeGenFunction r (Value (Ptr a))
-- | Allocate stack (array) memory.
arrayAlloca :: (IsSized a, AllocArg s) => s -> CodeGenFunction r (Value (Ptr a))
-- | Free heap memory.
free :: Value (Ptr a) -> CodeGenFunction r (Value ())
-- | Load a value from memory.
load :: Value (Ptr a) -> CodeGenFunction r (Value a)
-- | Store a value in memory
store :: Value a -> Value (Ptr a) -> CodeGenFunction r (Value ())
-- | Address arithmetic. See LLVM description. The index is a nested tuple
-- of the form (i1,(i2,( ... ()))). (This is without a doubt the
-- most confusing LLVM instruction, but the types help.)
getElementPtr :: (GetElementPtr o i n, IsIndexArg a) => Value (Ptr o) -> (a, i) -> CodeGenFunction r (Value (Ptr n))
-- | Truncate a value to a shorter bit width.
trunc :: (IsInteger a, IsInteger b) => Value a -> CodeGenFunction r (Value b)
-- | Zero extend a value to a wider width.
zext :: (IsInteger a, IsInteger b) => Value a -> CodeGenFunction r (Value b)
-- | Sign extend a value to wider width.
sext :: (IsInteger a, IsInteger b) => Value a -> CodeGenFunction r (Value b)
-- | Truncate a floating point value.
fptrunc :: (IsFloating a, IsFloating b) => Value a -> CodeGenFunction r (Value b)
-- | Extend a floating point value.
fpext :: (IsFloating a, IsFloating b) => Value a -> CodeGenFunction r (Value b)
-- | Convert a floating point value to an unsigned integer.
fptoui :: (IsFloating a, IsInteger b) => Value a -> CodeGenFunction r (Value b)
-- | Convert a floating point value to a signed integer.
fptosi :: (IsFloating a, IsInteger b) => Value a -> CodeGenFunction r (Value b)
-- | Convert an unsigned integer to a floating point value.
uitofp :: (IsInteger a, IsFloating b) => Value a -> CodeGenFunction r (Value b)
-- | Convert a signed integer to a floating point value.
sitofp :: (IsInteger a, IsFloating b) => Value a -> CodeGenFunction r (Value b)
-- | Convert a pointer to an integer.
ptrtoint :: (IsInteger b) => Value (Ptr a) -> CodeGenFunction r (Value b)
-- | Convert an integer to a pointer.
inttoptr :: (IsInteger a, IsType b) => Value (Ptr a) -> CodeGenFunction r (Value (Ptr b))
-- | Convert between to values of the same size by just copying the bit
-- pattern.
bitcast :: (IsFirstClass a, IsFirstClass b) => Value a -> CodeGenFunction r (Value b)
data IntPredicate
-- | equal
IntEQ :: IntPredicate
-- | not equal
IntNE :: IntPredicate
-- | unsigned greater than
IntUGT :: IntPredicate
-- | unsigned greater or equal
IntUGE :: IntPredicate
-- | unsigned less than
IntULT :: IntPredicate
-- | unsigned less or equal
IntULE :: IntPredicate
-- | signed greater than
IntSGT :: IntPredicate
-- | signed greater or equal
IntSGE :: IntPredicate
-- | signed less than
IntSLT :: IntPredicate
-- | signed less or equal
IntSLE :: IntPredicate
data RealPredicate
-- | Always false (always folded)
RealFalse :: RealPredicate
-- | True if ordered and equal
RealOEQ :: RealPredicate
-- | True if ordered and greater than
RealOGT :: RealPredicate
-- | True if ordered and greater than or equal
RealOGE :: RealPredicate
-- | True if ordered and less than
RealOLT :: RealPredicate
-- | True if ordered and less than or equal
RealOLE :: RealPredicate
-- | True if ordered and operands are unequal
RealONE :: RealPredicate
-- | True if ordered (no nans)
RealORD :: RealPredicate
-- | True if unordered: isnan(X) | isnan(Y)
RealUNO :: RealPredicate
-- | True if unordered or equal
RealUEQ :: RealPredicate
-- | True if unordered or greater than
RealUGT :: RealPredicate
-- | True if unordered, greater than, or equal
RealUGE :: RealPredicate
-- | True if unordered or less than
RealULT :: RealPredicate
-- | True if unordered, less than, or equal
RealULE :: RealPredicate
-- | True if unordered or not equal
RealUNE :: RealPredicate
-- | Always true (always folded)
RealT :: RealPredicate
-- | Compare integers.
icmp :: (IsInteger c, CmpOp a b c) => IntPredicate -> a -> b -> CodeGenFunction r (Value Bool)
-- | Compare floating point values.
fcmp :: (IsFloating c, CmpOp a b c) => RealPredicate -> a -> b -> CodeGenFunction r (Value Bool)
-- | Select between two values depending on a boolean.
select :: (IsFirstClass a) => Value Bool -> Value a -> Value a -> CodeGenFunction r (Value a)
-- | Join several variables (virtual registers) from different basic blocks
-- into one. All of the variables in the list are joined. See also
-- addPhiInputs.
phi :: (IsFirstClass a) => [(Value a, BasicBlock)] -> CodeGenFunction r (Value a)
-- | Add additional inputs to an existing phi node. The reason for this
-- instruction is that sometimes the structure of the code makes it
-- impossible to have all variables in scope at the point where you need
-- the phi node.
addPhiInputs :: (IsFirstClass a) => Value a -> [(Value a, BasicBlock)] -> CodeGenFunction r ()
-- | Call a function with the given arguments. The call instruction
-- is variadic, i.e., the number of arguments it takes depends on the
-- type of f.
call :: (CallArgs f g) => Function f -> g
type Terminate = ()
-- | Acceptable arguments to the ret instruction.
class Ret a r
-- | Acceptable arguments to call.
class CallArgs f g | f -> g, g -> f
-- | Acceptable arguments to arithmetic binary instructions.
class ABinOp a b c | a b -> c
-- | Acceptable operands to comparison instructions.
class CmpOp a b c | a b -> c
class FunctionArgs f g r | f -> g r, g r -> f
class (IsArithmetic a) => IsConst a
-- | Acceptable argument to array memory allocation.
class AllocArg a
-- | Acceptable arguments to getElementPointer.
class GetElementPtr optr ixs nptr | optr ixs -> nptr
-- | Acceptable single index to getElementPointer.
class IsIndexArg a
-- | The IsType class classifies all types that have an LLVM
-- representation.
class IsType a
typeRef :: (IsType a) => a -> TypeRef
-- | Arithmetic types, i.e., integral and floating types.
class (IsType a) => IsArithmetic a
isFloating :: (IsArithmetic a) => a -> Bool
-- | Integral types.
class (IsArithmetic a) => IsInteger a
isSigned :: (IsInteger a) => a -> Bool
-- | Floating types.
class (IsArithmetic a) => IsFloating a
-- | Primitive types.
class (IsType a) => IsPrimitive a
-- | First class types, i.e., the types that can be passed as arguments,
-- etc.
class (IsType a) => IsFirstClass a
-- | Types with a fixed size.
class (IsType a) => IsSized a
-- | Function type.
class (IsType a) => IsFunction a
-- | Sequence types, i.e., vectors and arrays
class IsSequence c
class (IsTypeNumber n) => IsPowerOf2 n
-- | Variable sized signed integer. The n parameter should belong to
-- IsTypeNumber.
newtype (IsTypeNumber n) => IntN n
IntN :: Integer -> IntN n
-- | Variable sized unsigned integer. The n parameter should belong
-- to IsTypeNumber.
newtype (IsTypeNumber n) => WordN n
WordN :: Integer -> WordN n
-- | 128 bit floating point.
newtype FP128
FP128 :: Rational -> FP128
-- | Fixed sized arrays, the array size is encoded in the n
-- parameter.
newtype (IsTypeNumber n) => Array n a
Array :: [a] -> Array n a
-- | Fixed sized vector, the array size is encoded in the n
-- parameter.
newtype Vector n a
Vector :: [a] -> Vector n a
data Value a
data ConstValue a
valueOf :: (IsConst a) => a -> Value a
value :: ConstValue a -> Value a
zero :: (IsType a) => ConstValue a
allOnes :: (IsInteger a) => ConstValue a
undef :: (IsType a) => ConstValue a
createString :: String -> TGlobal (Array n Word8)
createStringNul :: String -> TGlobal (Array n Word8)
-- | Make a constant vector. Replicates or truncates the list to get length
-- n.
constVector :: (IsTypeNumber n) => [ConstValue a] -> ConstValue (Vector n a)
-- | Make a constant array. Replicates or truncates the list to get length
-- n.
constArray :: (IsSized a, IsTypeNumber n) => [ConstValue a] -> ConstValue (Array n a)
mkVector :: (MkVector va n a) => va -> Vector n a
data CodeGenFunction r a
data CodeGenModule a
-- | A function is simply a pointer to the function.
type Function a = Value (Ptr a)
-- | Create a new function. Use newNamedFunction to create a
-- function with external linkage, since it needs a known name.
newFunction :: (IsFunction a) => Linkage -> CodeGenModule (Function a)
-- | Create a new named function.
newNamedFunction :: (IsFunction a) => Linkage -> String -> CodeGenModule (Function a)
-- | Define a function body. The basic block returned by the function is
-- the function entry point.
defineFunction :: (FunctionArgs f g (CodeGenFunction r ())) => Function f -> g -> CodeGenModule ()
-- | Create a new function with the given body.
createFunction :: (IsFunction f, FunctionArgs f g (CodeGenFunction r ())) => Linkage -> g -> CodeGenModule (Function f)
-- | Create a new function with the given body.
createNamedFunction :: (IsFunction f, FunctionArgs f g (CodeGenFunction r ())) => Linkage -> String -> g -> CodeGenModule (Function f)
type TFunction a = CodeGenModule (Function a)
type Global a = Value (Ptr a)
-- | Create a new global variable.
newGlobal :: (IsType a) => Bool -> Linkage -> TGlobal a
-- | Create a new named global variable.
newNamedGlobal :: (IsType a) => Bool -> Linkage -> String -> TGlobal a
-- | Give a global variable a (constant) value.
defineGlobal :: Global a -> ConstValue a -> CodeGenModule ()
-- | Create and define a global variable.
createGlobal :: (IsType a) => Bool -> Linkage -> ConstValue a -> TGlobal a
-- | Create and define a named global variable.
createNamedGlobal :: (IsType a) => Bool -> Linkage -> String -> ConstValue a -> TGlobal a
type TGlobal a = CodeGenModule (Global a)
-- | An enumeration for the kinds of linkage for global values.
data Linkage
-- | Externally visible function
ExternalLinkage :: Linkage
-- | Keep one copy of function when linking (inline)
LinkOnceLinkage :: Linkage
-- | Keep one copy of named function when linking (weak)
WeakLinkage :: Linkage
-- | Special purpose, only applies to global arrays
AppendingLinkage :: Linkage
-- | Rename collisions when linking (static functions)
InternalLinkage :: Linkage
-- | Function to be imported from DLL
DLLImportLinkage :: Linkage
-- | Function to be accessible from DLL
DLLExportLinkage :: Linkage
-- | ExternalWeak linkage description
ExternalWeakLinkage :: Linkage
-- | Stand-in functions for streaming fns from BC files
GhostLinkage :: Linkage
-- | A basic block is a sequence of non-branching instructions, terminated
-- by a control flow instruction.
data BasicBlock
newBasicBlock :: CodeGenFunction r BasicBlock
newNamedBasicBlock :: String -> CodeGenFunction r BasicBlock
defineBasicBlock :: BasicBlock -> CodeGenFunction r ()
createBasicBlock :: CodeGenFunction r BasicBlock
getCurrentBasicBlock :: CodeGenFunction r BasicBlock
-- | Print a value.
dumpValue :: Value a -> IO ()
dumpType :: Value a -> IO ()
-- | Add a control flow graph simplification pass to the manager.
addCFGSimplificationPass :: PassManager -> IO ()
-- | Add a constant propagation pass to the manager.
addConstantPropagationPass :: PassManager -> IO ()
addDemoteMemoryToRegisterPass :: PassManager -> IO ()
-- | Add a global value numbering pass to the manager.
addGVNPass :: PassManager -> IO ()
addInstructionCombiningPass :: PassManager -> IO ()
addPromoteMemoryToRegisterPass :: PassManager -> IO ()
addReassociatePass :: PassManager -> IO ()
addTargetData :: TargetDataRef -> PassManager -> IO ()
-- | An ExecutionEngine is JIT compiler that is used to generate
-- code for an LLVM module.
module LLVM.ExecutionEngine
-- | The type of the JITer.
data ExecutionEngine
-- | Create an execution engine for a module provider. Warning, do not call
-- this function more than once.
createExecutionEngine :: ModuleProvider -> IO ExecutionEngine
addModuleProvider :: ExecutionEngine -> ModuleProvider -> IO ()
runStaticConstructors :: ExecutionEngine -> IO ()
runStaticDestructors :: ExecutionEngine -> IO ()
-- | Class of LLVM function types that can be translated to the
-- corresponding Haskell type.
class Translatable f
class Generic a
-- | Generate a Haskell function from an LLVM function.
generateFunction :: (Translatable f) => ExecutionEngine -> Value (Ptr f) -> f
class Unsafe a b | a -> b
unsafePurify :: (Unsafe a b) => a -> b
-- | Translate a function to Haskell code. This is a simplified interface
-- to the execution engine and module mechanism.
simpleFunction :: (Translatable f) => CodeGenModule (Function f) -> IO f
-- | Combine simpleFunction and unsafePurify.
unsafeGenerateFunction :: (Unsafe t a, Translatable t) => CodeGenModule (Function t) -> a
instance Unsafe (IO a) a
instance (Unsafe b b') => Unsafe (a -> b) (a -> b')
instance (Generic a) => Translatable (IO a)
instance (Generic a, Translatable b) => Translatable (a -> b)