43 #define GET_REGINFO_TARGET_DESC
44 #include "X86GenRegisterInfo.inc"
48 cl::desc(
"Enable use of a base pointer for complex stack frames"));
54 (TT.isArch64Bit() ? X86::RIP : X86::EIP)) {
70 StackPtr = Use64BitReg ? X86::RSP : X86::ESP;
71 FramePtr = Use64BitReg ? X86::RBP : X86::EBP;
72 BasePtr = Use64BitReg ? X86::RBX : X86::EBX;
89 return getEncodingValue(i);
97 if (!Is64Bit && Idx == X86::sub_8bit)
98 Idx = X86::sub_8bit_hi;
101 return X86GenRegisterInfo::getSubClassWithSubReg(RC, Idx);
107 unsigned SubIdx)
const {
109 if (!Is64Bit && SubIdx == X86::sub_8bit) {
110 A = X86GenRegisterInfo::getSubClassWithSubReg(A, X86::sub_8bit_hi);
114 return X86GenRegisterInfo::getMatchingSuperRegClass(A, B, SubIdx);
128 if (RC == &X86::GR8_NOREXRegClass)
136 switch (Super->getID()) {
137 case X86::FR32RegClassID:
138 case X86::FR64RegClassID:
141 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
144 case X86::VR128RegClassID:
145 case X86::VR256RegClassID:
147 if (!Subtarget.
hasVLX() &&
148 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
151 case X86::VR128XRegClassID:
152 case X86::VR256XRegClassID:
155 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
158 case X86::FR32XRegClassID:
159 case X86::FR64XRegClassID:
162 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
165 case X86::GR8RegClassID:
166 case X86::GR16RegClassID:
167 case X86::GR32RegClassID:
168 case X86::GR64RegClassID:
169 case X86::RFP32RegClassID:
170 case X86::RFP64RegClassID:
171 case X86::RFP80RegClassID:
172 case X86::VR512RegClassID:
175 if (getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
185 unsigned Kind)
const {
191 return &X86::GR64RegClass;
201 ? &X86::LOW32_ADDR_ACCESS_RBPRegClass
202 : &X86::LOW32_ADDR_ACCESSRegClass;
204 return &X86::GR32RegClass;
207 return &X86::GR64_NOSPRegClass;
209 return &X86::GR32_NOSPRegClass;
212 return &X86::GR64_NOREXRegClass;
213 return &X86::GR32_NOREXRegClass;
216 return &X86::GR64_NOREX_NOSPRegClass;
218 return &X86::GR32_NOREX_NOSPRegClass;
228 return &X86::GR64_TCW64RegClass;
230 return &X86::GR64_TCRegClass;
234 return &X86::GR32RegClass;
235 return &X86::GR32_TCRegClass;
240 if (RC == &X86::CCRRegClass) {
242 return &X86::GR64RegClass;
244 return &X86::GR32RegClass;
254 unsigned FPDiff = TFI->
hasFP(MF) ? 1 : 0;
255 switch (RC->
getID()) {
258 case X86::GR32RegClassID:
260 case X86::GR64RegClassID:
262 case X86::VR128RegClassID:
263 return Is64Bit ? 10 : 4;
264 case X86::VR64RegClassID:
271 assert(MF &&
"MachineFunction required");
274 bool HasSSE = Subtarget.
hasSSE1();
275 bool HasAVX = Subtarget.
hasAVX();
289 return CSR_NoRegs_SaveList;
292 return CSR_64_AllRegs_AVX_SaveList;
293 return CSR_64_AllRegs_SaveList;
295 return CSR_64_RT_MostRegs_SaveList;
298 return CSR_64_RT_AllRegs_AVX_SaveList;
299 return CSR_64_RT_AllRegs_SaveList;
303 CSR_64_CXX_TLS_Darwin_PE_SaveList : CSR_64_TLS_Darwin_SaveList;
306 if (HasAVX512 && IsWin64)
307 return CSR_Win64_Intel_OCL_BI_AVX512_SaveList;
308 if (HasAVX512 && Is64Bit)
309 return CSR_64_Intel_OCL_BI_AVX512_SaveList;
310 if (HasAVX && IsWin64)
311 return CSR_Win64_Intel_OCL_BI_AVX_SaveList;
312 if (HasAVX && Is64Bit)
313 return CSR_64_Intel_OCL_BI_AVX_SaveList;
314 if (!HasAVX && !IsWin64 && Is64Bit)
315 return CSR_64_Intel_OCL_BI_SaveList;
319 return CSR_64_HHVM_SaveList;
323 return (HasSSE ? CSR_Win64_RegCall_SaveList :
324 CSR_Win64_RegCall_NoSSE_SaveList);
326 return (HasSSE ? CSR_SysV64_RegCall_SaveList :
327 CSR_SysV64_RegCall_NoSSE_SaveList);
330 return (HasSSE ? CSR_32_RegCall_SaveList :
331 CSR_32_RegCall_NoSSE_SaveList);
335 return CSR_64_MostRegs_SaveList;
339 return CSR_Win64_NoSSE_SaveList;
340 return CSR_Win64_SaveList;
343 return CSR_64EHRet_SaveList;
344 return CSR_64_SaveList;
348 return CSR_64_AllRegs_AVX512_SaveList;
350 return CSR_64_AllRegs_AVX_SaveList;
352 return CSR_64_AllRegs_SaveList;
353 return CSR_64_AllRegs_NoSSE_SaveList;
356 return CSR_32_AllRegs_AVX512_SaveList;
358 return CSR_32_AllRegs_AVX_SaveList;
360 return CSR_32_AllRegs_SSE_SaveList;
361 return CSR_32_AllRegs_SaveList;
370 return CSR_Win64_NoSSE_SaveList;
371 return CSR_Win64_SaveList;
374 return CSR_64EHRet_SaveList;
377 Attribute::SwiftError))
378 return CSR_64_SwiftError_SaveList;
379 return CSR_64_SaveList;
382 return CSR_32EHRet_SaveList;
383 return CSR_32_SaveList;
388 assert(MF &&
"Invalid MachineFunction pointer.");
391 return CSR_64_CXX_TLS_Darwin_ViaCopy_SaveList;
399 bool HasSSE = Subtarget.
hasSSE1();
400 bool HasAVX = Subtarget.
hasAVX();
406 return CSR_NoRegs_RegMask;
409 return CSR_64_AllRegs_AVX_RegMask;
410 return CSR_64_AllRegs_RegMask;
412 return CSR_64_RT_MostRegs_RegMask;
415 return CSR_64_RT_AllRegs_AVX_RegMask;
416 return CSR_64_RT_AllRegs_RegMask;
419 return CSR_64_TLS_Darwin_RegMask;
422 if (HasAVX512 && IsWin64)
423 return CSR_Win64_Intel_OCL_BI_AVX512_RegMask;
424 if (HasAVX512 && Is64Bit)
425 return CSR_64_Intel_OCL_BI_AVX512_RegMask;
426 if (HasAVX && IsWin64)
427 return CSR_Win64_Intel_OCL_BI_AVX_RegMask;
428 if (HasAVX && Is64Bit)
429 return CSR_64_Intel_OCL_BI_AVX_RegMask;
430 if (!HasAVX && !IsWin64 && Is64Bit)
431 return CSR_64_Intel_OCL_BI_RegMask;
435 return CSR_64_HHVM_RegMask;
439 return (HasSSE ? CSR_Win64_RegCall_RegMask :
440 CSR_Win64_RegCall_NoSSE_RegMask);
442 return (HasSSE ? CSR_SysV64_RegCall_RegMask :
443 CSR_SysV64_RegCall_NoSSE_RegMask);
446 return (HasSSE ? CSR_32_RegCall_RegMask :
447 CSR_32_RegCall_NoSSE_RegMask);
451 return CSR_64_MostRegs_RegMask;
454 return CSR_Win64_RegMask;
456 return CSR_64_RegMask;
460 return CSR_64_AllRegs_AVX512_RegMask;
462 return CSR_64_AllRegs_AVX_RegMask;
464 return CSR_64_AllRegs_RegMask;
465 return CSR_64_AllRegs_NoSSE_RegMask;
468 return CSR_32_AllRegs_AVX512_RegMask;
470 return CSR_32_AllRegs_AVX_RegMask;
472 return CSR_32_AllRegs_SSE_RegMask;
473 return CSR_32_AllRegs_RegMask;
483 return CSR_Win64_RegMask;
486 Attribute::SwiftError))
487 return CSR_64_SwiftError_RegMask;
488 return CSR_64_RegMask;
490 return CSR_32_RegMask;
495 return CSR_NoRegs_RegMask;
499 return CSR_64_TLS_Darwin_RegMask;
517 if (TFI->
hasFP(MF)) {
529 "Stack realignment in presence of dynamic allocas is not supported with"
530 "this calling convention.");
539 Reserved.
set(X86::CS);
540 Reserved.
set(X86::SS);
541 Reserved.
set(X86::DS);
542 Reserved.
set(X86::ES);
543 Reserved.
set(X86::FS);
544 Reserved.
set(X86::GS);
547 for (
unsigned n = 0; n != 8; ++n)
548 Reserved.
set(X86::ST0 + n);
554 Reserved.
set(X86::SIL);
555 Reserved.
set(X86::DIL);
556 Reserved.
set(X86::BPL);
557 Reserved.
set(X86::SPL);
559 for (
unsigned n = 0; n != 8; ++n) {
570 for (
unsigned n = 16; n != 32; ++n) {
576 assert(checkAllSuperRegsMarked(Reserved,
577 {X86::SIL, X86::DIL, X86::BPL, X86::SPL}));
589 assert(!(Mask[X86::EFLAGS / 32] & (1U << (X86::EFLAGS % 32))) &&
590 "EFLAGS are not live-out from a patchpoint.");
593 for (
auto Reg : {X86::EFLAGS, X86::RIP, X86::EIP, X86::IP})
594 Mask[
Reg / 32] &= ~(1U << (
Reg % 32));
616 bool CantUseFP = needsStackRealignment(MF);
640 unsigned Reg,
int &FrameIdx)
const {
652 unsigned Opc = II->getOpcode();
654 if ((Opc != X86::LEA32r && Opc != X86::LEA64r && Opc != X86::LEA64_32r) ||
664 if (Opc == X86::LEA64_32r)
677 int SPAdj,
unsigned FIOperandNum,
688 assert((!needsStackRealignment(MF) ||
690 "Return instruction can only reference SP relative frame objects");
702 if (Opc == TargetOpcode::LOCAL_ESCAPE) {
712 unsigned MachineBasePtr = BasePtr;
713 if (Opc == X86::LEA64_32r && X86::GR32RegClass.
contains(BasePtr))
720 if (BasePtr == StackPtr)
725 if (Opc == TargetOpcode::STACKMAP || Opc == TargetOpcode::PATCHPOINT) {
726 assert(BasePtr == FramePtr &&
"Expected the FP as base register");
735 int Offset = FIOffset + Imm;
737 "Requesting 64-bit offset in 32-bit immediate!");
742 uint64_t
Offset = FIOffset +
750 return TFI->
hasFP(MF) ? FramePtr : StackPtr;
The C convention as specified in the x86-64 supplement to the System V ABI, used on most non-Windows ...
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 ...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
static bool tryOptimizeLEAtoMOV(MachineBasicBlock::iterator II)
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
bool hasBasePointer(const MachineFunction &MF) const
bool callsEHReturn() const
unsigned getID() const
Return the register class ID number.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
unsigned getDwarfRegFlavour(const Triple &TT, bool isEH)
bool canReserveReg(unsigned PhysReg) const
canReserveReg - Returns true if PhysReg can be used as a reserved register.
return AArch64::GPR64RegClass contains(Reg)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool isOSWindows() const
Tests whether the OS is Windows.
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
AttributeList getAttributes() const
Return the attribute list for this Function.
bool Uses64BitFramePtr
True if the 64-bit frame or stack pointer should be used.
X86_INTR - x86 hardware interrupt context.
X86RegisterInfo(const Triple &TT)
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
getPointerRegClass - Returns a TargetRegisterClass used for pointer values.
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const HexagonInstrInfo * TII
const uint32_t * getDarwinTLSCallPreservedMask() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
Reg
All possible values of the reg field in the ModR/M byte.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
const TargetRegisterClass *const * sc_iterator
bool isArch64Bit() const
Test whether the architecture is 64-bit.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
static cl::opt< bool > EnableBasePointer("x86-use-base-pointer", cl::Hidden, cl::init(true), cl::desc("Enable use of a base pointer for complex stack frames"))
BitVector getReservedRegs(const MachineFunction &MF) const override
getReservedRegs - Returns a bitset indexed by physical register number indicating if a register is a ...
int getFrameIndexReferenceSP(const MachineFunction &MF, int FI, unsigned &SPReg, int Adjustment) const
void adjustStackMapLiveOutMask(uint32_t *Mask) const override
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
const MachineBasicBlock * getParent() const
const X86TargetLowering * getTargetLowering() const override
Function Alias Analysis false
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const override
initializer< Ty > init(const Ty &Val)
bool isReturn(QueryType Type=AnyInBundle) const
unsigned const MachineRegisterInfo * MRI
bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override
Code Generation virtual methods...
const uint32_t * getNoPreservedMask() const override
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MachineOperand & getOperand(unsigned i) const
MCRegAliasIterator enumerates all registers aliasing Reg.
const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const TargetRegisterClass * getGPRsForTailCall(const MachineFunction &MF) const
getGPRsForTailCall - Returns a register class with registers that can be used in forming tail calls...
int64_t getOffset() const
Return the offset from the symbol in this operand.
void setOffset(int64_t Offset)
MCSubRegIterator enumerates all sub-registers of Reg.
unsigned getBaseRegister() const
Triple - Helper class for working with autoconf configuration names.
Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins.
void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
constexpr bool isInt< 32 >(int64_t x)
void initLLVMToSEHAndCVRegMapping(MCRegisterInfo *MRI)
bool isTarget64BitILP32() const
Is this x86_64 with the ILP32 programming model (x32 ABI)?
MachineOperand class - Representation of each machine instruction operand.
int getSEHRegNum(unsigned i) const
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
getCalleeSavedRegs - Return a null-terminated list of all of the callee-save registers on this target...
const TargetRegisterClass * getCrossCopyRegClass(const TargetRegisterClass *RC) const override
getCrossCopyRegClass - Returns a legal register class to copy a register in the specified class to or...
Calling convention used by HipHop Virtual Machine (HHVM) to perform calls to and from translation cac...
unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
The C convention as implemented on Windows/x86-64 and AArch64.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool isTarget64BitLP64() const
Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
virtual bool canRealignStack(const MachineFunction &MF) const
True if the stack can be realigned for the target.
const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const override
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
bool canRealignStack(const MachineFunction &MF) const override
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
static bool CantUseSP(const MachineFrameInfo &MFI)
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
bool hasAttrSomewhere(Attribute::AttrKind Kind, unsigned *Index=nullptr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
unsigned getFrameRegister(const MachineFunction &MF) const override
Register calling convention used for parameters transfer optimization.
sc_iterator getSuperClasses() const
Returns a NULL-terminated list of super-classes.
unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const