| Copyright | (C) 2012-2016 University of Twente 2016-2017 Myrtle Software Ltd 2017-2018 Google Inc. 2021-2026 QBayLogic B.V. |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Clash.Normalize.Transformations.Letrec
Description
Transformations on letrec expressions.
Synopsis
- deadCode :: Transformation
- deadCodeWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- flattenLet :: Transformation
- flattenLetWorker :: HasCallStack => NormRewrite
- recToLetRec :: HasCallStack => NormRewrite
- removeUnusedExpr :: Transformation
- removeUnusedExprCase :: TransformContext -> Term -> Term -> Type -> [Alt] -> NormalizeSession Term
- removeUnusedExprSpine :: HasCallStack => NormRewrite
- simpleCSE :: Transformation
- simpleCSEWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- topLet :: Transformation
- topLetWorker :: HasCallStack => NormRewrite
Documentation
deadCode :: Transformation Source #
Remove unused let-bindings
deadCodeWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
flattenLet :: Transformation Source #
Flatten's letrecs after inlineCleanup
inlineCleanup sometimes exposes additional possibilities for caseCon,
which then introduces let-bindings in what should be ANF. This transformation
flattens those nested let-bindings again.
NB: must only be called in the cleaning up phase.
flattenLetWorker :: HasCallStack => NormRewrite Source #
The Let handler of flattenLet; recurses on the rebuilt let-expression
after merging nested bindings.
recToLetRec :: HasCallStack => NormRewrite Source #
Turn a normalized recursive function, where the recursive calls only pass along the unchanged original arguments, into let-recursive function. This means that all recursive calls are replaced by the same variable reference as found in the body of the top-level let-expression.
removeUnusedExprCase :: TransformContext -> Term -> Term -> Type -> [Alt] -> NormalizeSession Term Source #
The Case handler of removeUnusedExpr: a single-alternative case whose
pattern binds no used variables is replaced by the alternative.
removeUnusedExprSpine :: HasCallStack => NormRewrite Source #
The application-spine handlers of removeUnusedExpr: replace unused
arguments of primitives (and Vecs Cons) with removedArg.
simpleCSE :: Transformation Source #
Simplified CSE, only works on let-bindings, does an inverse topological sort of the let-bindings and then works from top to bottom
XXX: Check whether inverse top-sort followed by single traversal removes as many binders as the previous "apply-until-fixpoint" approach in the presence of recursive groups in the let-bindings. If not but just for checking whether changes to transformation affect the eventual size of the circuit, it would be really helpful if we tracked circuit size in the regression/test suite. On the two examples that were tested, Reducer and PipelinesViaFolds, this new version of CSE removed the same amount of let-binders.
simpleCSEWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
topLet :: Transformation Source #
Ensure that top-level lambda's eventually bind a let-expression of which the body is a variable-reference.
topLetWorker :: HasCallStack => NormRewrite Source #
The worker of topLet: a plain rewrite, offered at every node.