Notify LiveRangeEdit of new virtual registers.

Add a delegate class to MachineRegisterInfo with a single virtual
function, MRI_NoteNewVirtualRegister(). Update LiveRangeEdit to inherit
from this delegate class and override the definition of the callback
with an implementation that tracks the newly created virtual registers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188435 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mark Lacey
2013-08-14 23:50:09 +00:00
parent 1feb5854ae
commit 03fe68e0a9
4 changed files with 50 additions and 5 deletions

View File

@@ -27,7 +27,17 @@ namespace llvm {
/// registers, including vreg register classes, use/def chains for registers,
/// etc.
class MachineRegisterInfo {
public:
class Delegate {
public:
virtual void MRI_NoteNewVirtualRegister(unsigned Reg) {}
virtual ~Delegate() {}
};
private:
const TargetMachine &TM;
Delegate *TheDelegate;
/// IsSSA - True when the machine function is in SSA form and virtual
/// registers have a single def.
@@ -116,6 +126,23 @@ public:
return TM.getRegisterInfo();
}
void resetDelegate(Delegate *delegate) {
// Ensure another delegate does not take over unless the current
// delegate first unattaches itself. If we ever need to multicast
// notifications, we will need to change to using a list.
assert(TheDelegate == delegate &&
"Only the current delegate can perform reset!");
TheDelegate = 0;
}
void setDelegate(Delegate *delegate) {
assert(delegate && !TheDelegate &&
"Attempted to set delegate to null, or to change it without "
"first resetting it!");
TheDelegate = delegate;
}
//===--------------------------------------------------------------------===//
// Function State
//===--------------------------------------------------------------------===//