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

floats: Add fcvt instructions for doubles, and fix their overflow behaviour to reflect the spec #53

Merged
merged 4 commits into from
May 14, 2024

Conversation

AntonLydike
Copy link
Owner

@AntonLydike AntonLydike commented May 14, 2024

This adds fcvt.d.w[u] and fcvt.w[u].d instructions, and fixes the fcvt.s.w[u] and fcvt.w[u].s instructions overflow behavior to correctly reflect the spec (Thanks Markus Böck for digging this out, as it's a bit difficult to find in the spec itself).

This also fixes a long standing bug in the way registers are stored that would introduce bugs in certain edge cases (registers are now always treated as signed values, just as the code expects in most places).

Pre-Merge Checklist:

  • I added an entry to the CHANGELOG.md
  • I added a test that covers my change
  • I ran the pre-commit formatting hooks
  • CI Passes

@AntonLydike AntonLydike added bug Something isn't working enhancement New feature or request labels May 14, 2024
@AntonLydike AntonLydike requested a review from superlopuh May 14, 2024 10:32
@AntonLydike AntonLydike self-assigned this May 14, 2024
@@ -284,3 +308,6 @@ def shift_right_logical(self, amount: Union["Int32", int]) -> "UInt32":
if isinstance(amount, Int32):
amount = amount.value
return UInt32(self.value >> amount)

def signed(self) -> "Int32":
return Int32(self)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How should this handle overflow/negative values? It may be worth making this explicit.

Copy link
Owner Author

Choose a reason for hiding this comment

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

The ctypes.c_[u]int32 this wraps handles them natively when constructing a c_int32 from a c_uint32. I can make it more explicit by passing the ctypes type!

@AntonLydike AntonLydike merged commit 5e758a2 into master May 14, 2024
3 checks passed
@AntonLydike AntonLydike deleted the anton/correctly_model_float_convert_actions branch May 14, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants