Rename getEntryNode -> getEntryBlock()
[oota-llvm.git] / include / llvm / CodeGen / MachineBasicBlock.h
index 0f8a158c725bad2d64c5abe3c41a026ccf452181..96628ef09852f327151b61c065501162fa0ab63e 100644 (file)
@@ -1,34 +1,29 @@
-//===-- llvm/CodeGen/MachineCodeForBasicBlock.h -----------------*- C++ -*--=//
+//===-- llvm/CodeGen/MachineBasicBlock.h ------------------------*- C++ -*-===//
 // 
-// Purpose:
-//   Collect the sequence of machine instructions for a basic block.
-//===---------------------------------------------------------------------===//
+// Collect the sequence of machine instructions for a basic block.
+//
+//===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CODEGEN_MACHINECODEFORBASICBLOCK_H
-#define LLVM_CODEGEN_MACHINECODEFORBASICBLOCK_H
+#ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
+#define LLVM_CODEGEN_MACHINEBASICBLOCK_H
 
-#include "llvm/BasicBlock.h"
-#include "llvm/Annotation.h"
 #include <vector>
+class BasicBlock;
 class MachineInstr;
+template <typename T> struct ilist_traits;
 
-extern AnnotationID MCFBB_AID;
-
-class MachineCodeForBasicBlock: public Annotation {
+class MachineBasicBlock {
   std::vector<MachineInstr*> Insts;
+  MachineBasicBlock *Prev, *Next;
+  const BasicBlock *BB;
 public:
-  MachineCodeForBasicBlock();
-  ~MachineCodeForBasicBlock() {}
-  
-  // Static methods to retrieve or destroy the MachineCodeForBasicBlock
-  // object for a given basic block.
-  static MachineCodeForBasicBlock& get(const BasicBlock *bb) {
-    return *(MachineCodeForBasicBlock*)bb->getOrCreateAnnotation(MCFBB_AID);
-  }
+  MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb) {}
+  ~MachineBasicBlock() {}
   
-  static void destroy(const BasicBlock *bb) {
-    bb->deleteAnnotation(MCFBB_AID);
-  }
+  /// getBasicBlock - Return the LLVM basic block that this instance
+  /// corresponded to originally.
+  ///
+  const BasicBlock *getBasicBlock() const { return BB; }
   
   typedef std::vector<MachineInstr*>::iterator                iterator;
   typedef std::vector<MachineInstr*>::const_iterator    const_iterator;
@@ -69,6 +64,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; }
 };