-
-
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
Add llvmcall #5046
Add llvmcall #5046
Conversation
Having Is this good to merge? |
I am also looking forward to this. |
It is good to add some documentation of |
Any chance to see this merged before 0.3? The examples of #4042 could be used as documentation. |
I have an issue with llvmcall, am finding that the IR generated does not have quotes around the defined LLVM function name, when the Julia function calls llvmcall: using Base.llvmcall
function +(x::Int32, y::Int32)
llvmcall("""%3 = add i32 %1, %0
ret i32 %3""", Int32, (Int32, Int32), x, y)
end
code_llvm(+, (Int32, Int32)) Output:
It's lacking quotes around the LLVM function, like the standard + function:
|
I also want to see this land before 0.3/ |
@loladiro @JeffBezanson Is this possible for 0.3? |
I am trying to add support for PTX intrinsics in Julia using llvmcall. However, when using this in a Julia function, I always encounter the following problem: declare function:
retrieve llvm IR of this function:
However, if I execute the same code_llvm command again directly after this, It works (correct IR is returned). How can I avoid this error when compiling for the first time? It seems like the intrinsic should be declared first, but is it possible to achieve this using llvmcall? |
You raise a valid point. I believe the way to do this is probably to just go through all unreferenced functions and look them up in the global function table (or if they are intrinsics try to find them). Shouldn't be too hard. I may have a look at it over the weekend. |
I have another use case where the above mentioned problem occurs. In my project, I need to declare and get a reference to global variables on the fly. However, with llvmcall, all code is added to the module in a function scope and I need to add global variables. Currently I see two possibilities to solve this problem:
What do you think is the best solution? Or is there another way of solving this problem? |
Rebased on top of current master and added the ability to just pass a pointer to an llvm::Function*. Together with staged functions that is a very powerful combination. |
Travis originally failed due to an unrelated crash. I restarted the travis build and will merge once that passes since it's 0.4 now. |
@Keno, if you ever get a chance, I'd love to see even a short write up of good uses for this |
I'll put it on the todo list ;) |
f = m->getFunction(ir_name); | ||
} else { | ||
assert(isPtr); | ||
// Create Function sceleton |
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.
small typo: sceleton -> skeleton
It it would make a great blog post showing off some of the things you can do with this. @IainNZ you can look at Cxx.jl which uses this functionality already. Another example is in the tests, SIMD instructions!. |
Note that you may have to |
I wonder what will be the first of these new merges to set off all the PackageEvaluator alarms :D |
Can't wait ;) |
Nice! @pieterverstraete, your application sounds pretty interesting! Now that this is merged, I'll keep my fingers crossed. |
I don't think this is general enough to do what he wanted. Ptx requires a On Tuesday, August 12, 2014, Tim Holy notifications@github.com wrote:
|
needs docs |
Contents removed; see #8308. |
We're not allergic to new issues, and that would allow your feature request to be tracked more easily. Adding it to a closed issue means that we don't have the ability to tag, milestone, or use the other tools available to us to work with it. It's appropriate to cross-reference this issue in the new one, but please do open a new issue. |
Okay, will repost in a new issue. |
Thanks! |
This adds
llvmcall
as described in #4042. This is the simple version of this intrinsic.I have another version that basically takes functions in place of the IR and the various type declarations, allowing you to integrate any llvm based compiler. I'm a lot less sure about that interface than I am about this one, but I figured I'd mention it in this context anyway, since it's another point of discussion that's fairly similar (in particular, how do we efficiently do inline IR,C,ASM,D,whatever)?