X86RegisterInfo.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //===-- X86RegisterInfo.h - X86 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 X86 implementation of the TargetRegisterInfo class.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_X86_X86REGISTERINFO_H
  13. #define LLVM_LIB_TARGET_X86_X86REGISTERINFO_H
  14. #include "llvm/CodeGen/TargetRegisterInfo.h"
  15. #define GET_REGINFO_HEADER
  16. #include "X86GenRegisterInfo.inc"
  17. namespace llvm {
  18. class Triple;
  19. class X86RegisterInfo final : public X86GenRegisterInfo {
  20. private:
  21. /// Is64Bit - Is the target 64-bits.
  22. ///
  23. bool Is64Bit;
  24. /// IsWin64 - Is the target on of win64 flavours
  25. ///
  26. bool IsWin64;
  27. /// SlotSize - Stack slot size in bytes.
  28. ///
  29. unsigned SlotSize;
  30. /// StackPtr - X86 physical register used as stack ptr.
  31. ///
  32. unsigned StackPtr;
  33. /// FramePtr - X86 physical register used as frame ptr.
  34. ///
  35. unsigned FramePtr;
  36. /// BasePtr - X86 physical register used as a base ptr in complex stack
  37. /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
  38. /// variable size stack objects.
  39. unsigned BasePtr;
  40. public:
  41. explicit X86RegisterInfo(const Triple &TT);
  42. // FIXME: This should be tablegen'd like getDwarfRegNum is
  43. int getSEHRegNum(unsigned i) const;
  44. /// getMatchingSuperRegClass - Return a subclass of the specified register
  45. /// class A so that each register in it has a sub-register of the
  46. /// specified sub-register index which is in the specified register class B.
  47. const TargetRegisterClass *
  48. getMatchingSuperRegClass(const TargetRegisterClass *A,
  49. const TargetRegisterClass *B,
  50. unsigned Idx) const override;
  51. const TargetRegisterClass *
  52. getSubClassWithSubReg(const TargetRegisterClass *RC,
  53. unsigned Idx) const override;
  54. const TargetRegisterClass *
  55. getLargestLegalSuperClass(const TargetRegisterClass *RC,
  56. const MachineFunction &MF) const override;
  57. bool shouldRewriteCopySrc(const TargetRegisterClass *DefRC,
  58. unsigned DefSubReg,
  59. const TargetRegisterClass *SrcRC,
  60. unsigned SrcSubReg) const override;
  61. /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
  62. /// values.
  63. const TargetRegisterClass *
  64. getPointerRegClass(const MachineFunction &MF,
  65. unsigned Kind = 0) const override;
  66. /// getCrossCopyRegClass - Returns a legal register class to copy a register
  67. /// in the specified class to or from. Returns NULL if it is possible to copy
  68. /// between a two registers of the specified class.
  69. const TargetRegisterClass *
  70. getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
  71. /// getGPRsForTailCall - Returns a register class with registers that can be
  72. /// used in forming tail calls.
  73. const TargetRegisterClass *
  74. getGPRsForTailCall(const MachineFunction &MF) const;
  75. unsigned getRegPressureLimit(const TargetRegisterClass *RC,
  76. MachineFunction &MF) const override;
  77. /// getCalleeSavedRegs - Return a null-terminated list of all of the
  78. /// callee-save registers on this target.
  79. const MCPhysReg *
  80. getCalleeSavedRegs(const MachineFunction* MF) const override;
  81. const MCPhysReg *
  82. getCalleeSavedRegsViaCopy(const MachineFunction *MF) const;
  83. const uint32_t *getCallPreservedMask(const MachineFunction &MF,
  84. CallingConv::ID) const override;
  85. const uint32_t *getNoPreservedMask() const override;
  86. // Calls involved in thread-local variable lookup save more registers than
  87. // normal calls, so they need a different mask to represent this.
  88. const uint32_t *getDarwinTLSCallPreservedMask() const;
  89. /// getReservedRegs - Returns a bitset indexed by physical register number
  90. /// indicating if a register is a special register that has particular uses and
  91. /// should be considered unavailable at all times, e.g. SP, RA. This is used by
  92. /// register scavenger to determine what registers are free.
  93. BitVector getReservedRegs(const MachineFunction &MF) const override;
  94. /// isArgumentReg - Returns true if Reg can be used as an argument to a
  95. /// function.
  96. bool isArgumentRegister(const MachineFunction &MF,
  97. MCRegister Reg) const override;
  98. /// Return true if it is tile register class.
  99. bool isTileRegisterClass(const TargetRegisterClass *RC) const;
  100. /// Returns true if PhysReg is a fixed register.
  101. bool isFixedRegister(const MachineFunction &MF,
  102. MCRegister PhysReg) const override;
  103. void adjustStackMapLiveOutMask(uint32_t *Mask) const override;
  104. bool hasBasePointer(const MachineFunction &MF) const;
  105. bool canRealignStack(const MachineFunction &MF) const override;
  106. bool eliminateFrameIndex(MachineBasicBlock::iterator MI,
  107. int SPAdj, unsigned FIOperandNum,
  108. RegScavenger *RS = nullptr) const override;
  109. /// findDeadCallerSavedReg - Return a caller-saved register that isn't live
  110. /// when it reaches the "return" instruction. We can then pop a stack object
  111. /// to this register without worry about clobbering it.
  112. unsigned findDeadCallerSavedReg(MachineBasicBlock &MBB,
  113. MachineBasicBlock::iterator &MBBI) const;
  114. // Debug information queries.
  115. Register getFrameRegister(const MachineFunction &MF) const override;
  116. unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const;
  117. unsigned getPtrSizedStackRegister(const MachineFunction &MF) const;
  118. Register getStackRegister() const { return StackPtr; }
  119. Register getBaseRegister() const { return BasePtr; }
  120. /// Returns physical register used as frame pointer.
  121. /// This will always returns the frame pointer register, contrary to
  122. /// getFrameRegister() which returns the "base pointer" in situations
  123. /// involving a stack, frame and base pointer.
  124. Register getFramePtr() const { return FramePtr; }
  125. // FIXME: Move to FrameInfok
  126. unsigned getSlotSize() const { return SlotSize; }
  127. bool getRegAllocationHints(Register VirtReg, ArrayRef<MCPhysReg> Order,
  128. SmallVectorImpl<MCPhysReg> &Hints,
  129. const MachineFunction &MF, const VirtRegMap *VRM,
  130. const LiveRegMatrix *Matrix) const override;
  131. };
  132. } // End llvm namespace
  133. #endif