Safe Haskell | None |
---|---|
Language | Haskell2010 |
A simple representation with SOACs and nested parallelism.
Synopsis
- data SOACS
- type Prog = Prog SOACS
- type Body = Body SOACS
- type Stm = Stm SOACS
- type Pattern = Pattern SOACS
- type BasicOp = BasicOp SOACS
- type Exp = Exp SOACS
- type Lambda = Lambda SOACS
- type FunDef = FunDefT SOACS
- type FParam = FParam SOACS
- type LParam = LParam SOACS
- type RetType = RetType SOACS
- type PatElem = PatElem SOACS
- module Futhark.Representation.AST.Attributes
- module Futhark.Representation.AST.Traversals
- module Futhark.Representation.AST.Pretty
- data Int8
- data Int16
- data Int32
- data Int64
- data Word8
- data Word16
- data Word32
- data Word64
- pretty :: Pretty a => a -> String
- data ConvOp
- data CmpOp
- data BinOp
- = Add IntType
- | FAdd FloatType
- | Sub IntType
- | FSub FloatType
- | Mul IntType
- | FMul FloatType
- | UDiv IntType
- | SDiv IntType
- | FDiv FloatType
- | UMod IntType
- | SMod IntType
- | SQuot IntType
- | SRem IntType
- | 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 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
- 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 StreamOrd
- data Uniqueness
- defaultEntryPoint :: Name
- nameToString :: Name -> String
- nameFromString :: String -> Name
- nameToText :: Name -> Text
- nameFromText :: Text -> Name
- locStr :: SrcLoc -> String
- baseTag :: VName -> Int
- baseName :: VName -> Name
- baseString :: VName -> String
- data ErrorMsgPart a
- = ErrorString String
- | ErrorInt32 a
- newtype ErrorMsg a = ErrorMsg [ErrorMsgPart a]
- type Names = Set VName
- data PatElemT attr
- type Slice d = [DimIndex d]
- data DimIndex d
- type Param = ParamT
- data ParamT attr = Param {}
- data SubExp
- newtype Certificates = Certificates {
- unCertificates :: [VName]
- data Ident = Ident {}
- data Diet
- type DeclExtType = TypeBase ExtShape Uniqueness
- type DeclType = TypeBase Shape Uniqueness
- type ExtType = TypeBase ExtShape NoUniqueness
- type Type = TypeBase Shape NoUniqueness
- data TypeBase shape u
- data NoUniqueness = NoUniqueness
- type SpaceId = String
- data Space
- class (Monoid a, Eq a, Ord a) => ArrayShape a where
- newtype Rank = Rank Int
- type ExtShape = ShapeBase ExtSize
- type ExtSize = Ext SubExp
- data Ext a
- type Shape = ShapeBase SubExp
- newtype ShapeBase d = Shape {
- shapeDims :: [d]
- dimFix :: DimIndex d -> Maybe d
- sliceIndices :: Slice d -> Maybe [d]
- sliceDims :: Slice d -> [d]
- unitSlice :: Num d => d -> d -> DimIndex d
- fixSlice :: Num d => Slice d -> [d] -> [d]
- class (Show rt, Eq rt, Ord rt, DeclExtTyped rt) => IsRetType rt where
- primRetType :: PrimType -> rt
- applyRetType :: Typed attr => [rt] -> [Param attr] -> [(SubExp, Type)] -> Maybe [rt]
- class (Show rt, Eq rt, Ord rt, ExtTyped rt) => IsBodyType rt where
- primBodyType :: PrimType -> rt
- bodyTypeValues :: IsBodyType rt => [rt] -> [ExtType]
- retTypeValues :: IsRetType rt => [rt] -> [DeclExtType]
- expectedTypes :: Typed t => [VName] -> [t] -> [SubExp] -> [Type]
- class (Show (LetAttr l), Show (ExpAttr l), Show (BodyAttr l), Show (FParamAttr l), Show (LParamAttr l), Show (RetType l), Show (BranchType l), Show (Op l), Eq (LetAttr l), Eq (ExpAttr l), Eq (BodyAttr l), Eq (FParamAttr l), Eq (LParamAttr l), Eq (RetType l), Eq (BranchType l), Eq (Op l), Ord (LetAttr l), Ord (ExpAttr l), Ord (BodyAttr l), Ord (FParamAttr l), Ord (LParamAttr l), Ord (RetType l), Ord (BranchType l), Ord (Op l), IsRetType (RetType l), IsBodyType (BranchType l), Typed (FParamAttr l), Typed (LParamAttr l), Typed (LetAttr l), DeclTyped (FParamAttr l)) => Annotations l where
- type LetAttr l :: *
- type ExpAttr l :: *
- type BodyAttr l :: *
- type FParamAttr l :: *
- type LParamAttr l :: *
- type BranchType l :: *
- type Op l :: *
- data ProgT lore
- data EntryPointType
- type EntryPoint = ([EntryPointType], [EntryPointType])
- data FunDefT lore
- data LambdaT lore
- data IfSort
- data IfAttr rt = IfAttr {}
- data LoopForm lore
- data Safety
- data ExpT lore
- pattern Opaque :: SubExp -> BasicOp lore
- pattern Index :: VName -> Slice SubExp -> BasicOp lore
- pattern UnOp :: UnOp -> SubExp -> BasicOp lore
- pattern BinOp :: BinOp -> SubExp -> SubExp -> BasicOp lore
- pattern Iota :: SubExp -> SubExp -> SubExp -> IntType -> BasicOp lore
- pattern Rearrange :: [Int] -> VName -> BasicOp lore
- pattern Reshape :: ShapeChange SubExp -> VName -> BasicOp lore
- pattern Replicate :: Shape -> SubExp -> BasicOp lore
- pattern Copy :: VName -> BasicOp lore
- pattern SubExp :: SubExp -> BasicOp lore
- pattern CmpOp :: CmpOp -> SubExp -> SubExp -> BasicOp lore
- pattern ConvOp :: ConvOp -> SubExp -> BasicOp lore
- pattern ArrayLit :: [SubExp] -> Type -> BasicOp lore
- pattern Assert :: SubExp -> ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp lore
- pattern Update :: VName -> Slice SubExp -> SubExp -> BasicOp lore
- pattern Concat :: Int -> VName -> [VName] -> SubExp -> BasicOp lore
- pattern Manifest :: [Int] -> VName -> BasicOp lore
- pattern Repeat :: [Shape] -> Shape -> VName -> BasicOp lore
- pattern Scratch :: PrimType -> [SubExp] -> BasicOp lore
- pattern Rotate :: [SubExp] -> VName -> BasicOp lore
- type ShapeChange d = [DimChange d]
- data DimChange d
- = DimCoercion d
- | DimNew d
- data BodyT lore
- type Result = [SubExp]
- type Stms lore = Seq (Stm lore)
- pattern Let :: Pattern lore -> StmAux (ExpAttr lore) -> Exp lore -> Stm lore
- stmPattern :: Stm lore -> Pattern lore
- stmAux :: Stm lore -> StmAux (ExpAttr lore)
- stmExp :: Stm lore -> Exp lore
- data StmAux attr = StmAux {
- stmAuxCerts :: !Certificates
- stmAuxAttr :: attr
- data PatternT attr
- oneStm :: Stm lore -> Stms lore
- stmsFromList :: [Stm lore] -> Stms lore
- stmsToList :: Stms lore -> [Stm lore]
- stmsHead :: Stms lore -> Maybe (Stm lore, Stms lore)
- module Futhark.Representation.SOACS.SOAC
- data LambdaT lore = Lambda [LParam lore] (BodyT lore) [Type]
- data BodyT lore = Body (BodyAttr lore) (Stms lore) Result
- data PatternT attr = Pattern [PatElemT attr] [PatElemT attr]
- data PatElemT attr = PatElem VName attr
- newtype ProgT lore = Prog [FunDef lore]
- data ExpT lore = BasicOp (BasicOp lore)
- data FunDefT lore = FunDef (Maybe EntryPoint) Name [RetType lore] [FParam lore] (BodyT lore)
- data ParamT attr = Param VName attr
The Lore definition
The lore for the basic representation.
Instances
Syntax types
Module re-exports
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
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 return PrimType
s.
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 | Integer addition. |
FAdd FloatType | Floating-point addition. |
Sub IntType | Integer subtraction. |
FSub FloatType | Floating-point subtraction. |
Mul IntType | Integer multiplication. |
FMul FloatType | Floating-point multiplication. |
UDiv IntType | Unsigned integer division. Rounds towards negativity infinity. Note: this is different from LLVM. |
SDiv IntType | Signed integer division. Rounds towards negativity infinity. Note: this is different from LLVM. |
FDiv FloatType | Floating-point division. |
UMod IntType | Unsigned integer modulus; the countepart to |
SMod IntType | Signed integer modulus; the countepart to |
SQuot IntType | Signed integer division. Rounds towards zero.
This corresponds to the |
SRem IntType | 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. |
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: |
Non-array values.
IntValue !IntValue | |
FloatValue !FloatValue | |
BoolValue !Bool | |
Checked | The only value of type |
data FloatValue Source #
A floating-point value.
Instances
An integer value.
Low-level primitive types.
Instances
Bounded PrimType Source # | |
Enum PrimType Source # | |
Defined in Futhark.Representation.Primitive | |
Eq PrimType Source # | |
Ord PrimType Source # | |
Defined in Futhark.Representation.Primitive | |
Show PrimType Source # | |
Pretty PrimType Source # | |
A floating point type.
Instances
Bounded FloatType Source # | |
Enum FloatType Source # | |
Defined in Futhark.Representation.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.Representation.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 # | |
Defined in Futhark.Representation.Primitive | |
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 #
floatValue :: Real num => FloatType -> num -> FloatValue Source #
Create a FloatValue
from a type and a Rational
.
floatValueType :: FloatValue -> FloatType Source #
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 #
intToInt64 :: IntValue -> Int64 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?
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.
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 :: SrcLoc -> 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).
data ErrorMsgPart a Source #
A part of an error message.
ErrorString String | A literal string. |
ErrorInt32 a | A 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.Representation.AST.Syntax.Core fold :: Monoid m => ErrorMsg m -> 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 # | |
Defined in Futhark.Representation.AST.Syntax.Core | |
Eq a => Eq (ErrorMsg a) Source # | |
Ord a => Ord (ErrorMsg a) Source # | |
Defined in Futhark.Representation.AST.Syntax.Core | |
Show a => Show (ErrorMsg a) Source # | |
IsString (ErrorMsg a) Source # | |
Defined in Futhark.Representation.AST.Syntax.Core fromString :: String -> ErrorMsg a # | |
Pretty a => Pretty (ErrorMsg a) Source # | |
An element of a pattern - consisting of a name (essentially a pair of the name and type) and an addditional parametric attribute. This attribute is what is expected to contain the type of the resulting variable.
Instances
How to index a single dimension of an array.
Instances
A function parameter.
Instances
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
newtype Certificates Source #
A list of names used for certificates in some expressions.
Instances
An identifier consists of its name and the type of the value bound to the identifier.
Information about which parts of a value/type are consumed. For
example, we might say that a function taking three arguments of
types ([int], *[int], [int])
has diet [Observe, Consume,
Observe]
.
type DeclExtType = TypeBase ExtShape Uniqueness Source #
An ExtType
with uniqueness information, used for function
return types.
type DeclType = TypeBase Shape Uniqueness Source #
A type with shape and uniqueness information, used declaring return- and parameters types.
type ExtType = TypeBase ExtShape NoUniqueness Source #
A type with existentially quantified shapes - used as part of function (and function-like) return types. Generally only makes sense when used in a list.
type Type = TypeBase Shape NoUniqueness Source #
A type with shape information, used for describing the type of variables.
data TypeBase shape u Source #
An Futhark type is either an array or an element type. When
comparing types for equality with ==
, shapes must match.
Instances
data NoUniqueness Source #
A fancier name for '()' - encodes no uniqueness information.
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.
class (Monoid a, Eq a, Ord a) => ArrayShape a where Source #
A class encompassing types containing array shape information.
shapeRank :: a -> Int Source #
Return the rank of an array with the given size.
stripDims :: Int -> a -> a Source #
stripDims n shape
strips the outer n
dimensions from
shape
.
subShapeOf :: a -> a -> Bool Source #
Check whether one shape if a subset of another shape.
Instances
ArrayShape Rank Source # | |
ArrayShape (ShapeBase SubExp) Source # | |
ArrayShape (ShapeBase ExtSize) Source # | |
The size of an array type as merely the number of dimensions, with no further information.
type ExtShape = ShapeBase ExtSize Source #
Like ShapeBase
but some of its elements may be bound in a local
environment instead. These are denoted with integral indices.
Something that may be existential.
Instances
type Shape = ShapeBase SubExp Source #
The size of an array as a list of subexpressions. If a variable, that variable must be in scope where this array is used.
The size of an array type as a list of its dimension sizes, with the type of sizes being parametric.
Instances
class (Show rt, Eq rt, Ord rt, DeclExtTyped rt) => IsRetType rt where Source #
A type representing the return type of a function. In practice,
a list of these will be used. It should contain at least the
information contained in an ExtType
, but may have more, notably
an existential context.
primRetType :: PrimType -> rt Source #
Contruct a return type from a primitive type.
applyRetType :: Typed attr => [rt] -> [Param attr] -> [(SubExp, Type)] -> Maybe [rt] Source #
Given a function return type, the parameters of the function, and the arguments for a concrete call, return the instantiated return type for the concrete call, if valid.
Instances
IsRetType DeclExtType Source # | |
Defined in Futhark.Representation.AST.RetType primRetType :: PrimType -> DeclExtType Source # applyRetType :: Typed attr => [DeclExtType] -> [Param attr] -> [(SubExp, Type)] -> Maybe [DeclExtType] Source # | |
IsRetType FunReturns Source # | |
Defined in Futhark.Representation.ExplicitMemory primRetType :: PrimType -> FunReturns Source # applyRetType :: Typed attr => [FunReturns] -> [Param attr] -> [(SubExp, Type)] -> Maybe [FunReturns] Source # |
class (Show rt, Eq rt, Ord rt, ExtTyped rt) => IsBodyType rt where Source #
A type representing the return type of a body. It should contain
at least the information contained in a list of ExtType
s, but may
have more, notably an existential context.
primBodyType :: PrimType -> rt Source #
Construct a body type from a primitive type.
Instances
IsBodyType ExtType Source # | |
Defined in Futhark.Representation.AST.RetType primBodyType :: PrimType -> ExtType Source # | |
IsBodyType BodyReturns Source # | |
Defined in Futhark.Representation.ExplicitMemory primBodyType :: PrimType -> BodyReturns Source # |
bodyTypeValues :: IsBodyType rt => [rt] -> [ExtType] Source #
retTypeValues :: IsRetType rt => [rt] -> [DeclExtType] Source #
expectedTypes :: Typed t => [VName] -> [t] -> [SubExp] -> [Type] Source #
Given shape parameter names and value parameter types, produce the types of arguments accepted.
class (Show (LetAttr l), Show (ExpAttr l), Show (BodyAttr l), Show (FParamAttr l), Show (LParamAttr l), Show (RetType l), Show (BranchType l), Show (Op l), Eq (LetAttr l), Eq (ExpAttr l), Eq (BodyAttr l), Eq (FParamAttr l), Eq (LParamAttr l), Eq (RetType l), Eq (BranchType l), Eq (Op l), Ord (LetAttr l), Ord (ExpAttr l), Ord (BodyAttr l), Ord (FParamAttr l), Ord (LParamAttr l), Ord (RetType l), Ord (BranchType l), Ord (Op l), IsRetType (RetType l), IsBodyType (BranchType l), Typed (FParamAttr l), Typed (LParamAttr l), Typed (LetAttr l), DeclTyped (FParamAttr l)) => Annotations l Source #
Annotation for every let-pattern element.
Annotation for every expression.
Annotation for every body.
type FParamAttr l :: * Source #
Annotation for every (non-lambda) function parameter.
type LParamAttr l :: * Source #
Annotation for every lambda function parameter.
type BranchType l :: * Source #
The return type annotation of branches.
Extensible operation.
Instances
An entire Futhark program.
Instances
Annotations lore => Eq (ProgT lore) Source # | |
Annotations lore => Ord (ProgT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (ProgT lore) Source # | |
PrettyLore lore => Pretty (Prog lore) Source # | |
data EntryPointType Source #
Every entry point argument and return value has an annotation indicating how it maps to the original source program type.
TypeUnsigned | Is an unsigned integer or array of unsigned integers. |
TypeOpaque String Int | A black box type comprising this many core values. The string is a human-readable description with no other semantics. |
TypeDirect | Maps directly. |
Instances
Eq EntryPointType Source # | |
Defined in Futhark.Representation.AST.Syntax (==) :: EntryPointType -> EntryPointType -> Bool # (/=) :: EntryPointType -> EntryPointType -> Bool # | |
Ord EntryPointType Source # | |
Defined in Futhark.Representation.AST.Syntax compare :: EntryPointType -> EntryPointType -> Ordering # (<) :: EntryPointType -> EntryPointType -> Bool # (<=) :: EntryPointType -> EntryPointType -> Bool # (>) :: EntryPointType -> EntryPointType -> Bool # (>=) :: EntryPointType -> EntryPointType -> Bool # max :: EntryPointType -> EntryPointType -> EntryPointType # min :: EntryPointType -> EntryPointType -> EntryPointType # | |
Show EntryPointType Source # | |
Defined in Futhark.Representation.AST.Syntax showsPrec :: Int -> EntryPointType -> ShowS # show :: EntryPointType -> String # showList :: [EntryPointType] -> ShowS # |
type EntryPoint = ([EntryPointType], [EntryPointType]) Source #
Information about the parameters and return value of an entry point. The first element is for parameters, the second for return value.
Function Declarations
Instances
Scoped lore (FunDef lore) Source # | |
Annotations lore => Eq (FunDefT lore) Source # | |
Annotations lore => Ord (FunDefT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (FunDefT lore) Source # | |
PrettyLore lore => Pretty (FunDef lore) Source # | |
Renameable lore => Rename (FunDef lore) Source # | |
Anonymous function for use in a SOAC.
Instances
Scoped lore (Lambda lore) Source # | |
Annotations lore => Eq (LambdaT lore) Source # | |
Annotations lore => Ord (LambdaT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (LambdaT lore) Source # | |
PrettyLore lore => Pretty (Lambda lore) Source # | |
Substitutable lore => Substitute (Lambda lore) Source # | |
Defined in Futhark.Transform.Substitute | |
Renameable lore => Rename (Lambda lore) Source # | |
IfNormal | An ordinary branch. |
IfFallback | A branch where the "true" case is what we are actually interested in, and the "false" case is only present as a fallback for when the true case cannot be safely evaluated. the compiler is permitted to optimise away the branch if the true case contains only safe statements. |
Data associated with a branch.
For-loop or while-loop?
Instances
Scoped lore (LoopForm lore) Source # | |
Annotations lore => Eq (LoopForm lore) Source # | |
Annotations lore => Ord (LoopForm lore) Source # | |
Defined in Futhark.Representation.AST.Syntax compare :: LoopForm lore -> LoopForm lore -> Ordering # (<) :: LoopForm lore -> LoopForm lore -> Bool # (<=) :: LoopForm lore -> LoopForm lore -> Bool # (>) :: LoopForm lore -> LoopForm lore -> Bool # (>=) :: LoopForm lore -> LoopForm lore -> Bool # | |
Annotations lore => Show (LoopForm lore) Source # | |
FreeIn (LParamAttr lore) => FreeIn (LoopForm lore) Source # | |
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
.
The root Futhark expression type. The ExpT
constructor contains
a lore-specific operation. Do-loops, branches and function calls
are special. Everything else is a simple BasicOp
.
Apply Name [(SubExp, Diet)] [RetType lore] (Safety, SrcLoc, [SrcLoc]) | |
If SubExp (BodyT lore) (BodyT lore) (IfAttr (BranchType lore)) | |
DoLoop [(FParam lore, SubExp)] [(FParam lore, SubExp)] (LoopForm lore) (BodyT lore) |
|
Op (Op lore) |
Instances
Annotations lore => Eq (ExpT lore) Source # | |
Annotations lore => Ord (ExpT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (ExpT lore) Source # | |
PrettyLore lore => Pretty (Exp lore) Source # | |
Substitutable lore => Substitute (Exp lore) Source # | |
Defined in Futhark.Transform.Substitute | |
Renameable lore => Rename (Exp lore) Source # | |
pattern Opaque :: SubExp -> BasicOp lore Source #
Semantically and operationally just identity, but is invisible/impenetrable to optimisations (hopefully). This is just a hack to avoid optimisation (so, to work around compiler limitations).
pattern Index :: VName -> Slice SubExp -> BasicOp lore Source #
The certificates for bounds-checking are part of the Stm
.
pattern Iota :: SubExp -> SubExp -> SubExp -> IntType -> BasicOp lore Source #
iota(n, x, s) = [x,x+s,..,x+(n-1)*s]
.
The IntType
indicates the type of the array returned and the
offset/stride arguments, but not the length argument.
pattern Rearrange :: [Int] -> VName -> BasicOp lore Source #
Permute the dimensions of the input array. The list
of integers is a list of dimensions (0-indexed), which
must be a permutation of [0,n-1]
, where n
is the
number of dimensions in the input array.
pattern Reshape :: ShapeChange SubExp -> VName -> BasicOp lore Source #
1st arg is the new shape, 2nd arg is the input array *)
pattern Replicate :: Shape -> SubExp -> BasicOp lore Source #
replicate([3][2],1) = [[1,1], [1,1], [1,1]]
pattern Copy :: VName -> BasicOp lore Source #
Copy the given array. The result will not alias anything.
pattern CmpOp :: CmpOp -> SubExp -> SubExp -> BasicOp lore Source #
Comparison - result type is always boolean.
pattern ArrayLit :: [SubExp] -> Type -> BasicOp lore Source #
Array literals, e.g., [ [1+x, 3], [2, 1+4] ]
.
Second arg is the element type of the rows of the array.
Scalar operations
pattern Assert :: SubExp -> ErrorMsg SubExp -> (SrcLoc, [SrcLoc]) -> BasicOp lore Source #
Turn a boolean into a certificate, halting the program with the given error message if the boolean is false.
pattern Update :: VName -> Slice SubExp -> SubExp -> BasicOp lore Source #
An in-place update of the given array at the given position. Consumes the array.
pattern Concat :: Int -> VName -> [VName] -> SubExp -> BasicOp lore Source #
concat
0([1],[2, 3, 4]) = [1, 2, 3, 4]@.
pattern Manifest :: [Int] -> VName -> BasicOp lore Source #
Manifest an array with dimensions represented in the given order. The result will not alias anything.
pattern Repeat :: [Shape] -> Shape -> VName -> BasicOp lore Source #
Repeat each dimension of the input array some number of times,
given by the corresponding shape. For an array of rank k
, the
list must contain k
shapes. A shape may be empty (in which
case the dimension is not repeated, but it is still present).
The last shape indicates the amount of extra innermost
dimensions. All other extra dimensions are added *before* the original dimension.
pattern Scratch :: PrimType -> [SubExp] -> BasicOp lore Source #
Create array of given type and shape, with undefined elements.
pattern Rotate :: [SubExp] -> VName -> BasicOp lore Source #
Rotate the dimensions of the input array. The list of subexpressions specify how much each dimension is rotated. The length of this list must be equal to the rank of the array.
type ShapeChange d = [DimChange d] Source #
A list of DimChange
s, indicating the new dimensions of an array.
The new dimension in a Reshape
-like operation. This allows us to
disambiguate "real" reshapes, that change the actual shape of the
array, from type coercions that are just present to make the types
work out. The two constructors are considered equal for purposes of Eq
.
DimCoercion d | The new dimension is guaranteed to be numerically equal to the old one. |
DimNew d | The new dimension is not necessarily numerically equal to the old one. |
Instances
A body consists of a number of bindings, terminating in a result (essentially a tuple literal).
Instances
Annotations lore => Eq (BodyT lore) Source # | |
Annotations lore => Ord (BodyT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (BodyT lore) Source # | |
PrettyLore lore => Pretty (Body lore) Source # | |
Substitutable lore => Substitute (Body lore) Source # | |
Defined in Futhark.Transform.Substitute | |
Renameable lore => Rename (Body lore) Source # | |
Ranged lore => RangesOf (Body lore) Source # | |
stmPattern :: Stm lore -> Pattern lore Source #
Auxilliary Information associated with a statement.
StmAux | |
|
Instances
Eq attr => Eq (StmAux attr) Source # | |
Ord attr => Ord (StmAux attr) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Show attr => Show (StmAux attr) Source # | |
FreeIn attr => FreeIn (StmAux attr) Source # | |
Substitute attr => Substitute (StmAux attr) Source # | |
Defined in Futhark.Transform.Substitute | |
Rename attr => Rename (StmAux attr) Source # | |
A pattern is conceptually just a list of names and their types.
Instances
Functor PatternT Source # | |
Eq attr => Eq (PatternT attr) Source # | |
Ord attr => Ord (PatternT attr) Source # | |
Defined in Futhark.Representation.AST.Syntax compare :: PatternT attr -> PatternT attr -> Ordering # (<) :: PatternT attr -> PatternT attr -> Bool # (<=) :: PatternT attr -> PatternT attr -> Bool # (>) :: PatternT attr -> PatternT attr -> Bool # (>=) :: PatternT attr -> PatternT attr -> Bool # | |
Show attr => Show (PatternT attr) Source # | |
Semigroup (PatternT attr) Source # | |
Monoid (PatternT attr) Source # | |
Pretty (PatElemT attr) => Pretty (PatternT attr) Source # | |
FreeIn attr => FreeIn (PatternT attr) Source # | |
Substitute attr => Substitute (PatternT attr) Source # | |
Defined in Futhark.Transform.Substitute | |
Rename attr => Rename (PatternT attr) Source # | |
RangeOf attr => RangesOf (PatternT attr) Source # | |
stmsFromList :: [Stm lore] -> Stms lore Source #
stmsToList :: Stms lore -> [Stm lore] Source #
Anonymous function for use in a SOAC.
Instances
Scoped lore (Lambda lore) Source # | |
Annotations lore => Eq (LambdaT lore) Source # | |
Annotations lore => Ord (LambdaT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (LambdaT lore) Source # | |
PrettyLore lore => Pretty (Lambda lore) Source # | |
Substitutable lore => Substitute (Lambda lore) Source # | |
Defined in Futhark.Transform.Substitute | |
Renameable lore => Rename (Lambda lore) Source # | |
A body consists of a number of bindings, terminating in a result (essentially a tuple literal).
Instances
Annotations lore => Eq (BodyT lore) Source # | |
Annotations lore => Ord (BodyT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (BodyT lore) Source # | |
PrettyLore lore => Pretty (Body lore) Source # | |
Substitutable lore => Substitute (Body lore) Source # | |
Defined in Futhark.Transform.Substitute | |
Renameable lore => Rename (Body lore) Source # | |
Ranged lore => RangesOf (Body lore) Source # | |
A pattern is conceptually just a list of names and their types.
Instances
Functor PatternT Source # | |
Eq attr => Eq (PatternT attr) Source # | |
Ord attr => Ord (PatternT attr) Source # | |
Defined in Futhark.Representation.AST.Syntax compare :: PatternT attr -> PatternT attr -> Ordering # (<) :: PatternT attr -> PatternT attr -> Bool # (<=) :: PatternT attr -> PatternT attr -> Bool # (>) :: PatternT attr -> PatternT attr -> Bool # (>=) :: PatternT attr -> PatternT attr -> Bool # | |
Show attr => Show (PatternT attr) Source # | |
Semigroup (PatternT attr) Source # | |
Monoid (PatternT attr) Source # | |
Pretty (PatElemT attr) => Pretty (PatternT attr) Source # | |
FreeIn attr => FreeIn (PatternT attr) Source # | |
Substitute attr => Substitute (PatternT attr) Source # | |
Defined in Futhark.Transform.Substitute | |
Rename attr => Rename (PatternT attr) Source # | |
RangeOf attr => RangesOf (PatternT attr) Source # | |
An element of a pattern - consisting of a name (essentially a pair of the name and type) and an addditional parametric attribute. This attribute is what is expected to contain the type of the resulting variable.
Instances
An entire Futhark program.
Instances
Annotations lore => Eq (ProgT lore) Source # | |
Annotations lore => Ord (ProgT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (ProgT lore) Source # | |
PrettyLore lore => Pretty (Prog lore) Source # | |
The root Futhark expression type. The ExpT
constructor contains
a lore-specific operation. Do-loops, branches and function calls
are special. Everything else is a simple BasicOp
.
Instances
Annotations lore => Eq (ExpT lore) Source # | |
Annotations lore => Ord (ExpT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (ExpT lore) Source # | |
PrettyLore lore => Pretty (Exp lore) Source # | |
Substitutable lore => Substitute (Exp lore) Source # | |
Defined in Futhark.Transform.Substitute | |
Renameable lore => Rename (Exp lore) Source # | |
Function Declarations
Instances
Scoped lore (FunDef lore) Source # | |
Annotations lore => Eq (FunDefT lore) Source # | |
Annotations lore => Ord (FunDefT lore) Source # | |
Defined in Futhark.Representation.AST.Syntax | |
Annotations lore => Show (FunDefT lore) Source # | |
PrettyLore lore => Pretty (FunDef lore) Source # | |
Renameable lore => Rename (FunDef lore) Source # | |
A function parameter.