1 //===-- Thumb1FrameLowering.h - Thumb1-specific frame info stuff --*- C++ -*-=// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H 15 #define LLVM_LIB_TARGET_ARM_THUMB1FRAMELOWERING_H 16 17 #include "ARMFrameLowering.h" 18 #include "Thumb1InstrInfo.h" 19 #include "ThumbRegisterInfo.h" 20 #include "llvm/Target/TargetFrameLowering.h" 21 22 namespace llvm { 23 24 class Thumb1FrameLowering : public ARMFrameLowering { 25 public: 26 explicit Thumb1FrameLowering(const ARMSubtarget &sti); 27 28 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 29 /// the function. 30 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 31 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 32 33 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, 34 MachineBasicBlock::iterator MI, 35 const std::vector<CalleeSavedInfo> &CSI, 36 const TargetRegisterInfo *TRI) const override; 37 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, 38 MachineBasicBlock::iterator MI, 39 const std::vector<CalleeSavedInfo> &CSI, 40 const TargetRegisterInfo *TRI) const override; 41 42 bool hasReservedCallFrame(const MachineFunction &MF) const override; 43 44 MachineBasicBlock::iterator 45 eliminateCallFramePseudoInstr(MachineFunction &MF, 46 MachineBasicBlock &MBB, 47 MachineBasicBlock::iterator MI) const override; 48 49 /// Check whether or not the given \p MBB can be used as a epilogue 50 /// for the target. 51 /// The epilogue will be inserted before the first terminator of that block. 52 /// This method is used by the shrink-wrapping pass to decide if 53 /// \p MBB will be correctly handled by the target. 54 bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override; 55 56 /// Disable shrink wrap as tBfar/BL will be used to adjust for long jumps. 57 bool enableShrinkWrapping(const MachineFunction &MF) const override { 58 return false; 59 } 60 61 private: 62 /// Check if the frame lowering of \p MF needs a special fixup 63 /// code sequence for the epilogue. 64 /// Unlike T2 and ARM mode, the T1 pop instruction cannot restore 65 /// to LR, and we can't pop the value directly to the PC when 66 /// we need to update the SP after popping the value. So instead 67 /// we have to emit: 68 /// POP {r3} 69 /// ADD sp, #offset 70 /// BX r3 71 /// If this would clobber a return value, then generate this sequence instead: 72 /// MOV ip, r3 73 /// POP {r3} 74 /// ADD sp, #offset 75 /// MOV lr, r3 76 /// MOV r3, ip 77 /// BX lr 78 bool needPopSpecialFixUp(const MachineFunction &MF) const; 79 80 /// Emit the special fixup code sequence for the epilogue. 81 /// \see needPopSpecialFixUp for more details. 82 /// \p DoIt, tells this method whether or not to actually insert 83 /// the code sequence in \p MBB. I.e., when \p DoIt is false, 84 /// \p MBB is left untouched. 85 /// \returns For \p DoIt == true: True when the emission succeeded 86 /// false otherwise. For \p DoIt == false: True when the emission 87 /// would have been possible, false otherwise. 88 bool emitPopSpecialFixUp(MachineBasicBlock &MBB, bool DoIt) const; 89 }; 90 91 } // End llvm namespace 92 93 #endif 94