packages feed

llvm 0.4.4.1 → 0.4.4.2

raw patch · 8 files changed

+63/−44 lines, 8 files

Files

LLVM/Core/CodeGen.hs view
@@ -71,24 +71,22 @@  newtype ConstValue a = ConstValue FFI.ValueRef -class (IsType a) => IsConst a where+class (IsArithmetic a) => IsConst a where     constOf :: a -> ConstValue a-    isFloat :: a -> Bool-    isFloat _ = False  instance IsConst Bool   where constOf = constEnum (typeRef True) --instance IsConst Char   where constOf = constEnum (typeRef (0::Word8)) -- XXX Unicode-instance IsConst Word8  where constOf = constI False-instance IsConst Word16 where constOf = constI False-instance IsConst Word32 where constOf = constI False-instance IsConst Word64 where constOf = constI False-instance IsConst Int8   where constOf = constI True-instance IsConst Int16  where constOf = constI True-instance IsConst Int32  where constOf = constI True-instance IsConst Int64  where constOf = constI True-instance IsConst Float  where constOf = constF; isFloat = const True-instance IsConst Double where constOf = constF; isFloat = const True---instance IsConst FP128  where constOf = constF; isFloat = const True+instance IsConst Word8  where constOf = constI+instance IsConst Word16 where constOf = constI+instance IsConst Word32 where constOf = constI+instance IsConst Word64 where constOf = constI+instance IsConst Int8   where constOf = constI+instance IsConst Int16  where constOf = constI+instance IsConst Int32  where constOf = constI+instance IsConst Int64  where constOf = constI+instance IsConst Float  where constOf = constF+instance IsConst Double where constOf = constF+--instance IsConst FP128  where constOf = constF  {- instance IsConst (Array n a) where@@ -100,11 +98,10 @@ constEnum :: (Enum a) => FFI.TypeRef -> a -> ConstValue a constEnum t i = ConstValue $ FFI.constInt t (fromIntegral $ fromEnum i) 0 -constI :: (IsType a, Integral a) => Bool -> a -> ConstValue a-constI signed i = ConstValue $ FFI.constInt (typeRef i) (fromIntegral i)-       	      	  	       		    (fromIntegral $ fromEnum signed)+constI :: (IsInteger a, Integral a) => a -> ConstValue a+constI i = ConstValue $ FFI.constInt (typeRef i) (fromIntegral i) (fromIntegral $ fromEnum $ isSigned i) -constF :: (IsType a, Real a) => a -> ConstValue a+constF :: (IsFloating a, Real a) => a -> ConstValue a constF i = ConstValue $ FFI.constReal (typeRef i) (realToFrac i)  valueOf :: (IsConst a) => a -> Value a
LLVM/Core/Instructions.hs view
@@ -11,11 +11,11 @@     -- * Arithmetic binary operations     -- | Arithmetic operations with the normal semantics.     -- The u instractions are unsigned, the s instructions are signed.-    add, sub, mul,+    add, sub, mul, neg,     udiv, sdiv, fdiv, urem, srem, frem,     -- * Logical binary operations     -- |Logical instructions with the normal semantics.-    shl, lshr, ashr, and, or, xor,+    shl, lshr, ashr, and, or, xor, inv,     -- * Vector operations     extractelement,     insertelement,@@ -216,6 +216,20 @@     liftM Value $     withCurrentBuilder $ \ bld ->       U.withEmptyCString $ op bld a1 a2++type FFIUnOp = FFI.BuilderRef -> FFI.ValueRef -> U.CString -> IO FFI.ValueRef++buildUnOp :: FFIUnOp -> FFI.ValueRef -> CodeGenFunction r (Value a)+buildUnOp op a =+    liftM Value $+    withCurrentBuilder $ \ bld ->+      U.withEmptyCString $ op bld a++neg :: (IsArithmetic a) => Value a -> CodeGenFunction r (Value a)+neg (Value x) = buildUnOp FFI.buildNeg x++inv :: (IsInteger a) => Value a -> CodeGenFunction r (Value a)+inv (Value x) = buildUnOp FFI.buildNot x  -------------------------------------- 
LLVM/Core/Type.hs view
@@ -8,8 +8,8 @@     -- * Type classifier     IsType(..),     -- ** Special type classifiers-    IsArithmetic,-    IsInteger,+    IsArithmetic(..),+    IsInteger(..),     IsFloating,     IsPrimitive,     IsFirstClass,@@ -52,10 +52,13 @@     typeRef :: a -> FFI.TypeRef  -- ^The argument is never evaluated  -- |Arithmetic types, i.e., integral and floating types.-class IsType a => IsArithmetic a+class IsType a => IsArithmetic a where+    isFloating :: a -> Bool+    isFloating _ = False  -- |Integral types.-class IsArithmetic a => IsInteger a+class IsArithmetic a => IsInteger a where+    isSigned :: a -> Bool  -- |Floating types. class IsArithmetic a => IsFloating a@@ -130,9 +133,9 @@     typeRef = funcType []  --- Instances to classify types-instance IsArithmetic Float-instance IsArithmetic Double-instance IsArithmetic FP128+instance IsArithmetic Float where isFloating _ = True+instance IsArithmetic Double where isFloating _ = True+instance IsArithmetic FP128 where isFloating _ = True instance (IsTypeNumber n) => IsArithmetic (IntN n) instance (IsTypeNumber n) => IsArithmetic (WordN n) instance IsArithmetic Bool@@ -150,17 +153,17 @@ instance IsFloating Double instance IsFloating FP128 -instance (IsTypeNumber n) => IsInteger (IntN n)-instance (IsTypeNumber n) => IsInteger (WordN n)-instance IsInteger Bool-instance IsInteger Int8-instance IsInteger Int16-instance IsInteger Int32-instance IsInteger Int64-instance IsInteger Word8-instance IsInteger Word16-instance IsInteger Word32-instance IsInteger Word64+instance (IsTypeNumber n) => IsInteger (IntN n) where isSigned _ = True+instance (IsTypeNumber n) => IsInteger (WordN n) where isSigned _ = False+instance IsInteger Bool where isSigned _ = False+instance IsInteger Int8 where isSigned _ = True+instance IsInteger Int16 where isSigned _ = True+instance IsInteger Int32 where isSigned _ = True+instance IsInteger Int64 where isSigned _ = True+instance IsInteger Word8 where isSigned _ = False+instance IsInteger Word16 where isSigned _ = False+instance IsInteger Word32 where isSigned _ = False+instance IsInteger Word64 where isSigned _ = False  instance IsFirstClass Float instance IsFirstClass Double
LLVM/Core/Vector.hs view
@@ -1,10 +1,10 @@-{- # OPTIONS_GHC -fno-warn-orphan-instance # -}+{-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, ScopedTypeVariables #-} module LLVM.Core.Vector(MkVector(..)) where import Data.TypeNumbers import LLVM.Core.Type import LLVM.Core.Data-import LLVM.Core.CodeGen(IsConst(..), ConstValue(..), Value)+import LLVM.Core.CodeGen(IsConst(..), ConstValue(..)) import LLVM.FFI.Core(constVector) import Foreign.Ptr(Ptr, castPtr) import Foreign.Storable(Storable(..))
LLVM/ExecutionEngine/Engine.hs view
@@ -18,7 +18,11 @@                            withForeignPtr) import Foreign.Marshal.Utils (fromBool) import Foreign.C.String (peekCString)-import Foreign.Ptr (Ptr, FunPtr)+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) @@ -26,7 +30,6 @@ import qualified LLVM.FFI.ExecutionEngine as FFI import qualified LLVM.FFI.Target as FFI import qualified LLVM.Core.Util(Function)-import LLVM.Core.CodeGen(Value(..), Function) import LLVM.Core.Type(IsFirstClass, IsType(..))  -- |The type of the JITer.
LLVM/FFI/ExecutionEngine.hsc view
@@ -18,7 +18,9 @@     , runFunctionAsMain     , getExecutionEngineTargetData     , addGlobalMapping+#if HAS_GETPOINTERTOGLOBAL     , getPointerToGlobal+#endif      -- * Generic values     , GenericValue
examples/Makefile view
@@ -1,7 +1,7 @@ ghc := ghc ghcflags := -Wall -optl -w # -DHAS_GETPOINTERTOGLOBAL=1-examples := HelloJIT Fibonacci BrainF Vector Array DotProd+examples := HelloJIT Fibonacci BrainF Vector Array DotProd Arith  all: $(examples) 
llvm.cabal view
@@ -1,5 +1,5 @@ name: llvm-version: 0.4.4.1+version: 0.4.4.2 license: BSD3 license-file: LICENSE synopsis: Bindings to the LLVM compiler toolkit