mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-13 09:33:50 +00:00
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:
parent
534bcfb270
commit
f20c1a497f
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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,
|
||||
|
@ -111,12 +111,14 @@ MachineBasicBlock* ilist_traits<MachineBasicBlock>::createSentinel() {
|
||||
}
|
||||
|
||||
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,
|
||||
|
@ -136,7 +136,7 @@ void MachineOperand::print(std::ostream &OS, const TargetMachine *TM) const {
|
||||
/// 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);
|
||||
}
|
||||
@ -155,7 +155,7 @@ void MachineInstr::addImplicitDefUseOperands() {
|
||||
/// 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++;
|
||||
@ -174,7 +174,7 @@ MachineInstr::MachineInstr(const TargetInstrDescriptor &tid, bool NoImp)
|
||||
///
|
||||
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)
|
||||
@ -203,9 +203,9 @@ MachineInstr::MachineInstr(const MachineInstr &MI) {
|
||||
}
|
||||
|
||||
// Set parent, next, and prev to null
|
||||
parent = 0;
|
||||
prev = 0;
|
||||
next = 0;
|
||||
Parent = 0;
|
||||
Prev = 0;
|
||||
Next = 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user