[backend]添加了一些工具函数

This commit is contained in:
Lixuanwang
2025-08-04 16:32:54 +08:00
parent 64ba25a77e
commit 0179c13cf4
5 changed files with 36 additions and 26 deletions

View File

@@ -122,30 +122,6 @@ void RISCv64RegAlloc::precolorByCallingConvention() {
}
}
// // --- 部分2为CALL指令的返回值预着色 ---
// for (auto& mbb : MFunc->getBlocks()) {
// for (auto& instr : mbb->getInstructions()) {
// if (instr->getOpcode() == RVOpcodes::CALL) {
// if (!instr->getOperands().empty() &&
// instr->getOperands().front()->getKind() == MachineOperand::KIND_REG)
// {
// auto reg_op = static_cast<RegOperand*>(instr->getOperands().front().get());
// if (reg_op->isVirtual()) {
// unsigned ret_vreg = reg_op->getVRegNum();
// assert(vreg_to_value_map.count(ret_vreg) && "Return vreg not found!");
// Value* ret_val = vreg_to_value_map.at(ret_vreg);
// if (ret_val->getType()->isFloat()) {
// color_map[ret_vreg] = PhysicalReg::F10; // fa0
// } else {
// color_map[ret_vreg] = PhysicalReg::A0; // a0
// }
// }
// }
// }
// }
// }
// 将所有预着色的vreg视为已着色节点
for(const auto& pair : color_map) {
coloredNodes.insert(pair.first);