futhark-0.24.3: 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.IR.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 rep -> Maybe BasicOp Source #

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

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.

subExpVar :: SubExp -> Maybe VName Source #

If the SubExp is a Var return the variable name.

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.

defAux :: dec -> StmAux dec Source #

A StmAux with empty Certs.

stmCerts :: Stm rep -> Certs Source #

The certificates associated with a statement.

certify :: Certs -> Stm rep -> Stm rep Source #

Add certificates to a statement.

expExtTypesFromPat :: Typed dec => Pat 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 for 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 SizeOp Source # 
Instance details

Defined in Futhark.IR.GPU.Op

ASTRep rep => IsOp (SOAC rep) Source # 
Instance details

Defined in Futhark.IR.SOACS.SOAC

Methods

safeOp :: SOAC rep -> Bool Source #

cheapOp :: SOAC rep -> Bool Source #

(ASTRep rep, IsOp (op rep)) => IsOp (HostOp op rep) Source # 
Instance details

Defined in Futhark.IR.GPU.Op

Methods

safeOp :: HostOp op rep -> Bool Source #

cheapOp :: HostOp op rep -> Bool Source #

(ASTRep rep, IsOp (op rep)) => IsOp (MCOp op rep) Source # 
Instance details

Defined in Futhark.IR.MC.Op

Methods

safeOp :: MCOp op rep -> Bool Source #

cheapOp :: MCOp op rep -> Bool Source #

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

Defined in Futhark.IR.Mem

Methods

safeOp :: MemOp inner rep -> Bool Source #

cheapOp :: MemOp inner rep -> Bool Source #

IsOp (NoOp rep) Source # 
Instance details

Defined in Futhark.IR.Prop

Methods

safeOp :: NoOp rep -> Bool Source #

cheapOp :: NoOp rep -> Bool Source #

(ASTRep rep, ASTConstraints lvl) => IsOp (SegOp lvl rep) Source # 
Instance details

Defined in Futhark.IR.SegOp

Methods

safeOp :: SegOp lvl rep -> Bool Source #

cheapOp :: SegOp lvl rep -> Bool Source #

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), RephraseOp (OpC rep)) => ASTRep rep where Source #

Representation-specific attributes; also means the rep supports some basic facilities.

Methods

expTypesFromPat :: (HasScope rep m, Monad m) => Pat (LetDec 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.

Instances

Instances details
ASTRep GPU Source # 
Instance details

Defined in Futhark.IR.GPU

ASTRep GPUMem Source # 
Instance details

Defined in Futhark.IR.GPUMem

ASTRep MC Source # 
Instance details

Defined in Futhark.IR.MC

ASTRep MCMem Source # 
Instance details

Defined in Futhark.IR.MCMem

ASTRep SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

ASTRep Seq Source # 
Instance details

Defined in Futhark.IR.Seq

ASTRep SeqMem Source # 
Instance details

Defined in Futhark.IR.SeqMem

(ASTRep rep, AliasedOp (OpC rep (Aliases rep)), IsOp (OpC rep (Aliases rep))) => ASTRep (Aliases rep) Source # 
Instance details

Defined in Futhark.IR.Aliases

Methods

expTypesFromPat :: (HasScope (Aliases rep) m, Monad m) => Pat (LetDec (Aliases rep)) -> m [BranchType (Aliases rep)] Source #

(Informing rep, IsOp (OpC rep (Wise rep))) => ASTRep (Wise rep) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Rep

Methods

expTypesFromPat :: (HasScope (Wise rep) m, Monad m) => Pat (LetDec (Wise rep)) -> m [BranchType (Wise rep)] Source #