Skip to content

Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes#154719

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
androm3da:hexagon-inline-asm-register-classes
Apr 9, 2026
Merged

Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes#154719
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
androm3da:hexagon-inline-asm-register-classes

Conversation

@androm3da
Copy link
Copy Markdown
Contributor

Add three new register classes for the Hexagon inline assembly backend:

  • reg_pair: GPR double registers (r1:0 through r27:26)
  • vreg: HVX vector registers (v0-v31)
  • qreg: HVX predicate registers (q0-q3), clobber-only for now

@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. labels Apr 2, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 2, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
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 69 candidates
  • Random selection from 12 candidates

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 2, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 2, 2026

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@chenyukang
Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned JohnTitor and unassigned chenyukang Apr 3, 2026
@androm3da
Copy link
Copy Markdown
Contributor Author

cc @quic-mliebel

@JohnTitor
Copy link
Copy Markdown
Member

Looks good, could you squash fixup commits?

@androm3da androm3da force-pushed the hexagon-inline-asm-register-classes branch from 9041897 to baf51fc Compare April 5, 2026 13:42
@androm3da
Copy link
Copy Markdown
Contributor Author

Looks good, could you squash fixup commits?

done, thanks

@quic-mliebel
Copy link
Copy Markdown

Should named register pairs work for input/output?

When using any of the non-blocked register pairs they get rejected:

error: couldn't allocate input reg for constraint '{r3:2}'
--> /tmp/test_regpair.rs:14:11
     |
14 |     asm!("nop", in("r3:2") x);
     |           ^^^

error: couldn't allocate output register for constraint '{r3:2}'
--> /tmp/test_regpair.rs:27:11
     |
27 |     asm!("nop", lateout("r3:2") y);
     |           ^^^

error: couldn't allocate output register for constraint '{r3:2}'
--> /tmp/test_regpair.rs:20:11
     |
20 |     asm!("nop", out("r3:2") y);
     |           ^^^

error: aborting due to 3 previous errors

@androm3da androm3da force-pushed the hexagon-inline-asm-register-classes branch from baf51fc to 718f5cf Compare April 7, 2026 02:20
@androm3da
Copy link
Copy Markdown
Contributor Author

Should named register pairs work for input/output?

Good catch. Fixed. TBH I didn't know this inline asm feature existed.

Also improved the test coverage.

@rust-log-analyzer

This comment has been minimized.

…classes

Add new Hexagon inline asm register classes:
- reg_pair: GPR double registers (r1:0 through r27:26) for i64/f64 types
- vreg: HVX vector registers (v0-v31) for mode-dependent vector types
- vreg_pair: HVX vector pair registers (v1:0 through v31:30) for vector pairs
- qreg: HVX predicate registers (q0-q3), clobber-only

Key implementation details:
- GPR pairs use LLVM's 'd' register naming (d0-d13) for constraints
- HVX vector pairs use LLVM's 'w' register naming (w0-w15) for constraints
- Register overlap tracking for GPR pair<->single and HVX pair<->single conflicts
- HVX vector types are mode-dependent (64B vs 128B HVX length)

Note: vreg_quad (HVX vector quads) is not supported as LLVM's Hexagon
backend does not support vector quad types in inline asm constraints.
@androm3da androm3da force-pushed the hexagon-inline-asm-register-classes branch from 718f5cf to aa9da4b Compare April 7, 2026 17:01
@androm3da androm3da changed the title Hexagon inline asm: add reg_pair, vreg, and qreg register classes Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes Apr 7, 2026
@androm3da
Copy link
Copy Markdown
Contributor Author

I left out a file by mistake from the previous commit.

While reviewing the omitted file I also noticed that we can/should support vreg pairs in this update. So the update in aa9da4b now includes support for those.

@quic-mliebel
Copy link
Copy Markdown

LGTM 👍

Copy link
Copy Markdown
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 8, 2026

📌 Commit aa9da4b has been approved by JohnTitor

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 8, 2026
rust-bors bot pushed a commit that referenced this pull request Apr 8, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #154912 (Remove `BuiltinLintDiag`)
 - #154598 (test `#[naked]` with `#[link_section = "..."]` on windows)
 - #154719 (Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes)
 - #154057 (Parenthesize block-like expressions in index base of pretty printer)
 - #154893 (make `expected_literal` positive)
 - #155002 (Clarify that `core::range` ranges do not have special syntax)
@rust-bors rust-bors bot merged commit 3fb712c into rust-lang:main Apr 9, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Apr 9, 2026
rust-timer added a commit that referenced this pull request Apr 9, 2026
Rollup merge of #154719 - androm3da:hexagon-inline-asm-register-classes, r=JohnTitor

Hexagon inline asm: add reg_pair, vreg, vreg_pair, and qreg register classes

Add three new register classes for the Hexagon inline assembly backend:

* `reg_pair`: GPR double registers (r1:0 through r27:26)
* `vreg`: HVX vector registers (v0-v31)
* `qreg`: HVX predicate registers (q0-q3), clobber-only for now
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants