mirror of
https://github.com/open-goal/jak-project
synced 2026-06-21 00:31:41 -04:00
[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:
@@ -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
|
||||
Reference in New Issue
Block a user