abrown opened PR #10629 from abrown:asm-fixed to bytecodealliance:main:
This change introduces a new
Fixedwrapper type that allows us to plumb fixed registers through the assembler. These instructions are not yet used bycranelift-codegen, but will be necessary at some point as described in [#10238]. The end result of this is that up at thecranelift-codegenlevel, fixed registers should look like run-of-the-mill virtual registers using the appropriate types, but down incranelift-assembler-x64we panic if the register allocator does not give them the correct register.[#10238]: https://github.com/bytecodealliance/wasmtime/issues/10238
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
abrown requested cfallin for a review on PR #10629.
abrown requested wasmtime-compiler-reviewers for a review on PR #10629.
abrown updated PR #10629.
cfallin submitted PR review:
Looks good, thanks! Just some nits below.
cfallin created PR review comment:
Is there a reason (e.g. generic interface somewhere else) that we need to accept
reghere as an argument, rather than just using the generic parameterE-- since there is only one valid value to pass in?
cfallin created PR review comment:
Nice! This is presumably because a reg that we carried as a (always the same value)
u32previously now becomes a type parameter? Good to see reductions in any case.
cfallin created PR review comment:
Ah, I see below, this enables the idiom
Fixed(rax)for example, where type inference carriesregthrough to the generic parameter.Maybe there could be two entry points,
new()andfrom_const_reg(reg: u8)or similar? Maybe not a huge deal; just trying to reduce confusing APIs.
abrown submitted PR review.
abrown created PR review comment:
I don't think we need a different entry point and, in fact, I've been trying to remove this
AsReg::newsomehow. It's only during fuzzing that we need the ability to construct anAsReg. I just can't seem to pull the right Jenga blocks out to get rid of this without things falling down.
cfallin submitted PR review.
cfallin created PR review comment:
Ah, I see -- a few thoughts then:
- At the very least,
pub(crate) fn new(...)so it's only exposed to where fuzzing needs it (theArbitraryimpl);- Perhaps removing the field (so it's a zero-sized struct, carrying
Eonly at the type level); you still haveEforenc()to work; the only part I'm not as clear on is whereAsRefcomes in and why you need a reference (vs. constructing anRon-the-fly as needed, as e.g.fn to_reg(&self) -> R { R::new(E) }or something like that)
abrown merged PR #10629.
abrown submitted PR review.
abrown created PR review comment:
- At the very least,
pub(crate) fn new(...)so it's only exposed to where fuzzing needs it (theArbitraryimpl);What I meant is that I want to remove the trait function
AsReg::new--we can't make trait functionspub(crate), right?
- Perhaps removing the field (so it's a zero-sized struct, carrying
Eonly at the type level); you still haveEforenc()to work; the only part I'm not as clear on is whereAsRefcomes in and why you need a reference (vs. constructing anRon-the-fly as needed, as e.g.fn to_reg(&self) -> R { R::new(E) }or something like that)I believe we still need the field because we need a place for the virtual register to live until register allocation happens.
cfallin submitted PR review.
cfallin created PR review comment:
Oh, d'oh, I had missed that
newwas part of the trait definition too, sorry! And you're of course right that we need an actual vreg too.
Last updated: Jan 09 2026 at 13:15 UTC