-
Notifications
You must be signed in to change notification settings - Fork 80
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
xdsl/utils/comparisons.py
Outdated
|
||
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 |
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.
why not just (min, max)
?
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.
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.
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'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)
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 a me being ambiguous thing, I meant for the ()
to be tuple begin end markers, I'll rephrase
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.
How's the new version?
xdsl/utils/comparisons.py
Outdated
|
||
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 |
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 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)
"
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.
Yes, I like this better
…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`.
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
.