-
-
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
eliminate intrinsics #18754
eliminate intrinsics #18754
Conversation
copysign(x::Float64, y::Float64) = box(Float64,copysign_float(unbox(Float64,x),unbox(Float64,y))) | ||
copysign(x::Float32, y::Float32) = box(Float32,copysign_float(unbox(Float32,x),unbox(Float32,y))) | ||
copysign(x::Float64, y::Float64) = box(Float64, copysign_float(x, y)) | ||
copysign(x::Float32, y::Float32) = box(Float32, copysign_float(x, y)) |
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.
Extra space preceding y
in the method signature?
flipsign(x::Float64, y::Float64) = box(Float64,xor_int(unbox(Float64,x),and_int(unbox(Float64,y),0x8000000000000000))) | ||
flipsign(x::Float32, y::Float32) = box(Float32,xor_int(unbox(Float32,x),and_int(unbox(Float32,y),0x80000000))) | ||
flipsign(x::Float64, y::Float64) = box(Float64, xor_int(box(UInt64, x), and_int(box(UInt64, y), 0x8000000000000000))) | ||
flipsign(x::Float32, y::Float32) = box(Float32, xor_int(box(UInt32, x), and_int(box(UInt32, y), 0x80000000))) |
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.
Extra space preceding y
in the method signature here as well?
Cool, the For PTX we also need to call into |
d912744
to
6574027
Compare
|
||
.. _CUDA: http://llvm.org/docs/NVPTXUsage.html | ||
|
||
As with any ccall, it is essential to get the argument signature exactly correct. |
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.
code highlight ccall
jl_error(msg.c_str()); // TODO: this leaks memory | ||
} | ||
if (jl_is_cpointer_type(rt) && jl_is_typevar(jl_tparam0(rt))) | ||
jl_error("ccall: return type Ptr should have an element type, not Ptr{_<:T}"); |
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.
this Ptr{_<:T}
will be pretty confusing
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.
this isn't a new change
{ | ||
if (t->isFloatingPointTy()) | ||
return t; | ||
unsigned nb = (t->isPointerTy() ? t->getPrimitiveSizeInBits() : sizeof(void*)); |
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.
is this backwards?
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.
needs-test then if it was passing with a mistake here
if (t == T_float16) | ||
return T_int16; | ||
//if (t == T_float128) | ||
// return T_int128; |
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.
leave a comment or a cross-reference about why this is commented out (same below in JL_JLUINTT
and JL_JLSINTT
)
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.
this isn't a new change
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.
that's not a reason to leave unexplained things or lousy error messages in the code. while it's being rearranged is the right time to make these little improvements
#else | ||
Value *ret = builder.CreateCall3(prepare_call(jlpref_func), boxed(parg, ctx), iarg, alignarg); | ||
#ifdef JL_NEED_FLOATTEMP_VAR | ||
// Target platform might carry extra precision. |
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.
excess indent
needs a test for #18687 |
this isn't that kind of fix. this "fixes" the issue by deleting the special parsing code and the tests for it (of which apparently there were none). |
d175911
to
5595287
Compare
doesn't matter how it's being fixed. add a test. |
It's not fixed, it's deleted, along with all tests for it. |
That issue is about the fact that it works differently on master. To close that issue, and just in general, should add tests that it no longer works differently in this pr. Not asking for much here, tests and comments. Why are you fighting that? |
I'm not fixing that issue, I'm deleting the feature that the referenced issue complained about. |
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.
So what? You're replacing it with a new implementation that needs to be tested that it no longer has the undesirable behavior.
No, it's completely gone. The parser no longer has any knowledge of |
The implementation now happening in lowering instead of parsing doesn't change the fact that the parser behavior change for ccall should be tested and verified. |
How does the parser not implementing ccall not eliminate the need to test how the parser implements ccall? The parser no longer has any special behavior related to the symbol |
Because the parser used to implement ccall. If it hadn't had a custom implementation before, it would be fine. This is a change in behavior specifically for ccall, and that's the part that should now be tested. |
5595287
to
373cabd
Compare
why is llvmcall2 a separate file here? would the "nonsensical valid conversions and errors" tests have caught the mistake from #18754 (comment) ? |
It tests v2 of llvmcall. Yes, it includes coverage of that case. |
It occurs to me that after this change we should add t-functions for all intrinsics (previously we relied on their results always being passed to |
Yes, that's also on my list of eventually fixes for here (along with completely removing unbox and removing most calls to box) |
39680e3
to
cfe8efc
Compare
…anding to Expr(:ccall)
all intrinsics (but one) are now fully error-checking and runtime-interpreter-compatible
and remove the ducttape!
a handful of packages seem to have unused functions that are triggering this error
it was neutered by earlier commits, this just finishes deleting it
by adding type inference information to all of the intrinsics, the box intrinsic is no longer required for this purpose
this name better reflects what this intrinsic does, which is to change the type-tag on some data, without actually altering the data or its representation
7ebd07c
to
b34f47b
Compare
Cannot use it for all intrinsics as the libdevice ones aren't true intrinsics, and are rejected by the new llvmcall. Ref JuliaLang/julia#18754
After this, only 1 intrinsics (llvmcall
and some ccall fixes) remain to go to be fully interpretable and statically compilable!ccall
(and thus removesExpr(:ccall)
), fixes Inconsistent parsing ofccall
#18687Expr(:call, :ccall)
special in lowering (effectively, reservingccall
– as the keyword it already is) and which expands toExpr(:foreigncall)
representing the lowered ffi call (instead of expanding toExpr(:call, Core.Intrinsics.ccall)
, even though this couldn't really be a first-class function)ccall
for calling llvm intrinsics directly (via "llvmcall" calling convention)unbox
intrinsic is now just a deprecated alias for thebox
intrinsic (akareinterpret
)The ccall intrinsic now evaluates its global arguments during method definition time, eliminating the call back into the runtime from inside codegen (yay!), and making its semantics independent of runtime values (so that its behavior is statically compilable).
edit: see https://github.com/vtjnash/julep/wiki/0001:-Enhanced-static-compilation-and-C-interface