summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAditya Nandakumar <aditya_nandakumar@apple.com>2018-09-20 23:01:56 +0000
committerAditya Nandakumar <aditya_nandakumar@apple.com>2018-09-20 23:01:56 +0000
commite5909431b5f3479dd713c7fe4919a028499dd709 (patch)
treef5f3097526c9958e916be55e0ba6370b6a3b8239 /llvm/lib/CodeGen
parent180cd0717fc7eac37d7f65d351f69747bd67ab2b (diff)
downloadbcm5719-llvm-e5909431b5f3479dd713c7fe4919a028499dd709.tar.gz
bcm5719-llvm-e5909431b5f3479dd713c7fe4919a028499dd709.zip
Add the ability to register callbacks for removal and insertion of MachineInstrs
https://reviews.llvm.org/D52127 This patch adds the ability to watch for insertions/deletions of MachineInstructions similar to MachineRegisterInfo. llvm-svn: 342696
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp5
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp13
2 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 3e040711052..49181e338a1 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -110,6 +110,7 @@ void ilist_traits<MachineInstr>::addNodeToList(MachineInstr *N) {
// use/def lists.
MachineFunction *MF = Parent->getParent();
N->AddRegOperandsToUseLists(MF->getRegInfo());
+ MF->handleInsertion(*N);
}
/// When we remove an instruction from a basic block list, we update its parent
@@ -118,8 +119,10 @@ void ilist_traits<MachineInstr>::removeNodeFromList(MachineInstr *N) {
assert(N->getParent() && "machine instruction not in a basic block");
// Remove from the use/def lists.
- if (MachineFunction *MF = N->getMF())
+ if (MachineFunction *MF = N->getMF()) {
+ MF->handleRemoval(*N);
N->RemoveRegOperandsFromUseLists(MF->getRegInfo());
+ }
N->setParent(nullptr);
}
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 1b15819cd50..81fc47bd573 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -99,6 +99,9 @@ static const char *getPropertyName(MachineFunctionProperties::Property Prop) {
llvm_unreachable("Invalid machine function property");
}
+// Pin the vtable to this file.
+void MachineFunction::Delegate::anchor() {}
+
void MachineFunctionProperties::print(raw_ostream &OS) const {
const char *Separator = "";
for (BitVector::size_type I = 0; I < Properties.size(); ++I) {
@@ -135,6 +138,16 @@ MachineFunction::MachineFunction(const Function &F, const TargetMachine &Target,
init();
}
+void MachineFunction::handleInsertion(const MachineInstr &MI) {
+ if (TheDelegate)
+ TheDelegate->MF_HandleInsertion(MI);
+}
+
+void MachineFunction::handleRemoval(const MachineInstr &MI) {
+ if (TheDelegate)
+ TheDelegate->MF_HandleRemoval(MI);
+}
+
void MachineFunction::init() {
// Assume the function starts in SSA form with correct liveness.
Properties.set(MachineFunctionProperties::Property::IsSSA);
OpenPOWER on IntegriCloud