void AsmPrinter::emitDwarfAbbrev(const DIEAbbrev &Abbrev) const { // Emit the abbreviations code (base 1 index.) EmitULEB128(Abbrev.getNumber(), "Abbreviation Code"); // Emit the abbreviations data. Abbrev.Emit(this); }
// Define a unique number for the abbreviation. // void DwarfFile::assignAbbrevNumber(DIEAbbrev &Abbrev) { // Check the set for priors. DIEAbbrev *InSet = AbbreviationsSet.GetOrInsertNode(&Abbrev); // If it's newly added. if (InSet == &Abbrev) { // Add to abbreviation list. Abbreviations.push_back(&Abbrev); // Assign the vector position + 1 as its number. Abbrev.setNumber(Abbreviations.size()); } else { // Assign existing abbreviation number. Abbrev.setNumber(InSet->getNumber()); } }
DIEAbbrev &DIEAbbrevSet::uniqueAbbreviation(DIE &Die) { FoldingSetNodeID ID; DIEAbbrev Abbrev = Die.generateAbbrev(); Abbrev.Profile(ID); void *InsertPos; if (DIEAbbrev *Existing = AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) { Die.setAbbrevNumber(Existing->getNumber()); return *Existing; } // Move the abbreviation to the heap and assign a number. DIEAbbrev *New = new (Alloc) DIEAbbrev(std::move(Abbrev)); Abbreviations.push_back(New); New->setNumber(Abbreviations.size()); Die.setAbbrevNumber(Abbreviations.size()); // Store it for lookup. AbbreviationsSet.InsertNode(New, InsertPos); return *New; }