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; }
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.
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;
}
/// 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;
// 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;
// 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.
~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.
#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"
// 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);
}
}
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() {
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));
/// 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,
}
void ilist_traits<MachineBasicBlock>::transferNodesFromList(
- iplist<MachineBasicBlock, ilist_traits<MachineBasicBlock> >& toList,
- ilist_iterator<MachineBasicBlock> first,
- ilist_iterator<MachineBasicBlock> last) {
- if (Parent != toList.Parent)
- for (; first != last; ++first)
- first->Parent = toList.Parent;
+ iplist<MachineBasicBlock, ilist_traits<MachineBasicBlock> >& toList,
+ ilist_iterator<MachineBasicBlock> first,
+ ilist_iterator<MachineBasicBlock> last) {
+ // If splicing withing the same function, no change.
+ if (Parent == toList.Parent) return;
+
+ for (; first != last; ++first)
+ first->setParent(toList.Parent);
}
MachineFunction::MachineFunction(const Function *F,
/// MachineInstr ctor - This constructor creates a dummy MachineInstr with
/// TID NULL and no operands.
MachineInstr::MachineInstr()
- : TID(0), NumImplicitOps(0), parent(0) {
+ : TID(0), NumImplicitOps(0), Parent(0) {
// Make sure that we get added to a machine basicblock
LeakDetector::addGarbageObject(this);
}
/// TargetInstrDescriptor or the numOperands if it is not zero. (for
/// instructions with variable number of operands).
MachineInstr::MachineInstr(const TargetInstrDescriptor &tid, bool NoImp)
- : TID(&tid), NumImplicitOps(0), parent(0) {
+ : TID(&tid), NumImplicitOps(0), Parent(0) {
if (!NoImp && TID->ImplicitDefs)
for (const unsigned *ImpDefs = TID->ImplicitDefs; *ImpDefs; ++ImpDefs)
NumImplicitOps++;
///
MachineInstr::MachineInstr(MachineBasicBlock *MBB,
const TargetInstrDescriptor &tid)
- : TID(&tid), NumImplicitOps(0), parent(0) {
+ : TID(&tid), NumImplicitOps(0), Parent(0) {
assert(MBB && "Cannot use inserting ctor with null basic block!");
if (TID->ImplicitDefs)
for (const unsigned *ImpDefs = TID->ImplicitDefs; *ImpDefs; ++ImpDefs)
}
// Set parent, next, and prev to null
- parent = 0;
- prev = 0;
- next = 0;
+ Parent = 0;
+ Prev = 0;
+ Next = 0;
}