diff options
author | Tanya Lattner <tonic@nondot.org> | 2004-05-24 06:11:51 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2004-05-24 06:11:51 +0000 |
commit | a578cb7a65662415a0321caf6cffe2fb526fe5e6 (patch) | |
tree | 0b12b15b873a688b138d00a1e03d373c5b17088b /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | a0390ec7f9c040a0e90b30368d42ca078fa3efaf (diff) | |
download | llvm-a578cb7a65662415a0321caf6cffe2fb526fe5e6.zip llvm-a578cb7a65662415a0321caf6cffe2fb526fe5e6.tar.gz llvm-a578cb7a65662415a0321caf6cffe2fb526fe5e6.tar.bz2 |
Added MachineFunction parent* to MachineBasicBlock. Customized ilist template
to set the parent when a MachineBasicBlock is added to a MachineFunction.
llvm-svn: 13716
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 64f735c4..c0b144d 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -20,29 +20,25 @@ #include "Support/LeakDetector.h" using namespace llvm; -const MachineFunction *MachineBasicBlock::getParent() const { - // Get the parent by getting the Function parent of the basic block, and - // getting the MachineFunction from it. - 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 (); + assert(N->Parent == 0 && "machine instruction already in a basic block"); + N->Parent = parent; + N->Number = parent->getNextMBBNumber(); + LeakDetector::removeGarbageObject(N); + + } void ilist_traits<MachineBasicBlock>::removeNodeFromList (MachineBasicBlock* N) { + assert(N->Parent != 0 && "machine instruction not in a basic block"); + N->Parent = 0; N->Number = -1; + LeakDetector::addGarbageObject(N); } @@ -93,8 +89,13 @@ void MachineBasicBlock::dump() const void MachineBasicBlock::print(std::ostream &OS) const { + if(!getParent()) { + OS << "Can't print out MachineBasicBlock because parent MachineFunction is null\n"; + return; + } const BasicBlock *LBB = getBasicBlock(); - OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n"; + if(LBB) + OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n"; for (const_iterator I = begin(); I != end(); ++I) { OS << "\t"; I->print(OS, getParent()->getTarget()); |