forked from OSchip/llvm-project
RegScavenger: Add function to externally reserve a scavenging index
AMDGPU separately tracks the frame index we use for the emergency spill slot. In the case where we need to spill SGPRs to memory, we manually handle the save and restore. In other cases, the scavenger handles the spills normally. In a future change, I will need to add a second scavenging index in order to free a second register in case we are spilling to a large offset and also have to avoid clobbering a condition register (SCC). In the intersection of these two cases, we will end up recursively calling eliminateFrameIndex. We need to report to the scavenger that the first scavenging frame index is unavailable, and that the register is already used to avoid double spilling to the scavenging slot (and avoid clobbering the previously evicted register, and getting the same register for both scavenge calls). This is really ugly but I don't see a better way without requiring targets to be far more aware of how the scavenger iterator is advanced.
This commit is contained in:
parent
29f92da522
commit
5ecbcc207c
|
@ -70,6 +70,26 @@ class RegScavenger {
|
|||
public:
|
||||
RegScavenger() = default;
|
||||
|
||||
/// Record that \p Reg is in use at scavenging index \p FI. This is for
|
||||
/// targets which need to directly manage the spilling process, and need to
|
||||
/// update the scavenger's internal state. It's expected this be called a
|
||||
/// second time with \p Restore set to a non-null value, so that the
|
||||
/// externally inserted restore instruction resets the scavenged slot
|
||||
/// liveness when encountered.
|
||||
void assignRegToScavengingIndex(int FI, Register Reg,
|
||||
MachineInstr *Restore = nullptr) {
|
||||
for (ScavengedInfo &Slot : Scavenged) {
|
||||
if (Slot.FrameIndex == FI) {
|
||||
assert(!Slot.Reg || Slot.Reg == Reg);
|
||||
Slot.Reg = Reg;
|
||||
Slot.Restore = Restore;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
llvm_unreachable("did not find scavenging index");
|
||||
}
|
||||
|
||||
/// Start tracking liveness from the begin of basic block \p MBB.
|
||||
void enterBasicBlock(MachineBasicBlock &MBB);
|
||||
|
||||
|
|
Loading…
Reference in New Issue