29 : Header(8 + (atomList.size() * 4)), HeaderData(atomList),
35 assert(Data.empty() &&
"Already finalized!");
38 DataArray &DIEs = Entries[
Name];
42 void DwarfAccelTable::ComputeBucketCount(
void) {
44 std::vector<uint32_t> uniques(Data.size());
45 for (
size_t i = 0, e = Data.size(); i < e; ++i)
46 uniques[i] = Data[i]->HashValue;
48 std::vector<uint32_t>::iterator p =
49 std::unique(uniques.begin(), uniques.end());
50 uint32_t num = std::distance(uniques.begin(), p);
54 Header.bucket_count = num / 4;
56 Header.bucket_count = num / 2;
58 Header.bucket_count = num > 0 ? num : 1;
60 Header.hashes_count = num;
75 std::stable_sort(EI->second.begin(), EI->second.end(),
compareDIEs);
76 EI->second.erase(std::unique(EI->second.begin(), EI->second.end()),
79 HashData *Entry =
new (Allocator) HashData(EI->getKey(), EI->second);
80 Data.push_back(Entry);
91 Buckets.resize(Header.bucket_count);
92 for (
size_t i = 0, e = Data.size(); i < e; ++i) {
93 uint32_t bucket = Data[i]->HashValue % Header.bucket_count;
94 Buckets[bucket].push_back(Data[i]);
114 Asm->
EmitInt32(HeaderData.die_offset_base);
117 for (
size_t i = 0; i < HeaderData.Atoms.size(); i++) {
118 Atom
A = HeaderData.Atoms[i];
128 void DwarfAccelTable::EmitBuckets(
AsmPrinter *Asm) {
130 for (
size_t i = 0, e = Buckets.size(); i < e; ++i) {
132 if (Buckets[i].size() != 0)
136 index += Buckets[i].size();
142 void DwarfAccelTable::EmitHashes(
AsmPrinter *Asm) {
143 for (
size_t i = 0, e = Buckets.size(); i < e; ++i) {
144 for (HashList::const_iterator
HI = Buckets[i].
begin(),
145 HE = Buckets[i].end();
158 for (
size_t i = 0, e = Buckets.size(); i < e; ++i) {
159 for (HashList::const_iterator
HI = Buckets[i].
begin(),
160 HE = Buckets[i].end();
176 uint64_t PrevHash = UINT64_MAX;
177 for (
size_t i = 0, e = Buckets.size(); i < e; ++i) {
178 for (HashList::const_iterator
HI = Buckets[i].
begin(),
179 HE = Buckets[i].end();
189 DI = (*HI)->Data.begin(),
190 DE = (*HI)->Data.end();
196 if (HeaderData.Atoms.size() > 1) {
202 if (PrevHash != (*HI)->HashValue)
204 PrevHash = (*HI)->HashValue;
221 EmitOffsets(Asm, SecBegin);
237 O <<
"Name: " << EI->getKeyData() <<
"\n";
238 for (DataArray::const_iterator DI = EI->second.begin(),
239 DE = EI->second.end();
244 O <<
"Buckets and Hashes: \n";
245 for (
size_t i = 0, e = Buckets.size(); i < e; ++i)
246 for (HashList::const_iterator
HI = Buckets[i].
begin(),
247 HE = Buckets[i].end();
252 for (std::vector<HashData *>::const_iterator DI = Data.begin(),
virtual void AddComment(const Twine &T)
const char * AtomTypeString(unsigned Atom)
AtomTypeString - Return the string for the specified Atom type.
const char * FormEncodingString(unsigned Encoding)
void EmitInt8(int Value) const
Collects and handles information specific to a particular collection of units.
const_iterator begin(StringRef path)
Get begin iterator over path.
void EmitInt32(int Value) const
MCContext & getContext() const
static const MCBinaryExpr * CreateSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
void AddName(StringRef, DIE *, char=0)
void FinalizeTable(AsmPrinter *, StringRef)
void EmitInt16(int Value) const
void EmitValue(const MCExpr *Value, unsigned Size)
static const MCSymbolRefExpr * Create(const MCSymbol *Symbol, MCContext &Ctx)
void array_pod_sort(IteratorTy Start, IteratorTy End)
void Emit(AsmPrinter *, MCSymbol *, DwarfUnits *)
static bool compareDIEs(const DwarfAccelTable::HashDataContents *A, const DwarfAccelTable::HashDataContents *B)
virtual void EmitLabel(MCSymbol *Symbol)
void EmitSectionOffset(const MCSymbol *Label, const MCSymbol *SectionLabel) const
unsigned getOffset() const
void print(raw_ostream &O)
MCSymbol * getStringPoolSym()
Returns the entry into the start of the pool.
MCSymbol * getStringPoolEntry(StringRef Str)
Returns an entry into the string pool with the given string text.
MCSymbol * GetTempSymbol(StringRef Name, unsigned ID) const