This is an archive of the discontinued LLVM Phabricator instance.

[mips] Add partial support for R6 in the long branch pass
ClosedPublic

Authored by sdardis on Dec 4 2017, 7:18 AM.

Details

Summary

MIPSR6 introduced several new jump instructions and deprecated
the use of the 'j' instruction. For microMIPS32R6, 'j' was removed
entirely and it only has non delay slot jumps.

This patch adds support for MIPSR6 by using some R6 instructions--
'bc' instead of 'j', 'jic $reg, 0' instead of 'jalr $zero, $reg'--
and modifies the sequences not to use delay slots for R6.

Diff Detail

Repository
rL LLVM

Event Timeline

sdardis created this revision.Dec 4 2017, 7:18 AM
atanasyan accepted this revision.Dec 6 2017, 2:47 AM

LGTM with a few nits

lib/Target/Mips/MipsLongBranch.cpp
353 ↗(On Diff #125339)

I would revert this condition:

if (Subtarget.hasMips32r6()) {
  LongBrMBB->insert(Pos, ADDiuInstr);
  LongBrMBB->insert(Pos, BalInstr);
} else {
  LongBrMBB->insert(Pos, BalInstr);
  LongBrMBB->insert(Pos, ADDiuInstr);
  LongBrMBB->rbegin()->bundleWithPred();
}
462 ↗(On Diff #125339)

And here.

504 ↗(On Diff #125339)

And here.

547 ↗(On Diff #125339)

I would reduce number of ternary operators a bit:

LongBranchSeqSize = IsPIC
    ? ((ABI.IsN64() || STI.isTargetNaCl()) ? 10 : 9)
    : (STI.hasMips32r6() ? 1 : 2);
This revision is now accepted and ready to land.Dec 6 2017, 2:47 AM
This revision was automatically updated to reflect the committed changes.

Thanks for the review.