-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature[next]: Inline center deref lift vars #1455
feature[next]: Inline center deref lift vars #1455
Conversation
@@ -125,7 +125,8 @@ def new_name(name): | |||
class InlineLambdas(PreserveLocationVisitor, NodeTranslator): | |||
"""Inline lambda calls by substituting every argument by its value.""" | |||
|
|||
PRESERVED_ANNEX_ATTRS = ("type",) | |||
# TODO: document that these annex attrs are preserved, but not used by the pass itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the TODO here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... in other passes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment about TODO
…enter_deref_lift_vars
…enter_deref_lift_vars
…enter_deref_lift_vars
Inline all variables which are derefed in the center only (i.e. unshifted).
Consider the following example where
var
is never shifted:let(var, (↑stencil)(it))(·var + ·var)
Directly inlining
var
would increase the size of the tree and duplicate the calculation.Instead, this pass computes the value at the current location once and replaces all previous
references to
var
by an applied lift which captures this value.let(_icdlv_1, stencil(it))(·(↑(λ() → _icdlv_1) + ·(↑(λ() → _icdlv_1))
The lift inliner can then later easily transform this into a nice expression:
let(_icdlv_1, stencil(it))(_icdlv_1 + _icdlv_1)