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 rep -> Maybe BasicOp
- safeExp :: IsOp (Op rep) => Exp rep -> Bool
- subExpVars :: [SubExp] -> [VName]
- subExpVar :: SubExp -> Maybe VName
- commutativeLambda :: Lambda rep -> Bool
- entryPointSize :: EntryPointType -> Int
- defAux :: dec -> StmAux dec
- stmCerts :: Stm rep -> Certs
- certify :: Certs -> Stm rep -> Stm rep
- expExtTypesFromPat :: Typed dec => PatT dec -> [ExtType]
- attrsForAssert :: Attrs -> Attrs
- lamIsBinOp :: ASTRep rep => Lambda rep -> Maybe [(BinOp, PrimType, VName, VName)]
- 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 (RepTypes rep, PrettyRep rep, Renameable rep, Substitutable rep, FreeDec (ExpDec rep), FreeIn (LetDec rep), FreeDec (BodyDec rep), FreeIn (FParamInfo rep), FreeIn (LParamInfo rep), FreeIn (RetType rep), FreeIn (BranchType rep), IsOp (Op rep)) => ASTRep rep where
- expTypesFromPat :: (HasScope rep m, Monad m) => Pat rep -> m [BranchType rep]
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 rep) => Exp rep -> 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 rep -> 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).
expExtTypesFromPat :: Typed dec => PatT 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.
lamIsBinOp :: ASTRep rep => Lambda rep -> Maybe [(BinOp, PrimType, VName, VName)] Source #
Horizontally fission a lambda that models a binary operator.
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
class (RepTypes rep, PrettyRep rep, Renameable rep, Substitutable rep, FreeDec (ExpDec rep), FreeIn (LetDec rep), FreeDec (BodyDec rep), FreeIn (FParamInfo rep), FreeIn (LParamInfo rep), FreeIn (RetType rep), FreeIn (BranchType rep), IsOp (Op rep)) => ASTRep rep where Source #
Representation-specific attributes; also means the rep supports some basic facilities.
expTypesFromPat :: (HasScope rep m, Monad m) => Pat rep -> m [BranchType rep] Source #
Given a pattern, construct the type of a body that would match
it. An implementation for many representations would be
expExtTypesFromPat
.