Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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
- 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
- (~*~) :: 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
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 Language.Futhark.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 Int16 Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Int32 Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Int64 Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Int8 Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Half Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Double Source # | |
Defined in Futhark.Analysis.PrimExp | |
NumExp Float Source # | |
Defined in Futhark.Analysis.PrimExp |
class NumExp t => IntExp t where Source #
The class of integer types that can be used for constructing
TPrimExp
s.
expIntType :: TPrimExp t v -> IntType Source #
The type of an expression, known to be an integer type.
Instances
IntExp Int16 Source # | |
Defined in Futhark.Analysis.PrimExp | |
IntExp Int32 Source # | |
Defined in Futhark.Analysis.PrimExp | |
IntExp Int64 Source # | |
Defined in Futhark.Analysis.PrimExp | |
IntExp Int8 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.
expFloatType :: TPrimExp t v -> FloatType Source #
The type of an expression, known to be a floating-point type.
Instances
FloatExp Half Source # | |
Defined in Futhark.Analysis.PrimExp | |
FloatExp Double Source # | |
Defined in Futhark.Analysis.PrimExp | |
FloatExp Float Source # | |
Defined in Futhark.Analysis.PrimExp |
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.
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.
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.