make MachineFunction keep track of its ID and make
[oota-llvm.git] / include / llvm / CodeGen / MachineModuleInfo.h
index e5a962d26b7a8886408ec3d9ba2e79d42d9b9b2b..d36502985a59f4475d98f5ed7dbe35962a23297a 100644 (file)
@@ -32,7 +32,7 @@
 #define LLVM_CODEGEN_MACHINEMODULEINFO_H
 
 #include "llvm/Support/Dwarf.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/System/DataTypes.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/UniqueVector.h"
 #include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/GlobalValue.h"
 #include "llvm/Pass.h"
+#include "llvm/Metadata.h"
+#include "llvm/Support/ValueHandle.h"
 
 namespace llvm {
 
 //===----------------------------------------------------------------------===//
 // Forward declarations.
 class Constant;
+class MDNode;
 class GlobalVariable;
 class MachineBasicBlock;
 class MachineFunction;
@@ -133,18 +136,21 @@ class MachineModuleInfo : public ImmutablePass {
   /// llvm.compiler.used.
   SmallPtrSet<const Function *, 32> UsedFunctions;
 
-  /// UsedDbgLabels - labels are used by debug info entries.
-  SmallSet<unsigned, 8> UsedDbgLabels;
-
   bool CallsEHReturn;
   bool CallsUnwindInit;
  
   /// DbgInfoAvailable - True if debugging information is available
   /// in this module.
   bool DbgInfoAvailable;
+
 public:
   static char ID; // Pass identification, replacement for typeid
 
+  typedef std::pair<unsigned, TrackingVH<MDNode> > UnsignedAndMDNodePair;
+  typedef SmallVector< std::pair<TrackingVH<MDNode>, UnsignedAndMDNodePair>, 4>
+    VariableDbgInfoMapTy;
+  VariableDbgInfoMapTy VariableDbgInfo;
+
   MachineModuleInfo();
   ~MachineModuleInfo();
   
@@ -153,7 +159,7 @@ public:
 
   /// BeginFunction - Begin gathering function meta information.
   ///
-  void BeginFunction(MachineFunction *MF);
+  void BeginFunction(MachineFunction *) {}
   
   /// EndFunction - Discard function meta information.
   ///
@@ -166,9 +172,6 @@ public:
   Ty &getObjFileInfo() {
     if (ObjFileMMI == 0)
       ObjFileMMI = new Ty(*this);
-    
-    assert((void*)dynamic_cast<Ty*>(ObjFileMMI) == (void*)ObjFileMMI &&
-           "Invalid concrete type or multiple inheritence for getInfo");
     return *static_cast<Ty*>(ObjFileMMI);
   }
   
@@ -224,19 +227,6 @@ public:
     return LabelID ? LabelIDList[LabelID - 1] : 0;
   }
 
-  /// isDbgLabelUsed - Return true if label with LabelID is used by
-  /// DwarfWriter.
-  bool isDbgLabelUsed(unsigned LabelID) {
-    return UsedDbgLabels.count(LabelID);
-  }
-  
-  /// RecordUsedDbgLabel - Mark label with LabelID as used. This is used
-  /// by DwarfWriter to inform DebugLabelFolder that certain labels are
-  /// not to be deleted.
-  void RecordUsedDbgLabel(unsigned LabelID) {
-    UsedDbgLabels.insert(LabelID);
-  }
-
   /// getFrameMoves - Returns a reference to a list of moves done in the current
   /// function's prologue.  Used to construct frame maps for debug and exception
   /// handling comsumers.
@@ -325,6 +315,14 @@ public:
   /// of one is required to emit exception handling info.
   Function *getPersonality() const;
 
+  /// setVariableDbgInfo - Collect information used to emit debugging information
+  /// of a variable.
+  void setVariableDbgInfo(MDNode *N, unsigned Slot, MDNode *Scope) {
+    VariableDbgInfo.push_back(std::make_pair(N, std::make_pair(Slot, Scope)));
+  }
+
+  VariableDbgInfoMapTy &getVariableDbgInfo() {  return VariableDbgInfo;  }
+
 }; // End class MachineModuleInfo
 
 } // End llvm namespace