LLVM 20.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
21namespace llvm {
22 class Triple;
23
24class X86RegisterInfo final : public X86GenRegisterInfo {
25private:
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
51public:
52 explicit X86RegisterInfo(const Triple &TT);
53
54 /// Return the number of registers for the function.
55 unsigned getNumSupportedRegs(const MachineFunction &MF) const override;
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.
63 unsigned Idx) const override;
64
67 unsigned Idx) const override;
68
71 const MachineFunction &MF) const override;
72
74 unsigned DefSubReg,
75 const TargetRegisterClass *SrcRC,
76 unsigned SrcSubReg) const override;
77
78 /// getPointerRegClass - Returns a TargetRegisterClass used for pointer
79 /// values.
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.
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.
93 getGPRsForTailCall(const MachineFunction &MF) const;
94
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 /// getIPRACSRegs - This API can be removed when rbp is safe to optimized out
103 /// when IPRA is on.
104 const MCPhysReg *getIPRACSRegs(const MachineFunction *MF) const override;
105 const MCPhysReg *
108 CallingConv::ID) const override;
109 const uint32_t *getNoPreservedMask() const override;
110
111 // Calls involved in thread-local variable lookup save more registers than
112 // normal calls, so they need a different mask to represent this.
114
115 /// getReservedRegs - Returns a bitset indexed by physical register number
116 /// indicating if a register is a special register that has particular uses and
117 /// should be considered unavailable at all times, e.g. SP, RA. This is used by
118 /// register scavenger to determine what registers are free.
119 BitVector getReservedRegs(const MachineFunction &MF) const override;
120
121 /// isArgumentReg - Returns true if Reg can be used as an argument to a
122 /// function.
123 bool isArgumentRegister(const MachineFunction &MF,
124 MCRegister Reg) const override;
125
126 /// Return true if it is tile register class.
127 bool isTileRegisterClass(const TargetRegisterClass *RC) const;
128
129 /// Returns true if PhysReg is a fixed register.
130 bool isFixedRegister(const MachineFunction &MF,
131 MCRegister PhysReg) const override;
132
133 void adjustStackMapLiveOutMask(uint32_t *Mask) const override;
134
135 bool hasBasePointer(const MachineFunction &MF) const;
136
137 bool canRealignStack(const MachineFunction &MF) const override;
138
139 bool shouldRealignStack(const MachineFunction &MF) const override;
140
142 unsigned FIOperandNum, Register BaseReg,
143 int FIOffset) const;
144
146 int SPAdj, unsigned FIOperandNum,
147 RegScavenger *RS = nullptr) const override;
148
149 /// Process frame indices in forwards block order because
150 /// X86InstrInfo::getSPAdjust relies on it when searching for the
151 /// ADJCALLSTACKUP pseudo following a call.
152 /// TODO: Fix this and return true like all other targets.
153 bool eliminateFrameIndicesBackwards() const override { return false; }
154
155 /// findDeadCallerSavedReg - Return a caller-saved register that isn't live
156 /// when it reaches the "return" instruction. We can then pop a stack object
157 /// to this register without worry about clobbering it.
160
161 // Debug information queries.
162 Register getFrameRegister(const MachineFunction &MF) const override;
163 unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const;
164 unsigned getPtrSizedStackRegister(const MachineFunction &MF) const;
165 Register getStackRegister() const { return StackPtr; }
166 Register getBaseRegister() const { return BasePtr; }
167 /// Returns physical register used as frame pointer.
168 /// This will always returns the frame pointer register, contrary to
169 /// getFrameRegister() which returns the "base pointer" in situations
170 /// involving a stack, frame and base pointer.
171 Register getFramePtr() const { return FramePtr; }
172 // FIXME: Move to FrameInfok
173 unsigned getSlotSize() const { return SlotSize; }
174
177 const MachineFunction &MF, const VirtRegMap *VRM,
178 const LiveRegMatrix *Matrix) const override;
179};
180
181} // End llvm namespace
182
183#endif
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
IRTranslator LLVM IR MI
Live Register Matrix
unsigned Reg
uint64_t IntrinsicInst * II
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
getPointerRegClass - Returns a TargetRegisterClass used for pointer values.
unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const
bool hasBasePointer(const MachineFunction &MF) const
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
const TargetRegisterClass * getGPRsForTailCall(const MachineFunction &MF) const
getGPRsForTailCall - Returns a register class with registers that can be used in forming tail calls.
bool canRealignStack(const MachineFunction &MF) const override
BitVector getReservedRegs(const MachineFunction &MF) const override
getReservedRegs - Returns a bitset indexed by physical register number indicating if a register is a ...
bool shouldRealignStack(const MachineFunction &MF) const override
unsigned getNumSupportedRegs(const MachineFunction &MF) const override
Return the number of registers for the function.
const MCPhysReg * getIPRACSRegs(const MachineFunction *MF) const override
getIPRACSRegs - This API can be removed when rbp is safe to optimized out when IPRA is on.
Register getFrameRegister(const MachineFunction &MF) const override
unsigned findDeadCallerSavedReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI) const
findDeadCallerSavedReg - Return a caller-saved register that isn't live when it reaches the "return" ...
const uint32_t * getDarwinTLSCallPreservedMask() const
bool isTileRegisterClass(const TargetRegisterClass *RC) const
Return true if it is tile register class.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
bool isArgumentRegister(const MachineFunction &MF, MCRegister Reg) const override
isArgumentReg - Returns true if Reg can be used as an argument to a function.
Register getStackRegister() const
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
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 ...
unsigned getSlotSize() const
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
unsigned getPtrSizedStackRegister(const MachineFunction &MF) const
bool shouldRewriteCopySrc(const TargetRegisterClass *DefRC, unsigned DefSubReg, const TargetRegisterClass *SrcRC, unsigned SrcSubReg) const override
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
getCrossCopyRegClass - Returns a legal register class to copy a register in the specified class to or...
Register getFramePtr() const
Returns physical register used as frame pointer.
Register getBaseRegister() const
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallVectorImpl< MCPhysReg > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
void eliminateFrameIndex(MachineBasicBlock::iterator II, unsigned FIOperandNum, Register BaseReg, int FIOffset) const
const uint32_t * getNoPreservedMask() const override
bool isFixedRegister(const MachineFunction &MF, MCRegister PhysReg) const override
Returns true if PhysReg is a fixed register.
const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const override
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
getCalleeSavedRegs - Return a null-terminated list of all of the callee-save registers on this target...
void adjustStackMapLiveOutMask(uint32_t *Mask) const override
bool eliminateFrameIndicesBackwards() const override
Process frame indices in forwards block order because X86InstrInfo::getSPAdjust relies on it when sea...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18