| Copyright | (C) 2012-2016 University of Twente 2016-2017 Myrtle Software Ltd 2017-2022 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.Inline
Description
Transformations for inlining
Synopsis
- bindConstantVar :: Transformation
- bindConstantVarWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- inlineBndrsCleanup :: HasCallStack => InScopeSet -> VarEnv ((Id, Term), VarEnv Int) -> VarEnv ((Id, Term), VarEnv Int, Mark) -> [((Id, Term), VarEnv Int)] -> [(Id, Term)]
- inlineCast :: Transformation
- inlineCastWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- inlineCleanup :: Transformation
- inlineCleanupWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- collapseRHSNoops :: Transformation
- collapseRHSNoopsWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- inlineNonRep :: HasCallStack => NormRewrite
- inlineOrLiftNonRep :: Transformation
- inlineOrLiftNonRepWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- inlineSimIO :: Transformation
- inlineSimIOWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term
- inlineSmall :: Transformation
- inlineSmallWorker :: HasCallStack => NormRewrite
- inlineWorkFree :: Transformation
- inlineWorkFreeWorker :: HasCallStack => NormRewrite
Documentation
bindConstantVar :: Transformation Source #
Inline let-bindings when the RHS is either a local variable reference or is constant (except clock or reset generators)
Inlining a local variable reference loses the name of its binder, even when
the user wrote it. For example, in let b = a in ..., where the user named
both a and b, only a ends up in the HDL. The same goes for a parameter
of an inlined function whose argument is a variable named by the user. We'd
like to keep such aliases, so that the HDL shows both names, e.g.
assign b = a;. However, keeping them would probably break constant
propagation, such as for the reset values of registers.
bindConstantVarWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
The Let handler of bindConstantVar.
Arguments
| :: HasCallStack | |
| => InScopeSet | Current InScopeSet |
| -> VarEnv ((Id, Term), VarEnv Int) | Original let-binders with their free variables (+ #occurrences), that we want to inline |
| -> VarEnv ((Id, Term), VarEnv Int, Mark) | Processed let-binders with their free variables and a tag to mark the progress: * Temp: Will eventually form a recursive cycle * Done: Processed, non-recursive * Rec: Processed, recursive |
| -> [((Id, Term), VarEnv Int)] | The let-binders with their free variables (+ #occurrences), that we want to keep |
| -> [(Id, Term)] |
Used by inlineCleanup to inline binders that we want to inline into the
binders that we want to keep.
inlineCast :: Transformation Source #
Only inline casts that just contain a Var, because these are guaranteed work-free.
These are the result of the splitCastWork transformation.
inlineCastWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
The Let handler of inlineCast.
inlineCleanup :: Transformation Source #
Given a function in the desired normal form, inline all the following let-bindings:
Let-bindings with an internal name that is only used once, where it binds: * a primitive that will be translated to an HDL expression (as opposed to a HDL declaration) * a projection case-expression (1 alternative) * a data constructor * I/O actions
inlineCleanupWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
The Let handler of inlineCleanup.
collapseRHSNoops :: Transformation Source #
Takes a binding and collapses its term if it is a noop. Only runs at synthesis boundaries (NOINLINE/OPAQUE functions) to avoid running too early on functions that might be inlined later. See #3036.
collapseRHSNoopsWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
The Let handler of collapseRHSNoops.
inlineNonRep :: HasCallStack => NormRewrite Source #
Inline function with a non-representable result if it's the subject
of a Case-decomposition. It's a custom topdown traversal that -for efficiency
reasons- does not explore alternative of cases whose subject triggered an
inlineNonRepWorker.
inlineOrLiftNonRepWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
The Let handler of inlineOrLiftNonRep.
inlineSimIO :: Transformation Source #
Inline anything of type SimIO: IO actions cannot be shared
inlineSimIOWorker :: HasCallStack => TransformContext -> Term -> Bind Term -> Term -> NormalizeSession Term Source #
The Let handler of inlineSimIO.
inlineSmall :: Transformation Source #
Inline small functions
inlineSmallWorker :: HasCallStack => NormRewrite Source #
The application-spine handler of inlineSmall.
inlineWorkFree :: Transformation Source #
Inline work-free functions, i.e. fully applied functions that evaluate to
a constant. Applications to closed arguments are normalized before they're
inlined, see normalizeWorkFreeApp.
inlineWorkFreeWorker :: HasCallStack => NormRewrite Source #
The application-spine handler of inlineWorkFree.