summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
diff options
context:
space:
mode:
authorReed Kotler <rkotler@mips.com>2013-11-21 05:13:23 +0000
committerReed Kotler <rkotler@mips.com>2013-11-21 05:13:23 +0000
commit2fc05be88754d48c9c32883e7d0d381693fa0338 (patch)
treea19523860be4958ab34ec21cff9caa2f0d1101e9 /llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
parent2a9d96992d5b9c2a5811f9c31cc9164512c5498f (diff)
downloadbcm5719-llvm-2fc05be88754d48c9c32883e7d0d381693fa0338.tar.gz
bcm5719-llvm-2fc05be88754d48c9c32883e7d0d381693fa0338.zip
Add, to constant islands, long jumps similar to ARM far branch.
llvm-svn: 195312
Diffstat (limited to 'llvm/lib/Target/Mips/MipsConstantIslandPass.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsConstantIslandPass.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp b/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
index c46bbacf658..63d07f35478 100644
--- a/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
+++ b/llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
@@ -1399,9 +1399,29 @@ bool
MipsConstantIslands::fixupUnconditionalBr(ImmBranch &Br) {
MachineInstr *MI = Br.MI;
MachineBasicBlock *MBB = MI->getParent();
+ MachineBasicBlock *DestBB = MI->getOperand(0).getMBB();
// Use BL to implement far jump.
- Br.MaxDisp = ((1 << 16)-1) * 2;
- MI->setDesc(TII->get(Mips::BimmX16));
+ unsigned BimmX16MaxDisp = ((1 << 16)-1) * 2;
+ if (isBBInRange(MI, DestBB, BimmX16MaxDisp)) {
+ Br.MaxDisp = BimmX16MaxDisp;
+ MI->setDesc(TII->get(Mips::BimmX16));
+ }
+ else {
+ // need to give the math a more careful look here
+ // this is really a segment address and not
+ // a PC relative address. FIXME. But I think that
+ // just reducing the bits by 1 as I've done is correct.
+ // The basic block we are branching too much be longword aligned.
+ // we know that RA is saved because we always save it right now.
+ // this requirement will be relaxed later but we also have an alternate
+ // way to implement this that I will implement that does not need jal.
+ // We should have a way to back out this alignment restriction if we "can" later.
+ // but it is not harmful.
+ //
+ DestBB->setAlignment(2);
+ Br.MaxDisp = ((1<<24)-1) * 2;
+ MI->setDesc(TII->get(Mips::Jal16));
+ }
BBInfo[MBB->getNumber()].Size += 2;
adjustBBOffsetsAfter(MBB);
HasFarJump = true;
OpenPOWER on IntegriCloud