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

Safe HaskellNone
LanguageHaskell2010

Futhark.Optimise.Simplify

Synopsis

Documentation

simplifyProg :: SimplifiableLore lore => SimpleOps lore -> RuleBook (Wise lore) -> HoistBlockers lore -> Prog lore -> PassM (Prog lore) Source #

Simplify the given program. Even if the output differs from the output, meaningful simplification may not have taken place - the order of bindings may simply have been rearranged.

simplifySomething :: (MonadFreshNames m, HasScope lore m, SimplifiableLore lore) => (a -> SimpleM lore b) -> (b -> a) -> SimpleOps lore -> RuleBook (Wise lore) -> HoistBlockers lore -> a -> m a Source #

Run a simplification operation to convergence.

simplifyFun :: (MonadFreshNames m, SimplifiableLore lore) => SimpleOps lore -> RuleBook (Wise lore) -> HoistBlockers lore -> FunDef lore -> m (FunDef lore) Source #

Simplify the given function. Even if the output differs from the output, meaningful simplification may not have taken place - the order of bindings may simply have been rearranged. Runs in a loop until convergence.

simplifyLambda :: (MonadFreshNames m, HasScope lore m, SimplifiableLore lore) => SimpleOps lore -> RuleBook (Wise lore) -> HoistBlockers lore -> Lambda lore -> [Maybe VName] -> m (Lambda lore) Source #

Simplify just a single LambdaT.

simplifyStms :: (MonadFreshNames m, HasScope lore m, SimplifiableLore lore) => SimpleOps lore -> RuleBook (Wise lore) -> HoistBlockers lore -> Stms lore -> m (Stms lore) Source #

Simplify a list of Stms.

data SimpleOps lore Source #

Constructors

SimpleOps 

Fields

Instances
MonadReader (SimpleOps lore, Env lore) (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

ask :: SimpleM lore (SimpleOps lore, Env lore) #

local :: ((SimpleOps lore, Env lore) -> (SimpleOps lore, Env lore)) -> SimpleM lore a -> SimpleM lore a #

reader :: ((SimpleOps lore, Env lore) -> a) -> SimpleM lore a #

data SimpleM lore a Source #

Instances
MonadWriter Certificates (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

writer :: (a, Certificates) -> SimpleM lore a #

tell :: Certificates -> SimpleM lore () #

listen :: SimpleM lore a -> SimpleM lore (a, Certificates) #

pass :: SimpleM lore (a, Certificates -> Certificates) -> SimpleM lore a #

Monad (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

(>>=) :: SimpleM lore a -> (a -> SimpleM lore b) -> SimpleM lore b #

(>>) :: SimpleM lore a -> SimpleM lore b -> SimpleM lore b #

return :: a -> SimpleM lore a #

fail :: String -> SimpleM lore a #

Functor (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

fmap :: (a -> b) -> SimpleM lore a -> SimpleM lore b #

(<$) :: a -> SimpleM lore b -> SimpleM lore a #

Applicative (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

pure :: a -> SimpleM lore a #

(<*>) :: SimpleM lore (a -> b) -> SimpleM lore a -> SimpleM lore b #

liftA2 :: (a -> b -> c) -> SimpleM lore a -> SimpleM lore b -> SimpleM lore c #

(*>) :: SimpleM lore a -> SimpleM lore b -> SimpleM lore b #

(<*) :: SimpleM lore a -> SimpleM lore b -> SimpleM lore a #

MonadFreshNames (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

SimplifiableLore lore => LocalScope (Wise lore) (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

localScope :: Scope (Wise lore) -> SimpleM lore a -> SimpleM lore a Source #

SimplifiableLore lore => HasScope (Wise lore) (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

lookupType :: VName -> SimpleM lore Type Source #

lookupInfo :: VName -> SimpleM lore (NameInfo (Wise lore)) Source #

askScope :: SimpleM lore (Scope (Wise lore)) Source #

asksScope :: (Scope (Wise lore) -> a) -> SimpleM lore a Source #

MonadState (VNameSource, Bool) (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

get :: SimpleM lore (VNameSource, Bool) #

put :: (VNameSource, Bool) -> SimpleM lore () #

state :: ((VNameSource, Bool) -> (a, (VNameSource, Bool))) -> SimpleM lore a #

MonadReader (SimpleOps lore, Env lore) (SimpleM lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Engine

Methods

ask :: SimpleM lore (SimpleOps lore, Env lore) #

local :: ((SimpleOps lore, Env lore) -> (SimpleOps lore, Env lore)) -> SimpleM lore a -> SimpleM lore a #

reader :: ((SimpleOps lore, Env lore) -> a) -> SimpleM lore a #

type SimplifyOp lore = Op lore -> SimpleM lore (OpWithWisdom (Op lore), Stms (Wise lore)) Source #

data RuleBook lore Source #

A collection of both top-down and bottom-up rules.

Instances
Semigroup (RuleBook lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Rule

Methods

(<>) :: RuleBook lore -> RuleBook lore -> RuleBook lore #

sconcat :: NonEmpty (RuleBook lore) -> RuleBook lore #

stimes :: Integral b => b -> RuleBook lore -> RuleBook lore #

Monoid (RuleBook lore) Source # 
Instance details

Defined in Futhark.Optimise.Simplify.Rule

Methods

mempty :: RuleBook lore #

mappend :: RuleBook lore -> RuleBook lore -> RuleBook lore #

mconcat :: [RuleBook lore] -> RuleBook lore #