MIPS I, II, and III have delay slots for floating point comparisons and floating point register transfers (mtc1, mfc1). Currently, these are not taken into account and thus broken code may be generated on these targets. This patch inserts nops as necessary, while attempting to leave the current instruction if it is safe to stay.
The tests in this patch were updated by @sajattack
Sources:
https://gcc.gnu.org/legacy-ml/gcc-patches/2003-05/msg01601.html
https://gcc.gnu.org/legacy-ml/gcc-patches/2003-05/msg01605.html
https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/config/mips/mips.h#L1282
"See MIPS Run" Textbook: https://user-images.githubusercontent.com/1562711/144544253-de268f41-d808-4076-a500-e2cdba7f4294.png
MIPS R4000 Manual: https://user-images.githubusercontent.com/1562711/144544877-8896b4e9-3127-45a6-99d7-48b53a9b35e6.png
This code is being copied from handleForbiddenSlot() (most of it, actually). Can we factor/move the common code into a function/predicate?