MCPcopy Create free account
hub / github.com/Amanieu/regalloc3 / check_class

Method check_class

src/debug_utils/checker.rs:675–702  ·  view source on GitHub ↗

Checks that the allocation is compatible with the given register class.

(&self, alloc: Allocation, class: RegClass)

Source from the content-addressed store, hash-verified

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.

Callers 2

check_instMethod · 0.45
check_constraintMethod · 0.45

Calls 5

bank_for_classMethod · 0.80
spillslot_layoutMethod · 0.80
stack_layoutMethod · 0.80
reginfoMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected