futhark-0.20.0: An optimising compiler for a functional, array-oriented language.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Futhark.IR.Prop

Description

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

Documentation

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

asBasicOp :: Exp lore -> Maybe BasicOp Source #

If the expression is a BasicOp, return it, otherwise Nothing.

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.

subExpVar :: SubExp -> Maybe VName Source #

If the SubExp is a Var return the variable name.

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).

defAux :: dec -> StmAux dec Source #

A StmAux with empty Certificates.

stmCerts :: Stm lore -> Certificates Source #

The certificates associated with a statement.

certify :: Certificates -> Stm lore -> Stm lore Source #

Add certificates to 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.

Methods

safeOp :: op -> Bool Source #

Like safeExp, but for arbitrary ops.

cheapOp :: op -> Bool Source #

Should we try to hoist this out of branches?

Instances

Instances details
IsOp () Source # 
Instance details

Defined in Futhark.IR.Prop

Methods

safeOp :: () -> Bool Source #

cheapOp :: () -> Bool Source #

IsOp SizeOp Source # 
Instance details

Defined in Futhark.IR.Kernels.Kernel

ASTLore lore => IsOp (SOAC lore) Source # 
Instance details

Defined in Futhark.IR.SOACS.SOAC

Methods

safeOp :: SOAC lore -> Bool Source #

cheapOp :: SOAC lore -> Bool Source #

IsOp inner => IsOp (MemOp inner) Source # 
Instance details

Defined in Futhark.IR.Mem

Methods

safeOp :: MemOp inner -> Bool Source #

cheapOp :: MemOp inner -> Bool Source #

(ASTLore lore, ASTConstraints lvl) => IsOp (SegOp lvl lore) Source # 
Instance details

Defined in Futhark.IR.SegOp

Methods

safeOp :: SegOp lvl lore -> Bool Source #

cheapOp :: SegOp lvl lore -> Bool Source #

(ASTLore lore, IsOp op) => IsOp (MCOp lore op) Source # 
Instance details

Defined in Futhark.IR.MC.Op

Methods

safeOp :: MCOp lore op -> Bool Source #

cheapOp :: MCOp lore op -> Bool Source #

(ASTLore lore, IsOp op) => IsOp (HostOp lore op) Source # 
Instance details

Defined in Futhark.IR.Kernels.Kernel

Methods

safeOp :: HostOp lore op -> Bool Source #

cheapOp :: HostOp lore op -> Bool 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.

Methods

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.

Instances

Instances details
ASTLore Seq Source # 
Instance details

Defined in Futhark.IR.Seq

ASTLore SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

ASTLore MCMem Source # 
Instance details

Defined in Futhark.IR.MCMem

ASTLore MC Source # 
Instance details

Defined in Futhark.IR.MC

ASTLore SeqMem Source # 
Instance details

Defined in Futhark.IR.SeqMem

ASTLore Kernels Source # 
Instance details

Defined in Futhark.IR.Kernels

ASTLore KernelsMem Source # 
Instance details

Defined in Futhark.IR.KernelsMem

(ASTLore lore, CanBeAliased (Op lore)) => ASTLore (Aliases lore) Source # 
Instance details

Defined in Futhark.IR.Aliases

Methods

expTypesFromPattern :: (HasScope (Aliases lore) m, Monad m) => Pattern (Aliases lore) -> m [BranchType (Aliases lore)] Source #

(ASTLore lore, CanBeWise (Op lore)) => ASTLore (Wise lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Lore

Methods

expTypesFromPattern :: (HasScope (Wise lore) m, Monad m) => Pattern (Wise lore) -> m [BranchType (Wise lore)] Source #