LLVM  14.0.0git
X86RegisterInfo.h
Go to the documentation of this file.
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 
13 #ifndef LLVM_LIB_TARGET_X86_X86REGISTERINFO_H
14 #define LLVM_LIB_TARGET_X86_X86REGISTERINFO_H
15 
17 
18 #define GET_REGINFO_HEADER
19 #include "X86GenRegisterInfo.inc"
20 
21 namespace llvm {
22  class Triple;
23 
24 class X86RegisterInfo final : public X86GenRegisterInfo {
25 private:
26  /// Is64Bit - Is the target 64-bits.
27  ///
28  bool Is64Bit;
29 
30  /// IsWin64 - Is the target on of win64 flavours
31  ///
32  bool IsWin64;
33 
34  /// SlotSize - Stack slot size in bytes.
35  ///
36  unsigned SlotSize;
37 
38  /// StackPtr - X86 physical register used as stack ptr.
39  ///
40  unsigned StackPtr;
41 
42  /// FramePtr - X86 physical register used as frame ptr.
43  ///
44  unsigned FramePtr;
45 
46  /// BasePtr - X86 physical register used as a base ptr in complex stack
47  /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
48  /// variable size stack objects.
49  unsigned BasePtr;
50 
51 public:
52  explicit X86RegisterInfo(const Triple &TT);
53 
54  // FIXME: This should be tablegen'd like getDwarfRegNum is
55  int getSEHRegNum(unsigned i) const;
56 
57  /// getMatchingSuperRegClass - Return a subclass of the specified register
58  /// class A so that each register in it has a sub-register of the
59  /// specified sub-register index which is in the specified register class B.
60  const TargetRegisterClass *
62  const TargetRegisterClass *B,
63  unsigned Idx) const override;
64 
65  const TargetRegisterClass *
67  unsigned Idx) const override;
68 
69  const TargetRegisterClass *
71  const MachineFunction &MF) const override;
72 
73  bool shouldRewriteCopySrc(const TargetRegisterClass *DefRC,
74  unsigned DefSubReg,
75  const TargetRegisterClass *SrcRC,
76  unsigned SrcSubReg) const override;
77 
78  /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
79  /// values.
80  const TargetRegisterClass *
82  unsigned Kind = 0) const override;
83 
84  /// getCrossCopyRegClass - Returns a legal register class to copy a register
85  /// in the specified class to or from. Returns NULL if it is possible to copy
86  /// between a two registers of the specified class.
87  const TargetRegisterClass *
88  getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
89 
90  /// getGPRsForTailCall - Returns a register class with registers that can be
91  /// used in forming tail calls.
92  const TargetRegisterClass *
93  getGPRsForTailCall(const MachineFunction &MF) const;
94 
95  unsigned getRegPressureLimit(const TargetRegisterClass *RC,
96  MachineFunction &MF) const override;
97 
98  /// getCalleeSavedRegs - Return a null-terminated list of all of the
99  /// callee-save registers on this target.
100  const MCPhysReg *
101  getCalleeSavedRegs(const MachineFunction* MF) const override;
102  const MCPhysReg *
105  CallingConv::ID) const override;
106  const uint32_t *getNoPreservedMask() const override;
107 
108  // Calls involved in thread-local variable lookup save more registers than
109  // normal calls, so they need a different mask to represent this.
111 
112  /// getReservedRegs - Returns a bitset indexed by physical register number
113  /// indicating if a register is a special register that has particular uses and
114  /// should be considered unavailable at all times, e.g. SP, RA. This is used by
115  /// register scavenger to determine what registers are free.
116  BitVector getReservedRegs(const MachineFunction &MF) const override;
117 
118  void adjustStackMapLiveOutMask(uint32_t *Mask) const override;
119 
120  bool hasBasePointer(const MachineFunction &MF) const;
121 
122  bool canRealignStack(const MachineFunction &MF) const override;
123 
125  int SPAdj, unsigned FIOperandNum,
126  RegScavenger *RS = nullptr) const override;
127 
128  /// findDeadCallerSavedReg - Return a caller-saved register that isn't live
129  /// when it reaches the "return" instruction. We can then pop a stack object
130  /// to this register without worry about clobbering it.
133 
134  // Debug information queries.
135  Register getFrameRegister(const MachineFunction &MF) const override;
136  unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const;
137  unsigned getPtrSizedStackRegister(const MachineFunction &MF) const;
138  Register getStackRegister() const { return StackPtr; }
139  Register getBaseRegister() const { return BasePtr; }
140  /// Returns physical register used as frame pointer.
141  /// This will always returns the frame pointer register, contrary to
142  /// getFrameRegister() which returns the "base pointer" in situations
143  /// involving a stack, frame and base pointer.
144  Register getFramePtr() const { return FramePtr; }
145  // FIXME: Move to FrameInfok
146  unsigned getSlotSize() const { return SlotSize; }
147 
150  const MachineFunction &MF, const VirtRegMap *VRM,
151  const LiveRegMatrix *Matrix) const override;
152 };
153 
154 } // End llvm namespace
155 
156 #endif
i
i
Definition: README.txt:29
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:105
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::VirtRegMap
Definition: VirtRegMap.h:33
llvm::X86RegisterInfo::getFrameRegister
Register getFrameRegister(const MachineFunction &MF) const override
Definition: X86RegisterInfo.cpp:852
llvm::X86RegisterInfo::getRegPressureLimit
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
Definition: X86RegisterInfo.cpp:256
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::X86RegisterInfo::eliminateFrameIndex
void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
Definition: X86RegisterInfo.cpp:724
llvm::X86RegisterInfo::getCalleeSavedRegsViaCopy
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
Definition: X86RegisterInfo.cpp:404
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::X86RegisterInfo::getGPRsForTailCall
const TargetRegisterClass * getGPRsForTailCall(const MachineFunction &MF) const
getGPRsForTailCall - Returns a register class with registers that can be used in forming tail calls.
Definition: X86RegisterInfo.cpp:231
llvm::X86RegisterInfo::getDarwinTLSCallPreservedMask
const uint32_t * getDarwinTLSCallPreservedMask() const
Definition: X86RegisterInfo.cpp:525
X86GenRegisterInfo
llvm::X86RegisterInfo::getLargestLegalSuperClass
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
Definition: X86RegisterInfo.cpp:108
llvm::X86RegisterInfo::getNoPreservedMask
const uint32_t * getNoPreservedMask() const override
Definition: X86RegisterInfo.cpp:521
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:46
llvm::X86RegisterInfo::getFramePtr
Register getFramePtr() const
Returns physical register used as frame pointer.
Definition: X86RegisterInfo.h:144
llvm::X86RegisterInfo::getBaseRegister
Register getBaseRegister() const
Definition: X86RegisterInfo.h:139
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::X86RegisterInfo::shouldRewriteCopySrc
bool shouldRewriteCopySrc(const TargetRegisterClass *DefRC, unsigned DefSubReg, const TargetRegisterClass *SrcRC, unsigned SrcSubReg) const override
Definition: X86RegisterInfo.cpp:215
llvm::BitVector
Definition: BitVector.h:74
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::X86RegisterInfo::getRegAllocationHints
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
Definition: X86RegisterInfo.cpp:910
llvm::X86RegisterInfo::getSubClassWithSubReg
const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const override
Definition: X86RegisterInfo.cpp:83
llvm::X86RegisterInfo::getPtrSizedFrameRegister
unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const
Definition: X86RegisterInfo.cpp:858
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::X86RegisterInfo::X86RegisterInfo
X86RegisterInfo(const Triple &TT)
Definition: X86RegisterInfo.cpp:46
llvm::X86RegisterInfo::getCallPreservedMask
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
Definition: X86RegisterInfo.cpp:414
llvm::MachineFunction
Definition: MachineFunction.h:234
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
MBBI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Definition: AArch64SLSHardening.cpp:75
llvm::X86RegisterInfo::adjustStackMapLiveOutMask
void adjustStackMapLiveOutMask(uint32_t *Mask) const override
Definition: X86RegisterInfo.cpp:621
uint32_t
llvm::X86RegisterInfo::getMatchingSuperRegClass
const TargetRegisterClass * getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned Idx) const override
getMatchingSuperRegClass - Return a subclass of the specified register class A so that each register ...
Definition: X86RegisterInfo.cpp:95
llvm::X86RegisterInfo::canRealignStack
bool canRealignStack(const MachineFunction &MF) const override
Definition: X86RegisterInfo.cpp:664
llvm::X86RegisterInfo::getSEHRegNum
int getSEHRegNum(unsigned i) const
Definition: X86RegisterInfo.cpp:78
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
uint16_t
llvm::X86RegisterInfo::getCalleeSavedRegs
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
getCalleeSavedRegs - Return a null-terminated list of all of the callee-save registers on this target...
Definition: X86RegisterInfo.cpp:276
llvm::X86RegisterInfo::findDeadCallerSavedReg
unsigned findDeadCallerSavedReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI) const
findDeadCallerSavedReg - Return a caller-saved register that isn't live when it reaches the "return" ...
Definition: X86RegisterInfo.cpp:803
llvm::X86RegisterInfo::hasBasePointer
bool hasBasePointer(const MachineFunction &MF) const
Definition: X86RegisterInfo.cpp:645
llvm::X86RegisterInfo::getCrossCopyRegClass
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
getCrossCopyRegClass - Returns a legal register class to copy a register in the specified class to or...
Definition: X86RegisterInfo.cpp:245
llvm::X86RegisterInfo::getSlotSize
unsigned getSlotSize() const
Definition: X86RegisterInfo.h:146
llvm::SmallVectorImpl< MCPhysReg >
llvm::X86RegisterInfo::getReservedRegs
BitVector getReservedRegs(const MachineFunction &MF) const override
getReservedRegs - Returns a bitset indexed by physical register number indicating if a register is a ...
Definition: X86RegisterInfo.cpp:529
llvm::X86RegisterInfo::getStackRegister
Register getStackRegister() const
Definition: X86RegisterInfo.h:138
llvm::MachineInstrBundleIterator< MachineInstr >
TargetRegisterInfo.h
llvm::X86RegisterInfo::getPtrSizedStackRegister
unsigned getPtrSizedStackRegister(const MachineFunction &MF) const
Definition: X86RegisterInfo.cpp:867
llvm::X86RegisterInfo::getPointerRegClass
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
getPointerRegClass - Returns a TargetRegisterClass used for pointer values.
Definition: X86RegisterInfo.cpp:175
llvm::X86RegisterInfo
Definition: X86RegisterInfo.h:24
llvm::LiveRegMatrix
Definition: LiveRegMatrix.h:40