-
Notifications
You must be signed in to change notification settings - Fork 349
Add support for opaque pointers #1064
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bb59414
[llvmlite] Add support for opaque pointers
rj-jesus 2dc1f91
[llvmlite] Separate opaque and typed pointer types
rj-jesus f0f3562
[llvmlite] Minor code formatting fixes
rj-jesus 893ed91
Merge branch 'main' of github.com:numba/llvmlite into rjj/enable-opaq…
rj-jesus 3f93a04
Address review comments
rj-jesus f3685b6
Fix few missing changes
rj-jesus d704942
Address comments
rj-jesus a9ae1f2
Add Opaque pointers to CI configuration
gmarkall 87e2be0
Add a couple of examples with opaque pointers
rj-jesus e36892b
Make notes on typed pointer deprecation
gmarkall e2365e5
Add documentation for opaque pointers
gmarkall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,11 @@ | ||
|
|
||
| call activate %CONDA_ENV% | ||
|
|
||
| if "%OPAQUE_POINTERS%"=="yes" ( | ||
| set LLVMLITE_ENABLE_OPAQUE_POINTERS=1 | ||
| echo "Testing with opaque pointers enabled" | ||
| ) else ( | ||
| echo "Testing with opaque pointers disabled" | ||
| ) | ||
|
|
||
| python runtests.py -v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import llvmlite | ||
| llvmlite.opaque_pointers_enabled = True | ||
|
|
||
| import llvmlite.ir as ll | ||
|
|
||
| fntype = ll.FunctionType(ll.IntType(32), [ll.IntType(32), ll.IntType(32)]) | ||
|
|
||
| module = ll.Module() | ||
|
|
||
| func = ll.Function(module, fntype, name='foo') | ||
| bb_entry = func.append_basic_block() | ||
|
|
||
| builder = ll.IRBuilder() | ||
| builder.position_at_end(bb_entry) | ||
|
|
||
| stackint = builder.alloca(ll.IntType(32)) | ||
| # Instead of stackint.type.pointee we can access stackint.allocated_type | ||
| # directly. | ||
| builder.store(ll.Constant(stackint.allocated_type, 123), stackint) | ||
| myint = builder.load(stackint) | ||
|
|
||
| addinstr = builder.add(func.args[0], func.args[1]) | ||
| mulinstr = builder.mul(addinstr, ll.Constant(ll.IntType(32), 123)) | ||
| pred = builder.icmp_signed('<', addinstr, mulinstr) | ||
| builder.ret(mulinstr) | ||
|
|
||
| bb_block = func.append_basic_block() | ||
| builder.position_at_end(bb_block) | ||
|
|
||
| bb_exit = func.append_basic_block() | ||
|
|
||
| pred = builder.trunc(addinstr, ll.IntType(1)) | ||
| builder.cbranch(pred, bb_block, bb_exit) | ||
|
|
||
| builder.position_at_end(bb_exit) | ||
| builder.ret(myint) | ||
|
|
||
| print(module) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe it's worth noting this is only valid for alloca instructions since they have a clear "allocated type" (https://llvm.org/docs/doxygen/Instructions_8h_source.html#l00115).