[Decompiler - New IR] Add AtomicOp (#181)

* wip decompiler ir

* add AtomicOp stuff

* fix windows build and warnings

* add instruction parser

* include

* make minilzo shared

* odr fix

* a

* fix merge conflicts

* move decompiler into namespace

* update the code coverage to include the decompiler

* add demo test

* add register use test to example test
This commit is contained in:
water111
2021-01-06 20:04:15 -05:00
committed by GitHub
parent 3331e9cd00
commit 5093b97cda
71 changed files with 2676 additions and 210 deletions
+12 -10
View File
@@ -8,6 +8,7 @@
#include "TypeInspector.h"
#include "decompiler/IR/IR.h"
namespace decompiler {
namespace {
std::vector<Register> gpr_backups = {make_gpr(Reg::GP), make_gpr(Reg::S5), make_gpr(Reg::S4),
make_gpr(Reg::S3), make_gpr(Reg::S2), make_gpr(Reg::S1),
@@ -70,8 +71,8 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
// storing stack pointer on the stack is done by some ASM kernel functions
if (instr.kind == InstructionKind::SW && instr.get_src(0).get_reg() == make_gpr(Reg::SP)) {
printf("[Warning] %s Suspected ASM function based on this instruction in prologue: %s\n",
guessed_name.to_string().c_str(), instr.to_string(file).c_str());
warnings += ";; Flagged as ASM function because of " + instr.to_string(file) + "\n";
guessed_name.to_string().c_str(), instr.to_string(file.labels).c_str());
warnings += ";; Flagged as ASM function because of " + instr.to_string(file.labels) + "\n";
suspected_asm = true;
return;
}
@@ -93,8 +94,8 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
// support
if (instr.kind == InstructionKind::SD && instr.get_src(0).get_reg() == make_gpr(Reg::S7)) {
lg::warn("{} Suspected ASM function based on this instruction in prologue: {}\n",
guessed_name.to_string(), instr.to_string(file));
warnings += ";; Flagged as ASM function because of " + instr.to_string(file) + "\n";
guessed_name.to_string(), instr.to_string(file.labels));
warnings += ";; Flagged as ASM function because of " + instr.to_string(file.labels) + "\n";
suspected_asm = true;
return;
}
@@ -164,9 +165,9 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
suspected_asm = true;
printf("[Warning] %s Suspected asm function that isn't flagged due to stack store %s\n",
guessed_name.to_string().c_str(),
instructions.at(idx + i).to_string(file).c_str());
instructions.at(idx + i).to_string(file.labels).c_str());
warnings += ";; Suspected asm function due to stack store: " +
instructions.at(idx + i).to_string(file) + "\n";
instructions.at(idx + i).to_string(file.labels) + "\n";
return;
}
}
@@ -194,9 +195,9 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
suspected_asm = true;
printf("[Warning] %s Suspected asm function that isn't flagged due to stack store %s\n",
guessed_name.to_string().c_str(),
instructions.at(idx + i).to_string(file).c_str());
instructions.at(idx + i).to_string(file.labels).c_str());
warnings += ";; Suspected asm function due to stack store: " +
instructions.at(idx + i).to_string(file) + "\n";
instructions.at(idx + i).to_string(file.labels) + "\n";
return;
}
}
@@ -643,7 +644,7 @@ void Function::find_type_defs(LinkedObjectFile& file, DecompilerTypeSystem& dts)
// done!
// fmt::print("Got type {} parent {}\n", type_name, parent_type);
dts.add_type_parent(type_name, parent_type);
Label flag_label = file.labels.at(label_idx);
DecompilerLabel flag_label = file.labels.at(label_idx);
u64 word = file.read_data_word(flag_label);
flag_label.offset += 4;
u64 word2 = file.read_data_word(flag_label);
@@ -744,4 +745,5 @@ BlockTopologicalSort Function::bb_topo_sort() {
}
return result;
}
}
} // namespace decompiler