Make it explicit which parameter is the return address#176
Open
Make it explicit which parameter is the return address#176
Conversation
Contributor
Author
|
Ping @m-kurtenacker - you might also be interested in the mothballed closure conversion rewrite |
Contributor
Author
|
this now builds Rodent 🥳 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Revival of the previous "direct-style" changes in #138.
Unlike #138, this does not make function returns first-class values. Instead, we should have a pass that lowers captured returns to longjmp, implemented as an optional, backend-dependent feature.
Thorin uses a CpS IR which naturally represents function returns as continuations. While this form is elegant, it doesn't exactly map to the reality of what our targets can deal with: we actually expect that there is a "return continuation/parameter" that can be known by just looking at the order of the function type (how "deep" the
fn()type is). We also expect the return argument to always be to a continuation in the calling scope.Neither of these assumptions are particularly well enforced, and there is a lot of room for ambiguity. This PR adds a special
return_type()type constructor, much like how we also haveclosure_type(), only functions may have a return type param, and they have only one at most. Continuations (basic blocks) can be transformed into this type using thereturn_pointprimop.By making function returns their own type, we gain the following: