llvm-extra-0.10.1: Utility functions for the llvm interface

Safe HaskellNone

LLVM.Extra.ScalarOrVector

Description

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.

Synopsis

Documentation

class (Real a, IsFloating a) => Fraction a whereSource

Instances

Fraction Double 
Fraction Float 
(Positive n, Real a, IsFloating a, IsConst a) => Fraction (Vector n a) 

signedFraction :: Fraction a => Value a -> CodeGenFunction r (Value a)Source

The fraction has the same sign as the argument. This is not particular useful but fast on IEEE implementations.

addToPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a)Source

increment (first operand) may be negative, phase must always be non-negative

incPhase :: Fraction a => Value a -> Value a -> CodeGenFunction r (Value a)Source

both increment and phase must be non-negative

truncateToInt :: (IsFloating a, IsInteger i, ShapeOf a ~ ShapeOf i) => Value a -> CodeGenFunction r (Value i)Source

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)Source

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)Source

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)Source

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.

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)Source

type family Scalar vector :: *

class IsArithmetic a => Real a whereSource

Instances

Real Double 
Real Float 
Real Int 
Real Int8 
Real Int16 
Real Int32 
Real Int64 
Real Word 
Real Word8 
Real Word16 
Real Word32 
Real Word64 
Real FP128 
Positive n => Real (IntN n) 
Positive n => Real (WordN n) 
(Positive n, Real a) => Real (Vector n a) 

class IsInteger a => Saturated a whereSource

Methods

addSat, subSat :: Value a -> Value a -> CodeGenFunction r (Value a)Source