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

Add the posibility to type saved registers #284

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dbalatoni13
Copy link
Contributor

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.

Copy link
Collaborator

@simonlindholm simonlindholm left a 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()
Copy link
Collaborator

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]]:
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants