Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides various simple ways to query and manipulate fundamental Futhark terms, such as types and values. The intent is to keep Futhark.IRrsentation.AST.Syntax simple, and put whatever embellishments we need here. This is an internal, desugared representation.
Synopsis
- module Futhark.IR.Prop.Reshape
- module Futhark.IR.Prop.Rearrange
- module Futhark.IR.Prop.Types
- module Futhark.IR.Prop.Constants
- module Futhark.IR.Prop.TypeOf
- module Futhark.IR.Prop.Patterns
- module Futhark.IR.Prop.Names
- module Futhark.IR.RetType
- isBuiltInFunction :: Name -> Bool
- builtInFunctions :: Map Name (PrimType, [PrimType])
- asBasicOp :: Exp lore -> Maybe BasicOp
- safeExp :: IsOp (Op lore) => Exp lore -> Bool
- subExpVars :: [SubExp] -> [VName]
- subExpVar :: SubExp -> Maybe VName
- commutativeLambda :: Lambda lore -> Bool
- entryPointSize :: EntryPointType -> Int
- defAux :: dec -> StmAux dec
- stmCerts :: Stm lore -> Certificates
- certify :: Certificates -> Stm lore -> Stm lore
- expExtTypesFromPattern :: Typed dec => PatternT dec -> [ExtType]
- attrsForAssert :: Attrs -> Attrs
- type ASTConstraints a = (Eq a, Ord a, Show a, Rename a, Substitute a, FreeIn a, Pretty a)
- class (ASTConstraints op, TypedOp op) => IsOp op where
- class (Decorations lore, PrettyLore lore, Renameable lore, Substitutable lore, FreeDec (ExpDec lore), FreeIn (LetDec lore), FreeDec (BodyDec lore), FreeIn (FParamInfo lore), FreeIn (LParamInfo lore), FreeIn (RetType lore), FreeIn (BranchType lore), IsOp (Op lore)) => ASTLore lore where
- expTypesFromPattern :: (HasScope lore m, Monad m) => Pattern lore -> m [BranchType lore]
Documentation
module Futhark.IR.Prop.Reshape
module Futhark.IR.Prop.Rearrange
module Futhark.IR.Prop.Types
module Futhark.IR.Prop.Constants
module Futhark.IR.Prop.TypeOf
module Futhark.IR.Prop.Patterns
module Futhark.IR.Prop.Names
module Futhark.IR.RetType
Built-in functions
isBuiltInFunction :: Name -> Bool Source #
isBuiltInFunction k
is True
if k
is an element of builtInFunctions
.
builtInFunctions :: Map Name (PrimType, [PrimType]) Source #
A map of all built-in functions and their types.
Extra tools
safeExp :: IsOp (Op lore) => Exp lore -> Bool Source #
An expression is safe if it is always well-defined (assuming that any required certificates have been checked) in any context. For example, array indexing is not safe, as the index may be out of bounds. On the other hand, adding two numbers cannot fail.
subExpVars :: [SubExp] -> [VName] Source #
Return the variable names used in Var
subexpressions. May contain
duplicates.
commutativeLambda :: Lambda lore -> Bool Source #
Does the given lambda represent a known commutative function? Based on pattern matching and checking whether the lambda represents a known arithmetic operator; don't expect anything clever here.
entryPointSize :: EntryPointType -> Int Source #
How many value parameters are accepted by this entry point? This is used to determine which of the function parameters correspond to the parameters of the original function (they must all come at the end).
stmCerts :: Stm lore -> Certificates Source #
The certificates associated with a statement.
expExtTypesFromPattern :: Typed dec => PatternT dec -> [ExtType] Source #
Construct the type of an expression that would match the pattern.
attrsForAssert :: Attrs -> Attrs Source #
Keep only those attributes that are relevant for Assert
expressions.
type ASTConstraints a = (Eq a, Ord a, Show a, Rename a, Substitute a, FreeIn a, Pretty a) Source #
A handy shorthand for properties that we usually want to things we stuff into ASTs.
class (ASTConstraints op, TypedOp op) => IsOp op where Source #
A type class for operations.
Like safeExp
, but for arbitrary ops.
cheapOp :: op -> Bool Source #
Should we try to hoist this out of branches?
Instances
IsOp () Source # | |
IsOp SizeOp Source # | |
ASTLore lore => IsOp (SOAC lore) Source # | |
IsOp inner => IsOp (MemOp inner) Source # | |
(ASTLore lore, ASTConstraints lvl) => IsOp (SegOp lvl lore) Source # | |
(ASTLore lore, IsOp op) => IsOp (MCOp lore op) Source # | |
(ASTLore lore, IsOp op) => IsOp (HostOp lore op) Source # | |
class (Decorations lore, PrettyLore lore, Renameable lore, Substitutable lore, FreeDec (ExpDec lore), FreeIn (LetDec lore), FreeDec (BodyDec lore), FreeIn (FParamInfo lore), FreeIn (LParamInfo lore), FreeIn (RetType lore), FreeIn (BranchType lore), IsOp (Op lore)) => ASTLore lore where Source #
Lore-specific attributes; also means the lore supports some basic facilities.
expTypesFromPattern :: (HasScope lore m, Monad m) => Pattern lore -> m [BranchType lore] Source #
Given a pattern, construct the type of a body that would match
it. An implementation for many lores would be
expExtTypesFromPattern
.