Skip to content

Conversation

@GWTINYC
Copy link

@GWTINYC GWTINYC commented Nov 25, 2025

Background:

RFC 3838 introduces a new internal compiler attribute #[rustc_scalable_vector(N)] to define scalable vector types in the Rust standard library.
PR143924 is a preliminary experimental implementation of RFC 3838, aiming to allow types with a single field to be converted to scalable vectors at the codegen backend.

This PR is based on these previous works.

Summary:

This PR integrates Arm SVE (Scalable Vector Extension) types and intrinsics into the Rust stdarch library, enabling support for scalable vector operations on aarch64 targets.

Key changes:

1. Type System Integration

  • Added SVE type definitions in aarch64/sve/types.rs using #[rustc_scalable_vector(N)] attributes
  • Fixed module visibility by changing mod sve; to pub mod sve; in aarch64/mod.rs
  • Proper re-exports in aarch64/sve/mod.rs to ensure types and functions are accessible

2. Type Conversion Layer

  • Replaced standard SIMD intrinsics with bit-level reinterpretation using core::mem::transmute_copy
  • Implemented simd_cast and simd_reinterpret as safe bit-level operations for layout-compatible types

3. Selection Operation Implementation

  • Direct LLVM intrinsic integration via extern "C" with unique link names for each

davidtwco and others added 27 commits August 12, 2025 10:05
Extend parsing of `ReprOptions` with `rustc_scalable_vector(N)` which
optionally accepts a single literal integral value - the base multiple of
lanes that are in a scalable vector. Can only be applied to structs.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
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 <Jamie.Cunliffe@arm.com>
`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 <Jamie.Cunliffe@arm.com>
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 <Jamie.Cunliffe@arm.com>
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 <Jamie.Cunliffe@arm.com>
Scalable vectors cannot be members of ADTs and thus cannot be kept over
await points in async functions.
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 commit introduces a new file containing a comprehensive set of SVE (Scalable Vector Extension) intrinsics for the AArch64 architecture. The intrinsics include functions for absolute comparisons (greater than, less than, equal to) and arithmetic operations (addition, subtraction) for various data types (float, int) and their respective vector representations. Each function is annotated with documentation links to Arm's official documentation and includes test assertions for validation.

The addition of these intrinsics enhances the support for scalable vector types in Rust, aligning with recent changes to the compiler and standard library to accommodate scalable SIMD operations.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
This commit introduces a new module for Scalable Vector Extension (SVE) intrinsics specific to the AArch64 architecture. It includes the implementation of scalar type conversions, SIMD functions, and core SVE types such as `svbool_t`, `svint8_t`, and their variants. The new files `mod.rs`, `sve2.rs`, and `types.rs` provide foundational support for SVE operations, enhancing the Rust standard library's capabilities for scalable SIMD programming.

The implementation includes traits for scalar conversion and type casting, ensuring compatibility with various data types. This addition lays the groundwork for future enhancements and optimizations in SIMD operations within Rust.

Co-authored-by: Jamie Cunliffe <Jamie.Cunliffe@arm.com>
…t` )(`svcmp*`, `svc*` )(`svaddv`, `svcnt*`, `svclz/cls` )
…t` )(`svcmp*`, `svc*` )(`svaddv`, `svcnt*`, `svclz/cls` )(`svadr*`, `svld*`, `svst*` )(`svbic*`, `svbrk*`, `svcmla`)
…static dispatch for SVE select operations. Update documentation for clarity and maintainability.
…pe conversion documentation. Refactor existing conversion implementations for clarity and consistency.
@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2025

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

stdarch is developed in its own repository. If possible, consider making this change to rust-lang/stdarch instead.

cc @Amanieu, @folkertdev, @sayantn

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann

Changes to the size of AST and/or HIR nodes.

cc @nnethercote

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred to the platform-builtins intrinsics. Make sure the
LLVM backend as well as portable-simd gets adapted for the changes.

cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake

changes to the core type system

cc @compiler-errors, @lcnr

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rustbot rustbot added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Nov 25, 2025
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Nov 25, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot
Copy link
Collaborator

rustbot commented Nov 25, 2025

⚠️ Warning ⚠️

@GWTINYC GWTINYC closed this Nov 25, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 25, 2025
@GWTINYC GWTINYC reopened this Nov 25, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 25, 2025
@GWTINYC GWTINYC closed this Nov 25, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 25, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Nov 25, 2025

Hi. This is the moderation team of the Rust project. The comments left by you are significantly too verbose. While being detailed is good, please be respectful of reviewer time and avoid verbose text that mostly doesn't convey any useful content.

We are closing and locking this PR, but you're welcome to reopen this contribution in a new PR with more concise wording. It is perfectly fine to just leave a one line comment and bullet points otherwise if this is easier for you.

If you would like some help with that, please ensure you're familiar with our contribution guidelines and feel free to either reach out to moderation or ask on the Zulip stream for general help from other contributors.

If you are unsure how concise to make your message, you can include the full message in a <details> tag and let the reviewer know that some information may be missing from the concise message.

Note that this is a moderation warning. Repetitions of such overly verbose messages will result in a ban from contributing to our project. You can contact the moderation team to discuss your warning.

@RalfJung
Copy link
Member

I would add, please write commit messages in English, so that one has to learn only one language to get around the Rust project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants