Add a DIELocList class to handle pointers into the location list.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DIE.cpp
index e8be7ad626d6939f0b09b66eaf44d997c72cd97b..0c6e01504ef6ed8dfa7d2524b572f5941bdf4d40 100644 (file)
@@ -524,3 +524,34 @@ void DIEBlock::print(raw_ostream &O) const {
   DIE::print(O, 5);
 }
 #endif
+
+//===----------------------------------------------------------------------===//
+// DIELocList Implementation
+//===----------------------------------------------------------------------===//
+
+unsigned DIELocList::SizeOf(AsmPrinter *AP, dwarf::Form Form) const {
+  if (Form == dwarf::DW_FORM_data4)
+    return 4;
+  if (Form == dwarf::DW_FORM_sec_offset)
+    return 4;
+  return AP->getDataLayout().getPointerSize();
+}
+
+/// EmitValue - Emit label value.
+///
+void DIELocList::EmitValue(AsmPrinter *AP, dwarf::Form Form) const {
+  MCSymbol *Label = AP->GetTempSymbol("debug_loc", Index);
+  MCSymbol *DwarfDebugLocSectionSym = AP->getDwarfDebug()->getDebugLocSym();
+
+  if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
+    AP->EmitSectionOffset(Label, DwarfDebugLocSectionSym);
+  else
+    AP->EmitLabelDifference(Label, DwarfDebugLocSectionSym, 4);
+}
+
+#ifndef NDEBUG
+void DIELocList::print(raw_ostream &O) const {
+  O << "LocList: " << Index;
+
+}
+#endif