Skip to content

rustc_target/asm: add LoongArch LSX/LASX inline asm register support#158364

Open
heiher wants to merge 3 commits into
rust-lang:mainfrom
heiher:loong-asm-simd
Open

rustc_target/asm: add LoongArch LSX/LASX inline asm register support#158364
heiher wants to merge 3 commits into
rust-lang:mainfrom
heiher:loong-asm-simd

Conversation

@heiher

@heiher heiher commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Add support for LoongArch LSX and LASX registers in inline assembly by introducing the vreg and xreg register classes, along with their associated vector types and operand modifiers. The new register classes are gated behind the asm_experimental_reg feature. Also model the overlap between FPU, LSX, and LASX registers so register conflict checking works correctly for aliased registers.

@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. labels Jun 24, 2026
@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

rustbot has assigned @wesleywiser.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 20 candidates

@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

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

cc @antoyo, @GuillaumeGomez

@wesleywiser

Copy link
Copy Markdown
Member

This looks fine to me but I'm not sure whether we typically need T-lang to sign off on extensions to stable inline asm.

@Amanieu do you know if this needs a T-lang FCP?

@taiki-e

taiki-e commented Jun 25, 2026

Copy link
Copy Markdown
Member

AFAIK, a common way to add support for new registers in architectures where inline assembly is stable is to use asm_experimental_reg (#133416).

@heiher

heiher commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

AFAIK, a common way to add support for new registers in architectures where inline assembly is stable is to use asm_experimental_reg (#133416).

Thanks for pointing that out. I think gating new inline assembly register support behind asm_experimental_reg is a great design choice. It allows new functionality to be introduced and validated without immediately becoming part of Rust's stable interface, which helps avoid turning early design mistakes into long-term compatibility burdens.

heiher added 3 commits June 26, 2026 16:01
Add support for LoongArch LSX and LASX registers in inline assembly by
introducing the `vreg` and `xreg` register classes, along with their
associated vector types and operand modifiers. The new register classes
are gated behind the `asm_experimental_reg` feature. Also model the overlap
between FPU, LSX, and LASX registers so register conflict checking works
correctly for aliased registers.
Add UI tests for LoongArch LSX/LASX inline asm registers, including
target-feature gating and overlap diagnostics between `fN`, `vrN`, and
`xrN` registers.
Add assembly tests for LoongArch inline asm register modifiers. Verify
that the `w` and `u` modifiers correctly select LSX and LASX register
views for `freg`, `vreg`, and `xreg` operands and produce the expected
register names in the generated assembly.
@rustbot

rustbot commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@heiher

heiher commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

The newly added vreg and xreg register classes are gated behind the asm_experimental_reg feature rather than being stabilized. I've updated the test cases and the unstable book accordingly. Thanks!

@heiher heiher requested a review from wesleywiser June 26, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants