-
Notifications
You must be signed in to change notification settings - Fork 319
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
Allow gep
instructions to accept bare Python integers as indices.
#710
base: main
Are you sure you want to change the base?
Conversation
ir.Constants will be automatically constructed around Python integers if they are provided. The width of each converted integer will be chosen to be the smallest number of 8-bit bytes that can represent the value.
This changes the scheme to use i32s for all GEP indicies converted from Python ints, unless the index is too large to represent with an i32, in which case a wider integer is used.
@trbabb thank you for submitting this to the Numba issue tracker. I have added this to the 0.37.0 milestone. Also, it seems like there are some remaining flake8 issues to be resolved. |
Fixed the stray whitespace, but the overlong line is inlined SSA, which that file is already full of, and which I can't really truncate. What do I need to do to prevent that from failing the test? |
This should help: https://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html#in-line-ignoring-errors |
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.
Many thanks for the PR!
I like the idea of this change, but I think the changes to the tests need modifying. Instead of modifying an existing test case, could you add a new test case that tests accepting integers for the gep
instruction (and a mix of integers and ir.Constant
values) please?
i_type = types.IntType(bits) | ||
i = i_type(i) |
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.
i_type = types.IntType(bits) | |
i = i_type(i) | |
i = types.IntType(bits)(i) |
@trbabb Many thanks for the PR and your efforts so far! I'm spending some time going through the llvmlite PR backlog, and I have a couple of questions on this PR:
|
New feature:
gep
instructions can accept Python integers as indices, instead of requiring the client code to tediously construct ir.Constants around each index.For example:
becomes
The width of each converted integer will be chosen to be the smallest number of 8-bit bytes that is a power of two and can represent the value.
It is permissible to intermix Python integers with IR instructions in the index list.