raw-feldspar-0.4: Resource-Aware Feldspar
Safe HaskellNone
LanguageHaskell2010

Feldspar.Optimize

Description

Optimize Feldspar expressions

Synopsis

Documentation

prj' :: sub :<: sup => sup sig -> Maybe (sub sig) Source #

prj with a stronger constraint to allow using it in bidirectional patterns

pattern SymP :: forall sub (sup :: Type -> Type) sig. sub :<: sup => TypeRep (DenResult sig) -> sub sig -> AST (sup :&: TypeRepFun) sig Source #

pattern VarP :: forall (sup :: Type -> Type) info sig a. BindingT :<: sup => forall. (sig ~ Full a, Typeable a) => info (DenResult sig) -> Name -> AST (sup :&: info) sig Source #

pattern LamP :: forall (sup :: Type -> Type) info sig a1 a2 b. BindingT :<: sup => forall. ((a1 :-> sig) ~ (b :-> Full (a2 -> b)), Typeable a2) => info (DenResult (a1 :-> sig)) -> Name -> AST (sup :&: info) (Full a1) -> AST (sup :&: info) sig Source #

pattern LitP :: () => (Eq a, Show a) => TypeRep a -> a -> ASTF FeldDomain a Source #

pattern AddP :: () => (Num a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

pattern SubP :: () => (Num a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

pattern MulP :: () => (Num a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

pattern NegP :: () => (Num a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

pattern QuotP :: () => (Integral a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

pattern RemP :: () => (Integral a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

pattern DivP :: () => (Integral a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

pattern ModP :: () => (Integral a, PrimType' a) => TypeRep a -> ASTF FeldDomain a -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

constFold :: ASTF FeldDomain a -> ASTF FeldDomain a Source #

Reduce an expression to a literal if the following conditions are met:

  • The top-most symbol can be evaluated statically (i.g. not a variable or a lifted side-effecting program)
  • All immediate sub-terms are literals
  • The type of the expression is an allowed type for literals (e.g. not a function)

Note that this function only folds the top-level node of an expressions (if possible). It does not reduce an expression like 1+(2+3) where the sub-expression 2+3 is not a literal.

constArgs :: AST FeldDomain sig -> Bool Source #

Check whether all arguments of a symbol are literals

deleteVar :: Name -> Opt a -> Opt a Source #

cmInterface :: CodeMotionInterface FeldDomain Source #

Interface for controlling code motion

optimize :: OptEnv -> ASTF FeldDomain a -> ASTF FeldDomain a Source #

Optimize a Feldspar expression