Checks that the allocation is compatible with the given register class.
(&self, alloc: Allocation, class: RegClass)
| 673 | |
| 674 | /// Checks that the allocation is compatible with the given register class. |
| 675 | fn check_class(&self, alloc: Allocation, class: RegClass) -> Result<()> { |
| 676 | let reginfo = self.output.reginfo(); |
| 677 | match alloc.kind() { |
| 678 | AllocationKind::PhysReg(reg) => ensure!( |
| 679 | reginfo.class_members(class).contains(reg), |
| 680 | "{class} doesn't contain {reg}" |
| 681 | ), |
| 682 | AllocationKind::SpillSlot(slot) => { |
| 683 | ensure!( |
| 684 | reginfo.class_includes_spillslots(class), |
| 685 | "{class} doesn't allow spillslots" |
| 686 | ); |
| 687 | let bank = reginfo.bank_for_class(class); |
| 688 | let Some((_offset, spillslot_size)) = |
| 689 | self.output.stack_layout().spillslot_layout(slot) |
| 690 | else { |
| 691 | bail!("{slot} has no stack layout"); |
| 692 | }; |
| 693 | ensure!( |
| 694 | reginfo.spillslot_size(bank) == spillslot_size, |
| 695 | "{slot} has wrong size for {bank}: expected {}, got {}", |
| 696 | reginfo.spillslot_size(bank), |
| 697 | spillslot_size |
| 698 | ); |
| 699 | } |
| 700 | } |
| 701 | Ok(()) |
| 702 | } |
| 703 | |
| 704 | /// Checks that the allocation is the first member of a group in the given |
| 705 | /// register class, and returns the register group it is part of. |
no test coverage detected