Strip trailing whitespace.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.h
index 18afbdaab3ab593b7f6338c6a48e31cf8de8973d..d312eed8123f8480df812896d676a06d2b82315b 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/UniqueVector.h"
 #include <string>
@@ -34,7 +35,7 @@ class DbgScope;
 class DbgConcreteScope;
 class MachineFrameInfo;
 class MachineModuleInfo;
-class TargetAsmInfo;
+class MCAsmInfo;
 class Timer;
 
 //===----------------------------------------------------------------------===//
@@ -69,9 +70,8 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   ///
   SmallVector<CompileUnit *, 8> CompileUnits;
 
-  /// MainCU - Some platform prefers one compile unit per .o file. In such
-  /// cases, all dies are inserted in MainCU.
-  CompileUnit *MainCU;
+  /// ModuleCU - All DIEs are inserted in ModuleCU.
+  CompileUnit *ModuleCU;
 
   /// AbbreviationsSet - Used to uniquely define abbreviations.
   ///
@@ -120,7 +120,7 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
 
   /// SectionMap - Provides a unique id per text section.
   ///
-  UniqueVector<const Section*> SectionMap;
+  UniqueVector<const MCSection*> SectionMap;
 
   /// SectionSourceLines - Tracks line numbers per text section.
   ///
@@ -139,29 +139,25 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   DbgScope *FunctionDbgScope;
   
   /// DbgScopeMap - Tracks the scopes in the current function.
-  DenseMap<GlobalVariable *, DbgScope *> DbgScopeMap;
+  DenseMap<MDNode *, DbgScope *> DbgScopeMap;
 
   /// DbgAbstractScopeMap - Tracks abstract instance scopes in the current
   /// function.
-  DenseMap<GlobalVariable *, DbgScope *> DbgAbstractScopeMap;
+  DenseMap<MDNode *, DbgScope *> DbgAbstractScopeMap;
 
   /// DbgConcreteScopeMap - Tracks concrete instance scopes in the current
   /// function.
-  DenseMap<GlobalVariable *,
+  DenseMap<MDNode *,
            SmallVector<DbgScope *, 8> > DbgConcreteScopeMap;
 
   /// InlineInfo - Keep track of inlined functions and their location.  This
   /// information is used to populate debug_inlined section.
-  DenseMap<GlobalVariable *, SmallVector<unsigned, 4> > InlineInfo;
-
-  /// InlinedVariableScopes - Scopes information for the inlined subroutine
-  /// variables.
-  DenseMap<const MachineInstr *, DbgScope *> InlinedVariableScopes;
+  DenseMap<MDNode *, SmallVector<unsigned, 4> > InlineInfo;
 
   /// AbstractInstanceRootMap - Map of abstract instance roots of inlined
   /// functions. These are subroutine entries that contain a DW_AT_inline
   /// attribute.
-  DenseMap<const GlobalVariable *, DbgScope *> AbstractInstanceRootMap;
+  DenseMap<const MDNode *, DbgScope *> AbstractInstanceRootMap;
 
   /// AbstractInstanceRootList - List of abstract instance roots of inlined
   /// functions. These are subroutine entries that contain a DW_AT_inline
@@ -224,16 +220,9 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   ///
   void AssignAbbrevNumber(DIEAbbrev &Abbrev);
 
-  /// NewString - Add a string to the constant pool and returns a label.
-  ///
-  DWLabel NewString(const std::string &String) {
-    unsigned StringID = StringPool.insert(String);
-    return DWLabel("string", StringID);
-  }
-
-  /// NewDIEEntry - Creates a new DIEEntry to be a proxy for a debug information
-  /// entry.
-  DIEEntry *NewDIEEntry(DIE *Entry = NULL);
+  /// CreateDIEEntry - Creates a new DIEEntry to be a proxy for a debug
+  /// information entry.
+  DIEEntry *CreateDIEEntry(DIE *Entry = NULL);
 
   /// SetDIEEntry - Set a DIEEntry once the debug information entry is defined.
   ///
@@ -276,7 +265,7 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   /// AddDIEEntry - Add a DIE attribute data and value.
   ///
   void AddDIEEntry(DIE *Die, unsigned Attribute, unsigned Form, DIE *Entry) {
-    Die->AddValue(Attribute, Form, NewDIEEntry(Entry));
+    Die->AddValue(Attribute, Form, CreateDIEEntry(Entry));
   }
 
   /// AddBlock - Add block data.
@@ -286,11 +275,8 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   /// AddSourceLine - Add location information to specified debug information
   /// entry.
   void AddSourceLine(DIE *Die, const DIVariable *V);
-
-  /// AddSourceLine - Add location information to specified debug information
-  /// entry.
   void AddSourceLine(DIE *Die, const DIGlobal *G);
-
+  void AddSourceLine(DIE *Die, const DISubprogram *SP);
   void AddSourceLine(DIE *Die, const DIType *Ty);
 
   /// AddAddress - Add an address attribute to a die based on the location
@@ -298,6 +284,14 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   void AddAddress(DIE *Die, unsigned Attribute,
                   const MachineLocation &Location);
 
+  /// AddBlockByrefAddress - Start with the address based on the location
+  /// provided, and generate the DWARF information necessary to find the
+  /// actual Block variable (navigating the Block struct) based on the
+  /// starting location.  Add the DWARF information to the die.
+  ///
+  void AddBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
+                            const MachineLocation &Location);
+
   /// AddType - Add a new type attribute to the specified entity.
   void AddType(CompileUnit *DW_Unit, DIE *Entity, DIType Ty);
 
@@ -333,19 +327,20 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   /// CreateSubprogramDIE - Create new DIE using SP.
   DIE *CreateSubprogramDIE(CompileUnit *DW_Unit,
                            const DISubprogram &SP,
-                           bool IsConstructor = false);
+                           bool IsConstructor = false,
+                           bool IsInlined = false);
 
   /// FindCompileUnit - Get the compile unit for the given descriptor. 
   ///
   CompileUnit &FindCompileUnit(DICompileUnit Unit) const;
 
-  /// NewDbgScopeVariable - Create a new scope variable.
+  /// CreateDbgScopeVariable - Create a new scope variable.
   ///
-  DIE *NewDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit);
+  DIE *CreateDbgScopeVariable(DbgVariable *DV, CompileUnit *Unit);
 
   /// getOrCreateScope - Returns the scope associated with the given descriptor.
   ///
-  DbgScope *getOrCreateScope(GlobalVariable *V);
+  DbgScope *getOrCreateScope(MDNode *N);
 
   /// ConstructDbgScope - Construct the components of a scope.
   ///
@@ -355,12 +350,8 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
 
   /// ConstructFunctionDbgScope - Construct the scope for the subprogram.
   ///
-  void ConstructFunctionDbgScope(DbgScope *RootScope);
-
-  /// ConstructFunctionDbgScope - Construct the scope for the abstract debug
-  /// scope.
-  ///
-  void ConstructAbstractDbgScope(DbgScope *AbsScope);
+  void ConstructFunctionDbgScope(DbgScope *RootScope,
+                                 bool AbstractScope = false);
 
   /// ConstructDefaultDbgScope - Construct a default scope for the subprogram.
   ///
@@ -462,43 +453,31 @@ class VISIBILITY_HIDDEN DwarfDebug : public Dwarf {
   unsigned GetOrCreateSourceID(const std::string &DirName,
                                const std::string &FileName);
 
-  void ConstructCompileUnit(GlobalVariable *GV);
+  void ConstructCompileUnit(MDNode *N);
 
-  /// ConstructCompileUnits - Create a compile unit DIEs.
-  void ConstructCompileUnits();
+  void ConstructGlobalVariableDIE(MDNode *N);
 
-  bool ConstructGlobalVariableDIE(GlobalVariable *GV);
+  void ConstructSubprogram(MDNode *N);
 
-  /// ConstructGlobalVariableDIEs - Create DIEs for each of the externally 
-  /// visible global variables. Return true if at least one global DIE is
-  /// created.
-  bool ConstructGlobalVariableDIEs();
-
-  bool ConstructSubprogram(GlobalVariable *GV);
+  /// Find the type the programmer originally declared the variable to be
+  /// and return that type.
+  ///
+  DIType GetBlockByrefType(DIType Ty, std::string Name);
 
-  /// ConstructSubprograms - Create DIEs for each of the externally visible
-  /// subprograms. Return true if at least one subprogram DIE is created.
-  bool ConstructSubprograms();
 public:
   //===--------------------------------------------------------------------===//
   // Main entry points.
   //
-  DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T);
+  DwarfDebug(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T);
   virtual ~DwarfDebug();
 
   /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
   /// be emitted.
   bool ShouldEmitDwarfDebug() const { return shouldEmit; }
 
-  /// SetDebugInfo - Create global DIEs and emit initial debug info sections.
-  /// This is inovked by the target AsmPrinter.
-  void SetDebugInfo(MachineModuleInfo *mmi);
-
   /// BeginModule - Emit all Dwarf sections that should come prior to the
   /// content.
-  void BeginModule(Module *M) {
-    this->M = M;
-  }
+  void BeginModule(Module *M, MachineModuleInfo *MMI);
 
   /// EndModule - Emit all Dwarf sections that should come after the content.
   ///
@@ -537,14 +516,13 @@ public:
                                const std::string &FileName);
 
   /// RecordRegionStart - Indicate the start of a region.
-  unsigned RecordRegionStart(GlobalVariable *V);
+  unsigned RecordRegionStart(MDNode *N);
 
   /// RecordRegionEnd - Indicate the end of a region.
-  unsigned RecordRegionEnd(GlobalVariable *V);
+  unsigned RecordRegionEnd(MDNode *N);
 
   /// RecordVariable - Indicate the declaration of  a local variable.
-  void RecordVariable(GlobalVariable *GV, unsigned FrameIndex,
-                      const MachineInstr *MI);
+  void RecordVariable(MDNode *N, unsigned FrameIndex);
 
   //// RecordInlinedFnStart - Indicate the start of inlined subroutine.
   unsigned RecordInlinedFnStart(DISubprogram &SP, DICompileUnit CU,
@@ -553,11 +531,6 @@ public:
   /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
   unsigned RecordInlinedFnEnd(DISubprogram &SP);
 
-  /// RecordVariableScope - Record scope for the variable declared by
-  /// DeclareMI. DeclareMI must describe TargetInstrInfo::DECLARE. Record scopes
-  /// for only inlined subroutine variables. Other variables's scopes are
-  /// determined during RecordVariable().
-  void RecordVariableScope(DIVariable &DV, const MachineInstr *DeclareMI);
 };
 
 } // End of namespace llvm