[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
+9 -7
View File
@@ -16,6 +16,7 @@
#include "common/log/log.h"
#include "common/goos/PrettyPrinter.h"
namespace decompiler {
/*!
* Set the number of segments in this object file.
* This can only be done once, and must be done before adding any words.
@@ -45,7 +46,7 @@ int LinkedObjectFile::get_label_id_for(int seg, int offset) {
if (kv == label_per_seg_by_offset.at(seg).end()) {
// create a new label
int id = labels.size();
Label label;
DecompilerLabel label;
label.target_segment = seg;
label.offset = offset;
label.name = "L" + std::to_string(id);
@@ -498,7 +499,7 @@ void LinkedObjectFile::process_fp_relative_links() {
} break;
default:
printf("unknown fp using op: %s\n", instr.to_string(*this).c_str());
printf("unknown fp using op: %s\n", instr.to_string(labels).c_str());
assert(false);
}
}
@@ -544,7 +545,7 @@ std::string LinkedObjectFile::to_asm_json(const std::string& obj_file_name) {
}
auto& instr = func.instructions.at(i);
op["id"] = i;
op["asm_op"] = instr.to_string(*this);
op["asm_op"] = instr.to_string(labels);
if (func.has_basic_ops() && func.instr_starts_basic_op(i)) {
op["basic_op"] = func.get_basic_op_at_instr(i)->print(*this);
@@ -608,7 +609,7 @@ std::string LinkedObjectFile::print_function_disassembly(Function& func,
}
auto& instr = func.instructions.at(i);
std::string line = " " + instr.to_string(*this);
std::string line = " " + instr.to_string(labels);
if (write_hex) {
if (line.length() < 60) {
@@ -1053,14 +1054,15 @@ goos::Object LinkedObjectFile::to_form_script_object(int seg,
return result;
}
u32 LinkedObjectFile::read_data_word(const Label& label) {
u32 LinkedObjectFile::read_data_word(const DecompilerLabel& label) {
assert(0 == (label.offset % 4));
auto& word = words_by_seg.at(label.target_segment).at(label.offset / 4);
assert(word.kind == LinkedWord::Kind::PLAIN_DATA);
return word.data;
}
std::string LinkedObjectFile::get_goal_string_by_label(const Label& label) const {
std::string LinkedObjectFile::get_goal_string_by_label(const DecompilerLabel& label) const {
assert(0 == (label.offset % 4));
return get_goal_string(label.target_segment, (label.offset / 4) - 1, false);
}
}
} // namespace decompiler