Thumb1FrameLowering.h 3.5 KB

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