-
Notifications
You must be signed in to change notification settings - Fork 49
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
Add the posibility to type saved registers #284
base: master
Are you sure you want to change the base?
Conversation
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.
Looks reasonable, although I think you might currently be ~the only user of --reg-vars so it's not going to see a lot of use. :) Extending it to setup_planned_vars
or temp vars would make it a lot more useful, although, that looks a bit tricky, with the naming there being performed lazily...
corresponding_regs = [ | ||
r | ||
for r in regs | ||
if reg_field.name.endswith(str(r).removeprefix("$")) and not r.is_float() |
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.
reg_name = stack_info.function.reg_formatter.format(reg)
name == f"var_{reg_name}"
I think. Why the and not r.is_float()
?
Actually, hm, instead of hard-coding variable name, it might be cleaner if this function just parsed out a struct field name -> type mapping, and then add_register_var
did the register -> struct field name lookup, since that is the one who knows the variable name.
@@ -4365,6 +4368,34 @@ def setup_planned_vars( | |||
stack_info.planned_vars[key] = var | |||
|
|||
|
|||
def get_declared_reg_types( | |||
stack_info: StackInfo, regs: List[Register] | |||
) -> [Dict[Register, Type]]: |
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.
this is invalid type syntax -- the [] need to be removed. Can you run mypy?
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.
You are right. Sorry, I didn't get a notification so I completely forgot about this PR, I will get back to it once I have time.
This is often useful when a void* is cast to a specific type and loaded into a saved register. It should be tested whether it causes issues in optimized code.