Safe Haskell | None |
---|---|
Language | Haskell98 |
LLVM.ExecutionEngine
Contents
Description
An ExecutionEngine
is JIT compiler that is used to generate code for an LLVM module.
Synopsis
- data EngineAccess a
- data ExecutionEngine
- getEngine :: EngineAccess ExecutionEngine
- runEngineAccess :: EngineAccess a -> IO a
- runEngineAccessWithModule :: Module -> EngineAccess a -> IO a
- addModule :: Module -> EngineAccess ()
- class ExecutionFunction f
- type Importer f = FunPtr f -> f
- getExecutionFunction :: ExecutionFunction f => Importer f -> Function f -> EngineAccess f
- getPointerToFunction :: Function f -> EngineAccess (FunPtr f)
- addFunctionValue :: Function f -> FunPtr f -> EngineAccess ()
- addGlobalMappings :: GlobalMappings -> EngineAccess ()
- class Translatable f
- class Generic a
- generateFunction :: Translatable f => Function f -> EngineAccess f
- class Unsafe a
- unsafeRemoveIO :: Unsafe a => a -> RemoveIO a
- simpleFunction :: Translatable f => CodeGenModule (Function f) -> IO f
- unsafeGenerateFunction :: (Unsafe t, Translatable t) => CodeGenModule (Function t) -> RemoveIO t
- class IsType a => Marshal a where
- class IsPrimitive a => MarshalVector a where
- peekVector :: Positive n => Ptr (Vector n a) -> IO (Vector n a)
- pokeVector :: Positive n => Ptr (Vector n a) -> Vector n a -> IO ()
- sizeOf :: IsType a => Proxy a -> Int
- alignment :: IsType a => Proxy a -> Int
- class StructFields fields => StructFields fields
- sizeOfArray :: IsType a => Proxy a -> Int -> Int
- pokeList :: Marshal a => Ptr a -> [a] -> IO ()
- with :: Marshal a => a -> (Ptr a -> IO b) -> IO b
- alloca :: IsType a => (Ptr a -> IO b) -> IO b
- newtype Stored a = Stored {
- getStored :: a
- castToStoredPtr :: Ptr a -> Ptr (Stored a)
- castFromStoredPtr :: Ptr (Stored a) -> Ptr a
Execution engine
data EngineAccess a #
Instances
Monad EngineAccess | |
Defined in LLVM.ExecutionEngine.Engine Methods (>>=) :: EngineAccess a -> (a -> EngineAccess b) -> EngineAccess b # (>>) :: EngineAccess a -> EngineAccess b -> EngineAccess b # return :: a -> EngineAccess a # fail :: String -> EngineAccess a # | |
Functor EngineAccess | |
Defined in LLVM.ExecutionEngine.Engine Methods fmap :: (a -> b) -> EngineAccess a -> EngineAccess b # (<$) :: a -> EngineAccess b -> EngineAccess a # | |
Applicative EngineAccess | |
Defined in LLVM.ExecutionEngine.Engine Methods pure :: a -> EngineAccess a # (<*>) :: EngineAccess (a -> b) -> EngineAccess a -> EngineAccess b # liftA2 :: (a -> b -> c) -> EngineAccess a -> EngineAccess b -> EngineAccess c # (*>) :: EngineAccess a -> EngineAccess b -> EngineAccess b # (<*) :: EngineAccess a -> EngineAccess b -> EngineAccess a # | |
MonadIO EngineAccess | |
Defined in LLVM.ExecutionEngine.Engine Methods liftIO :: IO a -> EngineAccess a # |
data ExecutionEngine #
runEngineAccess :: EngineAccess a -> IO a #
runEngineAccessWithModule :: Module -> EngineAccess a -> IO a #
addModule :: Module -> EngineAccess () #
class ExecutionFunction f #
Minimal complete definition
keepAlive
Instances
ExecutionFunction (IO a) | |
Defined in LLVM.ExecutionEngine.Engine Methods keepAlive :: ExecutionEngine -> IO a -> IO a | |
ExecutionFunction f => ExecutionFunction (a -> f) | |
Defined in LLVM.ExecutionEngine.Engine Methods keepAlive :: ExecutionEngine -> (a -> f) -> a -> f |
getExecutionFunction :: ExecutionFunction f => Importer f -> Function f -> EngineAccess f #
getPointerToFunction :: Function f -> EngineAccess (FunPtr f) #
addFunctionValue :: Function f -> FunPtr f -> EngineAccess () #
addGlobalMappings :: GlobalMappings -> EngineAccess () #
Translation
class Translatable f Source #
Class of LLVM function types that can be translated to the corresponding Haskell type.
Minimal complete definition
translate
Instances
Generic a => Translatable (IO a) Source # | |
(Generic a, Translatable b) => Translatable (a -> b) Source # | |
Defined in LLVM.ExecutionEngine |
Minimal complete definition
toGeneric, fromGeneric
Instances
Generic Double | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Float | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Int | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Int8 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Int16 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Int32 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Int64 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Word | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Word8 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Word16 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Word32 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic Word64 | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic () | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic (StablePtr a) | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic (Ptr a) | |
Defined in LLVM.ExecutionEngine.Engine | |
Generic (Ptr a) | |
Defined in LLVM.ExecutionEngine.Engine |
generateFunction :: Translatable f => Function f -> EngineAccess f Source #
Generate a Haskell function from an LLVM function.
Note that the function is compiled for every call (Just-In-Time compilation).
If you want to compile the function once and call it a lot of times
then you should better use getPointerToFunction
.
Unsafe type conversion
Minimal complete definition
Instances
Unsafe (IO a) Source # | |
Defined in LLVM.ExecutionEngine Methods unsafeRemoveIO :: IO a -> RemoveIO (IO a) Source # | |
Unsafe b => Unsafe (a -> b) Source # | |
Defined in LLVM.ExecutionEngine Associated Types type RemoveIO (a -> b) :: Type Methods unsafeRemoveIO :: (a -> b) -> RemoveIO (a -> b) Source # |
Arguments
:: Unsafe a | |
=> a | |
-> RemoveIO a | Remove the IO from a function return type. This is unsafe in general. |
Simplified interface.
simpleFunction :: Translatable f => CodeGenModule (Function f) -> IO f Source #
Translate a function to Haskell code. This is a simplified interface to
the execution engine and module mechanism.
It is based on generateFunction
, so see there for limitations.
unsafeGenerateFunction :: (Unsafe t, Translatable t) => CodeGenModule (Function t) -> RemoveIO t Source #
Combine simpleFunction
and unsafeRemoveIO
.
Target information
Exchange data with JIT code in memory
class IsType a => Marshal a where #
Instances
Marshal Bool | |
Marshal Double | |
Marshal Float | |
Marshal Int | |
Marshal Int8 | |
Marshal Int16 | |
Marshal Int32 | |
Marshal Int64 | |
Marshal Word | |
Marshal Word8 | |
Marshal Word16 | |
Marshal Word32 | |
Marshal Word64 | |
Marshal (StablePtr a) | |
Storable a => Marshal (Ptr a) | |
IsFunction a => Marshal (FunPtr a) | |
Positive d => Marshal (IntN d) | |
IsType a => Marshal (Ptr a) | |
StructFields fields => Marshal (Struct fields) | |
Positive d => Marshal (WordN d) | |
(Natural n, Marshal a, IsSized a) => Marshal (Array n a) | |
(Positive n, MarshalVector a) => Marshal (Vector n a) | |
class IsPrimitive a => MarshalVector a where #
Methods
peekVector :: Positive n => Ptr (Vector n a) -> IO (Vector n a) #
pokeVector :: Positive n => Ptr (Vector n a) -> Vector n a -> IO () #
Instances
class StructFields fields => StructFields fields #
Minimal complete definition
peekStruct, pokeStruct
Instances
StructFields () | |
Defined in LLVM.ExecutionEngine.Marshal Methods peekStruct :: TypeRef -> Int -> Ptr struct -> IO () pokeStruct :: TypeRef -> Int -> Ptr struct -> () -> IO () | |
(Marshal a, IsSized a, StructFields as) => StructFields (a, as) | |
Defined in LLVM.ExecutionEngine.Marshal Methods peekStruct :: TypeRef -> Int -> Ptr struct -> IO (a, as) pokeStruct :: TypeRef -> Int -> Ptr struct -> (a, as) -> IO () |
sizeOfArray :: IsType a => Proxy a -> Int -> Int #
Instances
Marshal a => Storable (Stored a) | |
Defined in LLVM.ExecutionEngine.Marshal |
castToStoredPtr :: Ptr a -> Ptr (Stored a) #
castFromStoredPtr :: Ptr (Stored a) -> Ptr a #