-
Notifications
You must be signed in to change notification settings - Fork 131
Stablize variable typing and support integer truncation and sign extension #201
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
Conversation
Regards to the issue of sign extension on rv32 backend, should we introduce a compiler parameter |
It is a good idea. However, we then need to an effective way to select the extensions for RISC-V backend. |
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.
I think these changes look good. Please squash the commits.
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.
Please write commit messages for the first three commits.
In this patch, all variables (including IR generated variables) are now guaranteed to have default type "int" to later used for integer resizing, this includes truncation and sign extension. Currently, only following cases will generate resizing opcodes (OP_trunc & OP_sign_ext): - variable assignment to registers - function parameter preparation, variadic function parameters are default to have size of int type Additionally, several data structures and memory managements are adjusted to have extensibility, this includes local variable and syntactic block allocation. Close sysprog21#166.
I'll squash them as well to keep it tidy and simple. |
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.
LGTM
Thank @ChAoSUnItY for contributing! |
Stablize variable typing and support integer truncation and sign extension
Stablize variable typing and support integer truncation and sign extension
This is a attempt to support variable typing for all local variables (including synthesized ones) so that integer truncation and sign extension could be implemented, which targets to fix #166.
Notice that there's still some works including type derivation from operators and code cleanup.
About sign extension in rv32
It seems that package
qemu-user
is currently outdated (6.2.0) so Zbb extension is not supported, which results in the implementation of sign extension in rv32 currently using straightforward way to implement, that is bitwise shifting.Summary by Bito
This pull request enhances the variable typing system by implementing support for integer truncation and sign extension, optimizing memory allocation for local variables, and improving error handling. It addresses issue #166 and includes unit tests to ensure the reliability of these enhancements.Unit tests added: True
Estimated effort to review (1-5, lower is better): 2 - The changes are well-structured and documented, making the review process straightforward.