futhark-0.21.7: An optimising compiler for a functional, array-oriented language.
Safe HaskellNone
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 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.

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

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

Defined in Futhark.IR.Mem

Methods

safeOp :: MemOp inner -> Bool Source #

cheapOp :: MemOp inner -> 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 #

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

Defined in Futhark.IR.MC.Op

Methods

safeOp :: MCOp rep op -> Bool Source #

cheapOp :: MCOp rep op -> Bool Source #

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

Defined in Futhark.IR.GPU.Op

Methods

safeOp :: HostOp rep op -> Bool Source #

cheapOp :: HostOp rep op -> 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)) => 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 Seq Source # 
Instance details

Defined in Futhark.IR.Seq

ASTRep SOACS Source # 
Instance details

Defined in Futhark.IR.SOACS

ASTRep SeqMem Source # 
Instance details

Defined in Futhark.IR.SeqMem

ASTRep MCMem Source # 
Instance details

Defined in Futhark.IR.MCMem

ASTRep MC Source # 
Instance details

Defined in Futhark.IR.MC

ASTRep GPU Source # 
Instance details

Defined in Futhark.IR.GPU

ASTRep GPUMem Source # 
Instance details

Defined in Futhark.IR.GPUMem

(ASTRep rep, CanBeAliased (Op 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 #

(ASTRep rep, CanBeWise (Op 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 #