Uh oh!
There was an error while loading. Please reload this page.
Implement simd_as for pointers - #98441
Conversation
rust-highfive
commented
Jun 24, 2022
(rust-highfive has picked a reviewer for you, use r? to override) |
Uh oh!
There was an error while loading. Please reload this page.
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.
calebzulawski
commented
Jul 1, 2022
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 |
calebzulawski
commented
Jul 1, 2022
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 |
RalfJung
commented
Jul 2, 2022
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. |
calebzulawski
commented
Jul 2, 2022
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. |
RalfJung
commented
Jul 2, 2022
Or should the semantics of these be that of |
calebzulawski
commented
Jul 2, 2022
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 |
calebzulawski
commented
Jul 2, 2022
This is well above my head. Everything in portable SIMD is done via intrinsics, so I'm not really sure what the alternative is |
RalfJung
commented
Jul 2, 2022
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. |
michaelwoerister
commented
Jul 4, 2022
r? rust-lang/libs (or is this even something for the lang team to discuss?) |
calebzulawski
commented
Jul 22, 2022
I've changed this PR to add 3 new pointer intrinsics, rather than overload |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
thomcc
commented
Aug 27, 2022
@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. |
RalfJung
commented
Aug 27, 2022
intrinsics are lang territory though. Exposing intrinsics is libs territory, but that's not what this PR does. |
thomcc
commented
Aug 28, 2022
I can r+ this on behalf of libs, but not the lang/compiler parts. |
RalfJung
commented
Aug 28, 2022
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) |
RalfJung
commented
Aug 28, 2022
r? compiler |
wesleywiser
commented
Sep 9, 2022
r? compiler |
oli-obk
commented
Sep 16, 2022
@bors r+ |
bors
commented
Sep 16, 2022
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
calebzulawski
commented
Sep 17, 2022
Thanks all! |
Expands
simd_as(andsimd_cast) to handle pointer-to-pointer, pointer-to-integer, and integer-to-pointer conversions.cc @programmerjake@thomcc