[llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h MachineFunction.h
Tanya Brethour
tbrethou at cs.uiuc.edu
Mon May 24 01:14:02 PDT 2004
Changes in directory llvm/include/llvm/CodeGen:
MachineBasicBlock.h updated: 1.32 -> 1.33
MachineFunction.h updated: 1.33 -> 1.34
---
Log message:
Added MachineFunction parent* to MachineBasicBlock. Customized ilist template
to set the parent when a MachineBasicBlock is added to a MachineFunction.
---
Diffs of the changes: (+37 -3)
Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h
diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.32 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.33
--- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.32 Wed May 12 16:57:23 2004
+++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Mon May 24 01:11:51 2004
@@ -64,10 +64,11 @@
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 @@
/// 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;
Index: llvm/include/llvm/CodeGen/MachineFunction.h
diff -u llvm/include/llvm/CodeGen/MachineFunction.h:1.33 llvm/include/llvm/CodeGen/MachineFunction.h:1.34
--- llvm/include/llvm/CodeGen/MachineFunction.h:1.33 Wed May 12 16:35:21 2004
+++ llvm/include/llvm/CodeGen/MachineFunction.h Mon May 24 01:11:51 2004
@@ -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;
More information about the llvm-commits
mailing list