Add non-const MachineBasicBlock::getParent() accessor method.
authorBrian Gaeke <gaeke@uiuc.edu>
Wed, 12 May 2004 21:35:22 +0000 (21:35 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Wed, 12 May 2004 21:35:22 +0000 (21:35 +0000)
MBBs start out as #-1. When a MBB is added to a MachineFunction, it
gets the next available unique MBB number. If it is removed from a
MachineFunction, it goes back to being #-1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13514 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineBasicBlock.cpp

index b9f11e8eb1fbaf57ddfea0c8730a3171c2de3c7f..eccf3895761394f3f193aa00ad99fd9c49cf66e7 100644 (file)
@@ -26,6 +26,25 @@ const MachineFunction *MachineBasicBlock::getParent() const {
   return &MachineFunction::get(getBasicBlock()->getParent());
 }
 
+MachineFunction *MachineBasicBlock::getParent() {
+  // Get the parent by getting the Function parent of the basic block, and
+  // getting the MachineFunction from it.
+  return &MachineFunction::get(getBasicBlock()->getParent());
+}
+
+// MBBs start out as #-1. When a MBB is added to a MachineFunction, it 
+// gets the next available unique MBB number. If it is removed from a
+// MachineFunction, it goes back to being #-1.
+void ilist_traits<MachineBasicBlock>::addNodeToList (MachineBasicBlock* N)
+{
+  N->Number = N->getParent ()->getNextMBBNumber ();
+}
+
+void ilist_traits<MachineBasicBlock>::removeNodeFromList (MachineBasicBlock* N)
+{
+  N->Number = -1;
+}
+
 
 MachineInstr* ilist_traits<MachineInstr>::createNode()
 {