refactor: make caller-saved color preference explicit in ColorGraph Select phase

Split color selection in ColorGraph's Select phase to explicitly
distinguish caller-saved (c<19) and callee-saved (c>=19) registers,
preferring caller-saved colors. Behavior is equivalent to the previous
implementation since GP_ALLOCATABLE already lists caller-saved registers
first, but the new logic is more explicit and provides an extension
point for future callee-save optimization.
master
黄熙哲 1 week ago
parent e3e01256cd
commit 4d95f33dc2

@ -726,14 +726,24 @@ namespace mir
}
int assigned_color = -1;
// 收集可用颜色区分caller-saved和callee-saved
std::vector<int> caller_saved_avail;
std::vector<int> callee_saved_avail;
for (int c : allocatable_regs)
{
if (used_colors.find(c) == used_colors.end())
{
assigned_color = c;
break;
if (c < 19)
caller_saved_avail.push_back(c);
else
callee_saved_avail.push_back(c);
}
}
// 优先选择caller-saved颜色
if (!caller_saved_avail.empty())
assigned_color = caller_saved_avail[0];
else if (!callee_saved_avail.empty())
assigned_color = callee_saved_avail[0];
if (assigned_color >= 0)
{

Loading…
Cancel
Save