-
Notifications
You must be signed in to change notification settings - Fork 85
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) add support for IntegerType packing with arbitrary bitwidth up to 64 #3728
Conversation
While the bug I hit was with |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3728 +/- ##
=======================================
Coverage 91.28% 91.28%
=======================================
Files 468 468
Lines 58601 58611 +10
Branches 5656 5656
=======================================
+ Hits 53492 53502 +10
Misses 3659 3659
Partials 1450 1450 ☔ View full report in Codecov by Sentry. |
Can we not just store each integer in |
yes, I think that makes sense. for larger than 64 bits we would need something else than struct.pack however |
it should be ceil(bitwidth/8) though |
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.
Great, thanks for the quick fix. What's the reason for using struct.pack
to store these instead of a tuple of ints? Is this more space efficient? The documentation for struct
seems to suggest it's mainly for C interop.
To answer my own question, apparently python ints are at least 28 bytes |
xdsl/dialects/builtin.py
Outdated
@@ -532,14 +532,14 @@ def print_value_without_type(self, value: int, printer: Printer): | |||
|
|||
@property | |||
def format(self) -> str: | |||
match self.bitwidth: | |||
case 1 | 8: | |||
match -(self.bitwidth // -8): # ceildiv |
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.
?
match -(self.bitwidth // -8): # ceildiv | |
match (self.bitwidth - 1) >> 3: |
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 isn't correct
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.
(7 + self.bitwidth) >> 3
works I think
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.
(self.bitwidth + 7) >> 3
is also used on L389 to compute the byte size of a FixedBitWidthType
, so i think that one makes sense
No description provided.