Skip to content

Commit

Permalink
Reapply 0.6.5 changes.
Browse files Browse the repository at this point in the history
--HG--
extra : convert_revision : 59476cb8cad954305387ccf7c1f7f6d94a4f91e6
  • Loading branch information
augustss committed Jun 17, 2009
1 parent 0aff8d6 commit c564fd1
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 36 deletions.
12 changes: 4 additions & 8 deletions INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,9 @@ Prerequisites
-------------

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.
version 2.5 (from llvm.org) which is what it's been tested with.

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 ???.

B) Install from source.
Install from source.:
Build this and install it somewhere. Follow the LLVM instructions,
or use this:

Expand All @@ -29,6 +23,8 @@ or use this:

It's a good idea to have $SOMEWHERE/bin is in your path.

Installing from source on Windows requires MinGW.


Building
--------
Expand Down
4 changes: 1 addition & 3 deletions LLVM/ExecutionEngine.hs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,9 +10,7 @@ module LLVM.ExecutionEngine(
runStaticConstructors,
runStaticDestructors,
-}
#if HAS_GETPOINTERTOGLOBAL
getPointerToFunction,
#endif
-- * Translation
Translatable, Generic,
generateFunction,
Expand Down
10 changes: 1 addition & 9 deletions LLVM/ExecutionEngine/Engine.hs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -8,9 +8,7 @@ module LLVM.ExecutionEngine.Engine(
createExecutionEngine, addModuleProvider, addModule,
{- runStaticConstructors, runStaticDestructors, -}
getExecutionEngineTargetData,
#if HAS_GETPOINTERTOGLOBAL
getPointerToFunction,
#endif
runFunction, getRunFunction,
GenericValue, Generic(..)
) where
Expand All @@ -24,10 +22,8 @@ import Foreign.ForeignPtr (ForeignPtr, newForeignPtr, withForeignPtr)
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)

Expand Down Expand Up @@ -78,12 +74,10 @@ runStaticDestructors ee = withExecutionEngine ee FFI.runStaticDestructors
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.
Expand Down Expand Up @@ -149,12 +143,10 @@ getExecutionEngineTargetData = do
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
Expand Down
6 changes: 1 addition & 5 deletions LLVM/FFI/ExecutionEngine.hsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-}
{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-}

module LLVM.FFI.ExecutionEngine
(
Expand All @@ -18,9 +18,7 @@ module LLVM.FFI.ExecutionEngine
, runFunctionAsMain
, getExecutionEngineTargetData
, addGlobalMapping
#if HAS_GETPOINTERTOGLOBAL
, getPointerToGlobal
#endif

-- * Generic values
, GenericValue
Expand Down Expand Up @@ -112,7 +110,5 @@ foreign import ccall unsafe "LLVMGetExecutionEngineTargetData" getExecutionEngin
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
8 changes: 7 additions & 1 deletion LLVM/Util/Arithmetic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE CPP, FlexibleInstances, ScopedTypeVariables, FlexibleContexts, UndecidableInstances, TypeSynonymInstances, MultiParamTypeClasses, FunctionalDependencies, OverlappingInstances #-}
module LLVM.Util.Arithmetic(
TValue,
Cmp,
Cmp(..),
(%==), (%/=), (%<), (%<=), (%>), (%>=),
(%&&), (%||),
(?), (??),
Expand Down Expand Up @@ -36,6 +36,7 @@ instance Cmp Int64 Bool where cmp = icmp . adjSigned
instance Cmp Float Bool where cmp = fcmp . adjFloat
instance Cmp Double Bool where cmp = fcmp . adjFloat
instance Cmp FP128 Bool where cmp = fcmp . adjFloat
{-
instance (IsPowerOf2 n) => Cmp (Vector n Bool) (Vector n Bool) where cmp = icmp
instance (IsPowerOf2 n) => Cmp (Vector n Word8) (Vector n Bool) where cmp = icmp
instance (IsPowerOf2 n) => Cmp (Vector n Word16) (Vector n Bool) where cmp = icmp
Expand All @@ -48,6 +49,11 @@ instance (IsPowerOf2 n) => Cmp (Vector n Int64) (Vector n Bool) where cmp = icmp
instance (IsPowerOf2 n) => Cmp (Vector n Float) (Vector n Bool) where cmp = fcmp . adjFloat
instance (IsPowerOf2 n) => Cmp (Vector n Double) (Vector n Bool) where cmp = fcmp . adjFloat
instance (IsPowerOf2 n) => Cmp (Vector n FP128) (Vector n Bool) where cmp = fcmp . adjFloat
-}
instance (IsPowerOf2 n) => Cmp (Vector n Float) (Vector n Bool) where
cmp op = mapVector2 (fcmp (adjFloat op))
instance (IsPowerOf2 n) => Cmp (Vector n Word32) (Vector n Bool) where
cmp op = mapVector2 (cmp op)

adjSigned :: IntPredicate -> IntPredicate
adjSigned IntUGT = IntSGT
Expand Down
2 changes: 1 addition & 1 deletion LLVM/Util/File.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ clean:
-./setup clean
-rm -f setup setup.exe setup.exe.manifest
-rm *~
-rm -rf dist

distclean: clean
-rm -f setup configure
2 changes: 1 addition & 1 deletion examples/Arith.hs
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 2 additions & 4 deletions examples/Vector.hs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -74,12 +74,10 @@ main = do
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

Expand Down
11 changes: 7 additions & 4 deletions llvm.cabal
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>, Lennart Augustsson <[email protected]>
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

Expand All @@ -21,6 +22,7 @@ extra-source-files:
configure
configure.ac
examples/Arith.hs
examples/Align.hs
examples/Array.hs
examples/BrainF.hs
examples/Convert.hs
Expand All @@ -32,8 +34,10 @@ extra-source-files:
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

Expand All @@ -58,7 +62,6 @@ library
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
Expand Down

0 comments on commit c564fd1

Please sign in to comment.