This 🚧 draft 🚧 PR adds a control construct as found in Shady and performs a significant amount of refactoring on the IR to support closure conversion more robustly. This is not currently merge-able and exists as a tracking issue.
Current changelist:
Add control intrinsic and matching JoinPointType
Add an explicit ReturnType type that encodes the codomain of a function.
Use that as the ground-truth for whether a function is returning or not, in place of the order
Refactored a bunch of passes to use a unified Rewriter
Improve scoping analysis to produce a nesting
Made the scheduler::early use the new scoping analysis
Add a new World::scoped_dump that uses the new scope analysis to pretty-print IR
Add a graphviz IR dumping utility, that can also dump the world with scoping
Rewrite closure conversion entirely and make it robust
The lowering for this is tricky: setjmp/longjmp cannot be safely used inside functions because they can overwrite side effects that have happened in-between the control call and consuming the token. One solution is to emit cps-style code instead of direct-style, and then we can use tailcalls and perform manual stack pointer adjustments instead.
However there are backends where this will not be permissible (those who lack true function calls mostly) and we will need to find an alternative solution for those.
Still TODO:
🚧 Per-backend passes (in a way that doesn't break the kernels analysis)
Lower control to something sensible in non-shady backends
Aggressively eliminate closures for call-challenged backends
This 🚧 draft 🚧 PR adds a
control
construct as found in Shady and performs a significant amount of refactoring on the IR to support closure conversion more robustly. This is not currently merge-able and exists as a tracking issue.Current changelist:
control
intrinsic and matchingJoinPointType
ReturnType
type that encodes the codomain of a function.Rewriter
World::scoped_dump
that uses the new scope analysis to pretty-print IRThe lowering for this is tricky: setjmp/longjmp cannot be safely used inside functions because they can overwrite side effects that have happened in-between the
control
call and consuming the token. One solution is to emit cps-style code instead of direct-style, and then we can use tailcalls and perform manual stack pointer adjustments instead.However there are backends where this will not be permissible (those who lack true function calls mostly) and we will need to find an alternative solution for those.
Still TODO: