-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Implement simd_as for pointers #98441
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
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.
lgtm
Hm. Unless I am misunderstanding which part of the interface you are trying to model here, this behavior should probably be a separate intrinsic rather than be behind |
imho we need a simd equivalent to |
This comment was marked as duplicate.
This comment was marked as duplicate.
Yeah, there is no intention to make integer |
It's not clear to me we necessarily want the default cast to use the semantics of cc @RalfJung |
Not sure what you mean by "invalid". At least some people intent to basically deprecate There is also Given all the problems with |
I suppose by "intention" I meant that it's obviously a commonly used feature and requires an edition change, and future compilers will still need it to support old editions. Maybe in a (fairly far away) future edition of rust there will be no Without |
https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.cast We still need a method to explicitly change mutability. I didn't say we are there yet. And indeed Anyway, I am mostly concerned about casts between pointers and integers. Those are very different from the other casts, and that's why we now have dedicated methods with very detailed documentation for ptr2int casts and int2ptr casts. |
It's worth noting that I intend on implementing (and have already partially) the strict provenance API for std::simd--I just can't add some of these functions without a cast intrinsic. |
Right, this is just the intrinsic, nothing user-facing. However, I don't think it is a good idea to lump together So IMO it would also be better to make their SIMD versions separate intrinsics. |
Or should the semantics of these be that of |
I really just need the exposing casts, I've already implemented the others via transmute. Are there equivalent scalar pointer cast intrinsics I can reference? I implemented it with the |
They are not exposed as intrinsics, they are (for historic reasons) exposed via IMO they should be separate |
This is well above my head. Everything in portable SIMD is done via intrinsics, so I'm not really sure what the alternative is |
I think what you should do is to have a dedicated intrinsic for "SIMD expose_addr", and another dedicated intrinsic for "SIMD from_exposed_addr", and have That very roughly corresponds to how these operations are/should also be represented differently in MIR. |
r? rust-lang/libs (or is this even something for the lang team to discuss?) |
I've changed this PR to add 3 new pointer intrinsics, rather than overload |
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.
lgtm
@michaelwoerister Hmm, why did you request review from libs? This is all compiler code. |
i'd guess because we're expanding intrinsics' API so libs might have an opinion on their API. |
intrinsics are lang territory though. Exposing intrinsics is libs territory, but that's not what this PR does. |
I can r+ this on behalf of libs, but not the lang/compiler parts. |
None of these simd intrinsics are exposed on stable, so I don't think lang has been involved much so far. I expect that will be all discussed together when (some subset of) |
r? compiler |
r? compiler |
@bors r+ |
Implement simd_as for pointers Expands `simd_as` (and `simd_cast`) to handle pointer-to-pointer, pointer-to-integer, and integer-to-pointer conversions. cc `@programmerjake` `@thomcc`
Rollup of 6 pull requests Successful merges: - rust-lang#93628 (Stabilize `let else`) - rust-lang#98441 (Implement simd_as for pointers) - rust-lang#101790 (Do not suggest a placeholder to const and static without a type) - rust-lang#101807 (Disallow defaults on type GATs) - rust-lang#101915 (doc: fix redirected link in `/index.html`) - rust-lang#101931 (doc: Fix a typo in `Rc::make_mut` docstring) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Thanks all! |
Expands
simd_as
(andsimd_cast
) to handle pointer-to-pointer, pointer-to-integer, and integer-to-pointer conversions.cc @programmerjake @thomcc