LLVM 24.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
19
20#define GET_REGINFO_HEADER
21#include "X86GenRegisterInfo.inc"
22
23namespace llvm {
24 class Triple;
25
26class X86RegisterInfo final : public X86GenRegisterInfo {
27private:
28 /// Is64Bit - Is the target 64-bits.
29 ///
30 bool Is64Bit;
31
32 /// IsWin64 - Is the target on of win64 flavours
33 ///
34 bool IsWin64;
35
36 /// IsUEFI64 - Is UEFI 64 bit target.
37 ///
38 bool IsUEFI64;
39
40 /// SlotSize - Stack slot size in bytes.
41 ///
42 unsigned SlotSize;
43
44 /// StackPtr - X86 physical register used as stack ptr.
45 ///
46 unsigned StackPtr;
47
48 /// FramePtr - X86 physical register used as frame ptr.
49 ///
50 unsigned FramePtr;
51
52 /// BasePtr - X86 physical register used as a base ptr in complex stack
53 /// frames. I.e., when we need a 3rd base, not just SP and FP, due to
54 /// variable size stack objects.
55 unsigned BasePtr;
56
57public:
58 explicit X86RegisterInfo(const Triple &TT);
59
60 /// Return the number of registers for the function.
61 unsigned getNumSupportedRegs(const MachineFunction &MF) const override;
62
63 /// getMatchingSuperRegClass - Return a subclass of the specified register
64 /// class A so that each register in it has a sub-register of the
65 /// specified sub-register index which is in the specified register class B.
69 unsigned Idx) const override;
70
73 unsigned Idx) const override;
74
77 const MachineFunction &MF) const override;
78
79 /// getCrossCopyRegClass - Returns a legal register class to copy a register
80 /// in the specified class to or from. Returns NULL if it is possible to copy
81 /// between a two registers of the specified class.
83 getCrossCopyRegClass(const TargetRegisterClass *RC) const override;
84
86 MachineFunction &MF) const override;
87
88 /// getCalleeSavedRegs - Return a null-terminated list of all of the
89 /// callee-save registers on this target.
90 const MCPhysReg *
91 getCalleeSavedRegs(const MachineFunction* MF) const override;
92 /// getIPRACSRegs - This API can be removed when rbp is safe to optimized out
93 /// when IPRA is on.
94 const MCPhysReg *getIPRACSRegs(const MachineFunction *MF) const override;
95 const MCPhysReg *
98 CallingConv::ID) const override;
99 const uint32_t *getNoPreservedMask() const override;
100
101 // Calls involved in thread-local variable lookup save more registers than
102 // normal calls, so they need a different mask to represent this.
104
105 /// getReservedRegs - Returns a bitset indexed by physical register number
106 /// indicating if a register is a special register that has particular uses and
107 /// should be considered unavailable at all times, e.g. SP, RA. This is used by
108 /// register scavenger to determine what registers are free.
109 BitVector getReservedRegs(const MachineFunction &MF) const override;
110
111 /// isArgumentReg - Returns true if Reg can be used as an argument to a
112 /// function.
113 bool isArgumentRegister(const MachineFunction &MF,
114 MCRegister Reg) const override;
115
116 /// Return true if it is tile register class.
117 bool isTileRegisterClass(const TargetRegisterClass *RC) const;
118
119 /// Returns true if PhysReg is a fixed register.
120 bool isFixedRegister(const MachineFunction &MF,
121 MCRegister PhysReg) const override;
122
123 void adjustStackMapLiveOutMask(uint32_t *Mask) const override;
124
125 bool hasBasePointer(const MachineFunction &MF) const;
126
127 bool canRealignStack(const MachineFunction &MF) const override;
128
129 bool shouldRealignStack(const MachineFunction &MF) const override;
130
132 unsigned FIOperandNum, Register BaseReg,
133 int FIOffset) const;
134
136 int SPAdj, unsigned FIOperandNum,
137 RegScavenger *RS = nullptr) const override;
138
139 /// Process frame indices in forwards block order because
140 /// X86InstrInfo::getSPAdjust relies on it when searching for the
141 /// ADJCALLSTACKUP pseudo following a call.
142 /// TODO: Fix this and return true like all other targets.
143 bool eliminateFrameIndicesBackwards() const override { return false; }
144
145 /// findDeadCallerSavedReg - Return a caller-saved register that isn't live
146 /// when it reaches the "return" instruction. We can then pop a stack object
147 /// to this register without worry about clobbering it.
150
151 // Debug information queries.
152 Register getFrameRegister(const MachineFunction &MF) const override;
155 Register getStackRegister() const { return StackPtr; }
156 Register getBaseRegister() const { return BasePtr; }
157 /// Returns physical register used as frame pointer.
158 /// This will always returns the frame pointer register, contrary to
159 /// getFrameRegister() which returns the "base pointer" in situations
160 /// involving a stack, frame and base pointer.
161 Register getFramePtr() const { return FramePtr; }
162 // FIXME: Move to FrameInfok
163 unsigned getSlotSize() const { return SlotSize; }
164
167 const MachineFunction &MF, const VirtRegMap *VRM,
168 const LiveRegMatrix *Matrix) const override;
169
170 const TargetRegisterClass *
172
173 bool isNonRex2RegClass(const TargetRegisterClass *RC) const;
174
175 bool requiresRegisterScavenging(const MachineFunction &MF) const override {
176 return true;
177 }
178
179 unsigned getCSRFirstUseCost(const MachineFunction &MF) const override;
180 unsigned getCSRCostScale(const MachineFunction &MF) const override {
181 return 30;
182 }
183
184 const TargetRegisterClass *
186 return &X86::VR128XRegClass;
187 }
188};
189
190} // End llvm namespace
191
192#endif
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
IRTranslator LLVM IR MI
Live Register Matrix
Register Reg
uint64_t IntrinsicInst * II
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
MachineInstrBundleIterator< MachineInstr > iterator
Wrapper class representing virtual and physical registers.
Definition Register.h:20
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:346
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
bool hasBasePointer(const MachineFunction &MF) const
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
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 ...
Register getPtrSizedFrameRegister(const MachineFunction &MF) const
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" ...
unsigned getCSRCostScale(const MachineFunction &MF) const override
const uint32_t * getDarwinTLSCallPreservedMask() const
bool isTileRegisterClass(const TargetRegisterClass *RC) const
Return true if it is tile register class.
bool isNonRex2RegClass(const TargetRegisterClass *RC) const
bool requiresRegisterScavenging(const MachineFunction &MF) const override
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
Register getPtrSizedStackRegister(const MachineFunction &MF) const
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
unsigned getCSRFirstUseCost(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
const TargetRegisterClass * getRegClassToMinimizeDomainCrossings() 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...
X86RegisterInfo(const Triple &TT)
const TargetRegisterClass * constrainRegClassToNonRex2(const TargetRegisterClass *RC) const
Register getFramePtr() const
Returns physical register used as frame pointer.
Register getBaseRegister() const
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.
bool getRegAllocationHints(Register VirtReg, ArrayRef< MCPhysReg > Order, SmallSetVector< MCPhysReg, 16 > &Hints, const MachineFunction &MF, const VirtRegMap *VRM, const LiveRegMatrix *Matrix) const override
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...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58