Add BasicBlock list to MchineFunction that will eventually be the only
authorChris Lattner <sabre@nondot.org>
Mon, 28 Oct 2002 02:08:43 +0000 (02:08 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 28 Oct 2002 02:08:43 +0000 (02:08 +0000)
way to access MachineBasicBlocks.  For now, it is never filled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4324 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineBasicBlock.h
include/llvm/CodeGen/MachineFunction.h

index 2b1064dca576991b0dbc9e5796ac406b51ca1bf1..aa32a8110988819cccba23a48663f94f975fefec 100644 (file)
 #include <vector>
 class BasicBlock;
 class MachineInstr;
+template <typename T> struct ilist_traits;
 
 extern AnnotationID MCFBB_AID;
 
 class MachineBasicBlock : public Annotation {
   std::vector<MachineInstr*> Insts;
+  MachineBasicBlock *Prev, *Next;
 public:
   MachineBasicBlock() : Annotation(MCFBB_AID) {}
   ~MachineBasicBlock() {}
@@ -70,6 +72,14 @@ public:
     Insts.pop_back();
     return R;
   }
+
+private:   // Methods used to maintain doubly linked list of blocks...
+  friend class ilist_traits<MachineBasicBlock>;
+
+  MachineBasicBlock *getPrev() const { return Prev; }
+  MachineBasicBlock *getNext() const { return Next; }
+  void setPrev(MachineBasicBlock *P) { Prev = P; }
+  void setNext(MachineBasicBlock *N) { Next = N; }
 };
 
 
index 64cd4b56618030ced21c2a580dc7f0aeb8f02723..131b0359f76e1b532af025e0c13a61d92b94ba4d 100644 (file)
@@ -12,7 +12,9 @@
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "Support/NonCopyable.h"
 #include "Support/HashExtras.h"
-#include <Support/hash_set>
+#include "Support/hash_set"
+#include "Support/ilist"
+
 class Value;
 class Function;
 class Constant;
@@ -24,11 +26,14 @@ Pass *createMachineCodeConstructionPass(TargetMachine &Target);
 Pass *createMachineCodeDestructionPass();
 
 class MachineFunction : private Annotation {
-  hash_set<const Constant*> constantsForConstPool;
-  hash_map<const Value*, int> offsets;
-  const         Function* method;
+  const Function *method;
+
+  // List of machine basic blocks in function
+  iplist<MachineBasicBlock> BasicBlocks;
 
   // FIXME: State should be held elsewhere...
+  hash_set<const Constant*> constantsForConstPool;
+  hash_map<const Value*, int> offsets;
   unsigned     staticStackSize;
   unsigned     automaticVarsSize;
   unsigned     regSpillsSize;