37 #define GET_REGINFO_TARGET_DESC 38 #include "X86GenRegisterInfo.inc" 42 cl::desc(
"Enable use of a base pointer for complex stack frames"));
48 (TT.isArch64Bit() ? X86::RIP : X86::EIP)) {
64 StackPtr = Use64BitReg ? X86::RSP :
X86::ESP;
65 FramePtr = Use64BitReg ? X86::RBP : X86::EBP;
66 BasePtr = Use64BitReg ? X86::RBX :
X86::EBX;
83 return getEncodingValue(i);
91 if (!Is64Bit && Idx == X86::sub_8bit)
92 Idx = X86::sub_8bit_hi;
95 return X86GenRegisterInfo::getSubClassWithSubReg(RC, Idx);
101 unsigned SubIdx)
const {
103 if (!Is64Bit && SubIdx == X86::sub_8bit) {
104 A = X86GenRegisterInfo::getSubClassWithSubReg(A, X86::sub_8bit_hi);
108 return X86GenRegisterInfo::getMatchingSuperRegClass(A, B, SubIdx);
122 if (RC == &X86::GR8_NOREXRegClass)
130 switch (Super->getID()) {
131 case X86::FR32RegClassID:
132 case X86::FR64RegClassID:
135 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
138 case X86::VR128RegClassID:
139 case X86::VR256RegClassID:
141 if (!Subtarget.
hasVLX() &&
142 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
145 case X86::VR128XRegClassID:
146 case X86::VR256XRegClassID:
149 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
152 case X86::FR32XRegClassID:
153 case X86::FR64XRegClassID:
156 getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
159 case X86::GR8RegClassID:
160 case X86::GR16RegClassID:
161 case X86::GR32RegClassID:
162 case X86::GR64RegClassID:
163 case X86::RFP32RegClassID:
164 case X86::RFP64RegClassID:
165 case X86::RFP80RegClassID:
166 case X86::VR512_0_15RegClassID:
167 case X86::VR512RegClassID:
170 if (getRegSizeInBits(*Super) == getRegSizeInBits(*RC))
180 unsigned Kind)
const {
186 return &X86::GR64RegClass;
196 ? &X86::LOW32_ADDR_ACCESS_RBPRegClass
197 : &X86::LOW32_ADDR_ACCESSRegClass;
199 return &X86::GR32RegClass;
202 return &X86::GR64_NOSPRegClass;
204 return &X86::GR32_NOSPRegClass;
207 return &X86::GR64_NOREXRegClass;
208 return &X86::GR32_NOREXRegClass;
211 return &X86::GR64_NOREX_NOSPRegClass;
213 return &X86::GR32_NOREX_NOSPRegClass;
222 unsigned SrcSubReg)
const {
227 SrcRC->
hasSuperClassEq(&X86::GR64RegClass) && SrcSubReg == X86::sub_32bit)
238 return &X86::GR64_TCW64RegClass;
240 return &X86::GR64_TCRegClass;
244 return &X86::GR32RegClass;
245 return &X86::GR32_TCRegClass;
250 if (RC == &X86::CCRRegClass) {
252 return &X86::GR64RegClass;
254 return &X86::GR32RegClass;
264 unsigned FPDiff = TFI->
hasFP(MF) ? 1 : 0;
265 switch (RC->
getID()) {
268 case X86::GR32RegClassID:
270 case X86::GR64RegClassID:
272 case X86::VR128RegClassID:
273 return Is64Bit ? 10 : 4;
274 case X86::VR64RegClassID:
281 assert(MF &&
"MachineFunction required");
285 bool HasSSE = Subtarget.
hasSSE1();
286 bool HasAVX = Subtarget.
hasAVX();
300 return CSR_NoRegs_SaveList;
303 return CSR_64_AllRegs_AVX_SaveList;
304 return CSR_64_AllRegs_SaveList;
306 return CSR_64_RT_MostRegs_SaveList;
309 return CSR_64_RT_AllRegs_AVX_SaveList;
310 return CSR_64_RT_AllRegs_SaveList;
314 CSR_64_CXX_TLS_Darwin_PE_SaveList : CSR_64_TLS_Darwin_SaveList;
317 if (HasAVX512 && IsWin64)
318 return CSR_Win64_Intel_OCL_BI_AVX512_SaveList;
319 if (HasAVX512 && Is64Bit)
320 return CSR_64_Intel_OCL_BI_AVX512_SaveList;
321 if (HasAVX && IsWin64)
322 return CSR_Win64_Intel_OCL_BI_AVX_SaveList;
323 if (HasAVX && Is64Bit)
324 return CSR_64_Intel_OCL_BI_AVX_SaveList;
325 if (!HasAVX && !IsWin64 && Is64Bit)
326 return CSR_64_Intel_OCL_BI_SaveList;
330 return CSR_64_HHVM_SaveList;
334 return (HasSSE ? CSR_Win64_RegCall_SaveList :
335 CSR_Win64_RegCall_NoSSE_SaveList);
337 return (HasSSE ? CSR_SysV64_RegCall_SaveList :
338 CSR_SysV64_RegCall_NoSSE_SaveList);
341 return (HasSSE ? CSR_32_RegCall_SaveList :
342 CSR_32_RegCall_NoSSE_SaveList);
345 assert(!Is64Bit &&
"CFGuard check mechanism only used on 32-bit X86");
346 return (HasSSE ? CSR_Win32_CFGuard_Check_SaveList
347 : CSR_Win32_CFGuard_Check_NoSSE_SaveList);
350 return CSR_64_MostRegs_SaveList;
354 return CSR_Win64_NoSSE_SaveList;
355 return CSR_Win64_SaveList;
358 return CSR_64EHRet_SaveList;
359 return CSR_64_SaveList;
363 return CSR_64_AllRegs_AVX512_SaveList;
365 return CSR_64_AllRegs_AVX_SaveList;
367 return CSR_64_AllRegs_SaveList;
368 return CSR_64_AllRegs_NoSSE_SaveList;
371 return CSR_32_AllRegs_AVX512_SaveList;
373 return CSR_32_AllRegs_AVX_SaveList;
375 return CSR_32_AllRegs_SSE_SaveList;
376 return CSR_32_AllRegs_SaveList;
384 F.getAttributes().hasAttrSomewhere(Attribute::SwiftError);
386 return IsWin64 ? CSR_Win64_SwiftError_SaveList
387 : CSR_64_SwiftError_SaveList;
390 return HasSSE ? CSR_Win64_SaveList : CSR_Win64_NoSSE_SaveList;
392 return CSR_64EHRet_SaveList;
393 return CSR_64_SaveList;
396 return CallsEHReturn ? CSR_32EHRet_SaveList : CSR_32_SaveList;
401 assert(MF &&
"Invalid MachineFunction pointer.");
404 return CSR_64_CXX_TLS_Darwin_ViaCopy_SaveList;
412 bool HasSSE = Subtarget.
hasSSE1();
413 bool HasAVX = Subtarget.
hasAVX();
419 return CSR_NoRegs_RegMask;
422 return CSR_64_AllRegs_AVX_RegMask;
423 return CSR_64_AllRegs_RegMask;
425 return CSR_64_RT_MostRegs_RegMask;
428 return CSR_64_RT_AllRegs_AVX_RegMask;
429 return CSR_64_RT_AllRegs_RegMask;
432 return CSR_64_TLS_Darwin_RegMask;
435 if (HasAVX512 && IsWin64)
436 return CSR_Win64_Intel_OCL_BI_AVX512_RegMask;
437 if (HasAVX512 && Is64Bit)
438 return CSR_64_Intel_OCL_BI_AVX512_RegMask;
439 if (HasAVX && IsWin64)
440 return CSR_Win64_Intel_OCL_BI_AVX_RegMask;
441 if (HasAVX && Is64Bit)
442 return CSR_64_Intel_OCL_BI_AVX_RegMask;
443 if (!HasAVX && !IsWin64 && Is64Bit)
444 return CSR_64_Intel_OCL_BI_RegMask;
448 return CSR_64_HHVM_RegMask;
452 return (HasSSE ? CSR_Win64_RegCall_RegMask :
453 CSR_Win64_RegCall_NoSSE_RegMask);
455 return (HasSSE ? CSR_SysV64_RegCall_RegMask :
456 CSR_SysV64_RegCall_NoSSE_RegMask);
459 return (HasSSE ? CSR_32_RegCall_RegMask :
460 CSR_32_RegCall_NoSSE_RegMask);
463 assert(!Is64Bit &&
"CFGuard check mechanism only used on 32-bit X86");
464 return (HasSSE ? CSR_Win32_CFGuard_Check_RegMask
465 : CSR_Win32_CFGuard_Check_NoSSE_RegMask);
468 return CSR_64_MostRegs_RegMask;
471 return CSR_Win64_RegMask;
473 return CSR_64_RegMask;
477 return CSR_64_AllRegs_AVX512_RegMask;
479 return CSR_64_AllRegs_AVX_RegMask;
481 return CSR_64_AllRegs_RegMask;
482 return CSR_64_AllRegs_NoSSE_RegMask;
485 return CSR_32_AllRegs_AVX512_RegMask;
487 return CSR_32_AllRegs_AVX_RegMask;
489 return CSR_32_AllRegs_SSE_RegMask;
490 return CSR_32_AllRegs_RegMask;
503 return IsWin64 ? CSR_Win64_SwiftError_RegMask : CSR_64_SwiftError_RegMask;
504 return IsWin64 ? CSR_Win64_RegMask : CSR_64_RegMask;
507 return CSR_32_RegMask;
512 return CSR_NoRegs_RegMask;
516 return CSR_64_TLS_Darwin_RegMask;
524 Reserved.
set(X86::FPCW);
527 Reserved.
set(X86::FPSW);
530 Reserved.
set(X86::MXCSR);
537 Reserved.
set(X86::SSP);
544 if (TFI->
hasFP(MF)) {
555 "Stack realignment in presence of dynamic allocas is not supported with" 556 "this calling convention.");
564 Reserved.
set(X86::CS);
567 Reserved.
set(X86::ES);
572 for (
unsigned n = 0; n != 8; ++n)
573 Reserved.
set(X86::ST0 + n);
579 Reserved.
set(X86::SIL);
580 Reserved.
set(X86::DIL);
581 Reserved.
set(X86::BPL);
582 Reserved.
set(X86::SPL);
583 Reserved.
set(X86::SIH);
584 Reserved.
set(X86::DIH);
585 Reserved.
set(X86::BPH);
586 Reserved.
set(X86::SPH);
588 for (
unsigned n = 0; n != 8; ++n) {
599 for (
unsigned n = 16; n != 32; ++n) {
605 assert(checkAllSuperRegsMarked(Reserved,
606 {X86::SIL, X86::DIL, X86::BPL, X86::SPL,
607 X86::SIH, X86::DIH, X86::BPH, X86::SPH}));
619 assert(!(Mask[X86::EFLAGS / 32] & (1U << (X86::EFLAGS % 32))) &&
620 "EFLAGS are not live-out from a patchpoint.");
623 for (
auto Reg : {X86::EFLAGS, X86::RIP, X86::EIP, X86::IP})
624 Mask[
Reg / 32] &= ~(1U << (
Reg % 32));
646 bool CantUseFP = needsStackRealignment(MF);
670 unsigned Reg,
int &FrameIdx)
const {
682 unsigned Opc = II->getOpcode();
684 if ((Opc != X86::LEA32r && Opc != X86::LEA64r && Opc != X86::LEA64_32r) ||
694 if (Opc == X86::LEA64_32r)
718 int SPAdj,
unsigned FIOperandNum,
724 bool IsEHFuncletEpilogue = MBBI == MBB.
end() ?
false 733 assert((!needsStackRealignment(MF) ||
735 "Return instruction can only reference SP relative frame objects");
749 if (Opc == TargetOpcode::LOCAL_ESCAPE) {
760 if (Opc == X86::LEA64_32r && X86::GR32RegClass.
contains(BasePtr))
767 if (BasePtr == StackPtr)
772 if (Opc == TargetOpcode::STACKMAP || Opc == TargetOpcode::PATCHPOINT) {
773 assert(BasePtr == FramePtr &&
"Expected the FP as base register");
782 int Offset = FIOffset + Imm;
784 "Requesting 64-bit offset in 32-bit immediate!");
789 uint64_t
Offset = FIOffset +
797 return TFI->
hasFP(MF) ? FramePtr : StackPtr;
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 ...
bool hasBasePointer(const MachineFunction &MF) const
The C convention as specified in the x86-64 supplement to the System V ABI, used on most non-Windows ...
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
static bool tryOptimizeLEAtoMOV(MachineBasicBlock::iterator II)
Calling convention used by HipHop Virtual Machine (HHVM) to perform calls to and from translation cac...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
const TargetRegisterClass * getGPRsForTailCall(const MachineFunction &MF) const
getGPRsForTailCall - Returns a register class with registers that can be used in forming tail calls...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const
block Block Frequency true
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned getDwarfRegFlavour(const Triple &TT, bool isEH)
MCRegister getX86SubSuperRegister(MCRegister, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
return AArch64::GPR64RegClass contains(Reg)
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
bool Uses64BitFramePtr
True if the 64-bit frame or stack pointer should be used.
X86RegisterInfo(const Triple &TT)
const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const override
getPointerRegClass - Returns a TargetRegisterClass used for pointer values.
CLEANUPRET - Represents a return from a cleanup block funclet.
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
const HexagonInstrInfo * TII
static bool isFuncletReturnInstr(MachineInstr &MI)
bool isTarget64BitLP64() const
Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
virtual bool canRealignStack(const MachineFunction &MF) const
True if the stack can be realigned for the target.
const MCPhysReg * getCalleeSavedRegsViaCopy(const MachineFunction *MF) const
const TargetRegisterClass *const * sc_iterator
unsigned getID() const
Return the register class ID number.
int getWin64EHFrameIndexRef(const MachineFunction &MF, int FI, unsigned &SPReg) const
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"))
bool canReserveReg(unsigned PhysReg) const
canReserveReg - Returns true if PhysReg can be used as a reserved register.
bool shouldRewriteCopySrc(const TargetRegisterClass *DefRC, unsigned DefSubReg, const TargetRegisterClass *SrcRC, unsigned SrcSubReg) const override
AttributeList getAttributes() const
Return the attribute list for this Function.
BitVector getReservedRegs(const MachineFunction &MF) const override
getReservedRegs - Returns a bitset indexed by physical register number indicating if a register is a ...
bool Is64Bit
Is64Bit implies that x86_64 instructions are available.
void adjustStackMapLiveOutMask(uint32_t *Mask) const override
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
unsigned getPtrSizedStackRegister(const MachineFunction &MF) const
bool isReturn(QueryType Type=AnyInBundle) const
The C convention as implemented on Windows/x86-64 and AArch64.
X86_INTR - x86 hardware interrupt context.
bool isOSWindows() const
Tests whether the OS is Windows.
const X86TargetLowering * getTargetLowering() const override
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...
const TargetRegisterClass * getLargestLegalSuperClass(const TargetRegisterClass *RC, const MachineFunction &MF) const override
bool hasReservedSpillSlot(const MachineFunction &MF, unsigned Reg, int &FrameIdx) const override
sc_iterator getSuperClasses() const
Returns a NULL-terminated list of super-classes.
Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins.
initializer< Ty > init(const Ty &Val)
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
bool trackLivenessAfterRegAlloc(const MachineFunction &MF) const override
Code Generation virtual methods...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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...
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
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...
int getSEHRegNum(unsigned i) const
void setOffset(int64_t Offset)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Register getFrameRegister(const MachineFunction &MF) const override
Register calling convention used for parameters transfer optimization.
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)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
MachineOperand class - Representation of each machine instruction operand.
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
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...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
bool isTarget64BitILP32() const
Is this x86_64 with the ILP32 programming model (x32 ABI)?
bool callsEHReturn() const
const uint32_t * getDarwinTLSCallPreservedMask() const
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
CATCHRET - Represents a return from a catch block funclet.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
int getFrameIndexReferenceSP(const MachineFunction &MF, int FI, unsigned &SPReg, int Adjustment) const
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
virtual bool shouldRewriteCopySrc(const TargetRegisterClass *DefRC, unsigned DefSubReg, const TargetRegisterClass *SrcRC, unsigned SrcSubReg) const
bool isArch64Bit() const
Test whether the architecture is 64-bit.
bool isEHFuncletEntry() const
Returns true if this is the entry block of an EH funclet.
int64_t getOffset() const
Return the offset from the symbol in this operand.
void ChangeToRegister(Register 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...
const TargetRegisterClass * getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const override
bool canRealignStack(const MachineFunction &MF) const override
static bool CantUseSP(const MachineFrameInfo &MFI)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Special calling convention on Windows for calling the Control Guard Check ICall funtion.
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...
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
Function Alias Analysis false
Register getStackRegister() const
Wrapper class representing virtual and physical registers.
Register getBaseRegister() const