AArch64RegisterInfo.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //==- AArch64RegisterInfo.h - AArch64 Register Information Impl --*- 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. //
  9. // This file contains the AArch64 implementation of the MRegisterInfo class.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERINFO_H
  13. #define LLVM_LIB_TARGET_AARCH64_AARCH64REGISTERINFO_H
  14. #define GET_REGINFO_HEADER
  15. #include "AArch64GenRegisterInfo.inc"
  16. namespace llvm {
  17. class MachineFunction;
  18. class RegScavenger;
  19. class TargetRegisterClass;
  20. class Triple;
  21. class AArch64RegisterInfo final : public AArch64GenRegisterInfo {
  22. const Triple &TT;
  23. public:
  24. AArch64RegisterInfo(const Triple &TT);
  25. // FIXME: This should be tablegen'd like getDwarfRegNum is
  26. int getSEHRegNum(unsigned i) const {
  27. return getEncodingValue(i);
  28. }
  29. bool isReservedReg(const MachineFunction &MF, MCRegister Reg) const;
  30. bool isStrictlyReservedReg(const MachineFunction &MF, MCRegister Reg) const;
  31. bool isAnyArgRegReserved(const MachineFunction &MF) const;
  32. void emitReservedArgRegCallError(const MachineFunction &MF) const;
  33. void UpdateCustomCalleeSavedRegs(MachineFunction &MF) const;
  34. void UpdateCustomCallPreservedMask(MachineFunction &MF,
  35. const uint32_t **Mask) const;
  36. /// Code Generation virtual methods...
  37. const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
  38. const MCPhysReg *getDarwinCalleeSavedRegs(const MachineFunction *MF) const;
  39. const MCPhysReg *
  40. getCalleeSavedRegsViaCopy(const MachineFunction *MF) const;
  41. const uint32_t *getCallPreservedMask(const MachineFunction &MF,
  42. CallingConv::ID) const override;
  43. const uint32_t *getDarwinCallPreservedMask(const MachineFunction &MF,
  44. CallingConv::ID) const;
  45. unsigned getCSRFirstUseCost() const override {
  46. // The cost will be compared against BlockFrequency where entry has the
  47. // value of 1 << 14. A value of 5 will choose to spill or split really
  48. // cold path instead of using a callee-saved register.
  49. return 5;
  50. }
  51. const TargetRegisterClass *
  52. getSubClassWithSubReg(const TargetRegisterClass *RC,
  53. unsigned Idx) const override;
  54. // Calls involved in thread-local variable lookup save more registers than
  55. // normal calls, so they need a different mask to represent this.
  56. const uint32_t *getTLSCallPreservedMask() const;
  57. const uint32_t *getSMStartStopCallPreservedMask() const;
  58. const uint32_t *SMEABISupportRoutinesCallPreservedMaskFromX0() const;
  59. // Funclets on ARM64 Windows don't preserve any registers.
  60. const uint32_t *getNoPreservedMask() const override;
  61. // Unwinders may not preserve all Neon and SVE registers.
  62. const uint32_t *
  63. getCustomEHPadPreservedMask(const MachineFunction &MF) const override;
  64. /// getThisReturnPreservedMask - Returns a call preserved mask specific to the
  65. /// case that 'returned' is on an i64 first argument if the calling convention
  66. /// is one that can (partially) model this attribute with a preserved mask
  67. /// (i.e. it is a calling convention that uses the same register for the first
  68. /// i64 argument and an i64 return value)
  69. ///
  70. /// Should return NULL in the case that the calling convention does not have
  71. /// this property
  72. const uint32_t *getThisReturnPreservedMask(const MachineFunction &MF,
  73. CallingConv::ID) const;
  74. /// Stack probing calls preserve different CSRs to the normal CC.
  75. const uint32_t *getWindowsStackProbePreservedMask() const;
  76. BitVector getStrictlyReservedRegs(const MachineFunction &MF) const;
  77. BitVector getReservedRegs(const MachineFunction &MF) const override;
  78. std::optional<std::string>
  79. explainReservedReg(const MachineFunction &MF,
  80. MCRegister PhysReg) const override;
  81. bool isAsmClobberable(const MachineFunction &MF,
  82. MCRegister PhysReg) const override;
  83. const TargetRegisterClass *
  84. getPointerRegClass(const MachineFunction &MF,
  85. unsigned Kind = 0) const override;
  86. const TargetRegisterClass *
  87. getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
  88. bool requiresRegisterScavenging(const MachineFunction &MF) const override;
  89. bool useFPForScavengingIndex(const MachineFunction &MF) const override;
  90. bool requiresFrameIndexScavenging(const MachineFunction &MF) const override;
  91. bool needsFrameBaseReg(MachineInstr *MI, int64_t Offset) const override;
  92. bool isFrameOffsetLegal(const MachineInstr *MI, Register BaseReg,
  93. int64_t Offset) const override;
  94. Register materializeFrameBaseRegister(MachineBasicBlock *MBB, int FrameIdx,
  95. int64_t Offset) const override;
  96. void resolveFrameIndex(MachineInstr &MI, Register BaseReg,
  97. int64_t Offset) const override;
  98. bool eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
  99. unsigned FIOperandNum,
  100. RegScavenger *RS = nullptr) const override;
  101. bool cannotEliminateFrame(const MachineFunction &MF) const;
  102. bool requiresVirtualBaseRegisters(const MachineFunction &MF) const override;
  103. bool hasBasePointer(const MachineFunction &MF) const;
  104. unsigned getBaseRegister() const;
  105. bool isArgumentRegister(const MachineFunction &MF,
  106. MCRegister Reg) const override;
  107. // Debug information queries.
  108. Register getFrameRegister(const MachineFunction &MF) const override;
  109. unsigned getRegPressureLimit(const TargetRegisterClass *RC,
  110. MachineFunction &MF) const override;
  111. unsigned getLocalAddressRegister(const MachineFunction &MF) const;
  112. bool regNeedsCFI(unsigned Reg, unsigned &RegToUseForCFI) const;
  113. /// SrcRC and DstRC will be morphed into NewRC if this returns true
  114. bool shouldCoalesce(MachineInstr *MI, const TargetRegisterClass *SrcRC,
  115. unsigned SubReg, const TargetRegisterClass *DstRC,
  116. unsigned DstSubReg, const TargetRegisterClass *NewRC,
  117. LiveIntervals &LIS) const override;
  118. void getOffsetOpcodes(const StackOffset &Offset,
  119. SmallVectorImpl<uint64_t> &Ops) const override;
  120. };
  121. } // end namespace llvm
  122. #endif