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

dialects: (builtin) move value range helper definitions to utils #3550

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

superlopuh
Copy link
Member

This flips the dependency of the two files, I'd like to add some more helpers to the utils one for use in builtin.py.

@superlopuh superlopuh added the dialects Changes on the dialects label Dec 2, 2024
@superlopuh superlopuh self-assigned this Dec 2, 2024
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.39%. Comparing base (cc60fc2) to head (3b50cd7).
Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3550      +/-   ##
==========================================
+ Coverage   90.37%   90.39%   +0.01%     
==========================================
  Files         466      466              
  Lines       58555    58645      +90     
  Branches     5585     5585              
==========================================
+ Hits        52920    53012      +92     
+ Misses       4206     4202       -4     
- Partials     1429     1431       +2     

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


def unsigned_value_range(bitwidth: int) -> tuple[int, int]:
"""
For a given bitwidth, returns (min, max+1), where min and max are the smallest and
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just (min, max)?

Copy link
Member Author

Choose a reason for hiding this comment

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

It slightly complicates some calculations, which is not a big deal, but a little annoying. I also find that this inclusive-lb-exclusive-ub form is more intuitive.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if this is a mathematician thing but this can also be written by saying that the integer takes values in the range [min, max)

Copy link
Member Author

Choose a reason for hiding this comment

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

this is a me being ambiguous thing, I meant for the () to be tuple begin end markers, I'll rephrase

Copy link
Member Author

Choose a reason for hiding this comment

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

How's the new version?


def signless_value_range(bitwidth: int) -> tuple[int, int]:
"""
For a given bitwidth, returns the range `[min, max+1)`, where min and max are the
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think my suggestion has confused things. How about:
"For a given bitwidth, returns a tuple (min, max), such that signless integers of this bitwidth are in the range [min, max)"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I like this better

@superlopuh superlopuh merged commit 4cac115 into main Dec 2, 2024
15 checks passed
@superlopuh superlopuh deleted the sasha/builtin/convert-signedness branch December 2, 2024 16:11
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
…lproject#3550)

This flips the dependency of the two files, I'd like to add some more
helpers to the utils one for use in `builtin.py`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants