This is an archive of the discontinued LLVM Phabricator instance.

[mips] Manually replace JAL pseudo-instructions with their JALR equivalent, instead of using InstAlias.
ClosedPublic

Authored by tomatabacu on Oct 3 2014, 8:36 AM.

Details

Summary

This is needed by the .cprestore assembler directive.

This directive needs to be able to insert an LW instruction after every JALR replacement of a JAL pseudo-instruction
(and never after a JALR which has NOT been a result of a pseudo-instruction replacement).

The problem with using InstAlias for these is that after it replaces the pseudo-instruction, we can't find out if the resulting JALR instruction
was generated by an InstAlias or not, so we don't know whether or not to insert our LW instruction.

By replacing it manually, we know when the pseudo-instruction replacement happens and we can insert the LW instruction correctly.

Diff Detail

Event Timeline

tomatabacu updated this revision to Diff 14380.Oct 3 2014, 8:36 AM
tomatabacu retitled this revision from to [mips] Manually replace JAL pseudo-instructions with their JALR equivalent, instead of using InstAlias..
tomatabacu updated this object.
tomatabacu edited the test plan for this revision. (Show Details)
tomatabacu added a reviewer: dsanders.
tomatabacu added a subscriber: Unknown Object (MLST).
tomatabacu planned changes to this revision.Nov 5 2014, 8:26 AM

I need to add the MicroMips versions of the instructions we expand to.

tomatabacu updated this revision to Diff 16049.Nov 11 2014, 8:20 AM

-added the MicroMips version of these expansions.
-added a test-case for the MicroMips version (note that the normal version already has a test-case in MC/Mips/mips-jump-instructions.s).
-made some minor cosmetic changes to the code in the expandJalWithRegs function.

emaste added a subscriber: emaste.Jan 28 2015, 8:38 AM
tomatabacu updated this object.Jan 29 2015, 2:35 AM
dsanders accepted this revision.Jan 29 2015, 9:00 AM
dsanders edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jan 29 2015, 9:00 AM
tomatabacu closed this revision.Jan 30 2015, 3:20 AM

FYI I've made the following change for the commit.

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
1215–1218

Replaced this with a ternary operator comparison.