[Decompilation] Fixes to compiler/decompiler for gcommon (#227)

* fix shift naming issue

* fix bad argument variable names

* fix missing variable issue

* small missing things

* wip

* cleanup

* wip

* fix conditions

* small bug fix in rewriter

* fix incredibly stupid printing bug
This commit is contained in:
water111
2021-02-05 19:41:09 -05:00
committed by GitHub
parent 65206823ef
commit ddffda1e8c
29 changed files with 1000 additions and 379 deletions
+17
View File
@@ -436,6 +436,23 @@ void SSA::remap() {
}
};
std::unordered_map<Register, VarIdRecord, Register::hash> used_vars;
// we do this in two passes. the first pass collects only the B0 variables and adds those first,
// so these remain index 0 (expected by later decompiler passes)
for (auto& block : blocks) {
assert(block.phis.empty());
for (auto& instr : block.ins) {
if (instr.dst.has_value() && map.var_id(*instr.dst) == 0) {
used_vars[instr.dst->reg()].insert(map.var_id(*instr.dst));
}
for (auto& src : instr.src) {
if (map.var_id(src) == 0) {
used_vars[src.reg()].insert(map.var_id(src));
}
}
}
}
// and the second pass grabs all of them
for (auto& block : blocks) {
assert(block.phis.empty());
for (auto& instr : block.ins) {