This lays the groundwork for implementing "IR patterns", which need to (soundly) match reordered instructions.
If it's useful, my branch for doing IR pattern matching is here. I'm not sure if we should just do one big PR off of that branch instead?
The changes here aren't intended to have any output diffs, but they do change:
New Warning: in ..., regs were read before being written to: warnings.
I was unsure if these were worth adding at all: they usually aren't very useful to a decomper, but they are important to mips_to_c developers.
Some were from unsound asm pattern replacements, like dropping the "*" instruction in GccSqrtPattern. (It's usually a nop, but sometimes it should be included)
It's possible to get the state of argument/return registers incorrect by providing incorrect types in the context file. (e.g. marking a function int foo(int); as void foo(void);)
I had to change the raise DecompError("Undeclared read...") into a weaker return ErrorExpr("Read from unset register...") so that an incorrect context hint won't break an entire function.
I added special error handling for mtc0. It now treats it as a no-dest instruction, instead of assuming that it writes to its first arg.
This changed the output of a few functions like osUnmapTLBAll
This lays the groundwork for implementing "IR patterns", which need to (soundly) match reordered instructions.
If it's useful, my branch for doing IR pattern matching is here. I'm not sure if we should just do one big PR off of that branch instead?
The changes here aren't intended to have any output diffs, but they do change:
Warning: in ..., regs were read before being written to:
warnings."*"
instruction inGccSqrtPattern
. (It's usually anop
, but sometimes it should be included)int foo(int);
asvoid foo(void);
)raise DecompError("Undeclared read...")
into a weakerreturn ErrorExpr("Read from unset register...")
so that an incorrect context hint won't break an entire function.mtc0
. It now treats it as a no-dest instruction, instead of assuming that it writes to its first arg.osUnmapTLBAll