Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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
- newtype TPrimExp t v = TPrimExp {}
- 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
- 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
- constFoldPrimExp :: PrimExp v -> PrimExp v
- module Futhark.IR.Primitive
- class NumExp t where
- fromInteger' :: Integer -> TPrimExp t v
- fromBoolExp :: TPrimExp Bool v -> TPrimExp t v
- class NumExp t => IntExp t
- class NumExp t => FloatExp t where
- fromRational' :: Rational -> TPrimExp t v
- sExt :: IntType -> PrimExp v -> PrimExp v
- zExt :: IntType -> PrimExp v -> PrimExp v
- (.&&.) :: TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v
- (.||.) :: TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v
- (.<.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.<=.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.>.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.>=.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.==.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v
- (.&.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (.|.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (.^.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v
- (.>>.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t 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
- fMin64 :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v
- fMax64 :: TPrimExp Double v -> TPrimExp Double v -> TPrimExp Double v
Documentation
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!
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 String [PrimExp v] PrimType |
Instances
A PrimExp
tagged with a phantom type used to provide type-safe
construction. Does not guarantee that the underlying expression is
actually type correct.
Instances
primExpType :: PrimExp v -> PrimType Source #
leafExpTypes :: Ord a => PrimExp a -> Set (a, PrimType) Source #
Produce a mapping from the leaves of the PrimExp
to their
designated types.
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 Futhark.IR.Primitive
The class of numeric types that can be used for constructing
TPrimExp
s.
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
NumExp Double Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Float Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Int8 Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Int16 Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Int32 Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Int64 Source # | |
Defined in Futhark.Analysis.PrimExp |
class NumExp t => IntExp t Source #
The class of integer types that can be used for constructing
TPrimExp
s.
Instances
IntExp Int8 Source # | |
Defined in Futhark.Analysis.PrimExp | |
IntExp Int16 Source # | |
Defined in Futhark.Analysis.PrimExp | |
IntExp Int32 Source # | |
Defined in Futhark.Analysis.PrimExp | |
IntExp Int64 Source # | |
Defined in Futhark.Analysis.PrimExp |
class NumExp t => FloatExp t where Source #
The class of floating-point types that can be used for
constructing TPrimExp
s.
fromRational' :: Rational -> TPrimExp t v Source #
Construct a typed expression from a rational.
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.
(.&&.) :: TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v infixr 3 Source #
Lifted logical conjunction.
(.||.) :: TPrimExp Bool v -> TPrimExp Bool v -> TPrimExp Bool v infixr 2 Source #
Lifted logical conjunction.
(.<.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.<=.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.>.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.>=.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.==.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp Bool v infix 4 Source #
Lifted relational operators; assuming signed numbers in case of integers.
(.&.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #
Lifted bitwise operators. The right-shift is logical, *not* arithmetic.
(.|.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #
Lifted bitwise operators. The right-shift is logical, *not* arithmetic.
(.^.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #
Lifted bitwise operators. The right-shift is logical, *not* arithmetic.
(.>>.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #
Lifted bitwise operators. The right-shift is logical, *not* arithmetic.