Remove register class from SpillSlot (#80)

* Remove register class from `SpillSlot`

The register allocator was already allowing moves between spillslots and
registers of different classes, so this PR formalizes this by making
spillslots independent of register class.

This also fixes #79 by properly tracking the register class of an
`InsertedMove` with the `to_vreg` field which turns out to never
be `None` in practice. Removing the `Option` allows the register
class of the `VReg` to be used when building the per-class move lists.

Fixes #79

* Address review feedback
This commit is contained in:
Amanieu d'Antras
2022-09-21 05:05:23 +08:00
committed by GitHub
parent 3db1b7199b
commit 906a053208
6 changed files with 40 additions and 74 deletions

View File

@@ -40,14 +40,14 @@ impl Arbitrary<'_> for TestCase {
Allocation::reg(PReg::new(reg, RegClass::Int))
} else {
let slot = u.int_in_range(0..=31)?;
Allocation::stack(SpillSlot::new(slot, RegClass::Int))
Allocation::stack(SpillSlot::new(slot))
};
let dst = if bool::arbitrary(u)? {
let reg = u.int_in_range(0..=29)?;
Allocation::reg(PReg::new(reg, RegClass::Int))
} else {
let slot = u.int_in_range(0..=31)?;
Allocation::stack(SpillSlot::new(slot, RegClass::Int))
Allocation::stack(SpillSlot::new(slot))
};
// Stop if we are going to write a reg more than once:
@@ -88,7 +88,7 @@ fuzz_target!(|testcase: TestCase| {
let get_stackslot = || {
let slot = next_slot;
next_slot += 1;
Allocation::stack(SpillSlot::new(slot, RegClass::Int))
Allocation::stack(SpillSlot::new(slot))
};
let preferred_victim = PReg::new(0, RegClass::Int);
let scratch_resolver =