ARMFrameLowering.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //===- ARMTargetFrameLowering.h - Define frame lowering for ARM -*- 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_ARMFRAMELOWERING_H
  9. #define LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H
  10. #include "llvm/CodeGen/TargetFrameLowering.h"
  11. #include "llvm/Support/TypeSize.h"
  12. namespace llvm {
  13. class ARMSubtarget;
  14. class CalleeSavedInfo;
  15. class MachineFunction;
  16. class ARMFrameLowering : public TargetFrameLowering {
  17. protected:
  18. const ARMSubtarget &STI;
  19. public:
  20. explicit ARMFrameLowering(const ARMSubtarget &sti);
  21. /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
  22. /// the function.
  23. void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
  24. void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
  25. bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
  26. MachineBasicBlock::iterator MI,
  27. ArrayRef<CalleeSavedInfo> CSI,
  28. const TargetRegisterInfo *TRI) const override;
  29. bool
  30. restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
  31. MachineBasicBlock::iterator MI,
  32. MutableArrayRef<CalleeSavedInfo> CSI,
  33. const TargetRegisterInfo *TRI) const override;
  34. bool keepFramePointer(const MachineFunction &MF) const override;
  35. bool enableCalleeSaveSkip(const MachineFunction &MF) const override;
  36. bool hasFP(const MachineFunction &MF) const override;
  37. bool isFPReserved(const MachineFunction &MF) const;
  38. bool hasReservedCallFrame(const MachineFunction &MF) const override;
  39. bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
  40. StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
  41. Register &FrameReg) const override;
  42. int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
  43. Register &FrameReg, int SPAdj) const;
  44. void getCalleeSaves(const MachineFunction &MF,
  45. BitVector &SavedRegs) const override;
  46. void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
  47. RegScavenger *RS) const override;
  48. void adjustForSegmentedStacks(MachineFunction &MF,
  49. MachineBasicBlock &MBB) const override;
  50. /// Returns true if the target will correctly handle shrink wrapping.
  51. bool enableShrinkWrapping(const MachineFunction &MF) const override;
  52. bool isProfitableForNoCSROpt(const Function &F) const override {
  53. // The no-CSR optimisation is bad for code size on ARM, because we can save
  54. // many registers with a single PUSH/POP pair.
  55. return false;
  56. }
  57. bool
  58. assignCalleeSavedSpillSlots(MachineFunction &MF,
  59. const TargetRegisterInfo *TRI,
  60. std::vector<CalleeSavedInfo> &CSI) const override;
  61. const SpillSlot *
  62. getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
  63. private:
  64. void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
  65. ArrayRef<CalleeSavedInfo> CSI, unsigned StmOpc,
  66. unsigned StrOpc, bool NoGap, bool (*Func)(unsigned, bool),
  67. unsigned NumAlignedDPRCS2Regs, unsigned MIFlags = 0) const;
  68. void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
  69. MutableArrayRef<CalleeSavedInfo> CSI, unsigned LdmOpc,
  70. unsigned LdrOpc, bool isVarArg, bool NoGap,
  71. bool (*Func)(unsigned, bool),
  72. unsigned NumAlignedDPRCS2Regs) const;
  73. MachineBasicBlock::iterator
  74. eliminateCallFramePseudoInstr(MachineFunction &MF,
  75. MachineBasicBlock &MBB,
  76. MachineBasicBlock::iterator MI) const override;
  77. };
  78. } // end namespace llvm
  79. #endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H