llvm.org GIT mirror llvm / 083a8eb
Generate the dispatch code for a 'thumb' function. This is very similar to the others. They take the call site value. Determine if it's a proper value. And then jumps to the correct call site via a jump table. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141341 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
1 changed file(s) with 53 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
56675667 MBB->addSuccessor(DispatchBB);
56685668
56695669 MachineBasicBlock *TrapBB = MF->CreateMachineBasicBlock();
5670 BuildMI(TrapBB, dl, TII->get(ARM::TRAP));
5670 BuildMI(TrapBB, dl, TII->get(Subtarget->isThumb() ? ARM::tTRAP : ARM::TRAP));
56715671 DispatchBB->addSuccessor(TrapBB);
56725672
56735673 MachineBasicBlock *DispContBB = MF->CreateMachineBasicBlock();
56865686
56875687 MachineMemOperand *FIMMOLd =
56885688 MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI),
5689 MachineMemOperand::MOLoad, 4, 4);
5689 MachineMemOperand::MOLoad |
5690 MachineMemOperand::MOVolatile, 4, 4);
56905691
56915692 if (Subtarget->isThumb2()) {
56925693 unsigned NewVReg1 = MRI->createVirtualRegister(TRC);
57215722 .addJumpTableIndex(MJTI)
57225723 .addImm(UId);
57235724 } else if (Subtarget->isThumb()) {
5725 unsigned NewVReg1 = MRI->createVirtualRegister(TRC);
5726 AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::tLDRspi), NewVReg1)
5727 .addFrameIndex(FI)
5728 .addImm(1)
5729 .addMemOperand(FIMMOLd));
5730 AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::tCMPi8))
5731 .addReg(NewVReg1)
5732 .addImm(LPadList.size()));
5733 BuildMI(DispatchBB, dl, TII->get(ARM::tBcc))
5734 .addMBB(TrapBB)
5735 .addImm(ARMCC::HI)
5736 .addReg(ARM::CPSR);
5737
5738 unsigned NewVReg2 = MRI->createVirtualRegister(TRC);
5739 AddDefaultPred(BuildMI(DispContBB, dl, TII->get(ARM::tLSLri), NewVReg2)
5740 .addReg(ARM::CPSR, RegState::Define)
5741 .addReg(NewVReg1)
5742 .addImm(2));
5743
5744 unsigned NewVReg3 = MRI->createVirtualRegister(TRC);
5745 AddDefaultPred(BuildMI(DispContBB, dl, TII->get(ARM::tLEApcrelJT), NewVReg2)
5746 .addJumpTableIndex(MJTI)
5747 .addImm(UId));
5748
5749 unsigned NewVReg4 = MRI->createVirtualRegister(TRC);
5750 AddDefaultPred(BuildMI(DispContBB, dl, TII->get(ARM::tADDrr), NewVReg4)
5751 .addReg(ARM::CPSR, RegState::Define)
5752 .addReg(NewVReg2, RegState::Kill)
5753 .addReg(NewVReg3));
5754
5755 MachineMemOperand *JTMMOLd =
5756 MF->getMachineMemOperand(MachinePointerInfo::getJumpTable(),
5757 MachineMemOperand::MOLoad, 4, 4);
5758
5759 unsigned NewVReg5 = MRI->createVirtualRegister(TRC);
5760 AddDefaultPred(BuildMI(DispContBB, dl, TII->get(ARM::tLDRi), NewVReg5)
5761 .addReg(NewVReg4, RegState::Kill)
5762 .addImm(0)
5763 .addMemOperand(JTMMOLd));
5764
5765 unsigned NewVReg6 = MRI->createVirtualRegister(TRC);
5766 AddDefaultPred(BuildMI(DispContBB, dl, TII->get(ARM::tADDrr), NewVReg6)
5767 .addReg(ARM::CPSR, RegState::Define)
5768 .addReg(NewVReg5, RegState::Kill)
5769 .addReg(NewVReg3));
5770
5771 BuildMI(DispContBB, dl, TII->get(ARM::tBR_JTr))
5772 .addReg(NewVReg6, RegState::Kill)
5773 .addJumpTableIndex(MJTI)
5774 .addImm(UId);
57245775 } else {
57255776 unsigned NewVReg1 = MRI->createVirtualRegister(TRC);
57265777 AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::LDRi12), NewVReg1)