This is an archive of the discontinued LLVM Phabricator instance.

[mips] Enforce compact branch register restrictions
ClosedPublic

Authored by sdardis on May 20 2016, 10:05 AM.

Details

Summary

Enforce compact branch register restrictions such as the use of the zero
register, both operands being the same register. Emit clear error in such
cases as the issue is subtle.

For bovc and bnvc, silently fixup such cases when emitting objects directly,
like LLVM started doing in rL269899.

Diff Detail

Event Timeline

sdardis updated this revision to Diff 57946.May 20 2016, 10:05 AM
sdardis retitled this revision from to [mips] Enforce compact branch register restrictions.
sdardis updated this object.
sdardis added reviewers: dsanders, vkalintiris.
sdardis set the repository for this revision to rL LLVM.
sdardis added a subscriber: llvm-commits.
dsanders accepted this revision.May 31 2016, 8:22 AM
dsanders edited edge metadata.

LGTM with some nits and the new tests enabled.

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
3644–3659

Can we put these comments nearer the relevant block of code?

3654
LLVM's direct object emission

should be 'the encoding' since encoding for other purposes will swap the operands too.

3662–3683

Now that this is starting to grow I think we ought to change the way we write this.

I think we ought to convert it to a switch statement:

switch(Opcode) {
case Mips::JALR_HB:
case Mips::JALRC_HB_MMR6:
  if (Inst.getOperand(0).getReg() == Inst.getOperand(1).getReg()))
    return Match_RequiresDifferentSrcAndDst;
  return Match_Success;
case Mips::LWP_MM:
case Mips::LWP_MMR6:
  if (Inst.getOperand(0).getReg() == Inst.getOperand(2).getReg()))
    return Match_RequiresDifferentSrcAndDst;
  return Match_Success;
...
default:
  return Match_Success;
}
test/MC/Mips/mips32r6/invalid.s
39

Could you fix the typo on temporarely while you're here?

48–65

Did you mean to disable these new tests?

test/MC/Mips/mips64r6/invalid.s
48–61

Did you mean to disable these new tests?

This revision is now accepted and ready to land.May 31 2016, 8:22 AM
sdardis closed this revision.May 31 2016, 11:06 AM
sdardis marked an inline comment as done.

Thanks for the review. Committed as rL271301, rL271306.

test/MC/Mips/mips64r6/invalid.s