[backend]开始区分调用者保存寄存器与被调用者保存寄存器
This commit is contained in:
@ -436,8 +436,12 @@ void RISCv64RegAlloc::rewriteFunction() {
|
|||||||
if (reg_op->isVirtual()) {
|
if (reg_op->isVirtual()) {
|
||||||
unsigned vreg = reg_op->getVRegNum();
|
unsigned vreg = reg_op->getVRegNum();
|
||||||
if (color_map.count(vreg)) {
|
if (color_map.count(vreg)) {
|
||||||
// 如果vreg被成功着色,替换为物理寄存器
|
PhysicalReg preg = color_map.at(vreg);
|
||||||
reg_op->setPReg(color_map.at(vreg));
|
reg_op->setPReg(preg);
|
||||||
|
// 检查这个物理寄存器是否是 s0-s11
|
||||||
|
if (preg >= PhysicalReg::S0 && preg <= PhysicalReg::S11) {
|
||||||
|
used_callee_saved_regs.insert(preg);
|
||||||
|
}
|
||||||
} else if (spilled_vregs.count(vreg)) {
|
} else if (spilled_vregs.count(vreg)) {
|
||||||
// 如果vreg被溢出,替换为专用的溢出物理寄存器t6
|
// 如果vreg被溢出,替换为专用的溢出物理寄存器t6
|
||||||
reg_op->setPReg(PhysicalReg::T6);
|
reg_op->setPReg(PhysicalReg::T6);
|
||||||
|
|||||||
@ -54,8 +54,11 @@ private:
|
|||||||
// 这个map将在run()函数开始时被填充,并在rewriteFunction()中使用。
|
// 这个map将在run()函数开始时被填充,并在rewriteFunction()中使用。
|
||||||
std::map<unsigned, Value*> vreg_to_value_map;
|
std::map<unsigned, Value*> vreg_to_value_map;
|
||||||
|
|
||||||
|
std::set<PhysicalReg> used_callee_saved_regs;
|
||||||
|
|
||||||
// 用于计算类型大小的辅助函数
|
// 用于计算类型大小的辅助函数
|
||||||
unsigned getTypeSizeInBytes(Type* type);
|
unsigned getTypeSizeInBytes(Type* type);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sysy
|
} // namespace sysy
|
||||||
|
|||||||
Reference in New Issue
Block a user