[llvm-commits] CVS: llvm/lib/CodeGen/DwarfWriter.cpp MachineDebugInfo.cpp

Jim Laskey jlaskey at apple.com
Wed Mar 1 12:39:48 PST 2006



Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.38 -> 1.39
MachineDebugInfo.cpp updated: 1.20 -> 1.21
---
Log message:

Switch back to using actual dwarf tags.  Simplifies code without loss to other
debug forms.


---
Diffs of the changes:  (+103 -55)

 DwarfWriter.cpp      |   34 ++-----------
 MachineDebugInfo.cpp |  124 +++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 103 insertions(+), 55 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.38 llvm/lib/CodeGen/DwarfWriter.cpp:1.39
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.38	Wed Mar  1 12:20:30 2006
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Wed Mar  1 14:39:35 2006
@@ -1070,42 +1070,20 @@
     unsigned Encoding = BasicTy->getEncoding();
     Ty->AddUInt  (DW_AT_encoding,  DW_FORM_data1, Encoding);
   } else if (DerivedTypeDesc *DerivedTy = dyn_cast<DerivedTypeDesc>(TyDesc)) {
-    // Determine which derived type.
-    unsigned T = 0;
-    switch (DerivedTy->getTag()) {
-    case DI_TAG_typedef:   T = DW_TAG_typedef;         break;
-    case DI_TAG_pointer:   T = DW_TAG_pointer_type;    break;
-    case DI_TAG_reference: T = DW_TAG_reference_type;  break;
-    case DI_TAG_const:     T = DW_TAG_const_type;      break;
-    case DI_TAG_volatile:  T = DW_TAG_volatile_type;   break;
-    case DI_TAG_restrict:  T = DW_TAG_restrict_type;   break;
-    default: assert( 0 && "Unknown tag on derived type");
-    }
-    
     // Create specific DIE.
-    Slot = Ty = new DIE(T);
+    Slot = Ty = new DIE(DerivedTy->getTag());
     
     // Map to main type, void will not have a type.
     if (TypeDesc *FromTy = DerivedTy->getFromType()) {
        Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy));
     }
   } else if (CompositeTypeDesc *CompTy = dyn_cast<CompositeTypeDesc>(TyDesc)) {
-    // Determine which composite type.
-    unsigned T = 0;
-    switch (CompTy->getTag()) {
-    case DI_TAG_array:     T = DW_TAG_array_type;       break;
-    case DI_TAG_struct:    T = DW_TAG_structure_type;   break;
-    case DI_TAG_union:     T = DW_TAG_union_type;       break;
-    case DI_TAG_enum:      T = DW_TAG_enumeration_type; break;
-    default: assert( 0 && "Unknown tag on composite type");
-    }
-    
     // Create specific DIE.
-    Slot = Ty = new DIE(T);
+    Slot = Ty = new DIE(CompTy->getTag());
     std::vector<DebugInfoDesc *> &Elements = CompTy->getElements();
     
     switch (CompTy->getTag()) {
-    case DI_TAG_array: {
+    case DW_TAG_array_type: {
       // Add element type.
       if (TypeDesc *FromTy = CompTy->getFromType()) {
          Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy));
@@ -1139,13 +1117,13 @@
       
       break;
     }
-    case DI_TAG_struct: {
+    case DW_TAG_structure_type: {
       break;
     }
-    case DI_TAG_union: {
+    case DW_TAG_union_type: {
       break;
     }
-    case DI_TAG_enum: {
+    case DW_TAG_enumeration_type: {
       break;
     }
     default: break;


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.20 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.21
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.20	Wed Mar  1 11:53:02 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp	Wed Mar  1 14:39:36 2006
@@ -20,6 +20,7 @@
 #include <iostream>
 
 using namespace llvm;
+using namespace llvm::dwarf;
 
 // Handle the Pass registration stuff necessary to use TargetData's.
 namespace {
@@ -492,29 +493,29 @@
 /// GlobalVariable.  
 unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) {
   ConstantUInt *C = getUIntOperand(GV, 0);
-  return C ? (unsigned)C->getValue() : (unsigned)DIInvalid;
+  return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid;
 }
 
 /// DescFactory - Create an instance of debug info descriptor based on Tag.
 /// Return NULL if not a recognized Tag.
 DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) {
   switch (Tag) {
-  case DI_TAG_anchor:          return new AnchorDesc();
-  case DI_TAG_compile_unit:    return new CompileUnitDesc();
-  case DI_TAG_global_variable: return new GlobalVariableDesc();
-  case DI_TAG_subprogram:      return new SubprogramDesc();
-  case DI_TAG_basictype:       return new BasicTypeDesc();
-  case DI_TAG_typedef:
-  case DI_TAG_pointer:         
-  case DI_TAG_reference:
-  case DI_TAG_const:
-  case DI_TAG_volatile:         
-  case DI_TAG_restrict:        return new DerivedTypeDesc(Tag);
-  case DI_TAG_array:
-  case DI_TAG_struct:
-  case DI_TAG_union:
-  case DI_TAG_enum:            return new CompositeTypeDesc(Tag);
-  case DI_TAG_subrange:        return new SubrangeDesc();
+  case DW_TAG_anchor:           return new AnchorDesc();
+  case DW_TAG_compile_unit:     return new CompileUnitDesc();
+  case DW_TAG_variable:         return new GlobalVariableDesc();
+  case DW_TAG_subprogram:       return new SubprogramDesc();
+  case DW_TAG_base_type:        return new BasicTypeDesc();
+  case DW_TAG_typedef:
+  case DW_TAG_pointer_type:         
+  case DW_TAG_reference_type:
+  case DW_TAG_const_type:
+  case DW_TAG_volatile_type:         
+  case DW_TAG_restrict_type:    return new DerivedTypeDesc(Tag);
+  case DW_TAG_array_type:
+  case DW_TAG_structure_type:
+  case DW_TAG_union_type:
+  case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
+  case DW_TAG_subrange_type:    return new SubrangeDesc();
   default: break;
   }
   return NULL;
@@ -534,6 +535,20 @@
 
 //===----------------------------------------------------------------------===//
 
+AnchorDesc::AnchorDesc()
+: DebugInfoDesc(DW_TAG_anchor)
+, Name("")
+{}
+AnchorDesc::AnchorDesc(const std::string &N)
+: DebugInfoDesc(DW_TAG_anchor)
+, Name(N)
+{}
+
+// Implement isa/cast/dyncast.
+bool AnchorDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_anchor;
+}
+  
 /// getLinkage - get linkage appropriate for this type of descriptor.
 ///
 GlobalValue::LinkageTypes AnchorDesc::getLinkage() const {
@@ -586,7 +601,7 @@
 //===----------------------------------------------------------------------===//
 
 CompileUnitDesc::CompileUnitDesc()
-: AnchoredDesc(DI_TAG_compile_unit)
+: AnchoredDesc(DW_TAG_compile_unit)
 , DebugVersion(LLVMDebugVersion)
 , Language(0)
 , FileName("")
@@ -594,11 +609,16 @@
 , Producer("")
 {}
 
+// Implement isa/cast/dyncast.
+bool CompileUnitDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_compile_unit;
+}
+
 /// DebugVersionFromGlobal - Returns the version number from a compile unit
 /// GlobalVariable.
 unsigned CompileUnitDesc::DebugVersionFromGlobal(GlobalVariable *GV) {
   ConstantUInt *C = getUIntOperand(GV, 2);
-  return C ? (unsigned)C->getValue() : (unsigned)DIInvalid;
+  return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid;
 }
   
 /// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
@@ -693,10 +713,15 @@
 //===----------------------------------------------------------------------===//
 
 BasicTypeDesc::BasicTypeDesc()
-: TypeDesc(DI_TAG_basictype)
+: TypeDesc(DW_TAG_base_type)
 , Encoding(0)
 {}
 
+// Implement isa/cast/dyncast.
+bool BasicTypeDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_base_type;
+}
+
 /// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc.
 ///
 void BasicTypeDesc::ApplyToFields(DIVisitor *Visitor) {
@@ -735,6 +760,22 @@
 , FromType(NULL)
 {}
 
+// Implement isa/cast/dyncast.
+bool DerivedTypeDesc::classof(const DebugInfoDesc *D) {
+  unsigned T =  D->getTag();
+  switch (T) {
+  case DW_TAG_typedef:
+  case DW_TAG_pointer_type:
+  case DW_TAG_reference_type:
+  case DW_TAG_const_type:
+  case DW_TAG_volatile_type:
+  case DW_TAG_restrict_type:
+    return true;
+  default: break;
+  }
+  return false;
+}
+
 /// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc.
 ///
 void DerivedTypeDesc::ApplyToFields(DIVisitor *Visitor) {
@@ -775,6 +816,20 @@
 , Elements()
 {}
   
+// Implement isa/cast/dyncast.
+bool CompositeTypeDesc::classof(const DebugInfoDesc *D) {
+  unsigned T =  D->getTag();
+  switch (T) {
+  case DW_TAG_array_type:
+  case DW_TAG_structure_type:
+  case DW_TAG_union_type:
+  case DW_TAG_enumeration_type:
+    return true;
+  default: break;
+  }
+  return false;
+}
+
 /// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc.
 ///
 void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) {
@@ -812,11 +867,16 @@
 //===----------------------------------------------------------------------===//
 
 SubrangeDesc::SubrangeDesc()
-: DebugInfoDesc(DI_TAG_subrange)
+: DebugInfoDesc(DW_TAG_subrange_type)
 , Lo(0)
 , Hi(0)
 {}
 
+// Implement isa/cast/dyncast.
+bool SubrangeDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_subrange_type;
+}
+
 /// ApplyToFields - Target the visitor to the fields of the SubrangeDesc.
 ///
 void SubrangeDesc::ApplyToFields(DIVisitor *Visitor) {
@@ -873,10 +933,15 @@
 //===----------------------------------------------------------------------===//
 
 GlobalVariableDesc::GlobalVariableDesc()
-: GlobalDesc(DI_TAG_global_variable)
+: GlobalDesc(DW_TAG_variable)
 , Global(NULL)
 {}
 
+// Implement isa/cast/dyncast.
+bool GlobalVariableDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_variable; 
+}
+
 /// ApplyToFields - Target the visitor to the fields of the GlobalVariableDesc.
 ///
 void GlobalVariableDesc::ApplyToFields(DIVisitor *Visitor) {
@@ -921,9 +986,14 @@
 //===----------------------------------------------------------------------===//
 
 SubprogramDesc::SubprogramDesc()
-: GlobalDesc(DI_TAG_subprogram)
+: GlobalDesc(DW_TAG_subprogram)
 {}
 
+// Implement isa/cast/dyncast.
+bool SubprogramDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_subprogram;
+}
+
 /// ApplyToFields - Target the visitor to the fields of the
 /// SubprogramDesc.
 void SubprogramDesc::ApplyToFields(DIVisitor *Visitor) {
@@ -977,7 +1047,7 @@
   unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
   
   // Get the debug version if a compile unit.
-  if (Tag == DI_TAG_compile_unit) {
+  if (Tag == DW_TAG_compile_unit) {
     DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
   }
   
@@ -1123,12 +1193,12 @@
   
   // Get the Tag
   unsigned Tag = DebugInfoDesc::TagFromGlobal(GV);
-  if (Tag == DIInvalid) return false;
+  if (Tag == DW_TAG_invalid) return false;
 
   // If a compile unit we need the debug version.
-  if (Tag == DI_TAG_compile_unit) {
+  if (Tag == DW_TAG_compile_unit) {
     DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV);
-    if (DebugVersion == DIInvalid) return false;
+    if (DebugVersion == DW_TAG_invalid) return false;
   }
 
   // Construct an empty DebugInfoDesc.






More information about the llvm-commits mailing list