32 { SystemZ::R2D, 0x10 },
33 { SystemZ::R3D, 0x18 },
34 { SystemZ::R4D, 0x20 },
35 { SystemZ::R5D, 0x28 },
36 { SystemZ::R6D, 0x30 },
37 { SystemZ::R7D, 0x38 },
38 { SystemZ::R8D, 0x40 },
39 { SystemZ::R9D, 0x48 },
40 { SystemZ::R10D, 0x50 },
41 { SystemZ::R11D, 0x58 },
42 { SystemZ::R12D, 0x60 },
43 { SystemZ::R13D, 0x68 },
44 { SystemZ::R14D, 0x70 },
45 { SystemZ::R15D, 0x78 },
46 { SystemZ::F0D, 0x80 },
47 { SystemZ::F2D, 0x88 },
48 { SystemZ::F4D, 0x90 },
49 { SystemZ::F6D, 0x98 }
53 {SystemZ::R4D, 0x00}, {SystemZ::R5D, 0x08}, {SystemZ::R6D, 0x10},
54 {SystemZ::R7D, 0x18}, {SystemZ::R8D, 0x20}, {SystemZ::R9D, 0x28},
55 {SystemZ::R10D, 0x30}, {SystemZ::R11D, 0x38}, {SystemZ::R12D, 0x40},
56 {SystemZ::R13D, 0x48}, {SystemZ::R14D, 0x50}, {SystemZ::R15D, 0x58}};
60 int LAO,
Align TransAl,
61 bool StackReal,
unsigned PointerSize)
63 PointerSize(PointerSize) {}
65std::unique_ptr<SystemZFrameLowering>
69 return std::make_unique<SystemZXPLINKFrameLowering>(PtrSz);
70 return std::make_unique<SystemZELFFrameLowering>(PtrSz);
74struct SZFrameSortingObj {
77 uint64_t ObjectSize = 0;
81typedef std::vector<SZFrameSortingObj> SZFrameObjVec;
92 if (ObjectsToAllocate.
size() <= 1)
95 for (
auto &Obj : ObjectsToAllocate) {
96 SortingObjects[Obj].IsValid =
true;
97 SortingObjects[Obj].ObjectIndex = Obj;
104 for (
auto &
MI :
MBB) {
105 if (
MI.isDebugInstr())
107 for (
unsigned I = 0, E =
MI.getNumOperands();
I != E; ++
I) {
113 SortingObjects[Index].IsValid) {
114 if (
TII->hasDisplacementPairInsn(
MI.getOpcode()))
115 SortingObjects[Index].DPairCount++;
117 SortingObjects[Index].D12Count++;
129 auto CmpD12 = [](
const SZFrameSortingObj &
A,
const SZFrameSortingObj &
B) {
131 if (!
A.IsValid || !
B.IsValid)
133 if (!
A.ObjectSize || !
B.ObjectSize)
134 return A.ObjectSize > 0;
135 uint64_t ADensityCmp =
A.D12Count *
B.ObjectSize;
136 uint64_t BDensityCmp =
B.D12Count *
A.ObjectSize;
137 if (ADensityCmp != BDensityCmp)
138 return ADensityCmp < BDensityCmp;
139 return A.DPairCount *
B.ObjectSize <
B.DPairCount *
A.ObjectSize;
146 for (
auto &Obj : SortingObjects) {
150 ObjectsToAllocate[Idx++] = Obj.ObjectIndex;
171 int64_t ThisVal = NumBytes;
173 Opcode = SystemZ::AGHI;
175 Opcode = SystemZ::AGFI;
177 int64_t MinVal = -
uint64_t(1) << 31;
179 if (ThisVal < MinVal)
181 else if (ThisVal > MaxVal)
188 MI->getOperand(3).setIsDead();
195 std::vector<CalleeSavedInfo> &CSI)
const {
203 unsigned HighGPR = SystemZ::R15D;
205 for (
auto &CS : CSI) {
209 if (SystemZ::GR64BitRegClass.
contains(Reg) && StartSPOffset >
Offset) {
216 CS.setFrameIdx(FrameIdx);
218 CS.setFrameIdx(INT32_MAX);
232 if (StartSPOffset >
Offset) {
233 LowGPR = Reg; StartSPOffset =
Offset;
242 CurrOffset += StartSPOffset;
244 for (
auto &CS : CSI) {
245 if (CS.getFrameIdx() != INT32_MAX)
249 unsigned Size =
TRI->getSpillSize(*RC);
251 assert(CurrOffset % 8 == 0 &&
252 "8-byte alignment required for for all register save slots");
253 int FrameIdx = MFFrame.CreateFixedSpillStackObject(
Size, CurrOffset);
254 CS.setFrameIdx(FrameIdx);
267 bool HasFP =
hasFP(MF);
281 SavedRegs.
set(SystemZ::R6D);
282 SavedRegs.
set(SystemZ::R7D);
288 SavedRegs.
set(SystemZ::R11D);
293 SavedRegs.
set(SystemZ::R14D);
300 for (
unsigned I = 0; CSRegs[
I]; ++
I) {
301 unsigned Reg = CSRegs[
I];
302 if (SystemZ::GR64BitRegClass.
contains(Reg) && SavedRegs.
test(Reg)) {
303 SavedRegs.
set(SystemZ::R15D);
322 RegSpillOffsets.grow(SystemZ::NUM_TARGET_REGS);
323 for (
const auto &Entry : ELFSpillOffsetTable)
324 RegSpillOffsets[Entry.Reg] = Entry.Offset;
332 unsigned GPR64,
bool IsImplicit) {
334 MBB.getParent()->getSubtarget().getRegisterInfo();
336 bool IsLive =
MBB.isLiveIn(GPR64) ||
MBB.isLiveIn(GPR32);
337 if (!IsLive || !IsImplicit) {
340 MBB.addLiveIn(GPR64);
360 "Should be saving %r15 and something else");
376 if (SystemZ::GR64BitRegClass.
contains(Reg))
389 if (SystemZ::FP64BitRegClass.
contains(Reg)) {
391 TII->storeRegToStackSlot(
MBB,
MBBI, Reg,
true,
I.getFrameIdx(),
392 &SystemZ::FP64BitRegClass,
Register());
394 if (SystemZ::VR128BitRegClass.
contains(Reg)) {
396 TII->storeRegToStackSlot(
MBB,
MBBI, Reg,
true,
I.getFrameIdx(),
397 &SystemZ::VR128BitRegClass,
Register());
413 bool HasFP =
hasFP(MF);
419 if (SystemZ::FP64BitRegClass.
contains(Reg))
420 TII->loadRegFromStackSlot(
MBB,
MBBI, Reg,
I.getFrameIdx(),
421 &SystemZ::FP64BitRegClass,
Register());
422 if (SystemZ::VR128BitRegClass.
contains(Reg))
423 TII->loadRegFromStackSlot(
MBB,
MBBI, Reg,
I.getFrameIdx(),
424 &SystemZ::VR128BitRegClass,
Register());
435 "Should be loading %r15 and something else");
445 MIB.
addReg(HasFP ? SystemZ::R11D : SystemZ::R15D);
451 if (Reg != RestoreGPRs.
LowGPR && Reg != RestoreGPRs.
HighGPR &&
452 SystemZ::GR64BitRegClass.contains(Reg))
476 int64_t MaxArgOffset = 0;
481 MaxArgOffset = std::max(MaxArgOffset, ArgOffset);
484 uint64_t MaxReach = StackSize + MaxArgOffset;
490 RS->addScavengingFrameIndex(
492 RS->addScavengingFrameIndex(
501 for (
auto &MO : MRI->use_nodbg_operands(SystemZ::R6D))
510 unsigned CFIIndex =
MBB.getParent()->addFrameInst(
532 assert(&MF.
front() == &
MBB &&
"Shrink-wrapping not yet supported");
541 bool HasFP =
hasFP(MF);
550 "Pre allocated stack space for GHC function is too small");
554 "In GHC calling convention a frame pointer is not supported");
578 .getSpecialRegisters()
597 if (
MBBI !=
MBB.end() &&
MBBI->getOpcode() == SystemZ::STMG)
603 for (
auto &Save : CSI) {
605 if (SystemZ::GR64BitRegClass.
contains(Reg)) {
606 int FI = Save.getFrameIdx();
620 bool HasStackObject =
false;
623 HasStackObject =
true;
626 if (HasStackObject || MFFrame.
hasCalls())
636 int64_t Delta = -int64_t(StackSize);
637 const unsigned ProbeSize = TLI.getStackProbeSize(MF);
663 SPOffsetFromCFA += Delta;
678 MBBJ.addLiveIn(SystemZ::R11D);
683 for (
auto &Save : CSI) {
685 if (SystemZ::FP64BitRegClass.
contains(Reg)) {
687 (
MBBI->getOpcode() == SystemZ::STD ||
688 MBBI->getOpcode() == SystemZ::STDY))
692 }
else if (SystemZ::VR128BitRegClass.
contains(Reg)) {
694 MBBI->getOpcode() == SystemZ::VST)
709 nullptr, DwarfReg, SPOffsetFromCFA +
Offset));
714 for (
auto CFIIndex : CFIIndexes) {
733 assert(
MBBI->isReturn() &&
"Can only insert epilogue into returning blocks");
735 uint64_t StackSize = MFFrame.getStackSize();
738 unsigned Opcode =
MBBI->getOpcode();
739 if (Opcode != SystemZ::LMG)
742 unsigned AddrOpNo = 2;
744 uint64_t
Offset = StackSize +
MBBI->getOperand(AddrOpNo + 1).getImm();
745 unsigned NewOpcode = ZII->getOpcodeForOffset(Opcode,
Offset);
750 uint64_t NumBytes =
Offset - 0x7fff8;
754 NewOpcode = ZII->getOpcodeForOffset(Opcode,
Offset);
755 assert(NewOpcode &&
"No restore instruction available");
758 MBBI->setDesc(ZII->get(NewOpcode));
759 MBBI->getOperand(AddrOpNo + 1).ChangeToImmediate(
Offset);
760 }
else if (StackSize) {
775 if (
MI.getOpcode() == SystemZ::PROBED_STACKALLOC) {
779 if (StackAllocMI ==
nullptr)
782 const unsigned ProbeSize = TLI.getStackProbeSize(MF);
783 uint64_t NumFullBlocks = StackSize / ProbeSize;
784 uint64_t Residual = StackSize % ProbeSize;
793 bool EmitCFI) ->
void {
796 SPOffsetFromCFA -=
Size;
802 BuildMI(InsMBB, InsPt,
DL, ZII->get(SystemZ::CG))
818 if (NumFullBlocks < 3) {
820 for (
unsigned int i = 0; i < NumFullBlocks; i++)
821 allocateAndProbe(*
MBB,
MBBI, ProbeSize,
true);
824 uint64_t LoopAlloc = ProbeSize * NumFullBlocks;
825 SPOffsetFromCFA -= LoopAlloc;
837 MBB->addSuccessor(LoopMBB);
842 allocateAndProbe(*
MBB,
MBB->end(), ProbeSize,
false);
854 allocateAndProbe(*
MBB,
MBBI, Residual,
true);
862 if (DoneMBB !=
nullptr) {
886 bool BackChain = Subtarget.hasBackChain();
887 bool SoftFloat = Subtarget.hasSoftFloat();
888 unsigned Offset = RegSpillOffsets[Reg];
890 if (SystemZ::GR64BitRegClass.
contains(Reg))
893 Offset += BackChain ? 24 : 32;
916 bool BackChain = Subtarget.hasBackChain();
917 bool SoftFloat = Subtarget.hasSoftFloat();
918 if (HasPackedStackAttr && BackChain && !SoftFloat)
921 return HasPackedStackAttr && CallConv;
928 RegSpillOffsets(-1) {
932 RegSpillOffsets.grow(SystemZ::NUM_TARGET_REGS);
933 for (
const auto &Entry : XPLINKSpillOffsetTable)
934 RegSpillOffsets[Entry.Reg] = Entry.Offset;
1000 std::vector<CalleeSavedInfo> &CSI)
const {
1005 auto &GRRegClass = SystemZ::GR64BitRegClass;
1022 CSI.back().setRestored(
false);
1025 CSI.push_back(
CalleeSavedInfo(Regs.getReturnFunctionAddressRegister()));
1029 if (
hasFP(MF) || Subtarget.hasBackChain())
1036 CSI.back().setRestored(
false);
1041 int LowRestoreOffset = INT32_MAX;
1043 int LowSpillOffset = INT32_MAX;
1045 int HighOffset = -1;
1050 for (
auto &CS : CSI) {
1052 int Offset = RegSpillOffsets[Reg];
1054 if (GRRegClass.contains(Reg)) {
1055 if (LowSpillOffset >
Offset) {
1059 if (CS.isRestored() && LowRestoreOffset >
Offset) {
1060 LowRestoreOffset =
Offset;
1061 LowRestoreGPR = Reg;
1064 if (
Offset > HighOffset) {
1076 CS.setFrameIdx(FrameIdx);
1082 Align Alignment =
TRI->getSpillAlign(*RC);
1083 unsigned Size =
TRI->getSpillSize(*RC);
1086 CS.setFrameIdx(FrameIdx);
1096 assert(LowSpillGPR &&
"Expected registers to spill");
1107 bool HasFP =
hasFP(MF);
1114 SavedRegs.
set(Regs.getFramePointerRegister());
1132 if (SpillGPRs.LowGPR) {
1133 assert(SpillGPRs.LowGPR != SpillGPRs.HighGPR &&
1134 "Should be saving multiple registers");
1144 MIB.
addReg(Regs.getStackPointerRegister());
1148 MIB.
addImm(SpillGPRs.GPROffset);
1152 auto &GRRegClass = SystemZ::GR64BitRegClass;
1155 if (GRRegClass.contains(Reg))
1167 if (SystemZ::FP64BitRegClass.
contains(Reg)) {
1169 TII->storeRegToStackSlot(
MBB,
MBBI, Reg,
true,
I.getFrameIdx(),
1170 &SystemZ::FP64BitRegClass,
Register());
1172 if (SystemZ::VR128BitRegClass.
contains(Reg)) {
1174 TII->storeRegToStackSlot(
MBB,
MBBI, Reg,
true,
I.getFrameIdx(),
1175 &SystemZ::VR128BitRegClass,
Register());
1200 if (SystemZ::FP64BitRegClass.
contains(Reg))
1201 TII->loadRegFromStackSlot(
MBB,
MBBI, Reg,
I.getFrameIdx(),
1202 &SystemZ::FP64BitRegClass,
Register());
1203 if (SystemZ::VR128BitRegClass.
contains(Reg))
1204 TII->loadRegFromStackSlot(
MBB,
MBBI, Reg,
I.getFrameIdx(),
1205 &SystemZ::VR128BitRegClass,
Register());
1211 if (RestoreGPRs.
LowGPR) {
1216 .
addReg(Regs.getStackPointerRegister())
1228 MIB.
addReg(Regs.getStackPointerRegister());
1245 assert(&MF.
front() == &
MBB &&
"Shrink-wrapping not yet supported");
1246 unsigned InstCount =
MBB.size();
1257 bool HasFP =
hasFP(MF);
1263 const uint64_t StackSize = MFFrame.getStackSize();
1265 if (ZFI->getSpillGPRRegs().LowGPR) {
1267 if ((
MBBI !=
MBB.end()) && ((
MBBI->getOpcode() == SystemZ::STMG))) {
1268 const int Operand = 3;
1271 Offset = Regs.getStackPointerBias() +
MBBI->getOperand(Operand).getImm();
1276 StoreInstr = &*
MBBI;
1286 int64_t Delta = -int64_t(StackSize);
1292 if (StoreInstr && HasFP) {
1314 const uint64_t GuardPageSize = 1024 * 1024;
1315 if (StackSize > GuardPageSize) {
1316 assert(StoreInstr &&
"Wrong insertion point");
1317 BuildMI(
MBB, InsertPt,
DL, ZII->get(SystemZ::XPLINK_STACKALLOC));
1324 Regs.getFramePointerRegister())
1325 .
addReg(Regs.getStackPointerRegister());
1331 B.addLiveIn(Regs.getFramePointerRegister());
1341 unsigned FixedRegs = ZFI->getVarArgsFirstGPR() + ZFI->getVarArgsFirstFPR();
1344 uint64_t StartOffset = MFFrame.getOffsetAdjustment() +
1345 MFFrame.getStackSize() + Regs.getCallFrameSize() +
1347 unsigned Reg = GPRs[
I];
1350 .
addReg(Regs.getStackPointerRegister())
1353 if (!
MBB.isLiveIn(Reg))
1364 if (InstCount <
MBB.size()) {
1379 assert(
MBBI->isReturn() &&
"Can only insert epilogue into returning blocks");
1381 uint64_t StackSize = MFFrame.getStackSize();
1383 unsigned SPReg = Regs.getStackPointerRegister();
1400 if (
MI.getOpcode() == SystemZ::XPLINK_STACKALLOC) {
1404 if (StackAllocMI ==
nullptr)
1407 bool NeedSaveSP =
hasFP(MF);
1408 bool NeedSaveArg = PrologMBB.
isLiveIn(SystemZ::R3D);
1409 const int64_t SaveSlotR3 = 2192;
1423 BuildMI(StackExtMBB,
DL, ZII->get(SystemZ::LG), SystemZ::R3D)
1428 BuildMI(StackExtMBB,
DL, ZII->get(SystemZ::CallBASR_STACKEXT))
1450 BuildMI(
MBB, StackAllocMI,
DL, ZII->get(SystemZ::LLGT), SystemZ::R3D)
1467 MBB.addSuccessor(NextMBB);
1468 MBB.addSuccessor(StackExtMBB);
1472 BuildMI(*NextMBB, StackAllocMI,
DL, ZII->get(SystemZ::LGR))
1480 BuildMI(*NextMBB, StackAllocMI,
DL, ZII->get(SystemZ::LGR))
1484 BuildMI(*NextMBB, StackAllocMI,
DL, ZII->get(SystemZ::LG))
1531 int64_t LargestArgOffset = 0;
1535 LargestArgOffset = std::max(ObjOffset, LargestArgOffset);
1539 uint64_t MaxReach = (StackSize + Regs.getCallFrameSize() +
1540 Regs.getStackPointerBias() + LargestArgOffset);
1567 StackSize += Regs->getCallFrameSize();
1578 SPOffset -= StackSize;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
Register const TargetRegisterInfo * TRI
static constexpr MCPhysReg SPReg
This file declares the machine register scavenger class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static void buildDefCFAReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned Reg, const SystemZInstrInfo *ZII)
static void buildCFAOffs(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, int Offset, const SystemZInstrInfo *ZII)
static bool isXPLeafCandidate(const MachineFunction &MF)
static void addSavedGPR(MachineBasicBlock &MBB, MachineInstrBuilder &MIB, unsigned GPR64, bool IsImplicit)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool test(unsigned Idx) const
Returns true if bit Idx is set.
BitVector & set()
Set all bits in the bitvector.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register, SMLoc Loc={})
.cfi_def_cfa_register modifies a rule for computing CFA.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
const MCRegisterInfo * getRegisterInfo() const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
MCRegister getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo.
virtual int64_t getDwarfRegNum(MCRegister Reg, bool isEH) const
Map a target register to an equivalent dwarf register number.
Wrapper class representing physical registers. Should be passed by value.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
MachineInstrBundleIterator< MachineInstr > iterator
LLVM_ABI bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
void setMaxCallFrameSize(uint64_t S)
LLVM_ABI int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
LLVM_ABI int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
bool hasCalls() const
Return true if the current function has any function calls.
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
LLVM_ABI uint64_t estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
void setStackID(int ObjectIdx, uint8_t ID)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
LLVM_ABI int CreateSpillStackObject(uint64_t Size, Align Alignment, TargetStackID::Value StackID=TargetStackID::Default)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
int getObjectIndexEnd() const
Return one past the maximum frame object index.
LLVM_ABI int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
uint8_t getStackID(int ObjectIdx) const
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
void setStackSize(uint64_t Size)
Set the size of the stack.
int getObjectIndexBegin() const
Return the minimum frame object index.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
void setOffsetAdjustment(int64_t Adj)
Set the correction for frame offsets.
unsigned addFrameInst(const MCCFIInstruction &Inst)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
void push_back(MachineBasicBlock *MBB)
MCContext & getContext() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
bool disableFramePointerElim() const
Returns true if frame pointer elimination should be disabled for this function.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineBasicBlock & front() const
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
const MachineInstrBuilder & setOperandDead(unsigned OpIdx) const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
A description of a memory reference used in the backend.
@ MOVolatile
The memory access is volatile.
@ MOLoad
The memory access reads data.
MachineOperand class - Representation of each machine instruction operand.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI bool isPhysRegModified(MCRegister PhysReg, bool SkipNoReturnDef=false) const
Return true if the specified register is modified in this function.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
static StackOffset getFixed(int64_t Fixed)
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBII, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const override
void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &ObjectsToAllocate) const override
Order the symbols in the local stack frame.
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
unsigned getBackchainOffset(MachineFunction &MF) const override
void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologMBB) const override
Replace a StackProbe stub (if any) with the actual probe code inline.
bool hasFPImpl(const MachineFunction &MF) const override
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
bool usePackedStack(MachineFunction &MF) const
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
SystemZELFFrameLowering(unsigned PointerSize)
unsigned getRegSpillOffset(MachineFunction &MF, Register Reg) const
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
static std::unique_ptr< SystemZFrameLowering > create(const SystemZSubtarget &STI)
void emitIncrement(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &DL, Register Reg, int64_t NumBytes, const TargetInstrInfo *TII) const
unsigned getPointerSize() const
SystemZFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl, bool StackReal, unsigned PointerSize)
Register getVarArgsFirstGPR() const
int getFramePointerSaveIndex() const
SystemZ::GPRRegs getRestoreGPRRegs() const
void setRestoreGPRRegs(Register Low, Register High, unsigned Offs)
void setFramePointerSaveIndex(int Idx)
SystemZ::GPRRegs getSpillGPRRegs() const
void setSpillGPRRegs(Register Low, Register High, unsigned Offs)
const SystemZInstrInfo * getInstrInfo() const override
const SystemZTargetLowering * getTargetLowering() const override
bool isTargetXPLINK64() const
SystemZCallingConventionRegisters * getSpecialRegisters() const
XPLINK64 calling convention specific use registers Particular to z/OS when in 64 bit mode.
void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologMBB) const override
Replace a StackProbe stub (if any) with the actual probe code inline.
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBII, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
int getOrCreateFramePointerSaveIndex(MachineFunction &MF) const override
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
void determineFrameLayout(MachineFunction &MF) const
SystemZXPLINKFrameLowering(unsigned PointerSize)
bool hasFPImpl(const MachineFunction &MF) const override
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
Information about stack frame layout on the target.
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
TargetFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl=Align(1), bool StackReal=true)
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
TargetInstrInfo - Interface to description of machine instruction set.
virtual bool hasInlineStackProbe(const MachineFunction &MF) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
virtual const TargetLowering * getTargetLowering() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ AnyReg
OBSOLETED - Used for stack based JavaScript calls.
@ GHC
Used by the Glasgow Haskell Compiler (GHC).
const int64_t ELFCallFrameSize
const int64_t ELFCFAOffsetFromInitialSP
MachineBasicBlock * splitBlockBefore(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
const unsigned CCMASK_CMP_GT
MachineBasicBlock * emitBlockAfter(MachineBasicBlock *MBB)
const unsigned CCMASK_ICMP
const unsigned XPLINK64NumArgGPRs
const MCPhysReg ELFArgGPRs[ELFNumArgGPRs]
const unsigned CCMASK_CMP_LT
const unsigned ELFNumArgGPRs
const MCPhysReg XPLINK64ArgGPRs[XPLINK64NumArgGPRs]
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
void stable_sort(R &&Range)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
@ Define
Register definition.
constexpr RegState getImplRegState(bool B)
constexpr RegState getKillRegState(bool B)
auto reverse(ContainerTy &&C)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void fullyRecomputeLiveIns(ArrayRef< MachineBasicBlock * > MBBs)
Convenience function for recomputing live-in's for a set of MBBs until the computation converges.
MCRegisterClass TargetRegisterClass
This struct is a compact representation of a valid (non-zero power of two) alignment.
This class contains a discriminated union of information about pointers in memory operands,...