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

Arithmetic operators on Bits #587

Closed
cdonovick opened this issue Feb 13, 2020 · 2 comments · Fixed by #792
Closed

Arithmetic operators on Bits #587

cdonovick opened this issue Feb 13, 2020 · 2 comments · Fixed by #792
Assignees

Comments

@cdonovick
Copy link
Collaborator

Currently every implementation of AbstractBitVector other than Bits supports the use of arithmetic __operators__ (__add__, __sub__, etc...). While not specifically defined in the abc this had lead to a widespread assumption that AbstractBitVector supports these operators, further, it leads to PEak code that works in every context except for magma.

For example the following mantle test assume that BitVector defines __add__
https://github.com/phanrahan/mantle/blob/master/tests/test_coreir/test_arith.py#L10

Now, I believe that one following must happen:

  • Bits needs to add support for arithmetic ops,
  • we need to remove them from BitVector so that two are consistent
  • we need to create a MagmaBV distinct from Bits behaves like the rest of hwtypes.

Now removing support for arithmetic in BitVector would mean breaking almost every consumer of hwtypes. Adding them to Bits or creating a MagmaBV would break nothing.

@cdonovick
Copy link
Collaborator Author

Personally I think the easiest would be to add MagmaBV with the new magma protocol it would be very easy to get it to work with the rest of the infrastructure. While unifying the the interfaces between magma and hwtypes.

@rdaly525
Copy link
Collaborator

I believe we should keep all arithmetic operators (along with operations like sext) on hwtypes.BitVector and hwtypes.SMTBitVector as this maintains the QF BV SMT semantics. It is definitely annoying to have magma.Bits behave differently here when using it as a peak compilation target, so creating a consistent MagmaBV seems like a reasonable idea.

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 a pull request may close this issue.

5 participants