matt-kempster / m2c

A MIPS and PowerPC decompiler.
GNU General Public License v3.0
386 stars 46 forks source link

Fcmpo cror on dtk has a different format #277

Open dbalatoni13 opened 1 month ago

dbalatoni13 commented 1 month ago

We currently have an asm pattern for Fcmpo cror, it looks like this:

fcmpo $cr0, $x, $y
cror 2, N, 2

but in the asm format of dtk it's like this:

fcmpo $cr0, $x, $y
cror eq, gt, eq

or lt respectively.

What would be the nicest way to make m2c support both formats?

simonlindholm commented 1 month ago

The way this is meant to work is that you have a .set eq, 2 directive in your asm file that gets expanded during parsing. If dtk is assuming an implicit prelude then we may want to add that prelude to m2c.

dbalatoni13 commented 1 month ago

dtk asm files include macros.inc which does not contain this directive.

My question is: even if it did, would the include be needed to be manually pasted into the file before running m2c or is there an automatic way?

simonlindholm commented 1 month ago

It would currently need to be either manually pasted, yes. I think we can add an arch-specific prelude to deal with this? It would go in defines in parse_file. This approach does mean btw that reloc references to a global named eq gets treated as a literal with the value 2 instead, which is not ideal, but I think in practice the breakage will be non-existent.