decomp: merge all s6-* remappings and finish training-obs | villagep-obs | lavatube-obs | rolling-robber | snow-obs (#1018)

* decompiler: merge all `s6-*` usages

* decomp: finish `training-obs`

* decomp: finish `rolling-robber`

* decomp: finish `villagep-obs`

* decomp: finish `lavatube-obs`

* skip function in `lavatube-obs` over #1029

* closes #1029

* kick nasm

* merge s6 and sp in variable naming pass

* revert my fix

* fix mistakes and a bad method signature

Co-authored-by: water111 <awaterford111445@gmail.com>
This commit is contained in:
Tyler Wilding
2021-12-28 23:16:42 -05:00
committed by GitHub
parent e8db0583c9
commit c6f0c5cd29
52 changed files with 17962 additions and 3047 deletions
+19
View File
@@ -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();