Add DebugLoc-aware constructors for SDNode derived
[oota-llvm.git] / include / llvm / CodeGen / MachineFunction.h
index 98f3a948394e86b00d6ece4d5444a2988122e6ec..0d5a71d142d7aafd3f7e400962b6a8bde2360871 100644 (file)
@@ -18,7 +18,8 @@
 #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
 #define LLVM_CODEGEN_MACHINEFUNCTION_H
 
-#include "llvm/ADT/alist.h"
+#include "llvm/ADT/ilist.h"
+#include "llvm/CodeGen/DebugLoc.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
 #include "llvm/Support/Annotation.h"
 #include "llvm/Support/Allocator.h"
 namespace llvm {
 
 class Function;
-class TargetMachine;
 class MachineRegisterInfo;
 class MachineFrameInfo;
 class MachineConstantPool;
 class MachineJumpTableInfo;
+class TargetMachine;
 
 template <>
-class alist_traits<MachineBasicBlock, MachineBasicBlock> {
-  typedef alist_iterator<MachineBasicBlock> iterator;
+struct ilist_traits<MachineBasicBlock>
+    : public ilist_default_traits<MachineBasicBlock> {
+  mutable MachineBasicBlock Sentinel;
 public:
+  MachineBasicBlock *createSentinel() const { return &Sentinel; }
+  void destroySentinel(MachineBasicBlock *) const {}
+
   void addNodeToList(MachineBasicBlock* MBB);
   void removeNodeFromList(MachineBasicBlock* MBB);
-  void transferNodesFromList(alist_traits<MachineBasicBlock> &,
-                             iterator,
-                             iterator) {}
   void deleteNode(MachineBasicBlock *MBB);
+private:
+  void createNode(const MachineBasicBlock &);
 };
 
 /// MachineFunctionInfo - This class can be derived from and used by targets to
@@ -87,13 +91,13 @@ class MachineFunction : private Annotation {
   // Allocation management for basic blocks in function.
   Recycler<MachineBasicBlock> BasicBlockRecycler;
 
-  // Allocation management for memoperands in function.
-  Recycler<MachineMemOperand> MemOperandRecycler;
-
   // List of machine basic blocks in function
-  typedef alist<MachineBasicBlock> BasicBlockListType;
+  typedef ilist<MachineBasicBlock> BasicBlockListType;
   BasicBlockListType BasicBlocks;
 
+  // Tracks debug locations.
+  DebugLocTracker DebugLocInfo;
+
 public:
   MachineFunction(const Function *Fn, const TargetMachine &TM);
   ~MachineFunction();
@@ -303,14 +307,14 @@ public:
   ///
   void DeleteMachineBasicBlock(MachineBasicBlock *MBB);
 
-  /// CreateMachineMemOperand - Allocate a new MachineMemOperand. Use this
-  /// instead of `new MachineMemOperand'.
-  ///
-  MachineMemOperand *CreateMachineMemOperand(const MachineMemOperand &MMO);
+  //===--------------------------------------------------------------------===//
+  // Debug location.
+  //
 
-  /// DeleteMachineMemOperand - Delete the given MachineMemOperand.
-  ///
-  void DeleteMachineMemOperand(MachineMemOperand *MMO);
+  /// getOrCreateDebugLocID - Look up the DebugLocTuple index with the given
+  /// source file, line, and column. If none currently exists, create add a new
+  /// new DebugLocTuple and insert it into the DebugIdMap.
+  unsigned getOrCreateDebugLocID(unsigned Src, unsigned Line, unsigned Col);
 };
 
 //===--------------------------------------------------------------------===//