packages feed

llvm 0.4.1.0 → 0.4.2.0

raw patch · 5 files changed

+71/−12 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

LLVM/Core/CodeGen.hs view
@@ -61,6 +61,8 @@  class (IsType 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@@ -72,9 +74,9 @@ 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-instance IsConst Double where constOf = constF---instance IsConst FP128  where constOf = constF+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 (Array n a) where
LLVM/Core/Instructions.hs view
@@ -51,6 +51,7 @@ import Control.Monad(liftM) import Data.Int import Data.Word+import Foreign.C(CInt) --import Data.TypeNumbers import qualified LLVM.FFI.Core as FFI import LLVM.Core.Data@@ -331,6 +332,9 @@   | IntSLE                      -- ^ signed less or equal     deriving (Eq, Ord, Enum, Show) +fromIntPredicate :: IntPredicate -> CInt+fromIntPredicate p = fromIntegral (fromEnum p + 32)+ data RealPredicate =     RealFalse           -- ^ Always false (always folded)   | RealOEQ             -- ^ True if ordered and equal@@ -350,6 +354,9 @@   | RealT               -- ^ Always true (always folded)     deriving (Eq, Ord, Enum, Show) +fromRealPredicate :: RealPredicate -> CInt+fromRealPredicate p = fromIntegral (fromEnum p)+ -- |Acceptable operands to comparison instructions. class CmpOp a b c | a b -> c where     cmpop :: FFIBinOp -> a -> b -> CodeGenFunction r (Value Bool)@@ -366,12 +373,12 @@ -- | Compare integers. icmp :: (IsInteger c, CmpOp a b c) =>         IntPredicate -> a -> b -> CodeGenFunction r (Value Bool)-icmp p = cmpop (flip FFI.buildICmp (fromIntegral (fromEnum p + 32)))+icmp p = cmpop (flip FFI.buildICmp (fromIntPredicate p))  -- | Compare floating point values. fcmp :: (IsFloating c, CmpOp a b c) =>         RealPredicate -> a -> b -> CodeGenFunction r (Value Bool)-fcmp p = cmpop (flip FFI.buildFCmp (fromIntegral (fromEnum p)))+fcmp p = cmpop (flip FFI.buildFCmp (fromRealPredicate p))  -------------------------------------- @@ -602,3 +609,40 @@         U.withEmptyCString $           FFI.buildGEP bldPtr ptr idxPtr (fromIntegral idxLen) ++--------------------------------------+{-+instance (IsConst a) => Show (ConstValue a) -- XXX+instance (IsConst a) => Eq (ConstValue a)++{-+instance (IsConst a) => Eq (ConstValue a) where+    ConstValue x == ConstValue y  =+        if isFloating x then ConstValue (FFI.constFCmp (fromRealPredicate RealOEQ) x y)+                        else ConstValue (FFI.constICmp (fromIntPredicate    IntEQ) x y)+    ConstValue x /= ConstValue y  =+        if isFloating x then ConstValue (FFI.constFCmp (fromRealPredicate RealONE) x y)+                        else ConstValue (FFI.constICmp (fromIntPredicate    IntNE) x y)++instance (IsConst a) => Ord (ConstValue a) where+    ConstValue x <  ConstValue y  =+        if isFloating x then ConstValue (FFI.constFCmp (fromRealPredicate RealOLT) x y)+                        else ConstValue (FFI.constICmp (fromIntPredicate    IntLT) x y)+    ConstValue x <= ConstValue y  =+        if isFloating x then ConstValue (FFI.constFCmp (fromRealPredicate RealOLE) x y)+                        else ConstValue (FFI.constICmp (fromIntPredicate    IntLE) x y)+    ConstValue x >  ConstValue y  =+        if isFloating x then ConstValue (FFI.constFCmp (fromRealPredicate RealOGT) x y)+                        else ConstValue (FFI.constICmp (fromIntPredicate    IntGT) x y)+    ConstValue x >= ConstValue y  =+        if isFloating x then ConstValue (FFI.constFCmp (fromRealPredicate RealOGE) x y)+                        else ConstValue (FFI.constICmp (fromIntPredicate    IntGE) x y)+-}++instance (Num a, IsConst a) => Num (ConstValue a) where+    ConstValue x + ConstValue y  =  ConstValue (FFI.constAdd x y)+    ConstValue x - ConstValue y  =  ConstValue (FFI.constSub x y)+    ConstValue x * ConstValue y  =  ConstValue (FFI.constMul x y)+    negate (ConstValue x)        =  ConstValue (FFI.constNeg x)+    fromInteger x                =  constOf (fromInteger x :: a)+-}
LLVM/Core/Type.hs view
@@ -25,6 +25,19 @@ import LLVM.Core.Data import qualified LLVM.FFI.Core as FFI +-- XXX This could defined inductively, but this is good enough for LLVM+class (IsTypeNumber n) => IsPowerOf2 n+instance IsPowerOf2 (D1 End)+instance IsPowerOf2 (D2 End)+instance IsPowerOf2 (D4 End)+instance IsPowerOf2 (D8 End)+instance IsPowerOf2 (D1 (D6 End))+instance IsPowerOf2 (D3 (D2 End))+instance IsPowerOf2 (D6 (D4 End))+instance IsPowerOf2 (D1 (D2 (D8 End)))+instance IsPowerOf2 (D2 (D5 (D6 End)))+instance IsPowerOf2 (D5 (D1 (D2 End)))+ -- TODO: -- Move IntN, WordN to a special module that implements those types --   properly in Haskell.@@ -100,7 +113,7 @@     where typeRef _ = FFI.arrayType (typeRef (undefined :: a))     	  	      		    (typeNumber (undefined :: n)) -instance (IsTypeNumber n, IsPrimitive a) => IsType (Vector n a)+instance (IsPowerOf2 n, IsPrimitive a) => IsType (Vector n a)     where typeRef _ = FFI.vectorType (typeRef (undefined :: a))     	  	      		     (typeNumber (undefined :: n)) @@ -129,7 +142,7 @@ instance IsArithmetic Word16 instance IsArithmetic Word32 instance IsArithmetic Word64-instance (IsTypeNumber n, IsPrimitive a, IsArithmetic a) => IsArithmetic (Vector n a)+instance (IsPowerOf2 n, IsPrimitive a, IsArithmetic a) => IsArithmetic (Vector n a)  instance IsFloating Float instance IsFloating Double@@ -161,12 +174,12 @@ instance IsFirstClass Word16 instance IsFirstClass Word32 instance IsFirstClass Word64-instance (IsTypeNumber n, IsPrimitive a) => IsFirstClass (Vector n a)+instance (IsPowerOf2 n, IsPrimitive a) => IsFirstClass (Vector n a) instance (IsType a) => IsFirstClass (Ptr a) instance IsFirstClass () -- XXX This isn't right, but () can be returned  instance (IsTypeNumber n) => IsSequence (Array n)---instance (IsTypeNumber n, IsPrimitive a) => IsSequence (Vector n) a+--instance (IsPowerOf2 n, IsPrimitive a) => IsSequence (Vector n) a  instance IsSized Float instance IsSized Double@@ -183,7 +196,7 @@ instance IsSized Word32 instance IsSized Word64 instance (IsTypeNumber n, IsSized a) => IsSized (Array n a)-instance (IsTypeNumber n, IsPrimitive a) => IsSized (Vector n a)+instance (IsPowerOf2 n, IsPrimitive a) => IsSized (Vector n a) instance (IsType a) => IsSized (Ptr a)  instance IsPrimitive Float
examples/Makefile view
@@ -1,6 +1,6 @@ ghc := ghc ghcflags := -Wall -optl -w-examples := HelloJIT Fibonacci BrainF+examples := HelloJIT Fibonacci BrainF Vector  all: $(examples) 
llvm.cabal view
@@ -1,5 +1,5 @@ name: llvm-version: 0.4.1.0+version: 0.4.2.0 license: BSD3 license-file: LICENSE synopsis: Bindings to the LLVM compiler toolkit