-- 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: -- -- @package llvm-extra @version 0.9 -- | These functions work in arbitrary monads but are especially helpful -- when working with the CodeGenFunction monad. -- | Deprecated: use utility-ht:Control.Monad.HT module LLVM.Extra.Monad chain :: Monad m => [a -> m a] -> (a -> m a) liftR2 :: Monad m => (a -> b -> m c) -> m a -> m b -> m c liftR3 :: Monad m => (a -> b -> c -> m d) -> m a -> m b -> m c -> m d module LLVM.Extra.ArithmeticPrivate add :: IsArithmetic a => Value a -> Value a -> CodeGenFunction r (Value a) sub :: IsArithmetic a => Value a -> Value a -> CodeGenFunction r (Value 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) advanceArrayElementPtr :: Value (Ptr a) -> CodeGenFunction r (Value (Ptr a)) decreaseArrayElementPtr :: Value (Ptr a) -> CodeGenFunction r (Value (Ptr a)) mul :: IsArithmetic a => Value a -> Value a -> CodeGenFunction r (Value a) -- | This would also work for vectors, but LLVM-3.1 crashes when actually -- doing this. min :: CmpRet a => Value a -> Value a -> CodeGenFunction r (Value a) max :: CmpRet a => Value a -> Value a -> CodeGenFunction r (Value a) abs :: (IsArithmetic a, CmpRet a) => Value a -> CodeGenFunction r (Value a) signumGen :: (CmpRet a, IsPrimitive a) => Value a -> Value a -> Value a -> CodeGenFunction r (Value a) signum :: (Num a, CmpRet a, IsConst a, IsPrimitive a) => Value a -> CodeGenFunction r (Value a) cmpSelect :: CmpRet a => (Value a -> Value a -> CodeGenFunction r (Value (CmpResult a))) -> (Value a -> Value a -> CodeGenFunction r (Value a)) fcmp :: (IsFloating a, CmpRet a, CmpResult a ~ b) => FPPredicate -> Value a -> Value a -> CodeGenFunction r (Value b) cmp :: (CmpRet a, CmpResult a ~ b) => CmpPredicate -> Value a -> Value a -> CodeGenFunction r (Value b) and :: IsInteger a => Value a -> Value a -> CodeGenFunction r (Value a) or :: IsInteger a => Value a -> Value a -> CodeGenFunction r (Value a) fraction :: IsFloating a => Value a -> CodeGenFunction r (Value a) -- | Useful control structures additionally to those in -- LLVM.Util.Loop. module LLVM.Extra.Control arrayLoop :: (Phi a, IsType b, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr b) -> a -> (Value (Ptr b) -> a -> CodeGenFunction r a) -> CodeGenFunction r a arrayLoop2 :: (Phi s, IsType a, IsType b, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr a) -> Value (Ptr b) -> s -> (Value (Ptr a) -> Value (Ptr b) -> s -> CodeGenFunction r s) -> CodeGenFunction r s arrayLoopWithExit :: (Phi s, IsType a, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr a) -> s -> (Value (Ptr a) -> s -> CodeGenFunction r (Value Bool, s)) -> CodeGenFunction r (Value i, s) arrayLoop2WithExit :: (Phi s, IsType a, IsType b, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr a) -> Value (Ptr b) -> s -> (Value (Ptr a) -> Value (Ptr b) -> s -> CodeGenFunction r (Value Bool, s)) -> CodeGenFunction r (Value i, s) fixedLengthLoop :: (Phi s, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> s -> (s -> CodeGenFunction r s) -> CodeGenFunction r s whileLoop :: Phi a => a -> (a -> CodeGenFunction r (Value Bool)) -> (a -> CodeGenFunction r a) -> CodeGenFunction r a -- | This is a variant of whileLoop that may be more convient, -- because you only need one lambda expression for both loop condition -- and loop body. whileLoopShared :: Phi a => a -> (a -> (CodeGenFunction r (Value Bool), CodeGenFunction r a)) -> CodeGenFunction r a -- | This is a loop with a single point for exit from within the loop. The -- Bool value indicates whether the loop shall be continued. loopWithExit :: Phi a => a -> (a -> CodeGenFunction r (Value Bool, b)) -> (b -> CodeGenFunction r a) -> CodeGenFunction r b -- | This construct starts new blocks, so be prepared when continueing -- after an ifThenElse. ifThenElse :: Phi a => Value Bool -> CodeGenFunction r a -> CodeGenFunction r a -> CodeGenFunction r a ifThen :: Phi a => Value Bool -> a -> CodeGenFunction r a -> CodeGenFunction r a class Phi a => Select a select :: Select a => Value Bool -> a -> a -> CodeGenFunction r a selectTraversable :: (Select a, Traversable f, Applicative f) => Value Bool -> f a -> f a -> CodeGenFunction r (f a) -- | Branch-free variant of ifThen that is faster if the enclosed -- block is very simply, say, if it contains at most two instructions. It -- can only be used as alternative to ifThen if the enclosed block -- is free of side effects. ifThenSelect :: Select a => Value Bool -> a -> CodeGenFunction r a -> CodeGenFunction r a instance (Select a, Select b, Select c) => Select (a, b, c) instance (Select a, Select b) => Select (a, b) instance Select () instance (CmpRet a, IsPrimitive a) => Select (Value a) module LLVM.Extra.Class class Undefined a undefTuple :: Undefined a => a class Zero a zeroTuple :: Zero a => a zeroTuplePointed :: (Zero a, Applicative f) => f a class Undefined (ValueTuple haskellValue) => MakeValueTuple haskellValue where type family ValueTuple haskellValue :: * valueTupleOf :: MakeValueTuple haskellValue => haskellValue -> ValueTuple haskellValue undefTuplePointed :: (Undefined a, Applicative f) => f a valueTupleOfFunctor :: (MakeValueTuple h, Functor f) => f h -> f (ValueTuple h) phisTraversable :: (Phi a, Traversable f) => BasicBlock -> f a -> CodeGenFunction r (f a) addPhisFoldable :: (Phi a, Foldable f, Applicative f) => BasicBlock -> f a -> f a -> CodeGenFunction r () instance (Positive n, IsPrimitive a, IsConst a) => MakeValueTuple (Vector n a) instance MakeValueTuple (StablePtr a) instance IsFunction a => MakeValueTuple (FunPtr a) instance IsType a => MakeValueTuple (Ptr a) instance MakeValueTuple () instance MakeValueTuple Word64 instance MakeValueTuple Word32 instance MakeValueTuple Word16 instance MakeValueTuple Word8 instance MakeValueTuple Int64 instance MakeValueTuple Int32 instance MakeValueTuple Int16 instance MakeValueTuple Int8 instance MakeValueTuple Bool instance MakeValueTuple Double instance MakeValueTuple Float instance (MakeValueTuple a, MakeValueTuple b) => MakeValueTuple (Either a b) instance MakeValueTuple a => MakeValueTuple (Maybe a) instance (MakeValueTuple ah, MakeValueTuple bh, MakeValueTuple ch) => MakeValueTuple (ah, bh, ch) instance (MakeValueTuple ah, MakeValueTuple bh) => MakeValueTuple (ah, bh) instance (Zero a, Zero b, Zero c) => Zero (a, b, c) instance (Zero a, Zero b) => Zero (a, b) instance IsFirstClass a => Zero (ConstValue a) instance IsFirstClass a => Zero (Value a) instance Zero () instance (Undefined a, Undefined b) => Undefined (T a b) instance Undefined a => Undefined (T a) instance (Undefined a, Undefined b, Undefined c) => Undefined (a, b, c) instance (Undefined a, Undefined b) => Undefined (a, b) instance IsFirstClass a => Undefined (ConstValue a) instance IsFirstClass a => Undefined (Value a) instance Undefined () module LLVM.Extra.Vector class (Positive (Size v), Phi v, Undefined v) => Simple v where type family Element v :: * type family Size v :: * shuffleMatch :: Simple v => ConstValue (Vector (Size v) Word32) -> v -> CodeGenFunction r v extract :: Simple v => Value Word32 -> v -> CodeGenFunction r (Element v) -- | Allow to work on records of vectors as if they are vectors of records. -- This is a reasonable approach for records of different element types -- since processor vectors can only be built from elements of the same -- type. But also, say, for chunked stereo signal this makes sense. In -- this case we would work on Stereo (Value a). -- -- Formerly we used a two-way dependency Vector - (Element, Size). -- Now we have only the dependency Vector -> (Element, Size). This -- means that we need some more type annotations as in -- umul32to64/assemble, on the other hand we can allow multiple vector -- types with respect to the same element type. E.g. we can provide a -- vector type with pair elements where the pair elements are interleaved -- in the vector. class Simple v => C v insert :: C v => Value Word32 -> Element v -> v -> CodeGenFunction r v class (n ~ Size (Construct n a), a ~ Element (Construct n a), C (Construct n a)) => Canonical n a where type family Construct n a :: * size :: Positive n => Value (Vector n a) -> Int sizeInTuple :: Simple v => v -> Int -- | Manually assemble a vector of equal values. Better use -- ScalarOrVector.replicate. replicate :: C v => Element v -> CodeGenFunction r v iterate :: C v => (Element v -> CodeGenFunction r (Element v)) -> Element v -> CodeGenFunction r v -- | construct a vector out of single elements -- -- You must assert that the length of the list matches the vector size. -- -- This can be considered the inverse of extractAll. assemble :: C v => [Element v] -> CodeGenFunction r v -- | Manually implement vector shuffling using insertelement and -- extractelement. In contrast to LLVM's built-in instruction it supports -- distinct vector sizes, but it allows only one input vector (or a tuple -- of vectors, but we cannot shuffle between them). For more complex -- shuffling we recommend extractAll and assemble. shuffle :: (C v, C w, Element v ~ Element w) => v -> ConstValue (Vector (Size w) Word32) -> CodeGenFunction r w -- | 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 :: Simple v => v -> CodeGenFunction r v rotateDown :: Simple v => v -> CodeGenFunction r v reverse :: Simple v => v -> CodeGenFunction r v shiftUp :: C v => Element v -> v -> CodeGenFunction r (Element v, v) shiftDown :: C v => Element v -> v -> CodeGenFunction r (Element v, v) shiftUpMultiZero :: (C v, Zero (Element v)) => Int -> v -> CodeGenFunction r v shiftDownMultiZero :: (C v, Zero (Element v)) => Int -> v -> CodeGenFunction r v shuffleMatchTraversable :: (Simple v, Traversable f) => ConstValue (Vector (Size v) Word32) -> f v -> CodeGenFunction r (f v) -- | Implement the shuffleMatch method using the methods of the -- C class. shuffleMatchAccess :: C v => ConstValue (Vector (Size v) Word32) -> v -> CodeGenFunction r v shuffleMatchPlain1 :: (Positive n, IsPrimitive a) => Value (Vector n a) -> ConstValue (Vector n Word32) -> CodeGenFunction r (Value (Vector n a)) shuffleMatchPlain2 :: (Positive n, IsPrimitive a) => Value (Vector n a) -> Value (Vector n a) -> ConstValue (Vector n Word32) -> CodeGenFunction r (Value (Vector n a)) insertTraversable :: (C v, Traversable f, Applicative f) => Value Word32 -> f (Element v) -> f v -> CodeGenFunction r (f v) extractTraversable :: (Simple v, Traversable f) => Value Word32 -> f v -> CodeGenFunction r (f (Element v)) -- | provide the elements of a vector as a list of individual virtual -- registers -- -- This can be considered the inverse of assemble. extractAll :: Simple v => v -> CodeGenFunction r [Element v] data Constant n a constant :: Positive n => a -> Constant n a insertChunk :: (C c, C v, Element c ~ Element v) => Int -> c -> v -> CodeGenFunction r v modify :: C v => Value Word32 -> (Element v -> CodeGenFunction r (Element v)) -> (v -> CodeGenFunction r v) -- | Like LLVM.Util.Loop.mapVector but the loop is unrolled, which is -- faster since it can be packed by the code generator. map :: (C v, C w, Size v ~ Size w) => (Element v -> CodeGenFunction r (Element w)) -> (v -> CodeGenFunction r w) mapChunks :: (C ca, C cb, Size ca ~ Size cb, C va, C vb, Size va ~ Size vb, Element ca ~ Element va, Element cb ~ Element vb) => (ca -> CodeGenFunction r cb) -> (va -> CodeGenFunction r vb) zipChunksWith :: (C ca, C cb, C cc, Size ca ~ Size cb, Size cb ~ Size cc, C va, C vb, C vc, Size va ~ Size vb, Size vb ~ Size vc, Element ca ~ Element va, Element cb ~ Element vb, Element cc ~ Element vc) => (ca -> cb -> CodeGenFunction r cc) -> (va -> vb -> CodeGenFunction r vc) -- | If the target vector type is a native type then the chop operation -- produces no actual machine instruction. (nop) If the vector cannot be -- evenly divided into chunks the last chunk will be padded with -- undefined values. chop :: (C c, C v, Element c ~ Element v) => v -> [CodeGenFunction r c] -- | The target size is determined by the type. If the chunk list provides -- more data, the exceeding data is dropped. If the chunk list provides -- too few data, the target vector is filled with undefined elements. concat :: (C c, C v, Element c ~ Element v) => [c] -> CodeGenFunction r v signedFraction :: (IsFloating a, IsConst a, Real a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value (Vector n a)) -- | Needs (log n) vector additions cumulate1 :: (IsArithmetic a, IsPrimitive a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value (Vector n a)) -- | The order of addition is chosen for maximum efficiency. We do not try -- to prevent cancelations. class (IsArithmetic a, IsPrimitive a) => Arithmetic a where sum = sumGeneric sumToPair = sumToPairGeneric sumInterleavedToPair v = getLowestPair =<< reduceSumInterleaved 2 v cumulate = cumulateGeneric dotProduct x y = dotProductPartial (size x) x y mul = mul sum :: (Arithmetic a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value a) sumToPair :: (Arithmetic a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value a, Value a) sumInterleavedToPair :: (Arithmetic a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value a, Value a) cumulate :: (Arithmetic a, Positive n) => Value a -> Value (Vector n a) -> CodeGenFunction r (Value a, Value (Vector n a)) dotProduct :: (Arithmetic a, Positive n) => Value (Vector n a) -> Value (Vector n a) -> CodeGenFunction r (Value a) mul :: (Arithmetic a, Positive n) => Value (Vector n a) -> Value (Vector n a) -> CodeGenFunction r (Value (Vector n a)) class (Arithmetic a, CmpRet a, IsPrimitive a, IsConst a) => Real a min, max :: (Real a, Positive n) => Value (Vector n a) -> Value (Vector n a) -> CodeGenFunction r (Value (Vector n a)) abs :: (Real a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value (Vector n a)) signum :: (Real a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value (Vector n a)) truncate, fraction, floor :: (Real a, Positive n) => Value (Vector n a) -> CodeGenFunction r (Value (Vector n a)) instance Real Word64 instance Real Word32 instance Real Word16 instance Real Word8 instance Real Int64 instance Real Int32 instance Real Int16 instance Real Int8 instance Real Double instance Real Float instance Arithmetic Word64 instance Arithmetic Word32 instance Arithmetic Word16 instance Arithmetic Word8 instance Arithmetic Int64 instance Arithmetic Int32 instance Arithmetic Int16 instance Arithmetic Int8 instance Arithmetic Double instance Arithmetic Float instance (Canonical n a0, Canonical n a1, Canonical n a2) => Canonical n (a0, a1, a2) instance (Canonical n a0, Canonical n a1) => Canonical n (a0, a1) instance (Positive n, IsPrimitive a) => Canonical n (Value a) instance (Positive n, Phi a, Undefined a) => Simple (Constant n a) instance Undefined a => Undefined (Constant n a) instance Phi a => Phi (Constant n a) instance Traversable (Constant n) instance Foldable (Constant n) instance Applicative (Constant n) instance Functor (Constant n) instance (C v0, C v1, C v2, Size v0 ~ Size v1, Size v1 ~ Size v2) => C (v0, v1, v2) instance (Simple v0, Simple v1, Simple v2, Size v0 ~ Size v1, Size v1 ~ Size v2) => Simple (v0, v1, v2) instance (C v0, C v1, Size v0 ~ Size v1) => C (v0, v1) instance (Simple v0, Simple v1, Size v0 ~ Size v1) => Simple (v0, v1) instance (Positive n, IsPrimitive a) => C (Value (Vector n a)) instance (Positive n, IsPrimitive a) => Simple (Value (Vector n a)) module LLVM.Extra.Array size :: Natural n => Value (Array n a) -> Int -- | construct an array out of single elements -- -- You must assert that the length of the list matches the array size. -- -- This can be considered the inverse of extractAll. assemble :: (Natural n, IsFirstClass a, IsSized a) => [Value a] -> CodeGenFunction r (Value (Array n a)) -- | provide the elements of an array as a list of individual virtual -- registers -- -- This can be considered the inverse of assemble. extractAll :: (Natural n, IsFirstClass a, IsSized a) => Value (Array n a) -> CodeGenFunction r [Value a] -- | The loop is unrolled, since insertvalue and extractvalue -- expect constant indices. map :: (Natural n, IsFirstClass a, IsSized a, IsFirstClass b, IsSized b) => (Value a -> CodeGenFunction r (Value b)) -> (Value (Array n a) -> CodeGenFunction r (Value (Array n b))) -- | LLVM counterpart to Maybe datatype. module LLVM.Extra.Maybe -- | If isJust = False, then fromJust is an -- undefTuple. data T a Cons :: Value Bool -> a -> T a isJust :: T a -> Value Bool fromJust :: T a -> a -- | counterpart to maybe run :: Phi b => T a -> CodeGenFunction r b -> (a -> CodeGenFunction r b) -> CodeGenFunction r b for :: T a -> (a -> CodeGenFunction r ()) -> CodeGenFunction r () -- | counterpart to fromMaybe with swapped arguments select :: Select a => T a -> a -> CodeGenFunction r a alternative :: Select a => T a -> T a -> CodeGenFunction r (T a) -- | counterpart to Data.Maybe.HT.toMaybe fromBool :: Value Bool -> a -> T a toBool :: T a -> (Value Bool, a) getIsNothing :: T a -> CodeGenFunction r (Value Bool) just :: a -> T a nothing :: Undefined a => T a sequence :: T (CodeGenFunction r a) -> CodeGenFunction r (T a) traverse :: (a -> CodeGenFunction r b) -> T a -> CodeGenFunction r (T b) lift2 :: (a -> b -> c) -> T a -> T b -> CodeGenFunction r (T c) liftM2 :: (a -> b -> CodeGenFunction r c) -> T a -> T b -> CodeGenFunction r (T c) loopWithExit :: Phi a => a -> (a -> CodeGenFunction r (T c, b)) -> ((c, b) -> CodeGenFunction r a) -> CodeGenFunction r b -- | LLVM counterpart to Either datatype. module LLVM.Extra.Either -- | If isRight, then fromLeft is an undefTuple. -- If not isRight, then fromRight is an -- undefTuple. I would prefer a union type, but it was -- temporarily removed in LLVM-2.8 and did not return since then. data T a b Cons :: Value Bool -> a -> b -> T a b isRight :: T a b -> Value Bool fromLeft :: T a b -> a fromRight :: T a b -> b -- | counterpart to either run :: Phi c => T a b -> (a -> CodeGenFunction r c) -> (b -> CodeGenFunction r c) -> CodeGenFunction r c getIsLeft :: T a b -> CodeGenFunction r (Value Bool) mapLeft :: (a0 -> a1) -> T a0 b -> T a1 b mapRight :: (b0 -> b1) -> T a b0 -> T a b1 left :: Undefined b => a -> T a b right :: Undefined a => b -> T a b module LLVM.Extra.ScalarOrVectorPrivate class Replicate vector replicate :: Replicate vector => Value (Scalar vector) -> CodeGenFunction r (Value vector) replicateConst :: Replicate vector => ConstValue (Scalar vector) -> ConstValue vector singleton :: IsPrimitive a => Value a -> CodeGenFunction r (Value (Vector D1 a)) uaddSat :: (IsInteger v, CmpRet v, Replicate v, Scalar v ~ a, IsConst a, Bounded a) => Value v -> Value v -> CodeGenFunction r (Value v) usubSat :: (IsInteger v, CmpRet v, Replicate v, Scalar v ~ a, IsConst a, Bounded a) => Value v -> Value v -> CodeGenFunction r (Value v) saddSat :: (IsInteger v, CmpRet v, Replicate v, ShapeOf v ~ shape, ShapedType shape Bool ~ bv, ShapeOf bv ~ shape, CmpRet bv, Scalar v ~ a, IsConst a, Bounded a) => Value v -> Value v -> CodeGenFunction r (Value v) ssubSat :: (IsInteger v, CmpRet v, Replicate v, ShapeOf v ~ shape, ShapedType shape Bool ~ bv, ShapeOf bv ~ shape, CmpRet bv, Scalar v ~ a, IsConst a, Bounded a) => Value v -> Value v -> CodeGenFunction r (Value v) saddSatLogical :: (IsInteger v, CmpRet v, Replicate v, ShapeOf v ~ shape, ShapedType shape Bool ~ bv, ShapeOf bv ~ shape, CmpRet bv, IsInteger bv, Scalar v ~ a, IsConst a, Bounded a) => Value v -> Value v -> CodeGenFunction r (Value v) instance (Positive n, IsPrimitive a) => Replicate (Vector n a) instance Replicate (WordN d) instance Replicate (IntN d) instance Replicate Word64 instance Replicate Word32 instance Replicate Word16 instance Replicate Word8 instance Replicate Int64 instance Replicate Int32 instance Replicate Int16 instance Replicate Int8 instance Replicate Bool instance Replicate FP128 instance Replicate Double instance Replicate Float -- | Support for unified handling of scalars and vectors. -- -- Attention: The rounding and fraction functions only work for floating -- point values with maximum magnitude of maxBound :: Int32. -- This way we save expensive handling of possibly seldom cases. module LLVM.Extra.ScalarOrVector class (Real a, IsFloating a) => Fraction a truncate :: Fraction a => Value a -> CodeGenFunction r (Value a) fraction :: Fraction a => Value a -> CodeGenFunction r (Value a) -- | The fraction has the same sign as the argument. This is not particular -- useful but fast on IEEE implementations. signedFraction :: Fraction a => Value a -> CodeGenFunction r (Value a) -- | increment (first operand) may be negative, phase must always be -- non-negative addToPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a) -- | both increment and phase must be non-negative incPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a) truncateToInt :: (IsFloating a, IsInteger i, ShapeOf a ~ ShapeOf i) => Value a -> CodeGenFunction r (Value i) floorToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, ShapeOf a ~ ShapeOf i) => Value a -> CodeGenFunction r (Value i) ceilingToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, ShapeOf a ~ ShapeOf i) => Value a -> CodeGenFunction r (Value i) -- | Rounds to the next integer. For numbers of the form n+0.5, we -- choose one of the neighboured integers such that the overall -- implementation is most efficient. roundToIntFast :: (IsFloating a, RationalConstant a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, ShapeOf a ~ ShapeOf i) => Value a -> CodeGenFunction r (Value i) splitFractionToInt :: (IsFloating a, CmpRet a, IsInteger i, IntegerConstant i, CmpRet i, CmpResult a ~ CmpResult i, ShapeOf a ~ ShapeOf i) => Value a -> CodeGenFunction r (Value i, Value a) class Replicate vector replicate :: Replicate vector => Value (Scalar vector) -> CodeGenFunction r (Value vector) replicateConst :: Replicate vector => ConstValue (Scalar vector) -> ConstValue vector replicateOf :: (IsConst (Scalar v), Replicate v) => Scalar v -> Value v class IsArithmetic a => Real a min :: Real a => Value a -> Value a -> CodeGenFunction r (Value a) max :: Real a => Value a -> Value a -> CodeGenFunction r (Value a) abs :: Real a => Value a -> CodeGenFunction r (Value a) signum :: Real a => Value a -> CodeGenFunction r (Value a) class IsInteger a => Saturated a addSat, subSat :: Saturated a => Value a -> Value a -> CodeGenFunction r (Value a) class (IsArithmetic (Scalar v), IsArithmetic v) => PseudoModule v scale :: (PseudoModule v, a ~ Scalar v) => Value a -> Value v -> CodeGenFunction r (Value v) scaleConst :: (PseudoModule v, a ~ Scalar v) => ConstValue a -> ConstValue v -> CodeGenFunction r (ConstValue v) class IsConst a => IntegerConstant a constFromInteger :: IntegerConstant a => Integer -> ConstValue a class IntegerConstant a => RationalConstant a constFromRational :: RationalConstant a => Rational -> ConstValue a class RationalConstant a => TranscendentalConstant a constPi :: TranscendentalConstant a => ConstValue a instance (TranscendentalConstant a, IsPrimitive a, Positive n) => TranscendentalConstant (Vector n a) instance TranscendentalConstant Double instance TranscendentalConstant Float instance (RationalConstant a, IsPrimitive a, Positive n) => RationalConstant (Vector n a) instance RationalConstant Double instance RationalConstant Float instance (IntegerConstant a, IsPrimitive a, Positive n) => IntegerConstant (Vector n a) instance Positive n => IntegerConstant (IntN n) instance Positive n => IntegerConstant (WordN n) instance IntegerConstant Double instance IntegerConstant 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 (IsArithmetic a, IsPrimitive a, Positive n) => PseudoModule (Vector n a) instance PseudoModule Double instance PseudoModule Float instance PseudoModule Int64 instance PseudoModule Int32 instance PseudoModule Int16 instance PseudoModule Int8 instance PseudoModule Word64 instance PseudoModule Word32 instance PseudoModule Word16 instance PseudoModule Word8 instance (Positive n, IsPrimitive a, Saturated a, Bounded a, CmpRet a, IsConst a) => Saturated (Vector n a) instance Positive d => Saturated (WordN d) instance Positive d => Saturated (IntN d) instance Saturated Word64 instance Saturated Word32 instance Saturated Word16 instance Saturated Word8 instance Saturated Int64 instance Saturated Int32 instance Saturated Int16 instance Saturated Int8 instance (Positive n, Real a) => Real (Vector n a) instance Positive n => Real (WordN n) instance Positive n => Real (IntN n) instance Real Word64 instance Real Word32 instance Real Word16 instance Real Word8 instance Real Int64 instance Real Int32 instance Real Int16 instance Real Int8 instance Real FP128 instance Real Double instance Real Float instance (Positive n, Real a, IsFloating a, IsConst a) => Fraction (Vector n a) instance Fraction Double instance Fraction Float module LLVM.Extra.Arithmetic -- | This and the following type classes are intended for arithmetic -- operations on wrappers around LLVM types. E.g. you might define a -- fixed point fraction type by -- --
--   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.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) -- | 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) fromPlainMaybe :: Phi z => T a -> T r z 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 () just :: a -> T r z a nothing :: T r z a 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, CmpRet i, IsPrimitive i) => 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, CmpRet i, IsPrimitive i) => 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, CmpRet i, IsPrimitive i) => 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.Iterator -- | Simulates a non-strict list. data T r a mapM_ :: (a -> CodeGenFunction r ()) -> T r a -> CodeGenFunction r () mapState_ :: Phi t => (a -> t -> CodeGenFunction r t) -> T r a -> t -> CodeGenFunction r t mapStateM_ :: Phi t => (a -> StateT t (CodeGenFunction r) ()) -> T r a -> StateT t (CodeGenFunction r) () mapWhileState_ :: Phi t => (a -> t -> CodeGenFunction r (Value Bool, t)) -> T r a -> t -> CodeGenFunction r t empty :: T r a singleton :: a -> T r a cons :: (Phi a, Undefined a) => a -> T r a -> T r a -- | Attention: This always performs one function call more than necessary. -- I.e. if f reads from or writes to memory make sure that -- accessing one more pointer is legal. iterate :: (Phi a, Undefined a) => (a -> CodeGenFunction r a) -> a -> T r a countDown :: (Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> T r (Value i) arrayPtrs :: IsType a => Value (Ptr a) -> T r (Value (Ptr a)) mapM :: (a -> CodeGenFunction r b) -> T r a -> T r b mapMaybe :: (Phi b, Undefined b) => (a -> CodeGenFunction r (T b)) -> T r a -> T r b catMaybes :: (Phi a, Undefined a) => T r (T a) -> T r a takeWhileJust :: T r (T a) -> T r a takeWhile :: (a -> CodeGenFunction r (Value Bool)) -> T r a -> T r a cartesian :: (Phi a, Phi b, Undefined a, Undefined b) => T r a -> T r b -> T r (a, b) take :: (Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> T r a -> T r a fixedLengthLoop :: (Phi s, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> s -> (s -> CodeGenFunction r s) -> CodeGenFunction r s arrayLoop :: (Phi a, IsType b, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr b) -> a -> (Value (Ptr b) -> a -> CodeGenFunction r a) -> CodeGenFunction r a arrayLoopWithExit :: (Phi s, IsType a, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr a) -> s -> (Value (Ptr a) -> s -> CodeGenFunction r (Value Bool, s)) -> CodeGenFunction r (Value i, s) arrayLoop2 :: (Phi s, IsType a, IsType b, Num i, IsConst i, IsInteger i, CmpRet i, IsPrimitive i) => Value i -> Value (Ptr a) -> Value (Ptr b) -> s -> (Value (Ptr a) -> Value (Ptr b) -> s -> CodeGenFunction r s) -> CodeGenFunction r s instance Applicative (T r) instance Functor (T r) 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 cons :: (C a, Positive n) => Vector n a -> T n 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 () shuffle :: (C a, Positive n, Positive m) => ConstValue (Vector m Word32) -> T n a -> T n a -> CodeGenFunction r (T m 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) type Value n = Compose Value (Vector n) 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) take :: (Positive n, Positive m, C a) => T n a -> CodeGenFunction r (T m a) takeRev :: (Positive n, Positive m, C a) => T n a -> CodeGenFunction r (T m 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) => Int -> T n a -> CodeGenFunction r (T n a) shiftDownMultiZero :: (Positive n, C a) => Int -> T n a -> CodeGenFunction r (T n a) shiftUpMultiUndef :: (Positive n, C a) => Int -> T n a -> CodeGenFunction r (T n a) shiftDownMultiUndef :: (Positive n, C a) => Int -> T n a -> CodeGenFunction r (T n a) undefPrimitive :: (Positive n, IsPrimitive al, Repr (Value n) a ~ Value n al) => T n a shufflePrimitive :: (Positive n, Positive m, IsPrimitive al, Repr Value a ~ Value al, Repr (Value n) a ~ Value n al, Repr (Value m) a ~ Value m al) => ConstValue (Vector m Word32) -> T n a -> T n a -> CodeGenFunction r (T m a) extractPrimitive :: (Positive n, IsPrimitive al, Repr Value a ~ Value al, Repr (Value n) a ~ Value n al) => Value Word32 -> T n a -> CodeGenFunction r (T a) insertPrimitive :: (Positive n, IsPrimitive al, Repr Value a ~ Value al, Repr (Value n) a ~ Value n al) => 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 (IntegerConstant a, C a) => IntegerConstant a fromInteger' :: (IntegerConstant a, Positive n) => Integer -> T n a class (RationalConstant a, IntegerConstant a) => RationalConstant a fromRational' :: (RationalConstant a, Positive n) => Rational -> T n 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 (Select a, C a) => Select a select :: (Select a, Positive n) => T n Bool -> T n a -> T n a -> CodeGenFunction r (T n a) 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) class (BitShift a, C a) => BitShift a shl :: (BitShift a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) shr :: (BitShift a, Positive n) => T n a -> T n a -> CodeGenFunction r (T n a) instance BitShift Int64 instance BitShift Int32 instance BitShift Int16 instance BitShift Int8 instance BitShift Word64 instance BitShift Word32 instance BitShift Word16 instance BitShift Word8 instance (Positive n, Logic a) => Logic (T n a) instance Logic Word64 instance Logic Word32 instance Logic Word16 instance Logic Word8 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 Int64 instance Comparison Int32 instance Comparison Int16 instance Comparison Int8 instance Comparison Word64 instance Comparison Word32 instance Comparison Word16 instance Comparison Word8 instance Comparison Double instance Comparison Float 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 Bool instance Select Double instance Select 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 Word64 instance Additive Word32 instance Additive Word16 instance Additive Word8 instance Additive Int64 instance Additive Int32 instance Additive Int16 instance Additive Int8 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 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, C b, C c) => C (a, b, c) instance (C a, C b) => C (a, b) instance C Word64 instance C Word32 instance C Word16 instance C Word8 instance C Int64 instance C Int32 instance C Int16 instance C Int8 instance C Double instance C Float instance C Bool8 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.FastMath data NoNaNs NoNaNs :: NoNaNs data NoInfs NoInfs :: NoInfs data NoSignedZeros NoSignedZeros :: NoSignedZeros data AllowReciprocal AllowReciprocal :: AllowReciprocal data Fast Fast :: Fast class Flags flags setFlags :: (Flags flags, IsFloating a) => Proxy flags -> Bool -> Value a -> CodeGenFunction r () newtype Number flags a Number :: a -> Number flags a deconsNumber :: Number flags a -> a getNumber :: flags -> Number flags a -> a mvNumber :: T a -> T (Number flags a) mvDenumber :: T (Number flags a) -> T a class C a => MultiValue a setMultiValueFlags :: (MultiValue a, Flags flags) => Proxy flags -> Bool -> T (Number flags a) -> CodeGenFunction r () attachMultiValueFlags :: (Flags flags, MultiValue a) => Id (CodeGenFunction r (T (Number flags a))) liftNumberM :: (m ~ CodeGenFunction r, Flags flags, MultiValue b) => (T a -> m (T b)) -> T (Number flags a) -> m (T (Number flags b)) liftNumberM2 :: (m ~ CodeGenFunction r, Flags flags, MultiValue c) => (T a -> T b -> m (T c)) -> T (Number flags a) -> T (Number flags b) -> m (T (Number flags c)) mvecNumber :: T n a -> T n (Number flags a) mvecDenumber :: T n (Number flags a) -> T n a class (MultiValue a, C a) => MultiVector a setMultiVectorFlags :: (MultiVector a, Flags flags, Positive n) => Proxy flags -> Bool -> T n (Number flags a) -> CodeGenFunction r () attachMultiVectorFlags :: (Positive n, Flags flags, MultiVector a) => Id (CodeGenFunction r (T n (Number flags a))) liftMultiVectorM :: (m ~ CodeGenFunction r, Positive n, Flags flags, MultiVector b) => (T n a -> m (T n b)) -> T n (Number flags a) -> m (T n (Number flags b)) liftMultiVectorM2 :: (m ~ CodeGenFunction r, Positive n, Flags flags, MultiVector c) => (T n a -> T n b -> m (T n c)) -> T n (Number flags a) -> T n (Number flags b) -> m (T n (Number flags c)) class Tuple a setTupleFlags :: (Tuple a, Flags flags) => Proxy flags -> Bool -> a -> CodeGenFunction r () newtype Context flags a Context :: a -> Context flags a attachTupleFlags :: (Flags flags, Tuple a) => Id (CodeGenFunction r (Context flags a)) liftContext :: (Flags flags, Tuple b) => (a -> CodeGenFunction r b) -> Context flags a -> CodeGenFunction r (Context flags b) liftContext2 :: (Flags flags, Tuple c) => (a -> b -> CodeGenFunction r c) -> Context flags a -> Context flags b -> CodeGenFunction r (Context flags c) instance Show NoNaNs instance Eq NoNaNs instance Show NoInfs instance Eq NoInfs instance Show NoSignedZeros instance Eq NoSignedZeros instance Show AllowReciprocal instance Eq AllowReciprocal instance Show Fast instance Eq Fast instance Eq a => Eq (Number flags a) instance Ord a => Ord (Number flags a) instance Show a => Show (Number flags a) instance Num a => Num (Number flags a) instance Fractional a => Fractional (Number flags a) instance Floating a => Floating (Number flags a) instance Storable a => Storable (Number flags a) instance (Flags flags, Tuple a, Transcendental a) => Transcendental (Context flags a) instance (Flags flags, Tuple a, Algebraic a) => Algebraic (Context flags a) instance (Flags flags, Tuple a, FloatingComparison a) => FloatingComparison (Context flags a) instance (Flags flags, Tuple a, Comparison a) => Comparison (Context flags a) instance (Flags flags, Tuple a, Fraction a) => Fraction (Context flags a) instance (Flags flags, Tuple a, Real a) => Real (Context flags a) instance (Flags flags, Tuple a, RationalConstant a) => RationalConstant (Context flags a) instance (Flags flags, Tuple v, Field v) => Field (Context flags v) instance (Flags flags, Tuple a, IntegerConstant a) => IntegerConstant (Context flags a) instance (Flags flags, PseudoModule v, Tuple v, Scalar v ~ a, Tuple a) => PseudoModule (Context flags v) instance (Flags flags, PseudoRing a, Tuple a) => PseudoRing (Context flags a) instance (Flags flags, Tuple a, Additive a) => Additive (Context flags a) instance (Flags flags, Zero a, Tuple a) => Zero (Context flags a) instance IsFloating a => Tuple (Value a) instance (Flags flags, MultiVector a, FloatingComparison a) => FloatingComparison (Number flags a) instance (Flags flags, MultiVector a, Comparison a) => Comparison (Number flags a) instance (Flags flags, MultiVector a, Select a) => Select (Number flags a) instance (Flags flags, MultiVector a, Transcendental a) => Transcendental (Number flags a) instance (Flags flags, MultiVector a, Algebraic a) => Algebraic (Number flags a) instance (Flags flags, MultiVector a, Fraction a) => Fraction (Number flags a) instance (Flags flags, MultiVector a, Real a) => Real (Number flags a) instance (Flags flags, MultiVector a, Field a) => Field (Number flags a) instance (Flags flags, MultiVector a, PseudoRing a) => PseudoRing (Number flags a) instance (Flags flags, MultiVector a, Additive a) => Additive (Number flags a) instance (Flags flags, MultiVector a, RationalConstant a) => RationalConstant (Number flags a) instance (Flags flags, MultiVector a, IntegerConstant a) => IntegerConstant (Number flags a) instance (Flags flags, MultiVector a) => C (Number flags a) instance MultiVector Double instance MultiVector Float instance (Flags flags, MultiValue a, FloatingComparison a) => FloatingComparison (Number flags a) instance (Flags flags, MultiValue a, Comparison a) => Comparison (Number flags a) instance (Flags flags, MultiValue a, Select a) => Select (Number flags a) instance (Flags flags, MultiValue a, Transcendental a) => Transcendental (Number flags a) instance (Flags flags, MultiValue a, Algebraic a) => Algebraic (Number flags a) instance (Flags flags, MultiValue a, Fraction a) => Fraction (Number flags a) instance (Flags flags, MultiValue a, Real a) => Real (Number flags a) instance (Flags flags, MultiValue a, a ~ Scalar v, MultiValue v, PseudoModule v) => PseudoModule (Number flags v) instance (Flags flags, MultiValue a, Field a) => Field (Number flags a) instance (Flags flags, MultiValue a, PseudoRing a) => PseudoRing (Number flags a) instance (Flags flags, MultiValue a, Additive a) => Additive (Number flags a) instance (Flags flags, MultiValue a, RationalConstant a) => RationalConstant (Number flags a) instance (Flags flags, MultiValue a, IntegerConstant a) => IntegerConstant (Number flags a) instance (Flags flags, Decompose pa) => Decompose (Number flags pa) instance (Flags flags, Compose a) => Compose (Number flags a) instance MultiValue Double instance MultiValue Float instance MultiValue a => C (Number flags a) instance (Flags f0, Flags f1, Flags f2, Flags f3, Flags f4) => Flags (f0, f1, f2, f3, f4) instance (Flags f0, Flags f1, Flags f2, Flags f3) => Flags (f0, f1, f2, f3) instance (Flags f0, Flags f1, Flags f2) => Flags (f0, f1, f2) instance (Flags f0, Flags f1) => Flags (f0, f1) instance Flags Fast instance Flags AllowReciprocal instance Flags NoSignedZeros instance Flags NoInfs instance Flags NoNaNs module LLVM.Extra.Multi.Vector.Instance type MVVector n a = T (Vector n a) toMultiValue :: T n a -> MVVector n a fromMultiValue :: MVVector n a -> T n a liftMultiValueM :: Functor f => (T n a -> f (T m b)) -> (MVVector n a -> f (MVVector m b)) liftMultiValueM2 :: Functor f => (T n a -> T m b -> f (T k c)) -> (MVVector n a -> MVVector m b -> f (MVVector k c)) liftMultiValueM3 :: Functor f => (T n a -> T m b -> T m c -> f (T k d)) -> (MVVector n a -> MVVector m b -> MVVector m c -> f (MVVector k d)) instance (Positive n, BitShift a) => BitShift (Vector n a) instance (Positive n, Logic a) => Logic (Vector n a) instance (Positive n, Additive a) => Additive (Vector n a) instance (Positive n, RationalConstant a) => RationalConstant (Vector n a) instance (Positive n, IntegerConstant a) => IntegerConstant (Vector n a) instance (Positive n, C a) => C (Vector n 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 () boolPFrom8 :: T Bool8 -> T Bool bool8FromP :: T Bool -> T Bool8 intFromBool8 :: NativeInteger i ir => T Bool8 -> CodeGenFunction r (T i) floatFromBool8 :: NativeFloating a ar => T Bool8 -> CodeGenFunction r (T a) toEnum :: Repr Value w ~ Value w => T w -> T (T w e) fromEnum :: Repr Value w ~ Value w => T (T w e) -> T w succ :: (IsArithmetic w, IntegerConstant w) => T (T w e) -> CodeGenFunction r (T (T w e)) pred :: (IsArithmetic w, IntegerConstant w) => T (T w e) -> CodeGenFunction r (T (T w e)) cmpEnum :: (CmpRet w, IsPrimitive w) => CmpPredicate -> T (T w a) -> T (T w a) -> CodeGenFunction r (T Bool) class C a => Bounded a minBound, maxBound :: Bounded a => T a splitMaybe :: T (Maybe a) -> (T Bool, T a) toMaybe :: T Bool -> T a -> T (Maybe a) nothing :: C a => T (Maybe a) just :: T a -> T (Maybe a) 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) mapFstF :: Functor f => (T a0 -> f (T a1)) -> T (a0, b) -> f (T (a1, b)) mapSndF :: Functor f => (T b0 -> f (T b1)) -> T (a, b0) -> f (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) mapFst3F :: Functor f => (T a0 -> f (T a1)) -> T (a0, b, c) -> f (T (a1, b, c)) mapSnd3F :: Functor f => (T b0 -> f (T b1)) -> T (a, b0, c) -> f (T (a, b1, c)) mapThd3F :: Functor f => (T c0 -> f (T c1)) -> T (a, b, c0) -> f (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) tag :: T a -> T (Tagged tag a) untag :: T (Tagged tag a) -> T a liftTaggedM :: Monad m => (T a -> m (T b)) -> T (Tagged tag a) -> m (T (Tagged tag b)) liftTaggedM2 :: Monad m => (T a -> T b -> m (T c)) -> T (Tagged tag a) -> T (Tagged tag b) -> m (T (Tagged tag c)) 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) inc :: (Additive i, IntegerConstant i) => T i -> CodeGenFunction r (T i) dec :: (Additive i, IntegerConstant i) => T i -> CodeGenFunction r (T i) 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, IsPrimitive ir) => NativeInteger i ir class (Repr Value a ~ Value ar, IsFloating ar, RationalConstant ar, CmpRet ar, IsPrimitive ar) => 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 C a => 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 BitShift a shl :: BitShift a => T a -> T a -> CodeGenFunction r (T a) shr :: BitShift a => T 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) 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 al => Value (Ptr al) -> CodeGenFunction r (T a) storePrimitive :: Repr Value a ~ Value al => T a -> Value (Ptr al) -> CodeGenFunction r () decomposePrimitive :: Repr Value a ~ Value al => Value al -> CodeGenFunction r (T a) composePrimitive :: Repr Value a ~ Value al => T a -> CodeGenFunction r (Value al) 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 a => C (Tagged tag 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 instance C Bool8 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 (Vector n a) instance (C n a, C n b, C n c) => C n (a, b, c) 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 instance (Positive n, Positive (n :*: D64)) => C n Int64 instance (Positive n, Positive (n :*: D32)) => C n Int32 instance (Positive n, Positive (n :*: D16)) => C n Int16 instance (Positive n, Positive (n :*: D8)) => C n Int8 instance (Positive n, Positive (n :*: D64)) => C n Word64 instance (Positive n, Positive (n :*: D32)) => C n Word32 instance (Positive n, Positive (n :*: D16)) => C n Word16 instance (Positive n, Positive (n :*: D8)) => C n Word8 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 () -- | Deprecated: use castTuplePtr instead castStorablePtr :: (MakeValueTuple haskellValue, C (ValueTuple haskellValue)) => Ptr haskellValue -> Ptr (Struct (ValueTuple haskellValue)) castTuplePtr :: (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 () module LLVM.Extra.Multi.Value.Vector cons :: (Positive n, C a) => Vector n a -> T (Vector n a) fst :: T (Vector n (a, b)) -> T (Vector n a) snd :: T (Vector n (a, b)) -> T (Vector n b) fst3 :: T (Vector n (a, b, c)) -> T (Vector n a) snd3 :: T (Vector n (a, b, c)) -> T (Vector n b) thd3 :: T (Vector n (a, b, c)) -> T (Vector n c) zip :: T (Vector n a) -> T (Vector n b) -> T (Vector n (a, b)) zip3 :: T (Vector n a) -> T (Vector n b) -> T (Vector n c) -> T (Vector n (a, b, c)) unzip :: T (Vector n (a, b)) -> (T (Vector n a), T (Vector n b)) unzip3 :: T (Vector n (a, b, c)) -> (T (Vector n a), T (Vector n b), T (Vector n c)) swap :: T (Vector n (a, b)) -> T (Vector n (b, a)) mapFst :: (T (Vector n a0) -> T (Vector n a1)) -> T (Vector n (a0, b)) -> T (Vector n (a1, b)) mapSnd :: (T (Vector n b0) -> T (Vector n b1)) -> T (Vector n (a, b0)) -> T (Vector n (a, b1)) mapFst3 :: (T (Vector n a0) -> T (Vector n a1)) -> T (Vector n (a0, b, c)) -> T (Vector n (a1, b, c)) mapSnd3 :: (T (Vector n b0) -> T (Vector n b1)) -> T (Vector n (a, b0, c)) -> T (Vector n (a, b1, c)) mapThd3 :: (T (Vector n c0) -> T (Vector n c1)) -> T (Vector n (a, b, c0)) -> T (Vector n (a, b, c1)) extract :: (Positive n, C a) => Value Word32 -> T (Vector n a) -> CodeGenFunction r (T a) insert :: (Positive n, C a) => Value Word32 -> T a -> T (Vector n a) -> CodeGenFunction r (T (Vector n a)) replicate :: (Positive n, C a) => T a -> CodeGenFunction r (T (Vector n a)) dissect :: (Positive n, C a) => T (Vector n a) -> CodeGenFunction r [T a] select :: (Positive n, Select a) => T (Vector n Bool) -> T (Vector n a) -> T (Vector n a) -> CodeGenFunction r (T (Vector n a)) cmp :: (Positive n, Comparison a) => CmpPredicate -> T (Vector n a) -> T (Vector n a) -> CodeGenFunction r (T (Vector n Bool)) take :: (Positive n, Positive m, C a) => T (Vector n a) -> CodeGenFunction r (T (Vector m a)) takeRev :: (Positive n, Positive m, C a) => T (Vector n a) -> CodeGenFunction r (T (Vector m a)) module LLVM.Extra.Multi.Iterator takeWhile :: (a -> CodeGenFunction r (T Bool)) -> T r a -> T r a countDown :: (Additive i, Comparison i, IntegerConstant i) => T i -> T r (T i) take :: (Additive i, Comparison i, IntegerConstant i) => T i -> T r a -> T r a class C a => Enum a succ, pred :: Enum a => T a -> CodeGenFunction r (T a) enumFrom :: Enum a => T a -> T r (T a) enumFromTo :: Enum a => T a -> T a -> T r (T a) instance (IsInteger w, IntegerConstant w, Num w, CmpRet w, IsPrimitive w, Enum e) => Enum (T w e) 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