diff options
author | Sasa Stankovic <Sasa.Stankovic@imgtec.com> | 2014-05-27 18:53:06 +0000 |
---|---|---|
committer | Sasa Stankovic <Sasa.Stankovic@imgtec.com> | 2014-05-27 18:53:06 +0000 |
commit | 95ce098219b204612be7595a94a382d5cab6eea4 (patch) | |
tree | 80ef49bd60749ac8336e6a7e900c20eb53485102 /lib/Target/Mips/MipsMCInstLower.cpp | |
parent | 41087d99df6ed87405639a6ee1a4bc7b825d4b65 (diff) | |
download | llvm-95ce098219b204612be7595a94a382d5cab6eea4.tar.gz llvm-95ce098219b204612be7595a94a382d5cab6eea4.tar.bz2 llvm-95ce098219b204612be7595a94a382d5cab6eea4.tar.xz |
[mips] Optimize long branch for MIPS64 by removing %higher and %highest.
%higher and %highest can have non-zero values only for offsets greater
than 2GB, which is highly unlikely, if not impossible when compiling a
single function. This makes long branch for MIPS64 3 instructions smaller.
Differential Revision: http://llvm-reviews.chandlerc.com/D3281.diff
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsMCInstLower.cpp')
-rw-r--r-- | lib/Target/Mips/MipsMCInstLower.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/Target/Mips/MipsMCInstLower.cpp b/lib/Target/Mips/MipsMCInstLower.cpp index 85f7867466..821392e1d4 100644 --- a/lib/Target/Mips/MipsMCInstLower.cpp +++ b/lib/Target/Mips/MipsMCInstLower.cpp @@ -162,16 +162,16 @@ MCOperand MipsMCInstLower::createSub(MachineBasicBlock *BB1, } void MipsMCInstLower:: -lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI, int Opcode, - MCSymbolRefExpr::VariantKind Kind) const { - OutMI.setOpcode(Opcode); +lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const { + OutMI.setOpcode(Mips::LUi); // Lower register operand. OutMI.addOperand(LowerOperand(MI->getOperand(0))); - // Create %hi($tgt-$baltgt) or %highest($tgt-$baltgt). + // Create %hi($tgt-$baltgt). OutMI.addOperand(createSub(MI->getOperand(1).getMBB(), - MI->getOperand(2).getMBB(), Kind)); + MI->getOperand(2).getMBB(), + MCSymbolRefExpr::VK_Mips_ABS_HI)); } void MipsMCInstLower:: @@ -185,7 +185,7 @@ lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI, int Opcode, OutMI.addOperand(LowerOperand(MO)); } - // Create %lo($tgt-$baltgt), %hi($tgt-$baltgt) or %higher($tgt-$baltgt). + // Create %lo($tgt-$baltgt) or %hi($tgt-$baltgt). OutMI.addOperand(createSub(MI->getOperand(2).getMBB(), MI->getOperand(3).getMBB(), Kind)); } @@ -196,11 +196,7 @@ bool MipsMCInstLower::lowerLongBranch(const MachineInstr *MI, default: return false; case Mips::LONG_BRANCH_LUi: - lowerLongBranchLUi(MI, OutMI, Mips::LUi, MCSymbolRefExpr::VK_Mips_ABS_HI); - return true; - case Mips::LONG_BRANCH_LUi64: - lowerLongBranchLUi(MI, OutMI, Mips::LUi64, - MCSymbolRefExpr::VK_Mips_HIGHEST); + lowerLongBranchLUi(MI, OutMI); return true; case Mips::LONG_BRANCH_ADDiu: lowerLongBranchADDiu(MI, OutMI, Mips::ADDiu, @@ -208,10 +204,7 @@ bool MipsMCInstLower::lowerLongBranch(const MachineInstr *MI, return true; case Mips::LONG_BRANCH_DADDiu: unsigned TargetFlags = MI->getOperand(2).getTargetFlags(); - if (TargetFlags == MipsII::MO_HIGHER) - lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu, - MCSymbolRefExpr::VK_Mips_HIGHER); - else if (TargetFlags == MipsII::MO_ABS_HI) + if (TargetFlags == MipsII::MO_ABS_HI) lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu, MCSymbolRefExpr::VK_Mips_ABS_HI); else if (TargetFlags == MipsII::MO_ABS_LO) |