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

[mypyc] Foundational work to help support native ints #12884

Merged
merged 28 commits into from
Jun 11, 2022

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented May 27, 2022

Some IR and codegen changes that help with native int support.

This was split off from a branch with a working implementation of
native ints to make reviewing easier. Some tests and primitives
are missing here and I will include them in follow-up PRs.

Summary of major changes below.

  1. Allow ambiguous error returns from functions. Since all values
    of i64 values are valid return values, none can be reserved for
    errors. The approach here is to have the error value overlap a
    valid value, and use PyErr_Occurred() as a secondary check
    to make sure it actually was an error.

  2. Add Extend op which extends a value to a larger integer
    type with either zero or sign extension.

  3. Improve subtype checking with native int types.

  4. Fill in other minor gaps in IR and codegen support for native
    ints.

Work on mypyc/mypyc#837.

# If True, error/undefined value overlaps with a valid value. To detect
# an exception, PyErr_Occurred() must be used in addition to checking for
# error value.
error_overlap = False
Copy link
Member

Choose a reason for hiding this comment

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

This concept is a bit counterintuitive, so maybe specifically give an example of fixed ints here? Also do I understand correctly that the only kind of error that can happen is an overflow (zero division could only come from float)?

@JukkaL JukkaL merged commit ddbea69 into master Jun 11, 2022
@JukkaL JukkaL deleted the native-int-foundation branch June 11, 2022 18:19
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 this pull request may close these issues.

2 participants