packages feed

llvm 0.6.4.0 → 0.6.5.0

raw patch · 12 files changed

+82/−35 lines, 12 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

INSTALL.txt view
@@ -10,15 +10,9 @@ -------------  Firstly, you'll need to have LLVM.  I recommend installing LLVM-version 2.4 (from llvm.org) which is what it's been tested with.-Do A or B.--A) Install from a binary package.  Follow the LLVM instructions.-The binary package at llvm.org for Windows only contains executable-files and no libraries.  You can find a complete Windows binary package-at ???.+version 2.5 (from llvm.org) which is what it's been tested with. -B) Install from source.+Install from source.: Build this and install it somewhere.  Follow the LLVM instructions, or use this: @@ -28,6 +22,8 @@   make install  It's a good idea to have $SOMEWHERE/bin is in your path.++Installing from source on Windows requires MinGW.   Building
LLVM/ExecutionEngine.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, FlexibleInstances, UndecidableInstances, MultiParamTypeClasses, FunctionalDependencies #-}+{-# LANGUAGE FlexibleInstances, UndecidableInstances, MultiParamTypeClasses, FunctionalDependencies #-}  -- |An 'ExecutionEngine' is JIT compiler that is used to generate code for an LLVM module. module LLVM.ExecutionEngine(     -- * Execution engine@@ -10,9 +10,7 @@     runStaticConstructors,     runStaticDestructors, -}-#if HAS_GETPOINTERTOGLOBAL     getPointerToFunction,-#endif     -- * Translation     Translatable, Generic,     generateFunction,
LLVM/ExecutionEngine/Engine.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, ForeignFunctionInterface, FlexibleInstances, UndecidableInstances, OverlappingInstances, ScopedTypeVariables, GeneralizedNewtypeDeriving #-}+{-# LANGUAGE ForeignFunctionInterface, FlexibleInstances, UndecidableInstances, OverlappingInstances, ScopedTypeVariables, GeneralizedNewtypeDeriving #-} module LLVM.ExecutionEngine.Engine(        EngineAccess,        runEngineAccess,@@ -8,9 +8,7 @@        createExecutionEngine, addModuleProvider, addModule,        {- runStaticConstructors, runStaticDestructors, -}        getExecutionEngineTargetData,-#if HAS_GETPOINTERTOGLOBAL        getPointerToFunction,-#endif        runFunction, getRunFunction,        GenericValue, Generic(..)        ) where@@ -24,10 +22,8 @@ import Foreign.Marshal.Utils (fromBool) import Foreign.C.String (peekCString) import Foreign.Ptr (Ptr)-#if HAS_GETPOINTERTOGLOBAL import Foreign.Ptr (FunPtr) import LLVM.Core.CodeGen(Value(..), Function)-#endif import Foreign.Storable (peek) import System.IO.Unsafe (unsafePerformIO) @@ -78,12 +74,10 @@ getExecutionEngineTargetData :: ExecutionEngine -> IO FFI.TargetDataRef getExecutionEngineTargetData ee = withExecutionEngine ee FFI.getExecutionEngineTargetData -#if HAS_GETPOINTERTOGLOBAL getPointerToFunction :: ExecutionEngine -> Function f -> IO (FunPtr f) getPointerToFunction ee (Value f) =     withExecutionEngine ee $ \ eePtr ->       FFI.getPointerToGlobal eePtr f-#endif -}  -- This global variable holds the one and only execution engine.@@ -149,12 +143,10 @@     eePtr <- gets ea_engine     liftIO $ FFI.getExecutionEngineTargetData eePtr -#if HAS_GETPOINTERTOGLOBAL getPointerToFunction :: Function f -> EngineAccess (FunPtr f) getPointerToFunction (Value f) = do     eePtr <- gets ea_engine     liftIO $ FFI.getPointerToGlobal eePtr f-#endif  addModule :: Module -> EngineAccess () addModule m = do
LLVM/FFI/ExecutionEngine.hsc view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-}+{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-}  module LLVM.FFI.ExecutionEngine     (@@ -18,9 +18,7 @@     , runFunctionAsMain     , getExecutionEngineTargetData     , addGlobalMapping-#if HAS_GETPOINTERTOGLOBAL     , getPointerToGlobal-#endif      -- * Generic values     , GenericValue@@ -112,7 +110,5 @@ foreign import ccall unsafe "LLVMAddGlobalMapping" addGlobalMapping     :: ExecutionEngineRef -> ValueRef -> Ptr () -> IO () -#if HAS_GETPOINTERTOGLOBAL foreign import ccall unsafe "LLVMGetPointerToGlobal" getPointerToGlobal     :: ExecutionEngineRef -> ValueRef -> IO (FunPtr a)-#endif
LLVM/Util/File.hs view
@@ -1,6 +1,6 @@ module LLVM.Util.File(writeCodeGenModule, optimizeFunction, optimizeFunctionCG) where import System.Directory-import System.Process+import System.Cmd(system)  import LLVM.Core import LLVM.ExecutionEngine
Makefile view
@@ -51,6 +51,7 @@ 	-./setup clean 	-rm -f setup setup.exe setup.exe.manifest 	-rm *~+	-rm -rf dist  distclean: clean 	-rm -f setup configure
+ examples/Align.hs view
@@ -0,0 +1,16 @@+module Align (main) where+import Data.TypeLevel(D4)+import Data.Word++import LLVM.Core+import LLVM.ExecutionEngine++main :: IO ()+main = do+    let td = ourTargetData+    print (littleEndian td,+           aBIAlignmentOfType td $ typeRef (undefined :: Word32),+	   aBIAlignmentOfType td $ typeRef (undefined :: Double),+	   aBIAlignmentOfType td $ typeRef (undefined :: Vector D4 Float),+	   storeSizeOfType td $ typeRef (undefined :: Vector D4 Float)+	   )
examples/Arith.hs view
@@ -1,5 +1,5 @@ {-# OPTIONS_GHC -fno-warn-type-defaults #-}-{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE ScopedTypeVariables, PatternSignatures #-} module Arith where import Data.Int import Data.TypeLevel(D4)
examples/Vector.hs view
@@ -1,6 +1,6 @@-{-# LANGUAGE CPP, TypeOperators #-}+{-# LANGUAGE TypeOperators #-} module Vector where-import System.Process(system)+import System.Cmd(system) import Control.Monad import Data.TypeLevel.Num(D16, toNum) import Data.Word@@ -74,12 +74,10 @@     m <- newModule     iovec <- defineModule m cgvec -#if HAS_GETPOINTERTOGLOBAL     fptr <- runEngineAccess $ do addModule m; getPointerToFunction iovec     let fvec = convert fptr      fvec 10 >>= print-#endif      vec <- runEngineAccess $ do addModule m; generateFunction iovec 
llvm.cabal view
@@ -1,15 +1,16 @@ name: llvm-version: 0.6.4.0+version: 0.6.5.0 license: BSD3 license-file: LICENSE synopsis: Bindings to the LLVM compiler toolkit description: Bindings to the LLVM compiler toolkit+	     New in 0.6.5.0: Adapted to LLVM 2.5 author: Bryan O'Sullivan, Lennart Augustsson maintainer: Bryan O'Sullivan <bos@serpentine.com>, Lennart Augustsson <lennart@augustsson.net> homepage: http://darcs.serpentine.com/llvm/ stability: experimental category: Compilers/Interpreters, Code Generation-tested-with: GHC == 6.8.2, GHC == 6.10.1+tested-with: GHC == 6.10.1 cabal-version: >= 1.2.3 build-type: Custom @@ -21,6 +22,7 @@     configure     configure.ac     examples/Arith.hs+    examples/Align.hs     examples/Array.hs     examples/BrainF.hs     examples/Convert.hs@@ -32,8 +34,10 @@     examples/mainfib.c     tests/Makefile     tests/TestValue.hs-    tools/Makefile+    tools/DiffFFI.hs+    tools/FunctionMangler.hs     tools/IntrinsicMangler.hs+    tools/Makefile     llvm.buildinfo.in     llvm.buildinfo.windows.in @@ -58,7 +62,6 @@     build-depends: base < 2.0 || >= 2.2, bytestring >= 0.9, mtl, directory, process, type-level    ghc-options: -Wall-  cpp-options: -DHAS_GETPOINTERTOGLOBAL=1    if os(darwin)     ld-options: -w /System/Library/Frameworks/vecLib.framework/Versions/A/vecLib
+ tools/DiffFFI.hs view
@@ -0,0 +1,39 @@+module DiffFFI (main) where++import Control.Monad (forM_)+import Data.List (foldl')+import qualified Data.Map as M+import System.Environment (getArgs)+import System.Exit (exitFailure)+import System.IO (hPutStrLn, stderr)+import Text.Regex.Posix ((=~))++import FunctionMangulation (pattern, rewriteFunction)++cFunctions :: String -> M.Map String String+cFunctions s = foldl' go M.empty (s =~ pattern)+  where go m (_:ret:name:params:_) =+            M.insert ("LLVM" ++ name) (rewriteFunction ret name params) m+        go m _ = m++hsFunctions :: String -> M.Map String String+hsFunctions s = foldl' go M.empty (s =~ pat)+    where pat = "\"([a-zA-Z0-9_]+)\"[ \t\n]+([a-zA-Z0-9_']+)"+          go m (_:cname:hsname:_) = M.insert cname hsname m+          go m _ = m++main :: IO ()+main = do+  args <- getArgs+  case args of+    [cFile, hsFile] -> do+              c <- cFunctions `fmap` readFile cFile+              hs <- hsFunctions `fmap` readFile hsFile+              putStrLn "In C, not Haskell:"+              forM_ (M.toAscList $ M.difference c hs) $ \(_, hsfunc) ->+                    putStrLn hsfunc+              putStrLn "In Haskell, not C:"+              forM_ (M.keys $ M.difference hs c) $ putStrLn . ("  "++)+    _ -> do+         hPutStrLn stderr "Usage: DiffFFI cFile hsFile"+         exitFailure
+ tools/FunctionMangler.hs view
@@ -0,0 +1,8 @@+module FunctionMangler (main) where++import Data.List (intercalate)++import FunctionMangulation (rewrite)++main :: IO ()+main = interact (intercalate "\n\n" . concat . rewrite) >> putStr "\n"