Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Sequential imperative code.
Synopsis
- type Program = Definitions Sequential
- type Function = Function Sequential
- data FunctionT a = Function Bool [Param] [Param] (Code a) [ExternalValue] [ExternalValue]
- type Code = Code Sequential
- data Sequential
- data Int8
- data Int16
- data Int32
- data Int64
- data Word8
- data Word16
- data Word32
- data Word64
- srclocOf :: Located a => a -> SrcLoc
- data Loc
- data SrcLoc
- class Located a where
- pretty :: Pretty a => a -> String
- data ConvOp
- data CmpOp
- data BinOp
- = Add IntType Overflow
- | FAdd FloatType
- | Sub IntType Overflow
- | FSub FloatType
- | Mul IntType Overflow
- | FMul FloatType
- | UDiv IntType Safety
- | UDivUp IntType Safety
- | SDiv IntType Safety
- | SDivUp IntType Safety
- | FDiv FloatType
- | FMod FloatType
- | UMod IntType Safety
- | SMod IntType Safety
- | SQuot IntType Safety
- | SRem IntType Safety
- | SMin IntType
- | UMin IntType
- | FMin FloatType
- | SMax IntType
- | UMax IntType
- | FMax FloatType
- | Shl IntType
- | LShr IntType
- | AShr IntType
- | And IntType
- | Or IntType
- | Xor IntType
- | Pow IntType
- | FPow FloatType
- | LogAnd
- | LogOr
- data Safety
- data Overflow
- data UnOp
- data PrimValue
- = IntValue !IntValue
- | FloatValue !FloatValue
- | BoolValue !Bool
- | Checked
- data FloatValue
- data IntValue
- = Int8Value !Int8
- | Int16Value !Int16
- | Int32Value !Int32
- | Int64Value !Int64
- data PrimType
- data FloatType
- data IntType
- allIntTypes :: [IntType]
- allFloatTypes :: [FloatType]
- allPrimTypes :: [PrimType]
- intValue :: Integral int => IntType -> int -> IntValue
- intValueType :: IntValue -> IntType
- valueIntegral :: Integral int => IntValue -> int
- floatValue :: Real num => FloatType -> num -> FloatValue
- floatValueType :: FloatValue -> FloatType
- primValueType :: PrimValue -> PrimType
- blankPrimValue :: PrimType -> PrimValue
- allUnOps :: [UnOp]
- allBinOps :: [BinOp]
- allCmpOps :: [CmpOp]
- allConvOps :: [ConvOp]
- doUnOp :: UnOp -> PrimValue -> Maybe PrimValue
- doComplement :: IntValue -> IntValue
- doAbs :: IntValue -> IntValue
- doFAbs :: FloatValue -> FloatValue
- doSSignum :: IntValue -> IntValue
- doUSignum :: IntValue -> IntValue
- doBinOp :: BinOp -> PrimValue -> PrimValue -> Maybe PrimValue
- doAdd :: IntValue -> IntValue -> IntValue
- doMul :: IntValue -> IntValue -> IntValue
- doSDiv :: IntValue -> IntValue -> Maybe IntValue
- doSMod :: IntValue -> IntValue -> Maybe IntValue
- doPow :: IntValue -> IntValue -> Maybe IntValue
- doConvOp :: ConvOp -> PrimValue -> Maybe PrimValue
- doZExt :: IntValue -> IntType -> IntValue
- doSExt :: IntValue -> IntType -> IntValue
- doFPConv :: FloatValue -> FloatType -> FloatValue
- doFPToUI :: FloatValue -> IntType -> IntValue
- doFPToSI :: FloatValue -> IntType -> IntValue
- doUIToFP :: IntValue -> FloatType -> FloatValue
- doSIToFP :: IntValue -> FloatType -> FloatValue
- doCmpOp :: CmpOp -> PrimValue -> PrimValue -> Maybe Bool
- doCmpEq :: PrimValue -> PrimValue -> Bool
- doCmpUlt :: IntValue -> IntValue -> Bool
- doCmpUle :: IntValue -> IntValue -> Bool
- doCmpSlt :: IntValue -> IntValue -> Bool
- doCmpSle :: IntValue -> IntValue -> Bool
- doFCmpLt :: FloatValue -> FloatValue -> Bool
- doFCmpLe :: FloatValue -> FloatValue -> Bool
- intToWord64 :: IntValue -> Word64
- intToInt64 :: IntValue -> Int64
- binOpType :: BinOp -> PrimType
- cmpOpType :: CmpOp -> PrimType
- unOpType :: UnOp -> PrimType
- convOpType :: ConvOp -> (PrimType, PrimType)
- primFuns :: Map String ([PrimType], PrimType, [PrimValue] -> Maybe PrimValue)
- zeroIsh :: PrimValue -> Bool
- oneIsh :: PrimValue -> Bool
- negativeIsh :: PrimValue -> Bool
- zeroIshInt :: IntValue -> Bool
- oneIshInt :: IntValue -> Bool
- primBitSize :: PrimType -> Int
- primByteSize :: Num a => PrimType -> a
- intByteSize :: Num a => IntType -> a
- floatByteSize :: Num a => FloatType -> a
- commutativeBinOp :: BinOp -> Bool
- convOpFun :: ConvOp -> String
- prettySigned :: Bool -> PrimType -> String
- data VName = VName !Name !Int
- data Name
- data Commutativity
- data Uniqueness
- defaultEntryPoint :: Name
- nameToString :: Name -> String
- nameFromString :: String -> Name
- nameToText :: Name -> Text
- nameFromText :: Text -> Name
- locStr :: Located a => a -> String
- locStrRel :: (Located a, Located b) => a -> b -> String
- prettyStacktrace :: Int -> [String] -> String
- baseTag :: VName -> Int
- baseName :: VName -> Name
- baseString :: VName -> String
- quote :: String -> String
- pquote :: Doc -> Doc
- data ErrorMsgPart a
- = ErrorString String
- | ErrorInt32 a
- | ErrorInt64 a
- newtype ErrorMsg a = ErrorMsg [ErrorMsgPart a]
- data SubExp
- type SpaceId = String
- data Space
- errorMsgArgTypes :: ErrorMsg a -> [PrimType]
- class FreeIn dec => FreeDec dec where
- precomputed :: dec -> FV -> FV
- class FreeIn a where
- data FV
- data Names
- namesIntMap :: Names -> IntMap VName
- nameIn :: VName -> Names -> Bool
- namesFromList :: [VName] -> Names
- namesToList :: Names -> [VName]
- oneName :: VName -> Names
- namesIntersection :: Names -> Names -> Names
- namesIntersect :: Names -> Names -> Bool
- namesSubtract :: Names -> Names -> Names
- mapNames :: (VName -> VName) -> Names -> Names
- fvBind :: Names -> FV -> FV
- fvName :: VName -> FV
- fvNames :: Names -> FV
- freeInStmsAndRes :: (FreeIn (Op lore), FreeIn (LetDec lore), FreeIn (LParamInfo lore), FreeIn (FParamInfo lore), FreeDec (BodyDec lore), FreeDec (ExpDec lore)) => Stms lore -> Result -> FV
- freeIn :: FreeIn a => a -> Names
- boundInBody :: Body lore -> Names
- boundByStm :: Stm lore -> Names
- boundByStms :: Stms lore -> Names
- boundByLambda :: Lambda lore -> [VName]
- class NumExp t => FloatExp t where
- fromRational' :: Rational -> TPrimExp t v
- class NumExp t => IntExp t
- class NumExp t where
- fromInteger' :: Integer -> TPrimExp t v
- fromBoolExp :: TPrimExp Bool v -> TPrimExp t v
- newtype TPrimExp t v = TPrimExp {}
- data 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
- isF32 :: PrimExp v -> TPrimExp Float v
- isF64 :: PrimExp v -> TPrimExp Double v
- primExpSizeAtLeast :: Int -> PrimExp v -> Bool
- constFoldPrimExp :: 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
- sExt :: IntType -> PrimExp v -> PrimExp v
- zExt :: IntType -> PrimExp v -> PrimExp v
- evalPrimExp :: (Pretty v, MonadFail m) => (v -> m PrimValue) -> PrimExp v -> m PrimValue
- primExpType :: PrimExp v -> PrimType
- coerceIntPrimExp :: IntType -> PrimExp v -> PrimExp v
- true :: TPrimExp Bool v
- false :: TPrimExp Bool 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
- leafExpTypes :: Ord a => PrimExp a -> Set (a, PrimType)
- newtype Count u e = Count {
- unCount :: e
- data Bytes
- data Elements
- data Arg
- type TExp t = TPrimExp t ExpLeaf
- type Exp = PrimExp ExpLeaf
- data ExpLeaf
- data Volatility
- pattern DebugPrint :: String -> Maybe Exp -> Code a
- pattern Call :: [VName] -> Name -> [Arg] -> Code a
- pattern SetMem :: VName -> VName -> Space -> Code a
- pattern SetScalar :: VName -> Exp -> Code a
- pattern DeclareArray :: VName -> Space -> PrimType -> ArrayContents -> Code a
- pattern DeclareScalar :: VName -> Volatility -> PrimType -> Code a
- pattern DeclareMem :: VName -> Space -> Code a
- pattern (:>>:) :: Code a -> Code a -> Code a
- pattern Assert :: Exp -> ErrorMsg Exp -> (SrcLoc, [SrcLoc]) -> Code a
- pattern Copy :: VName -> Count Bytes (TExp Int64) -> Space -> VName -> Count Bytes (TExp Int64) -> Space -> Count Bytes (TExp Int64) -> Code a
- pattern Allocate :: VName -> Count Bytes (TExp Int64) -> Space -> Code a
- pattern Skip :: Code a
- pattern For :: VName -> Exp -> Code a -> Code a
- pattern While :: TExp Bool -> Code a -> Code a
- pattern Free :: VName -> Space -> Code a
- pattern Comment :: String -> Code a -> Code a
- pattern Write :: VName -> Count Elements (TExp Int64) -> PrimType -> Space -> Volatility -> Exp -> Code a
- pattern If :: TExp Bool -> Code a -> Code a -> Code a
- pattern Op :: a -> Code a
- data ArrayContents
- data FunctionT a
- data ExternalValue
- data ValueDesc
- data Signedness
- data Constants a = Constants {
- constsDecl :: [Param]
- constsInit :: Code a
- newtype Functions a = Functions [(Name, Function a)]
- data Definitions a = Definitions {}
- data Param
- type DimSize = SubExp
- type MemSize = SubExp
- paramName :: Param -> VName
- lexicalMemoryUsage :: Function a -> Map VName Space
- calledFuncs :: Code a -> Set Name
- elements :: a -> Count Elements a
- bytes :: a -> Count Bytes a
- withElemType :: Count Elements (TExp Int64) -> PrimType -> Count Bytes (TExp Int64)
- var :: VName -> PrimType -> Exp
- vi32 :: VName -> TExp Int32
- vi64 :: VName -> TExp Int64
- index :: VName -> Count Elements (TExp Int64) -> PrimType -> Space -> Volatility -> Exp
- declaredIn :: Code a -> Names
Documentation
type Program = Definitions Sequential Source #
An imperative program.
type Function = Function Sequential Source #
An imperative function.
A imperative function, containing the body as well as its low-level inputs and outputs, as well as its high-level arguments and results. The latter are only used if the function is an entry point.
Function Bool [Param] [Param] (Code a) [ExternalValue] [ExternalValue] |
Instances
Functor FunctionT Source # | |
Foldable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode fold :: Monoid m => FunctionT m -> m # foldMap :: Monoid m => (a -> m) -> FunctionT a -> m # foldMap' :: Monoid m => (a -> m) -> FunctionT a -> m # foldr :: (a -> b -> b) -> b -> FunctionT a -> b # foldr' :: (a -> b -> b) -> b -> FunctionT a -> b # foldl :: (b -> a -> b) -> b -> FunctionT a -> b # foldl' :: (b -> a -> b) -> b -> FunctionT a -> b # foldr1 :: (a -> a -> a) -> FunctionT a -> a # foldl1 :: (a -> a -> a) -> FunctionT a -> a # toList :: FunctionT a -> [a] # length :: FunctionT a -> Int # elem :: Eq a => a -> FunctionT a -> Bool # maximum :: Ord a => FunctionT a -> a # minimum :: Ord a => FunctionT a -> a # | |
Traversable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode | |
Show a => Show (FunctionT a) Source # | |
Pretty op => Pretty (FunctionT op) Source # | |
type Code = Code Sequential Source #
A piece of imperative code.
data Sequential Source #
Phantom type for identifying sequential imperative code.
Instances
Pretty Sequential Source # | |
Defined in Futhark.CodeGen.ImpCode.Sequential | |
FreeIn Sequential Source # | |
Defined in Futhark.CodeGen.ImpCode.Sequential freeIn' :: Sequential -> FV Source # |
8-bit signed integer type
Instances
16-bit signed integer type
Instances
32-bit signed integer type
Instances
64-bit signed integer type
Instances
8-bit unsigned integer type
Instances
16-bit unsigned integer type
Instances
32-bit unsigned integer type
Instances
64-bit unsigned integer type
Instances
Location type, consisting of a beginning position and an end position.
Instances
Eq Loc | |
Data Loc | |
Defined in Data.Loc gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Loc -> c Loc # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Loc # dataTypeOf :: Loc -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Loc) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Loc) # gmapT :: (forall b. Data b => b -> b) -> Loc -> Loc # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r # gmapQ :: (forall d. Data d => d -> u) -> Loc -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Loc -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Loc -> m Loc # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc # | |
Read Loc | |
Show Loc | |
Semigroup Loc | |
Monoid Loc | |
Pretty Loc | |
IsLocation Loc | |
Located Loc | |
Source location type. Source location are all equal, which allows AST nodes to be compared modulo location information.
Instances
Eq SrcLoc | |
Data SrcLoc | |
Defined in Data.Loc gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SrcLoc -> c SrcLoc # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SrcLoc # toConstr :: SrcLoc -> Constr # dataTypeOf :: SrcLoc -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SrcLoc) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SrcLoc) # gmapT :: (forall b. Data b => b -> b) -> SrcLoc -> SrcLoc # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SrcLoc -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SrcLoc -> r # gmapQ :: (forall d. Data d => d -> u) -> SrcLoc -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> SrcLoc -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> SrcLoc -> m SrcLoc # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcLoc -> m SrcLoc # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SrcLoc -> m SrcLoc # | |
Ord SrcLoc | |
Read SrcLoc | |
Show SrcLoc | |
Semigroup SrcLoc | |
Monoid SrcLoc | |
IsLocation SrcLoc | |
Located SrcLoc | |
ToIdent (SrcLoc -> Id) | |
Located values have a location.
Instances
Conversion operators try to generalise the from t0 x to t1
instructions from LLVM.
ZExt IntType IntType | Zero-extend the former integer type to the latter. If the new type is smaller, the result is a truncation. |
SExt IntType IntType | Sign-extend the former integer type to the latter. If the new type is smaller, the result is a truncation. |
FPConv FloatType FloatType | Convert value of the former floating-point type to the latter. If the new type is smaller, the result is a truncation. |
FPToUI FloatType IntType | Convert a floating-point value to the nearest unsigned integer (rounding towards zero). |
FPToSI FloatType IntType | Convert a floating-point value to the nearest signed integer (rounding towards zero). |
UIToFP IntType FloatType | Convert an unsigned integer to a floating-point value. |
SIToFP IntType FloatType | Convert a signed integer to a floating-point value. |
IToB IntType | Convert an integer to a boolean value. Zero becomes false; anything else is true. |
BToI IntType | Convert a boolean to an integer. True is converted to 1 and False to 0. |
Comparison operators are like BinOp
s, but they always return a
boolean value. The somewhat ugly constructor names are straight
out of LLVM.
CmpEq PrimType | All types equality. |
CmpUlt IntType | Unsigned less than. |
CmpUle IntType | Unsigned less than or equal. |
CmpSlt IntType | Signed less than. |
CmpSle IntType | Signed less than or equal. |
FCmpLt FloatType | Floating-point less than. |
FCmpLe FloatType | Floating-point less than or equal. |
CmpLlt | Boolean less than. |
CmpLle | Boolean less than or equal. |
Binary operators. These correspond closely to the binary operators in LLVM. Most are parametrised by their expected input and output types.
Add IntType Overflow | Integer addition. |
FAdd FloatType | Floating-point addition. |
Sub IntType Overflow | Integer subtraction. |
FSub FloatType | Floating-point subtraction. |
Mul IntType Overflow | Integer multiplication. |
FMul FloatType | Floating-point multiplication. |
UDiv IntType Safety | Unsigned integer division. Rounds towards negativity infinity. Note: this is different from LLVM. |
UDivUp IntType Safety | Unsigned integer division. Rounds towards positive infinity. |
SDiv IntType Safety | Signed integer division. Rounds towards negativity infinity. Note: this is different from LLVM. |
SDivUp IntType Safety | Signed integer division. Rounds towards positive infinity. |
FDiv FloatType | Floating-point division. |
FMod FloatType | Floating-point modulus. |
UMod IntType Safety | Unsigned integer modulus; the countepart to |
SMod IntType Safety | Signed integer modulus; the countepart to |
SQuot IntType Safety | Signed integer division. Rounds towards zero. This
corresponds to the |
SRem IntType Safety | Signed integer division. Rounds towards zero. This
corresponds to the |
SMin IntType | Returns the smallest of two signed integers. |
UMin IntType | Returns the smallest of two unsigned integers. |
FMin FloatType | Returns the smallest of two floating-point numbers. |
SMax IntType | Returns the greatest of two signed integers. |
UMax IntType | Returns the greatest of two unsigned integers. |
FMax FloatType | Returns the greatest of two floating-point numbers. |
Shl IntType | Left-shift. |
LShr IntType | Logical right-shift, zero-extended. |
AShr IntType | Arithmetic right-shift, sign-extended. |
And IntType | Bitwise and. |
Or IntType | Bitwise or. |
Xor IntType | Bitwise exclusive-or. |
Pow IntType | Integer exponentiation. |
FPow FloatType | Floating-point exponentiation. |
LogAnd | Boolean and - not short-circuiting. |
LogOr | Boolean or - not short-circuiting. |
Whether something is safe or unsafe (mostly function calls, and
in the context of whether operations are dynamically checked).
When we inline an Unsafe
function, we remove all safety checks in
its body. The Ord
instance picks Unsafe
as being less than
Safe
.
For operations like integer division, a safe division will not explode the computer in case of division by zero, but instead return some unspecified value. This always involves a run-time check, so generally the unsafe variant is what the compiler will insert, but guarded by an explicit assertion elsewhere. Safe operations are useful when the optimiser wants to move e.g. a division to a location where the divisor may be zero, but where the result will only be used when it is non-zero (so it doesn't matter what result is provided with a zero divisor, as long as the program keeps running).
What to do in case of arithmetic overflow. Futhark's semantics are that overflow does wraparound, but for generated code (like address arithmetic), it can be beneficial for overflow to be undefined behaviour, as it allows better optimisation of things such as GPU kernels.
Note that all values of this type are considered equal for Eq
and
Ord
.
Various unary operators. It is a bit ad-hoc what is a unary operator and what is a built-in function. Perhaps these should all go away eventually.
Not | E.g., |
Complement IntType | E.g., |
Abs IntType |
|
FAbs FloatType |
|
SSignum IntType | Signed sign function: |
USignum IntType | Unsigned sign function: |
FSignum FloatType | Floating-point sign function. |
Non-array values.
IntValue !IntValue | |
FloatValue !FloatValue | |
BoolValue !Bool | |
Checked | The only value of type |
data FloatValue Source #
A floating-point value.
Instances
Eq FloatValue Source # | |
Defined in Futhark.IR.Primitive (==) :: FloatValue -> FloatValue -> Bool # (/=) :: FloatValue -> FloatValue -> Bool # | |
Ord FloatValue Source # | |
Defined in Futhark.IR.Primitive compare :: FloatValue -> FloatValue -> Ordering # (<) :: FloatValue -> FloatValue -> Bool # (<=) :: FloatValue -> FloatValue -> Bool # (>) :: FloatValue -> FloatValue -> Bool # (>=) :: FloatValue -> FloatValue -> Bool # max :: FloatValue -> FloatValue -> FloatValue # min :: FloatValue -> FloatValue -> FloatValue # | |
Show FloatValue Source # | |
Defined in Futhark.IR.Primitive showsPrec :: Int -> FloatValue -> ShowS # show :: FloatValue -> String # showList :: [FloatValue] -> ShowS # | |
ToExp FloatValue Source # | |
Defined in Futhark.CodeGen.Backends.SimpleRep toExp :: FloatValue -> SrcLoc -> Exp # | |
Pretty FloatValue Source # | |
Defined in Futhark.IR.Primitive | |
IsValue FloatValue Source # | |
Defined in Futhark.IR.Prop.Constants value :: FloatValue -> PrimValue Source # |
An integer value.
Low-level primitive types.
Instances
Bounded PrimType Source # | |
Enum PrimType Source # | |
Eq PrimType Source # | |
Ord PrimType Source # | |
Defined in Futhark.IR.Primitive | |
Show PrimType Source # | |
Pretty PrimType Source # | |
A floating point type.
Instances
Bounded FloatType Source # | |
Enum FloatType Source # | |
Defined in Futhark.IR.Primitive succ :: FloatType -> FloatType # pred :: FloatType -> FloatType # fromEnum :: FloatType -> Int # enumFrom :: FloatType -> [FloatType] # enumFromThen :: FloatType -> FloatType -> [FloatType] # enumFromTo :: FloatType -> FloatType -> [FloatType] # enumFromThenTo :: FloatType -> FloatType -> FloatType -> [FloatType] # | |
Eq FloatType Source # | |
Ord FloatType Source # | |
Defined in Futhark.IR.Primitive | |
Show FloatType Source # | |
Pretty FloatType Source # | |
An integer type, ordered by size. Note that signedness is not a property of the type, but a property of the operations performed on values of these types.
Instances
Bounded IntType Source # | |
Enum IntType Source # | |
Eq IntType Source # | |
Ord IntType Source # | |
Show IntType Source # | |
Pretty IntType Source # | |
allIntTypes :: [IntType] Source #
A list of all integer types.
allFloatTypes :: [FloatType] Source #
A list of all floating-point types.
allPrimTypes :: [PrimType] Source #
A list of all primitive types.
intValueType :: IntValue -> IntType Source #
The type of an integer value.
floatValue :: Real num => FloatType -> num -> FloatValue Source #
Create a FloatValue
from a type and a Rational
.
floatValueType :: FloatValue -> FloatType Source #
The type of a floating-point value.
primValueType :: PrimValue -> PrimType Source #
The type of a basic value.
blankPrimValue :: PrimType -> PrimValue Source #
A "blank" value of the given primitive type - this is zero, or whatever is close to it. Don't depend on this value, but use it for e.g. creating arrays to be populated by do-loops.
allConvOps :: [ConvOp] Source #
A list of all conversion operators for all types.
doComplement :: IntValue -> IntValue Source #
E.g., ~(~1) = 1
.
doFAbs :: FloatValue -> FloatValue Source #
abs(-2.0) = 2.0
.
doSDiv :: IntValue -> IntValue -> Maybe IntValue Source #
Signed integer division. Rounds towards negativity infinity. Note: this is different from LLVM.
doSMod :: IntValue -> IntValue -> Maybe IntValue Source #
Signed integer modulus; the countepart to SDiv
.
doZExt :: IntValue -> IntType -> IntValue Source #
Zero-extend the given integer value to the size of the given type. If the type is smaller than the given value, the result is a truncation.
doSExt :: IntValue -> IntType -> IntValue Source #
Sign-extend the given integer value to the size of the given type. If the type is smaller than the given value, the result is a truncation.
doFPConv :: FloatValue -> FloatType -> FloatValue Source #
Convert the former floating-point type to the latter.
doFPToUI :: FloatValue -> IntType -> IntValue Source #
Convert a floating-point value to the nearest unsigned integer (rounding towards zero).
doFPToSI :: FloatValue -> IntType -> IntValue Source #
Convert a floating-point value to the nearest signed integer (rounding towards zero).
doUIToFP :: IntValue -> FloatType -> FloatValue Source #
Convert an unsigned integer to a floating-point value.
doSIToFP :: IntValue -> FloatType -> FloatValue Source #
Convert a signed integer to a floating-point value.
doCmpEq :: PrimValue -> PrimValue -> Bool Source #
Compare any two primtive values for exact equality.
doFCmpLt :: FloatValue -> FloatValue -> Bool Source #
Floating-point less than.
doFCmpLe :: FloatValue -> FloatValue -> Bool Source #
Floating-point less than or equal.
intToWord64 :: IntValue -> Word64 Source #
convOpType :: ConvOp -> (PrimType, PrimType) Source #
The input and output types of a conversion operator.
primFuns :: Map String ([PrimType], PrimType, [PrimValue] -> Maybe PrimValue) Source #
A mapping from names of primitive functions to their parameter types, their result type, and a function for evaluating them.
negativeIsh :: PrimValue -> Bool Source #
Is the given value kind of negative?
zeroIshInt :: IntValue -> Bool Source #
Is the given integer value kind of zero?
primBitSize :: PrimType -> Int Source #
The size of a value of a given primitive type in bites.
primByteSize :: Num a => PrimType -> a Source #
The size of a value of a given primitive type in eight-bit bytes.
intByteSize :: Num a => IntType -> a Source #
The size of a value of a given integer type in eight-bit bytes.
floatByteSize :: Num a => FloatType -> a Source #
The size of a value of a given floating-point type in eight-bit bytes.
commutativeBinOp :: BinOp -> Bool Source #
True if the given binary operator is commutative.
prettySigned :: Bool -> PrimType -> String Source #
True if signed. Only makes a difference for integer types.
A name tagged with some integer. Only the integer is used in
comparisons, no matter the type of vn
.
Instances
The abstract (not really) type representing names in the Futhark
compiler. String
s, being lists of characters, are very slow,
while Text
s are based on byte-arrays.
Instances
data Commutativity Source #
Whether some operator is commutative or not. The Monoid
instance returns the least commutative of its arguments.
Instances
data Uniqueness Source #
The uniqueness attribute of a type. This essentially indicates
whether or not in-place modifications are acceptable. With respect
to ordering, Unique
is greater than Nonunique
.
Instances
defaultEntryPoint :: Name Source #
The name of the default program entry point (main).
nameToString :: Name -> String Source #
Convert a name to the corresponding list of characters.
nameFromString :: String -> Name Source #
Convert a list of characters to the corresponding name.
locStr :: Located a => a -> String Source #
A human-readable location string, of the form
filename:lineno:columnno
. This follows the GNU coding standards
for error messages:
https://www.gnu.org/prep/standards/html_node/Errors.html
This function assumes that both start and end position is in the same file (it is not clear what the alternative would even mean).
locStrRel :: (Located a, Located b) => a -> b -> String Source #
Like locStr
, but locStrRel prev now
prints the location now
with the file name left out if the same as prev
. This is useful
when printing messages that are all in the context of some
initially printed location (e.g. the first mention contains the
file name; the rest just line and column name).
prettyStacktrace :: Int -> [String] -> String Source #
Given a list of strings representing entries in the stack trace and the index of the frame to highlight, produce a final newline-terminated string for showing to the user. This string should also be preceded by a newline. The most recent stack frame must come first in the list.
quote :: String -> String Source #
Enclose a string in the prefered quotes used in error messages. These are picked to not collide with characters permitted in identifiers.
data ErrorMsgPart a Source #
A part of an error message.
ErrorString String | A literal string. |
ErrorInt32 a | A run-time integer value. |
ErrorInt64 a | A bigger run-time integer value. |
Instances
An error message is a list of error parts, which are concatenated to form the final message.
ErrorMsg [ErrorMsgPart a] |
Instances
Functor ErrorMsg Source # | |
Foldable ErrorMsg Source # | |
Defined in Futhark.IR.Syntax.Core fold :: Monoid m => ErrorMsg m -> m # foldMap :: Monoid m => (a -> m) -> ErrorMsg a -> m # foldMap' :: Monoid m => (a -> m) -> ErrorMsg a -> m # foldr :: (a -> b -> b) -> b -> ErrorMsg a -> b # foldr' :: (a -> b -> b) -> b -> ErrorMsg a -> b # foldl :: (b -> a -> b) -> b -> ErrorMsg a -> b # foldl' :: (b -> a -> b) -> b -> ErrorMsg a -> b # foldr1 :: (a -> a -> a) -> ErrorMsg a -> a # foldl1 :: (a -> a -> a) -> ErrorMsg a -> a # elem :: Eq a => a -> ErrorMsg a -> Bool # maximum :: Ord a => ErrorMsg a -> a # minimum :: Ord a => ErrorMsg a -> a # | |
Traversable ErrorMsg Source # | |
Eq a => Eq (ErrorMsg a) Source # | |
Ord a => Ord (ErrorMsg a) Source # | |
Show a => Show (ErrorMsg a) Source # | |
IsString (ErrorMsg a) Source # | |
Defined in Futhark.IR.Syntax.Core fromString :: String -> ErrorMsg a # | |
Pretty a => Pretty (ErrorMsg a) Source # | |
A subexpression is either a scalar constant or a variable. One important property is that evaluation of a subexpression is guaranteed to complete in constant time.
Instances
The memory space of a block. If DefaultSpace
, this is the "default"
space, whatever that is. The exact meaning of the SpaceId
depends on the backend used. In GPU kernels, for example, this is
used to distinguish between constant, global and shared memory
spaces. In GPU-enabled host code, it is used to distinguish
between host memory (DefaultSpace
) and GPU space.
DefaultSpace | |
Space SpaceId | |
ScalarSpace [SubExp] PrimType | A special kind of memory that is a statically sized array of some primitive type. Used for private memory on GPUs. |
errorMsgArgTypes :: ErrorMsg a -> [PrimType] Source #
How many non-constant parts does the error message have, and what is their type?
class FreeIn dec => FreeDec dec where Source #
Either return precomputed free names stored in the attribute, or the freshly computed names. Relies on lazy evaluation to avoid the work.
Nothing
precomputed :: dec -> FV -> FV Source #
Instances
FreeDec () Source # | |
Defined in Futhark.IR.Prop.Names precomputed :: () -> FV -> FV Source # | |
FreeDec Names Source # | |
Defined in Futhark.IR.Prop.Names | |
FreeDec AliasDec Source # | |
Defined in Futhark.IR.Aliases | |
FreeDec ExpWisdom Source # | |
Defined in Futhark.Optimise.Simplify.Lore | |
FreeDec a => FreeDec [a] Source # | |
Defined in Futhark.IR.Prop.Names precomputed :: [a] -> FV -> FV Source # | |
FreeDec a => FreeDec (Maybe a) Source # | |
Defined in Futhark.IR.Prop.Names | |
(FreeDec a, FreeIn b) => FreeDec (a, b) Source # | |
Defined in Futhark.IR.Prop.Names precomputed :: (a, b) -> FV -> FV Source # |
A class indicating that we can obtain free variable information from values of this type.
Nothing
Instances
A computation to build a free variable set.
A set of names. Note that the Ord
instance is a dummy that
treats everything as EQ
if ==
, and otherwise LT
.
Instances
Eq Names Source # | |
Ord Names Source # | |
Show Names Source # | |
Semigroup Names Source # | |
Monoid Names Source # | |
Pretty Names Source # | |
FreeDec Names Source # | |
Defined in Futhark.IR.Prop.Names | |
FreeIn Names Source # | |
Substitute Names Source # | |
Defined in Futhark.Transform.Substitute | |
Rename Names Source # | |
AliasesOf Names Source # | |
MonadState Names (TypeM lore) Source # | |
namesIntMap :: Names -> IntMap VName Source #
Retrieve the data structure underlying the names representation.
namesFromList :: [VName] -> Names Source #
Construct a name set from a list. Slow.
namesToList :: Names -> [VName] Source #
Turn a name set into a list of names. Slow.
freeInStmsAndRes :: (FreeIn (Op lore), FreeIn (LetDec lore), FreeIn (LParamInfo lore), FreeIn (FParamInfo lore), FreeDec (BodyDec lore), FreeDec (ExpDec lore)) => Stms lore -> Result -> FV Source #
Return the set of variable names that are free in the given statements and result. Filters away the names that are bound by the statements.
boundByStm :: Stm lore -> Names Source #
The names bound by a binding.
boundByStms :: Stms lore -> Names Source #
The names bound by the bindings.
boundByLambda :: Lambda lore -> [VName] Source #
The names of the lambda parameters plus the index parameter.
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.
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 |
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 |
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
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
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.
(.&&.) :: 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.
(.<<.) :: TPrimExp t v -> TPrimExp t v -> TPrimExp t v Source #
Lifted bitwise operators. The right-shift is logical, *not* arithmetic.
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.
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.
A wrapper supporting a phantom type for indicating what we are counting.
Instances
Functor (Count u) Source # | |
Foldable (Count u) Source # | |
Defined in Futhark.IR.Kernels.Sizes fold :: Monoid m => Count u m -> m # foldMap :: Monoid m => (a -> m) -> Count u a -> m # foldMap' :: Monoid m => (a -> m) -> Count u a -> m # foldr :: (a -> b -> b) -> b -> Count u a -> b # foldr' :: (a -> b -> b) -> b -> Count u a -> b # foldl :: (b -> a -> b) -> b -> Count u a -> b # foldl' :: (b -> a -> b) -> b -> Count u a -> b # foldr1 :: (a -> a -> a) -> Count u a -> a # foldl1 :: (a -> a -> a) -> Count u a -> a # elem :: Eq a => a -> Count u a -> Bool # maximum :: Ord a => Count u a -> a # minimum :: Ord a => Count u a -> a # | |
Traversable (Count u) Source # | |
Eq e => Eq (Count u e) Source # | |
Num e => Num (Count u e) Source # | |
Defined in Futhark.IR.Kernels.Sizes | |
Ord e => Ord (Count u e) Source # | |
Defined in Futhark.IR.Kernels.Sizes | |
Show e => Show (Count u e) Source # | |
Pretty e => Pretty (Count u e) Source # | |
IntegralExp e => IntegralExp (Count u e) Source # | |
Defined in Futhark.IR.Kernels.Sizes | |
FreeIn e => FreeIn (Count u e) Source # | |
Substitute e => Substitute (Count u e) Source # | |
Defined in Futhark.IR.Kernels.Sizes |
type Exp = PrimExp ExpLeaf Source #
A side-effect free expression whose execution will produce a single primitive value.
The leaves of an Exp
.
ScalarVar VName | A scalar variable. The type is stored in the
|
SizeOf PrimType | The size of a primitive type. |
Index VName (Count Elements (TExp Int64)) PrimType Space Volatility | Reading a value from memory. The arguments have
the same meaning as with |
data Volatility Source #
The volatility of a memory access or variable. Feel free to ignore this for backends where it makes no sense (anything but C and similar low-level things)
Instances
Eq Volatility Source # | |
Defined in Futhark.CodeGen.ImpCode (==) :: Volatility -> Volatility -> Bool # (/=) :: Volatility -> Volatility -> Bool # | |
Ord Volatility Source # | |
Defined in Futhark.CodeGen.ImpCode compare :: Volatility -> Volatility -> Ordering # (<) :: Volatility -> Volatility -> Bool # (<=) :: Volatility -> Volatility -> Bool # (>) :: Volatility -> Volatility -> Bool # (>=) :: Volatility -> Volatility -> Bool # max :: Volatility -> Volatility -> Volatility # min :: Volatility -> Volatility -> Volatility # | |
Show Volatility Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> Volatility -> ShowS # show :: Volatility -> String # showList :: [Volatility] -> ShowS # |
pattern DebugPrint :: String -> Maybe Exp -> Code a Source #
Print the given value to the screen, somehow annotated with the given string as a description. If no type/value pair, just print the string. This has no semantic meaning, but is used entirely for debugging. Code generators are free to ignore this statement.
pattern Call :: [VName] -> Name -> [Arg] -> Code a Source #
Function call. The results are written to the
provided VName
variables.
pattern DeclareArray :: VName -> Space -> PrimType -> ArrayContents -> Code a Source #
Create an array containing the given values. The lifetime of the array will be the entire application. This is mostly used for constant arrays, but also for some bookkeeping data, like the synchronisation counts used to implement reduction.
pattern DeclareScalar :: VName -> Volatility -> PrimType -> Code a Source #
Declare a scalar variable with an initially undefined value.
pattern (:>>:) :: Code a -> Code a -> Code a Source #
Statement composition. Crucial for the Semigroup
instance.
pattern Assert :: Exp -> ErrorMsg Exp -> (SrcLoc, [SrcLoc]) -> Code a Source #
Assert that something must be true. Should it turn out not to be true, then report a failure along with the given error message.
pattern Copy :: VName -> Count Bytes (TExp Int64) -> Space -> VName -> Count Bytes (TExp Int64) -> Space -> Count Bytes (TExp Int64) -> Code a Source #
Destination, offset in destination, destination space, source, offset in source, offset space, number of bytes.
pattern Allocate :: VName -> Count Bytes (TExp Int64) -> Space -> Code a Source #
Memory space must match the corresponding
DeclareMem
.
pattern For :: VName -> Exp -> Code a -> Code a Source #
A for-loop iterating the given number of times. The loop parameter starts counting from zero and will have the same (integer) type as the bound. The bound is evaluated just once, before the loop is entered.
pattern While :: TExp Bool -> Code a -> Code a Source #
While loop. The conditional is (of course) re-evaluated before every iteration of the loop.
pattern Free :: VName -> Space -> Code a Source #
Indicate that some memory block will never again be referenced via the indicated variable. However, it may still be accessed through aliases. It is only safe to actually deallocate the memory block if this is the last reference. There is no guarantee that all memory blocks will be freed with this statement. Backends are free to ignore it entirely.
pattern Comment :: String -> Code a -> Code a Source #
Has the same semantics as the contained code, but the comment should show up in generated code for ease of inspection.
pattern Write :: VName -> Count Elements (TExp Int64) -> PrimType -> Space -> Volatility -> Exp -> Code a Source #
data ArrayContents Source #
The contents of a statically declared constant array. Such arrays are always unidimensional, and reshaped if necessary in the code that uses them.
ArrayValues [PrimValue] | Precisely these values. |
ArrayZeros Int | This many zeroes. |
Instances
Show ArrayContents Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> ArrayContents -> ShowS # show :: ArrayContents -> String # showList :: [ArrayContents] -> ShowS # | |
Pretty ArrayContents Source # | |
Defined in Futhark.CodeGen.ImpCode ppr :: ArrayContents -> Doc # pprPrec :: Int -> ArrayContents -> Doc # pprList :: [ArrayContents] -> Doc # |
A imperative function, containing the body as well as its low-level inputs and outputs, as well as its high-level arguments and results. The latter are only used if the function is an entry point.
Instances
Functor FunctionT Source # | |
Foldable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode fold :: Monoid m => FunctionT m -> m # foldMap :: Monoid m => (a -> m) -> FunctionT a -> m # foldMap' :: Monoid m => (a -> m) -> FunctionT a -> m # foldr :: (a -> b -> b) -> b -> FunctionT a -> b # foldr' :: (a -> b -> b) -> b -> FunctionT a -> b # foldl :: (b -> a -> b) -> b -> FunctionT a -> b # foldl' :: (b -> a -> b) -> b -> FunctionT a -> b # foldr1 :: (a -> a -> a) -> FunctionT a -> a # foldl1 :: (a -> a -> a) -> FunctionT a -> a # toList :: FunctionT a -> [a] # length :: FunctionT a -> Int # elem :: Eq a => a -> FunctionT a -> Bool # maximum :: Ord a => FunctionT a -> a # minimum :: Ord a => FunctionT a -> a # | |
Traversable FunctionT Source # | |
Defined in Futhark.CodeGen.ImpCode | |
Show a => Show (FunctionT a) Source # | |
Pretty op => Pretty (FunctionT op) Source # | |
data ExternalValue Source #
^ An externally visible value. This can be an opaque value (covering several physical internal values), or a single value that can be used externally.
OpaqueValue String [ValueDesc] | The string is a human-readable description with no other semantics. |
TransparentValue ValueDesc |
Instances
Show ExternalValue Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> ExternalValue -> ShowS # show :: ExternalValue -> String # showList :: [ExternalValue] -> ShowS # | |
Pretty ExternalValue Source # | |
Defined in Futhark.CodeGen.ImpCode ppr :: ExternalValue -> Doc # pprPrec :: Int -> ExternalValue -> Doc # pprList :: [ExternalValue] -> Doc # | |
FreeIn ExternalValue Source # | |
Defined in Futhark.CodeGen.ImpCode freeIn' :: ExternalValue -> FV Source # |
A description of an externally meaningful value.
ArrayValue VName Space PrimType Signedness [DimSize] | An array with memory block memory space, element type, signedness of element type (if applicable), and shape. |
ScalarValue PrimType Signedness VName | A scalar value with signedness if applicable. |
data Signedness Source #
Since the core language does not care for signedness, but the source language does, entry point input/output information has metadata for integer types (and arrays containing these) that indicate whether they are really unsigned integers.
Instances
Eq Signedness Source # | |
Defined in Futhark.CodeGen.ImpCode (==) :: Signedness -> Signedness -> Bool # (/=) :: Signedness -> Signedness -> Bool # | |
Show Signedness Source # | |
Defined in Futhark.CodeGen.ImpCode showsPrec :: Int -> Signedness -> ShowS # show :: Signedness -> String # showList :: [Signedness] -> ShowS # |
A collection of imperative constants.
Constants | |
|
A collection of imperative functions.
Instances
Functor Functions Source # | |
Foldable Functions Source # | |
Defined in Futhark.CodeGen.ImpCode fold :: Monoid m => Functions m -> m # foldMap :: Monoid m => (a -> m) -> Functions a -> m # foldMap' :: Monoid m => (a -> m) -> Functions a -> m # foldr :: (a -> b -> b) -> b -> Functions a -> b # foldr' :: (a -> b -> b) -> b -> Functions a -> b # foldl :: (b -> a -> b) -> b -> Functions a -> b # foldl' :: (b -> a -> b) -> b -> Functions a -> b # foldr1 :: (a -> a -> a) -> Functions a -> a # foldl1 :: (a -> a -> a) -> Functions a -> a # toList :: Functions a -> [a] # length :: Functions a -> Int # elem :: Eq a => a -> Functions a -> Bool # maximum :: Ord a => Functions a -> a # minimum :: Ord a => Functions a -> a # | |
Traversable Functions Source # | |
Defined in Futhark.CodeGen.ImpCode | |
Semigroup (Functions a) Source # | |
Monoid (Functions a) Source # | |
Pretty op => Pretty (Functions op) Source # | |
FreeIn a => FreeIn (Functions a) Source # | |
data Definitions a Source #
A collection of imperative functions and constants.
Instances
Pretty op => Pretty (Definitions op) Source # | |
Defined in Futhark.CodeGen.ImpCode ppr :: Definitions op -> Doc # pprPrec :: Int -> Definitions op -> Doc # pprList :: [Definitions op] -> Doc # |
An ImpCode function parameter.
lexicalMemoryUsage :: Function a -> Map VName Space Source #
Find those memory blocks that are used only lexically. That is,
are not used as the source or target of a SetMem
, or are the
result of the function, nor passed as arguments to other functions.
This is interesting because such memory blocks do not need
reference counting, but can be managed in a purely stack-like
fashion.
We do not look inside any Op
s. We assume that no Op
is going
to SetMem
a memory block declared outside it.
calledFuncs :: Code a -> Set Name Source #
The set of functions that are called by this code. Assumes there
are no function calls in Op
s.
withElemType :: Count Elements (TExp Int64) -> PrimType -> Count Bytes (TExp Int64) Source #
Convert a count of elements into a count of bytes, given the per-element size.
index :: VName -> Count Elements (TExp Int64) -> PrimType -> Space -> Volatility -> Exp Source #
Concise wrapper for using Index
.
declaredIn :: Code a -> Names Source #
The names declared with DeclareMem
, DeclareScalar
, and
DeclareArray
in the given code.