rust-lang / rust-lang/rust

`asm!` should actually understand "can you address this register?"

Open
#126,890 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-inline-assembly C-cleanup O-AArch64 O-riscv T-compiler T-libs
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

In https://github.com/rust-lang/rust/pull/126849 I fixed a bug on 32-bit Arm regarding features that govern "which register fits where" by sorting the features based on register class hierarchically.

However, this bug is present on more than 32-bit Arm: https://github.com/rust-lang/rust/blob/0d8f734172ca17844a3c0f1d938222aac49b0d16/compiler/rustc_target/src/asm/aarch64.rs#L134-L149

In addition, there's some very ad-hoc restrictions showing up that in many cases are basically trying to encode the same thing:

https://github.com/rust-lang/rust/blob/0d8f734172ca17844a3c0f1d938222aac49b0d16/compiler/rustc_target/src/asm/riscv.rs#L81-L96

I believe we should switch to modeling register addressability more directly, and test more exhaustively for all architectural variations people want us to support.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading PR 126849 and the register-class handling in compiler/rustc_target/src/asm/aarch64.rs, especially lines 134-149. Compare it with the ad-hoc restrictions in compiler/rustc_target/src/asm/riscv.rs, lines 81-96. Done means register addressability is modeled directly and architectural variations are tested exhaustively.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.