-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Global llvmcall statements #8308
Comments
perhaps there should just be a |
A function/macro About the scoping issue, doesn't the LLVM module always maps the Julia one? Or how would this be an issue? I'm not too familiar with the Julia core. |
Created PR #8673. |
|
#11604 is merged, this can be closed. |
I'm using
llvmcall
to hook-up certain intrinsics to Julia, but ran into the issue that intrinsics need to be declared, and this is currently not supported (for example, see this thread). I have two possible solutions for this problem, but I'd like some feedback before cleaning it up and sending a PR.My first idea was to do as @Keno proposed, automatically adding declarations for intrinsics. This proved messy, because I could not find a way to use the existing LLVM parsing machinery because of the missing declarations immediately aborting the parser/lexer. Duplicating this functionality seems hopeless, especially for complex declarations (
addrspace
annotations, function pointers, ...). Anyway, for very simple declarations it looked like this:What seemed like a more flexible solution, is to extend
llvmcall
such that the user can pass arbitrary declarations, which get pasted before the function definition when called for the first time. By allowing their
argument to be a tuple of(decls, ir)
, this is backwards compatible. Disadvantage: the addition of global state, to check whether a certain (arbitrary) declaration has been added already (because redeclaring identifiers is invalid, and trips the parser). I haven't found another way of checking whether certain declarations have been added to the module already (or we'd need to parse the declarations). This allows usingllvmcall
as follows:Any comments?
The text was updated successfully, but these errors were encountered: