diff --git a/decompiler/IR2/OpenGoalMapping.cpp b/decompiler/IR2/OpenGoalMapping.cpp index 324bf52069..740e6feac4 100644 --- a/decompiler/IR2/OpenGoalMapping.cpp +++ b/decompiler/IR2/OpenGoalMapping.cpp @@ -8,6 +8,14 @@ typedef OpenGOALAsm::InstructionModifiers MOD; const std::map MIPS_ASM_TO_OPEN_GOAL_FUNCS = { // ----- EE ------- + // Instructions that are nopped + {InstructionKind::MTC0, {".nop", {MOD::SKIP_IT}}}, // they only use this for performance counters / Count / Debug + {InstructionKind::MTPC, {".nop", {MOD::SKIP_IT}}}, + {InstructionKind::MFPC, {".nop", {MOD::SKIP_IT}}}, + {InstructionKind::SYNCP, {".nop", {MOD::SKIP_IT}}}, + {InstructionKind::SYNCL, {".nop", {MOD::SKIP_IT}}}, + + // Shifts and such {InstructionKind::PSLLW, {".pw.sll", {}}}, {InstructionKind::PSRAW, {".pw.sra", {}}}, {InstructionKind::PSUBW, {".psubw", {}}}, @@ -152,6 +160,10 @@ OpenGOALAsm::OpenGOALAsm(Instruction _instr) : instr(_instr) { if (func.funcTemplate.rfind("TODO", 0) == 0) { todo = true; } + if (std::find(func.modifiers.begin(), func.modifiers.end(), InstructionModifiers::SKIP_IT) != + func.modifiers.end()) { + skip = true; + } } } @@ -166,6 +178,10 @@ OpenGOALAsm::OpenGOALAsm(Instruction _instr, if (func.funcTemplate.rfind("TODO", 0) == 0) { todo = true; } + if (std::find(func.modifiers.begin(), func.modifiers.end(), InstructionModifiers::SKIP_IT) != + func.modifiers.end()) { + skip = true; + } } } diff --git a/decompiler/IR2/OpenGoalMapping.h b/decompiler/IR2/OpenGoalMapping.h index 9f2a671020..4ae4e3adf6 100644 --- a/decompiler/IR2/OpenGoalMapping.h +++ b/decompiler/IR2/OpenGoalMapping.h @@ -22,7 +22,8 @@ struct OpenGOALAsm { FSF, OFFSET, SWAP_FIRST_TWO_SOURCE_ARGS, - ACC_THIRD_SRC_ARG + ACC_THIRD_SRC_ARG, + SKIP_IT }; struct Function { @@ -40,6 +41,7 @@ struct OpenGOALAsm { bool valid = true; bool todo = false; + bool skip = false; Instruction instr; std::optional m_dst; std::vector> m_src; diff --git a/decompiler/analysis/inline_asm_rewrite.cpp b/decompiler/analysis/inline_asm_rewrite.cpp index 3597b07cfb..48142ce606 100644 --- a/decompiler/analysis/inline_asm_rewrite.cpp +++ b/decompiler/analysis/inline_asm_rewrite.cpp @@ -45,6 +45,8 @@ bool rewrite_inline_asm_instructions(Form* top_level_form, asmOp.instr.to_string(f.ir2.env.file->labels)); new_entries.push_back(entry); continue; + } else if (asmOp.skip) { + continue; } else if (elem->op()->instruction().kind == InstructionKind::VOPMULA) { // So far, the only instruction we deal with in pairs is the outer-product // This is kinda a hack, internally the src args of VOPMSUB will be swapped which is