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

Safe HaskellNone

LLVM.Extra.Arithmetic

Contents

Synopsis

arithmetic: generalized and improved type inference

class Zero a => Additive a whereSource

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.

Methods

zero :: aSource

add :: a -> a -> CodeGenFunction r aSource

sub :: a -> a -> CodeGenFunction r aSource

neg :: a -> CodeGenFunction r aSource

Instances

IsArithmetic a => Additive (Value a) 
IsArithmetic a => Additive (ConstValue a) 
(Additive a, Additive b) => Additive (a, b) 
(Additive a, Additive b, Additive c) => Additive (a, b, c) 

class Additive a => PseudoRing a whereSource

Methods

mul :: a -> a -> CodeGenFunction r aSource

class (PseudoRing a, Additive v) => PseudoModule a v whereSource

Methods

scale :: a -> v -> CodeGenFunction r vSource

class PseudoRing a => Field a whereSource

Methods

fdiv :: a -> a -> CodeGenFunction r aSource

Instances

data CmpPredicate

Constructors

CmpEQ

equal

CmpNE

not equal

CmpGT

greater than

CmpGE

greater or equal

CmpLT

less than

CmpLE

less or equal

class Additive a => Real a whereSource

Methods

min :: a -> a -> CodeGenFunction r aSource

max :: a -> a -> CodeGenFunction r aSource

abs :: a -> CodeGenFunction r aSource

signum :: a -> CodeGenFunction r aSource

Instances

Real a => Real (Value a) 

class Real a => Fraction a whereSource

Instances

incPhase :: Fraction a => a -> a -> CodeGenFunction r aSource

both increment and phase must be non-negative

pointer arithmetic

transcendental functions

class Field a => Algebraic a whereSource

Methods

sqrt :: a -> CodeGenFunction r aSource

Instances