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

Jim Laskey jlaskey at apple.com
Wed Mar 1 09:53:16 PST 2006



Changes in directory llvm/lib/CodeGen:

DwarfWriter.cpp updated: 1.35 -> 1.36
MachineDebugInfo.cpp updated: 1.19 -> 1.20
---
Log message:

Basic array support.


---
Diffs of the changes:  (+197 -10)

 DwarfWriter.cpp      |   73 +++++++++++++++++++++++++--
 MachineDebugInfo.cpp |  134 +++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 197 insertions(+), 10 deletions(-)


Index: llvm/lib/CodeGen/DwarfWriter.cpp
diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.35 llvm/lib/CodeGen/DwarfWriter.cpp:1.36
--- llvm/lib/CodeGen/DwarfWriter.cpp:1.35	Tue Feb 28 14:15:07 2006
+++ llvm/lib/CodeGen/DwarfWriter.cpp	Wed Mar  1 11:53:02 2006
@@ -1072,12 +1072,12 @@
     // 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;
+    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");
     }
     
@@ -1088,6 +1088,67 @@
     if (TypeDesc *FromTy = DerivedTy->getFromType()) {
        Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Unit, 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);
+    std::vector<DebugInfoDesc *> &Elements = CompTy->getElements();
+    
+    switch (CompTy->getTag()) {
+    case DI_TAG_array: {
+      // Add element type.
+      if (TypeDesc *FromTy = CompTy->getFromType()) {
+         Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Unit, FromTy));
+      }
+      // Don't emit size attribute.
+      Size = 0;
+      
+      // Construct an anonymous type for index type.
+      DIE *IndexTy = new DIE(DW_TAG_base_type);
+      IndexTy->AddUInt(DW_AT_byte_size, 0, 4);
+      IndexTy->AddUInt(DW_AT_encoding, DW_FORM_data1, DW_ATE_signed);
+      // Add to context.
+      Unit->getDie()->AddChild(IndexTy);
+    
+      // Add subranges to array type.
+      for(unsigned i = 0, N = Elements.size(); i < N; ++i) {
+        SubrangeDesc *SRD = cast<SubrangeDesc>(Elements[i]);
+        int64_t Lo = SRD->getLo();
+        int64_t Hi = SRD->getHi();
+        DIE *Subrange = new DIE(DW_TAG_subrange_type);
+        
+        // If a range is available.
+        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);
+        }
+        Ty->AddChild(Subrange);
+      }
+      
+      break;
+    }
+    case DI_TAG_struct: {
+      break;
+    }
+    case DI_TAG_union: {
+      break;
+    }
+    case DI_TAG_enum: {
+      break;
+    }
+    default: break;
+    }
   }
   
   assert(Ty && "Type not supported yet");


Index: llvm/lib/CodeGen/MachineDebugInfo.cpp
diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.19 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.20
--- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.19	Tue Feb 28 14:15:07 2006
+++ llvm/lib/CodeGen/MachineDebugInfo.cpp	Wed Mar  1 11:53:02 2006
@@ -197,6 +197,7 @@
   ///
   virtual void Apply(int &Field)             { ++Count; }
   virtual void Apply(unsigned &Field)        { ++Count; }
+  virtual void Apply(int64_t &Field)         { ++Count; }
   virtual void Apply(uint64_t &Field)        { ++Count; }
   virtual void Apply(bool &Field)            { ++Count; }
   virtual void Apply(std::string &Field)     { ++Count; }
@@ -234,6 +235,10 @@
     Constant *C = CI->getOperand(I++);
     Field = cast<ConstantUInt>(C)->getValue();
   }
+  virtual void Apply(int64_t &Field) {
+    Constant *C = CI->getOperand(I++);
+    Field = cast<ConstantSInt>(C)->getValue();
+  }
   virtual void Apply(uint64_t &Field) {
     Constant *C = CI->getOperand(I++);
     Field = cast<ConstantUInt>(C)->getValue();
@@ -290,6 +295,9 @@
   virtual void Apply(unsigned &Field) {
     Elements.push_back(ConstantUInt::get(Type::UIntTy, Field));
   }
+  virtual void Apply(int64_t &Field) {
+    Elements.push_back(ConstantSInt::get(Type::IntTy, Field));
+  }
   virtual void Apply(uint64_t &Field) {
     Elements.push_back(ConstantUInt::get(Type::UIntTy, Field));
   }
@@ -337,7 +345,11 @@
     }
     
     Constant *CA = ConstantArray::get(AT, ArrayElements);
-    Constant *CAE = ConstantExpr::getCast(CA, EmptyTy);
+    GlobalVariable *CAGV = new GlobalVariable(AT, true,
+                                              GlobalValue::InternalLinkage,
+                                              CA, "llvm.dbg.array",
+                                              SR.getModule());
+    Constant *CAE = ConstantExpr::getCast(CAGV, EmptyTy);
     Elements.push_back(CAE);
   }
 };
@@ -365,6 +377,9 @@
   virtual void Apply(unsigned &Field) {
     Fields.push_back(Type::UIntTy);
   }
+  virtual void Apply(int64_t &Field) {
+    Fields.push_back(Type::IntTy);
+  }
   virtual void Apply(uint64_t &Field) {
     Fields.push_back(Type::UIntTy);
   }
@@ -422,6 +437,10 @@
     Constant *C = CI->getOperand(I++);
     IsValid = IsValid && isa<ConstantInt>(C);
   }
+  virtual void Apply(int64_t &Field) {
+    Constant *C = CI->getOperand(I++);
+    IsValid = IsValid && isa<ConstantInt>(C);
+  }
   virtual void Apply(uint64_t &Field) {
     Constant *C = CI->getOperand(I++);
     IsValid = IsValid && isa<ConstantInt>(C);
@@ -491,6 +510,11 @@
   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();
   default: break;
   }
   return NULL;
@@ -681,6 +705,18 @@
   Visitor->Apply(Encoding);
 }
 
+/// getDescString - Return a string used to compose global names and labels.
+///
+const char *BasicTypeDesc::getDescString() const {
+  return "llvm.dbg.basictype";
+}
+
+/// getTypeString - Return a string used to label this descriptor's type.
+///
+const char *BasicTypeDesc::getTypeString() const {
+  return "llvm.dbg.basictype.type";
+}
+
 #ifndef NDEBUG
 void BasicTypeDesc::dump() {
   std::cerr << getDescString() << " "
@@ -691,14 +727,13 @@
             << "Encoding(" << Encoding << ")\n";
 }
 #endif
+
 //===----------------------------------------------------------------------===//
 
 DerivedTypeDesc::DerivedTypeDesc(unsigned T)
 : TypeDesc(T)
 , FromType(NULL)
-{
-  assert(classof((const DebugInfoDesc *)this) && "Unknown derived type.");
-}
+{}
 
 /// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc.
 ///
@@ -708,6 +743,18 @@
   Visitor->Apply((DebugInfoDesc *&)FromType);
 }
 
+/// getDescString - Return a string used to compose global names and labels.
+///
+const char *DerivedTypeDesc::getDescString() const {
+  return "llvm.dbg.derivedtype";
+}
+
+/// getTypeString - Return a string used to label this descriptor's type.
+///
+const char *DerivedTypeDesc::getTypeString() const {
+  return "llvm.dbg.derivedtype.type";
+}
+
 #ifndef NDEBUG
 void DerivedTypeDesc::dump() {
   std::cerr << getDescString() << " "
@@ -723,6 +770,85 @@
 
 //===----------------------------------------------------------------------===//
 
+CompositeTypeDesc::CompositeTypeDesc(unsigned T)
+: DerivedTypeDesc(T)
+, Elements()
+{}
+  
+/// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc.
+///
+void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) {
+  DerivedTypeDesc::ApplyToFields(Visitor);
+  
+  Visitor->Apply(Elements);
+}
+
+/// getDescString - Return a string used to compose global names and labels.
+///
+const char *CompositeTypeDesc::getDescString() const {
+  return "llvm.dbg.compositetype";
+}
+
+/// getTypeString - Return a string used to label this descriptor's type.
+///
+const char *CompositeTypeDesc::getTypeString() const {
+  return "llvm.dbg.compositetype.type";
+}
+
+#ifndef NDEBUG
+void CompositeTypeDesc::dump() {
+  std::cerr << getDescString() << " "
+            << "Tag(" << getTag() << "), "
+            << "Context(" << getContext() << "), "
+            << "Name(\"" << getName() << "\"), "
+            << "Size(" << getSize() << "), "
+            << "File(" << getFile() << "), "
+            << "Line(" << getLine() << "), "
+            << "FromType(" << getFromType() << "), "
+            << "Elements.size(" << Elements.size() << ")\n";
+}
+#endif
+
+//===----------------------------------------------------------------------===//
+
+SubrangeDesc::SubrangeDesc()
+: DebugInfoDesc(DI_TAG_subrange)
+, Lo(0)
+, Hi(0)
+{}
+
+/// ApplyToFields - Target the visitor to the fields of the SubrangeDesc.
+///
+void SubrangeDesc::ApplyToFields(DIVisitor *Visitor) {
+  DebugInfoDesc::ApplyToFields(Visitor);
+
+  Visitor->Apply(Lo);
+  Visitor->Apply(Hi);
+}
+
+/// getDescString - Return a string used to compose global names and labels.
+///
+const char *SubrangeDesc::getDescString() const {
+  return "llvm.dbg.subrange";
+}
+  
+/// getTypeString - Return a string used to label this descriptor's type.
+///
+const char *SubrangeDesc::getTypeString() const {
+  return "llvm.dbg.subrange.type";
+}
+
+#ifndef NDEBUG
+void SubrangeDesc::dump() {
+  std::cerr << getDescString() << " "
+            << "Tag(" << getTag() << "), "
+            << "Lo(" << Lo << "), "
+            << "Hi(" << Hi << ")\n";
+}
+#endif
+
+//===----------------------------------------------------------------------===//
+
 GlobalDesc::GlobalDesc(unsigned T)
 : AnchoredDesc(T)
 , Context(0)






More information about the llvm-commits mailing list