[backend]消除了线性扫描分配器对参数寄存器的引用

This commit is contained in:
Lixuanwang
2025-08-05 02:21:42 +08:00
parent df50eedaeb
commit 676880ca05
2 changed files with 63 additions and 20 deletions

View File

@@ -65,6 +65,44 @@ void RISCv64RegAlloc::run() {
}
}
// const int MAX_ITERATIONS = 50;
// int iteration = 0;
// while (iteration++ < MAX_ITERATIONS) {
// if (doAllocation()) {
// break;
// } else {
// rewriteProgram();
// if (DEBUG) std::cerr << "--- Spilling detected, re-running allocation (iteration " << iteration << ") ---\n";
// if (iteration >= MAX_ITERATIONS) {
// std::cerr << "ERROR: Register allocation failed to converge after " << MAX_ITERATIONS << " iterations\n";
// std::cerr << " Spill worklist size: " << spillWorklist.size() << "\n";
// std::cerr << " Total nodes: " << (initial.size() + coloredNodes.size()) << "\n";
// // Emergency spill remaining nodes to break the loop
// std::cerr << " Emergency spilling remaining spill worklist nodes...\n";
// for (unsigned node : spillWorklist) {
// spilledNodes.insert(node);
// }
// // Also spill any nodes that didn't get colors
// std::set<unsigned> uncolored;
// for (unsigned node : initial) {
// if (color_map.find(node) == color_map.end()) {
// uncolored.insert(node);
// }
// }
// for (unsigned node : uncolored) {
// spilledNodes.insert(node);
// }
// // Force completion
// break;
// }
// }
// }
applyColoring();
MFunc->getFrameInfo().vreg_to_preg_map = this->color_map;