aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2004-05-24 06:11:51 +0000
committerTanya Lattner <tonic@nondot.org>2004-05-24 06:11:51 +0000
commit792699c46ef9bfc47dd459bbfa7e71bcb2cee29a (patch)
tree09579fa1fb5054e308cfb202d2c63d643d9b9120 /include/llvm
parent2b90565e3df82377eaadff30ac0bc5fbb54e91e7 (diff)
downloadexternal_llvm-792699c46ef9bfc47dd459bbfa7e71bcb2cee29a.tar.gz
external_llvm-792699c46ef9bfc47dd459bbfa7e71bcb2cee29a.tar.bz2
external_llvm-792699c46ef9bfc47dd459bbfa7e71bcb2cee29a.zip
Added MachineFunction parent* to MachineBasicBlock. Customized ilist template
to set the parent when a MachineBasicBlock is added to a MachineFunction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13716 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/CodeGen/MachineBasicBlock.h7
-rw-r--r--include/llvm/CodeGen/MachineFunction.h33
2 files changed, 37 insertions, 3 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h
index a035ba1477..4dfda90ae8 100644
--- a/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/include/llvm/CodeGen/MachineBasicBlock.h
@@ -64,10 +64,11 @@ public:
std::vector<MachineBasicBlock *> Predecessors;
std::vector<MachineBasicBlock *> Successors;
int Number;
+ MachineFunction *Parent;
public:
MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb),
- Number(-1) {
+ Number(-1), Parent(0) {
Insts.parent = this;
}
~MachineBasicBlock() {}
@@ -79,8 +80,8 @@ public:
/// getParent - Return the MachineFunction containing this basic block.
///
- const MachineFunction *getParent() const;
- MachineFunction *getParent();
+ const MachineFunction *getParent() const { return Parent; }
+ MachineFunction *getParent() { return Parent; }
typedef ilist<MachineInstr>::iterator iterator;
typedef ilist<MachineInstr>::const_iterator const_iterator;
diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h
index cb9958bb1f..dcec822f8e 100644
--- a/include/llvm/CodeGen/MachineFunction.h
+++ b/include/llvm/CodeGen/MachineFunction.h
@@ -23,6 +23,39 @@
namespace llvm {
+// ilist_traits
+template <>
+class ilist_traits<MachineBasicBlock> {
+ // this is only set by the MachineFunction owning the ilist
+ friend class MachineFunction;
+ MachineFunction* parent;
+
+public:
+ ilist_traits<MachineBasicBlock>() : parent(0) { }
+
+ static MachineBasicBlock* getPrev(MachineBasicBlock* N) { return N->Prev; }
+ static MachineBasicBlock* getNext(MachineBasicBlock* N) { return N->Next; }
+
+ static const MachineBasicBlock*
+ getPrev(const MachineBasicBlock* N) { return N->Prev; }
+
+ static const MachineBasicBlock*
+ getNext(const MachineBasicBlock* N) { return N->Next; }
+
+ static void setPrev(MachineBasicBlock* N, MachineBasicBlock* prev) { N->Prev = prev; }
+ static void setNext(MachineBasicBlock* N, MachineBasicBlock* next) { N->Next = next; }
+
+ static MachineBasicBlock* createNode();
+ void addNodeToList(MachineBasicBlock* N);
+ void removeNodeFromList(MachineBasicBlock* N);
+ void transferNodesFromList(
+ iplist<MachineBasicBlock, ilist_traits<MachineBasicBlock> >& toList,
+ ilist_iterator<MachineBasicBlock> first,
+ ilist_iterator<MachineBasicBlock> last);
+};
+
+
+
class Function;
class TargetMachine;
class SSARegMap;