mirror of
https://github.com/open-goal/jak-project
synced 2026-07-30 16:04:33 -04:00
merge s6 and sp in variable naming pass
This commit is contained in:
@@ -86,6 +86,14 @@ void VarMapSSA::merge(const VarSSA& var_a, const VarSSA& var_b) {
|
||||
}
|
||||
}
|
||||
|
||||
void VarMapSSA::merge_reg(Register reg) {
|
||||
for (auto& entry : m_entries) {
|
||||
if (entry.reg == reg) {
|
||||
entry.var_id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Make all Bs A.
|
||||
*/
|
||||
@@ -491,6 +499,13 @@ std::string SSA::print() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Merge all variables in the same register to the given register.
|
||||
*/
|
||||
void SSA::merge_reg_to_single_variable(Register reg) {
|
||||
map.merge_reg(reg);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Simplify the SSA while still keeping it in SSA form.
|
||||
* This does only a single pass of simplifications and returns true if it made changes.
|
||||
@@ -1070,6 +1085,10 @@ std::optional<VariableNames> run_variable_renaming(const Function& function,
|
||||
fmt::print("Simplified SSA\n{}-------------------------------\n", ssa.print());
|
||||
}
|
||||
|
||||
// merge special registers
|
||||
ssa.merge_reg_to_single_variable(Register(Reg::GPR, Reg::SP));
|
||||
ssa.merge_reg_to_single_variable(Register(Reg::GPR, Reg::S6));
|
||||
|
||||
// remember what the SSA mapping was:
|
||||
auto ssa_mapping = ssa.get_ssa_mapping();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user