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

backend: add full init to RegisterType #4020

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

superlopuh
Copy link
Member

A checkpoint in what I've been slowly working towards, we need to have a way to explicitly create the register we need, and not just from a string.

Verifier PR to follow.

@superlopuh superlopuh added the backend Compiler backend in xDSL label Mar 4, 2025
@superlopuh superlopuh self-assigned this Mar 4, 2025
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.18%. Comparing base (a9ee7c9) to head (a20b7b1).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4020      +/-   ##
==========================================
- Coverage   90.19%   90.18%   -0.01%     
==========================================
  Files         458      458              
  Lines       58319    58324       +5     
  Branches     5688     5689       +1     
==========================================
+ Hits        52598    52602       +4     
  Misses       4331     4331              
- Partials     1390     1391       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

return index_attr, spelling

@classmethod
def from_spelling(cls, spelling: StringAttr | str) -> Self:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name has been bothering me in the last few PRs, because in my mind spelling redirects to orthography.
Moreover, there is no mention in the RISC-V or Arm ISA specification manuals, so it is completely foreign.

Can't we call this simply and plainly from_name? I mean, we also have register_name at some point, and it won't affect verification even if I give an erroneous register name.

Lastly, for example, in the RISC-V case you have the register number and the register name (e.g., x8 and s0/fp).
The index will cover the register number part, while for xN this is just a mnemonic name of that, and the sN is the corresponding ABI name.

In any case, my point is that these are just names, and we should just call them that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully, this is just a find/replace kind of thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely agree, with the caveat that name is already taken. Let's discuss this on Zulip.

@superlopuh superlopuh merged commit 45dd50e into main Mar 5, 2025
17 checks passed
@superlopuh superlopuh deleted the sasha/registers/explicit-init branch March 5, 2025 13:57
superlopuh added a commit that referenced this pull request Mar 6, 2025
As noted by Chris in
#4020 (comment),
`spelling` is not the ideal name for the concept. `name` is already
taken, so I propose `register_name`. We already have a helper that
returns a `str` called `register_name`, which I propose to just remove.
@@ -5,23 +5,23 @@


def test_unallocated_register():
unallocated = x86.register.GeneralRegisterType("")
unallocated = x86.register.GeneralRegisterType.from_spelling("")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It means that, as before, the one and only difference between an allocated register and an unallocated one is that the former has a name/spelling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unallocated is always "" and None for name and index, and allocated is always != "", and not None for name and index.

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

Successfully merging this pull request may close these issues.

3 participants