diff options
| author | Devang Patel <dpatel@apple.com> | 2009-01-05 18:33:01 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2009-01-05 18:33:01 +0000 |
| commit | 758e7d778186a426b5169ac78af2e134e4b1539c (patch) | |
| tree | 0f39356df3c50fe9369247d2113838e61ed897c8 /llvm/lib | |
| parent | 96fce00dc0046aa0ad8e4589b280b0b253db43bf (diff) | |
| download | bcm5719-llvm-758e7d778186a426b5169ac78af2e134e4b1539c.tar.gz bcm5719-llvm-758e7d778186a426b5169ac78af2e134e4b1539c.zip | |
Construct array/vector type DIEs using DebugInfo.
llvm-svn: 61724
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/DebugInfo.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 40 |
2 files changed, 46 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index f1f7d8eff35..8b802d7fffa 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/lib/Analysis/DebugInfo.cpp @@ -174,7 +174,12 @@ DIVariable::DIVariable(GlobalVariable *GV) : DIDescriptor(GV) { GV = 0; } - +unsigned DIArray::getNumElements() const { + assert (GV && "Invalid DIArray"); + Constant *C = GV->getInitializer(); + assert (C && "Invalid DIArray initializer"); + return C->getNumOperands(); +} //===----------------------------------------------------------------------===// // DIFactory: Basic Helpers diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 30f14b7c9f3..af419822255 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -1512,6 +1512,7 @@ private: AddUInt(&Buffer, DW_AT_byte_size, 0, Size); } + /// ConstructType - Construct derived type die from DIDerivedType. void ConstructType(CompileUnit *DW_Unit, DIE &Buffer, DIDerivedType *DTy) { @@ -1540,6 +1541,45 @@ private: // FIXME - Enable this. AddSourceLine(&Buffer, *DTy); } + // ConstructSubrangeDIE - Construct subrange DIE from DISubrange. + void ConstructSubrangeDIE (DIE &Buffer, DISubrange *SR, DIE *IndexTy) { + int64_t L = SR->getLo(); + int64_t H = SR->getHi(); + DIE *DW_Subrange = new DIE(DW_TAG_subrange_type); + if (L != H) { + AddDIEntry(DW_Subrange, DW_AT_type, DW_FORM_ref4, IndexTy); + if (L) + AddSInt(DW_Subrange, DW_AT_lower_bound, 0, L); + AddSInt(DW_Subrange, DW_AT_upper_bound, 0, H); + } + Buffer.AddChild(DW_Subrange); + } + + /// ConstructArrayTypeDIE - Construct array type DIE from DICompositeType. + void ConstructArrayTypeDIE(CompileUnit *DW_Unit, DIE &Buffer, + DICompositeType *CTy) { + Buffer.setTag(DW_TAG_array_type); + if (CTy->getTag() == DW_TAG_vector_type) + AddUInt(&Buffer, DW_AT_GNU_vector, DW_FORM_flag, 1); + + DIArray Elements = CTy->getTypeArray(); + // FIXME - Enable this. + // AddType(&Buffer, CTy->getTypeDerivedFrom(), DW_Unit); + + // Construct an anonymous type for index type. + DIE IdxBuffer(DW_TAG_base_type); + AddUInt(&IdxBuffer, DW_AT_byte_size, 0, sizeof(int32_t)); + AddUInt(&IdxBuffer, DW_AT_encoding, DW_FORM_data1, DW_ATE_signed); + DIE *IndexTy = DW_Unit->AddDie(IdxBuffer); + + // Add subranges to array type. + for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { + DISubrange Element = Elements.getElement(i); + ConstructSubrangeDIE(Buffer, &Element, IndexTy); + } + } + + /// ConstructType - Adds all the required attributes to the type. /// void ConstructType(DIE &Buffer, TypeDesc *TyDesc, CompileUnit *Unit) { |

