Files
nudt-compiler-cpp/src/mir/RegAlloc.cpp

30 lines
649 B
C++

#include "mir/MIR.h"
#include <stdexcept>
#include "utils/Log.h"
namespace mir {
namespace {
bool IsAllowedReg(PhysReg reg) {
return true; // We allow all defined physical registers
}
} // namespace
void RunRegAlloc(MachineFunction& function) {
for (const auto& block : function.GetBlocks()) {
for (const auto& inst : block.GetInstructions()) {
for (const auto& operand : inst.GetOperands()) {
if (operand.GetKind() == Operand::Kind::Reg &&
!IsAllowedReg(operand.GetReg())) {
throw std::runtime_error(FormatError("mir", "寄存器分配失败"));
}
}
}
}
}
} // namespace mir