decomp: allow skipping inline-asm from output

This commit is contained in:
Tyler Wilding
2022-01-09 23:26:30 -05:00
parent 0352d132dd
commit 4b1cbd104d
3 changed files with 21 additions and 1 deletions
+16
View File
@@ -8,6 +8,14 @@ typedef OpenGOALAsm::InstructionModifiers MOD;
const std::map<InstructionKind, OpenGOALAsm::Function> 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;
}
}
}
+3 -1
View File
@@ -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<RegisterAccess> m_dst;
std::vector<std::optional<RegisterAccess>> m_src;
@@ -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