90 lines · c
1//===- Thumb1FrameLowering.h - Thumb1-specific frame info stuff ---*- C++ -*-=//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H10#define LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H11 12#include "ARMFrameLowering.h"13 14namespace llvm {15 16class ARMSubtarget;17class MachineFunction;18 19class Thumb1FrameLowering : public ARMFrameLowering {20public:21 explicit Thumb1FrameLowering(const ARMSubtarget &sti);22 23 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into24 /// the function.25 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;26 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;27 28 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,29 MachineBasicBlock::iterator MI,30 ArrayRef<CalleeSavedInfo> CSI,31 const TargetRegisterInfo *TRI) const override;32 bool33 restoreCalleeSavedRegisters(MachineBasicBlock &MBB,34 MachineBasicBlock::iterator MI,35 MutableArrayRef<CalleeSavedInfo> CSI,36 const TargetRegisterInfo *TRI) const override;37 38 bool hasReservedCallFrame(const MachineFunction &MF) const override;39 40 MachineBasicBlock::iterator41 eliminateCallFramePseudoInstr(MachineFunction &MF,42 MachineBasicBlock &MBB,43 MachineBasicBlock::iterator MI) const override;44 45 /// Check whether or not the given \p MBB can be used as a epilogue46 /// for the target.47 /// The epilogue will be inserted before the first terminator of that block.48 /// This method is used by the shrink-wrapping pass to decide if49 /// \p MBB will be correctly handled by the target.50 bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override;51 52 /// Disable shrink wrap as tBfar/BL will be used to adjust for long jumps.53 bool enableShrinkWrapping(const MachineFunction &MF) const override {54 return false;55 }56 57private:58 /// Check if the frame lowering of \p MF needs a special fixup59 /// code sequence for the epilogue.60 /// Unlike T2 and ARM mode, the T1 pop instruction cannot restore61 /// to LR, and we can't pop the value directly to the PC when62 /// we need to update the SP after popping the value. So instead63 /// we have to emit:64 /// POP {r3}65 /// ADD sp, #offset66 /// BX r367 /// If this would clobber a return value, then generate this sequence instead:68 /// MOV ip, r369 /// POP {r3}70 /// ADD sp, #offset71 /// MOV lr, r372 /// MOV r3, ip73 /// BX lr74 bool needPopSpecialFixUp(const MachineFunction &MF) const;75 76 /// Emit the special fixup code sequence for the epilogue.77 /// \see needPopSpecialFixUp for more details.78 /// \p DoIt, tells this method whether or not to actually insert79 /// the code sequence in \p MBB. I.e., when \p DoIt is false,80 /// \p MBB is left untouched.81 /// \returns For \p DoIt == true: True when the emission succeeded82 /// false otherwise. For \p DoIt == false: True when the emission83 /// would have been possible, false otherwise.84 bool emitPopSpecialFixUp(MachineBasicBlock &MBB, bool DoIt) const;85};86 87} // end namespace llvm88 89#endif // LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H90