xref: /netbsd-src/external/apache2/llvm/dist/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp (revision 82d56013d7b633d116a93943de88e08335357a7c)
17330f729Sjoerg //===- llvm/CodeGen/AsmPrinter/AccelTable.cpp - Accelerator Tables --------===//
27330f729Sjoerg //
37330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
47330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
57330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
67330f729Sjoerg //
77330f729Sjoerg //===----------------------------------------------------------------------===//
87330f729Sjoerg //
97330f729Sjoerg // This file contains support for writing accelerator tables.
107330f729Sjoerg //
117330f729Sjoerg //===----------------------------------------------------------------------===//
127330f729Sjoerg 
137330f729Sjoerg #include "llvm/CodeGen/AccelTable.h"
147330f729Sjoerg #include "DwarfCompileUnit.h"
157330f729Sjoerg #include "llvm/ADT/STLExtras.h"
167330f729Sjoerg #include "llvm/ADT/StringMap.h"
177330f729Sjoerg #include "llvm/ADT/Twine.h"
187330f729Sjoerg #include "llvm/BinaryFormat/Dwarf.h"
197330f729Sjoerg #include "llvm/CodeGen/AsmPrinter.h"
207330f729Sjoerg #include "llvm/CodeGen/DIE.h"
217330f729Sjoerg #include "llvm/MC/MCExpr.h"
227330f729Sjoerg #include "llvm/MC/MCStreamer.h"
237330f729Sjoerg #include "llvm/MC/MCSymbol.h"
247330f729Sjoerg #include "llvm/Support/raw_ostream.h"
257330f729Sjoerg #include "llvm/Target/TargetLoweringObjectFile.h"
267330f729Sjoerg #include <algorithm>
277330f729Sjoerg #include <cstddef>
287330f729Sjoerg #include <cstdint>
297330f729Sjoerg #include <limits>
307330f729Sjoerg #include <vector>
317330f729Sjoerg 
327330f729Sjoerg using namespace llvm;
337330f729Sjoerg 
computeBucketCount()347330f729Sjoerg void AccelTableBase::computeBucketCount() {
357330f729Sjoerg   // First get the number of unique hashes.
367330f729Sjoerg   std::vector<uint32_t> Uniques;
377330f729Sjoerg   Uniques.reserve(Entries.size());
387330f729Sjoerg   for (const auto &E : Entries)
397330f729Sjoerg     Uniques.push_back(E.second.HashValue);
407330f729Sjoerg   array_pod_sort(Uniques.begin(), Uniques.end());
417330f729Sjoerg   std::vector<uint32_t>::iterator P =
427330f729Sjoerg       std::unique(Uniques.begin(), Uniques.end());
437330f729Sjoerg 
447330f729Sjoerg   UniqueHashCount = std::distance(Uniques.begin(), P);
457330f729Sjoerg 
467330f729Sjoerg   if (UniqueHashCount > 1024)
477330f729Sjoerg     BucketCount = UniqueHashCount / 4;
487330f729Sjoerg   else if (UniqueHashCount > 16)
497330f729Sjoerg     BucketCount = UniqueHashCount / 2;
507330f729Sjoerg   else
517330f729Sjoerg     BucketCount = std::max<uint32_t>(UniqueHashCount, 1);
527330f729Sjoerg }
537330f729Sjoerg 
finalize(AsmPrinter * Asm,StringRef Prefix)547330f729Sjoerg void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {
557330f729Sjoerg   // Create the individual hash data outputs.
567330f729Sjoerg   for (auto &E : Entries) {
577330f729Sjoerg     // Unique the entries.
587330f729Sjoerg     llvm::stable_sort(E.second.Values,
597330f729Sjoerg                       [](const AccelTableData *A, const AccelTableData *B) {
607330f729Sjoerg                         return *A < *B;
617330f729Sjoerg                       });
627330f729Sjoerg     E.second.Values.erase(
637330f729Sjoerg         std::unique(E.second.Values.begin(), E.second.Values.end()),
647330f729Sjoerg         E.second.Values.end());
657330f729Sjoerg   }
667330f729Sjoerg 
677330f729Sjoerg   // Figure out how many buckets we need, then compute the bucket contents and
687330f729Sjoerg   // the final ordering. The hashes and offsets can be emitted by walking these
697330f729Sjoerg   // data structures. We add temporary symbols to the data so they can be
707330f729Sjoerg   // referenced when emitting the offsets.
717330f729Sjoerg   computeBucketCount();
727330f729Sjoerg 
737330f729Sjoerg   // Compute bucket contents and final ordering.
747330f729Sjoerg   Buckets.resize(BucketCount);
757330f729Sjoerg   for (auto &E : Entries) {
767330f729Sjoerg     uint32_t Bucket = E.second.HashValue % BucketCount;
777330f729Sjoerg     Buckets[Bucket].push_back(&E.second);
787330f729Sjoerg     E.second.Sym = Asm->createTempSymbol(Prefix);
797330f729Sjoerg   }
807330f729Sjoerg 
817330f729Sjoerg   // Sort the contents of the buckets by hash value so that hash collisions end
827330f729Sjoerg   // up together. Stable sort makes testing easier and doesn't cost much more.
837330f729Sjoerg   for (auto &Bucket : Buckets)
847330f729Sjoerg     llvm::stable_sort(Bucket, [](HashData *LHS, HashData *RHS) {
857330f729Sjoerg       return LHS->HashValue < RHS->HashValue;
867330f729Sjoerg     });
877330f729Sjoerg }
887330f729Sjoerg 
897330f729Sjoerg namespace {
907330f729Sjoerg /// Base class for writing out Accelerator tables. It holds the common
917330f729Sjoerg /// functionality for the two Accelerator table types.
927330f729Sjoerg class AccelTableWriter {
937330f729Sjoerg protected:
947330f729Sjoerg   AsmPrinter *const Asm;          ///< Destination.
957330f729Sjoerg   const AccelTableBase &Contents; ///< Data to emit.
967330f729Sjoerg 
977330f729Sjoerg   /// Controls whether to emit duplicate hash and offset table entries for names
987330f729Sjoerg   /// with identical hashes. Apple tables don't emit duplicate entries, DWARF v5
997330f729Sjoerg   /// tables do.
1007330f729Sjoerg   const bool SkipIdenticalHashes;
1017330f729Sjoerg 
1027330f729Sjoerg   void emitHashes() const;
1037330f729Sjoerg 
1047330f729Sjoerg   /// Emit offsets to lists of entries with identical names. The offsets are
1057330f729Sjoerg   /// relative to the Base argument.
1067330f729Sjoerg   void emitOffsets(const MCSymbol *Base) const;
1077330f729Sjoerg 
1087330f729Sjoerg public:
AccelTableWriter(AsmPrinter * Asm,const AccelTableBase & Contents,bool SkipIdenticalHashes)1097330f729Sjoerg   AccelTableWriter(AsmPrinter *Asm, const AccelTableBase &Contents,
1107330f729Sjoerg                    bool SkipIdenticalHashes)
1117330f729Sjoerg       : Asm(Asm), Contents(Contents), SkipIdenticalHashes(SkipIdenticalHashes) {
1127330f729Sjoerg   }
1137330f729Sjoerg };
1147330f729Sjoerg 
1157330f729Sjoerg class AppleAccelTableWriter : public AccelTableWriter {
1167330f729Sjoerg   using Atom = AppleAccelTableData::Atom;
1177330f729Sjoerg 
1187330f729Sjoerg   /// The fixed header of an Apple Accelerator Table.
1197330f729Sjoerg   struct Header {
1207330f729Sjoerg     uint32_t Magic = MagicHash;
1217330f729Sjoerg     uint16_t Version = 1;
1227330f729Sjoerg     uint16_t HashFunction = dwarf::DW_hash_function_djb;
1237330f729Sjoerg     uint32_t BucketCount;
1247330f729Sjoerg     uint32_t HashCount;
1257330f729Sjoerg     uint32_t HeaderDataLength;
1267330f729Sjoerg 
1277330f729Sjoerg     /// 'HASH' magic value to detect endianness.
1287330f729Sjoerg     static const uint32_t MagicHash = 0x48415348;
1297330f729Sjoerg 
Header__anon66e006530311::AppleAccelTableWriter::Header1307330f729Sjoerg     Header(uint32_t BucketCount, uint32_t UniqueHashCount, uint32_t DataLength)
1317330f729Sjoerg         : BucketCount(BucketCount), HashCount(UniqueHashCount),
1327330f729Sjoerg           HeaderDataLength(DataLength) {}
1337330f729Sjoerg 
1347330f729Sjoerg     void emit(AsmPrinter *Asm) const;
1357330f729Sjoerg #ifndef NDEBUG
1367330f729Sjoerg     void print(raw_ostream &OS) const;
dump__anon66e006530311::AppleAccelTableWriter::Header1377330f729Sjoerg     void dump() const { print(dbgs()); }
1387330f729Sjoerg #endif
1397330f729Sjoerg   };
1407330f729Sjoerg 
1417330f729Sjoerg   /// The HeaderData describes the structure of an Apple accelerator table
1427330f729Sjoerg   /// through a list of Atoms.
1437330f729Sjoerg   struct HeaderData {
1447330f729Sjoerg     /// In the case of data that is referenced via DW_FORM_ref_* the offset
1457330f729Sjoerg     /// base is used to describe the offset for all forms in the list of atoms.
1467330f729Sjoerg     uint32_t DieOffsetBase;
1477330f729Sjoerg 
1487330f729Sjoerg     const SmallVector<Atom, 4> Atoms;
1497330f729Sjoerg 
HeaderData__anon66e006530311::AppleAccelTableWriter::HeaderData1507330f729Sjoerg     HeaderData(ArrayRef<Atom> AtomList, uint32_t Offset = 0)
1517330f729Sjoerg         : DieOffsetBase(Offset), Atoms(AtomList.begin(), AtomList.end()) {}
1527330f729Sjoerg 
1537330f729Sjoerg     void emit(AsmPrinter *Asm) const;
1547330f729Sjoerg #ifndef NDEBUG
1557330f729Sjoerg     void print(raw_ostream &OS) const;
dump__anon66e006530311::AppleAccelTableWriter::HeaderData1567330f729Sjoerg     void dump() const { print(dbgs()); }
1577330f729Sjoerg #endif
1587330f729Sjoerg   };
1597330f729Sjoerg 
1607330f729Sjoerg   Header Header;
1617330f729Sjoerg   HeaderData HeaderData;
1627330f729Sjoerg   const MCSymbol *SecBegin;
1637330f729Sjoerg 
1647330f729Sjoerg   void emitBuckets() const;
1657330f729Sjoerg   void emitData() const;
1667330f729Sjoerg 
1677330f729Sjoerg public:
AppleAccelTableWriter(AsmPrinter * Asm,const AccelTableBase & Contents,ArrayRef<Atom> Atoms,const MCSymbol * SecBegin)1687330f729Sjoerg   AppleAccelTableWriter(AsmPrinter *Asm, const AccelTableBase &Contents,
1697330f729Sjoerg                         ArrayRef<Atom> Atoms, const MCSymbol *SecBegin)
1707330f729Sjoerg       : AccelTableWriter(Asm, Contents, true),
1717330f729Sjoerg         Header(Contents.getBucketCount(), Contents.getUniqueHashCount(),
1727330f729Sjoerg                8 + (Atoms.size() * 4)),
1737330f729Sjoerg         HeaderData(Atoms), SecBegin(SecBegin) {}
1747330f729Sjoerg 
1757330f729Sjoerg   void emit() const;
1767330f729Sjoerg 
1777330f729Sjoerg #ifndef NDEBUG
1787330f729Sjoerg   void print(raw_ostream &OS) const;
dump() const1797330f729Sjoerg   void dump() const { print(dbgs()); }
1807330f729Sjoerg #endif
1817330f729Sjoerg };
1827330f729Sjoerg 
1837330f729Sjoerg /// Class responsible for emitting a DWARF v5 Accelerator Table. The only
1847330f729Sjoerg /// public function is emit(), which performs the actual emission.
1857330f729Sjoerg ///
1867330f729Sjoerg /// The class is templated in its data type. This allows us to emit both dyamic
1877330f729Sjoerg /// and static data entries. A callback abstract the logic to provide a CU
1887330f729Sjoerg /// index for a given entry, which is different per data type, but identical
1897330f729Sjoerg /// for every entry in the same table.
1907330f729Sjoerg template <typename DataT>
1917330f729Sjoerg class Dwarf5AccelTableWriter : public AccelTableWriter {
1927330f729Sjoerg   struct Header {
1937330f729Sjoerg     uint16_t Version = 5;
1947330f729Sjoerg     uint16_t Padding = 0;
1957330f729Sjoerg     uint32_t CompUnitCount;
1967330f729Sjoerg     uint32_t LocalTypeUnitCount = 0;
1977330f729Sjoerg     uint32_t ForeignTypeUnitCount = 0;
1987330f729Sjoerg     uint32_t BucketCount;
1997330f729Sjoerg     uint32_t NameCount;
2007330f729Sjoerg     uint32_t AbbrevTableSize = 0;
2017330f729Sjoerg     uint32_t AugmentationStringSize = sizeof(AugmentationString);
2027330f729Sjoerg     char AugmentationString[8] = {'L', 'L', 'V', 'M', '0', '7', '0', '0'};
2037330f729Sjoerg 
Header__anon66e006530311::Dwarf5AccelTableWriter::Header2047330f729Sjoerg     Header(uint32_t CompUnitCount, uint32_t BucketCount, uint32_t NameCount)
2057330f729Sjoerg         : CompUnitCount(CompUnitCount), BucketCount(BucketCount),
2067330f729Sjoerg           NameCount(NameCount) {}
2077330f729Sjoerg 
208*82d56013Sjoerg     void emit(Dwarf5AccelTableWriter &Ctx);
2097330f729Sjoerg   };
2107330f729Sjoerg   struct AttributeEncoding {
2117330f729Sjoerg     dwarf::Index Index;
2127330f729Sjoerg     dwarf::Form Form;
2137330f729Sjoerg   };
2147330f729Sjoerg 
2157330f729Sjoerg   Header Header;
2167330f729Sjoerg   DenseMap<uint32_t, SmallVector<AttributeEncoding, 2>> Abbreviations;
2177330f729Sjoerg   ArrayRef<MCSymbol *> CompUnits;
2187330f729Sjoerg   llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry;
219*82d56013Sjoerg   MCSymbol *ContributionEnd = nullptr;
2207330f729Sjoerg   MCSymbol *AbbrevStart = Asm->createTempSymbol("names_abbrev_start");
2217330f729Sjoerg   MCSymbol *AbbrevEnd = Asm->createTempSymbol("names_abbrev_end");
2227330f729Sjoerg   MCSymbol *EntryPool = Asm->createTempSymbol("names_entries");
2237330f729Sjoerg 
2247330f729Sjoerg   DenseSet<uint32_t> getUniqueTags() const;
2257330f729Sjoerg 
2267330f729Sjoerg   // Right now, we emit uniform attributes for all tags.
2277330f729Sjoerg   SmallVector<AttributeEncoding, 2> getUniformAttributes() const;
2287330f729Sjoerg 
2297330f729Sjoerg   void emitCUList() const;
2307330f729Sjoerg   void emitBuckets() const;
2317330f729Sjoerg   void emitStringOffsets() const;
2327330f729Sjoerg   void emitAbbrevs() const;
2337330f729Sjoerg   void emitEntry(const DataT &Entry) const;
2347330f729Sjoerg   void emitData() const;
2357330f729Sjoerg 
2367330f729Sjoerg public:
2377330f729Sjoerg   Dwarf5AccelTableWriter(
2387330f729Sjoerg       AsmPrinter *Asm, const AccelTableBase &Contents,
2397330f729Sjoerg       ArrayRef<MCSymbol *> CompUnits,
2407330f729Sjoerg       llvm::function_ref<unsigned(const DataT &)> GetCUIndexForEntry);
2417330f729Sjoerg 
242*82d56013Sjoerg   void emit();
2437330f729Sjoerg };
2447330f729Sjoerg } // namespace
2457330f729Sjoerg 
emitHashes() const2467330f729Sjoerg void AccelTableWriter::emitHashes() const {
2477330f729Sjoerg   uint64_t PrevHash = std::numeric_limits<uint64_t>::max();
2487330f729Sjoerg   unsigned BucketIdx = 0;
2497330f729Sjoerg   for (auto &Bucket : Contents.getBuckets()) {
2507330f729Sjoerg     for (auto &Hash : Bucket) {
2517330f729Sjoerg       uint32_t HashValue = Hash->HashValue;
2527330f729Sjoerg       if (SkipIdenticalHashes && PrevHash == HashValue)
2537330f729Sjoerg         continue;
2547330f729Sjoerg       Asm->OutStreamer->AddComment("Hash in Bucket " + Twine(BucketIdx));
2557330f729Sjoerg       Asm->emitInt32(HashValue);
2567330f729Sjoerg       PrevHash = HashValue;
2577330f729Sjoerg     }
2587330f729Sjoerg     BucketIdx++;
2597330f729Sjoerg   }
2607330f729Sjoerg }
2617330f729Sjoerg 
emitOffsets(const MCSymbol * Base) const2627330f729Sjoerg void AccelTableWriter::emitOffsets(const MCSymbol *Base) const {
2637330f729Sjoerg   const auto &Buckets = Contents.getBuckets();
2647330f729Sjoerg   uint64_t PrevHash = std::numeric_limits<uint64_t>::max();
2657330f729Sjoerg   for (size_t i = 0, e = Buckets.size(); i < e; ++i) {
2667330f729Sjoerg     for (auto *Hash : Buckets[i]) {
2677330f729Sjoerg       uint32_t HashValue = Hash->HashValue;
2687330f729Sjoerg       if (SkipIdenticalHashes && PrevHash == HashValue)
2697330f729Sjoerg         continue;
2707330f729Sjoerg       PrevHash = HashValue;
2717330f729Sjoerg       Asm->OutStreamer->AddComment("Offset in Bucket " + Twine(i));
272*82d56013Sjoerg       Asm->emitLabelDifference(Hash->Sym, Base, Asm->getDwarfOffsetByteSize());
2737330f729Sjoerg     }
2747330f729Sjoerg   }
2757330f729Sjoerg }
2767330f729Sjoerg 
emit(AsmPrinter * Asm) const2777330f729Sjoerg void AppleAccelTableWriter::Header::emit(AsmPrinter *Asm) const {
2787330f729Sjoerg   Asm->OutStreamer->AddComment("Header Magic");
2797330f729Sjoerg   Asm->emitInt32(Magic);
2807330f729Sjoerg   Asm->OutStreamer->AddComment("Header Version");
2817330f729Sjoerg   Asm->emitInt16(Version);
2827330f729Sjoerg   Asm->OutStreamer->AddComment("Header Hash Function");
2837330f729Sjoerg   Asm->emitInt16(HashFunction);
2847330f729Sjoerg   Asm->OutStreamer->AddComment("Header Bucket Count");
2857330f729Sjoerg   Asm->emitInt32(BucketCount);
2867330f729Sjoerg   Asm->OutStreamer->AddComment("Header Hash Count");
2877330f729Sjoerg   Asm->emitInt32(HashCount);
2887330f729Sjoerg   Asm->OutStreamer->AddComment("Header Data Length");
2897330f729Sjoerg   Asm->emitInt32(HeaderDataLength);
2907330f729Sjoerg }
2917330f729Sjoerg 
emit(AsmPrinter * Asm) const2927330f729Sjoerg void AppleAccelTableWriter::HeaderData::emit(AsmPrinter *Asm) const {
2937330f729Sjoerg   Asm->OutStreamer->AddComment("HeaderData Die Offset Base");
2947330f729Sjoerg   Asm->emitInt32(DieOffsetBase);
2957330f729Sjoerg   Asm->OutStreamer->AddComment("HeaderData Atom Count");
2967330f729Sjoerg   Asm->emitInt32(Atoms.size());
2977330f729Sjoerg 
2987330f729Sjoerg   for (const Atom &A : Atoms) {
2997330f729Sjoerg     Asm->OutStreamer->AddComment(dwarf::AtomTypeString(A.Type));
3007330f729Sjoerg     Asm->emitInt16(A.Type);
3017330f729Sjoerg     Asm->OutStreamer->AddComment(dwarf::FormEncodingString(A.Form));
3027330f729Sjoerg     Asm->emitInt16(A.Form);
3037330f729Sjoerg   }
3047330f729Sjoerg }
3057330f729Sjoerg 
emitBuckets() const3067330f729Sjoerg void AppleAccelTableWriter::emitBuckets() const {
3077330f729Sjoerg   const auto &Buckets = Contents.getBuckets();
3087330f729Sjoerg   unsigned index = 0;
3097330f729Sjoerg   for (size_t i = 0, e = Buckets.size(); i < e; ++i) {
3107330f729Sjoerg     Asm->OutStreamer->AddComment("Bucket " + Twine(i));
3117330f729Sjoerg     if (!Buckets[i].empty())
3127330f729Sjoerg       Asm->emitInt32(index);
3137330f729Sjoerg     else
3147330f729Sjoerg       Asm->emitInt32(std::numeric_limits<uint32_t>::max());
3157330f729Sjoerg     // Buckets point in the list of hashes, not to the data. Do not increment
3167330f729Sjoerg     // the index multiple times in case of hash collisions.
3177330f729Sjoerg     uint64_t PrevHash = std::numeric_limits<uint64_t>::max();
3187330f729Sjoerg     for (auto *HD : Buckets[i]) {
3197330f729Sjoerg       uint32_t HashValue = HD->HashValue;
3207330f729Sjoerg       if (PrevHash != HashValue)
3217330f729Sjoerg         ++index;
3227330f729Sjoerg       PrevHash = HashValue;
3237330f729Sjoerg     }
3247330f729Sjoerg   }
3257330f729Sjoerg }
3267330f729Sjoerg 
emitData() const3277330f729Sjoerg void AppleAccelTableWriter::emitData() const {
3287330f729Sjoerg   const auto &Buckets = Contents.getBuckets();
329*82d56013Sjoerg   for (const AccelTableBase::HashList &Bucket : Buckets) {
3307330f729Sjoerg     uint64_t PrevHash = std::numeric_limits<uint64_t>::max();
331*82d56013Sjoerg     for (auto &Hash : Bucket) {
3327330f729Sjoerg       // Terminate the previous entry if there is no hash collision with the
3337330f729Sjoerg       // current one.
3347330f729Sjoerg       if (PrevHash != std::numeric_limits<uint64_t>::max() &&
3357330f729Sjoerg           PrevHash != Hash->HashValue)
3367330f729Sjoerg         Asm->emitInt32(0);
3377330f729Sjoerg       // Remember to emit the label for our offset.
338*82d56013Sjoerg       Asm->OutStreamer->emitLabel(Hash->Sym);
3397330f729Sjoerg       Asm->OutStreamer->AddComment(Hash->Name.getString());
3407330f729Sjoerg       Asm->emitDwarfStringOffset(Hash->Name);
3417330f729Sjoerg       Asm->OutStreamer->AddComment("Num DIEs");
3427330f729Sjoerg       Asm->emitInt32(Hash->Values.size());
3437330f729Sjoerg       for (const auto *V : Hash->Values)
3447330f729Sjoerg         static_cast<const AppleAccelTableData *>(V)->emit(Asm);
3457330f729Sjoerg       PrevHash = Hash->HashValue;
3467330f729Sjoerg     }
3477330f729Sjoerg     // Emit the final end marker for the bucket.
348*82d56013Sjoerg     if (!Bucket.empty())
3497330f729Sjoerg       Asm->emitInt32(0);
3507330f729Sjoerg   }
3517330f729Sjoerg }
3527330f729Sjoerg 
emit() const3537330f729Sjoerg void AppleAccelTableWriter::emit() const {
3547330f729Sjoerg   Header.emit(Asm);
3557330f729Sjoerg   HeaderData.emit(Asm);
3567330f729Sjoerg   emitBuckets();
3577330f729Sjoerg   emitHashes();
3587330f729Sjoerg   emitOffsets(SecBegin);
3597330f729Sjoerg   emitData();
3607330f729Sjoerg }
3617330f729Sjoerg 
3627330f729Sjoerg template <typename DataT>
emit(Dwarf5AccelTableWriter & Ctx)363*82d56013Sjoerg void Dwarf5AccelTableWriter<DataT>::Header::emit(Dwarf5AccelTableWriter &Ctx) {
3647330f729Sjoerg   assert(CompUnitCount > 0 && "Index must have at least one CU.");
3657330f729Sjoerg 
3667330f729Sjoerg   AsmPrinter *Asm = Ctx.Asm;
367*82d56013Sjoerg   Ctx.ContributionEnd =
368*82d56013Sjoerg       Asm->emitDwarfUnitLength("names", "Header: unit length");
3697330f729Sjoerg   Asm->OutStreamer->AddComment("Header: version");
3707330f729Sjoerg   Asm->emitInt16(Version);
3717330f729Sjoerg   Asm->OutStreamer->AddComment("Header: padding");
3727330f729Sjoerg   Asm->emitInt16(Padding);
3737330f729Sjoerg   Asm->OutStreamer->AddComment("Header: compilation unit count");
3747330f729Sjoerg   Asm->emitInt32(CompUnitCount);
3757330f729Sjoerg   Asm->OutStreamer->AddComment("Header: local type unit count");
3767330f729Sjoerg   Asm->emitInt32(LocalTypeUnitCount);
3777330f729Sjoerg   Asm->OutStreamer->AddComment("Header: foreign type unit count");
3787330f729Sjoerg   Asm->emitInt32(ForeignTypeUnitCount);
3797330f729Sjoerg   Asm->OutStreamer->AddComment("Header: bucket count");
3807330f729Sjoerg   Asm->emitInt32(BucketCount);
3817330f729Sjoerg   Asm->OutStreamer->AddComment("Header: name count");
3827330f729Sjoerg   Asm->emitInt32(NameCount);
3837330f729Sjoerg   Asm->OutStreamer->AddComment("Header: abbreviation table size");
384*82d56013Sjoerg   Asm->emitLabelDifference(Ctx.AbbrevEnd, Ctx.AbbrevStart, sizeof(uint32_t));
3857330f729Sjoerg   Asm->OutStreamer->AddComment("Header: augmentation string size");
3867330f729Sjoerg   assert(AugmentationStringSize % 4 == 0);
3877330f729Sjoerg   Asm->emitInt32(AugmentationStringSize);
3887330f729Sjoerg   Asm->OutStreamer->AddComment("Header: augmentation string");
389*82d56013Sjoerg   Asm->OutStreamer->emitBytes({AugmentationString, AugmentationStringSize});
3907330f729Sjoerg }
3917330f729Sjoerg 
3927330f729Sjoerg template <typename DataT>
getUniqueTags() const3937330f729Sjoerg DenseSet<uint32_t> Dwarf5AccelTableWriter<DataT>::getUniqueTags() const {
3947330f729Sjoerg   DenseSet<uint32_t> UniqueTags;
3957330f729Sjoerg   for (auto &Bucket : Contents.getBuckets()) {
3967330f729Sjoerg     for (auto *Hash : Bucket) {
3977330f729Sjoerg       for (auto *Value : Hash->Values) {
3987330f729Sjoerg         unsigned Tag = static_cast<const DataT *>(Value)->getDieTag();
3997330f729Sjoerg         UniqueTags.insert(Tag);
4007330f729Sjoerg       }
4017330f729Sjoerg     }
4027330f729Sjoerg   }
4037330f729Sjoerg   return UniqueTags;
4047330f729Sjoerg }
4057330f729Sjoerg 
4067330f729Sjoerg template <typename DataT>
4077330f729Sjoerg SmallVector<typename Dwarf5AccelTableWriter<DataT>::AttributeEncoding, 2>
getUniformAttributes() const4087330f729Sjoerg Dwarf5AccelTableWriter<DataT>::getUniformAttributes() const {
4097330f729Sjoerg   SmallVector<AttributeEncoding, 2> UA;
4107330f729Sjoerg   if (CompUnits.size() > 1) {
4117330f729Sjoerg     size_t LargestCUIndex = CompUnits.size() - 1;
4127330f729Sjoerg     dwarf::Form Form = DIEInteger::BestForm(/*IsSigned*/ false, LargestCUIndex);
4137330f729Sjoerg     UA.push_back({dwarf::DW_IDX_compile_unit, Form});
4147330f729Sjoerg   }
4157330f729Sjoerg   UA.push_back({dwarf::DW_IDX_die_offset, dwarf::DW_FORM_ref4});
4167330f729Sjoerg   return UA;
4177330f729Sjoerg }
4187330f729Sjoerg 
4197330f729Sjoerg template <typename DataT>
emitCUList() const4207330f729Sjoerg void Dwarf5AccelTableWriter<DataT>::emitCUList() const {
4217330f729Sjoerg   for (const auto &CU : enumerate(CompUnits)) {
4227330f729Sjoerg     Asm->OutStreamer->AddComment("Compilation unit " + Twine(CU.index()));
4237330f729Sjoerg     Asm->emitDwarfSymbolReference(CU.value());
4247330f729Sjoerg   }
4257330f729Sjoerg }
4267330f729Sjoerg 
4277330f729Sjoerg template <typename DataT>
emitBuckets() const4287330f729Sjoerg void Dwarf5AccelTableWriter<DataT>::emitBuckets() const {
4297330f729Sjoerg   uint32_t Index = 1;
4307330f729Sjoerg   for (const auto &Bucket : enumerate(Contents.getBuckets())) {
4317330f729Sjoerg     Asm->OutStreamer->AddComment("Bucket " + Twine(Bucket.index()));
4327330f729Sjoerg     Asm->emitInt32(Bucket.value().empty() ? 0 : Index);
4337330f729Sjoerg     Index += Bucket.value().size();
4347330f729Sjoerg   }
4357330f729Sjoerg }
4367330f729Sjoerg 
4377330f729Sjoerg template <typename DataT>
emitStringOffsets() const4387330f729Sjoerg void Dwarf5AccelTableWriter<DataT>::emitStringOffsets() const {
4397330f729Sjoerg   for (const auto &Bucket : enumerate(Contents.getBuckets())) {
4407330f729Sjoerg     for (auto *Hash : Bucket.value()) {
4417330f729Sjoerg       DwarfStringPoolEntryRef String = Hash->Name;
4427330f729Sjoerg       Asm->OutStreamer->AddComment("String in Bucket " + Twine(Bucket.index()) +
4437330f729Sjoerg                                    ": " + String.getString());
4447330f729Sjoerg       Asm->emitDwarfStringOffset(String);
4457330f729Sjoerg     }
4467330f729Sjoerg   }
4477330f729Sjoerg }
4487330f729Sjoerg 
4497330f729Sjoerg template <typename DataT>
emitAbbrevs() const4507330f729Sjoerg void Dwarf5AccelTableWriter<DataT>::emitAbbrevs() const {
451*82d56013Sjoerg   Asm->OutStreamer->emitLabel(AbbrevStart);
4527330f729Sjoerg   for (const auto &Abbrev : Abbreviations) {
4537330f729Sjoerg     Asm->OutStreamer->AddComment("Abbrev code");
4547330f729Sjoerg     assert(Abbrev.first != 0);
455*82d56013Sjoerg     Asm->emitULEB128(Abbrev.first);
4567330f729Sjoerg     Asm->OutStreamer->AddComment(dwarf::TagString(Abbrev.first));
457*82d56013Sjoerg     Asm->emitULEB128(Abbrev.first);
4587330f729Sjoerg     for (const auto &AttrEnc : Abbrev.second) {
459*82d56013Sjoerg       Asm->emitULEB128(AttrEnc.Index, dwarf::IndexString(AttrEnc.Index).data());
460*82d56013Sjoerg       Asm->emitULEB128(AttrEnc.Form,
4617330f729Sjoerg                        dwarf::FormEncodingString(AttrEnc.Form).data());
4627330f729Sjoerg     }
463*82d56013Sjoerg     Asm->emitULEB128(0, "End of abbrev");
464*82d56013Sjoerg     Asm->emitULEB128(0, "End of abbrev");
4657330f729Sjoerg   }
466*82d56013Sjoerg   Asm->emitULEB128(0, "End of abbrev list");
467*82d56013Sjoerg   Asm->OutStreamer->emitLabel(AbbrevEnd);
4687330f729Sjoerg }
4697330f729Sjoerg 
4707330f729Sjoerg template <typename DataT>
emitEntry(const DataT & Entry) const4717330f729Sjoerg void Dwarf5AccelTableWriter<DataT>::emitEntry(const DataT &Entry) const {
4727330f729Sjoerg   auto AbbrevIt = Abbreviations.find(Entry.getDieTag());
4737330f729Sjoerg   assert(AbbrevIt != Abbreviations.end() &&
4747330f729Sjoerg          "Why wasn't this abbrev generated?");
4757330f729Sjoerg 
476*82d56013Sjoerg   Asm->emitULEB128(AbbrevIt->first, "Abbreviation code");
4777330f729Sjoerg   for (const auto &AttrEnc : AbbrevIt->second) {
4787330f729Sjoerg     Asm->OutStreamer->AddComment(dwarf::IndexString(AttrEnc.Index));
4797330f729Sjoerg     switch (AttrEnc.Index) {
4807330f729Sjoerg     case dwarf::DW_IDX_compile_unit: {
4817330f729Sjoerg       DIEInteger ID(getCUIndexForEntry(Entry));
482*82d56013Sjoerg       ID.emitValue(Asm, AttrEnc.Form);
4837330f729Sjoerg       break;
4847330f729Sjoerg     }
4857330f729Sjoerg     case dwarf::DW_IDX_die_offset:
4867330f729Sjoerg       assert(AttrEnc.Form == dwarf::DW_FORM_ref4);
4877330f729Sjoerg       Asm->emitInt32(Entry.getDieOffset());
4887330f729Sjoerg       break;
4897330f729Sjoerg     default:
4907330f729Sjoerg       llvm_unreachable("Unexpected index attribute!");
4917330f729Sjoerg     }
4927330f729Sjoerg   }
4937330f729Sjoerg }
4947330f729Sjoerg 
emitData() const4957330f729Sjoerg template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emitData() const {
496*82d56013Sjoerg   Asm->OutStreamer->emitLabel(EntryPool);
4977330f729Sjoerg   for (auto &Bucket : Contents.getBuckets()) {
4987330f729Sjoerg     for (auto *Hash : Bucket) {
4997330f729Sjoerg       // Remember to emit the label for our offset.
500*82d56013Sjoerg       Asm->OutStreamer->emitLabel(Hash->Sym);
5017330f729Sjoerg       for (const auto *Value : Hash->Values)
5027330f729Sjoerg         emitEntry(*static_cast<const DataT *>(Value));
5037330f729Sjoerg       Asm->OutStreamer->AddComment("End of list: " + Hash->Name.getString());
504*82d56013Sjoerg       Asm->emitInt8(0);
5057330f729Sjoerg     }
5067330f729Sjoerg   }
5077330f729Sjoerg }
5087330f729Sjoerg 
5097330f729Sjoerg template <typename DataT>
Dwarf5AccelTableWriter(AsmPrinter * Asm,const AccelTableBase & Contents,ArrayRef<MCSymbol * > CompUnits,llvm::function_ref<unsigned (const DataT &)> getCUIndexForEntry)5107330f729Sjoerg Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
5117330f729Sjoerg     AsmPrinter *Asm, const AccelTableBase &Contents,
5127330f729Sjoerg     ArrayRef<MCSymbol *> CompUnits,
5137330f729Sjoerg     llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry)
5147330f729Sjoerg     : AccelTableWriter(Asm, Contents, false),
5157330f729Sjoerg       Header(CompUnits.size(), Contents.getBucketCount(),
5167330f729Sjoerg              Contents.getUniqueNameCount()),
5177330f729Sjoerg       CompUnits(CompUnits), getCUIndexForEntry(std::move(getCUIndexForEntry)) {
5187330f729Sjoerg   DenseSet<uint32_t> UniqueTags = getUniqueTags();
5197330f729Sjoerg   SmallVector<AttributeEncoding, 2> UniformAttributes = getUniformAttributes();
5207330f729Sjoerg 
5217330f729Sjoerg   Abbreviations.reserve(UniqueTags.size());
5227330f729Sjoerg   for (uint32_t Tag : UniqueTags)
5237330f729Sjoerg     Abbreviations.try_emplace(Tag, UniformAttributes);
5247330f729Sjoerg }
5257330f729Sjoerg 
emit()526*82d56013Sjoerg template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emit() {
5277330f729Sjoerg   Header.emit(*this);
5287330f729Sjoerg   emitCUList();
5297330f729Sjoerg   emitBuckets();
5307330f729Sjoerg   emitHashes();
5317330f729Sjoerg   emitStringOffsets();
5327330f729Sjoerg   emitOffsets(EntryPool);
5337330f729Sjoerg   emitAbbrevs();
5347330f729Sjoerg   emitData();
535*82d56013Sjoerg   Asm->OutStreamer->emitValueToAlignment(4, 0);
536*82d56013Sjoerg   Asm->OutStreamer->emitLabel(ContributionEnd);
5377330f729Sjoerg }
5387330f729Sjoerg 
emitAppleAccelTableImpl(AsmPrinter * Asm,AccelTableBase & Contents,StringRef Prefix,const MCSymbol * SecBegin,ArrayRef<AppleAccelTableData::Atom> Atoms)5397330f729Sjoerg void llvm::emitAppleAccelTableImpl(AsmPrinter *Asm, AccelTableBase &Contents,
5407330f729Sjoerg                                    StringRef Prefix, const MCSymbol *SecBegin,
5417330f729Sjoerg                                    ArrayRef<AppleAccelTableData::Atom> Atoms) {
5427330f729Sjoerg   Contents.finalize(Asm, Prefix);
5437330f729Sjoerg   AppleAccelTableWriter(Asm, Contents, Atoms, SecBegin).emit();
5447330f729Sjoerg }
5457330f729Sjoerg 
emitDWARF5AccelTable(AsmPrinter * Asm,AccelTable<DWARF5AccelTableData> & Contents,const DwarfDebug & DD,ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs)5467330f729Sjoerg void llvm::emitDWARF5AccelTable(
5477330f729Sjoerg     AsmPrinter *Asm, AccelTable<DWARF5AccelTableData> &Contents,
5487330f729Sjoerg     const DwarfDebug &DD, ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs) {
5497330f729Sjoerg   std::vector<MCSymbol *> CompUnits;
5507330f729Sjoerg   SmallVector<unsigned, 1> CUIndex(CUs.size());
5517330f729Sjoerg   int Count = 0;
5527330f729Sjoerg   for (const auto &CU : enumerate(CUs)) {
5537330f729Sjoerg     if (CU.value()->getCUNode()->getNameTableKind() !=
5547330f729Sjoerg         DICompileUnit::DebugNameTableKind::Default)
5557330f729Sjoerg       continue;
5567330f729Sjoerg     CUIndex[CU.index()] = Count++;
5577330f729Sjoerg     assert(CU.index() == CU.value()->getUniqueID());
5587330f729Sjoerg     const DwarfCompileUnit *MainCU =
5597330f729Sjoerg         DD.useSplitDwarf() ? CU.value()->getSkeleton() : CU.value().get();
5607330f729Sjoerg     CompUnits.push_back(MainCU->getLabelBegin());
5617330f729Sjoerg   }
5627330f729Sjoerg 
5637330f729Sjoerg   if (CompUnits.empty())
5647330f729Sjoerg     return;
5657330f729Sjoerg 
5667330f729Sjoerg   Asm->OutStreamer->SwitchSection(
5677330f729Sjoerg       Asm->getObjFileLowering().getDwarfDebugNamesSection());
5687330f729Sjoerg 
5697330f729Sjoerg   Contents.finalize(Asm, "names");
5707330f729Sjoerg   Dwarf5AccelTableWriter<DWARF5AccelTableData>(
5717330f729Sjoerg       Asm, Contents, CompUnits,
5727330f729Sjoerg       [&](const DWARF5AccelTableData &Entry) {
5737330f729Sjoerg         const DIE *CUDie = Entry.getDie().getUnitDie();
5747330f729Sjoerg         return CUIndex[DD.lookupCU(CUDie)->getUniqueID()];
5757330f729Sjoerg       })
5767330f729Sjoerg       .emit();
5777330f729Sjoerg }
5787330f729Sjoerg 
emitDWARF5AccelTable(AsmPrinter * Asm,AccelTable<DWARF5AccelTableStaticData> & Contents,ArrayRef<MCSymbol * > CUs,llvm::function_ref<unsigned (const DWARF5AccelTableStaticData &)> getCUIndexForEntry)5797330f729Sjoerg void llvm::emitDWARF5AccelTable(
5807330f729Sjoerg     AsmPrinter *Asm, AccelTable<DWARF5AccelTableStaticData> &Contents,
5817330f729Sjoerg     ArrayRef<MCSymbol *> CUs,
5827330f729Sjoerg     llvm::function_ref<unsigned(const DWARF5AccelTableStaticData &)>
5837330f729Sjoerg         getCUIndexForEntry) {
5847330f729Sjoerg   Contents.finalize(Asm, "names");
5857330f729Sjoerg   Dwarf5AccelTableWriter<DWARF5AccelTableStaticData>(Asm, Contents, CUs,
5867330f729Sjoerg                                                      getCUIndexForEntry)
5877330f729Sjoerg       .emit();
5887330f729Sjoerg }
5897330f729Sjoerg 
emit(AsmPrinter * Asm) const5907330f729Sjoerg void AppleAccelTableOffsetData::emit(AsmPrinter *Asm) const {
591*82d56013Sjoerg   assert(Die.getDebugSectionOffset() <= UINT32_MAX &&
592*82d56013Sjoerg          "The section offset exceeds the limit.");
5937330f729Sjoerg   Asm->emitInt32(Die.getDebugSectionOffset());
5947330f729Sjoerg }
5957330f729Sjoerg 
emit(AsmPrinter * Asm) const5967330f729Sjoerg void AppleAccelTableTypeData::emit(AsmPrinter *Asm) const {
597*82d56013Sjoerg   assert(Die.getDebugSectionOffset() <= UINT32_MAX &&
598*82d56013Sjoerg          "The section offset exceeds the limit.");
5997330f729Sjoerg   Asm->emitInt32(Die.getDebugSectionOffset());
6007330f729Sjoerg   Asm->emitInt16(Die.getTag());
6017330f729Sjoerg   Asm->emitInt8(0);
6027330f729Sjoerg }
6037330f729Sjoerg 
emit(AsmPrinter * Asm) const6047330f729Sjoerg void AppleAccelTableStaticOffsetData::emit(AsmPrinter *Asm) const {
6057330f729Sjoerg   Asm->emitInt32(Offset);
6067330f729Sjoerg }
6077330f729Sjoerg 
emit(AsmPrinter * Asm) const6087330f729Sjoerg void AppleAccelTableStaticTypeData::emit(AsmPrinter *Asm) const {
6097330f729Sjoerg   Asm->emitInt32(Offset);
6107330f729Sjoerg   Asm->emitInt16(Tag);
6117330f729Sjoerg   Asm->emitInt8(ObjCClassIsImplementation ? dwarf::DW_FLAG_type_implementation
6127330f729Sjoerg                                           : 0);
6137330f729Sjoerg   Asm->emitInt32(QualifiedNameHash);
6147330f729Sjoerg }
6157330f729Sjoerg 
6167330f729Sjoerg constexpr AppleAccelTableData::Atom AppleAccelTableTypeData::Atoms[];
6177330f729Sjoerg constexpr AppleAccelTableData::Atom AppleAccelTableOffsetData::Atoms[];
6187330f729Sjoerg constexpr AppleAccelTableData::Atom AppleAccelTableStaticOffsetData::Atoms[];
6197330f729Sjoerg constexpr AppleAccelTableData::Atom AppleAccelTableStaticTypeData::Atoms[];
6207330f729Sjoerg 
6217330f729Sjoerg #ifndef NDEBUG
print(raw_ostream & OS) const6227330f729Sjoerg void AppleAccelTableWriter::Header::print(raw_ostream &OS) const {
6237330f729Sjoerg   OS << "Magic: " << format("0x%x", Magic) << "\n"
6247330f729Sjoerg      << "Version: " << Version << "\n"
6257330f729Sjoerg      << "Hash Function: " << HashFunction << "\n"
6267330f729Sjoerg      << "Bucket Count: " << BucketCount << "\n"
6277330f729Sjoerg      << "Header Data Length: " << HeaderDataLength << "\n";
6287330f729Sjoerg }
6297330f729Sjoerg 
print(raw_ostream & OS) const6307330f729Sjoerg void AppleAccelTableData::Atom::print(raw_ostream &OS) const {
6317330f729Sjoerg   OS << "Type: " << dwarf::AtomTypeString(Type) << "\n"
6327330f729Sjoerg      << "Form: " << dwarf::FormEncodingString(Form) << "\n";
6337330f729Sjoerg }
6347330f729Sjoerg 
print(raw_ostream & OS) const6357330f729Sjoerg void AppleAccelTableWriter::HeaderData::print(raw_ostream &OS) const {
6367330f729Sjoerg   OS << "DIE Offset Base: " << DieOffsetBase << "\n";
6377330f729Sjoerg   for (auto Atom : Atoms)
6387330f729Sjoerg     Atom.print(OS);
6397330f729Sjoerg }
6407330f729Sjoerg 
print(raw_ostream & OS) const6417330f729Sjoerg void AppleAccelTableWriter::print(raw_ostream &OS) const {
6427330f729Sjoerg   Header.print(OS);
6437330f729Sjoerg   HeaderData.print(OS);
6447330f729Sjoerg   Contents.print(OS);
6457330f729Sjoerg   SecBegin->print(OS, nullptr);
6467330f729Sjoerg }
6477330f729Sjoerg 
print(raw_ostream & OS) const6487330f729Sjoerg void AccelTableBase::HashData::print(raw_ostream &OS) const {
6497330f729Sjoerg   OS << "Name: " << Name.getString() << "\n";
6507330f729Sjoerg   OS << "  Hash Value: " << format("0x%x", HashValue) << "\n";
6517330f729Sjoerg   OS << "  Symbol: ";
6527330f729Sjoerg   if (Sym)
6537330f729Sjoerg     OS << *Sym;
6547330f729Sjoerg   else
6557330f729Sjoerg     OS << "<none>";
6567330f729Sjoerg   OS << "\n";
6577330f729Sjoerg   for (auto *Value : Values)
6587330f729Sjoerg     Value->print(OS);
6597330f729Sjoerg }
6607330f729Sjoerg 
print(raw_ostream & OS) const6617330f729Sjoerg void AccelTableBase::print(raw_ostream &OS) const {
6627330f729Sjoerg   // Print Content.
6637330f729Sjoerg   OS << "Entries: \n";
6647330f729Sjoerg   for (const auto &Entry : Entries) {
6657330f729Sjoerg     OS << "Name: " << Entry.first() << "\n";
6667330f729Sjoerg     for (auto *V : Entry.second.Values)
6677330f729Sjoerg       V->print(OS);
6687330f729Sjoerg   }
6697330f729Sjoerg 
6707330f729Sjoerg   OS << "Buckets and Hashes: \n";
6717330f729Sjoerg   for (auto &Bucket : Buckets)
6727330f729Sjoerg     for (auto &Hash : Bucket)
6737330f729Sjoerg       Hash->print(OS);
6747330f729Sjoerg 
6757330f729Sjoerg   OS << "Data: \n";
6767330f729Sjoerg   for (auto &E : Entries)
6777330f729Sjoerg     E.second.print(OS);
6787330f729Sjoerg }
6797330f729Sjoerg 
print(raw_ostream & OS) const6807330f729Sjoerg void DWARF5AccelTableData::print(raw_ostream &OS) const {
6817330f729Sjoerg   OS << "  Offset: " << getDieOffset() << "\n";
6827330f729Sjoerg   OS << "  Tag: " << dwarf::TagString(getDieTag()) << "\n";
6837330f729Sjoerg }
6847330f729Sjoerg 
print(raw_ostream & OS) const6857330f729Sjoerg void DWARF5AccelTableStaticData::print(raw_ostream &OS) const {
6867330f729Sjoerg   OS << "  Offset: " << getDieOffset() << "\n";
6877330f729Sjoerg   OS << "  Tag: " << dwarf::TagString(getDieTag()) << "\n";
6887330f729Sjoerg }
6897330f729Sjoerg 
print(raw_ostream & OS) const6907330f729Sjoerg void AppleAccelTableOffsetData::print(raw_ostream &OS) const {
6917330f729Sjoerg   OS << "  Offset: " << Die.getOffset() << "\n";
6927330f729Sjoerg }
6937330f729Sjoerg 
print(raw_ostream & OS) const6947330f729Sjoerg void AppleAccelTableTypeData::print(raw_ostream &OS) const {
6957330f729Sjoerg   OS << "  Offset: " << Die.getOffset() << "\n";
6967330f729Sjoerg   OS << "  Tag: " << dwarf::TagString(Die.getTag()) << "\n";
6977330f729Sjoerg }
6987330f729Sjoerg 
print(raw_ostream & OS) const6997330f729Sjoerg void AppleAccelTableStaticOffsetData::print(raw_ostream &OS) const {
7007330f729Sjoerg   OS << "  Static Offset: " << Offset << "\n";
7017330f729Sjoerg }
7027330f729Sjoerg 
print(raw_ostream & OS) const7037330f729Sjoerg void AppleAccelTableStaticTypeData::print(raw_ostream &OS) const {
7047330f729Sjoerg   OS << "  Static Offset: " << Offset << "\n";
7057330f729Sjoerg   OS << "  QualifiedNameHash: " << format("%x\n", QualifiedNameHash) << "\n";
7067330f729Sjoerg   OS << "  Tag: " << dwarf::TagString(Tag) << "\n";
7077330f729Sjoerg   OS << "  ObjCClassIsImplementation: "
7087330f729Sjoerg      << (ObjCClassIsImplementation ? "true" : "false");
7097330f729Sjoerg   OS << "\n";
7107330f729Sjoerg }
7117330f729Sjoerg #endif
712