-//===-- llvm/CodeGen/MachineBasicBlock.h ------------------------*- C++ -*--=//
+//===-- llvm/CodeGen/MachineBasicBlock.h ------------------------*- C++ -*-===//
//
// Collect the sequence of machine instructions for a basic block.
//
-//===---------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_MACHINEBASICBLOCK_H
#define LLVM_CODEGEN_MACHINEBASICBLOCK_H
-#include "llvm/BasicBlock.h"
+#include <vector>
+class BasicBlock;
class MachineInstr;
+template <typename T> struct ilist_traits;
-extern AnnotationID MCFBB_AID;
-
-// FIXME: this should go away soon
-class MachineBasicBlock;
-typedef MachineBasicBlock MachineCodeForBasicBlock;
-
-class MachineBasicBlock: public Annotation {
+class MachineBasicBlock {
std::vector<MachineInstr*> Insts;
+ MachineBasicBlock *Prev, *Next;
+ const BasicBlock *BB;
public:
- MachineBasicBlock();
+ MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb) {}
~MachineBasicBlock() {}
- // Static methods to retrieve or destroy the MachineBasicBlock
- // object for a given basic block.
- static MachineBasicBlock& get(const BasicBlock *bb) {
- return *(MachineBasicBlock*)bb->getOrCreateAnnotation(MCFBB_AID);
- }
-
- 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;
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; }
};