-
-
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
Extend llvmcall with support for entering declarations. #8740
Closed
Conversation
This file contains 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
It would be great to have something like this to be able to use LLVM intrinsics from with |
Is this related? immutable Matrix4x4
i_1::Float64
i_2::Float64
i_3::Float64
i_4::Float64
i_5::Float64
i_6::Float64
i_7::Float64
i_8::Float64
i_9::Float64
i_10::Float64
i_11::Float64
i_12::Float64
i_13::Float64
i_14::Float64
i_15::Float64
i_16::Float64
end
function mulllvm(a::Matrix4x4, b::Matrix4x4)
Base.llvmcall("""
%ptr = getelementptr <4 double>, %Matrix4x4* %0, i64 0, i64 0
%3 = load <4 x double>, <4 double>* %ptr
ret <4 x double> %3
""", NTuple{4, Float64},
(Matrix4x4, Matrix4x4),
a,b)
end
const x = Matrix4x4(rand(16)...)
println(mulllvm(x,x))
#yields:
ERROR: LoadError: error compiling mulllvm: Failed to parse LLVM Assembly:
julia: <string>:2:56: error: expected ')' at end of argument list
define <4 x double> @"julia_mulllvm_426531"(%Matrix4x4 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } ,%Matrix4x4 = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double } ) {
^
in include_from_node1 at loading.jl:129
while loading C:\Users\Sim\.julia\v0.4\playground.jl\llvmcall.jl, in expression starting on line 30
|
This would be really helpful for debugging codegen issues. |
ihnorton
added
needs decision
A decision on this change is needed
compiler:codegen
Generation of LLVM IR and native code
labels
Apr 2, 2015
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler:codegen
Generation of LLVM IR and native code
needs decision
A decision on this change is needed
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.
This is a copy of PR #8673 -- I accidentally created the old PR from my
master
branch, which isn't very clean.This PR adds support to
llvmcall
for inserting required declarations in the module. This is useful when you want tollvmcall
intrinsics, because LLVM refuses to parse IR with undeclared identifiers (for example, see this thread).The idea behind this solution is to allow passing a tuple
(decls, ir)
as first argument tollvmcall
, where currently only an IR string or a pointer to a LLVM function is allowed. Thedecls
IR is then pasted before the functionllvmcall
generates. In order to avoid duplicate declarations, which LLVM does not like, a global set keeps track of the declarations added to the current module.Example usage:
As mentioned in issue #8308 I also tried other approaches, such as automatically parsing identifiers in the IR, but that turned out pretty fragile.