This is an archive of the discontinued LLVM Phabricator instance.

[mips] [IAS] Unify common functionality of LA and LI.
ClosedPublic

Authored by tomatabacu on Apr 27 2015, 5:44 AM.

Details

Summary

A side-effect of this is that LA gains proper handling of unsigned and positive signed 16-bit immediates and more accurate error messages.

Diff Detail

Event Timeline

dsanders edited edge metadata.May 6 2015, 7:32 AM

Thanks for combining these two. I've got a few comments but they are all fairly minor.

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
1721–1723

We don't really need the MCOperand's. We could have an int64_t for ImmOp and unsigned for the two register operands. This would also remove the need to allow nullptr in SrcRegOp since we could use Mips::NoRegister instead.

1743

Mips::ZERO should be Mips::ZERO64 on 64-bit targets.

Likewise for the bitwise operations below but not for ADDiu.

Also, I'd suggest having SrcReg default to Mips::ZERO or Mips::ZERO64 and renaming UseSrcReg to SrcRegIsNotZero.

1768–1775

This could be done in a follow-up patch, but all of the cases below this one end with the same code to generate an ADDu. We could factor it out fairly easily.

1850–1861

Similar to expandLoadAddressReg(), most of these pointers ought to be references and passed to loadImmediate() as, for example, &ImmOp or ImmOp->getImm()

1865–1904

Could you switch these back to references? You can always pass, for example, &ImmOp or ImmOp->getImm() into loadImmediate().

tomatabacu updated this revision to Diff 25059.May 6 2015, 9:39 AM
tomatabacu edited edge metadata.

Addressed review comments.

Replied to inline comments.

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
1721–1723

Done.

1743

Essentially done.
I didn't make SrcReg default to Mips::ZERO or Mips::ZERO64 because there are only 2 places where it could be used with those values and they are slightly different, as one of them should only get Mips::ZERO (the ADDiu).
This also means that there's no reason to rename UseSrcReg to SrcRegIsNotZero.

1768–1775

Done.

1850–1861

Done.

1865–1904

Done.

dsanders accepted this revision.May 13 2015, 3:33 AM
dsanders edited edge metadata.

LGTM with/without an optional nit.

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
1743

Good point. I'd slightly prefer it for tidyness but it's a very slight preference so consider it optional.

This revision is now accepted and ready to land.May 13 2015, 3:33 AM
tomatabacu closed this revision.May 13 2015, 6:59 AM