Skip to content
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

VIL code generator has knowledge of x86 return register #158

Open
iafisher opened this issue Sep 1, 2022 · 0 comments
Open

VIL code generator has knowledge of x86 return register #158

iafisher opened this issue Sep 1, 2022 · 0 comments
Labels
internal Issues which do not affect end users

Comments

@iafisher
Copy link
Owner

iafisher commented Sep 1, 2022

vil::Register::ret() returns a register with index 13, which maps to RAX in x86. There is actually no ret instruction in VIL; instead, the code generated for a return statement places the value of the expression in vil::Register::ret() and then jumps to the function's return label (so that every function has a single place of return).

The reason VIL has no ret instruction is that the x86 code generator needs to generate some code after the last instruction of the function but before the return to clean up the stack frame, but that would be awkward if ret were a regular instruction. Probably the solution is to move the stack clean-up logic in an abstracted form into VIL, and add a ret instruction to VIL that takes a register argument and let the x86 generator handle moving that register into RAX.

@iafisher iafisher added the internal Issues which do not affect end users label Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issues which do not affect end users
Projects
None yet
Development

No branches or pull requests

1 participant