aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-31 04:56:33 +0000
committerChris Lattner <sabre@nondot.org>2007-12-31 04:56:33 +0000
commitf20c1a497fe3922ac718429d65a5fe396890575e (patch)
treed0b6a54ac22fe125c6bcad9a0bdaf41af2f9fd6a /lib/CodeGen/MachineBasicBlock.cpp
parent534bcfb270d25d2a29759d19981443fee7260e94 (diff)
downloadexternal_llvm-f20c1a497fe3922ac718429d65a5fe396890575e.zip
external_llvm-f20c1a497fe3922ac718429d65a5fe396890575e.tar.gz
external_llvm-f20c1a497fe3922ac718429d65a5fe396890575e.tar.bz2
properly encapsulate the parent field of MBB and MI with get/set accessors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45469 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp
index f539596..3b84d68 100644
--- a/lib/CodeGen/MachineBasicBlock.cpp
+++ b/lib/CodeGen/MachineBasicBlock.cpp
@@ -14,7 +14,6 @@
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/BasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/MRegisterInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetInstrInfo.h"
@@ -36,17 +35,17 @@ std::ostream& llvm::operator<<(std::ostream &OS, const MachineBasicBlock &MBB) {
// 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) {
- assert(N->Parent == 0 && "machine instruction already in a basic block");
- N->Parent = Parent;
+ assert(N->getParent() == 0 && "machine instruction already in a basic block");
+ N->setParent(Parent);
N->Number = Parent->addToMBBNumbering(N);
LeakDetector::removeGarbageObject(N);
}
void ilist_traits<MachineBasicBlock>::removeNodeFromList(MachineBasicBlock* N) {
- assert(N->Parent != 0 && "machine instruction not in a basic block");
- N->Parent->removeFromMBBNumbering(N->Number);
+ assert(N->getParent() != 0 && "machine instruction not in a basic block");
+ N->getParent()->removeFromMBBNumbering(N->Number);
N->Number = -1;
- N->Parent = 0;
+ N->setParent(0);
LeakDetector::addGarbageObject(N);
}
@@ -58,24 +57,26 @@ MachineInstr* ilist_traits<MachineInstr>::createSentinel() {
}
void ilist_traits<MachineInstr>::addNodeToList(MachineInstr* N) {
- assert(N->parent == 0 && "machine instruction already in a basic block");
- N->parent = parent;
+ assert(N->getParent() == 0 && "machine instruction already in a basic block");
+ N->setParent(parent);
LeakDetector::removeGarbageObject(N);
}
void ilist_traits<MachineInstr>::removeNodeFromList(MachineInstr* N) {
- assert(N->parent != 0 && "machine instruction not in a basic block");
- N->parent = 0;
+ assert(N->getParent() != 0 && "machine instruction not in a basic block");
+ N->setParent(0);
LeakDetector::addGarbageObject(N);
}
void ilist_traits<MachineInstr>::transferNodesFromList(
- iplist<MachineInstr, ilist_traits<MachineInstr> >& fromList,
- ilist_iterator<MachineInstr> first,
- ilist_iterator<MachineInstr> last) {
- if (parent != fromList.parent)
- for (; first != last; ++first)
- first->parent = parent;
+ iplist<MachineInstr, ilist_traits<MachineInstr> >& fromList,
+ ilist_iterator<MachineInstr> first,
+ ilist_iterator<MachineInstr> last) {
+ // Splice within the same MBB -> no change.
+ if (parent == fromList.parent) return;
+
+ for (; first != last; ++first)
+ first->setParent(parent);
}
MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
@@ -177,7 +178,8 @@ void MachineBasicBlock::removeSuccessor(MachineBasicBlock *succ) {
Successors.erase(I);
}
-MachineBasicBlock::succ_iterator MachineBasicBlock::removeSuccessor(succ_iterator I) {
+MachineBasicBlock::succ_iterator
+MachineBasicBlock::removeSuccessor(succ_iterator I) {
assert(I != Successors.end() && "Not a current successor!");
(*I)->removePredecessor(this);
return(Successors.erase(I));
@@ -229,8 +231,8 @@ void MachineBasicBlock::ReplaceUsesOfBlockWith(MachineBasicBlock *Old,
/// CFG to be inserted. If we have proven that MBB can only branch to DestA and
/// DestB, remove any other MBB successors from the CFG. DestA and DestB can
/// be null.
-/// Besides DestA and DestB, retain other edges leading to LandingPads (currently
-/// there can be only one; we don't check or require that here).
+/// Besides DestA and DestB, retain other edges leading to LandingPads
+/// (currently there can be only one; we don't check or require that here).
/// Note it is possible that DestA and/or DestB are LandingPads.
bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
MachineBasicBlock *DestB,