clash-lib-1.6.5: Clash: a functional hardware description language - As a library
Copyright(C) 2012-2016 University of Twente
2016-2017 Myrtle Software Ltd
2017-2018 Google Inc.
2021-2022 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Normalize.Transformations.Letrec

Description

Transformations on letrec expressions.

Synopsis

Documentation

deadCode :: HasCallStack => NormRewrite Source #

Remove unused let-bindings

flattenLet :: HasCallStack => NormRewrite 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.

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.

simpleCSE :: HasCallStack => NormRewrite 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.

topLet :: HasCallStack => NormRewrite Source #

Ensure that top-level lambda's eventually bind a let-expression of which the body is a variable-reference.