futhark-0.25.27: An optimising compiler for a functional, array-oriented language.

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Analysis.PrimExp

Contents

- Construction
- Untyped construction

Description

A primitive expression is an expression where the non-leaves are primitive operators. Our representation does not guarantee that the expression is type-correct.

Synopsis

- data PrimExp v
  - = LeafExp v PrimType
  - | ValueExp PrimValue
  - | BinOpExp BinOp (PrimExp v) (PrimExp v)
  - | CmpOpExp CmpOp (PrimExp v) (PrimExp v)
  - | UnOpExp UnOp (PrimExp v)
  - | ConvOpExp ConvOp (PrimExp v)
  - | FunExp Text [PrimExp v] PrimType
- newtype TPrimExp t v = TPrimExp {
  - untyped :: PrimExp v
  }
- isInt8 :: PrimExp v -> TPrimExp Int8 v
- isInt16 :: PrimExp v -> TPrimExp Int16 v
- isInt32 :: PrimExp v -> TPrimExp Int32 v
- isInt64 :: PrimExp v -> TPrimExp Int64 v
- isBool :: PrimExp v -> TPrimExp Bool v
- isF16 :: PrimExp v -> TPrimExp Half v
- isF32 :: PrimExp v -> TPrimExp Float v
- isF64 :: PrimExp v -> TPrimExp Double v
- evalPrimExp :: (Pretty v, MonadFail m) => (v -> m PrimValue) -> PrimExp v -> m PrimValue
- primExpType :: PrimExp v -> PrimType
- primExpSizeAtLeast :: Int -> PrimExp v -> Bool
- coerceIntPrimExp :: IntType -> PrimExp v -> PrimExp v
- leafExpTypes :: Ord a => PrimExp a -> Set (a, PrimType)
- true :: TPrimExp Bool v
- false :: TPrimExp Bool v
- fromBool :: Bool -> TPrimExp Bool v
- constFoldPrimExp :: PrimExp v -> PrimExp v
- module Language.Futhark.Primitive
- class NumExp t where
  - fromInteger' :: Integer -> TPrimExp t v
  - fromBoolExp :: TPrimExp Bool v -> TPrimExp t v
- class NumExp t => IntExp t where
  - expIntType :: TPrimExp t v -> IntType
- class NumExp t => FloatExp t where
  - fromRational' :: Rational -> TPrimExp t v
  - expFloatType :: TPrimExp t v -> FloatType
- sExt :: IntType -> PrimExp v -> PrimExp v
- zExt :: IntType -> PrimExp v -> PrimExp v
- (.&&.) :: Eq v => TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v
- (.||.) :: Eq v => TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v
- (.<.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.<=.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.>.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.>=.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.==.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.&.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (.|.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (.^.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (.>>.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (.<<.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- bNot :: TPrimExp Bool v -> TPrimExp Bool v
- sMax32 :: TPrimExp Int32 v -> TPrimExp Int32 v -> TPrimExp Int32 v
- sMin32 :: TPrimExp Int32 v -> TPrimExp Int32 v -> TPrimExp Int32 v
- sMax64 :: TPrimExp Int64 v -> TPrimExp Int64 v -> TPrimExp Int64 v
- sMin64 :: TPrimExp Int64 v -> TPrimExp Int64 v -> TPrimExp Int64 v
- sExt32 :: IntExp t => TPrimExp t v -> TPrimExp Int32 v
- sExt64 :: IntExp t => TPrimExp t v -> TPrimExp Int64 v
- zExt32 :: IntExp t => TPrimExp t v -> TPrimExp Int32 v
- zExt64 :: IntExp t => TPrimExp t v -> TPrimExp Int64 v
- sExtAs :: (IntExp to, IntExp from) => TPrimExp from v -> TPrimExp to v -> TPrimExp to v
- fMin16 :: TPrimExp Half v -> TPrimExp Half v -> TPrimExp Half v
- fMin32 :: TPrimExp Float v -> TPrimExp Float v -> TPrimExp Float v
- fMin64 :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v
- fMax16 :: TPrimExp Half v -> TPrimExp Half v -> TPrimExp Half v
- fMax32 :: TPrimExp Float v -> TPrimExp Float v -> TPrimExp Float v
- fMax64 :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v
- condExp :: TPrimExp Bool v -> TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (~*~) :: PrimExp v -> PrimExp v -> PrimExp v
- (~/~) :: PrimExp v -> PrimExp v -> PrimExp v
- (~+~) :: PrimExp v -> PrimExp v -> PrimExp v
- (~-~) :: PrimExp v -> PrimExp v -> PrimExp v
- (~==~) :: PrimExp v -> PrimExp v -> PrimExp v

# Documentation

data PrimExp v Source #

A primitive expression parametrised over the representation of free variables. Note that the `Functor`, `Traversable`, and `Num` instances perform automatic (but simple) constant folding.

Note also that the `Num` instance assumes `OverflowUndef` semantics!

Constructors

LeafExp v PrimType |
ValueExp PrimValue |
BinOpExp BinOp (PrimExp v) (PrimExp v) |
CmpOpExp CmpOp (PrimExp v) (PrimExp v) |
UnOpExp UnOp (PrimExp v) |
ConvOpExp ConvOp (PrimExp v) |
FunExp Text [PrimExp v] PrimType |

#### Instances

Instances details

Foldable PrimExp Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

fold :: Monoid m => PrimExp m -> m Source #

foldMap :: Monoid m => (a -> m) -> PrimExp a -> m Source #

foldMap' :: Monoid m => (a -> m) -> PrimExp a -> m Source #

foldr :: (a -> b -> b) -> b -> PrimExp a -> b Source #

foldr' :: (a -> b -> b) -> b -> PrimExp a -> b Source #

foldl :: (b -> a -> b) -> b -> PrimExp a -> b Source #

foldl' :: (b -> a -> b) -> b -> PrimExp a -> b Source #

foldr1 :: (a -> a -> a) -> PrimExp a -> a Source #

foldl1 :: (a -> a -> a) -> PrimExp a -> a Source #

toList :: PrimExp a -> [a] Source #

null :: PrimExp a -> Bool Source #

length :: PrimExp a -> Int Source #

elem :: Eq a => a -> PrimExp a -> Bool Source #

maximum :: Ord a => PrimExp a -> a Source #

minimum :: Ord a => PrimExp a -> a Source #

sum :: Num a => PrimExp a -> a Source #

product :: Num a => PrimExp a -> a Source #

Traversable PrimExp Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods traverse :: Applicative f => (a -> f b) -> PrimExp a -> f (PrimExp b) Source # sequenceA :: Applicative f => PrimExp (f a) -> f (PrimExp a) Source # mapM :: Monad m => (a -> m b) -> PrimExp a -> m (PrimExp b) Source # sequence :: Monad m => PrimExp (m a) -> m (PrimExp a) Source #
Functor PrimExp Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fmap :: (a -> b) -> PrimExp a -> PrimExp b Source # (<$) :: a -> PrimExp b -> PrimExp a Source #
Show v => Show (PrimExp v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods showsPrec :: Int -> PrimExp v -> ShowS Source # show :: PrimExp v -> String Source # showList :: [PrimExp v] -> ShowS Source #
ToExp (PrimExp VName) Source # |
Instance details Defined in Futhark.CodeGen.ImpGen Methods toExp :: PrimExp VName -> ImpM rep r op Exp Source # toExp' :: PrimType -> PrimExp VName -> Exp Source #
ToExp v => ToExp (PrimExp v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp.Convert Methods toExp :: MonadBuilder m => PrimExp v -> m (Exp (Rep m)) Source #
FreeIn v => FreeIn (PrimExp v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods freeIn' :: PrimExp v -> FV Source #
Substitute v => Substitute (PrimExp v) Source # |
Instance details Defined in Futhark.Transform.Substitute Methods substituteNames :: Map VName VName -> PrimExp v -> PrimExp v Source #
Eq v => Eq (PrimExp v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods (==) :: PrimExp v -> PrimExp v -> Bool Source # (/=) :: PrimExp v -> PrimExp v -> Bool Source #
Ord v => Ord (PrimExp v) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

compare :: PrimExp v -> PrimExp v -> Ordering Source #

(<) :: PrimExp v -> PrimExp v -> Bool Source #

(<=) :: PrimExp v -> PrimExp v -> Bool Source #

(>) :: PrimExp v -> PrimExp v -> Bool Source #

(>=) :: PrimExp v -> PrimExp v -> Bool Source #

max :: PrimExp v -> PrimExp v -> PrimExp v Source #

min :: PrimExp v -> PrimExp v -> PrimExp v Source #

Pretty v => Pretty (PrimExp v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods pretty :: PrimExp v -> Doc ann Source # prettyList :: [PrimExp v] -> Doc ann Source #

newtype TPrimExp t v Source #

A `PrimExp` tagged with a phantom type used to provide type-safe construction. Does not guarantee that the underlying expression is actually type correct.

Constructors

TPrimExp |

Fields

- untyped :: PrimExp v

#### Instances

Instances details

Foldable (TPrimExp t) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

fold :: Monoid m => TPrimExp t m -> m Source #

foldMap :: Monoid m => (a -> m) -> TPrimExp t a -> m Source #

foldMap' :: Monoid m => (a -> m) -> TPrimExp t a -> m Source #

foldr :: (a -> b -> b) -> b -> TPrimExp t a -> b Source #

foldr' :: (a -> b -> b) -> b -> TPrimExp t a -> b Source #

foldl :: (b -> a -> b) -> b -> TPrimExp t a -> b Source #

foldl' :: (b -> a -> b) -> b -> TPrimExp t a -> b Source #

foldr1 :: (a -> a -> a) -> TPrimExp t a -> a Source #

foldl1 :: (a -> a -> a) -> TPrimExp t a -> a Source #

toList :: TPrimExp t a -> [a] Source #

null :: TPrimExp t a -> Bool Source #

length :: TPrimExp t a -> Int Source #

elem :: Eq a => a -> TPrimExp t a -> Bool Source #

maximum :: Ord a => TPrimExp t a -> a Source #

minimum :: Ord a => TPrimExp t a -> a Source #

sum :: Num a => TPrimExp t a -> a Source #

product :: Num a => TPrimExp t a -> a Source #

Traversable (TPrimExp t) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods traverse :: Applicative f => (a -> f b) -> TPrimExp t a -> f (TPrimExp t b) Source # sequenceA :: Applicative f => TPrimExp t (f a) -> f (TPrimExp t a) Source # mapM :: Monad m => (a -> m b) -> TPrimExp t a -> m (TPrimExp t b) Source # sequence :: Monad m => TPrimExp t (m a) -> m (TPrimExp t a) Source #
Functor (TPrimExp t) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fmap :: (a -> b) -> TPrimExp t a -> TPrimExp t b Source # (<$) :: a -> TPrimExp t b -> TPrimExp t a Source #
ToExp (TExp t) Source # |
Instance details Defined in Futhark.CodeGen.Backends.GenericC.Code Methods toExp :: TExp t -> SrcLoc -> Exp Source #
Pretty v => Floating (TPrimExp Half v) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

pi :: TPrimExp Half v Source #

exp :: TPrimExp Half v -> TPrimExp Half v Source #

log :: TPrimExp Half v -> TPrimExp Half v Source #

sqrt :: TPrimExp Half v -> TPrimExp Half v Source #

(**) :: TPrimExp Half v -> TPrimExp Half v -> TPrimExp Half v Source #

logBase :: TPrimExp Half v -> TPrimExp Half v -> TPrimExp Half v Source #

sin :: TPrimExp Half v -> TPrimExp Half v Source #

cos :: TPrimExp Half v -> TPrimExp Half v Source #

tan :: TPrimExp Half v -> TPrimExp Half v Source #

asin :: TPrimExp Half v -> TPrimExp Half v Source #

acos :: TPrimExp Half v -> TPrimExp Half v Source #

atan :: TPrimExp Half v -> TPrimExp Half v Source #

sinh :: TPrimExp Half v -> TPrimExp Half v Source #

cosh :: TPrimExp Half v -> TPrimExp Half v Source #

tanh :: TPrimExp Half v -> TPrimExp Half v Source #

asinh :: TPrimExp Half v -> TPrimExp Half v Source #

acosh :: TPrimExp Half v -> TPrimExp Half v Source #

atanh :: TPrimExp Half v -> TPrimExp Half v Source #

log1p :: TPrimExp Half v -> TPrimExp Half v Source #

expm1 :: TPrimExp Half v -> TPrimExp Half v Source #

log1pexp :: TPrimExp Half v -> TPrimExp Half v Source #

log1mexp :: TPrimExp Half v -> TPrimExp Half v Source #

Pretty v => Floating (TPrimExp Double v) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

pi :: TPrimExp Double v Source #

exp :: TPrimExp Double v -> TPrimExp Double v Source #

log :: TPrimExp Double v -> TPrimExp Double v Source #

sqrt :: TPrimExp Double v -> TPrimExp Double v Source #

(**) :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v Source #

logBase :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v Source #

sin :: TPrimExp Double v -> TPrimExp Double v Source #

cos :: TPrimExp Double v -> TPrimExp Double v Source #

tan :: TPrimExp Double v -> TPrimExp Double v Source #

asin :: TPrimExp Double v -> TPrimExp Double v Source #

acos :: TPrimExp Double v -> TPrimExp Double v Source #

atan :: TPrimExp Double v -> TPrimExp Double v Source #

sinh :: TPrimExp Double v -> TPrimExp Double v Source #

cosh :: TPrimExp Double v -> TPrimExp Double v Source #

tanh :: TPrimExp Double v -> TPrimExp Double v Source #

asinh :: TPrimExp Double v -> TPrimExp Double v Source #

acosh :: TPrimExp Double v -> TPrimExp Double v Source #

atanh :: TPrimExp Double v -> TPrimExp Double v Source #

log1p :: TPrimExp Double v -> TPrimExp Double v Source #

expm1 :: TPrimExp Double v -> TPrimExp Double v Source #

log1pexp :: TPrimExp Double v -> TPrimExp Double v Source #

log1mexp :: TPrimExp Double v -> TPrimExp Double v Source #

Pretty v => Floating (TPrimExp Float v) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

pi :: TPrimExp Float v Source #

exp :: TPrimExp Float v -> TPrimExp Float v Source #

log :: TPrimExp Float v -> TPrimExp Float v Source #

sqrt :: TPrimExp Float v -> TPrimExp Float v Source #

(**) :: TPrimExp Float v -> TPrimExp Float v -> TPrimExp Float v Source #

logBase :: TPrimExp Float v -> TPrimExp Float v -> TPrimExp Float v Source #

sin :: TPrimExp Float v -> TPrimExp Float v Source #

cos :: TPrimExp Float v -> TPrimExp Float v Source #

tan :: TPrimExp Float v -> TPrimExp Float v Source #

asin :: TPrimExp Float v -> TPrimExp Float v Source #

acos :: TPrimExp Float v -> TPrimExp Float v Source #

atan :: TPrimExp Float v -> TPrimExp Float v Source #

sinh :: TPrimExp Float v -> TPrimExp Float v Source #

cosh :: TPrimExp Float v -> TPrimExp Float v Source #

tanh :: TPrimExp Float v -> TPrimExp Float v Source #

asinh :: TPrimExp Float v -> TPrimExp Float v Source #

acosh :: TPrimExp Float v -> TPrimExp Float v Source #

atanh :: TPrimExp Float v -> TPrimExp Float v Source #

log1p :: TPrimExp Float v -> TPrimExp Float v Source #

expm1 :: TPrimExp Float v -> TPrimExp Float v Source #

log1pexp :: TPrimExp Float v -> TPrimExp Float v Source #

log1mexp :: TPrimExp Float v -> TPrimExp Float v Source #

(NumExp t, Pretty v) => Num (TPrimExp t v) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

(+) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

(-) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

(*) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

negate :: TPrimExp t v -> TPrimExp t v Source #

abs :: TPrimExp t v -> TPrimExp t v Source #

signum :: TPrimExp t v -> TPrimExp t v Source #

fromInteger :: Integer -> TPrimExp t v Source #

(FloatExp t, Pretty v) => Fractional (TPrimExp t v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods (/) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source # recip :: TPrimExp t v -> TPrimExp t v Source # fromRational :: Rational -> TPrimExp t v Source #
Show v => Show (TPrimExp t v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods showsPrec :: Int -> TPrimExp t v -> ShowS Source # show :: TPrimExp t v -> String Source # showList :: [TPrimExp t v] -> ShowS Source #
ToExp v => ToExp (TPrimExp t v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp.Convert Methods toExp :: MonadBuilder m => TPrimExp t v -> m (Exp (Rep m)) Source #
FreeIn v => FreeIn (TPrimExp t v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods freeIn' :: TPrimExp t v -> FV Source #
Substitute v => Substitute (TPrimExp t v) Source # |
Instance details Defined in Futhark.Transform.Substitute Methods substituteNames :: Map VName VName -> TPrimExp t v -> TPrimExp t v Source #
(IntExp t, Pretty v) => IntegralExp (TPrimExp t v) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

quot :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

rem :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

div :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

mod :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

sgn :: TPrimExp t v -> Maybe Int Source #

pow :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

divUp :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

nextMul :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Eq v => Eq (TPrimExp t v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods (==) :: TPrimExp t v -> TPrimExp t v -> Bool Source # (/=) :: TPrimExp t v -> TPrimExp t v -> Bool Source #
Ord v => Ord (TPrimExp t v) Source # |

Instance details

Defined in Futhark.Analysis.PrimExp

Methods

compare :: TPrimExp t v -> TPrimExp t v -> Ordering Source #

(<) :: TPrimExp t v -> TPrimExp t v -> Bool Source #

(<=) :: TPrimExp t v -> TPrimExp t v -> Bool Source #

(>) :: TPrimExp t v -> TPrimExp t v -> Bool Source #

(>=) :: TPrimExp t v -> TPrimExp t v -> Bool Source #

max :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

min :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Pretty v => Pretty (TPrimExp t v) Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods pretty :: TPrimExp t v -> Doc ann Source # prettyList :: [TPrimExp t v] -> Doc ann Source #

isInt8 :: PrimExp v -> TPrimExp Int8 v Source #

This expression is of type `Int8`.

isInt16 :: PrimExp v -> TPrimExp Int16 v Source #

This expression is of type `Int16`.

isInt32 :: PrimExp v -> TPrimExp Int32 v Source #

This expression is of type `Int32`.

isInt64 :: PrimExp v -> TPrimExp Int64 v Source #

This expression is of type `Int64`.

isBool :: PrimExp v -> TPrimExp Bool v Source #

This is a boolean expression.

isF16 :: PrimExp v -> TPrimExp Half v Source #

This expression is of type `Half`.

isF32 :: PrimExp v -> TPrimExp Float v Source #

This expression is of type `Float`.

isF64 :: PrimExp v -> TPrimExp Double v Source #

This expression is of type `Double`.

evalPrimExp :: (Pretty v, MonadFail m) => (v -> m PrimValue) -> PrimExp v -> m PrimValue Source #

Evaluate a `PrimExp` in the given monad. Invokes `fail` on type errors.

primExpType :: PrimExp v -> PrimType Source #

The type of values returned by a `PrimExp`. This function returning does not imply that the `PrimExp` is type-correct.

primExpSizeAtLeast :: Int -> PrimExp v -> Bool Source #

True if the `PrimExp` has at least this many nodes. This can be much more efficient than comparing with `length` for large `PrimExp`s, as this function is lazy.

coerceIntPrimExp :: IntType -> PrimExp v -> PrimExp v Source #

If the given `PrimExp` is a constant of the wrong integer type, coerce it to the given integer type. This is a workaround for an issue in the `Num` instance.

leafExpTypes :: Ord a => PrimExp a -> Set (a, PrimType) Source #

Produce a mapping from the leaves of the `PrimExp` to their designated types.

true :: TPrimExp Bool v Source #

Boolean-valued PrimExps.

false :: TPrimExp Bool v Source #

Boolean-valued PrimExps.

fromBool :: Bool -> TPrimExp Bool v Source #

Conversion from Bool to `TPrimExp`

constFoldPrimExp :: PrimExp v -> PrimExp v Source #

Perform quick and dirty constant folding on the top level of a PrimExp. This is necessary because we want to consider e.g. equality modulo constant folding.

# Construction

module Language.Futhark.Primitive

class NumExp t where Source #

The class of numeric types that can be used for constructing `TPrimExp`s.

Methods

fromInteger' :: Integer -> TPrimExp t v Source #

Construct a typed expression from an integer.

fromBoolExp :: TPrimExp Bool v -> TPrimExp t v Source #

Construct a numeric expression from a boolean expression. This can be used to encode arithmetic control flow.

#### Instances

Instances details

NumExp Int16 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromInteger' :: Integer -> TPrimExp Int16 v Source # fromBoolExp :: TPrimExp Bool v -> TPrimExp Int16 v Source #
NumExp Int32 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromInteger' :: Integer -> TPrimExp Int32 v Source # fromBoolExp :: TPrimExp Bool v -> TPrimExp Int32 v Source #
NumExp Int64 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromInteger' :: Integer -> TPrimExp Int64 v Source # fromBoolExp :: TPrimExp Bool v -> TPrimExp Int64 v Source #
NumExp Int8 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromInteger' :: Integer -> TPrimExp Int8 v Source # fromBoolExp :: TPrimExp Bool v -> TPrimExp Int8 v Source #
NumExp Half Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromInteger' :: Integer -> TPrimExp Half v Source # fromBoolExp :: TPrimExp Bool v -> TPrimExp Half v Source #
NumExp Double Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromInteger' :: Integer -> TPrimExp Double v Source # fromBoolExp :: TPrimExp Bool v -> TPrimExp Double v Source #
NumExp Float Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromInteger' :: Integer -> TPrimExp Float v Source # fromBoolExp :: TPrimExp Bool v -> TPrimExp Float v Source #

class NumExp t => IntExp t where Source #

The class of integer types that can be used for constructing `TPrimExp`s.

Methods

expIntType :: TPrimExp t v -> IntType Source #

The type of an expression, known to be an integer type.

#### Instances

Instances details

IntExp Int16 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods expIntType :: TPrimExp Int16 v -> IntType Source #
IntExp Int32 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods expIntType :: TPrimExp Int32 v -> IntType Source #
IntExp Int64 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods expIntType :: TPrimExp Int64 v -> IntType Source #
IntExp Int8 Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods expIntType :: TPrimExp Int8 v -> IntType Source #

class NumExp t => FloatExp t where Source #

The class of floating-point types that can be used for constructing `TPrimExp`s.

Methods

fromRational' :: Rational -> TPrimExp t v Source #

Construct a typed expression from a rational.

expFloatType :: TPrimExp t v -> FloatType Source #

The type of an expression, known to be a floating-point type.

#### Instances

Instances details

FloatExp Half Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromRational' :: Rational -> TPrimExp Half v Source # expFloatType :: TPrimExp Half v -> FloatType Source #
FloatExp Double Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromRational' :: Rational -> TPrimExp Double v Source # expFloatType :: TPrimExp Double v -> FloatType Source #
FloatExp Float Source # |
Instance details Defined in Futhark.Analysis.PrimExp Methods fromRational' :: Rational -> TPrimExp Float v Source # expFloatType :: TPrimExp Float v -> FloatType Source #

sExt :: IntType -> PrimExp v -> PrimExp v Source #

Untyped smart constructor for sign extension that does a bit of constant folding.

zExt :: IntType -> PrimExp v -> PrimExp v Source #

Untyped smart constructor for zero extension that does a bit of constant folding.

(.&&.) :: Eq v => TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v infixr 3 Source #

Lifted logical conjunction.

(.||.) :: Eq v => TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v infixr 2 Source #

Lifted logical conjunction.

(.<.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #

Lifted relational operators; assuming signed numbers in case of integers.

(.<=.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #

Lifted relational operators; assuming signed numbers in case of integers.

(.>.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #

Lifted relational operators; assuming signed numbers in case of integers.

(.>=.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #

Lifted relational operators; assuming signed numbers in case of integers.

(.==.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #

Lifted relational operators; assuming signed numbers in case of integers.

(.&.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Lifted bitwise operators. The right-shift is logical, *not* arithmetic.

(.|.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Lifted bitwise operators. The right-shift is logical, *not* arithmetic.

(.^.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Lifted bitwise operators. The right-shift is logical, *not* arithmetic.

(.>>.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Lifted bitwise operators. The right-shift is logical, *not* arithmetic.

(.<<.) :: Eq v => TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Lifted bitwise operators. The right-shift is logical, *not* arithmetic.

bNot :: TPrimExp Bool v -> TPrimExp Bool v Source #

Boolean negation smart constructor.

sMax32 :: TPrimExp Int32 v -> TPrimExp Int32 v -> TPrimExp Int32 v Source #

SMax on 32-bit integers.

sMin32 :: TPrimExp Int32 v -> TPrimExp Int32 v -> TPrimExp Int32 v Source #

SMin on 32-bit integers.

sMax64 :: TPrimExp Int64 v -> TPrimExp Int64 v -> TPrimExp Int64 v Source #

SMax on 64-bit integers.

sMin64 :: TPrimExp Int64 v -> TPrimExp Int64 v -> TPrimExp Int64 v Source #

SMin on 64-bit integers.

sExt32 :: IntExp t => TPrimExp t v -> TPrimExp Int32 v Source #

Sign-extend to 32 bit integer.

sExt64 :: IntExp t => TPrimExp t v -> TPrimExp Int64 v Source #

Sign-extend to 64 bit integer.

zExt32 :: IntExp t => TPrimExp t v -> TPrimExp Int32 v Source #

Zero-extend to 32 bit integer.

zExt64 :: IntExp t => TPrimExp t v -> TPrimExp Int64 v Source #

Zero-extend to 64 bit integer.

sExtAs :: (IntExp to, IntExp from) => TPrimExp from v -> TPrimExp to v -> TPrimExp to v Source #

Convert result of some integer expression to have the same type as another, using sign extension.

fMin16 :: TPrimExp Half v -> TPrimExp Half v -> TPrimExp Half v Source #

16-bit float minimum.

fMin32 :: TPrimExp Float v -> TPrimExp Float v -> TPrimExp Float v Source #

32-bit float minimum.

fMin64 :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v Source #

64-bit float minimum.

fMax16 :: TPrimExp Half v -> TPrimExp Half v -> TPrimExp Half v Source #

16-bit float maximum.

fMax32 :: TPrimExp Float v -> TPrimExp Float v -> TPrimExp Float v Source #

32-bit float maximum.

fMax64 :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v Source #

64-bit float maximum.

condExp :: TPrimExp Bool v -> TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #

Conditional expression.

# Untyped construction

(~*~) :: PrimExp v -> PrimExp v -> PrimExp v infix 7 Source #

Multiplication of untyped `PrimExp`s, which must have the same type. Uses `OverflowWrap` for integer operations.

(~/~) :: PrimExp v -> PrimExp v -> PrimExp v infix 7 Source #

Division of untyped `PrimExp`s, which must have the same type. For integers, this is unsafe signed division.

(~+~) :: PrimExp v -> PrimExp v -> PrimExp v infix 6 Source #

Addition of untyped `PrimExp`s, which must have the same type. Uses `OverflowWrap` for integer operations.

(~-~) :: PrimExp v -> PrimExp v -> PrimExp v infix 6 Source #

Subtraction of untyped `PrimExp`s, which must have the same type. Uses `OverflowWrap` for integer operations.

(~==~) :: PrimExp v -> PrimExp v -> PrimExp v infix 4 Source #

Equality of untyped `PrimExp`s, which must have the same type.