llvm-tf 3.0.3.1.8 → 3.0.3.1.9
raw patch · 2 files changed
+26/−13 lines, 2 files
Files
- llvm-tf.cabal +2/−2
- src/LLVM/ExecutionEngine/Engine.hs +24/−11
llvm-tf.cabal view
@@ -1,5 +1,5 @@ Name: llvm-tf-Version: 3.0.3.1.8+Version: 3.0.3.1.9 License: BSD3 License-File: LICENSE Synopsis: Bindings to the LLVM compiler toolkit using type families.@@ -37,7 +37,7 @@ Location: http://code.haskell.org/~thielema/llvm-tf/ Source-Repository this- Tag: 3.0.3.1.8+ Tag: 3.0.3.1.9 Type: darcs Location: http://code.haskell.org/~thielema/llvm-tf/
src/LLVM/ExecutionEngine/Engine.hs view
@@ -7,7 +7,8 @@ module LLVM.ExecutionEngine.Engine( EngineAccess, runEngineAccess,- createExecutionEngine, addModuleProvider, addModule,+ createExecutionEngine, addModuleProvider,+ createExecutionEngineForModule, addModule, getExecutionEngineTargetData, getPointerToFunction, addFunctionValue, addGlobalMappings,@@ -22,8 +23,8 @@ import LLVM.Core.CodeGen (Value(..), Function) import LLVM.Core.CodeGenMonad (GlobalMappings(..)) import LLVM.Core.Util- (Module, ModuleProvider, withModuleProvider,- createModule, createModuleProviderForExistingModule)+ (Module, withModule,+ ModuleProvider, withModuleProvider, createModule) import LLVM.Core.Type (IsFirstClass, typeRef) import LLVM.Util.Proxy (Proxy(Proxy)) @@ -59,13 +60,14 @@ theEngine :: MVar (Maybe FFI.ExecutionEngineRef) theEngine = unsafePerformIO $ newMVar Nothing -createExecutionEngine :: ModuleProvider -> IO FFI.ExecutionEngineRef-createExecutionEngine prov =- withModuleProvider prov $ \provPtr ->- alloca $ \eePtr ->+createExecutionEngineGen ::+ (Ptr FFI.ExecutionEngineRef -> ptr -> Ptr U.CString -> IO Bool) ->+ ptr -> IO FFI.ExecutionEngineRef+createExecutionEngineGen create mPtr =+ alloca $ \eePtr -> alloca $ \errPtr -> do- ret <- FFI.createExecutionEngine eePtr provPtr errPtr- if ret == 1+ success <- create eePtr mPtr errPtr+ if success then do err <- peek errPtr errStr <- peekCString err@@ -74,6 +76,18 @@ else peek eePtr +createExecutionEngine :: ModuleProvider -> IO FFI.ExecutionEngineRef+createExecutionEngine prov =+ withModuleProvider prov $+ createExecutionEngineGen+ (\eePtr provPtr errPtr ->+ fmap (0/=) $ FFI.createExecutionEngine eePtr provPtr errPtr)++createExecutionEngineForModule :: Module -> IO FFI.ExecutionEngineRef+createExecutionEngineForModule m =+ withModule m $+ createExecutionEngineGen FFI.createExecutionEngineForModule+ getTheEngine :: IO FFI.ExecutionEngineRef getTheEngine = do mee <- takeMVar theEngine@@ -81,8 +95,7 @@ Just ee -> do putMVar theEngine mee; return ee Nothing -> do m <- createModule "__empty__"- mp <- createModuleProviderForExistingModule m- ee <- createExecutionEngine mp+ ee <- createExecutionEngineForModule m putMVar theEngine (Just ee) return ee