raw-feldspar-0.3: 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 :: Type -> Type) (sup :: Type -> Type) sig. sub :<: sup => TypeRep (DenResult sig) -> sub sig -> AST (sup :&: TypeRepFun) sig Source #

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

pattern LamP :: forall (sup :: Type -> Type) (info :: Type -> Type) sig. BindingT :<: sup => forall a a1 b. ((a :-> sig) ~# (b :-> Full (a1 -> b)), Typeable a1) => info (DenResult (a :-> sig)) -> Name -> AST (sup :&: info) (Full a) -> 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 #

pattern NonLitP :: forall 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