aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-10-18 23:11:05 +0000
committerBill Wendling <isanbard@gmail.com>2011-10-18 23:11:05 +0000
commita5871dc1044ff31906f3a2cfc639c7fcd0a14c76 (patch)
treea6e8f522429ba555d50fdb820a64b393b9f5e45a
parentbf79f919417f450245c284db19125e76c969a84e (diff)
downloadexternal_llvm-a5871dc1044ff31906f3a2cfc639c7fcd0a14c76.zip
external_llvm-a5871dc1044ff31906f3a2cfc639c7fcd0a14c76.tar.gz
external_llvm-a5871dc1044ff31906f3a2cfc639c7fcd0a14c76.tar.bz2
For Thumb mode, we need to use a constant pool if the value is too large to be
used with the CMP instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142458 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/ARM/ARMISelLowering.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp
index 236ea6f..9cc1d33 100644
--- a/lib/Target/ARM/ARMISelLowering.cpp
+++ b/lib/Target/ARM/ARMISelLowering.cpp
@@ -5809,9 +5809,26 @@ EmitSjLjDispatchBlock(MachineInstr *MI, MachineBasicBlock *MBB) const {
.addImm(1)
.addMemOperand(FIMMOLd));
- AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::tCMPi8))
- .addReg(NewVReg1)
- .addImm(LPadList.size()));
+ if (NumLPads < 256) {
+ AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::tCMPi8))
+ .addReg(NewVReg1)
+ .addImm(NumLPads));
+ } else {
+ MachineConstantPool *ConstantPool = MF->getConstantPool();
+ const Constant *C =
+ ConstantInt::get(Type::getInt32Ty(MF->getFunction()->getContext()),
+ NumLPads);
+ unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
+
+ unsigned VReg1 = MRI->createVirtualRegister(TRC);
+ AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::tLDRpci))
+ .addReg(VReg1, RegState::Define)
+ .addConstantPoolIndex(Idx));
+ AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::tCMPr))
+ .addReg(NewVReg1)
+ .addReg(VReg1));
+ }
+
BuildMI(DispatchBB, dl, TII->get(ARM::tBcc))
.addMBB(TrapBB)
.addImm(ARMCC::HI)