1327952Sdim//===- Thumb1FrameLowering.h - Thumb1-specific frame info stuff ---*- C++ -*-=// 2218885Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6218885Sdim// 7218885Sdim//===----------------------------------------------------------------------===// 8218885Sdim 9280031Sdim#ifndef LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H 10280031Sdim#define LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H 11218885Sdim 12218885Sdim#include "ARMFrameLowering.h" 13218885Sdim 14218885Sdimnamespace llvm { 15218885Sdim 16327952Sdimclass ARMSubtarget; 17327952Sdimclass MachineFunction; 18327952Sdim 19218885Sdimclass Thumb1FrameLowering : public ARMFrameLowering { 20218885Sdimpublic: 21276479Sdim explicit Thumb1FrameLowering(const ARMSubtarget &sti); 22218885Sdim 23218885Sdim /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 24218885Sdim /// the function. 25288943Sdim void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 26276479Sdim void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 27218885Sdim 28218885Sdim bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, 29218885Sdim MachineBasicBlock::iterator MI, 30218885Sdim const std::vector<CalleeSavedInfo> &CSI, 31276479Sdim const TargetRegisterInfo *TRI) const override; 32218885Sdim bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, 33276479Sdim MachineBasicBlock::iterator MI, 34327952Sdim std::vector<CalleeSavedInfo> &CSI, 35276479Sdim const TargetRegisterInfo *TRI) const override; 36218885Sdim 37276479Sdim bool hasReservedCallFrame(const MachineFunction &MF) const override; 38249423Sdim 39309124Sdim MachineBasicBlock::iterator 40276479Sdim eliminateCallFramePseudoInstr(MachineFunction &MF, 41276479Sdim MachineBasicBlock &MBB, 42276479Sdim MachineBasicBlock::iterator MI) const override; 43296417Sdim 44296417Sdim /// Check whether or not the given \p MBB can be used as a epilogue 45296417Sdim /// for the target. 46296417Sdim /// The epilogue will be inserted before the first terminator of that block. 47296417Sdim /// This method is used by the shrink-wrapping pass to decide if 48296417Sdim /// \p MBB will be correctly handled by the target. 49296417Sdim bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override; 50296417Sdim 51296417Sdim /// Disable shrink wrap as tBfar/BL will be used to adjust for long jumps. 52296417Sdim bool enableShrinkWrapping(const MachineFunction &MF) const override { 53296417Sdim return false; 54296417Sdim } 55296417Sdim 56296417Sdimprivate: 57296417Sdim /// Check if the frame lowering of \p MF needs a special fixup 58296417Sdim /// code sequence for the epilogue. 59296417Sdim /// Unlike T2 and ARM mode, the T1 pop instruction cannot restore 60296417Sdim /// to LR, and we can't pop the value directly to the PC when 61296417Sdim /// we need to update the SP after popping the value. So instead 62296417Sdim /// we have to emit: 63296417Sdim /// POP {r3} 64296417Sdim /// ADD sp, #offset 65296417Sdim /// BX r3 66296417Sdim /// If this would clobber a return value, then generate this sequence instead: 67296417Sdim /// MOV ip, r3 68296417Sdim /// POP {r3} 69296417Sdim /// ADD sp, #offset 70296417Sdim /// MOV lr, r3 71296417Sdim /// MOV r3, ip 72296417Sdim /// BX lr 73296417Sdim bool needPopSpecialFixUp(const MachineFunction &MF) const; 74296417Sdim 75296417Sdim /// Emit the special fixup code sequence for the epilogue. 76296417Sdim /// \see needPopSpecialFixUp for more details. 77296417Sdim /// \p DoIt, tells this method whether or not to actually insert 78296417Sdim /// the code sequence in \p MBB. I.e., when \p DoIt is false, 79296417Sdim /// \p MBB is left untouched. 80296417Sdim /// \returns For \p DoIt == true: True when the emission succeeded 81296417Sdim /// false otherwise. For \p DoIt == false: True when the emission 82296417Sdim /// would have been possible, false otherwise. 83296417Sdim bool emitPopSpecialFixUp(MachineBasicBlock &MBB, bool DoIt) const; 84218885Sdim}; 85218885Sdim 86327952Sdim} // end namespace llvm 87218885Sdim 88327952Sdim#endif // LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H 89