Modeling subregister aliasing
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading the current regalloc2 API around PRegs, physical register classes, and clobber sets, then compare the issue's LLVM register-units and subregister model. Done means establishing whether aliasing can be represented, or documenting a supported outside-the-allocator approach such as fixed constraints, explicit moves, or live-range splitting.
Written by the indexing model from the issue text.
Description
I’m experimenting with using regalloc2 for a cranelift backend targeting a old Z80 8-bit CPU with hierarchical registers —
where two small registers can form one larger register, and vice versa:
B + C = BC (16-bit)
D + E = DE (16-bit)
H + L = HL (16-bit)
Here’s the challenge:
Some 16-bit instructions can use either BC or DE.
When BC is used, both B and C become clobbered.
When DE is used, D and E are clobbered instead.
The 8-bit registers are individually addressable, but they also participate in 16-bit operations as pairs.
The problem is that regalloc2 assumes all physical registers in a class are disjoint,
and clobber sets must be fixed before allocation.
That makes it unclear how to express a relationship like “BC aliases both B and C” or “writing BC invalidates B and C.”
LLVM handles this using register units and subregisters, where overlapping registers share “register units”
and the allocator tracks partial definitions and interference on that level.
regalloc2, however, currently has no notion of aliasing or register overlap.
So I’m wondering:
Is there any way to model such subregister aliasing with the current regalloc2 API?
Would it make sense to support aliasing PRegs or register subsets (similar to LLVM’s register units / subregister indices)?
Or is the current expectation that these aliasing relationships be handled entirely outside the allocator,
e.g. by inserting explicit moves, using fixed constraints, or splitting live ranges manually?
- Dominant language
- Rust
- Stars
- 266
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bytecodealliance/regalloc2
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
bytecodealliance/regalloc2#265 · 7 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
bytecodealliance/regalloc2#222 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
bytecodealliance/regalloc2#206 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
bytecodealliance/regalloc2#194 · 7 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
bytecodealliance/regalloc2#191 · 3 comments ·
All issues in bytecodealliance/regalloc2
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
issue
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
web-infra-dev/rspack#15847 ·