futhark-0.25.27: An optimising compiler for a functional, array-oriented language.

Safe Haskell | Safe-Inferred
Language | GHC2021

Futhark.Optimise.Simplify.Rep

Contents

- Constructing representation

Description

Representation used by the simplification engine. It contains aliasing information and a bit of caching for various information that is looked up frequently. The name is an old relic; feel free to suggest a better one.

Synopsis

- data Wise rep
- newtype VarWisdom = VarWisdom {
  - varWisdomAliases :: VarAliases
  }
- data ExpWisdom
- removeStmWisdom :: RephraseOp (OpC rep) => Stm (Wise rep) -> Stm rep
- removeLambdaWisdom :: RephraseOp (OpC rep) => Lambda (Wise rep) -> Lambda rep
- removeFunDefWisdom :: RephraseOp (OpC rep) => FunDef (Wise rep) -> FunDef rep
- removeExpWisdom :: RephraseOp (OpC rep) => Exp (Wise rep) -> Exp rep
- removePatWisdom :: Pat (VarWisdom, a) -> Pat a
- removeBodyWisdom :: RephraseOp (OpC rep) => Body (Wise rep) -> Body rep
- removeScopeWisdom :: Scope (Wise rep) -> Scope rep
- addScopeWisdom :: Scope rep -> Scope (Wise rep)
- addWisdomToPat :: Informing rep => Pat (LetDec rep) -> Exp (Wise rep) -> Pat (LetDec (Wise rep))
- mkWiseBody :: Informing rep => BodyDec rep -> Stms (Wise rep) -> Result -> Body (Wise rep)
- mkWiseStm :: Informing rep => Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp (Wise rep) -> Stm (Wise rep)
- mkWiseExpDec :: Informing rep => Pat (LetDec (Wise rep)) -> ExpDec rep -> Exp (Wise rep) -> ExpDec (Wise rep)
- class CanBeWise op where
  - addOpWisdom :: Informing rep => op rep -> op (Wise rep)
- type Informing rep = (ASTRep rep, AliasedOp (OpC rep), RephraseOp (OpC rep), CanBeWise (OpC rep), FreeIn (OpC rep (Wise rep)), ASTConstraints (OpC rep (Wise rep)))
- informLambda :: Informing rep => Lambda rep -> Lambda (Wise rep)
- informFunDef :: Informing rep => FunDef rep -> FunDef (Wise rep)
- informStms :: Informing rep => Stms rep -> Stms (Wise rep)
- informBody :: Informing rep => Body rep -> Body (Wise rep)

# Documentation

data Wise rep Source #

Representative phantom type for the simplifier representation.

#### Instances

Instances details

BuilderOps (Wise GPU) Source # |

Instance details

Defined in Futhark.IR.GPU.Simplify

Methods

mkExpDecB :: (MonadBuilder m, Rep m ~ Wise GPU) => Pat (LetDec (Wise GPU)) -> Exp (Wise GPU) -> m (ExpDec (Wise GPU)) Source #

mkBodyB :: (MonadBuilder m, Rep m ~ Wise GPU) => Stms (Wise GPU) -> Result -> m (Body (Wise GPU)) Source #

mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise GPU) => [VName] -> Exp (Wise GPU) -> m (Stm (Wise GPU)) Source #

BuilderOps (Wise GPUMem) Source # |

Instance details

Defined in Futhark.IR.GPUMem

Methods

mkExpDecB :: (MonadBuilder m, Rep m ~ Wise GPUMem) => Pat (LetDec (Wise GPUMem)) -> Exp (Wise GPUMem) -> m (ExpDec (Wise GPUMem)) Source #

mkBodyB :: (MonadBuilder m, Rep m ~ Wise GPUMem) => Stms (Wise GPUMem) -> Result -> m (Body (Wise GPUMem)) Source #

mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise GPUMem) => [VName] -> Exp (Wise GPUMem) -> m (Stm (Wise GPUMem)) Source #

BuilderOps (Wise MC) Source # |
Instance details Defined in Futhark.IR.MC Methods mkExpDecB :: (MonadBuilder m, Rep m ~ Wise MC) => Pat (LetDec (Wise MC)) -> Exp (Wise MC) -> m (ExpDec (Wise MC)) Source # mkBodyB :: (MonadBuilder m, Rep m ~ Wise MC) => Stms (Wise MC) -> Result -> m (Body (Wise MC)) Source # mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise MC) => [VName] -> Exp (Wise MC) -> m (Stm (Wise MC)) Source #
BuilderOps (Wise MCMem) Source # |

Instance details

Defined in Futhark.IR.MCMem

Methods

mkExpDecB :: (MonadBuilder m, Rep m ~ Wise MCMem) => Pat (LetDec (Wise MCMem)) -> Exp (Wise MCMem) -> m (ExpDec (Wise MCMem)) Source #

mkBodyB :: (MonadBuilder m, Rep m ~ Wise MCMem) => Stms (Wise MCMem) -> Result -> m (Body (Wise MCMem)) Source #

mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise MCMem) => [VName] -> Exp (Wise MCMem) -> m (Stm (Wise MCMem)) Source #

BuilderOps (Wise SOACS) Source # |

Instance details

Defined in Futhark.IR.SOACS.Simplify

Methods

mkExpDecB :: (MonadBuilder m, Rep m ~ Wise SOACS) => Pat (LetDec (Wise SOACS)) -> Exp (Wise SOACS) -> m (ExpDec (Wise SOACS)) Source #

mkBodyB :: (MonadBuilder m, Rep m ~ Wise SOACS) => Stms (Wise SOACS) -> Result -> m (Body (Wise SOACS)) Source #

mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise SOACS) => [VName] -> Exp (Wise SOACS) -> m (Stm (Wise SOACS)) Source #

BuilderOps (Wise Seq) Source # |
Instance details Defined in Futhark.IR.Seq Methods mkExpDecB :: (MonadBuilder m, Rep m ~ Wise Seq) => Pat (LetDec (Wise Seq)) -> Exp (Wise Seq) -> m (ExpDec (Wise Seq)) Source # mkBodyB :: (MonadBuilder m, Rep m ~ Wise Seq) => Stms (Wise Seq) -> Result -> m (Body (Wise Seq)) Source # mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise Seq) => [VName] -> Exp (Wise Seq) -> m (Stm (Wise Seq)) Source #
BuilderOps (Wise SeqMem) Source # |

Instance details

Defined in Futhark.IR.SeqMem

Methods

mkExpDecB :: (MonadBuilder m, Rep m ~ Wise SeqMem) => Pat (LetDec (Wise SeqMem)) -> Exp (Wise SeqMem) -> m (ExpDec (Wise SeqMem)) Source #

mkBodyB :: (MonadBuilder m, Rep m ~ Wise SeqMem) => Stms (Wise SeqMem) -> Result -> m (Body (Wise SeqMem)) Source #

mkLetNamesB :: (MonadBuilder m, Rep m ~ Wise SeqMem) => [VName] -> Exp (Wise SeqMem) -> m (Stm (Wise SeqMem)) Source #

(Buildable rep, Informing rep) => Buildable (Wise rep) Source # |

Instance details

Defined in Futhark.Optimise.Simplify.Rep

Methods

mkExpPat :: [Ident] -> Exp (Wise rep) -> Pat (LetDec (Wise rep)) Source #

mkExpDec :: Pat (LetDec (Wise rep)) -> Exp (Wise rep) -> ExpDec (Wise rep) Source #

mkBody :: Stms (Wise rep) -> Result -> Body (Wise rep) Source #

mkLetNames :: (MonadFreshNames m, HasScope (Wise rep) m) => [VName] -> Exp (Wise rep) -> m (Stm (Wise rep)) Source #

(Informing rep, Pretty (OpC rep (Wise rep))) => PrettyRep (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods ppExpDec :: ExpDec (Wise rep) -> Exp (Wise rep) -> Maybe (Doc a) Source #
(Informing rep, IsOp (OpC 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 #
Informing rep => Aliased (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods bodyAliases :: Body (Wise rep) -> [Names] Source # consumedInBody :: Body (Wise rep) -> Names Source #
(Informing rep, Ord (OpC rep (Wise rep)), Eq (OpC rep (Wise rep)), Show (OpC rep (Wise rep)), IsOp (OpC rep), Pretty (OpC rep (Wise rep))) => RepTypes (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Associated Types type LetDec (Wise rep) Source # type ExpDec (Wise rep) Source # type BodyDec (Wise rep) Source # type FParamInfo (Wise rep) Source # type LParamInfo (Wise rep) Source # type RetType (Wise rep) Source # type BranchType (Wise rep) Source # type OpC (Wise rep) :: Type -> Type Source #
HasSOAC (Wise GPU) Source # |
Instance details Defined in Futhark.IR.GPU.Simplify Methods asSOAC :: Op (Wise GPU) -> Maybe (SOAC (Wise GPU)) Source # soacOp :: SOAC (Wise GPU) -> Op (Wise GPU) Source #
HasSOAC (Wise SOACS) Source # |
Instance details Defined in Futhark.IR.SOACS.Simplify Methods asSOAC :: Op (Wise SOACS) -> Maybe (SOAC (Wise SOACS)) Source # soacOp :: SOAC (Wise SOACS) -> Op (Wise SOACS) Source #
HasSegOp (Wise GPU) Source # |
Instance details Defined in Futhark.IR.GPU.Simplify Associated Types type SegOpLevel (Wise GPU) Source # Methods asSegOp :: Op (Wise GPU) -> Maybe (SegOp (SegOpLevel (Wise GPU)) (Wise GPU)) Source # segOp :: SegOp (SegOpLevel (Wise GPU)) (Wise GPU) -> Op (Wise GPU) Source #
HasSegOp (Wise MC) Source # |
Instance details Defined in Futhark.IR.MC Associated Types type SegOpLevel (Wise MC) Source # Methods asSegOp :: Op (Wise MC) -> Maybe (SegOp (SegOpLevel (Wise MC)) (Wise MC)) Source # segOp :: SegOp (SegOpLevel (Wise MC)) (Wise MC) -> Op (Wise MC) Source #
TraverseOpStms (Wise GPU) Source # |
Instance details Defined in Futhark.IR.GPU.Simplify Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise GPU)) (Wise GPU) Source #
TraverseOpStms (Wise GPUMem) Source # |
Instance details Defined in Futhark.IR.GPUMem Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise GPUMem)) (Wise GPUMem) Source #
TraverseOpStms (Wise MC) Source # |
Instance details Defined in Futhark.IR.MC Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise MC)) (Wise MC) Source #
TraverseOpStms (Wise MCMem) Source # |
Instance details Defined in Futhark.IR.MCMem Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise MCMem)) (Wise MCMem) Source #
TraverseOpStms (Wise SOACS) Source # |
Instance details Defined in Futhark.IR.SOACS.Simplify Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise SOACS)) (Wise SOACS) Source #
TraverseOpStms (Wise Seq) Source # |
Instance details Defined in Futhark.IR.Seq Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise Seq)) (Wise Seq) Source #
TraverseOpStms (Wise SeqMem) Source # |
Instance details Defined in Futhark.IR.SeqMem Methods traverseOpStms :: Monad m => OpStmsTraverser m (Op (Wise SeqMem)) (Wise SeqMem) Source #
SimplifiableRep rep => HasScope (Wise rep) (SimpleM rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Engine Methods lookupType :: VName -> SimpleM rep Type Source # lookupInfo :: VName -> SimpleM rep (NameInfo (Wise rep)) Source # askScope :: SimpleM rep (Scope (Wise rep)) Source # asksScope :: (Scope (Wise rep) -> a) -> SimpleM rep a Source #
SimplifiableRep rep => LocalScope (Wise rep) (SimpleM rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Engine Methods localScope :: Scope (Wise rep) -> SimpleM rep a -> SimpleM rep a Source #
type BodyDec (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type BodyDec (Wise rep)
type BranchType (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type BranchType (Wise rep) = BranchType rep
type ExpDec (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type ExpDec (Wise rep) = (ExpWisdom, ExpDec rep)
type FParamInfo (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type FParamInfo (Wise rep) = FParamInfo rep
type LParamInfo (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type LParamInfo (Wise rep) = LParamInfo rep
type LetDec (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type LetDec (Wise rep) = (VarWisdom, LetDec rep)
type OpC (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type OpC (Wise rep) = OpC rep
type RetType (Wise rep) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep type RetType (Wise rep) = RetType rep
type SegOpLevel (Wise GPU) Source # |
Instance details Defined in Futhark.IR.GPU.Simplify type SegOpLevel (Wise GPU) = SegLevel
type SegOpLevel (Wise MC) Source # |
Instance details Defined in Futhark.IR.MC type SegOpLevel (Wise MC) = ()

newtype VarWisdom Source #

The information associated with a let-bound variable.

Constructors

VarWisdom |

Fields

- varWisdomAliases :: VarAliases

#### Instances

Instances details

Show VarWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods showsPrec :: Int -> VarWisdom -> ShowS Source # show :: VarWisdom -> String Source # showList :: [VarWisdom] -> ShowS Source #
FreeIn VarWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods freeIn' :: VarWisdom -> FV Source #
Rename VarWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods rename :: VarWisdom -> RenameM VarWisdom Source #
Substitute VarWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods substituteNames :: Map VName VName -> VarWisdom -> VarWisdom Source #
Eq VarWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods (==) :: VarWisdom -> VarWisdom -> Bool Source # (/=) :: VarWisdom -> VarWisdom -> Bool Source #
Ord VarWisdom Source # |

Instance details

Defined in Futhark.Optimise.Simplify.Rep

Methods

compare :: VarWisdom -> VarWisdom -> Ordering Source #

(<) :: VarWisdom -> VarWisdom -> Bool Source #

(<=) :: VarWisdom -> VarWisdom -> Bool Source #

(>) :: VarWisdom -> VarWisdom -> Bool Source #

(>=) :: VarWisdom -> VarWisdom -> Bool Source #

max :: VarWisdom -> VarWisdom -> VarWisdom Source #

min :: VarWisdom -> VarWisdom -> VarWisdom Source #

Pretty VarWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods pretty :: VarWisdom -> Doc ann Source # prettyList :: [VarWisdom] -> Doc ann Source #
AliasesOf (VarWisdom, dec) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods aliasesOf :: (VarWisdom, dec) -> Names Source #

data ExpWisdom Source #

Simplifier information about an expression.

#### Instances

Instances details

Show ExpWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods showsPrec :: Int -> ExpWisdom -> ShowS Source # show :: ExpWisdom -> String Source # showList :: [ExpWisdom] -> ShowS Source #
FreeDec ExpWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods precomputed :: ExpWisdom -> FV -> FV Source #
FreeIn ExpWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods freeIn' :: ExpWisdom -> FV Source #
Rename ExpWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods rename :: ExpWisdom -> RenameM ExpWisdom Source #
Substitute ExpWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods substituteNames :: Map VName VName -> ExpWisdom -> ExpWisdom Source #
Eq ExpWisdom Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods (==) :: ExpWisdom -> ExpWisdom -> Bool Source # (/=) :: ExpWisdom -> ExpWisdom -> Bool Source #
Ord ExpWisdom Source # |

Instance details

Defined in Futhark.Optimise.Simplify.Rep

Methods

compare :: ExpWisdom -> ExpWisdom -> Ordering Source #

(<) :: ExpWisdom -> ExpWisdom -> Bool Source #

(<=) :: ExpWisdom -> ExpWisdom -> Bool Source #

(>) :: ExpWisdom -> ExpWisdom -> Bool Source #

(>=) :: ExpWisdom -> ExpWisdom -> Bool Source #

max :: ExpWisdom -> ExpWisdom -> ExpWisdom Source #

min :: ExpWisdom -> ExpWisdom -> ExpWisdom Source #

removeStmWisdom :: RephraseOp (OpC rep) => Stm (Wise rep) -> Stm rep Source #

Remove simplifier information from statement.

removeLambdaWisdom :: RephraseOp (OpC rep) => Lambda (Wise rep) -> Lambda rep Source #

Remove simplifier information from lambda.

removeFunDefWisdom :: RephraseOp (OpC rep) => FunDef (Wise rep) -> FunDef rep Source #

Remove simplifier information from function.

removeExpWisdom :: RephraseOp (OpC rep) => Exp (Wise rep) -> Exp rep Source #

Remove simplifier information from expression.

removePatWisdom :: Pat (VarWisdom, a) -> Pat a Source #

Remove simplifier information from pattern.

removeBodyWisdom :: RephraseOp (OpC rep) => Body (Wise rep) -> Body rep Source #

Remove simplifier information from body.

removeScopeWisdom :: Scope (Wise rep) -> Scope rep Source #

Remove simplifier information from scope.

addScopeWisdom :: Scope rep -> Scope (Wise rep) Source #

Add simplifier information to scope. All the aliasing information will be vacuous, however.

addWisdomToPat :: Informing rep => Pat (LetDec rep) -> Exp (Wise rep) -> Pat (LetDec (Wise rep)) Source #

Add simplifier information to pattern.

mkWiseBody :: Informing rep => BodyDec rep -> Stms (Wise rep) -> Result -> Body (Wise rep) Source #

Produce a body with simplifier information.

mkWiseStm :: Informing rep => Pat (LetDec rep) -> StmAux (ExpDec rep) -> Exp (Wise rep) -> Stm (Wise rep) Source #

Produce a statement with simplifier information.

mkWiseExpDec :: Informing rep => Pat (LetDec (Wise rep)) -> ExpDec rep -> Exp (Wise rep) -> ExpDec (Wise rep) Source #

Produce simplifier information for an expression.

class CanBeWise op where Source #

A type class for indicating that this operation can be lifted into the simplifier representation.

Methods

addOpWisdom :: Informing rep => op rep -> op (Wise rep) Source #

#### Instances

Instances details

CanBeWise SOAC Source # |
Instance details Defined in Futhark.IR.SOACS.SOAC Methods addOpWisdom :: Informing rep => SOAC rep -> SOAC (Wise rep) Source #
CanBeWise op => CanBeWise (HostOp op) Source # |
Instance details Defined in Futhark.IR.GPU.Op Methods addOpWisdom :: Informing rep => HostOp op rep -> HostOp op (Wise rep) Source #
CanBeWise op => CanBeWise (MCOp op) Source # |
Instance details Defined in Futhark.IR.MC.Op Methods addOpWisdom :: Informing rep => MCOp op rep -> MCOp op (Wise rep) Source #
CanBeWise inner => CanBeWise (MemOp inner) Source # |
Instance details Defined in Futhark.IR.Mem Methods addOpWisdom :: Informing rep => MemOp inner rep -> MemOp inner (Wise rep) Source #
CanBeWise (NoOp :: Type -> Type) Source # |
Instance details Defined in Futhark.Optimise.Simplify.Rep Methods addOpWisdom :: Informing rep => NoOp rep -> NoOp (Wise rep) Source #
CanBeWise (SegOp lvl) Source # |
Instance details Defined in Futhark.IR.SegOp Methods addOpWisdom :: Informing rep => SegOp lvl rep -> SegOp lvl (Wise rep) Source #

# Constructing representation

type Informing rep = (ASTRep rep, AliasedOp (OpC rep), RephraseOp (OpC rep), CanBeWise (OpC rep), FreeIn (OpC rep (Wise rep)), ASTConstraints (OpC rep (Wise rep))) Source #

Constraints that let us transform a representation into a `Wise` representation.

informLambda :: Informing rep => Lambda rep -> Lambda (Wise rep) Source #

Construct a `Wise` lambda.

informFunDef :: Informing rep => FunDef rep -> FunDef (Wise rep) Source #

Construct a `Wise` function definition.

informStms :: Informing rep => Stms rep -> Stms (Wise rep) Source #

Construct `Wise` statements.

informBody :: Informing rep => Body rep -> Body (Wise rep) Source #

Construct a `Wise` body.