-
Notifications
You must be signed in to change notification settings - Fork 13.5k
repr(scalable)
#143924
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
base: master
Are you sure you want to change the base?
repr(scalable)
#143924
Conversation
rustbot has assigned @compiler-errors. Use |
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_attr_data_structures Some changes occurred in compiler/rustc_passes/src/check_attr.rs Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred to the platform-builtins intrinsics. Make sure the cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred in compiler/rustc_codegen_gcc changes to the core type system Some changes occurred to the CTFE machinery |
Extend parsing of `ReprOptions` with `repr(scalable(N))` which always accepts a single literal integral value - the base multiple of lanes that are in a scalable vector. Can only be applied to structs and must be used with `repr(simd)`. Co-authored-by: Jamie Cunliffe <[email protected]>
Add a `repr_scalable` feature gate and require its use for the `repr(scalable(N)` attribute. Co-authored-by: Jamie Cunliffe <[email protected]>
Extend well-formedness checking and HIR analysis to prohibit the use of scalable vectors in structs, enums, unions, tuples and arrays. LLVM does not support scalable vectors being members of other types, so these restrictions are necessary. Co-authored-by: Jamie Cunliffe <[email protected]>
Scalable vectors can be passed by register over the FFI boundary to C code, so they shouldn't be linted by `improper_ctypes`.
I've changed this back to a draft and marked it as |
0ed0434
to
cf9474d
Compare
Scalable vectors should behave like other value types - being permitted as arguments, locals, return types, etc. This requires that these types be `Sized`, despite not meeting the definition and requirements of `Sized`. `feature(sized_hierarchy)` is being implemented to enable scalable vectors to be non-`const Sized`, but in the mean time, add a builtin impl for scalable vectors. This must be addressed prior to stabilisation.
`simd_reinterpret` is a replacement for `transmute`, specifically for use with scalable SIMD types. It is used in the tests for scalable vectors and in stdarch. Co-authored-by: Jamie Cunliffe <[email protected]>
cf9474d
to
d58c634
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Introduces `BackendRepr::ScalableVector` corresponding to scalable vector types annotated with `repr(scalable)` which lowers to a scalable vector type in LLVM. Co-authored-by: Jamie Cunliffe <[email protected]>
LLVM doesn't handle stores on `<vscale x N x i1>` for `N != 16`, a type used internally in SVE intrinsics. Spilling to the stack to create debuginfo will cause errors during instruction selection. These types that are an internal implementation detail to the intrinsic, so users should never see them types and won't need any debuginfo. Co-authored-by: Jamie Cunliffe <[email protected]>
Scalable vectors cannot be members of ADTs and thus cannot be kept over await points in async functions.
0c22701
to
3ad0898
Compare
This comment has been minimized.
This comment has been minimized.
As scalable vectors are ultimately just registers, they should be able to implement `Copy` and `Clone`, which require some small special-casing in the compiler to ignore the field within the scalable vector types.
This comment has been minimized.
This comment has been minimized.
5c92874
to
3edf1b6
Compare
Scalable vector types only work with the relevant target features enabled, so require this for any function with the types in its signature.
Trivial changes to rust-analyzer to keep it compiling with changes to `ReprOptions`.
This comment has been minimized.
This comment has been minimized.
3edf1b6
to
4f6b823
Compare
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.
I do not intend to have repr(simd)
survive this year, so I do not think this should be added.
Could you elaborate? |
I intend to replace it with an approach based on lang items for a variety of reasons, one of them being that to start with, the |
Likewise, scalable vectors do not really have a diversity in their representation. They either go in the scalable vector registers or they don't. They are one type, even if it is parameterized by the element type (and possibly the CPU's Matrix state, idk). |
I think this discussion is better for the RFC - rust-lang/rfcs#3838 - rather than the implementation. With that said, I definitely don't think this should to be blocked by your intentions to change Nothing in rust-lang/rfcs#3838 should make your plans impossible as it's just more internal infrastructure that could easily be changed to something else with a well-motivated proposal, no different than |
So you want me to race you? |
|
☔ The latest upstream changes (presumably #143934) made this pull request unmergeable. Please resolve the merge conflicts. |
Supercedes #118917.
Initial experimental implementation of rust-lang/rfcs#3838. Introduces a
repr(simd, scalable(N))
attribute that can be applied to types with a single[$ty]
field (foru{16,32,64}
,i{16,32,64}
,f{32,64}
,bool
).repr(scalable)
types are lowered to scalable vectors in the codegen backend.As with any unstable feature, there will necessarily be follow-ups as we experiment and find cases that we've not considered or still need some logic to handle, but this aims to be a decent baseline to start from.
This is pending approval from the relevant teams (and working out which team that is) to have an experimental implementation. I'll update this line when that approval is received.
Scalable vectors are non-
const Sized
in rust-lang/rfcs#3729 parlance, so while implementation of that RFC is in-progress (currently blocked on the next solver), this requires some special-casing in the type system: this implementation adds a built-in impl forSized
for these types.That's definitely incorrect and there will be cases where it causes an ICE or incorrect code to be accepted (only when using the unstable feature!), but there is no intention of stabilising it like that, and given that an implementation of
sized_hierarchy
is coming, there is a clear path to removing this. A built-in implementation ofSized
was chosen as the workaround over skipping the addition ofSized
constraints in the first place for a few reasons:Sized
is much closer to how the final implementation will look with non-const Sized
. That will have a built-in impl forSized
, just notconst Sized
.Sized
obligation is being added for a scalable vector in every circumstance because sometimes you're adding an obligation on a inference variable or something like that and you just don't know yet. In those circumstances, all you can do is skip theSized
obligation iffeature(repr_scalable)
is true and that's way more incorrect.Sized
obligation is added, and if we're going to add something incorrect temporarily, it's better for it to be small and in one place than small and in two dozen places.