This is an archive of the discontinued LLVM Phabricator instance.

[mips] Add support for .cpload.
ClosedPublic

Authored by matheusalmeida on Apr 24 2014, 4:53 AM.

Details

Summary

This directive is used for setting up $gp in the beginning of a function.
It expands to three instructions if PIC is enabled:
lui $gp, %hi(_gp_disp)
addui $gp, $gp, %lo(_gp_disp)
addu $gp, $gp, $reg

_gp_disp is a special symbol that the linker sets to the distance between
the lui instruction and the context pointer (_gp).

Diff Detail

Event Timeline

matheusalmeida retitled this revision from to [mips] Add support for .cpload..
matheusalmeida updated this object.
matheusalmeida edited the test plan for this revision. (Show Details)
matheusalmeida added inline comments.Apr 24 2014, 5:44 AM
lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
441

This can be shortened to MCA.getContext().

452

This can be shortened to MCA.getContext().

dsanders added inline comments.Apr 25 2014, 2:30 AM
lib/Target/Mips/AsmParser/MipsAsmParser.cpp
2317–2318

Should there be a separate check for MIPS16?

2321

Please use ParseAnyRegister instead and use the methods in MipsOperand to convert it to a GPR. If you can change the remaining uses of parseRegister to ParseAnyRegister in a follow-on patch it would be appreciated.

This will remove the need for isGPR(), and getGPR(). It may also remove the need for the extra reportParseError() function.

2588–2590

Removed whitespace?

lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
417

*independent

418

Use isN32() || isN64() instead of !(STI.getFeatureBits() & Mips::FeatureO32).
This will be a bit more robust when O64, EABI, etc. are implemented.

428–429

Mentioning the extension in the above comment is enough to describe the functionality that depends on unimplemented options.

If you'd prefer to keep the code as well, it would be good to mention that -mshared doesn't exist yet.

432–434

If you don't need to use it, it may be best not to assign it to a variable. Attempting to silence the warning may not be portable.

Now uses ParseAnyReg as opposed to parseRegister.

The Mips16 check is going to be done in a follow-up patch
after we add more asm tests that check that we correctly
handle .set mips16 and .set nomips16.

dsanders accepted this revision.Apr 29 2014, 8:28 AM
dsanders edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 29 2014, 8:28 AM