diff options
author | Brian Gaeke <gaeke@uiuc.edu> | 2004-05-12 21:35:22 +0000 |
---|---|---|
committer | Brian Gaeke <gaeke@uiuc.edu> | 2004-05-12 21:35:22 +0000 |
commit | cb5d22a0cb353afaac80c4694815730633f220a8 (patch) | |
tree | ca73e0dfdc5cd16de04e3d848062ab5573679f6a /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 379e609e3d2b3b859715f29cb4317c1ec4964267 (diff) | |
download | bcm5719-llvm-cb5d22a0cb353afaac80c4694815730633f220a8.tar.gz bcm5719-llvm-cb5d22a0cb353afaac80c4694815730633f220a8.zip |
Add non-const MachineBasicBlock::getParent() accessor method.
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.
llvm-svn: 13514
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index b9f11e8eb1f..eccf3895761 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -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() { |