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
This commit is contained in:
Chris Lattner
2007-12-31 04:56:33 +00:00
parent 534bcfb270
commit f20c1a497f
5 changed files with 53 additions and 49 deletions

View File

@@ -33,17 +33,17 @@ protected:
public:
ilist_traits<MachineInstr>() : parent(0) { }
static MachineInstr* getPrev(MachineInstr* N) { return N->prev; }
static MachineInstr* getNext(MachineInstr* N) { return N->next; }
static MachineInstr* getPrev(MachineInstr* N) { return N->Prev; }
static MachineInstr* getNext(MachineInstr* N) { return N->Next; }
static const MachineInstr*
getPrev(const MachineInstr* N) { return N->prev; }
getPrev(const MachineInstr* N) { return N->Prev; }
static const MachineInstr*
getNext(const MachineInstr* N) { return N->next; }
getNext(const MachineInstr* N) { return N->Next; }
static void setPrev(MachineInstr* N, MachineInstr* prev) { N->prev = prev; }
static void setNext(MachineInstr* N, MachineInstr* next) { N->next = next; }
static void setPrev(MachineInstr* N, MachineInstr* prev) { N->Prev = prev; }
static void setNext(MachineInstr* N, MachineInstr* next) { N->Next = next; }
static MachineInstr* createSentinel();
static void destroySentinel(MachineInstr *MI) { delete MI; }
@@ -63,7 +63,9 @@ class MachineBasicBlock {
MachineBasicBlock *Prev, *Next;
const BasicBlock *BB;
int Number;
MachineFunction *Parent;
MachineFunction *xParent;
void setParent(MachineFunction *P) { xParent = P; }
/// Predecessors/Successors - Keep track of the predecessor / successor
/// basicblocks.
@@ -79,10 +81,8 @@ class MachineBasicBlock {
bool IsLandingPad;
public:
explicit MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0),
BB(bb), Number(-1),
Parent(0),
IsLandingPad(false) {
explicit MachineBasicBlock(const BasicBlock *bb = 0)
: Prev(0), Next(0), BB(bb), Number(-1), xParent(0), IsLandingPad(false) {
Insts.parent = this;
}
@@ -95,8 +95,8 @@ public:
/// getParent - Return the MachineFunction containing this basic block.
///
const MachineFunction *getParent() const { return Parent; }
MachineFunction *getParent() { return Parent; }
const MachineFunction *getParent() const { return xParent; }
MachineFunction *getParent() { return xParent; }
typedef ilist<MachineInstr>::iterator iterator;
typedef ilist<MachineInstr>::const_iterator const_iterator;

View File

@@ -34,8 +34,8 @@ class MachineInstr {
// are determined at construction time).
std::vector<MachineOperand> Operands; // the operands
MachineInstr* prev, *next; // links for our intrusive list
MachineBasicBlock* parent; // pointer to the owning basic block
MachineInstr *Prev, *Next; // Links for MBB's intrusive list.
MachineBasicBlock *Parent; // Pointer to the owning basic block.
// OperandComplete - Return true if it's illegal to add a new operand
bool OperandsComplete() const;
@@ -45,7 +45,7 @@ class MachineInstr {
// Intrusive list support
friend struct ilist_traits<MachineInstr>;
void setParent(MachineBasicBlock *P) { Parent = P; }
public:
/// MachineInstr ctor - This constructor creates a dummy MachineInstr with
/// TID NULL and no operands.
@@ -64,8 +64,8 @@ public:
~MachineInstr();
const MachineBasicBlock* getParent() const { return parent; }
MachineBasicBlock* getParent() { return parent; }
const MachineBasicBlock* getParent() const { return Parent; }
MachineBasicBlock* getParent() { return Parent; }
/// getInstrDescriptor - Returns the target instruction descriptor of this
/// MachineInstr.