feat(mir): 增加 Lab3 AArch64 MVP 后端与 --emit-asm 支持
This commit is contained in:
@@ -1,4 +1,33 @@
|
||||
// 寄存器分配:
|
||||
// - 将虚拟寄存器分配到物理寄存器
|
||||
// - 处理 spill/reload,并为后续栈帧布局提供栈槽需求信息
|
||||
#include "mir/MIR.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user