diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:50:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:50:12 +0000 |
| commit | e6d1592492a3a379186bfb02bd0f4eda0669c0d5 (patch) | |
| tree | 599ab169a01f1c86eda9adc774edaedde2f2db5b /lib/Target/ARM/ThumbRegisterInfo.cpp | |
| parent | 1a56a5ead7a2e84bee8240f5f6b033b5f1707154 (diff) | |
Notes
Diffstat (limited to 'lib/Target/ARM/ThumbRegisterInfo.cpp')
| -rw-r--r-- | lib/Target/ARM/ThumbRegisterInfo.cpp | 75 |
1 files changed, 14 insertions, 61 deletions
diff --git a/lib/Target/ARM/ThumbRegisterInfo.cpp b/lib/Target/ARM/ThumbRegisterInfo.cpp index e4bdd40fb743..a96417ffce4d 100644 --- a/lib/Target/ARM/ThumbRegisterInfo.cpp +++ b/lib/Target/ARM/ThumbRegisterInfo.cpp @@ -1,9 +1,8 @@ //===-- ThumbRegisterInfo.cpp - Thumb-1 Register Information -------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -447,63 +446,6 @@ void ThumbRegisterInfo::resolveFrameIndex(MachineInstr &MI, unsigned BaseReg, (void)Done; } -/// saveScavengerRegister - Spill the register so it can be used by the -/// register scavenger. Return true. -bool ThumbRegisterInfo::saveScavengerRegister( - MachineBasicBlock &MBB, MachineBasicBlock::iterator I, - MachineBasicBlock::iterator &UseMI, const TargetRegisterClass *RC, - unsigned Reg) const { - - const ARMSubtarget &STI = MBB.getParent()->getSubtarget<ARMSubtarget>(); - if (!STI.isThumb1Only()) - return ARMBaseRegisterInfo::saveScavengerRegister(MBB, I, UseMI, RC, Reg); - - // Thumb1 can't use the emergency spill slot on the stack because - // ldr/str immediate offsets must be positive, and if we're referencing - // off the frame pointer (if, for example, there are alloca() calls in - // the function, the offset will be negative. Use R12 instead since that's - // a call clobbered register that we know won't be used in Thumb1 mode. - const TargetInstrInfo &TII = *STI.getInstrInfo(); - DebugLoc DL; - BuildMI(MBB, I, DL, TII.get(ARM::tMOVr)) - .addReg(ARM::R12, RegState::Define) - .addReg(Reg, RegState::Kill) - .add(predOps(ARMCC::AL)); - - // The UseMI is where we would like to restore the register. If there's - // interference with R12 before then, however, we'll need to restore it - // before that instead and adjust the UseMI. - bool done = false; - for (MachineBasicBlock::iterator II = I; !done && II != UseMI ; ++II) { - if (II->isDebugInstr()) - continue; - // If this instruction affects R12, adjust our restore point. - for (unsigned i = 0, e = II->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = II->getOperand(i); - if (MO.isRegMask() && MO.clobbersPhysReg(ARM::R12)) { - UseMI = II; - done = true; - break; - } - if (!MO.isReg() || MO.isUndef() || !MO.getReg() || - TargetRegisterInfo::isVirtualRegister(MO.getReg())) - continue; - if (MO.getReg() == ARM::R12) { - UseMI = II; - done = true; - break; - } - } - } - // Restore the register from R12 - BuildMI(MBB, UseMI, DL, TII.get(ARM::tMOVr)) - .addReg(Reg, RegState::Define) - .addReg(ARM::R12, RegState::Kill) - .add(predOps(ARMCC::AL)); - - return true; -} - void ThumbRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj, unsigned FIOperandNum, RegScavenger *RS) const { @@ -619,3 +561,14 @@ void ThumbRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II, if (MI.isPredicable()) MIB.add(predOps(ARMCC::AL)); } + +bool +ThumbRegisterInfo::useFPForScavengingIndex(const MachineFunction &MF) const { + if (MF.getSubtarget<ARMSubtarget>().isThumb1Only()) { + // For Thumb1, the emergency spill slot must be some small positive + // offset from the base/stack pointer. + return false; + } + // For Thumb2, put the emergency spill slot next to FP. + return true; +} |
