-
Notifications
You must be signed in to change notification settings - Fork 11
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
Float128 calling convention and alignment #4
Comments
Just a thought, have you try to add a |
how do I do that? is that an undocumented calling convention? |
Ah, we don't seem to support it. Should I open an issue? |
I don't think our |
Note that I think you won't be able to use it in |
I see, thanks. |
I tried some experiments following @yuyichao 's suggestion, for example function baz(x::Float128, y::Float128)
r = Base.llvmcall("""%f = inttoptr i64 %2 to <2 x double> (<2 x double>, <2 x double>)*
%vv = call x86_vectorcallcc <2 x double> %f(<2 x double> %0, <2 x double> %1)
ret <2 x double> %vv""",
Cfloat128, Tuple{Cfloat128,Cfloat128,Ptr{Cvoid}},
x.data, y.data, cglobal((:__addtf3,quadoplib)))
return Float128(r)
end Replacing methods in Quadmath with patterns like this works fine for Linux and OSX. It runs on Windows (no segfaults) but produces incorrect answers, apparently because the Windows version of libgcc_s doesn't return Float128 results in xmm0 as expected from the ABI. (AFAICT the value of xmm0 is preserved across the call.) |
Come to think about it, depending on if LLVM and GCC agrees on the calling convention, if you are already using llvmcall, you can probably directly use fp128 in it ;-p.... Other than that, I have no idea what calling convention gcc uses..... It is worth noting that GCC does NOT use the same vector calling convention as clang or msvc. (I didn't realize you are calling gcc compiled library....) I just finished dealing with a similar issue with vector calls on windows so I'm pretty positive on that....... You might have to check the assembly code to figure out what calling convention gcc is using..... =( |
we're calling into libquadmath, which is bundled as part of the gcc runtime (which we ship with Julia apparently) |
Not sure if it makes a difference, but did you change how |
Yes, I changed the Note that the Quadmath conversions, comparisons, and arithmetic are passed to libgcc_s (not libquadmath) in Windows and Linux. I was surprised to learn that LLVM FWIW, I found that IR using |
It seems that we have overthought this. The Windows libraries treat Float128 as a struct, so pointers should be used. I've started on this in PR #16. (Perhaps someone should notify the LLVM developers.) |
Fixed by #16. |
At the moment we fake the calling convention on Mac and Linux by reinterpreting as
NTuple{2,VecElement{Float64}}
. Unfortunately this doesn't seem to work on Windows.Upstream:
Also mentioned in
The text was updated successfully, but these errors were encountered: