Skip to content

Unsigned comparisons #2812

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gretay-js
Copy link
Contributor

The middle-end/backend can already emit unsigned comparisons. This PR exposes them as the following new builtins to the users: %lessequal_unsigned %lessthan_unsigned %greaterequal_unsigned %greaterthan_unsigned and compare_unsigned for int and boxed/unboxed int32/int64/nativeint, reusing the existing typed-based translation of compare primitives.

The main changes are in Lambda and Translprim. The rest of the PR is refactoring to propagate the signed/unsigned information to the middle end.

This is a draft because it's completely untested.

Copy link
Contributor

@TheNumbat TheNumbat left a comment

Choose a reason for hiding this comment

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

This approach looks good, I can review in more detail after you add tests

@@ -60,15 +61,15 @@ type comparison =
| Compare

type comparison_kind =
| Compare_generic
| Compare_ints
| Compare_generic of { signed : bool }
Copy link
Contributor

Choose a reason for hiding this comment

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

Polymorphic comparison probably shouldn't have an unsigned option, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. They all start as Compare_generic in lookup_primitive. I will try to move this bool to the Comparison constructor of prim, it'll be cleaner. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants