#include "mir/MIR.h" #include namespace mir { namespace { bool IsAllowedReg(PhysReg reg) { switch (reg) { case PhysReg::W0: case PhysReg::W8: case PhysReg::W9: case PhysReg::X29: case PhysReg::X30: case PhysReg::SP: return true; } return false; } } // namespace void RunRegAlloc(MachineFunction& function) { for (const auto& inst : function.entry().instructions()) { for (const auto& operand : inst.operands()) { if (operand.kind() == Operand::Kind::Reg && !IsAllowedReg(operand.reg())) { throw std::runtime_error("Lab3 MVP 后端发现未预着色的寄存器"); } } } } } // namespace mir