Expand description
Register state: 15 general-purpose 64-bit registers + PC.
PVM2 is RV64E — a 16-register integer base (x0–x15) — so it has the
full 15 GPRs (x1, x2, x5–x15, plus x3, x4) with x0
hardwired to zero, plus an instruction pointer. x3/x4 map to the two
high slots (13, 14) so the 13 commonly-used registers keep slots
0..=12; the recompiler holds those 13 in host registers and spills
x3/x4 to memory (see reg_is_spilled). Only x16–x31 (which do
not exist in the E base) remain reserved.
Structs§
- Regs
- Full register state: 15 GPRs + PC.
Enums§
- RegClass
- Classification of a 5-bit RV register index in PVM2.
Constants§
- REG_
COUNT - Number of general-purpose registers.
- REG_
SLOT_ LUT - 32-entry const-folded copy of
reg_slot_or_fffor the recompiler’s codegen/gas hot path — a single load beats the range-match (the profiler showed the match at ~8.8% of compile). Generated fromreg_class, so it cannot drift from the canonical classification.
Functions§
- reg_
class - Classify a 5-bit RV register index (low 5 bits of
x). SeeRegClass. - reg_
is_ reserved - True iff
xis a reserved register (x16..x31— they do not exist in the RV64E base) — as opposed tox0, which also lacks a slot but is valid. Drives the reserved-encoding (illegal) check in both engines. - reg_
is_ spilled - True iff
xis a spilled register —x3orx4, the two GPRs that map to the high slots (13, 14). They are real, fully-valid registers (the interpreter executes them as ordinary GPRs), but the x86-64 recompiler’s host register file is exhausted by the other 13 slots, so it holdsx3/x4in memory and materialises them per access. The recompiler uses this to route anx3/x4instruction to its cold spill path; the gas model uses it to charge the memory-spill cost. - reg_
slot_ or_ ff - PVM2 GPR slot (
0..=14) forx, or0xFFifxhas no slot —x0(hardwired zero) or a reserved register (x16..x31). The gas simulator reads0xFFas “no dependency / no write”; both engines’ gas paths use this (the recompiler via the const-foldedREG_SLOT_LUT) so gas agrees bit-for-bit. Note0xFFconflatesx0with reserved — usereg_is_reservedwhen that distinction matters.