ARMFrameLowering.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 hasReservedCallFrame(const MachineFunction &MF) const override;
  38. bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
  39. StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
  40. Register &FrameReg) const override;
  41. int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
  42. Register &FrameReg, int SPAdj) const;
  43. void getCalleeSaves(const MachineFunction &MF,
  44. BitVector &SavedRegs) const override;
  45. void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
  46. RegScavenger *RS) const override;
  47. void adjustForSegmentedStacks(MachineFunction &MF,
  48. MachineBasicBlock &MBB) const override;
  49. /// Returns true if the target will correctly handle shrink wrapping.
  50. bool enableShrinkWrapping(const MachineFunction &MF) const override;
  51. bool isProfitableForNoCSROpt(const Function &F) const override {
  52. // The no-CSR optimisation is bad for code size on ARM, because we can save
  53. // many registers with a single PUSH/POP pair.
  54. return false;
  55. }
  56. bool
  57. assignCalleeSavedSpillSlots(MachineFunction &MF,
  58. const TargetRegisterInfo *TRI,
  59. std::vector<CalleeSavedInfo> &CSI) const override;
  60. const SpillSlot *
  61. getCalleeSavedSpillSlots(unsigned &NumEntries) const override;
  62. private:
  63. void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
  64. ArrayRef<CalleeSavedInfo> CSI, unsigned StmOpc,
  65. unsigned StrOpc, bool NoGap, bool (*Func)(unsigned, bool),
  66. unsigned NumAlignedDPRCS2Regs, unsigned MIFlags = 0) const;
  67. void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
  68. MutableArrayRef<CalleeSavedInfo> CSI, unsigned LdmOpc,
  69. unsigned LdrOpc, bool isVarArg, bool NoGap,
  70. bool (*Func)(unsigned, bool),
  71. unsigned NumAlignedDPRCS2Regs) const;
  72. MachineBasicBlock::iterator
  73. eliminateCallFramePseudoInstr(MachineFunction &MF,
  74. MachineBasicBlock &MBB,
  75. MachineBasicBlock::iterator MI) const override;
  76. };
  77. } // end namespace llvm
  78. #endif // LLVM_LIB_TARGET_ARM_ARMFRAMELOWERING_H