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

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

pattern LamP :: forall t sup t1. (:<:) BindingT sup => forall a a1 b. ((~#) * * ((:->) a t1) ((:->) b (Full (a1 -> b))), Typeable * a1) => t (DenResult ((:->) a t1)) -> Name -> AST ((:&:) sup t) (Full a) -> AST ((:&:) sup t) t1 Source #

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

pattern NonLitP :: forall a. ASTF FeldDomain a Source #

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

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

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

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

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

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

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

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

pattern DivBalancedP :: forall a. () => (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