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

Jim Laskey jlaskey at apple.com
Wed Mar 1 15:52:51 PST 2006



Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.39 -> 1.40
MachineDebugInfo.cpp updated: 1.21 -> 1.22
---
Log message:

Support for enumerations.


---
Diffs of the changes:  (+57 -2)

 DwarfWriter.cpp      |   15 +++++++++++++--
 MachineDebugInfo.cpp |   44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.39 llvm/lib/CodeGen/DwarfWriter.cpp:1.40
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.39	Wed Mar  1 14:39:35 2006
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Wed Mar  1 17:52:37 2006
@@ -1109,8 +1109,8 @@
         if (Lo != Hi) {
           Subrange->AddDIEntry(DW_AT_type, DW_FORM_ref4, IndexTy);
           // Only add low if non-zero.
-          if (Lo) Subrange->AddUInt(DW_AT_lower_bound, 0, Lo);
-          Subrange->AddUInt(DW_AT_upper_bound, 0, Hi);
+          if (Lo) Subrange->AddSInt(DW_AT_lower_bound, 0, Lo);
+          Subrange->AddSInt(DW_AT_upper_bound, 0, Hi);
         }
         Ty->AddChild(Subrange);
       }
@@ -1124,6 +1124,17 @@
       break;
     }
     case DW_TAG_enumeration_type: {
+      // Add enumerators to enumeration type.
+      for(unsigned i = 0, N = Elements.size(); i < N; ++i) {
+        EnumeratorDesc *ED = cast<EnumeratorDesc>(Elements[i]);
+        const std::string &Name = ED->getName();
+        int64_t Value = ED->getValue();
+        DIE *Enumerator = new DIE(DW_TAG_enumerator);
+        Enumerator->AddString(DW_AT_name, DW_FORM_string, Name);
+        Enumerator->AddSInt(DW_AT_const_value, DW_FORM_sdata, Value);
+        Ty->AddChild(Enumerator);
+      }
+
       break;
     }
     default: break;


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.21 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.22
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.21	Wed Mar  1 14:39:36 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp	Wed Mar  1 17:52:37 2006
@@ -516,6 +516,7 @@
   case DW_TAG_union_type:
   case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag);
   case DW_TAG_subrange_type:    return new SubrangeDesc();
+  case DW_TAG_enumerator:       return new EnumeratorDesc();
   default: break;
   }
   return NULL;
@@ -909,6 +910,49 @@
 
 //===----------------------------------------------------------------------===//
 
+EnumeratorDesc::EnumeratorDesc()
+: DebugInfoDesc(DW_TAG_enumerator)
+, Name("")
+, Value(0)
+{}
+
+// Implement isa/cast/dyncast.
+bool EnumeratorDesc::classof(const DebugInfoDesc *D) {
+  return D->getTag() == DW_TAG_enumerator;
+}
+
+/// ApplyToFields - Target the visitor to the fields of the EnumeratorDesc.
+///
+void EnumeratorDesc::ApplyToFields(DIVisitor *Visitor) {
+  DebugInfoDesc::ApplyToFields(Visitor);
+
+  Visitor->Apply(Name);
+  Visitor->Apply(Value);
+}
+
+/// getDescString - Return a string used to compose global names and labels.
+///
+const char *EnumeratorDesc::getDescString() const {
+  return "llvm.dbg.enumerator";
+}
+  
+/// getTypeString - Return a string used to label this descriptor's type.
+///
+const char *EnumeratorDesc::getTypeString() const {
+  return "llvm.dbg.enumerator.type";
+}
+
+#ifndef NDEBUG
+void EnumeratorDesc::dump() {
+  std::cerr << getDescString() << " "
+            << "Tag(" << getTag() << "), "
+            << "Name(" << Name << "), "
+            << "Value(" << Value << ")\n";
+}
+#endif
+
+//===----------------------------------------------------------------------===//
+
 GlobalDesc::GlobalDesc(unsigned T)
 : AnchoredDesc(T)
 , Context(0)






More information about the llvm-commits mailing list