summaryrefslogtreecommitdiff
path: root/lib/Target/Mips/MipsLongBranch.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2012-08-28 18:58:57 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2012-08-28 18:58:57 +0000
commit4fb08317af55c97f421047f0bdbfdd320ac76936 (patch)
tree1135d625be556e05633f855cd360aca49eee6fe2 /lib/Target/Mips/MipsLongBranch.cpp
parent4ba6916a98fffd9dedac5945ac51d40c8948069e (diff)
downloadllvm-4fb08317af55c97f421047f0bdbfdd320ac76936.tar.gz
llvm-4fb08317af55c97f421047f0bdbfdd320ac76936.tar.bz2
llvm-4fb08317af55c97f421047f0bdbfdd320ac76936.tar.xz
Follow-up patch to r162731.
Fix a couple of bugs in mips' long branch pass. This patch was supposed to be committed along with r162731, so I don't have a new test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsLongBranch.cpp')
-rw-r--r--lib/Target/Mips/MipsLongBranch.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/Target/Mips/MipsLongBranch.cpp b/lib/Target/Mips/MipsLongBranch.cpp
index 98d8d83fb9..b9dbd522b7 100644
--- a/lib/Target/Mips/MipsLongBranch.cpp
+++ b/lib/Target/Mips/MipsLongBranch.cpp
@@ -257,10 +257,10 @@ void MipsLongBranch::expandToLongBranch(MBBInfo &I) {
LongBrMBB->addSuccessor(BalTgtMBB);
BalTgtMBB->addSuccessor(TgtMBB);
- uint64_t TgtAddress = MBBInfos[TgtMBB->getNumber()].Address;
- uint64_t Offset = TgtAddress - (I.Address + I.Size - 20);
- uint64_t Lo = Offset & 0xffff;
- uint64_t Hi = ((Offset + 0x8000) >> 16) & 0xffff;
+ int64_t TgtAddress = MBBInfos[TgtMBB->getNumber()].Address;
+ int64_t Offset = TgtAddress - (I.Address + I.Size - 20);
+ int64_t Lo = SignExtend64<16>(Offset & 0xffff);
+ int64_t Hi = SignExtend64<16>(((Offset + 0x8000) >> 16) & 0xffff);
if (ABI != MipsSubtarget::N64) {
// $longbr:
@@ -317,8 +317,9 @@ void MipsLongBranch::expandToLongBranch(MBBInfo &I) {
// $fallthrough:
//
- uint64_t Higher = ((Offset + 0x80008000) >> 32) & 0xffff;
- uint64_t Highest = ((Offset + 0x800080008000LL) >> 48) & 0xffff;
+ int64_t Higher = SignExtend64<16>(((Offset + 0x80008000) >> 32) & 0xffff);
+ int64_t Highest =
+ SignExtend64<16>(((Offset + 0x800080008000LL) >> 48) & 0xffff);
Pos = LongBrMBB->begin();
@@ -412,7 +413,7 @@ bool MipsLongBranch::runOnMachineFunction(MachineFunction &F) {
continue;
I->HasLongBranch = true;
- I->Size += LongBranchSeqSize;
+ I->Size += LongBranchSeqSize * 4;
++LongBranches;
EverMadeChange = MadeChange = true;
}
@@ -427,7 +428,7 @@ bool MipsLongBranch::runOnMachineFunction(MachineFunction &F) {
uint64_t Address = 0;
- for (I = MBBInfos.begin(); I != E; ++I, Address += I->Size)
+ for (I = MBBInfos.begin(); I != E; Address += I->Size, ++I)
I->Address = Address;
}