[decomp] add mips2c converter (#842)

* mips 2 c basic version, not yet tested

* calling works without crashing, but the function doesn't

* it works

* add test

* cleanup and actually add the test

* dont use mips2c by default for font

* clean up formatting
This commit is contained in:
water111
2021-09-11 20:52:35 -04:00
committed by GitHub
parent e47476983a
commit f9d8fcd6e4
61 changed files with 3463 additions and 153 deletions
+9 -6
View File
@@ -78,7 +78,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
lg::warn(
"Function {} was flagged as asm due to this instruction: {}. Consider flagging as asm "
"in config!",
guessed_name.to_string(), instr.to_string(file.labels));
name(), instr.to_string(file.labels));
warnings.general_warning("Flagged as asm because of {}", instr.to_string(file.labels));
suspected_asm = true;
return;
@@ -103,7 +103,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
lg::warn(
"Function {} was flagged as asm due to this instruction: {}. Consider flagging as asm "
"in config!",
guessed_name.to_string(), instr.to_string(file.labels));
name(), instr.to_string(file.labels));
warnings.general_warning("Flagged as asm because of {}", instr.to_string(file.labels));
suspected_asm = true;
return;
@@ -158,7 +158,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
if (this_reg != get_expected_gpr_backup(i, n_gpr_backups)) {
suspected_asm = true;
lg::warn("Function {} stores on the stack in a strange way ({}), flagging as asm!",
instructions.at(idx + i).to_string(file.labels), guessed_name.to_string());
instructions.at(idx + i).to_string(file.labels), name());
warnings.general_warning("Flagged as asm due to strange stack store: {}",
instructions.at(idx + i).to_string(file.labels));
return;
@@ -187,7 +187,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
if (this_reg != get_expected_fpr_backup(i, n_fpr_backups)) {
suspected_asm = true;
lg::warn("Function {} stores on the stack in a strange way ({}), flagging as asm!",
instructions.at(idx + i).to_string(file.labels), guessed_name.to_string());
instructions.at(idx + i).to_string(file.labels), name());
warnings.general_warning("Flagged as asm due to strange stack store: {}",
instructions.at(idx + i).to_string(file.labels));
return;
@@ -378,8 +378,7 @@ void Function::check_epilogue(const LinkedObjectFile& file) {
idx--;
assert(is_jr_ra(instructions.at(idx)));
idx--;
lg::warn("Function {} has a double return and is being flagged as asm.",
guessed_name.to_string());
lg::warn("Function {} has a double return and is being flagged as asm.", name());
warnings.general_warning("Flagged as asm due to double return");
}
// delay slot should be daddiu sp, sp, offset
@@ -773,4 +772,8 @@ BlockTopologicalSort Function::bb_topo_sort() {
return result;
}
std::string Function::name() const {
return guessed_name.to_string();
}
} // namespace decompiler