41 unsigned StackAlignOverride)
44 STI(STI),
TII(*STI.getInstrInfo()), TRI(STI.getRegisterInfo()) {
102 return X86::SUB64ri8;
103 return X86::SUB64ri32;
106 return X86::SUB32ri8;
114 return X86::ADD64ri8;
115 return X86::ADD64ri32;
118 return X86::ADD32ri8;
124 return isLP64 ? X86::SUB64rr : X86::SUB32rr;
128 return isLP64 ? X86::ADD64rr : X86::ADD32rr;
134 return X86::AND64ri8;
135 return X86::AND64ri32;
138 return X86::AND32ri8;
143 return IsLP64 ? X86::LEA64r : X86::LEA32r;
158 static const uint16_t CallerSavedRegs32Bit[] = {
159 X86::EAX, X86::EDX, X86::ECX, 0
162 static const uint16_t CallerSavedRegs64Bit[] = {
163 X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
164 X86::R8, X86::R9, X86::R10, X86::R11, 0
167 unsigned Opc = MBBI->getOpcode();
174 case X86::TCRETURNdi:
175 case X86::TCRETURNri:
176 case X86::TCRETURNmi:
177 case X86::TCRETURNdi64:
178 case X86::TCRETURNri64:
179 case X86::TCRETURNmi64:
181 case X86::EH_RETURN64: {
183 for (
unsigned i = 0, e = MBBI->getNumOperands(); i != e; ++i) {
194 const uint16_t *
CS = Is64Bit ? CallerSavedRegs64Bit : CallerSavedRegs32Bit;
196 if (!Uses.
count(*CS))
207 unsigned Reg = II->first;
209 if (Reg == X86::RAX || Reg == X86::EAX || Reg == X86::AX ||
210 Reg == X86::AH || Reg == X86::AL)
220 bool BreakNext =
false;
224 unsigned Reg = MO.getReg();
225 if (Reg != X86::EFLAGS)
244 int64_t NumBytes,
bool InEpilogue)
const {
245 bool isSub = NumBytes < 0;
246 uint64_t Offset = isSub ? -NumBytes : NumBytes;
248 uint64_t Chunk = (1LL << 31) - 1;
252 if (Offset > Chunk) {
263 unsigned Opc =
Is64Bit ? X86::MOV64ri : X86::MOV32ri;
278 uint64_t ThisVal =
std::min(Offset, Chunk);
279 if (ThisVal == (
Is64Bit ? 8 : 4)) {
286 ? (
Is64Bit ? X86::PUSH64r : X86::PUSH32r)
287 : (
Is64Bit ? X86::POP64r : X86::POP32r);
298 MBB, MBBI, DL, isSub ? -ThisVal : ThisVal, InEpilogue);
308 int64_t Offset,
bool InEpilogue)
const {
309 assert(Offset != 0 &&
"zero offset stack adjustment requested");
328 "We shouldn't have allowed this insertion point");
338 bool IsSub = Offset < 0;
339 uint64_t AbsOffset = IsSub ? -Offset : Offset;
353 unsigned StackPtr, uint64_t *NumBytes =
nullptr) {
354 if (MBBI == MBB.
begin())
return;
357 unsigned Opc = PI->getOpcode();
358 if ((Opc == X86::ADD64ri32 || Opc == X86::ADD64ri8 ||
359 Opc == X86::ADD32ri || Opc == X86::ADD32ri8 ||
360 Opc == X86::LEA32r || Opc == X86::LEA64_32r) &&
361 PI->getOperand(0).getReg() == StackPtr) {
363 *NumBytes += PI->getOperand(2).getImm();
365 }
else if ((Opc == X86::SUB64ri32 || Opc == X86::SUB64ri8 ||
366 Opc == X86::SUB32ri || Opc == X86::SUB32ri8) &&
367 PI->getOperand(0).getReg() == StackPtr) {
369 *NumBytes -= PI->getOperand(2).getImm();
376 bool doMergeWithPrevious)
const {
377 if ((doMergeWithPrevious && MBBI == MBB.
begin()) ||
378 (!doMergeWithPrevious && MBBI == MBB.
end()))
384 unsigned Opc = PI->getOpcode();
387 if ((Opc == X86::ADD64ri32 || Opc == X86::ADD64ri8 ||
388 Opc == X86::ADD32ri || Opc == X86::ADD32ri8 ||
389 Opc == X86::LEA32r || Opc == X86::LEA64_32r) &&
390 PI->getOperand(0).getReg() ==
StackPtr){
391 Offset += PI->getOperand(2).getImm();
393 if (!doMergeWithPrevious) MBBI = NI;
394 }
else if ((Opc == X86::SUB64ri32 || Opc == X86::SUB64ri8 ||
395 Opc == X86::SUB32ri || Opc == X86::SUB32ri8) &&
396 PI->getOperand(0).getReg() ==
StackPtr) {
397 Offset -= PI->getOperand(2).getImm();
399 if (!doMergeWithPrevious) MBBI = NI;
411 .addCFIIndex(CFIIndex);
425 if (CSI.empty())
return;
428 for (std::vector<CalleeSavedInfo>::const_iterator
429 I = CSI.begin(), E = CSI.end();
I != E; ++
I) {
431 unsigned Reg =
I->getReg();
434 BuildCFI(MBB, MBBI, DL,
464 CallOp = IsLargeCodeModel ? X86::CALL64r : X86::CALL64pcrel32;
466 CallOp = X86::CALLpcrel32;
471 Symbol =
"___chkstk_ms";
488 .addExternalSymbol(Symbol);
489 CI =
BuildMI(MBB, MBBI, DL,
TII.
get(CallOp)).addReg(X86::R11);
491 CI =
BuildMI(MBB, MBBI, DL,
TII.
get(CallOp)).addExternalSymbol(Symbol);
494 unsigned AX =
Is64Bit ? X86::RAX : X86::EAX;
495 unsigned SP =
Is64Bit ? X86::RSP : X86::ESP;
515 const uint64_t Win64MaxSEHOffset = 128;
516 uint64_t SEHFrameOffset =
std::min(SPAdjust, Win64MaxSEHOffset);
518 return SEHFrameOffset & -16;
525 uint64_t X86FrameLowering::calculateMaxStackAlign(
const MachineFunction &MF)
const {
531 MaxAlign = (StackAlign > MaxAlign) ? StackAlign : MaxAlign;
541 uint64_t MaxAlign)
const {
542 uint64_t Val = -MaxAlign;
641 "MF used frame lowering for wrong subtarget");
647 uint64_t MaxAlign = calculateMaxStackAlign(MF);
649 bool HasFP =
hasFP(MF);
656 const unsigned MachineFramePtr =
665 if (TailCallReturnAddrDelta && IsWin64Prologue)
668 if (TailCallReturnAddrDelta < 0)
676 unsigned StackProbeSize = 4096;
696 StackSize = std::max(MinSize, StackSize > 128 ? StackSize - 128 : 0);
703 if (TailCallReturnAddrDelta < 0) {
704 BuildStackAdjustment(MBB, MBBI, DL, TailCallReturnAddrDelta,
723 uint64_t NumBytes = 0;
728 uint64_t FrameSize = StackSize -
SlotSize;
731 FrameSize += SlotSize;
753 BuildCFI(MBB, MBBI, DL,
757 unsigned DwarfFramePtr =
TRI->getDwarfRegNum(MachineFramePtr,
true);
759 nullptr, DwarfFramePtr, 2 * stackGrowth));
768 if (!IsWin64Prologue) {
780 unsigned DwarfFramePtr =
TRI->getDwarfRegNum(MachineFramePtr,
true);
781 BuildCFI(MBB, MBBI, DL,
787 I->addLiveIn(MachineFramePtr);
793 bool PushedRegs =
false;
794 int StackOffset = 2 * stackGrowth;
796 while (MBBI != MBB.
end() &&
797 (MBBI->getOpcode() == X86::PUSH32r ||
798 MBBI->getOpcode() == X86::PUSH64r)) {
800 unsigned Reg = MBBI->getOperand(0).getReg();
803 if (!HasFP && NeedsDwarfCFI) {
807 BuildCFI(MBB, MBBI, DL,
809 StackOffset += stackGrowth;
822 assert(HasFP &&
"There should be a frame pointer if stack is realigned.");
823 BuildStackAlignAND(MBB, MBBI, DL, MaxAlign);
841 uint64_t AlignedNumBytes = NumBytes;
844 if (AlignedNumBytes >= StackProbeSize && UseStackProbe) {
851 assert(!
Is64Bit &&
"EAX is livein in x64 case!");
879 .addImm(isEAXAlive ? NumBytes - 4 : NumBytes)
891 for (; SetRAX != MBBI; ++SetRAX)
902 }
else if (NumBytes) {
906 if (NeedsWinCFI && NumBytes)
911 int SEHFrameOffset = 0;
912 if (IsWin64Prologue && HasFP) {
936 Offset += SEHFrameOffset;
955 assert(HasFP &&
"There should be a frame pointer if stack is realigned.");
956 BuildStackAlignAND(MBB, MBBI, DL, MaxAlign);
992 if (((!HasFP && NumBytes) || PushedRegs) && NeedsDwarfCFI) {
994 if (!HasFP && NumBytes) {
998 nullptr, -StackSize + stackGrowth));
1024 if (MBBI != MBB.
end())
1025 DL = MBBI->getDebugLoc();
1029 unsigned MachineFramePtr =
1039 uint64_t MaxAlign = calculateMaxStackAlign(MF);
1041 uint64_t NumBytes = 0;
1045 uint64_t FrameSize = StackSize -
SlotSize;
1046 NumBytes = FrameSize - CSSize;
1055 TII.
get(
Is64Bit ? X86::POP64r : X86::POP32r), MachineFramePtr);
1057 NumBytes = StackSize - CSSize;
1059 uint64_t SEHStackAllocAmt = NumBytes;
1062 while (MBBI != MBB.
begin()) {
1064 unsigned Opc = PI->getOpcode();
1066 if (Opc != X86::POP32r && Opc != X86::POP64r && Opc !=
X86::DBG_VALUE &&
1067 !PI->isTerminator())
1074 if (MBBI != MBB.
end())
1075 DL = MBBI->getDebugLoc();
1089 uint64_t LEAAmount =
1090 IsWin64Prologue ? SEHStackAllocAmt - SEHFrameOffset : -CSSize;
1099 if (LEAAmount != 0) {
1102 FramePtr,
false, LEAAmount);
1110 }
else if (NumBytes) {
1127 assert(Offset >= 0 &&
"TCDelta should never be positive");
1148 bool HasFP =
hasFP(MF);
1150 int64_t FPDelta = 0;
1152 if (IsWin64Prologue) {
1153 assert(!MFI->
hasCalls() || (StackSize % 16) == 8);
1156 uint64_t FrameSize = StackSize -
SlotSize;
1159 FrameSize += SlotSize;
1160 uint64_t NumBytes = FrameSize - CSSize;
1164 return -SEHFrameOffset;
1170 FPDelta = FrameSize - SEHFrameOffset;
1171 assert((!MFI->
hasCalls() || (FPDelta % 16) == 0) &&
1172 "FPDelta isn't aligned per the Win64 ABI!");
1177 assert(HasFP &&
"VLAs and dynamic stack realign, but no FP?!");
1180 return Offset +
SlotSize + FPDelta;
1183 return Offset + StackSize;
1188 return Offset +
SlotSize + FPDelta;
1191 return Offset + StackSize;
1196 return Offset + StackSize;
1203 if (TailCallReturnAddrDelta < 0)
1204 Offset -= TailCallReturnAddrDelta;
1207 return Offset + FPDelta;
1211 unsigned &FrameReg)
const {
1246 int TailCallReturnAddrDelta =
1248 assert(!(TailCallReturnAddrDelta < 0) &&
"we don't handle this case!");
1281 return Offset + StackSize;
1286 unsigned &FrameReg)
const {
1295 std::vector<CalleeSavedInfo> &CSI)
const {
1299 unsigned CalleeSavedFrameSize = 0;
1311 for (
unsigned i = 0; i < CSI.size(); ++i) {
1313 CSI.erase(CSI.begin() + i);
1320 for (
unsigned i = CSI.size(); i != 0; --i) {
1321 unsigned Reg = CSI[i - 1].getReg();
1330 CSI[i - 1].setFrameIdx(SlotIndex);
1336 for (
unsigned i = CSI.size(); i != 0; --i) {
1337 unsigned Reg = CSI[i - 1].getReg();
1345 SpillSlotOffset -= RC->
getSize();
1348 CSI[i - 1].setFrameIdx(SlotIndex);
1357 const std::vector<CalleeSavedInfo> &CSI,
1362 unsigned Opc =
STI.
is64Bit() ? X86::PUSH64r : X86::PUSH32r;
1363 for (
unsigned i = CSI.size(); i != 0; --i) {
1364 unsigned Reg = CSI[i - 1].getReg();
1377 for (
unsigned i = CSI.size(); i != 0; --i) {
1378 unsigned Reg = CSI[i-1].getReg();
1397 const std::vector<CalleeSavedInfo> &CSI,
1405 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
1406 unsigned Reg = CSI[i].getReg();
1407 if (X86::GR64RegClass.
contains(Reg) ||
1416 unsigned Opc =
STI.
is64Bit() ? X86::POP64r : X86::POP32r;
1417 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
1418 unsigned Reg = CSI[i].getReg();
1419 if (!X86::GR64RegClass.
contains(Reg) &&
1438 if (TailCallReturnAddrDelta < 0) {
1449 TailCallReturnAddrDelta -
SlotSize,
true);
1462 if (
I->hasNestAttr())
1479 return Primary ? X86::R14 : X86::R13;
1481 return Primary ? X86::EBX : X86::EDI;
1486 return Primary ? X86::R11 : X86::R12;
1488 return Primary ? X86::R11D : X86::R12D;
1497 "nested function.");
1498 return Primary ? X86::EAX : X86::ECX;
1501 return Primary ? X86::EDX : X86::EAX;
1502 return Primary ? X86::ECX : X86::EAX;
1513 unsigned TlsReg, TlsOffset;
1518 "Scratch register is live-in");
1539 bool IsNested =
false;
1569 TlsOffset =
IsLP64 ? 0x70 : 0x40;
1572 TlsOffset = 0x60 + 90*8;
1586 if (CompareStackPointer)
1587 ScratchReg =
IsLP64 ? X86::RSP : X86::ESP;
1589 BuildMI(checkMBB, DL,
TII.
get(
IsLP64 ? X86::LEA64r : X86::LEA64_32r), ScratchReg).addReg(X86::RSP)
1600 TlsOffset = 0x48 + 90*4;
1613 if (CompareStackPointer)
1614 ScratchReg = X86::ESP;
1616 BuildMI(checkMBB, DL,
TII.
get(X86::LEA32r), ScratchReg).addReg(X86::ESP)
1621 BuildMI(checkMBB, DL,
TII.
get(X86::CMP32rm)).addReg(ScratchReg)
1626 unsigned ScratchReg2;
1628 if (CompareStackPointer) {
1631 SaveScratch2 =
false;
1643 "Scratch register is live-in and not saved");
1664 BuildMI(checkMBB, DL,
TII.
get(X86::JA_1)).addMBB(&PrologueMBB);
1672 const unsigned RegAX =
IsLP64 ? X86::RAX : X86::EAX;
1673 const unsigned Reg10 =
IsLP64 ? X86::R10 : X86::R10D;
1674 const unsigned Reg11 =
IsLP64 ? X86::R11 : X86::R11D;
1675 const unsigned MOVrr =
IsLP64 ? X86::MOV64rr : X86::MOV32rr;
1676 const unsigned MOVri =
IsLP64 ? X86::MOV64ri : X86::MOV32ri;
1720 .addExternalSymbol(
"__morestack");
1723 .addExternalSymbol(
"__morestack");
1727 BuildMI(allocMBB, DL,
TII.
get(X86::MORESTACK_RET_RESTORE_R10));
1761 const unsigned HipeLeafWords = 24;
1762 const unsigned CCRegisteredArgs =
Is64Bit ? 6 : 5;
1763 const unsigned Guaranteed = HipeLeafWords *
SlotSize;
1769 "HiPE prologue is only supported on Linux operating systems.");
1779 unsigned MoreStackForCalls = 0;
1782 MBBI != MBBE; ++MBBI)
1809 unsigned CalleeStkArity =
1811 if (HipeLeafWords - 1 > CalleeStkArity)
1812 MoreStackForCalls = std::max(MoreStackForCalls,
1813 (HipeLeafWords - 1 - CalleeStkArity) * SlotSize);
1815 MaxStack += MoreStackForCalls;
1820 if (MaxStack > Guaranteed) {
1834 unsigned ScratchReg, SPReg, PReg, SPLimitOffset;
1835 unsigned LEAop, CMPop, CALLop;
1839 LEAop = X86::LEA64r;
1840 CMPop = X86::CMP64rm;
1841 CALLop = X86::CALL64pcrel32;
1842 SPLimitOffset = 0x90;
1846 LEAop = X86::LEA32r;
1847 CMPop = X86::CMP32rm;
1848 CALLop = X86::CALLpcrel32;
1849 SPLimitOffset = 0x4c;
1854 "HiPE prologue scratch register is live-in");
1858 SPReg,
false, -MaxStack);
1861 .addReg(ScratchReg), PReg,
false, SPLimitOffset);
1862 BuildMI(stackCheckMBB, DL,
TII.
get(X86::JAE_1)).addMBB(&PrologueMBB);
1866 addExternalSymbol(
"inc_stack_0");
1868 SPReg,
false, -MaxStack);
1870 .addReg(ScratchReg), PReg,
false, SPLimitOffset);
1871 BuildMI(incStackMBB, DL,
TII.
get(X86::JLE_1)).addMBB(incStackMBB);
1887 unsigned Opcode = I->getOpcode();
1890 uint64_t Amount = !reserveCallFrame ? I->getOperand(0).getImm() : 0;
1891 uint64_t InternalAmt = (isDestroy || Amount) ? I->getOperand(1).getImm() : 0;
1894 if (!reserveCallFrame) {
1909 Amount -= InternalAmt;
1913 int Offset = isDestroy ? Amount : -Amount;
1914 BuildStackAdjustment(MBB, I, DL, Offset,
false);
1919 if (isDestroy && InternalAmt) {
1927 while (I != B && !std::prev(I)->isCall())
1929 BuildStackAdjustment(MBB, I, DL, -InternalAmt,
false);
1934 assert(MBB.
getParent() &&
"Block is not attached to a function!");
void push_front(MachineBasicBlock *MBB)
bool isInt< 32 >(int64_t x)
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
void setPhysRegUsed(unsigned Reg)
setPhysRegUsed - Mark the specified register used in this function.
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
const GlobalValue * getGlobal() const
livein_iterator livein_end() const
static bool isEAXLiveIn(MachineFunction &MF)
bool isTargetCygMing() const
bool isTargetMachO() const
bool hasBasePointer(const MachineFunction &MF) const
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
std::vector< unsigned >::const_iterator livein_iterator
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
iterator getFirstTerminator()
getFirstTerminator - returns an iterator to the first terminator instruction of this basic block...
cl::opt< bool > ForceStackAlign
static unsigned getLEArOpcode(unsigned IsLP64)
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
unsigned getArgumentStackSize() const
void verify(Pass *p=nullptr, const char *Banner=nullptr) const
verify - Run the current MachineFunction through the machine code verifier, useful for debugger use...
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
void addLiveIn(unsigned Reg)
Adds the specified register as a live in.
unsigned getCalleeSavedFrameSize() const
void setCalleeSavedFrameSize(unsigned bytes)
void setIsDead(bool Val=true)
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
X86FrameLowering(const X86Subtarget &STI, unsigned StackAlignOverride)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
StringRef getName() const
Return a constant reference to the value's name.
X86MachineFunctionInfo - This class is derived from MachineFunction and contains private X86 target-s...
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
bool Uses64BitFramePtr
True if the 64-bit frame or stack pointer should be used.
livein_iterator livein_begin() const
unsigned getSize() const
getSize - Return the size of the register in bytes, which is also the size of a stack slot allocated ...
bool isTargetNaCl64() const
int getTCReturnAddrDelta() const
unsigned getCallFrameDestroyOpcode() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
const HexagonInstrInfo * TII
bool isTargetDarwin() const
bool callsUnwindInit() const
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
static bool usesTheStack(const MachineFunction &MF)
usesTheStack - This function checks if any of the users of EFLAGS copies the EFLAGS.
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isInt< 8 >(int64_t x)
Reg
All possible values of the reg field in the ModR/M byte.
iterator_range< iterator > terminators()
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
void adjustForHiPEPrologue(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override
Erlang programs may need a special prologue to handle the stack size they might need at runtime...
static const uint64_t kSplitStackAvailable
bool hasDebugInfo() const
hasDebugInfo - Returns true if valid debug info is present.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
virtual unsigned getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
const MachineInstrBuilder & addImm(int64_t Val) const
addImm - Add a new immediate operand.
static reg_instr_iterator reg_instr_end()
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
defusechain_iterator - This class provides iterator support for machine operands in the function that...
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
bool needsFrameIndexResolution(const MachineFunction &MF) const override
int getFrameIndexReferenceFromSP(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
Same as above, except that the 'base register' will always be RSP, not RBP on x86.
bool hasStackObjects() const
Return true if there are any stack objects in this function.
bool isLiveIn(unsigned Reg) const
static unsigned getANDriOpcode(bool IsLP64, int64_t Imm)
bool is64Bit() const
Is this x86_64? (disregarding specific ABI / programming model)
unsigned LLVM_ATTRIBUTE_UNUSED_RESULT addFrameInst(const MCCFIInstruction &Inst)
static void mergeSPUpdatesUp(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, unsigned StackPtr, uint64_t *NumBytes=nullptr)
mergeSPUpdatesUp - Merge two stack-manipulating instructions upper iterator.
static unsigned calculateSetFPREG(uint64_t SPAdjust)
bool getHasSEHFramePtrSave() const
bool Is64Bit
Is64Bit implies that x86_64 instructions are available.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned getX86SubSuperRegister(unsigned Reg, MVT::SimpleValueType VT, bool High)
Returns the sub or super register of a specific X86 register.
unsigned getUndefRegState(bool B)
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
DBG_VALUE - a mapping of the llvm.dbg.value intrinsic.
unsigned getDefRegState(bool B)
bundle_iterator< MachineInstr, instr_iterator > iterator
bool hasStackMap() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool regsOverlap(unsigned regA, unsigned regB) const
regsOverlap - Returns true if the two registers are equal or alias each other.
bool isCallingConvWin64(CallingConv::ID CC) const
CodeModel::Model getCodeModel() const
Returns the code model.
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
unsigned getAlignment() const
getAlignment - Return the minimum required alignment for a register of this class.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
void setStackSize(uint64_t Size)
Set the size of the stack.
static bool is64Bit(const char *name)
livein_iterator livein_end() const
DebugLoc findDebugLoc(instr_iterator MBBI)
findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE instructions...
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
const MachineOperand & getOperand(unsigned i) const
bool isTargetWin32() const
bool shouldSplitStack()
Should we be emitting segmented stack stuff for the function.
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Load the specified register of the given register class from the specified stack frame index...
bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a epilogue for the target.
virtual unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const
If the specified machine instruction is a direct store to a stack slot, return the virtual or physica...
void setFlag(MIFlag Flag)
Set a MI flag.
MCRegAliasIterator enumerates all registers aliasing Reg.
static const MachineInstrBuilder & addRegOffset(const MachineInstrBuilder &MIB, unsigned Reg, bool isKill, int Offset)
addRegOffset - This function is used to add a memory reference of the form [Reg + Offset]...
reg_instr_iterator reg_instr_begin(unsigned RegNo) const
void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, DebugLoc DL) const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
int mergeSPUpdates(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, bool doMergeWithPrevious) const
Check the instruction before/after the passed instruction.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
BuildMI - Builder interface.
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
Store the specified register of the given register class to the specified stack frame index...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned getBaseRegister() const
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
unsigned getStackRegister() const
static unsigned getSUBriOpcode(unsigned IsLP64, int64_t Imm)
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
eliminateCallFramePseudoInstr - This method is called during prolog/epilog code insertion to eliminat...
bool callsEHReturn() const
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
static unsigned getADDriOpcode(unsigned IsLP64, int64_t Imm)
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool hasCalls() const
Return true if the current function has any function calls.
static unsigned findDeadCallerSavedReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const TargetRegisterInfo *TRI, bool Is64Bit)
findDeadCallerSavedReg - Return a caller-saved register that isn't live when it reaches the "return" ...
int getRestoreBasePointerOffset() const
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
const MCContext & getContext() const
bool isTarget64BitILP32() const
Is this x86_64 with the ILP32 programming model (x32 ABI)?
MachineOperand class - Representation of each machine instruction operand.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
Information about stack frame layout on the target.
void setUsesMorestackAddr(bool b)
bool isTargetLinux() const
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
livein_iterator livein_begin() const
void setOffsetAdjustment(int Adj)
Set the correction for frame offsets.
MachineFrameInfo * getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
X86_FastCall - 'fast' analog of X86_StdCall.
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simpli...
const TargetInstrInfo & TII
bool isUInt< 32 >(uint64_t x)
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
getMinimalPhysRegClass - Returns the Register Class of a physical register of the given type...
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool canUseLEAForSPInEpilogue(const MachineFunction &MF) const
Check that LEA can be used on SP in an epilogue sequence for MF.
bool isTargetDragonFly() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
const MCRegisterInfo * getRegisterInfo() const
Representation of each machine instruction.
int getSEHFramePtrSaveIndex() const
static bool terminatorsNeedFlagsAsInput(const MachineBasicBlock &MBB)
Check whether or not the terminators of MBB needs to read EFLAGS.
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override
Adjust the prologue to have the function use segmented stacks.
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
void ensureMaxAlignment(unsigned Align)
Make sure the function is at least Align bytes aligned.
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.
void emitStackProbeCall(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, DebugLoc DL) const
Emit a call to the target's stack probe function.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned char TargetFlags=0) const
bool isTarget64BitLP64() const
Is this x86_64 with the LP64 programming model (standard AMD64, no x32)?
bool isCall(QueryType Type=AnyInBundle) const
Fast - This calling convention attempts to make calls as fast as possible (e.g.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
bool needsStackRealignment(const MachineFunction &MF) const override
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset)
Create a spill slot at a fixed location on the stack.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
unsigned getSlotSize() const
static unsigned getSUBrrOpcode(unsigned isLP64)
int getFrameIndexOffsetFromSP(const MachineFunction &MF, int FI) const
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
const X86RegisterInfo * TRI
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 'eh_return' gcc dwarf builtin...
std::vector< std::pair< unsigned, unsigned > >::const_iterator livein_iterator
unsigned getReg() const
getReg - Returns the register number.
StringRef getValueAsString() const
Return the attribute's value as a string.
static unsigned getADDrrOpcode(unsigned isLP64)
bool isTargetWin64() const
static unsigned GetScratchRegister(bool Is64Bit, bool IsLP64, const MachineFunction &MF, bool Primary)
GetScratchRegister - Get a temp register for performing work in the segmented stack and the Erlang/Hi...
void emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, int64_t NumBytes, bool InEpilogue) const
Emit a series of instructions to increment / decrement the stack pointer by a constant value...
bool isTargetFreeBSD() const
static const unsigned FramePtr
BasicBlockListType::iterator iterator
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.
MachineModuleInfo & getMMI() const
unsigned getFrameRegister(const MachineFunction &MF) const override
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
int getFrameIndexOffset(const MachineFunction &MF, int FI) const override
getFrameIndexOffset - Returns the displacement from the frame register to the stack frame of the spec...
static bool HasNestArgument(const MachineFunction *MF)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
addReg - Add a new virtual register operand...
SlotIndex - An opaque wrapper around machine indexes.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
void addSuccessor(MachineBasicBlock *succ, uint32_t weight=0)
addSuccessor - Add succ as a successor of this MachineBasicBlock.
bool getRestoreBasePointer() const
MachineModuleInfo - This class contains meta information specific to a module.
bool usesWindowsCFI() const