24 #define DEBUG_TYPE "frame-info" 53 bool Unused =
false) {
56 for (
unsigned i = 0; CSRegs[i]; ++i)
57 LiveRegs.
addReg(CSRegs[i]);
62 for (
unsigned Reg : RC) {
67 for (
unsigned Reg : RC) {
79 return AMDGPU::NoRegister;
86 MRI, LiveRegs, AMDGPU::SReg_32_XM0_XEXECRegClass,
true);
95 unsigned ScratchRsrcReg,
unsigned SPReg,
int FI) {
105 if (isUInt<12>(Offset)) {
106 BuildMI(MBB, I,
DebugLoc(), TII->get(AMDGPU::BUFFER_STORE_DWORD_OFFSET))
121 MF->
getRegInfo(), LiveRegs, AMDGPU::VGPR_32RegClass);
123 BuildMI(MBB, I,
DebugLoc(), TII->get(AMDGPU::V_MOV_B32_e32), OffsetReg)
126 BuildMI(MBB, I,
DebugLoc(), TII->get(AMDGPU::BUFFER_STORE_DWORD_OFFEN))
143 unsigned ScratchRsrcReg,
unsigned SPReg,
int FI) {
152 if (isUInt<12>(Offset)) {
154 TII->get(AMDGPU::BUFFER_LOAD_DWORD_OFFSET), SpillReg)
155 .addReg(ScratchRsrcReg)
168 MF->
getRegInfo(), LiveRegs, AMDGPU::VGPR_32RegClass);
170 BuildMI(MBB, I,
DebugLoc(), TII->get(AMDGPU::V_MOV_B32_e32), OffsetReg)
174 TII->get(AMDGPU::BUFFER_LOAD_DWORD_OFFEN), SpillReg)
216 Register FlatScrInitLo = TRI->getSubReg(FlatScratchInitReg, AMDGPU::sub0);
217 Register FlatScrInitHi = TRI->getSubReg(FlatScratchInitReg, AMDGPU::sub1);
224 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_ADD_U32), FlatScrInitLo)
225 .addReg(FlatScrInitLo)
226 .
addReg(ScratchWaveOffsetReg);
227 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_ADDC_U32), FlatScrInitHi)
228 .addReg(FlatScrInitHi)
230 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_SETREG_B32)).
231 addReg(FlatScrInitLo).
234 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_SETREG_B32)).
235 addReg(FlatScrInitHi).
241 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_ADD_U32), AMDGPU::FLAT_SCR_LO)
242 .addReg(FlatScrInitLo)
243 .
addReg(ScratchWaveOffsetReg);
244 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_ADDC_U32), AMDGPU::FLAT_SCR_HI)
245 .addReg(FlatScrInitHi)
254 BuildMI(MBB, I, DL, TII->get(AMDGPU::COPY), AMDGPU::FLAT_SCR_LO)
259 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_ADD_U32), FlatScrInitLo)
260 .addReg(FlatScrInitLo)
261 .
addReg(ScratchWaveOffsetReg);
264 BuildMI(MBB, I, DL, TII->get(AMDGPU::S_LSHR_B32), AMDGPU::FLAT_SCR_HI)
269 unsigned SIFrameLowering::getReservedPrivateSegmentBufferReg(
279 if (ScratchRsrcReg == AMDGPU::NoRegister ||
281 return AMDGPU::NoRegister;
285 return ScratchRsrcReg;
300 AllSGPR128s = AllSGPR128s.
slice(std::min(static_cast<unsigned>(AllSGPR128s.
size()), NumPreloaded));
314 return ScratchRsrcReg;
318 std::pair<unsigned, bool>
319 SIFrameLowering::getReservedPrivateSegmentWaveByteOffsetReg(
328 if (ScratchWaveOffsetReg == AMDGPU::NoRegister ||
330 return std::make_pair(AMDGPU::NoRegister,
false);
334 return std::make_pair(ScratchWaveOffsetReg,
false);
339 if (NumPreloaded > AllSGPRs.
size())
340 return std::make_pair(ScratchWaveOffsetReg,
false);
342 AllSGPRs = AllSGPRs.
slice(NumPreloaded);
358 unsigned ReservedRegCount = 13;
360 if (AllSGPRs.
size() < ReservedRegCount)
361 return std::make_pair(ScratchWaveOffsetReg,
false);
363 bool HandledScratchWaveOffsetReg =
365 bool FPAdjusted =
false;
371 if (!HandledScratchWaveOffsetReg) {
372 HandledScratchWaveOffsetReg =
true;
382 ScratchWaveOffsetReg =
Reg;
389 return std::make_pair(ScratchWaveOffsetReg, FPAdjusted);
394 assert(&MF.
front() == &MBB &&
"Shrink-wrapping not yet supported");
419 if (MFI->hasFlatScratchInit())
420 emitFlatScratchInit(ST, MF, MBB);
422 unsigned ScratchRsrcReg
423 = getReservedPrivateSegmentBufferReg(ST, TII, TRI, MFI, MF);
425 unsigned ScratchWaveOffsetReg;
427 std::tie(ScratchWaveOffsetReg, FPAdjusted) =
428 getReservedPrivateSegmentWaveByteOffsetReg(ST, TII, TRI, MFI, MF);
431 Register PreloadedScratchWaveOffsetReg = MFI->getPreloadedReg(
434 unsigned PreloadedPrivateBufferReg = AMDGPU::NoRegister;
435 if (ST.isAmdHsaOrMesa(F)) {
436 PreloadedPrivateBufferReg = MFI->getPreloadedReg(
440 bool OffsetRegUsed = ScratchWaveOffsetReg != AMDGPU::NoRegister &&
442 bool ResourceRegUsed = ScratchRsrcReg != AMDGPU::NoRegister &&
446 if (PreloadedScratchWaveOffsetReg == AMDGPU::NoRegister)
451 MRI.
addLiveIn(PreloadedScratchWaveOffsetReg);
452 MBB.
addLiveIn(PreloadedScratchWaveOffsetReg);
454 if (ResourceRegUsed && PreloadedPrivateBufferReg != AMDGPU::NoRegister) {
455 assert(ST.isAmdHsaOrMesa(F) || ST.isMesaGfxShader(F));
456 MRI.
addLiveIn(PreloadedPrivateBufferReg);
457 MBB.
addLiveIn(PreloadedPrivateBufferReg);
462 if (&OtherBB == &MBB)
465 if (OffsetRegUsed || FPAdjusted)
466 OtherBB.addLiveIn(ScratchWaveOffsetReg);
469 OtherBB.addLiveIn(ScratchRsrcReg);
478 bool CopyBuffer = ResourceRegUsed &&
479 PreloadedPrivateBufferReg != AMDGPU::NoRegister &&
480 ST.isAmdHsaOrMesa(F) &&
481 ScratchRsrcReg != PreloadedPrivateBufferReg;
486 bool CopyBufferFirst = TRI->isSubRegisterEq(PreloadedPrivateBufferReg,
487 ScratchWaveOffsetReg);
488 if (CopyBuffer && CopyBufferFirst) {
489 BuildMI(MBB, I, DL, TII->
get(AMDGPU::COPY), ScratchRsrcReg)
493 unsigned SPReg = MFI->getStackPtrOffsetReg();
494 assert(SPReg != AMDGPU::SP_REG);
497 const bool HasFP =
hasFP(MF);
499 if (HasFP || OffsetRegUsed) {
500 assert(ScratchWaveOffsetReg);
501 BuildMI(MBB, I, DL, TII->
get(AMDGPU::COPY), ScratchWaveOffsetReg)
502 .addReg(PreloadedScratchWaveOffsetReg, HasFP ?
RegState::Kill : 0);
505 if (CopyBuffer && !CopyBufferFirst) {
506 BuildMI(MBB, I, DL, TII->
get(AMDGPU::COPY), ScratchRsrcReg)
510 if (ResourceRegUsed) {
511 emitEntryFunctionScratchSetup(ST, MF, MBB, MFI, I,
512 PreloadedPrivateBufferReg, ScratchRsrcReg);
521 if (StackSize == 0) {
522 BuildMI(MBB, I, DL, TII->
get(AMDGPU::COPY), SPReg)
523 .addReg(MFI->getScratchWaveOffsetReg());
525 BuildMI(MBB, I, DL, TII->
get(AMDGPU::S_ADD_U32), SPReg)
526 .addReg(MFI->getScratchWaveOffsetReg())
527 .addImm(StackSize * ST.getWavefrontSize());
533 void SIFrameLowering::emitEntryFunctionScratchSetup(
const GCNSubtarget &ST,
536 unsigned ScratchRsrcReg)
const {
546 Register RsrcLo = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub0);
547 Register RsrcHi = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub1);
548 Register Rsrc01 = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub0_sub1);
550 const MCInstrDesc &SMovB32 = TII->get(AMDGPU::S_MOV_B32);
553 BuildMI(MBB, I, DL, SMovB32, RsrcHi)
557 const MCInstrDesc &GetPC64 = TII->get(AMDGPU::S_GETPC_B64);
558 BuildMI(MBB, I, DL, GetPC64, Rsrc01);
560 auto GitPtrLo = AMDGPU::SGPR0;
567 GitPtrLo = AMDGPU::SGPR8;
575 BuildMI(MBB, I, DL, SMovB32, RsrcLo)
582 const MCInstrDesc &LoadDwordX4 = TII->get(AMDGPU::S_LOAD_DWORDX4_IMM);
591 BuildMI(MBB, I, DL, LoadDwordX4, ScratchRsrcReg)
601 || (PreloadedPrivateBufferReg == AMDGPU::NoRegister)) {
603 const MCInstrDesc &SMovB32 = TII->get(AMDGPU::S_MOV_B32);
605 Register Rsrc2 = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub2);
606 Register Rsrc3 = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub3);
612 Register Rsrc01 = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub0_sub1);
615 const MCInstrDesc &Mov64 = TII->get(AMDGPU::S_MOV_B64);
617 BuildMI(MBB, I, DL, Mov64, Rsrc01)
621 const MCInstrDesc &LoadDwordX2 = TII->get(AMDGPU::S_LOAD_DWORDX2_IMM);
629 BuildMI(MBB, I, DL, LoadDwordX2, Rsrc01)
641 Register Rsrc0 = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub0);
642 Register Rsrc1 = TRI->getSubReg(ScratchRsrcReg, AMDGPU::sub1);
644 BuildMI(MBB, I, DL, SMovB32, Rsrc0)
648 BuildMI(MBB, I, DL, SMovB32, Rsrc1)
654 BuildMI(MBB, I, DL, SMovB32, Rsrc2)
655 .
addImm(Rsrc23 & 0xffffffff)
658 BuildMI(MBB, I, DL, SMovB32, Rsrc3)
702 unsigned ScratchExecCopy = AMDGPU::NoRegister;
713 if (!
Reg.FI.hasValue())
716 if (ScratchExecCopy == AMDGPU::NoRegister) {
717 if (LiveRegs.
empty()) {
729 const unsigned OrSaveExec = ST.
isWave32() ?
730 AMDGPU::S_OR_SAVEEXEC_B32 : AMDGPU::S_OR_SAVEEXEC_B64;
742 if (ScratchExecCopy != AMDGPU::NoRegister) {
744 unsigned ExecMov = ST.
isWave32() ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
745 unsigned Exec = ST.
isWave32() ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
746 BuildMI(MBB, MBBI, DL, TII->
get(ExecMov), Exec)
748 LiveRegs.
addReg(ScratchExecCopy);
758 assert(Spill.size() == 1);
762 BuildMI(MBB, MBBI, DL, TII->getMCOpcodeFromPseudo(AMDGPU::V_WRITELANE_B32),
769 if (TRI.needsStackRealignment(MF)) {
773 RoundedSize += Alignment;
774 if (LiveRegs.
empty()) {
781 MRI, LiveRegs, AMDGPU::SReg_32_XM0RegClass);
782 assert(ScratchSPReg != AMDGPU::NoRegister &&
787 BuildMI(MBB, MBBI, DL, TII->
get(AMDGPU::S_ADD_U32), ScratchSPReg)
791 BuildMI(MBB, MBBI, DL, TII->
get(AMDGPU::S_AND_B32), FramePtrReg)
796 }
else if ((HasFP =
hasFP(MF))) {
801 BuildMI(MBB, MBBI, DL, TII->
get(AMDGPU::COPY), FramePtrReg)
806 if (HasFP && RoundedSize != 0) {
807 BuildMI(MBB, MBBI, DL, TII->
get(AMDGPU::S_ADD_U32), StackPtrReg)
815 "Needed to save FP but didn't save it anywhere");
819 "Saved FP but didn't need it");
840 if (RoundedSize != 0 &&
hasFP(MF)) {
842 BuildMI(MBB, MBBI, DL, TII->
get(AMDGPU::S_SUB_U32), StackPtrReg)
862 assert(Spill.size() == 1);
863 BuildMI(MBB, MBBI, DL, TII->getMCOpcodeFromPseudo(AMDGPU::V_READLANE_B32),
865 .addReg(Spill[0].VGPR)
869 unsigned ScratchExecCopy = AMDGPU::NoRegister;
872 if (!
Reg.FI.hasValue())
876 if (ScratchExecCopy == AMDGPU::NoRegister) {
878 if (LiveRegs.
empty()) {
888 const unsigned OrSaveExec =
889 ST.
isWave32() ? AMDGPU::S_OR_SAVEEXEC_B32 : AMDGPU::S_OR_SAVEEXEC_B64;
891 BuildMI(MBB, MBBI, DL, TII->
get(OrSaveExec), ScratchExecCopy)
900 if (ScratchExecCopy != AMDGPU::NoRegister) {
902 unsigned ExecMov = ST.
isWave32() ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
903 unsigned Exec = ST.
isWave32() ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
904 BuildMI(MBB, MBBI, DL, TII->
get(ExecMov), Exec)
928 FramePointerSaveIndex && I != FramePointerSaveIndex) {
938 unsigned &FrameReg)
const {
956 "SGPR spill should have been removed in SILowerSGPRSpills");
962 assert(RS &&
"RegScavenger required if spilling");
966 TRI->getSpillSize(AMDGPU::SGPR_32RegClass), 0,
false);
970 TRI->getSpillSize(AMDGPU::SGPR_32RegClass),
971 TRI->getSpillAlignment(AMDGPU::SGPR_32RegClass),
1002 const bool WillHaveFP =
1009 SavedVGPRs.
reset(SSpill.VGPR);
1011 const bool HasFP = WillHaveFP ||
hasFP(MF);
1028 dbgs() <<
"Spilling FP to " <<
printReg(Spill.VGPR, TRI)
1029 <<
':' << Spill.Lane <<
'\n');
1046 dbgs() <<
"FP requires fallback spill to " <<
printReg(Spill.VGPR, TRI)
1047 <<
':' << Spill.Lane <<
'\n';);
1072 std::vector<CalleeSavedInfo> &CSI)
const {
1080 for (
auto &CS : CSI) {
1095 int64_t Amount = I->getOperand(0).getImm();
1097 return MBB.
erase(I);
1101 const DebugLoc &DL = I->getDebugLoc();
1102 unsigned Opc = I->getOpcode();
1103 bool IsDestroy = Opc == TII->getCallFrameDestroyOpcode();
1104 uint64_t CalleePopAmount = IsDestroy ? I->getOperand(1).getImm() : 0;
1109 Amount =
alignTo(Amount, Align);
1114 unsigned Op = IsDestroy ? AMDGPU::S_SUB_U32 : AMDGPU::S_ADD_U32;
1118 }
else if (CalleePopAmount != 0) {
1122 return MBB.
erase(I);
unsigned getFrameOffsetReg() const
unsigned getScratchWaveOffsetReg() const
constexpr bool isUInt< 32 >(uint64_t x)
void clearBitsInMask(const uint32_t *Mask, unsigned MaskWords=~0u)
clearBitsInMask - Clear any bits in this vector that are set in Mask.
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...
Interface definition for SIRegisterInfo.
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
bool hasStackMap() const
This method may be called any time after instruction selection is complete to determine if there is a...
unsigned reservedPrivateSegmentBufferReg(const MachineFunction &MF) const
Return the end register initially reserved for the scratch buffer in case spilling is needed...
AMDGPU specific subclass of TargetSubtarget.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
bool isAllocatable(unsigned PhysReg) const
isAllocatable - Returns true when PhysReg belongs to an allocatable register class and it hasn't been...
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 getStackPtrOffsetReg() const
void addLiveIn(unsigned Reg, unsigned vreg=0)
addLiveIn - Add the specified register as a live-in.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
bool hasImplicitBufferPtr() const
void emitEntryFunctionPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const
const SIInstrInfo * getInstrInfo() const override
bool hasMergedShaders() const
unsigned const TargetRegisterInfo * TRI
bool isSupportedStackID(TargetStackID::Value ID) const override
void setIsStackRealigned(bool Realigned=true)
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
void removeDeadFrameIndices(MachineFrameInfo &MFI)
Calling convention used for Mesa/AMDPAL geometry shaders.
const SIRegisterInfo & getRegisterInfo() const
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) 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 void buildPrologSpill(LivePhysRegs &LiveRegs, MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const SIInstrInfo *TII, unsigned SpillReg, unsigned ScratchRsrcReg, unsigned SPReg, int FI)
bool empty() const
Returns true if the set is empty.
void setScratchRSrcReg(unsigned Reg)
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
A description of a memory reference used in the backend.
bool isMesaGfxShader(const Function &F) const
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
const HexagonInstrInfo * TII
uint64_t getScratchRsrcWords23() const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
bool isEntryFunction() const
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
static bool allStackObjectsAreDead(const MachineFrameInfo &MFI)
ArrayRef< SpilledReg > getSGPRToVGPRSpills(int FrameIndex) const
The memory access is dereferenceable (i.e., doesn't trap).
static MCPhysReg findUnusedSGPRNonCalleeSaved(MachineRegisterInfo &MRI)
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 ...
static bool allSGPRSpillsAreDead(const MachineFrameInfo &MFI, Optional< int > FramePointerSaveIndex)
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
unsigned getGITPtrHigh() const
bool haveFreeLanesForSGPRSpill(const MachineFunction &MF, unsigned NumLane) const
returns true if NumLanes slots are available in VGPRs already used for SGPR spilling.
void setStackPtrOffsetReg(unsigned Reg)
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
const T & getValue() const LLVM_LVALUE_FUNCTION
int getObjectIndexBegin() const
Return the minimum frame object index.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
int getObjectIndexEnd() const
Return one past the maximum frame object index.
bool allocateSGPRSpillToVGPR(MachineFunction &MF, int FI)
Reserve a slice of a VGPR to support spilling for FrameIndex FI.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
Calling convention used for Mesa/AMDPAL compute shaders.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
unsigned getMaxNumSGPRs(unsigned WavesPerEU, bool Addressable) const
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
int64_t getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset)
bool isCompute(CallingConv::ID cc)
void clearBitsNotInMask(const uint32_t *Mask, unsigned MaskWords=~0u)
clearBitsNotInMask - Clear a bit in this vector for every '0' bit in Mask.
This file declares the machine register scavenger class.
const TargetRegisterInfo * getTargetRegisterInfo() const
void setFrameOffsetReg(unsigned Reg)
unsigned const MachineRegisterInfo * MRI
unsigned reservedPrivateSegmentWaveByteOffsetReg(const MachineFunction &MF) const
Return the end register initially reserved for the scratch wave offset in case spilling is needed...
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.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
void addLiveIns(const MachineBasicBlock &MBB)
Adds all live-in registers of basic block MBB.
static ArrayRef< MCPhysReg > getAllSGPR128(const GCNSubtarget &ST, const MachineFunction &MF)
bool any() const
any - Returns true if any bit is set.
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
void stepBackward(const MachineInstr &MI)
Simulates liveness when stepping backwards over an instruction(bundle).
static ArrayRef< MCPhysReg > getAllSGPRs(const GCNSubtarget &ST, const MachineFunction &MF)
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Generation getGeneration() const
ArrayRef< SGPRSpillVGPRCSR > getSGPRSpillVGPRs() const
void setScratchWaveOffsetReg(unsigned Reg)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
This class contains a discriminated union of information about pointers in memory operands...
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
The memory access writes data.
unsigned getWavefrontSize() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool available(const MachineRegisterInfo &MRI, MCPhysReg Reg) const
Returns true if register Reg and no aliasing register is in the set.
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
unsigned getScratchRSrcReg() const
Returns the physical register reserved for use as the resource descriptor for scratch accesses...
bool isStackRealigned() const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool hasSGPRInitBug() const
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void determineCalleeSavesSGPR(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
bool isPhysRegUsed(unsigned PhysReg) const
Return true if the specified register is modified or read in this function.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array...
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
bool flatScratchIsPointer() const
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Provides AMDGPU specific target descriptions.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Interface definition for SIInstrInfo.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
static void buildEpilogReload(LivePhysRegs &LiveRegs, MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const SIInstrInfo *TII, unsigned SpillReg, unsigned ScratchRsrcReg, unsigned SPReg, int FI)
unsigned SGPRForFPSaveRestoreCopy
If this is set, an SGPR used for save/restore of the register used for the frame pointer.
unsigned getImplicitBufferPtrUserSGPR() const
The memory access always returns the same value (or traps).
bool isAmdHsaOrMesa(const Function &F) const
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const TargetRegisterClass * getWaveMaskRegClass() const
uint8_t getStackID(int ObjectIdx) const
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Register getFrameRegister(const MachineFunction &MF) const override
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...
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
void addReg(MCPhysReg Reg)
Adds a physical register and all its sub-registers to the set.
unsigned getNumPreloadedSGPRs() const
static unsigned findScratchNonCalleeSaveRegister(MachineRegisterInfo &MRI, LivePhysRegs &LiveRegs, const TargetRegisterClass &RC, bool Unused=false)
void removeReg(MCPhysReg Reg)
Removes a physical register, all its sub-registers, and all its super-registers from the set...
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
Address space for constant memory (VTX2).
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
Optional< int > FramePointerSaveIndex
Wrapper class representing virtual and physical registers.
bool hasCalls() const
Return true if the current function has any function calls.
Register getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const
const SIRegisterInfo * getRegisterInfo() const override