[clang] [llvm] [Mips] Add r5900 (PlayStation 2 Emotion Engine) CPU support (PR #176666)
Rick Gaiser via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 27 08:29:57 PST 2026
================
@@ -587,10 +648,20 @@ bool MipsDelaySlotFiller::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
if (!hasUnoccupiedSlot(&*I))
continue;
- // Delay slot filling is disabled at -O0, or in microMIPS32R6.
- if (!DisableDelaySlotFiller &&
- (TM->getOptLevel() != CodeGenOptLevel::None) &&
- !(InMicroMipsMode && STI.hasMips32r6())) {
+ // R5900 short loop erratum fix: skip delay slot filling for short backward
+ // loops to avoid triggering a hardware bug where short loops may exit
+ // early. The fix can be controlled with -mfix-r5900 / -mno-fix-r5900.
+ if (STI.fixR5900() && isR5900ShortLoopBranch(&*I, MBB)) {
+ LLVM_DEBUG(dbgs() << DEBUG_TYPE ": skipping delay slot fill for R5900 "
+ "short loop branch.\n");
+ ++R5900ShortLoopNops;
+ // Fall through to insert NOP in delay slot
----------------
rickgaiser wrote:
I made the changes, if ok this can be resolved.
https://github.com/llvm/llvm-project/pull/176666
More information about the cfe-commits
mailing list