llvm-dsl 0.1.2 → 0.2
raw patch · 10 files changed
+358/−358 lines, 10 filesdep ~llvm-extraPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: llvm-extra
API changes (from Hackage documentation)
- LLVM.DSL.Example.Median: type MV = T
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.Field a, LLVM.Extra.Multi.Value.Private.RationalConstant a) => Algebra.Field.C (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.Field a, LLVM.Extra.Multi.Value.Private.Real a, LLVM.Extra.Multi.Value.Private.RationalConstant a) => GHC.Real.Fractional (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.PseudoRing a, LLVM.Extra.Multi.Value.Private.IntegerConstant a) => Algebra.Ring.C (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.PseudoRing a, LLVM.Extra.Multi.Value.Private.Real a, LLVM.Extra.Multi.Value.Private.IntegerConstant a) => GHC.Num.Num (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.Real a, LLVM.Extra.Multi.Value.Private.PseudoRing a, LLVM.Extra.Multi.Value.Private.IntegerConstant a) => Algebra.Absolute.C (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.Transcendental a, LLVM.Extra.Multi.Value.Private.RationalConstant a) => Algebra.Algebraic.C (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.Transcendental a, LLVM.Extra.Multi.Value.Private.RationalConstant a) => Algebra.Transcendental.C (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (LLVM.Extra.Multi.Value.Private.Transcendental a, LLVM.Extra.Multi.Value.Private.Real a, LLVM.Extra.Multi.Value.Private.RationalConstant a) => GHC.Float.Floating (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: instance (a GHC.Types.~ LLVM.Extra.Multi.Value.Private.Scalar v, LLVM.Extra.Multi.Value.Private.PseudoModule v, LLVM.Extra.Multi.Value.Private.IntegerConstant a) => Algebra.Module.C (LLVM.DSL.Expression.Exp a) (LLVM.DSL.Expression.Exp v)
- LLVM.DSL.Expression: instance LLVM.DSL.Expression.Aggregate (LLVM.DSL.Expression.Exp a) (LLVM.Extra.Multi.Value.Private.T a)
- LLVM.DSL.Expression: instance LLVM.DSL.Expression.Aggregate exp mv => LLVM.DSL.Expression.Aggregate (LLVM.DSL.Expression.Scalar exp) (LLVM.Extra.Scalar.T mv)
- LLVM.DSL.Expression: instance LLVM.DSL.Expression.Decompose (LLVM.Extra.Multi.Value.Private.Atom a)
- LLVM.DSL.Expression: instance LLVM.DSL.Expression.Value LLVM.Extra.Multi.Value.Private.T
- LLVM.DSL.Expression: instance LLVM.Extra.Multi.Value.Private.Additive a => Algebra.Additive.C (LLVM.DSL.Expression.Exp a)
- LLVM.DSL.Expression: modifyMultiValue :: (Value val, Compose a, Decompose pattern, PatternTuple pattern ~ tuple) => pattern -> (Decomposed T pattern -> a) -> val tuple -> val (Composed a)
- LLVM.DSL.Expression: modifyMultiValue2 :: (Value val, Compose a, Decompose patternA, Decompose patternB, PatternTuple patternA ~ tupleA, PatternTuple patternB ~ tupleB) => patternA -> patternB -> (Decomposed T patternA -> Decomposed T patternB -> a) -> val tupleA -> val tupleB -> val (Composed a)
- LLVM.DSL.Expression: modifyMultiValueM :: (Compose a, Decompose pattern, PatternTuple pattern ~ tuple) => pattern -> (forall r. Decomposed T pattern -> CodeGenFunction r a) -> Exp tuple -> Exp (Composed a)
- LLVM.DSL.Expression: modifyMultiValueM2 :: (Compose a, Decompose patternA, Decompose patternB, PatternTuple patternA ~ tupleA, PatternTuple patternB ~ tupleB) => patternA -> patternB -> (forall r. Decomposed T patternA -> Decomposed T patternB -> CodeGenFunction r a) -> Exp tupleA -> Exp tupleB -> Exp (Composed a)
- LLVM.DSL.Expression: type MultiValuesOf exp;
- LLVM.DSL.Expression.Maybe: instance LLVM.DSL.Expression.Aggregate exp mv => LLVM.DSL.Expression.Aggregate (LLVM.DSL.Expression.Maybe.T exp) (LLVM.Extra.MaybePrivate.T mv)
- LLVM.DSL.Parameter: multiValue :: C a => T p a -> T a -> T a
- LLVM.DSL.Parameter: withMulti :: C b => T p b -> (forall parameters. C parameters => (p -> parameters) -> (T parameters -> T b) -> a) -> a
+ LLVM.DSL.Example.Median: type NV = T
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.Field a, LLVM.Extra.Nice.Value.Private.RationalConstant a) => Algebra.Field.C (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.Field a, LLVM.Extra.Nice.Value.Private.Real a, LLVM.Extra.Nice.Value.Private.RationalConstant a) => GHC.Real.Fractional (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.PseudoRing a, LLVM.Extra.Nice.Value.Private.IntegerConstant a) => Algebra.Ring.C (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.PseudoRing a, LLVM.Extra.Nice.Value.Private.Real a, LLVM.Extra.Nice.Value.Private.IntegerConstant a) => GHC.Num.Num (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.Real a, LLVM.Extra.Nice.Value.Private.PseudoRing a, LLVM.Extra.Nice.Value.Private.IntegerConstant a) => Algebra.Absolute.C (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.Transcendental a, LLVM.Extra.Nice.Value.Private.RationalConstant a) => Algebra.Algebraic.C (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.Transcendental a, LLVM.Extra.Nice.Value.Private.RationalConstant a) => Algebra.Transcendental.C (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (LLVM.Extra.Nice.Value.Private.Transcendental a, LLVM.Extra.Nice.Value.Private.Real a, LLVM.Extra.Nice.Value.Private.RationalConstant a) => GHC.Float.Floating (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: instance (a GHC.Types.~ LLVM.Extra.Nice.Value.Private.Scalar v, LLVM.Extra.Nice.Value.Private.PseudoModule v, LLVM.Extra.Nice.Value.Private.IntegerConstant a) => Algebra.Module.C (LLVM.DSL.Expression.Exp a) (LLVM.DSL.Expression.Exp v)
+ LLVM.DSL.Expression: instance LLVM.DSL.Expression.Aggregate (LLVM.DSL.Expression.Exp a) (LLVM.Extra.Nice.Value.Private.T a)
+ LLVM.DSL.Expression: instance LLVM.DSL.Expression.Aggregate exp nv => LLVM.DSL.Expression.Aggregate (LLVM.DSL.Expression.Scalar exp) (LLVM.Extra.Scalar.T nv)
+ LLVM.DSL.Expression: instance LLVM.DSL.Expression.Decompose (LLVM.Extra.Nice.Value.Private.Atom a)
+ LLVM.DSL.Expression: instance LLVM.DSL.Expression.Value LLVM.Extra.Nice.Value.Private.T
+ LLVM.DSL.Expression: instance LLVM.Extra.Nice.Value.Private.Additive a => Algebra.Additive.C (LLVM.DSL.Expression.Exp a)
+ LLVM.DSL.Expression: modifyNiceValue :: (Value val, Compose a, Decompose pattern, PatternTuple pattern ~ tuple) => pattern -> (Decomposed T pattern -> a) -> val tuple -> val (Composed a)
+ LLVM.DSL.Expression: modifyNiceValue2 :: (Value val, Compose a, Decompose patternA, Decompose patternB, PatternTuple patternA ~ tupleA, PatternTuple patternB ~ tupleB) => patternA -> patternB -> (Decomposed T patternA -> Decomposed T patternB -> a) -> val tupleA -> val tupleB -> val (Composed a)
+ LLVM.DSL.Expression: modifyNiceValueM :: (Compose a, Decompose pattern, PatternTuple pattern ~ tuple) => pattern -> (forall r. Decomposed T pattern -> CodeGenFunction r a) -> Exp tuple -> Exp (Composed a)
+ LLVM.DSL.Expression: modifyNiceValueM2 :: (Compose a, Decompose patternA, Decompose patternB, PatternTuple patternA ~ tupleA, PatternTuple patternB ~ tupleB) => patternA -> patternB -> (forall r. Decomposed T patternA -> Decomposed T patternB -> CodeGenFunction r a) -> Exp tupleA -> Exp tupleB -> Exp (Composed a)
+ LLVM.DSL.Expression: type NiceValuesOf exp;
+ LLVM.DSL.Expression.Maybe: instance LLVM.DSL.Expression.Aggregate exp nv => LLVM.DSL.Expression.Aggregate (LLVM.DSL.Expression.Maybe.T exp) (LLVM.Extra.MaybePrivate.T nv)
+ LLVM.DSL.Parameter: niceValue :: C a => T p a -> T a -> T a
+ LLVM.DSL.Parameter: withNice :: C b => T p b -> (forall parameters. C parameters => (p -> parameters) -> (T parameters -> T b) -> a) -> a
- LLVM.DSL.Example.Median: median3Case :: (Comparison a, Select a) => MV a -> MV a -> MV a -> CodeGenFunction r (MV a)
+ LLVM.DSL.Example.Median: median3Case :: (Comparison a, Select a) => NV a -> NV a -> NV a -> CodeGenFunction r (NV a)
- LLVM.DSL.Example.Median: median3CaseVec :: (Comparison a, Select a) => MV a -> MV a -> MV a -> CodeGenFunction r (MV a)
+ LLVM.DSL.Example.Median: median3CaseVec :: (Comparison a, Select a) => NV a -> NV a -> NV a -> CodeGenFunction r (NV a)
- LLVM.DSL.Expression: bundle :: Aggregate exp mv => exp -> CodeGenFunction r mv
+ LLVM.DSL.Expression: bundle :: Aggregate exp nv => exp -> CodeGenFunction r nv
- LLVM.DSL.Expression: class (MultiValuesOf exp ~ mv, ExpressionsOf mv ~ exp) => Aggregate exp mv where {
+ LLVM.DSL.Expression: class (NiceValuesOf exp ~ nv, ExpressionsOf nv ~ exp) => Aggregate exp nv where {
- LLVM.DSL.Expression: class Compose multituple where {
+ LLVM.DSL.Expression: class Compose nicetuple where {
- LLVM.DSL.Expression: compose :: Compose multituple => multituple -> Exp (Composed multituple)
+ LLVM.DSL.Expression: compose :: Compose nicetuple => nicetuple -> Exp (Composed nicetuple)
- LLVM.DSL.Expression: dissect :: Aggregate exp mv => mv -> exp
+ LLVM.DSL.Expression: dissect :: Aggregate exp nv => nv -> exp
- LLVM.DSL.Expression: type Composed multituple;
+ LLVM.DSL.Expression: type Composed nicetuple;
- LLVM.DSL.Expression: type ExpressionsOf mv;
+ LLVM.DSL.Expression: type ExpressionsOf nv;
Files
- llvm-dsl.cabal +4/−4
- src/LLVM/DSL/Example/Median.hs +31/−31
- src/LLVM/DSL/Expression.hs +223/−223
- src/LLVM/DSL/Expression/Maybe.hs +8/−8
- src/LLVM/DSL/Expression/Vector.hs +48/−48
- src/LLVM/DSL/Parameter.hs +20/−20
- src/LLVM/DSL/Render/Argument.hs +1/−1
- src/LLVM/DSL/Render/Run.hs +1/−1
- src/LLVM/DSL/Value.hs +1/−1
- test/Test/LLVM/DSL/Example/Median.hs +21/−21
llvm-dsl.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: 2.2 Name: llvm-dsl-Version: 0.1.2+Version: 0.2 License: BSD-3-Clause License-File: LICENSE Author: Henning Thielemann <haskell@henning-thielemann.de>@@ -33,7 +33,7 @@ Location: https://hub.darcs.net/thielema/llvm-dsl/ Source-Repository this- Tag: 0.1.2+ Tag: 0.2 Type: darcs Location: https://hub.darcs.net/thielema/llvm-dsl/ @@ -44,8 +44,8 @@ Library Build-Depends:- llvm-extra >=0.11 && <0.13,- llvm-tf >=9.0 && <17.1,+ llvm-extra >=0.12.1 && <0.14,+ llvm-tf >=9.0 && <21.1, tfp >=1.0 && <1.1, numeric-prelude >=0.4.3 && <0.5, storable-record >=0.0.5 && <0.1,
src/LLVM/DSL/Example/Median.hs view
@@ -3,8 +3,8 @@ import qualified LLVM.DSL.Expression as Expr import LLVM.DSL.Expression (Exp, (==*), (<=*), (&&*), (||*)) -import qualified LLVM.Extra.Multi.Vector as MVec-import qualified LLVM.Extra.Multi.Value as MV+import qualified LLVM.Extra.Nice.Vector as NVec+import qualified LLVM.Extra.Nice.Value as NV import qualified LLVM.Core as LLVM @@ -13,7 +13,7 @@ -median3IfThen :: (MV.Comparison a) => Exp a -> Exp a -> Exp a -> Exp a+median3IfThen :: (NV.Comparison a) => Exp a -> Exp a -> Exp a -> Exp a median3IfThen a b c = Expr.ifThenElse (a<=*b) (Expr.ifThenElse (b<=*c)@@ -24,7 +24,7 @@ (Expr.ifThenElse (b<=*c) c b)) median3Select ::- (MV.Comparison a, MV.Select a) => Exp a -> Exp a -> Exp a -> Exp a+ (NV.Comparison a, NV.Select a) => Exp a -> Exp a -> Exp a -> Exp a median3Select a b c = Expr.select (a<=*b) (Expr.select (b<=*c)@@ -35,7 +35,7 @@ (Expr.select (b<=*c) c b)) median3SelectShared ::- (MV.Comparison a, MV.Select a) => Exp a -> Exp a -> Exp a -> Exp a+ (NV.Comparison a, NV.Select a) => Exp a -> Exp a -> Exp a -> Exp a median3SelectShared a b c = Expr.with (a<=*b) $ \a_le_b -> Expr.with (b<=*c) $ \b_le_c ->@@ -45,48 +45,48 @@ (Expr.select a_le_c a (Expr.select b_le_c c b)) median3MinMax ::- (MV.Comparison a, MV.Select a) => Exp a -> Exp a -> Exp a -> Exp a+ (NV.Comparison a, NV.Select a) => Exp a -> Exp a -> Exp a -> Exp a median3MinMax a b c = let minab = Expr.min a b in let maxab = Expr.max a b in Expr.select (maxab <=* c) maxab $ Expr.select (minab <=* c) c minab median3MinMaxVector ::- (LLVM.Positive n, MVec.C a) =>- (MV.Comparison a, MV.Select a) =>- MVec.T n a -> MVec.T n a -> MVec.T n a ->- LLVM.CodeGenFunction r (MVec.T n a)+ (LLVM.Positive n, NVec.C a) =>+ (NV.Comparison a, NV.Select a) =>+ NVec.T n a -> NVec.T n a -> NVec.T n a ->+ LLVM.CodeGenFunction r (NVec.T n a) median3MinMaxVector a b c =- MVec.map (uncurry3 (Expr.unliftM3 median3MinMax) . MV.unzip3) $- MVec.zip3 a b c+ NVec.map (uncurry3 (Expr.unliftM3 median3MinMax) . NV.unzip3) $+ NVec.zip3 a b c -type MV = MV.T+type NV = NV.T median3Case ::- (MV.Comparison a, MV.Select a) =>- MV a -> MV a -> MV a -> LLVM.CodeGenFunction r (MV a)+ (NV.Comparison a, NV.Select a) =>+ NV a -> NV a -> NV a -> LLVM.CodeGenFunction r (NV a) median3Case a b c = do- a_le_b <- MV.cmp LLVM.CmpLE a b- a_le_c <- MV.cmp LLVM.CmpLE a c- b_le_c <- MV.cmp LLVM.CmpLE b c- let mask = MV.fromInteger'- a_le_b_mask <- MV.select a_le_b (mask 1) (mask 0)- a_le_c_mask <- MV.select a_le_c (mask 2) (mask 0)- b_le_c_mask <- MV.select b_le_c (mask 4) (mask 0)- maskMV <- MV.or a_le_b_mask =<< MV.or a_le_c_mask b_le_c_mask- let maskE = Expr.lift0 (maskMV :: MV Word8)+ a_le_b <- NV.cmp LLVM.CmpLE a b+ a_le_c <- NV.cmp LLVM.CmpLE a c+ b_le_c <- NV.cmp LLVM.CmpLE b c+ let mask = NV.fromInteger'+ a_le_b_mask <- NV.select a_le_b (mask 1) (mask 0)+ a_le_c_mask <- NV.select a_le_c (mask 2) (mask 0)+ b_le_c_mask <- NV.select b_le_c (mask 4) (mask 0)+ maskNV <- NV.or a_le_b_mask =<< NV.or a_le_c_mask b_le_c_mask+ let maskE = Expr.lift0 (maskNV :: NV Word8) selectB <- Expr.unExp (maskE ==* 0 ||* maskE ==* 7) selectA <- Expr.unExp (maskE ==* 1 ||* maskE ==* 6)- MV.select selectA a =<< MV.select selectB b c+ NV.select selectA a =<< NV.select selectB b c median3CaseVec ::- (MV.Comparison a, MV.Select a) =>- MV a -> MV a -> MV a -> LLVM.CodeGenFunction r (MV a)+ (NV.Comparison a, NV.Select a) =>+ NV a -> NV a -> NV a -> LLVM.CodeGenFunction r (NV a) median3CaseVec a b c = do- a_le_b <- MV.cmp LLVM.CmpLE a b- a_le_c <- MV.cmp LLVM.CmpLE a c- b_le_c <- MV.cmp LLVM.CmpLE b c+ a_le_b <- NV.cmp LLVM.CmpLE a b+ a_le_c <- NV.cmp LLVM.CmpLE a c+ b_le_c <- NV.cmp LLVM.CmpLE b c let check ab ac bc = Expr.select (Expr.lift0 a_le_b) 1 0 ==* (ab :: Exp Word8) &&*@@ -95,4 +95,4 @@ Expr.select (Expr.lift0 b_le_c) 1 0 ==* (bc :: Exp Word8) selectB <- Expr.unExp (check 0 0 0 ||* check 1 1 1) selectA <- Expr.unExp (check 1 0 0 ||* check 0 1 1)- MV.select selectA a =<< MV.select selectB b c+ NV.select selectA a =<< NV.select selectB b c
src/LLVM/DSL/Expression.hs view
@@ -5,13 +5,13 @@ module LLVM.DSL.Expression where import qualified LLVM.Extra.ScalarOrVector as SoV-import qualified LLVM.Extra.Multi.Value as MultiValue+import qualified LLVM.Extra.Nice.Value as NiceValue import qualified LLVM.Extra.FastMath as FastMath import qualified LLVM.Extra.Scalar as Scalar import qualified LLVM.Extra.Arithmetic as A import qualified LLVM.Extra.Control as C import qualified LLVM.Core as LLVM-import LLVM.Extra.Multi.Value (PatternTuple, Decomposed, Atom)+import LLVM.Extra.Nice.Value (PatternTuple, Decomposed, Atom) import qualified Control.Monad.HT as Monad import Control.Monad.IO.Class (liftIO)@@ -43,22 +43,22 @@ curry, uncurry, recip, pi, sqrt, maybe, toEnum, fromEnum, pred, succ) -newtype Exp a = Exp {unExp :: forall r. LLVM.CodeGenFunction r (MultiValue.T a)}+newtype Exp a = Exp {unExp :: forall r. LLVM.CodeGenFunction r (NiceValue.T a)} {- Using IORef should be thread-safe here, because you cannot fork within CodeGenFunction. -}-unique :: (forall r. LLVM.CodeGenFunction r (MultiValue.T a)) -> Exp a+unique :: (forall r. LLVM.CodeGenFunction r (NiceValue.T a)) -> Exp a unique = Exp -_unique :: (forall r. LLVM.CodeGenFunction r (MultiValue.T a)) -> Exp a+_unique :: (forall r. LLVM.CodeGenFunction r (NiceValue.T a)) -> Exp a _unique code = unsafePerformIO $ fmap (withKey code) $ newIORef Nothing withKey ::- (forall r. LLVM.CodeGenFunction r (MultiValue.T a)) ->- IORef (Maybe (MultiValue.T a)) -> Exp a+ (forall r. LLVM.CodeGenFunction r (NiceValue.T a)) ->+ IORef (Maybe (NiceValue.T a)) -> Exp a withKey code ref = Exp (do ma <- liftIO $ readIORef ref@@ -78,15 +78,15 @@ class Value val where- lift0 :: MultiValue.T a -> val a+ lift0 :: NiceValue.T a -> val a lift1 ::- (MultiValue.T a -> MultiValue.T b) ->+ (NiceValue.T a -> NiceValue.T b) -> val a -> val b lift2 ::- (MultiValue.T a -> MultiValue.T b -> MultiValue.T c) ->+ (NiceValue.T a -> NiceValue.T b -> NiceValue.T c) -> val a -> val b -> val c -instance Value MultiValue.T where+instance Value NiceValue.T where lift0 = id lift1 = id lift2 = id@@ -98,23 +98,23 @@ lift3 :: (Value val) =>- (MultiValue.T a -> MultiValue.T b -> MultiValue.T c -> MultiValue.T d) ->+ (NiceValue.T a -> NiceValue.T b -> NiceValue.T c -> NiceValue.T d) -> val a -> val b -> val c -> val d-lift3 f a b = lift2 (MultiValue.uncurry f) (zip a b)+lift3 f a b = lift2 (NiceValue.uncurry f) (zip a b) lift4 :: (Value val) =>- (MultiValue.T a -> MultiValue.T b -> MultiValue.T c -> MultiValue.T d ->- MultiValue.T e) ->+ (NiceValue.T a -> NiceValue.T b -> NiceValue.T c -> NiceValue.T d ->+ NiceValue.T e) -> val a -> val b -> val c -> val d -> val e-lift4 f a b = lift3 (MultiValue.uncurry f) (zip a b)+lift4 f a b = lift3 (NiceValue.uncurry f) (zip a b) liftM :: (Aggregate ae am) => (forall r.- am -> LLVM.CodeGenFunction r (MultiValue.T b)) ->+ am -> LLVM.CodeGenFunction r (NiceValue.T b)) -> (ae -> Exp b) liftM f a = unique (f =<< bundle a) @@ -122,7 +122,7 @@ (Aggregate ae am) => (Aggregate be bm) => (forall r.- am -> bm -> LLVM.CodeGenFunction r (MultiValue.T c)) ->+ am -> bm -> LLVM.CodeGenFunction r (NiceValue.T c)) -> (ae -> be -> Exp c) liftM2 f a b = unique (Monad.liftJoin2 f (bundle a) (bundle b)) @@ -131,7 +131,7 @@ (Aggregate be bm) => (Aggregate ce cm) => (forall r.- am -> bm -> cm -> LLVM.CodeGenFunction r (MultiValue.T d)) ->+ am -> bm -> cm -> LLVM.CodeGenFunction r (NiceValue.T d)) -> (ae -> be -> ce -> Exp d) liftM3 f a b c = unique (Monad.liftJoin3 f (bundle a) (bundle b) (bundle c)) @@ -174,35 +174,35 @@ liftReprM :: (forall r.- MultiValue.Repr a ->- LLVM.CodeGenFunction r (MultiValue.Repr b)) ->+ NiceValue.Repr a ->+ LLVM.CodeGenFunction r (NiceValue.Repr b)) -> (Exp a -> Exp b)-liftReprM f = liftM (MultiValue.liftM f)+liftReprM f = liftM (NiceValue.liftM f) liftReprM2 :: (forall r.- MultiValue.Repr a -> MultiValue.Repr b ->- LLVM.CodeGenFunction r (MultiValue.Repr c)) ->+ NiceValue.Repr a -> NiceValue.Repr b ->+ LLVM.CodeGenFunction r (NiceValue.Repr c)) -> (Exp a -> Exp b -> Exp c)-liftReprM2 f = liftM2 (MultiValue.liftM2 f)+liftReprM2 f = liftM2 (NiceValue.liftM2 f) liftReprM3 :: (forall r.- MultiValue.Repr a -> MultiValue.Repr b -> MultiValue.Repr c ->- LLVM.CodeGenFunction r (MultiValue.Repr d)) ->+ NiceValue.Repr a -> NiceValue.Repr b -> NiceValue.Repr c ->+ LLVM.CodeGenFunction r (NiceValue.Repr d)) -> (Exp a -> Exp b -> Exp c -> Exp d)-liftReprM3 f = liftM3 (MultiValue.liftM3 f)+liftReprM3 f = liftM3 (NiceValue.liftM3 f) zip :: (Value val) => val a -> val b -> val (a, b)-zip = lift2 MultiValue.zip+zip = lift2 NiceValue.zip zip3 :: (Value val) => val a -> val b -> val c -> val (a, b, c)-zip3 = lift3 MultiValue.zip3+zip3 = lift3 NiceValue.zip3 zip4 :: (Value val) => val a -> val b -> val c -> val d -> val (a, b, c, d)-zip4 = lift4 MultiValue.zip4+zip4 = lift4 NiceValue.zip4 unzip :: (Value val) => val (a, b) -> (val a, val b) unzip ab = (fst ab, snd ab)@@ -212,29 +212,29 @@ unzip4 :: (Value val) => val (a, b, c, d) -> (val a, val b, val c, val d) unzip4 abcd =- (lift1 (\(MultiValue.Cons (a,_,_,_)) -> MultiValue.Cons a) abcd,- lift1 (\(MultiValue.Cons (_,b,_,_)) -> MultiValue.Cons b) abcd,- lift1 (\(MultiValue.Cons (_,_,c,_)) -> MultiValue.Cons c) abcd,- lift1 (\(MultiValue.Cons (_,_,_,d)) -> MultiValue.Cons d) abcd)+ (lift1 (\(NiceValue.Cons (a,_,_,_)) -> NiceValue.Cons a) abcd,+ lift1 (\(NiceValue.Cons (_,b,_,_)) -> NiceValue.Cons b) abcd,+ lift1 (\(NiceValue.Cons (_,_,c,_)) -> NiceValue.Cons c) abcd,+ lift1 (\(NiceValue.Cons (_,_,_,d)) -> NiceValue.Cons d) abcd) fst :: (Value val) => val (a, b) -> val a-fst = lift1 MultiValue.fst+fst = lift1 NiceValue.fst snd :: (Value val) => val (a, b) -> val b-snd = lift1 MultiValue.snd+snd = lift1 NiceValue.snd mapFst :: (Exp a -> Exp b) -> Exp (a, c) -> Exp (b, c)-mapFst f = liftM (MultiValue.mapFstF (unliftM1 f))+mapFst f = liftM (NiceValue.mapFstF (unliftM1 f)) mapSnd :: (Exp b -> Exp c) -> Exp (a, b) -> Exp (a, c)-mapSnd f = liftM (MultiValue.mapSndF (unliftM1 f))+mapSnd f = liftM (NiceValue.mapSndF (unliftM1 f)) mapPair :: (Exp a0 -> Exp a1, Exp b0 -> Exp b1) -> Exp (a0, b0) -> Exp (a1, b1) mapPair (f,g) = mapFst f . mapSnd g swap :: (Value val) => val (a, b) -> val (b, a)-swap = lift1 MultiValue.swap+swap = lift1 NiceValue.swap curry :: (Exp (a,b) -> c) -> (Exp a -> Exp b -> c) curry f = Tuple.curry (f . Tuple.uncurry zip)@@ -244,22 +244,22 @@ fst3 :: (Value val) => val (a,b,c) -> val a-fst3 = lift1 MultiValue.fst3+fst3 = lift1 NiceValue.fst3 snd3 :: (Value val) => val (a,b,c) -> val b-snd3 = lift1 MultiValue.snd3+snd3 = lift1 NiceValue.snd3 thd3 :: (Value val) => val (a,b,c) -> val c-thd3 = lift1 MultiValue.thd3+thd3 = lift1 NiceValue.thd3 mapFst3 :: (Exp a0 -> Exp a1) -> Exp (a0,b,c) -> Exp (a1,b,c)-mapFst3 f = liftM (MultiValue.mapFst3F (unliftM1 f))+mapFst3 f = liftM (NiceValue.mapFst3F (unliftM1 f)) mapSnd3 :: (Exp b0 -> Exp b1) -> Exp (a,b0,c) -> Exp (a,b1,c)-mapSnd3 f = liftM (MultiValue.mapSnd3F (unliftM1 f))+mapSnd3 f = liftM (NiceValue.mapSnd3F (unliftM1 f)) mapThd3 :: (Exp c0 -> Exp c1) -> Exp (a,b,c0) -> Exp (a,b,c1)-mapThd3 f = liftM (MultiValue.mapThd3F (unliftM1 f))+mapThd3 f = liftM (NiceValue.mapThd3F (unliftM1 f)) mapTriple :: (Exp a0 -> Exp a1, Exp b0 -> Exp b1, Exp c0 -> Exp c1) ->@@ -268,81 +268,81 @@ tuple :: Exp tuple -> Exp (StTuple.Tuple tuple)-tuple = lift1 MultiValue.tuple+tuple = lift1 NiceValue.tuple untuple :: Exp (StTuple.Tuple tuple) -> Exp tuple-untuple = lift1 MultiValue.untuple+untuple = lift1 NiceValue.untuple -modifyMultiValue ::+modifyNiceValue :: (Value val,- MultiValue.Compose a,- MultiValue.Decompose pattern,- MultiValue.PatternTuple pattern ~ tuple) =>+ NiceValue.Compose a,+ NiceValue.Decompose pattern,+ NiceValue.PatternTuple pattern ~ tuple) => pattern ->- (Decomposed MultiValue.T pattern -> a) ->- val tuple -> val (MultiValue.Composed a)-modifyMultiValue p f = lift1 $ MultiValue.modify p f+ (Decomposed NiceValue.T pattern -> a) ->+ val tuple -> val (NiceValue.Composed a)+modifyNiceValue p f = lift1 $ NiceValue.modify p f -modifyMultiValue2 ::+modifyNiceValue2 :: (Value val,- MultiValue.Compose a,- MultiValue.Decompose patternA,- MultiValue.Decompose patternB,- MultiValue.PatternTuple patternA ~ tupleA,- MultiValue.PatternTuple patternB ~ tupleB) =>+ NiceValue.Compose a,+ NiceValue.Decompose patternA,+ NiceValue.Decompose patternB,+ NiceValue.PatternTuple patternA ~ tupleA,+ NiceValue.PatternTuple patternB ~ tupleB) => patternA -> patternB ->- (Decomposed MultiValue.T patternA ->- Decomposed MultiValue.T patternB -> a) ->- val tupleA -> val tupleB -> val (MultiValue.Composed a)-modifyMultiValue2 pa pb f = lift2 $ MultiValue.modify2 pa pb f+ (Decomposed NiceValue.T patternA ->+ Decomposed NiceValue.T patternB -> a) ->+ val tupleA -> val tupleB -> val (NiceValue.Composed a)+modifyNiceValue2 pa pb f = lift2 $ NiceValue.modify2 pa pb f -modifyMultiValueM ::- (MultiValue.Compose a,- MultiValue.Decompose pattern,- MultiValue.PatternTuple pattern ~ tuple) =>+modifyNiceValueM ::+ (NiceValue.Compose a,+ NiceValue.Decompose pattern,+ NiceValue.PatternTuple pattern ~ tuple) => pattern -> (forall r.- Decomposed MultiValue.T pattern ->+ Decomposed NiceValue.T pattern -> LLVM.CodeGenFunction r a) ->- Exp tuple -> Exp (MultiValue.Composed a)-modifyMultiValueM p f = liftM (MultiValue.modifyF p f)+ Exp tuple -> Exp (NiceValue.Composed a)+modifyNiceValueM p f = liftM (NiceValue.modifyF p f) -modifyMultiValueM2 ::- (MultiValue.Compose a,- MultiValue.Decompose patternA,- MultiValue.Decompose patternB,- MultiValue.PatternTuple patternA ~ tupleA,- MultiValue.PatternTuple patternB ~ tupleB) =>+modifyNiceValueM2 ::+ (NiceValue.Compose a,+ NiceValue.Decompose patternA,+ NiceValue.Decompose patternB,+ NiceValue.PatternTuple patternA ~ tupleA,+ NiceValue.PatternTuple patternB ~ tupleB) => patternA -> patternB -> (forall r.- Decomposed MultiValue.T patternA ->- Decomposed MultiValue.T patternB ->+ Decomposed NiceValue.T patternA ->+ Decomposed NiceValue.T patternB -> LLVM.CodeGenFunction r a) ->- Exp tupleA -> Exp tupleB -> Exp (MultiValue.Composed a)-modifyMultiValueM2 pa pb f = liftM2 (MultiValue.modifyF2 pa pb f)+ Exp tupleA -> Exp tupleB -> Exp (NiceValue.Composed a)+modifyNiceValueM2 pa pb f = liftM2 (NiceValue.modifyF2 pa pb f) -class Compose multituple where- type Composed multituple+class Compose nicetuple where+ type Composed nicetuple {- | A nested 'zip'. -}- compose :: multituple -> Exp (Composed multituple)+ compose :: nicetuple -> Exp (Composed nicetuple) class (Composed (Decomposed Exp pattern) ~ PatternTuple pattern) => Decompose pattern where {- |- Analogous to 'MultiValue.decompose'.+ Analogous to 'NiceValue.decompose'. -} decompose :: pattern -> Exp (PatternTuple pattern) -> Decomposed Exp pattern {- |-Analogus to 'MultiValue.modifyMultiValue'.+Analogus to 'NiceValue.modify'. -} modify :: (Compose a, Decompose pattern) =>@@ -440,26 +440,26 @@ or use the NumericPrelude type classes. -} consComplex :: Exp a -> Exp a -> Exp (Complex a)-consComplex = lift2 MultiValue.consComplex+consComplex = lift2 NiceValue.consComplex deconsComplex :: Exp (Complex a) -> (Exp a, Exp a)-deconsComplex c = (lift1 MultiValue.realPart c, lift1 MultiValue.imagPart c)+deconsComplex c = (lift1 NiceValue.realPart c, lift1 NiceValue.imagPart c) -class (MultiValuesOf exp ~ mv, ExpressionsOf mv ~ exp) => Aggregate exp mv where- type MultiValuesOf exp- type ExpressionsOf mv- bundle :: exp -> LLVM.CodeGenFunction r mv- dissect :: mv -> exp+class (NiceValuesOf exp ~ nv, ExpressionsOf nv ~ exp) => Aggregate exp nv where+ type NiceValuesOf exp+ type ExpressionsOf nv+ bundle :: exp -> LLVM.CodeGenFunction r nv+ dissect :: nv -> exp -instance Aggregate (Exp a) (MultiValue.T a) where- type MultiValuesOf (Exp a) = MultiValue.T a- type ExpressionsOf (MultiValue.T a) = Exp a+instance Aggregate (Exp a) (NiceValue.T a) where+ type NiceValuesOf (Exp a) = NiceValue.T a+ type ExpressionsOf (NiceValue.T a) = Exp a bundle (Exp x) = x dissect x = Exp (return x) instance (Aggregate ae al, Aggregate be bl) => Aggregate (ae,be) (al,bl) where- type MultiValuesOf (ae,be) = (MultiValuesOf ae, MultiValuesOf be)+ type NiceValuesOf (ae,be) = (NiceValuesOf ae, NiceValuesOf be) type ExpressionsOf (al,bl) = (ExpressionsOf al, ExpressionsOf bl) bundle (a,b) = Monad.lift2 (,) (bundle a) (bundle b) dissect (a,b) = (dissect a, dissect b)@@ -467,8 +467,8 @@ instance (Aggregate ae al, Aggregate be bl, Aggregate ce cl) => Aggregate (ae,be,ce) (al,bl,cl) where- type MultiValuesOf (ae,be,ce) =- (MultiValuesOf ae, MultiValuesOf be, MultiValuesOf ce)+ type NiceValuesOf (ae,be,ce) =+ (NiceValuesOf ae, NiceValuesOf be, NiceValuesOf ce) type ExpressionsOf (al,bl,cl) = (ExpressionsOf al, ExpressionsOf bl, ExpressionsOf cl) bundle (a,b,c) = Monad.lift3 (,,) (bundle a) (bundle b) (bundle c)@@ -477,9 +477,9 @@ instance (Aggregate ae al, Aggregate be bl, Aggregate ce cl, Aggregate de dl) => Aggregate (ae,be,ce,de) (al,bl,cl,dl) where- type MultiValuesOf (ae,be,ce,de) =- (MultiValuesOf ae, MultiValuesOf be,- MultiValuesOf ce, MultiValuesOf de)+ type NiceValuesOf (ae,be,ce,de) =+ (NiceValuesOf ae, NiceValuesOf be,+ NiceValuesOf ce, NiceValuesOf de) type ExpressionsOf (al,bl,cl,dl) = (ExpressionsOf al, ExpressionsOf bl, ExpressionsOf cl, ExpressionsOf dl)@@ -488,7 +488,7 @@ dissect (a,b,c,d) = (dissect a, dissect b, dissect c, dissect d) instance (Aggregate ae al) => Aggregate (Complex.T ae) (Complex.T al) where- type MultiValuesOf (Complex.T ae) = Complex.T (MultiValuesOf ae)+ type NiceValuesOf (Complex.T ae) = Complex.T (NiceValuesOf ae) type ExpressionsOf (Complex.T al) = Complex.T (ExpressionsOf al) dissect = fmap dissect bundle c =@@ -499,9 +499,9 @@ -- ToDo: move to numericprelude? newtype Scalar a = Scalar a -instance (Aggregate exp mv) => Aggregate (Scalar exp) (Scalar.T mv) where- type MultiValuesOf (Scalar exp) = Scalar.T (MultiValuesOf exp)- type ExpressionsOf (Scalar.T mv) = Scalar (ExpressionsOf mv)+instance (Aggregate exp nv) => Aggregate (Scalar exp) (Scalar.T nv) where+ type NiceValuesOf (Scalar exp) = Scalar.T (NiceValuesOf exp)+ type ExpressionsOf (Scalar.T nv) = Scalar (ExpressionsOf nv) bundle (Scalar x) = Scalar.Cons <$> bundle x dissect (Scalar.Cons x) = Scalar $ dissect x @@ -519,115 +519,115 @@ Scalar a *> Scalar b = Scalar (a Ring.* b) -cons :: (MultiValue.C a) => a -> Exp a-cons = lift0 . MultiValue.cons+cons :: (NiceValue.C a) => a -> Exp a+cons = lift0 . NiceValue.cons unit :: Exp () unit = cons () -zero :: (MultiValue.C a) => Exp a-zero = lift0 MultiValue.zero+zero :: (NiceValue.C a) => Exp a+zero = lift0 NiceValue.zero -add :: (MultiValue.Additive a) => Exp a -> Exp a -> Exp a-add = liftM2 MultiValue.add+add :: (NiceValue.Additive a) => Exp a -> Exp a -> Exp a+add = liftM2 NiceValue.add -sub :: (MultiValue.Additive a) => Exp a -> Exp a -> Exp a-sub = liftM2 MultiValue.sub+sub :: (NiceValue.Additive a) => Exp a -> Exp a -> Exp a+sub = liftM2 NiceValue.sub -neg :: (MultiValue.Additive a) => Exp a -> Exp a-neg = liftM MultiValue.neg+neg :: (NiceValue.Additive a) => Exp a -> Exp a+neg = liftM NiceValue.neg -one :: (MultiValue.IntegerConstant a) => Exp a+one :: (NiceValue.IntegerConstant a) => Exp a one = fromInteger' 1 -mul :: (MultiValue.PseudoRing a) => Exp a -> Exp a -> Exp a-mul = liftM2 MultiValue.mul+mul :: (NiceValue.PseudoRing a) => Exp a -> Exp a -> Exp a+mul = liftM2 NiceValue.mul -sqr :: (MultiValue.PseudoRing a) => Exp a -> Exp a-sqr = liftM $ \x -> MultiValue.mul x x+sqr :: (NiceValue.PseudoRing a) => Exp a -> Exp a+sqr = liftM $ \x -> NiceValue.mul x x -recip :: (MultiValue.Field a, MultiValue.IntegerConstant a) => Exp a -> Exp a+recip :: (NiceValue.Field a, NiceValue.IntegerConstant a) => Exp a -> Exp a recip = fdiv one -fdiv :: (MultiValue.Field a) => Exp a -> Exp a -> Exp a-fdiv = liftM2 MultiValue.fdiv+fdiv :: (NiceValue.Field a) => Exp a -> Exp a -> Exp a+fdiv = liftM2 NiceValue.fdiv -sqrt :: (MultiValue.Algebraic a) => Exp a -> Exp a-sqrt = liftM MultiValue.sqrt+sqrt :: (NiceValue.Algebraic a) => Exp a -> Exp a+sqrt = liftM NiceValue.sqrt -pow :: (MultiValue.Transcendental a) => Exp a -> Exp a -> Exp a-pow = liftM2 MultiValue.pow+pow :: (NiceValue.Transcendental a) => Exp a -> Exp a -> Exp a+pow = liftM2 NiceValue.pow -idiv :: (MultiValue.Integral a) => Exp a -> Exp a -> Exp a-idiv = liftM2 MultiValue.idiv+idiv :: (NiceValue.Integral a) => Exp a -> Exp a -> Exp a+idiv = liftM2 NiceValue.idiv -irem :: (MultiValue.Integral a) => Exp a -> Exp a -> Exp a-irem = liftM2 MultiValue.irem+irem :: (NiceValue.Integral a) => Exp a -> Exp a -> Exp a+irem = liftM2 NiceValue.irem -shl :: (MultiValue.BitShift a) => Exp a -> Exp a -> Exp a-shl = liftM2 MultiValue.shl+shl :: (NiceValue.BitShift a) => Exp a -> Exp a -> Exp a+shl = liftM2 NiceValue.shl -shr :: (MultiValue.BitShift a) => Exp a -> Exp a -> Exp a-shr = liftM2 MultiValue.shr+shr :: (NiceValue.BitShift a) => Exp a -> Exp a -> Exp a+shr = liftM2 NiceValue.shr -fromInteger' :: (MultiValue.IntegerConstant a) => Integer -> Exp a-fromInteger' = lift0 . MultiValue.fromInteger'+fromInteger' :: (NiceValue.IntegerConstant a) => Integer -> Exp a+fromInteger' = lift0 . NiceValue.fromInteger' -fromRational' :: (MultiValue.RationalConstant a) => Rational -> Exp a-fromRational' = lift0 . MultiValue.fromRational'+fromRational' :: (NiceValue.RationalConstant a) => Rational -> Exp a+fromRational' = lift0 . NiceValue.fromRational' boolPFrom8 :: Exp Bool8 -> Exp Bool-boolPFrom8 = lift1 MultiValue.boolPFrom8+boolPFrom8 = lift1 NiceValue.boolPFrom8 bool8FromP :: Exp Bool -> Exp Bool8-bool8FromP = lift1 MultiValue.bool8FromP+bool8FromP = lift1 NiceValue.bool8FromP -intFromBool8 :: (MultiValue.NativeInteger i ir) => Exp Bool8 -> Exp i-intFromBool8 = liftM MultiValue.intFromBool8+intFromBool8 :: (NiceValue.NativeInteger i ir) => Exp Bool8 -> Exp i+intFromBool8 = liftM NiceValue.intFromBool8 -floatFromBool8 :: (MultiValue.NativeFloating a ar) => Exp Bool8 -> Exp a-floatFromBool8 = liftM MultiValue.floatFromBool8+floatFromBool8 :: (NiceValue.NativeFloating a ar) => Exp Bool8 -> Exp a+floatFromBool8 = liftM NiceValue.floatFromBool8 toEnum ::- (MultiValue.Repr w ~ LLVM.Value w) =>+ (NiceValue.Repr w ~ LLVM.Value w) => Exp w -> Exp (Enum.T w e)-toEnum = lift1 MultiValue.toEnum+toEnum = lift1 NiceValue.toEnum fromEnum ::- (MultiValue.Repr w ~ LLVM.Value w) =>+ (NiceValue.Repr w ~ LLVM.Value w) => Exp (Enum.T w e) -> Exp w-fromEnum = lift1 MultiValue.fromEnum+fromEnum = lift1 NiceValue.fromEnum succ, pred :: (LLVM.IsArithmetic w, SoV.IntegerConstant w) => Exp (Enum.T w e) -> Exp (Enum.T w e)-succ = liftM MultiValue.succ-pred = liftM MultiValue.pred+succ = liftM NiceValue.succ+pred = liftM NiceValue.pred fromFastMath :: Exp (FastMath.Number flags a) -> Exp a-fromFastMath = lift1 FastMath.mvDenumber+fromFastMath = lift1 FastMath.nvDenumber toFastMath :: Exp a -> Exp (FastMath.Number flags a)-toFastMath = lift1 FastMath.mvNumber+toFastMath = lift1 FastMath.nvNumber -minBound, maxBound :: (MultiValue.Bounded a) => Exp a-minBound = lift0 MultiValue.minBound-maxBound = lift0 MultiValue.maxBound+minBound, maxBound :: (NiceValue.Bounded a) => Exp a+minBound = lift0 NiceValue.minBound+maxBound = lift0 NiceValue.maxBound cmp ::- (MultiValue.Comparison a) =>+ (NiceValue.Comparison a) => LLVM.CmpPredicate -> Exp a -> Exp a -> Exp Bool-cmp ord = liftM2 (MultiValue.cmp ord)+cmp ord = liftM2 (NiceValue.cmp ord) infix 4 ==*, /=*, <*, <=*, >*, >=* (==*), (/=*), (<*), (>=*), (>*), (<=*) ::- (MultiValue.Comparison a) => Exp a -> Exp a -> Exp Bool+ (NiceValue.Comparison a) => Exp a -> Exp a -> Exp Bool (==*) = cmp LLVM.CmpEQ (/=*) = cmp LLVM.CmpNE (<*) = cmp LLVM.CmpLT@@ -636,15 +636,15 @@ (<=*) = cmp LLVM.CmpLE -min, max :: (MultiValue.Real a) => Exp a -> Exp a -> Exp a+min, max :: (NiceValue.Real a) => Exp a -> Exp a -> Exp a min = liftM2 A.min max = liftM2 A.max -limit :: (MultiValue.Real a) => (Exp a, Exp a) -> Exp a -> Exp a+limit :: (NiceValue.Real a) => (Exp a, Exp a) -> Exp a -> Exp a limit (l,u) = max l . min u -fraction :: (MultiValue.Fraction a) => Exp a -> Exp a-fraction = liftM MultiValue.fraction+fraction :: (NiceValue.Fraction a) => Exp a -> Exp a+fraction = liftM NiceValue.fraction true, false :: Exp Bool@@ -653,82 +653,82 @@ infixr 3 &&* (&&*) :: Exp Bool -> Exp Bool -> Exp Bool-(&&*) = liftM2 MultiValue.and+(&&*) = liftM2 NiceValue.and infixr 2 ||* (||*) :: Exp Bool -> Exp Bool -> Exp Bool-(||*) = liftM2 MultiValue.or+(||*) = liftM2 NiceValue.or not :: Exp Bool -> Exp Bool-not = liftM MultiValue.inv+not = liftM NiceValue.inv {- | Like 'ifThenElse' but computes both alternative expressions and then uses LLVM's efficient @select@ instruction. -}-select :: (MultiValue.Select a) => Exp Bool -> Exp a -> Exp a -> Exp a-select = liftM3 MultiValue.select+select :: (NiceValue.Select a) => Exp Bool -> Exp a -> Exp a -> Exp a+select = liftM3 NiceValue.select -ifThenElse :: (MultiValue.C a) => Exp Bool -> Exp a -> Exp a -> Exp a+ifThenElse :: (NiceValue.C a) => Exp Bool -> Exp a -> Exp a -> Exp a ifThenElse ec ex ey = unique (do- MultiValue.Cons c <- unExp ec+ NiceValue.Cons c <- unExp ec C.ifThenElse c (unExp ex) (unExp ey)) -complement :: (MultiValue.Logic a) => Exp a -> Exp a-complement = liftM MultiValue.inv+complement :: (NiceValue.Logic a) => Exp a -> Exp a+complement = liftM NiceValue.inv infixl 7 .&.*-(.&.*) :: (MultiValue.Logic a) => Exp a -> Exp a -> Exp a-(.&.*) = liftM2 MultiValue.and+(.&.*) :: (NiceValue.Logic a) => Exp a -> Exp a -> Exp a+(.&.*) = liftM2 NiceValue.and infixl 5 .|.*-(.|.*) :: (MultiValue.Logic a) => Exp a -> Exp a -> Exp a-(.|.*) = liftM2 MultiValue.or+(.|.*) :: (NiceValue.Logic a) => Exp a -> Exp a -> Exp a+(.|.*) = liftM2 NiceValue.or infixl 6 `xor`-xor :: (MultiValue.Logic a) => Exp a -> Exp a -> Exp a-xor = liftM2 MultiValue.xor+xor :: (NiceValue.Logic a) => Exp a -> Exp a -> Exp a+xor = liftM2 NiceValue.xor toMaybe :: Exp Bool -> Exp a -> Exp (Maybe a)-toMaybe = lift2 MultiValue.toMaybe+toMaybe = lift2 NiceValue.toMaybe -maybe :: (MultiValue.C b) => Exp b -> (Exp a -> Exp b) -> Exp (Maybe a) -> Exp b+maybe :: (NiceValue.C b) => Exp b -> (Exp a -> Exp b) -> Exp (Maybe a) -> Exp b maybe n j = liftM $ \m -> do- let (MultiValue.Cons b, a) = MultiValue.splitMaybe m+ let (NiceValue.Cons b, a) = NiceValue.splitMaybe m C.ifThenElse b (unliftM1 j a) (unExp n) instance- (MultiValue.PseudoRing a, MultiValue.Real a, MultiValue.IntegerConstant a) =>+ (NiceValue.PseudoRing a, NiceValue.Real a, NiceValue.IntegerConstant a) => Num (Exp a) where fromInteger = fromInteger' (+) = add (-) = sub negate = neg (*) = mul- abs = liftM MultiValue.abs- signum = liftM MultiValue.signum+ abs = liftM NiceValue.abs+ signum = liftM NiceValue.signum instance- (MultiValue.Field a, MultiValue.Real a, MultiValue.RationalConstant a) =>+ (NiceValue.Field a, NiceValue.Real a, NiceValue.RationalConstant a) => Fractional (Exp a) where fromRational = fromRational' (/) = fdiv instance- (MultiValue.Transcendental a, MultiValue.Real a,- MultiValue.RationalConstant a) =>+ (NiceValue.Transcendental a, NiceValue.Real a,+ NiceValue.RationalConstant a) => Floating (Exp a) where- pi = unique MultiValue.pi- sin = liftM MultiValue.sin- cos = liftM MultiValue.cos+ pi = unique NiceValue.pi+ sin = liftM NiceValue.sin+ cos = liftM NiceValue.cos sqrt = sqrt (**) = pow- exp = liftM MultiValue.exp- log = liftM MultiValue.log+ exp = liftM NiceValue.exp+ log = liftM NiceValue.log asin _ = error "LLVM missing intrinsic: asin" acos _ = error "LLVM missing intrinsic: acos"@@ -745,14 +745,14 @@ We do not require a numeric prelude superclass, thus also LLVM only types like vectors are instances. -}-instance (MultiValue.Additive a) => Additive.C (Exp a) where+instance (NiceValue.Additive a) => Additive.C (Exp a) where zero = zero (+) = add (-) = sub negate = neg instance- (MultiValue.PseudoRing a, MultiValue.IntegerConstant a) =>+ (NiceValue.PseudoRing a, NiceValue.IntegerConstant a) => Ring.C (Exp a) where one = one (*) = mul@@ -764,37 +764,37 @@ that LLVM vectors cannot be nested. -} instance- (a ~ MultiValue.Scalar v,- MultiValue.PseudoModule v, MultiValue.IntegerConstant a) =>+ (a ~ NiceValue.Scalar v,+ NiceValue.PseudoModule v, NiceValue.IntegerConstant a) => Module.C (Exp a) (Exp v) where- (*>) = liftM2 MultiValue.scale+ (*>) = liftM2 NiceValue.scale instance- (MultiValue.Field a, MultiValue.RationalConstant a) =>+ (NiceValue.Field a, NiceValue.RationalConstant a) => Field.C (Exp a) where (/) = fdiv fromRational' = fromRational' . Field.fromRational' instance- (MultiValue.Transcendental a, MultiValue.RationalConstant a) =>+ (NiceValue.Transcendental a, NiceValue.RationalConstant a) => Algebraic.C (Exp a) where sqrt = sqrt root n x = pow x (recip $ fromInteger' n) x^/r = pow x (Field.fromRational' r) -tau :: (MultiValue.Transcendental a, MultiValue.RationalConstant a) => Exp a+tau :: (NiceValue.Transcendental a, NiceValue.RationalConstant a) => Exp a tau = mul (fromInteger' 2) Trans.pi instance- (MultiValue.Transcendental a, MultiValue.RationalConstant a) =>+ (NiceValue.Transcendental a, NiceValue.RationalConstant a) => Trans.C (Exp a) where- pi = unique MultiValue.pi- sin = liftM MultiValue.sin- cos = liftM MultiValue.cos+ pi = unique NiceValue.pi+ sin = liftM NiceValue.sin+ cos = liftM NiceValue.cos (**) = pow- exp = liftM MultiValue.exp- log = liftM MultiValue.log+ exp = liftM NiceValue.exp+ log = liftM NiceValue.log asin _ = error "LLVM missing intrinsic: asin" acos _ = error "LLVM missing intrinsic: acos"@@ -802,38 +802,38 @@ instance- (MultiValue.Real a, MultiValue.PseudoRing a, MultiValue.IntegerConstant a) =>+ (NiceValue.Real a, NiceValue.PseudoRing a, NiceValue.IntegerConstant a) => Absolute.C (Exp a) where- abs = liftM MultiValue.abs- signum = liftM MultiValue.signum+ abs = liftM NiceValue.abs+ signum = liftM NiceValue.signum fromIntegral ::- (MultiValue.NativeInteger i ir, MultiValue.NativeFloating a ar) =>+ (NiceValue.NativeInteger i ir, NiceValue.NativeFloating a ar) => Exp i -> Exp a-fromIntegral = liftM MultiValue.fromIntegral+fromIntegral = liftM NiceValue.fromIntegral truncateToInt ::- (MultiValue.NativeInteger i ir, MultiValue.NativeFloating a ar) =>+ (NiceValue.NativeInteger i ir, NiceValue.NativeFloating a ar) => Exp a -> Exp i-truncateToInt = liftM MultiValue.truncateToInt+truncateToInt = liftM NiceValue.truncateToInt floorToInt ::- (MultiValue.NativeInteger i ir, MultiValue.NativeFloating a ar) =>+ (NiceValue.NativeInteger i ir, NiceValue.NativeFloating a ar) => Exp a -> Exp i-floorToInt = liftM MultiValue.floorToInt+floorToInt = liftM NiceValue.floorToInt ceilingToInt ::- (MultiValue.NativeInteger i ir, MultiValue.NativeFloating a ar) =>+ (NiceValue.NativeInteger i ir, NiceValue.NativeFloating a ar) => Exp a -> Exp i-ceilingToInt = liftM MultiValue.ceilingToInt+ceilingToInt = liftM NiceValue.ceilingToInt roundToIntFast ::- (MultiValue.NativeInteger i ir, MultiValue.NativeFloating a ar) =>+ (NiceValue.NativeInteger i ir, NiceValue.NativeFloating a ar) => Exp a -> Exp i-roundToIntFast = liftM MultiValue.roundToIntFast+roundToIntFast = liftM NiceValue.roundToIntFast splitFractionToInt ::- (MultiValue.NativeInteger i ir, MultiValue.NativeFloating a ar) =>+ (NiceValue.NativeInteger i ir, NiceValue.NativeFloating a ar) => Exp a -> (Exp i, Exp a)-splitFractionToInt = unzip . liftM MultiValue.splitFractionToInt+splitFractionToInt = unzip . liftM NiceValue.splitFractionToInt
src/LLVM/DSL/Expression/Maybe.hs view
@@ -8,7 +8,7 @@ import qualified LLVM.DSL.Expression as Expr import LLVM.DSL.Expression (Exp) -import qualified LLVM.Extra.Multi.Value as MultiValue+import qualified LLVM.Extra.Nice.Value as NiceValue import qualified LLVM.Extra.Maybe as Maybe import qualified LLVM.Core as LLVM@@ -22,17 +22,17 @@ {- | counterpart to 'Data.Maybe.fromMaybe' with swapped arguments -}-select :: (MultiValue.Select a) => T (Exp a) -> Exp a -> Exp a+select :: (NiceValue.Select a) => T (Exp a) -> Exp a -> Exp a select (Cons b a) d = Expr.select b a d -instance (Expr.Aggregate exp mv) => Expr.Aggregate (T exp) (Maybe.T mv) where- type MultiValuesOf (T exp) = Maybe.T (Expr.MultiValuesOf exp)- type ExpressionsOf (Maybe.T mv) = T (Expr.ExpressionsOf mv)+instance (Expr.Aggregate exp nv) => Expr.Aggregate (T exp) (Maybe.T nv) where+ type NiceValuesOf (T exp) = Maybe.T (Expr.NiceValuesOf exp)+ type ExpressionsOf (Maybe.T nv) = T (Expr.ExpressionsOf nv) bundle (Cons b a) = Monad.lift2 Maybe.Cons (fmap unbool $ Expr.bundle b) (Expr.bundle a) dissect (Maybe.Cons b a) =- Cons (Expr.dissect (MultiValue.Cons b)) (Expr.dissect a)+ Cons (Expr.dissect (NiceValue.Cons b)) (Expr.dissect a) -unbool :: MultiValue.T Bool -> LLVM.Value Bool-unbool (MultiValue.Cons b) = b+unbool :: NiceValue.T Bool -> LLVM.Value Bool+unbool (NiceValue.Cons b) = b
src/LLVM/DSL/Expression/Vector.hs view
@@ -5,10 +5,10 @@ import qualified LLVM.DSL.Expression as Expr import LLVM.DSL.Expression (Exp) -import qualified LLVM.Extra.Multi.Value.Vector as MultiValueVec-import qualified LLVM.Extra.Multi.Value as MultiValue-import qualified LLVM.Extra.Multi.Vector.Instance as MultiVectorInst-import qualified LLVM.Extra.Multi.Vector as MultiVector+import qualified LLVM.Extra.Nice.Value.Vector as NiceValueVec+import qualified LLVM.Extra.Nice.Value as NiceValue+import qualified LLVM.Extra.Nice.Vector.Instance as NiceVectorInst+import qualified LLVM.Extra.Nice.Vector as NiceVector import qualified LLVM.Extra.Arithmetic as A import qualified LLVM.Core as LLVM @@ -18,24 +18,24 @@ cons ::- (LLVM.Positive n, MultiVector.C a) =>+ (LLVM.Positive n, NiceVector.C a) => LLVM.Vector n a -> Exp (LLVM.Vector n a)-cons = Expr.lift0 . MultiValueVec.cons+cons = Expr.lift0 . NiceValueVec.cons fst ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b) => Exp (LLVM.Vector n (a,b)) -> Exp (LLVM.Vector n a)-fst = Expr.lift1 MultiValueVec.fst+fst = Expr.lift1 NiceValueVec.fst snd ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b) => Exp (LLVM.Vector n (a,b)) -> Exp (LLVM.Vector n b)-snd = Expr.lift1 MultiValueVec.snd+snd = Expr.lift1 NiceValueVec.snd swap ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b) => Exp (LLVM.Vector n (a,b)) -> Exp (LLVM.Vector n (b,a))-swap = Expr.lift1 MultiValueVec.swap+swap = Expr.lift1 NiceValueVec.swap mapFst :: (Exp (LLVM.Vector n a0) -> Exp (LLVM.Vector n a1)) ->@@ -43,7 +43,7 @@ mapFst f = Expr.liftReprM (\(a0,b) -> do- MultiValue.Cons a1 <- Expr.unliftM1 f $ MultiValue.Cons a0+ NiceValue.Cons a1 <- Expr.unliftM1 f $ NiceValue.Cons a0 return (a1,b)) mapSnd ::@@ -52,113 +52,113 @@ mapSnd f = Expr.liftReprM (\(a,b0) -> do- MultiValue.Cons b1 <- Expr.unliftM1 f $ MultiValue.Cons b0+ NiceValue.Cons b1 <- Expr.unliftM1 f $ NiceValue.Cons b0 return (a,b1)) fst3 ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b, MultiVector.C c) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b, NiceVector.C c) => Exp (LLVM.Vector n (a,b,c)) -> Exp (LLVM.Vector n a)-fst3 = Expr.lift1 MultiValueVec.fst3+fst3 = Expr.lift1 NiceValueVec.fst3 snd3 ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b, MultiVector.C c) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b, NiceVector.C c) => Exp (LLVM.Vector n (a,b,c)) -> Exp (LLVM.Vector n b)-snd3 = Expr.lift1 MultiValueVec.snd3+snd3 = Expr.lift1 NiceValueVec.snd3 thd3 ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b, MultiVector.C c) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b, NiceVector.C c) => Exp (LLVM.Vector n (a,b,c)) -> Exp (LLVM.Vector n c)-thd3 = Expr.lift1 MultiValueVec.thd3+thd3 = Expr.lift1 NiceValueVec.thd3 zip ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b) => Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n b) -> Exp (LLVM.Vector n (a,b))-zip = Expr.lift2 MultiValueVec.zip+zip = Expr.lift2 NiceValueVec.zip zip3 ::- (LLVM.Positive n, MultiVector.C a, MultiVector.C b, MultiVector.C c) =>+ (LLVM.Positive n, NiceVector.C a, NiceVector.C b, NiceVector.C c) => Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n b) -> Exp (LLVM.Vector n c) -> Exp (LLVM.Vector n (a,b,c))-zip3 = Expr.lift3 MultiValueVec.zip3+zip3 = Expr.lift3 NiceValueVec.zip3 replicate ::- (LLVM.Positive n, MultiVector.C a) =>+ (LLVM.Positive n, NiceVector.C a) => Exp a -> Exp (LLVM.Vector n a)-replicate = Expr.liftM MultiValueVec.replicate+replicate = Expr.liftM NiceValueVec.replicate iterate ::- (LLVM.Positive n, MultiVector.C a) =>+ (LLVM.Positive n, NiceVector.C a) => (Exp a -> Exp a) -> Exp a -> Exp (LLVM.Vector n a)-iterate f = Expr.liftM (MultiValueVec.iterate (Expr.unliftM1 f))+iterate f = Expr.liftM (NiceValueVec.iterate (Expr.unliftM1 f)) take ::- (LLVM.Positive n, LLVM.Positive m, MultiVector.Select a) =>+ (LLVM.Positive n, LLVM.Positive m, NiceVector.Select a) => Exp (LLVM.Vector n a) -> Exp (LLVM.Vector m a)-take = Expr.liftM MultiValueVec.take+take = Expr.liftM NiceValueVec.take takeRev ::- (LLVM.Positive n, LLVM.Positive m, MultiVector.Select a) =>+ (LLVM.Positive n, LLVM.Positive m, NiceVector.Select a) => Exp (LLVM.Vector n a) -> Exp (LLVM.Vector m a)-takeRev = Expr.liftM MultiValueVec.takeRev+takeRev = Expr.liftM NiceValueVec.takeRev cumulate ::- (LLVM.Positive n, MultiVector.Additive a) =>+ (LLVM.Positive n, NiceVector.Additive a) => Exp a -> Exp (LLVM.Vector n a) -> (Exp a, Exp (LLVM.Vector n a)) cumulate a0 v0 = Expr.unzip $ Expr.liftM2 (\a v ->- fmap (uncurry MultiValue.zip .- Tuple.mapSnd MultiVectorInst.toMultiValue) $- MultiVector.cumulate a $ MultiVectorInst.fromMultiValue v)+ fmap (uncurry NiceValue.zip .+ Tuple.mapSnd NiceVectorInst.toNiceValue) $+ NiceVector.cumulate a $ NiceVectorInst.fromNiceValue v) a0 v0 cmp ::- (LLVM.Positive n, MultiVector.Comparison a) =>+ (LLVM.Positive n, NiceVector.Comparison a) => LLVM.CmpPredicate -> Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n Bool)-cmp ord = Expr.liftM2 (MultiValueVec.cmp ord)+cmp ord = Expr.liftM2 (NiceValueVec.cmp ord) select ::- (LLVM.Positive n, MultiVector.Select a) =>+ (LLVM.Positive n, NiceVector.Select a) => Exp (LLVM.Vector n Bool) -> Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n a)-select = Expr.liftM3 MultiValueVec.select+select = Expr.liftM3 NiceValueVec.select min, max ::- (LLVM.Positive n, MultiVector.Real a) =>+ (LLVM.Positive n, NiceVector.Real a) => Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n a) min = Expr.liftM2 A.min max = Expr.liftM2 A.max limit ::- (LLVM.Positive n, MultiVector.Real a) =>+ (LLVM.Positive n, NiceVector.Real a) => (Exp (LLVM.Vector n a), Exp (LLVM.Vector n a)) -> Exp (LLVM.Vector n a) -> Exp (LLVM.Vector n a) limit (l,u) = max l . min u fromIntegral ::- (MultiValueVec.NativeInteger i ir, MultiValueVec.NativeFloating a ar,+ (NiceValueVec.NativeInteger i ir, NiceValueVec.NativeFloating a ar, LLVM.ShapeOf ir ~ LLVM.ShapeOf ar) => Exp i -> Exp a-fromIntegral = Expr.liftM MultiValueVec.fromIntegral+fromIntegral = Expr.liftM NiceValueVec.fromIntegral truncateToInt ::- (MultiValueVec.NativeInteger i ir, MultiValueVec.NativeFloating a ar,+ (NiceValueVec.NativeInteger i ir, NiceValueVec.NativeFloating a ar, LLVM.ShapeOf ir ~ LLVM.ShapeOf ar) => Exp a -> Exp i-truncateToInt = Expr.liftM MultiValueVec.truncateToInt+truncateToInt = Expr.liftM NiceValueVec.truncateToInt splitFractionToInt ::- (MultiValueVec.NativeInteger i ir, MultiValueVec.NativeFloating a ar,+ (NiceValueVec.NativeInteger i ir, NiceValueVec.NativeFloating a ar, LLVM.ShapeOf ir ~ LLVM.ShapeOf ar) => Exp a -> (Exp i, Exp a)-splitFractionToInt = Expr.unzip . Expr.liftM MultiValueVec.splitFractionToInt+splitFractionToInt = Expr.unzip . Expr.liftM NiceValueVec.splitFractionToInt
src/LLVM/DSL/Parameter.hs view
@@ -8,11 +8,11 @@ ($#), get, valueTuple,- multiValue,+ niceValue, with, withValue,- withMulti,+ withNice, Tunnel(..), tunnel,@@ -26,8 +26,8 @@ wordInt, ) where -import qualified LLVM.Extra.Multi.Value.Marshal as MarshalMV-import qualified LLVM.Extra.Multi.Value as MultiValue+import qualified LLVM.Extra.Nice.Value.Marshal as MarshalNice+import qualified LLVM.Extra.Nice.Value as NiceValue import qualified LLVM.Extra.Tuple as Tuple import qualified LLVM.Extra.Marshal as Marshal @@ -101,10 +101,10 @@ T p tuple -> value -> value valueTuple = genericValue Tuple.valueOf -multiValue ::- (MultiValue.C a) =>- T p a -> MultiValue.T a -> MultiValue.T a-multiValue = genericValue MultiValue.cons+niceValue ::+ (NiceValue.C a) =>+ T p a -> NiceValue.T a -> NiceValue.T a+niceValue = genericValue NiceValue.cons genericValue :: (a -> value) ->@@ -133,27 +133,27 @@ withValue (Constant a) f = f (const ()) (\() -> Tuple.valueOf a) withValue (Variable v) f = f v id -{-# INLINE withMulti #-}-withMulti ::- (MarshalMV.C b) =>+{-# INLINE withNice #-}+withNice ::+ (MarshalNice.C b) => T p b -> (forall parameters.- (MarshalMV.C parameters) =>+ (MarshalNice.C parameters) => (p -> parameters) ->- (MultiValue.T parameters -> MultiValue.T b) ->+ (NiceValue.T parameters -> NiceValue.T b) -> a) -> a-withMulti = with MultiValue.cons+withNice = with NiceValue.cons {-# INLINE with #-} with ::- (MarshalMV.C b) =>- (b -> MultiValue.T b) ->+ (MarshalNice.C b) =>+ (b -> NiceValue.T b) -> T p b -> (forall parameters.- (MarshalMV.C parameters) =>+ (MarshalNice.C parameters) => (p -> parameters) ->- (MultiValue.T parameters -> MultiValue.T b) ->+ (NiceValue.T parameters -> NiceValue.T b) -> a) -> a with cons p f =@@ -164,9 +164,9 @@ data Tunnel p a = forall t.- (MarshalMV.C t) => Tunnel (p -> t) (MultiValue.T t -> MultiValue.T a)+ (MarshalNice.C t) => Tunnel (p -> t) (NiceValue.T t -> NiceValue.T a) -tunnel :: (MarshalMV.C a) => (a -> MultiValue.T a) -> T p a -> Tunnel p a+tunnel :: (MarshalNice.C a) => (a -> NiceValue.T a) -> T p a -> Tunnel p a tunnel cons p = case p of Constant b -> Tunnel (const ()) (\_ -> cons b)
src/LLVM/DSL/Render/Argument.hs view
@@ -14,7 +14,7 @@ import qualified LLVM.DSL.Expression as Expr import LLVM.DSL.Expression (Exp) -import qualified LLVM.Extra.Multi.Value.Marshal as Marshal+import qualified LLVM.Extra.Nice.Value.Marshal as Marshal import Data.Tuple.Strict (mapPair, mapTriple)
src/LLVM/DSL/Render/Run.hs view
@@ -17,7 +17,7 @@ import LLVM.DSL.Render.Argument (Creator) import LLVM.DSL.Expression (Exp) -import qualified LLVM.Extra.Multi.Value.Marshal as Marshal+import qualified LLVM.Extra.Nice.Value.Marshal as Marshal import Prelude2010 import Prelude ()
src/LLVM/DSL/Value.hs view
@@ -6,7 +6,7 @@ {-# LANGUAGE UndecidableInstances #-} {- | Wrap LLVM code for arithmetic computations.-Similar to "LLVM.DSL.Expression" but not based on 'MultiValue'+Similar to "LLVM.DSL.Expression" but not based on 'NiceValue' but on "LLVM.Extra.Arithmetic" methods. Detects sharing using a 'Vault'. -}
test/Test/LLVM/DSL/Example/Median.hs view
@@ -2,15 +2,15 @@ module Test.LLVM.DSL.Example.Median where import qualified LLVM.DSL.Example.Median as Median-import LLVM.DSL.Example.Median (MV)+import LLVM.DSL.Example.Median (NV) import qualified LLVM.DSL.Execution as Exec import qualified LLVM.DSL.Expression as Expr import LLVM.DSL.Expression (Exp) import qualified LLVM.Extra.Storable as Memory-import qualified LLVM.Extra.Multi.Vector as MVec-import qualified LLVM.Extra.Multi.Value as MV+import qualified LLVM.Extra.Nice.Vector as NVec+import qualified LLVM.Extra.Nice.Value as NV import qualified LLVM.Core as LLVM @@ -36,7 +36,7 @@ LLVM.Value Float -> LLVM.Value Float -> LLVM.Value Float -> LLVM.CodeGenFunction Float (LLVM.Value Float) unliftM3ExprFloat f a b c = do- MV.Cons m <- Expr.unliftM3 f (MV.Cons a) (MV.Cons b) (MV.Cons c)+ NV.Cons m <- Expr.unliftM3 f (NV.Cons a) (NV.Cons b) (NV.Cons c) return m unliftM3ExprInt32 ::@@ -44,31 +44,31 @@ LLVM.Value Int32 -> LLVM.Value Int32 -> LLVM.Value Int32 -> LLVM.CodeGenFunction Int32 (LLVM.Value Int32) unliftM3ExprInt32 f a b c = do- MV.Cons m <- Expr.unliftM3 f (MV.Cons a) (MV.Cons b) (MV.Cons c)+ NV.Cons m <- Expr.unliftM3 f (NV.Cons a) (NV.Cons b) (NV.Cons c) return m -unliftM3MVInt32 ::- (MV Int32 -> MV Int32 -> MV Int32 ->- LLVM.CodeGenFunction Int32 (MV Int32)) ->+unliftM3NVInt32 ::+ (NV Int32 -> NV Int32 -> NV Int32 ->+ LLVM.CodeGenFunction Int32 (NV Int32)) -> LLVM.Value Int32 -> LLVM.Value Int32 -> LLVM.Value Int32 -> LLVM.CodeGenFunction Int32 (LLVM.Value Int32)-unliftM3MVInt32 f a b c = do- MV.Cons m <- f (MV.Cons a) (MV.Cons b) (MV.Cons c)+unliftM3NVInt32 f a b c = do+ NV.Cons m <- f (NV.Cons a) (NV.Cons b) (NV.Cons c) return m type ValPtrV4Int32 = LLVM.Value (Ptr (LLVM.Vector D4 Int32)) -unliftM3MVV4Int32 ::- (MVec.T D4 Int32 -> MVec.T D4 Int32 -> MVec.T D4 Int32 ->- LLVM.CodeGenFunction r (MVec.T D4 Int32)) ->+unliftM3NVV4Int32 ::+ (NVec.T D4 Int32 -> NVec.T D4 Int32 -> NVec.T D4 Int32 ->+ LLVM.CodeGenFunction r (NVec.T D4 Int32)) -> ValPtrV4Int32 -> ValPtrV4Int32 -> ValPtrV4Int32 -> ValPtrV4Int32 -> LLVM.CodeGenFunction r ()-unliftM3MVV4Int32 f aPtr bPtr cPtr mPtr = do- a <- MVec.Cons <$> Memory.load aPtr- b <- MVec.Cons <$> Memory.load bPtr- c <- MVec.Cons <$> Memory.load cPtr- MVec.Cons m <- f a b c+unliftM3NVV4Int32 f aPtr bPtr cPtr mPtr = do+ a <- NVec.Cons <$> Memory.load aPtr+ b <- NVec.Cons <$> Memory.load bPtr+ c <- NVec.Cons <$> Memory.load cPtr+ NVec.Cons m <- f a b c Memory.store m mPtr @@ -97,8 +97,8 @@ func "median3Select" (unliftM3ExprInt32 Median.median3Select) : func "median3SelectS" (unliftM3ExprInt32 Median.median3SelectShared) : func "median3MinMax" (unliftM3ExprInt32 Median.median3MinMax) :- func "median3Case" (unliftM3MVInt32 Median.median3Case) :- func "median3CaseVec" (unliftM3MVInt32 Median.median3CaseVec) :+ func "median3Case" (unliftM3NVInt32 Median.median3Case) :+ func "median3CaseVec" (unliftM3NVInt32 Median.median3CaseVec) : [] (medianFloat, medianVector, medianFuncs) <-@@ -107,7 +107,7 @@ (Exec.createFunction derefMedian3FloatPtr "median3MinMaxFloat" (unliftM3ExprFloat Median.median3MinMax)) (Exec.createFunction derefMedian3V4Ptr "median3MinMaxVector"- (unliftM3MVV4Int32 Median.median3MinMaxVector))+ (unliftM3NVV4Int32 Median.median3MinMaxVector)) (Trav.sequenceA funcs) let check expected m = do