Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions llvm/include/llvm/CodeGen/MachineInstrBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,21 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
.setMMRAMetadata(MIMD.getMMRAMetadata());
}

/// This version of the builder inserts the newly-built instruction after the
/// given position in the given MachineBasicBlock, and does NOT take a
/// destination register.
inline MachineInstrBuilder BuildMIAfter(MachineBasicBlock &BB,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being addressed separately #151607

MachineBasicBlock::iterator I,
const MIMetadata &MIMD,
const MCInstrDesc &MCID) {
MachineFunction &MF = *BB.getParent();
MachineInstr *MI = MF.CreateMachineInstr(MCID, MIMD.getDL());
BB.insertAfter(I, MI);
return MachineInstrBuilder(MF, MI)
.setPCSections(MIMD.getPCSections())
.setMMRAMetadata(MIMD.getMMRAMetadata());
}

inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
MachineBasicBlock::instr_iterator I,
const MIMetadata &MIMD,
Expand Down
31 changes: 31 additions & 0 deletions llvm/lib/Target/AMDGPU/GCNRegPressure.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,37 @@ struct GCNRegPressure {
DynamicVGPRBlockSize));
}

unsigned getVGPRSpills(MachineFunction &MF) {
const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
if (!ST.hasGFX90AInsts())
return 0;

auto MaxVectorRegs = ST.getMaxNumVectorRegs(MF.getFunction());
unsigned ArchVGPRThreshold = MaxVectorRegs.first;
unsigned AGPRThreshold = MaxVectorRegs.second;

unsigned ArchPressure = getArchVGPRNum();
unsigned AGPRPressure = getAGPRNum();

unsigned ArchSpill = ArchPressure > ArchVGPRThreshold
? (ArchPressure - ArchVGPRThreshold)
: 0;
unsigned AGPRSpill =
AGPRPressure > AGPRThreshold ? (AGPRPressure - AGPRThreshold) : 0;

unsigned UnifiedSpill = 0;

if (ST.hasGFX90AInsts()) {
unsigned CombinedThreshold = ST.getMaxNumVGPRs(MF);
unsigned UnifiedPressure = getVGPRNum(true);
UnifiedSpill = UnifiedPressure > CombinedThreshold
? (UnifiedPressure - CombinedThreshold)
: 0;
}

return std::max(UnifiedSpill, (ArchSpill + AGPRSpill));
}

void inc(unsigned Reg,
LaneBitmask PrevMask,
LaneBitmask NewMask,
Expand Down
Loading