diff options
author | Simon Dardis <simon.dardis@imgtec.com> | 2016-08-18 13:22:43 +0000 |
---|---|---|
committer | Simon Dardis <simon.dardis@imgtec.com> | 2016-08-18 13:22:43 +0000 |
commit | ea3431598e552fdfb7cd69f92fecc661d64fa2b1 (patch) | |
tree | 7d3f9520e0b820906b5f64c905f34612d766a221 /llvm/lib/Target/Mips/MipsAsmPrinter.cpp | |
parent | 83f6bbc1546fbc7736efb8c13d2590f5c3fd3647 (diff) | |
download | bcm5719-llvm-ea3431598e552fdfb7cd69f92fecc661d64fa2b1.tar.gz bcm5719-llvm-ea3431598e552fdfb7cd69f92fecc661d64fa2b1.zip |
[mips] Correct tail call encoding for MIPSR6
r277708 enabled tails calls for MIPS but used the 'jr' instruction when the
jump target was held in a register. For MIPSR6, 'jalr $zero, $reg' should
have been used. Additionally, add missing patterns for external and global
symbols for tail calls.
Reviewers: dsanders, vkalintiris
Differential Review: https://reviews.llvm.org/D23301
llvm-svn: 279064
Diffstat (limited to 'llvm/lib/Target/Mips/MipsAsmPrinter.cpp')
-rw-r--r-- | llvm/lib/Target/Mips/MipsAsmPrinter.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index 3136f504d42..7519c309e44 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -98,6 +98,7 @@ bool MipsAsmPrinter::lowerOperand(const MachineOperand &MO, MCOperand &MCOp) { void MipsAsmPrinter::emitPseudoIndirectBranch(MCStreamer &OutStreamer, const MachineInstr *MI) { bool HasLinkReg = false; + bool InMicroMipsMode = Subtarget->inMicroMipsMode(); MCInst TmpInst0; if (Subtarget->hasMips64r6()) { @@ -106,8 +107,12 @@ void MipsAsmPrinter::emitPseudoIndirectBranch(MCStreamer &OutStreamer, HasLinkReg = true; } else if (Subtarget->hasMips32r6()) { // MIPS32r6 should use (JALR ZERO, $rs) - TmpInst0.setOpcode(Mips::JALR); - HasLinkReg = true; + if (InMicroMipsMode) + TmpInst0.setOpcode(Mips::JRC16_MMR6); + else { + TmpInst0.setOpcode(Mips::JALR); + HasLinkReg = true; + } } else if (Subtarget->inMicroMipsMode()) // microMIPS should use (JR_MM $rs) TmpInst0.setOpcode(Mips::JR_MM); @@ -185,7 +190,9 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) { if (I->getOpcode() == Mips::PseudoReturn || I->getOpcode() == Mips::PseudoReturn64 || I->getOpcode() == Mips::PseudoIndirectBranch || - I->getOpcode() == Mips::PseudoIndirectBranch64) { + I->getOpcode() == Mips::PseudoIndirectBranch64 || + I->getOpcode() == Mips::TAILCALLREG || + I->getOpcode() == Mips::TAILCALLREG64) { emitPseudoIndirectBranch(*OutStreamer, &*I); continue; } |