-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Utility functions for the llvm interface -- -- The Low-Level Virtual-Machine is a compiler back-end with optimizer. -- You may also call it a high-level portable assembler. This package -- provides various utility functions for the Haskell interface to LLVM, -- for example: -- --
-- newtype Fixed = Fixed Int32 ---- -- and then use the same methods for floating point and fixed point -- arithmetic. -- -- In contrast to the arithmetic methods in the llvm wrapper, in -- our methods the types of operands and result match. Advantage: Type -- inference determines most of the types automatically. Disadvantage: -- You cannot use constant values directly, but you have to convert them -- all to Value. class Zero a => Additive a zero :: Additive a => a add :: Additive a => a -> a -> CodeGenFunction r a sub :: Additive a => a -> a -> CodeGenFunction r a neg :: Additive a => a -> CodeGenFunction r a one :: IntegerConstant a => a inc :: (IsArithmetic a, IsConst a, Num a) => Value a -> CodeGenFunction r (Value a) dec :: (IsArithmetic a, IsConst a, Num a) => Value a -> CodeGenFunction r (Value a) class Additive a => PseudoRing a mul :: PseudoRing a => a -> a -> CodeGenFunction r a square :: PseudoRing a => a -> CodeGenFunction r a class (PseudoRing (Scalar v), Additive v) => PseudoModule v scale :: PseudoModule v => Scalar v -> v -> CodeGenFunction r v class PseudoRing a => Field a fdiv :: Field a => a -> a -> CodeGenFunction r a class IntegerConstant a fromInteger' :: IntegerConstant a => Integer -> a class IntegerConstant a => RationalConstant a fromRational' :: RationalConstant a => Rational -> a -- | In Haskell terms this is a quot. idiv :: IsInteger a => Value a -> Value a -> CodeGenFunction r (Value a) irem :: IsInteger a => Value a -> Value a -> CodeGenFunction r (Value a) class Comparison a => FloatingComparison a fcmp :: FloatingComparison a => FPPredicate -> a -> a -> CodeGenFunction r (CmpResult a) class Comparison a where type family CmpResult a :: * cmp :: Comparison a => CmpPredicate -> a -> a -> CodeGenFunction r (CmpResult a) data CmpPredicate :: * -- | equal CmpEQ :: CmpPredicate -- | not equal CmpNE :: CmpPredicate -- | greater than CmpGT :: CmpPredicate -- | greater or equal CmpGE :: CmpPredicate -- | less than CmpLT :: CmpPredicate -- | less or equal CmpLE :: CmpPredicate class Logic a and :: Logic a => a -> a -> CodeGenFunction r a or :: Logic a => a -> a -> CodeGenFunction r a xor :: Logic a => a -> a -> CodeGenFunction r a inv :: Logic a => a -> CodeGenFunction r a class Additive a => Real a min :: Real a => a -> a -> CodeGenFunction r a max :: Real a => a -> a -> CodeGenFunction r a abs :: Real a => a -> CodeGenFunction r a signum :: Real a => a -> CodeGenFunction r a class Real a => Fraction a truncate :: Fraction a => a -> CodeGenFunction r a fraction :: Fraction a => a -> CodeGenFunction r a signedFraction :: Fraction a => a -> CodeGenFunction r a addToPhase :: Fraction a => a -> a -> CodeGenFunction r a -- | both increment and phase must be non-negative incPhase :: Fraction a => a -> a -> CodeGenFunction r a advanceArrayElementPtr :: Value (Ptr a) -> CodeGenFunction r (Value (Ptr a)) decreaseArrayElementPtr :: Value (Ptr a) -> CodeGenFunction r (Value (Ptr a)) class Field a => Algebraic a sqrt :: Algebraic a => a -> CodeGenFunction r a class Algebraic a => Transcendental a pi :: Transcendental a => CodeGenFunction r a sin, log, exp, cos :: Transcendental a => a -> CodeGenFunction r a pow :: Transcendental a => a -> a -> CodeGenFunction r a instance (IsFloating a, TranscendentalConstant a) => Transcendental (Value a) instance IsFloating a => Algebraic (Value a) instance IsInteger a => Logic (ConstValue a) instance IsInteger a => Logic (Value a) instance (IsFloating a, CmpRet a) => FloatingComparison (ConstValue a) instance (IsFloating a, CmpRet a) => FloatingComparison (Value a) instance CmpRet a => Comparison (ConstValue a) instance CmpRet a => Comparison (Value a) instance Fraction a => Fraction (Value a) instance Real a => Real (Value a) instance RationalConstant a => RationalConstant (Value a) instance RationalConstant a => RationalConstant (ConstValue a) instance IsFloating v => Field (ConstValue v) instance IsFloating v => Field (Value v) instance IntegerConstant a => IntegerConstant (Value a) instance IntegerConstant a => IntegerConstant (ConstValue a) instance PseudoModule v => PseudoModule (ConstValue v) instance PseudoModule v => PseudoModule (Value v) instance IsArithmetic v => PseudoRing (ConstValue v) instance IsArithmetic v => PseudoRing (Value v) instance (Additive a, Additive b, Additive c) => Additive (a, b, c) instance (Additive a, Additive b) => Additive (a, b) instance IsArithmetic a => Additive (ConstValue a) instance IsArithmetic a => Additive (Value a) module LLVM.Extra.Multi.Value newtype T a Cons :: (Repr Value a) -> T a class C a where type family Repr (f :: * -> *) a :: * cons :: C a => a -> T a undef :: C a => T a zero :: C a => T a phis :: C a => BasicBlock -> T a -> CodeGenFunction r (T a) addPhis :: C a => BasicBlock -> T a -> T a -> CodeGenFunction r () consPrimitive :: (IsConst al, Value al ~ Repr Value a) => al -> T a undefPrimitive :: (IsType al, Value al ~ Repr Value a) => T a zeroPrimitive :: (IsType al, Value al ~ Repr Value a) => T a phisPrimitive :: (IsFirstClass al, Value al ~ Repr Value a) => BasicBlock -> T a -> CodeGenFunction r (T a) addPhisPrimitive :: (IsFirstClass al, Value al ~ Repr Value a) => BasicBlock -> T a -> T a -> CodeGenFunction r () consUnit :: Repr Value a ~ () => a -> T a undefUnit :: Repr Value a ~ () => T a zeroUnit :: Repr Value a ~ () => T a phisUnit :: Repr Value a ~ () => BasicBlock -> T a -> CodeGenFunction r (T a) addPhisUnit :: Repr Value a ~ () => BasicBlock -> T a -> T a -> CodeGenFunction r () fst :: T (a, b) -> T a snd :: T (a, b) -> T b curry :: (T (a, b) -> c) -> (T a -> T b -> c) uncurry :: (T a -> T b -> c) -> (T (a, b) -> c) mapFst :: (T a0 -> T a1) -> T (a0, b) -> T (a1, b) mapSnd :: (T b0 -> T b1) -> T (a, b0) -> T (a, b1) swap :: T (a, b) -> T (b, a) fst3 :: T (a, b, c) -> T a snd3 :: T (a, b, c) -> T b thd3 :: T (a, b, c) -> T c mapFst3 :: (T a0 -> T a1) -> T (a0, b, c) -> T (a1, b, c) mapSnd3 :: (T b0 -> T b1) -> T (a, b0, c) -> T (a, b1, c) mapThd3 :: (T c0 -> T c1) -> T (a, b, c0) -> T (a, b, c1) zip :: T a -> T b -> T (a, b) zip3 :: T a -> T b -> T c -> T (a, b, c) zip4 :: T a -> T b -> T c -> T d -> T (a, b, c, d) unzip :: T (a, b) -> (T a, T b) unzip3 :: T (a, b, c) -> (T a, T b, T c) unzip4 :: T (a, b, c, d) -> (T a, T b, T c, T d) consComplex :: T a -> T a -> T (Complex a) deconsComplex :: T (Complex a) -> (T a, T a) class Compose multituple where type family Composed multituple compose :: Compose multituple => multituple -> T (Composed multituple) class Composed (Decomposed T pattern) ~ PatternTuple pattern => Decompose pattern decompose :: Decompose pattern => pattern -> T (PatternTuple pattern) -> Decomposed T pattern -- | A combination of compose and decompose that let you -- operate on tuple multivalues as Haskell tuples. modify :: (Compose a, Decompose pattern) => pattern -> (Decomposed T pattern -> a) -> T (PatternTuple pattern) -> T (Composed a) modify2 :: (Compose a, Decompose patternA, Decompose patternB) => patternA -> patternB -> (Decomposed T patternA -> Decomposed T patternB -> a) -> T (PatternTuple patternA) -> T (PatternTuple patternB) -> T (Composed a) modifyF :: (Compose a, Decompose pattern, Functor f) => pattern -> (Decomposed T pattern -> f a) -> T (PatternTuple pattern) -> f (T (Composed a)) modifyF2 :: (Compose a, Decompose patternA, Decompose patternB, Functor f) => patternA -> patternB -> (Decomposed T patternA -> Decomposed T patternB -> f a) -> T (PatternTuple patternA) -> T (PatternTuple patternB) -> f (T (Composed a)) data Atom a Atom :: Atom a atom :: Atom a realPart :: T (Complex a) -> T a imagPart :: T (Complex a) -> T a lift1 :: (Repr Value a -> Repr Value b) -> T a -> T b liftM0 :: Monad m => m (Repr Value a) -> m (T a) liftM :: Monad m => (Repr Value a -> m (Repr Value b)) -> T a -> m (T b) liftM2 :: Monad m => (Repr Value a -> Repr Value b -> m (Repr Value c)) -> T a -> T b -> m (T c) liftM3 :: Monad m => (Repr Value a -> Repr Value b -> Repr Value c -> m (Repr Value d)) -> T a -> T b -> T c -> m (T d) class C a => IntegerConstant a fromInteger' :: IntegerConstant a => Integer -> T a class IntegerConstant a => RationalConstant a fromRational' :: RationalConstant a => Rational -> T a class C a => Additive a add :: Additive a => T a -> T a -> CodeGenFunction r (T a) sub :: Additive a => T a -> T a -> CodeGenFunction r (T a) neg :: Additive a => T a -> CodeGenFunction r (T a) class Additive a => PseudoRing a mul :: PseudoRing a => T a -> T a -> CodeGenFunction r (T a) class PseudoRing a => Field a fdiv :: Field a => T a -> T a -> CodeGenFunction r (T a) class (PseudoRing (Scalar v), Additive v) => PseudoModule v scale :: PseudoModule v => T (Scalar v) -> T v -> CodeGenFunction r (T v) class Additive a => Real a min :: Real a => T a -> T a -> CodeGenFunction r (T a) max :: Real a => T a -> T a -> CodeGenFunction r (T a) abs :: Real a => T a -> CodeGenFunction r (T a) signum :: Real a => T a -> CodeGenFunction r (T a) class Real a => Fraction a truncate :: Fraction a => T a -> CodeGenFunction r (T a) fraction :: Fraction a => T a -> CodeGenFunction r (T a) class (Repr Value i ~ Value ir, IsInteger ir, IntegerConstant ir, CmpRet ir, NumberOfElements ir ~ D1, CmpResult ir ~ Bool) => NativeInteger i ir class (Repr Value a ~ Value ar, IsFloating ar, RationalConstant ar, CmpRet ar, NumberOfElements ar ~ D1, CmpResult ar ~ Bool) => NativeFloating a ar truncateToInt :: (NativeInteger i ir, NativeFloating a ar) => T a -> CodeGenFunction r (T i) roundToIntFast :: (NativeInteger i ir, NativeFloating a ar) => T a -> CodeGenFunction r (T i) ceilingToInt :: (NativeInteger i ir, NativeFloating a ar) => T a -> CodeGenFunction r (T i) floorToInt :: (NativeInteger i ir, NativeFloating a ar) => T a -> CodeGenFunction r (T i) splitFractionToInt :: (NativeInteger i ir, NativeFloating a ar) => T a -> CodeGenFunction r (T (i, a)) class Field a => Algebraic a sqrt :: Algebraic a => T a -> CodeGenFunction r (T a) class Algebraic a => Transcendental a pi :: Transcendental a => CodeGenFunction r (T a) sin, log, exp, cos :: Transcendental a => T a -> CodeGenFunction r (T a) pow :: Transcendental a => T a -> T a -> CodeGenFunction r (T a) class C a => Select a select :: Select a => T Bool -> T a -> T a -> CodeGenFunction r (T a) class Real a => Comparison a cmp :: Comparison a => CmpPredicate -> T a -> T a -> CodeGenFunction r (T Bool) class Comparison a => FloatingComparison a fcmp :: FloatingComparison a => FPPredicate -> T a -> T a -> CodeGenFunction r (T Bool) class Logic a and :: Logic a => T a -> T a -> CodeGenFunction r (T a) or :: Logic a => T a -> T a -> CodeGenFunction r (T a) xor :: Logic a => T a -> T a -> CodeGenFunction r (T a) inv :: Logic a => T a -> CodeGenFunction r (T a) class PseudoRing a => Integral a idiv :: Integral a => T a -> T a -> CodeGenFunction r (T a) irem :: Integral a => T a -> T a -> CodeGenFunction r (T a) fromIntegral :: (NativeInteger i ir, NativeFloating a ar) => T i -> CodeGenFunction r (T a) instance Integral Int64 instance Integral Int32 instance Integral Word64 instance Integral Word32 instance Logic a => Logic (T a) instance Logic Bool instance FloatingComparison a => FloatingComparison (T a) instance FloatingComparison Float instance Comparison a => Comparison (T a) instance Comparison Word64 instance Comparison Word32 instance Comparison Word16 instance Comparison Word8 instance Comparison Int64 instance Comparison Int32 instance Comparison Int16 instance Comparison Int8 instance Comparison Double instance Comparison Float instance Select a => Select (T a) instance (Select a, Select b, Select c) => Select (a, b, c) instance (Select a, Select b) => Select (a, b) instance Select Int64 instance Select Int32 instance Select Int16 instance Select Int8 instance Select Word64 instance Select Word32 instance Select Word16 instance Select Word8 instance Select Double instance Select Float instance Transcendental a => Transcendental (T a) instance Transcendental Double instance Transcendental Float instance Algebraic a => Algebraic (T a) instance Algebraic Double instance Algebraic Float instance NativeFloating Double Double instance NativeFloating Float Float instance NativeInteger Int64 Int64 instance NativeInteger Int32 Int32 instance NativeInteger Int16 Int16 instance NativeInteger Int8 Int8 instance NativeInteger Word64 Word64 instance NativeInteger Word32 Word32 instance NativeInteger Word16 Word16 instance NativeInteger Word8 Word8 instance Fraction a => Fraction (T a) instance Fraction Double instance Fraction Float instance Real a => Real (T a) instance Real Int64 instance Real Int32 instance Real Int16 instance Real Int8 instance Real Word64 instance Real Word32 instance Real Word16 instance Real Word8 instance Real Double instance Real Float instance PseudoModule a => PseudoModule (T a) instance PseudoModule Double instance PseudoModule Float instance Field a => Field (T a) instance Field Double instance Field Float instance PseudoRing a => PseudoRing (T a) instance PseudoRing Int64 instance PseudoRing Int32 instance PseudoRing Int16 instance PseudoRing Int8 instance PseudoRing Word64 instance PseudoRing Word32 instance PseudoRing Word16 instance PseudoRing Word8 instance PseudoRing Double instance PseudoRing Float instance Additive a => Additive (T a) instance Additive Int64 instance Additive Int32 instance Additive Int16 instance Additive Int8 instance Additive Word64 instance Additive Word32 instance Additive Word16 instance Additive Word8 instance Additive Double instance Additive Float instance RationalConstant a => RationalConstant (T a) instance IntegerConstant a => IntegerConstant (T a) instance RationalConstant Double instance RationalConstant Float instance IntegerConstant Int64 instance IntegerConstant Int32 instance IntegerConstant Int16 instance IntegerConstant Int8 instance IntegerConstant Word64 instance IntegerConstant Word32 instance IntegerConstant Word16 instance IntegerConstant Word8 instance IntegerConstant Double instance IntegerConstant Float instance C a => Phi (T a) instance C a => Undefined (T a) instance C a => Zero (T a) instance Decompose pa => Decompose (Complex pa) instance Compose a => Compose (Complex a) instance (Decompose pa, Decompose pb, Decompose pc, Decompose pd) => Decompose (pa, pb, pc, pd) instance (Compose a, Compose b, Compose c, Compose d) => Compose (a, b, c, d) instance (Decompose pa, Decompose pb, Decompose pc) => Decompose (pa, pb, pc) instance (Compose a, Compose b, Compose c) => Compose (a, b, c) instance (Decompose pa, Decompose pb) => Decompose (pa, pb) instance (Compose a, Compose b) => Compose (a, b) instance Decompose () instance Compose () instance Decompose (Atom a) instance Compose (T a) instance C a => C (Complex a) instance (C a, C b, C c, C d) => C (a, b, c, d) instance (C a, C b, C c) => C (a, b, c) instance (C a, C b) => C (a, b) instance C () instance C (StablePtr a) instance IsFunction a => C (FunPtr a) instance IsType a => C (Ptr a) instance C Int64 instance C Int32 instance C Int16 instance C Int8 instance C Word64 instance C Word32 instance C Word16 instance C Word8 instance C Double instance C Float instance C Bool module LLVM.Extra.Multi.Vector newtype T n a Cons :: (Repr (Value n) a) -> T n a consPrim :: Repr (Value n) a ~ Value n a => Value (Vector n a) -> T n a deconsPrim :: Repr (Value n) a ~ Value n a => T n a -> Value (Vector n a) class C a => C a undef :: (C a, Positive n) => T n a zero :: (C a, Positive n) => T n a phis :: (C a, Positive n) => BasicBlock -> T n a -> CodeGenFunction r (T n a) addPhis :: (C a, Positive n) => BasicBlock -> T n a -> T n a -> CodeGenFunction r () shuffleMatch :: (C a, Positive n) => ConstValue (Vector n Word32) -> T n a -> CodeGenFunction r (T n a) extract :: (C a, Positive n) => Value Word32 -> T n a -> CodeGenFunction r (T a) insert :: (C a, Positive n) => Value Word32 -> T a -> T n a -> CodeGenFunction r (T n a) newtype Value n a Value :: (PrimValue n a) -> Value n a map :: (Positive n, C a, C b) => (T a -> CodeGenFunction r (T b)) -> (T n a -> CodeGenFunction r (T n b)) zip :: T n a -> T n b -> T n (a, b) zip3 :: T n a -> T n b -> T n c -> T n (a, b, c) unzip :: T n (a, b) -> (T n a, T n b) unzip3 :: T n (a, b, c) -> (T n a, T n b, T n c) replicate :: (Positive n, C a) => T a -> CodeGenFunction r (T n a) iterate :: (Positive n, C a) => (T a -> CodeGenFunction r (T a)) -> T a -> CodeGenFunction r (T n a) lift1 :: (Repr (Value n) a -> Repr (Value n) b) -> T n a -> T n b modify :: (Positive n, C a) => Value Word32 -> (T a -> CodeGenFunction r (T a)) -> (T n a -> CodeGenFunction r (T n a)) assemble :: (Positive n, C a) => [T a] -> CodeGenFunction r (T n a) dissect :: (Positive n, C a) => T n a -> CodeGenFunction r [T a] dissectList :: (Positive n, C a) => T n a -> [CodeGenFunction r (T a)] reverse :: (Positive n, C a) => T n a -> CodeGenFunction r (T n a) -- | Rotate one element towards the higher elements. -- -- I don't want to call it rotateLeft or rotateRight, because there is no -- prefered layout for the vector elements. In Intel's instruction manual -- vector elements are indexed like the bits, that is from right to left. -- However, when working with Haskell list and enumeration syntax, the -- start index is left. rotateUp :: (Positive n, C a) => T n a -> CodeGenFunction r (T n a) rotateDown :: (Positive n, C a) => T n a -> CodeGenFunction r (T n a) shiftUp :: (Positive n, C a) => T a -> T n a -> CodeGenFunction r (T a, T n a) shiftDown :: (Positive n, C a) => T a -> T n a -> CodeGenFunction r (T a, T n a) shiftUpMultiZero :: (Positive n, C a, ValueTuple a ~ al, Zero al) => Int -> T n a -> CodeGenFunction r (T n a) shiftDownMultiZero :: (Positive n, C a, ValueTuple a ~ al, Zero al) => Int -> T n a -> CodeGenFunction r (T n a) undefPrimitive :: (Positive n, IsPrimitive a, Repr (Value n) a ~ Value n a) => T n a shuffleMatchPrimitive :: (Positive n, IsPrimitive a, Repr Value a ~ Value a, Repr (Value n) a ~ Value n a) => ConstValue (Vector n Word32) -> T n a -> CodeGenFunction r (T n a) extractPrimitive :: (Positive n, IsPrimitive a, Repr Value a ~ Value a, Repr (Value n) a ~ Value n a) => Value Word32 -> T n a -> CodeGenFunction r (T a) insertPrimitive :: (Positive n, IsPrimitive a, Repr Value a ~ Value a, Repr (Value n) a ~ Value n a) => Value Word32 -> T a -> T n a -> CodeGenFunction r (T n a) shuffleMatchTraversable :: (Positive n, C a, Traversable f) => ConstValue (Vector n Word32) -> f (T n a) -> CodeGenFunction r (f (T n a)) insertTraversable :: (Positive n, C a, Traversable f, Applicative f) => Value Word32 -> f (T a) -> f (T n a) -> CodeGenFunction r (f (T n a)) extractTraversable :: (Positive n, C a, Traversable f) => Value Word32 -> f (T n a) -> CodeGenFunction r (f (T a)) class (Additive a, C a) => Additive a add :: (Additive a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) sub :: (Additive a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) neg :: (Additive a, Positive n) => T n a -> CodeGenFunction r (T n a) class (PseudoRing a, Additive a) => PseudoRing a mul :: (PseudoRing a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) class (Field a, PseudoRing a) => Field a fdiv :: (Field a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) class (PseudoModule v, PseudoRing (Scalar v), Additive v) => PseudoModule v scale :: (PseudoModule v, Positive n) => T n (Scalar v) -> T n v -> CodeGenFunction r (T n v) class (Real a, Additive a) => Real a min :: (Real a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) max :: (Real a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) abs :: (Real a, Positive n) => T n a -> CodeGenFunction r (T n a) signum :: (Real a, Positive n) => T n a -> CodeGenFunction r (T n a) class (Fraction a, Real a) => Fraction a truncate :: (Fraction a, Positive n) => T n a -> CodeGenFunction r (T n a) fraction :: (Fraction a, Positive n) => T n a -> CodeGenFunction r (T n a) class (Algebraic a, Field a) => Algebraic a sqrt :: (Algebraic a, Positive n) => T n a -> CodeGenFunction r (T n a) class (Transcendental a, Algebraic a) => Transcendental a pi :: (Transcendental a, Positive n) => CodeGenFunction r (T n a) sin, log, exp, cos :: (Transcendental a, Positive n) => T n a -> CodeGenFunction r (T n a) pow :: (Transcendental a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) class (FloatingComparison a, Comparison a) => FloatingComparison a fcmp :: (FloatingComparison a, Positive n) => FPPredicate -> T n a -> T n a -> CodeGenFunction r (T n Bool) class (Comparison a, C a) => Comparison a cmp :: (Comparison a, Positive n) => CmpPredicate -> T n a -> T n a -> CodeGenFunction r (T n Bool) class (Logic a, C a) => Logic a and :: (Logic a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) or :: (Logic a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) xor :: (Logic a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) inv :: (Logic a, Positive n) => T n a -> CodeGenFunction r (T n a) instance (Positive n, Logic a) => Logic (T n a) instance Logic Bool instance (Positive n, FloatingComparison a) => FloatingComparison (T n a) instance FloatingComparison Float instance (Positive n, Comparison a) => Comparison (T n a) instance Comparison Double instance Comparison Float instance (Positive n, Transcendental a) => Transcendental (T n a) instance Transcendental Double instance Transcendental Float instance (Positive n, Algebraic a) => Algebraic (T n a) instance Algebraic Double instance Algebraic Float instance (Positive n, Fraction a) => Fraction (T n a) instance Fraction Double instance Fraction Float instance (Positive n, Real a) => Real (T n a) instance Real Double instance Real Float instance (Positive n, PseudoModule a) => PseudoModule (T n a) instance PseudoModule Double instance PseudoModule Float instance (Positive n, Field a) => Field (T n a) instance Field Double instance Field Float instance (Positive n, PseudoRing a) => PseudoRing (T n a) instance PseudoRing Double instance PseudoRing Float instance (Positive n, Additive a) => Additive (T n a) instance Additive Double instance Additive Float instance (Positive n, RationalConstant a) => RationalConstant (T n a) instance (Positive n, IntegerConstant a) => IntegerConstant (T n a) instance RationalConstant Double instance RationalConstant Float instance IntegerConstant Double instance IntegerConstant Float instance (C a, C b, C c) => C (a, b, c) instance (C a, C b) => C (a, b) instance C Double instance C Float instance C Bool instance (Positive n, C a) => Phi (T n a) instance (Positive n, C a) => Zero (T n a) instance (Positive n, C a) => Undefined (T n a) module LLVM.Extra.Multi.Vector.Memory class (Positive n, C a, IsSized (Struct n a)) => C n a where type family Struct n a :: * load ptr = decompose =<< load ptr store r ptr = flip store ptr =<< compose r decompose = decomposeFromLoad load compose = composeFromStore store load :: C n a => Value (Ptr (Struct n a)) -> CodeGenFunction r (T n a) store :: C n a => T n a -> Value (Ptr (Struct n a)) -> CodeGenFunction r () decompose :: C n a => Value (Struct n a) -> CodeGenFunction r (T n a) compose :: C n a => T n a -> CodeGenFunction r (Value (Struct n a)) instance (C n a, C n b) => C n (a, b) instance (Positive n, Positive (n :*: D64)) => C n Double instance (Positive n, Positive (n :*: D32)) => C n Float module LLVM.Extra.Multi.Value.Memory class (C a, IsSized (Struct a)) => C a where type family Struct a :: * load ptr = decompose =<< load ptr store r ptr = flip store ptr =<< compose r decompose = decomposeFromLoad load compose = composeFromStore store load :: C a => Value (Ptr (Struct a)) -> CodeGenFunction r (T a) store :: C a => T a -> Value (Ptr (Struct a)) -> CodeGenFunction r () decompose :: C a => Value (Struct a) -> CodeGenFunction r (T a) compose :: C a => T a -> CodeGenFunction r (Value (Struct a)) loadPrimitive :: Repr Value a ~ Value a => Value (Ptr a) -> CodeGenFunction r (T a) storePrimitive :: Repr Value a ~ Value a => T a -> Value (Ptr a) -> CodeGenFunction r () decomposePrimitive :: Repr Value a ~ Value a => Value a -> CodeGenFunction r (T a) composePrimitive :: Repr Value a ~ Value a => T a -> CodeGenFunction r (Value a) loadUnit :: Repr Value a ~ () => Value (Ptr (Struct ())) -> CodeGenFunction r (T a) storeUnit :: T a -> Value (Ptr (Struct ())) -> CodeGenFunction r () decomposeUnit :: Repr Value a ~ () => Value (Struct ()) -> CodeGenFunction r (T a) composeUnit :: T a -> CodeGenFunction r (Value (Struct ())) castStructPtr :: Ptr a -> Ptr (Struct a) instance (C a, C b, C c, C d) => C (a, b, c, d) instance (C a, C b, C c) => C (a, b, c) instance (C a, C b) => C (a, b) instance C a => C (Complex a) instance C () instance C (StablePtr a) instance IsFunction a => C (FunPtr a) instance IsType a => C (Ptr a) instance C Int64 instance C Int32 instance C Int16 instance C Int8 instance C Word64 instance C Word32 instance C Word16 instance C Word8 instance C Double instance C Float module LLVM.Extra.Scalar -- | The entire purpose of this datatype is to mark a type as scalar, -- although it might also be interpreted as vector. This way you can -- write generic operations for vectors using the PseudoModule -- class, and specialise them to scalar types with respect to the -- PseudoRing class. From another perspective you can consider the -- T type constructor a marker where the Scalar type -- function stops reducing nested vector types to scalar types. newtype T a Cons :: a -> T a decons :: T a -> a liftM :: Monad m => (a -> m b) -> T a -> m (T b) liftM2 :: Monad m => (a -> b -> m c) -> T a -> T b -> m (T c) unliftM :: Monad m => (T a -> m (T r)) -> a -> m r unliftM2 :: Monad m => (T a -> T b -> m (T r)) -> a -> b -> m r unliftM3 :: Monad m => (T a -> T b -> T c -> m (T r)) -> a -> b -> c -> m r unliftM4 :: Monad m => (T a -> T b -> T c -> T d -> m (T r)) -> a -> b -> c -> d -> m r unliftM5 :: Monad m => (T a -> T b -> T c -> T d -> T e -> m (T r)) -> a -> b -> c -> d -> e -> m r instance Transcendental a => Transcendental (T a) instance Algebraic a => Algebraic (T a) instance Fraction a => Fraction (T a) instance Real a => Real (T a) instance PseudoRing a => PseudoModule (T a) instance Field a => Field (T a) instance PseudoRing a => PseudoRing (T a) instance Additive a => Additive (T a) instance RationalConstant a => RationalConstant (T a) instance IntegerConstant a => IntegerConstant (T a) instance Phi a => Phi (T a) instance Undefined a => Undefined (T a) instance Zero a => Zero (T a) module LLVM.Extra.Memory -- | An implementation of both MakeValueTuple and C must -- ensure that haskellValue is compatible with Stored -- (Struct haskellValue) (which we want to call -- llvmStruct). That is, writing and reading llvmStruct -- by LLVM must be the same as accessing haskellValue by -- Storable methods. ToDo: In future we may also require -- Storable constraint for llvmStruct. -- -- We use a functional dependency in order to let type inference work -- nicely. class (Phi llvmValue, Undefined llvmValue, IsType (Struct llvmValue), IsSized (Struct llvmValue)) => C llvmValue where type family Struct llvmValue :: * load ptr = decompose =<< load ptr store r ptr = flip store ptr =<< compose r decompose = decomposeFromLoad load compose = composeFromStore store load :: C llvmValue => Value (Ptr (Struct llvmValue)) -> CodeGenFunction r llvmValue store :: C llvmValue => llvmValue -> Value (Ptr (Struct llvmValue)) -> CodeGenFunction r () decompose :: C llvmValue => Value (Struct llvmValue) -> CodeGenFunction r llvmValue compose :: C llvmValue => llvmValue -> CodeGenFunction r (Value (Struct llvmValue)) modify :: C llvmValue => (llvmValue -> CodeGenFunction r llvmValue) -> Value (Ptr (Struct llvmValue)) -> CodeGenFunction r () castStorablePtr :: (MakeValueTuple haskellValue, C (ValueTuple haskellValue)) => Ptr haskellValue -> Ptr (Struct (ValueTuple haskellValue)) type Record r o v = Element r o v v data Element r o v x element :: (C x, GetValue o n, ValueType o n ~ Struct x, GetElementPtr o (n, ()), ElementPtrType o (n, ()) ~ Struct x) => (v -> x) -> n -> Element r o v x loadRecord :: Record r o llvmValue -> Value (Ptr o) -> CodeGenFunction r llvmValue storeRecord :: Record r o llvmValue -> llvmValue -> Value (Ptr o) -> CodeGenFunction r () decomposeRecord :: Record r o llvmValue -> Value o -> CodeGenFunction r llvmValue composeRecord :: IsType o => Record r o llvmValue -> llvmValue -> CodeGenFunction r (Value o) loadNewtype :: C a => (a -> llvmValue) -> Value (Ptr (Struct a)) -> CodeGenFunction r llvmValue storeNewtype :: C a => (llvmValue -> a) -> llvmValue -> Value (Ptr (Struct a)) -> CodeGenFunction r () decomposeNewtype :: C a => (a -> llvmValue) -> Value (Struct a) -> CodeGenFunction r llvmValue composeNewtype :: C a => (llvmValue -> a) -> llvmValue -> CodeGenFunction r (Value (Struct a)) class (IsFirstClass llvmType, IsType (Stored llvmType)) => FirstClass llvmType where type family Stored llvmType :: * instance C n a => C (T n a) instance C a => C (T a) instance (FirstClass a, IsSized (Stored a)) => C (Value a) instance (sm ~ StoredStruct s, IsType (Struct s), IsType (Struct sm)) => ConvertStruct s i () instance (sm ~ StoredStruct s, FirstClass a, am ~ Stored a, GetValue (Struct s) (Proxy i), GetValue (Struct sm) (Proxy i), ValueType (Struct s) (Proxy i) ~ a, ValueType (Struct sm) (Proxy i) ~ am, ConvertStruct s (Succ i) rem) => ConvertStruct s i (a, rem) instance (IsFirstClass (Struct s), IsType (Struct (StoredStruct s)), ConvertStruct s D0 s) => FirstClass (Struct s) instance FirstClass (StablePtr a) instance IsFunction a => FirstClass (FunPtr a) instance IsType a => FirstClass (Ptr a) instance (Natural n, IsFirstClass (Stored a), FirstClass a, IsSized a, IsSized (Stored a)) => FirstClass (Array n a) instance (Positive n, IsPrimitive a, IsPrimitive (Stored a), FirstClass a) => FirstClass (Vector n a) instance FirstClass Bool instance FirstClass Word64 instance FirstClass Word32 instance FirstClass Word16 instance FirstClass Word8 instance FirstClass Int64 instance FirstClass Int32 instance FirstClass Int16 instance FirstClass Int8 instance FirstClass Double instance FirstClass Float instance C a => C (T a) instance (C a, C b) => C (T a b) instance C a => C (T a) instance (C a, C b, C c) => C (a, b, c) instance (C a, C b) => C (a, b) instance Applicative (Element r o v) instance Functor (Element r o v) instance C () -- | Maybe transformer datatype implemented in continuation passing style. module LLVM.Extra.MaybeContinuation -- | Isomorphic to ReaderT (CodeGenFunction r z) (ContT z -- (CodeGenFunction r)) a, where the reader provides the block for -- Nothing and the continuation part manages the Just. newtype T r z a Cons :: (CodeGenFunction r z -> (a -> CodeGenFunction r z) -> CodeGenFunction r z) -> T r z a resolve :: T r z a -> CodeGenFunction r z -> (a -> CodeGenFunction r z) -> CodeGenFunction r z map :: (a -> CodeGenFunction r b) -> T r z a -> T r z b -- | counterpart to Data.Maybe.HT.toMaybe withBool :: Phi z => Value Bool -> CodeGenFunction r a -> T r z a fromBool :: Phi z => CodeGenFunction r (Value Bool, a) -> T r z a toBool :: Undefined a => T r (Value Bool, a) a -> CodeGenFunction r (Value Bool, a) fromMaybe :: Phi z => CodeGenFunction r (T a) -> T r z a toMaybe :: Undefined a => T r (T a) a -> CodeGenFunction r (T a) isJust :: T r (Value Bool) a -> CodeGenFunction r (Value Bool) lift :: CodeGenFunction r a -> T r z a guard :: Phi z => Value Bool -> T r z () bind :: T r z a -> (a -> T r z b) -> T r z b -- | Run an exception handler if the Maybe-action fails. The exception is -- propagated. That is, the handler is intended for a cleanup procedure. onFail :: CodeGenFunction r () -> T r z a -> T r z a -- | Run the first action and if that fails run the second action. If both -- actions fail, then the composed action fails, too. alternative :: (Phi z, Undefined a) => T r (T a) a -> T r (T a) a -> T r z a fixedLengthLoop :: (Phi s, Undefined s, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i, CmpResult i ~ Bool) => Value i -> s -> (s -> T r (T s) s) -> CodeGenFunction r (Value i, T s) -- | If the returned position is smaller than the array size, then returned -- final state is nothing. arrayLoop :: (Phi s, Undefined s, IsType a, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i, CmpResult i ~ Bool) => Value i -> Value (Ptr a) -> s -> (Value (Ptr a) -> s -> T r (T (Value (Ptr a), s)) s) -> CodeGenFunction r (Value i, T s) arrayLoop2 :: (Phi s, Undefined s, IsType a, IsType b, Num i, IsConst i, IsInteger i, IsFirstClass i, CmpRet i, CmpResult i ~ Bool) => Value i -> Value (Ptr a) -> Value (Ptr b) -> s -> (Value (Ptr a) -> Value (Ptr b) -> s -> T r (T (Value (Ptr a), (Value (Ptr b), s))) s) -> CodeGenFunction r (Value i, T s) instance MonadIO (T r z) instance Monad (T r z) instance Applicative (T r z) instance Functor (T r z) module LLVM.Extra.Multi.Class class C value where type family Size value :: * switch :: C value => f T -> f (T (Size value)) -> f value newtype Const a value Const :: value a -> Const a value getConst :: Const a value -> value a undef :: (C value, Size value ~ n, Positive n, C a) => value a zero :: (C value, Size value ~ n, Positive n, C a) => value a newtype Op0 r a value Op0 :: CodeGenFunction r (value a) -> Op0 r a value runOp0 :: Op0 r a value -> CodeGenFunction r (value a) newtype Op1 r a b value Op1 :: (value a -> CodeGenFunction r (value b)) -> Op1 r a b value runOp1 :: Op1 r a b value -> value a -> CodeGenFunction r (value b) newtype Op2 r a b c value Op2 :: (value a -> value b -> CodeGenFunction r (value c)) -> Op2 r a b c value runOp2 :: Op2 r a b c value -> value a -> value b -> CodeGenFunction r (value c) add :: (Positive n, Additive a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) sub :: (Positive n, Additive a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) neg :: (Positive n, Additive a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) mul :: (Positive n, PseudoRing a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) fdiv :: (Positive n, Field a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) scale :: (Positive n, PseudoModule v, n ~ Size value, C value) => value (Scalar v) -> value v -> CodeGenFunction r (value v) min :: (Positive n, Real a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) max :: (Positive n, Real a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) abs :: (Positive n, Real a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) signum :: (Positive n, Real a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) truncate :: (Positive n, Fraction a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) fraction :: (Positive n, Fraction a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) sqrt :: (Positive n, Algebraic a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) pi :: (Positive n, Transcendental a, n ~ Size value, C value) => CodeGenFunction r (value a) sin :: (Positive n, Transcendental a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) log :: (Positive n, Transcendental a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) exp :: (Positive n, Transcendental a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) cos :: (Positive n, Transcendental a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) pow :: (Positive n, Transcendental a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) cmp :: (Positive n, Comparison a, n ~ Size value, C value) => CmpPredicate -> value a -> value a -> CodeGenFunction r (value Bool) fcmp :: (Positive n, FloatingComparison a, n ~ Size value, C value) => FPPredicate -> value a -> value a -> CodeGenFunction r (value Bool) and :: (Positive n, Logic a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) xor :: (Positive n, Logic a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) or :: (Positive n, Logic a, n ~ Size value, C value) => value a -> value a -> CodeGenFunction r (value a) inv :: (Positive n, Logic a, n ~ Size value, C value) => value a -> CodeGenFunction r (value a) instance Positive n => C (T n) instance C T