-
Notifications
You must be signed in to change notification settings - Fork 5
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
Implement the register
keyword
#13
Comments
A little update to this is that we moved the frame pointer from the zero page to the return stack. It sits on top of the return address.
So this conflicts a little with our other plan of using the top of the return stack as a register and A little cost comparison of operations (if we optimize well)…
|
I guess a second short on the return stack would only make sense for loop variables. If we can optimize really well, maybe it also works for other things where all the arithmetic can be done directly on the return stack.
|
Oh, if you have one |
Currently all local variables and function arguments get written to and read from an in-memory stack (
@rbp
). This makes for pretty ugly and inefficient assembly. In many cases such variables never have their address taken, so it would be possible to skip this. Any modern compiler would optimise this away with a series of passes that do alias analysis etc, but we want to keep this compiler simple and single-pass-ish, so let's do things the old-fashioned way: implement theregister
keyword!I was thinking of putting
register
variables on the uxn working stack, but after hearing my concerns about how many operations might be needed to access something buried deep in the stack by temporaries, lynn pointed out you can also use the uxn return stack to store data, so that might be worth trying instead. :3For function arguments annotated with
register
, it would be nice to have this work together with #12 so they don't need copying within the callee at all.The text was updated successfully, but these errors were encountered: