@@ -182,11 +182,7 @@ class AppleAccelTableWriter : public AccelTableWriter {
182
182
// / Class responsible for emitting a DWARF v5 Accelerator Table. The only
183
183
// / public function is emit(), which performs the actual emission.
184
184
// /
185
- // / The class is templated in its data type. This allows us to emit both dyamic
186
- // / and static data entries. A callback abstract the logic to provide a CU
187
- // / index for a given entry, which is different per data type, but identical
188
- // / for every entry in the same table.
189
- template <typename DataT>
185
+ // / A callback abstracts the logic to provide a CU index for a given entry.
190
186
class Dwarf5AccelTableWriter : public AccelTableWriter {
191
187
struct Header {
192
188
uint16_t Version = 5 ;
@@ -216,7 +212,7 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
216
212
ArrayRef<std::variant<MCSymbol *, uint64_t >> CompUnits;
217
213
ArrayRef<std::variant<MCSymbol *, uint64_t >> TypeUnits;
218
214
llvm::function_ref<std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(
219
- const DataT &)>
215
+ const DWARF5AccelTableData &)>
220
216
getIndexForEntry;
221
217
MCSymbol *ContributionEnd = nullptr ;
222
218
MCSymbol *AbbrevStart = Asm->createTempSymbol (" names_abbrev_start" );
@@ -232,16 +228,16 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
232
228
void emitBuckets () const ;
233
229
void emitStringOffsets () const ;
234
230
void emitAbbrevs () const ;
235
- void emitEntry (const DataT &Entry) const ;
231
+ void emitEntry (const DWARF5AccelTableData &Entry) const ;
236
232
void emitData () const ;
237
233
238
234
public:
239
235
Dwarf5AccelTableWriter (
240
236
AsmPrinter *Asm, const AccelTableBase &Contents,
241
237
ArrayRef<std::variant<MCSymbol *, uint64_t >> CompUnits,
242
238
ArrayRef<std::variant<MCSymbol *, uint64_t >> TypeUnits,
243
- llvm::function_ref<
244
- std::optional<DWARF5AccelTable::UnitIndexAndEncoding>( const DataT &)>
239
+ llvm::function_ref<std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(
240
+ const DWARF5AccelTableData &)>
245
241
getIndexForEntry,
246
242
bool IsSplitDwarf);
247
243
@@ -370,8 +366,7 @@ DWARF5AccelTableData::DWARF5AccelTableData(const DIE &Die,
370
366
const bool IsTU)
371
367
: OffsetVal(&Die), DieTag(Die.getTag()), UnitID(UnitID), IsTU(IsTU) {}
372
368
373
- template <typename DataT>
374
- void Dwarf5AccelTableWriter<DataT>::Header::emit(Dwarf5AccelTableWriter &Ctx) {
369
+ void Dwarf5AccelTableWriter::Header::emit (Dwarf5AccelTableWriter &Ctx) {
375
370
assert (CompUnitCount > 0 && " Index must have at least one CU." );
376
371
377
372
AsmPrinter *Asm = Ctx.Asm ;
@@ -417,14 +412,14 @@ static uint32_t constructAbbreviationTag(
417
412
AbbrvTag |= Tag << LowerBitSize;
418
413
return AbbrvTag;
419
414
}
420
- template <typename DataT>
421
- void Dwarf5AccelTableWriter<DataT>::populateAbbrevsMap() {
415
+ void Dwarf5AccelTableWriter::populateAbbrevsMap () {
422
416
for (auto &Bucket : Contents.getBuckets ()) {
423
417
for (auto *Hash : Bucket) {
424
418
for (auto *Value : Hash->Values ) {
425
419
std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet =
426
- getIndexForEntry (*static_cast <const DataT *>(Value));
427
- unsigned Tag = static_cast <const DataT *>(Value)->getDieTag ();
420
+ getIndexForEntry (*static_cast <const DWARF5AccelTableData *>(Value));
421
+ unsigned Tag =
422
+ static_cast <const DWARF5AccelTableData *>(Value)->getDieTag ();
428
423
uint32_t AbbrvTag = constructAbbreviationTag (Tag, EntryRet);
429
424
if (Abbreviations.count (AbbrvTag) == 0 ) {
430
425
SmallVector<DWARF5AccelTableData::AttributeEncoding, 2 > UA;
@@ -438,8 +433,7 @@ void Dwarf5AccelTableWriter<DataT>::populateAbbrevsMap() {
438
433
}
439
434
}
440
435
441
- template <typename DataT>
442
- void Dwarf5AccelTableWriter<DataT>::emitCUList() const {
436
+ void Dwarf5AccelTableWriter::emitCUList () const {
443
437
for (const auto &CU : enumerate(CompUnits)) {
444
438
Asm->OutStreamer ->AddComment (" Compilation unit " + Twine (CU.index ()));
445
439
if (std::holds_alternative<MCSymbol *>(CU.value ()))
@@ -449,8 +443,7 @@ void Dwarf5AccelTableWriter<DataT>::emitCUList() const {
449
443
}
450
444
}
451
445
452
- template <typename DataT>
453
- void Dwarf5AccelTableWriter<DataT>::emitTUList() const {
446
+ void Dwarf5AccelTableWriter::emitTUList () const {
454
447
for (const auto &TU : enumerate(TypeUnits)) {
455
448
Asm->OutStreamer ->AddComment (" Type unit " + Twine (TU.index ()));
456
449
if (std::holds_alternative<MCSymbol *>(TU.value ()))
@@ -462,8 +455,7 @@ void Dwarf5AccelTableWriter<DataT>::emitTUList() const {
462
455
}
463
456
}
464
457
465
- template <typename DataT>
466
- void Dwarf5AccelTableWriter<DataT>::emitBuckets() const {
458
+ void Dwarf5AccelTableWriter::emitBuckets () const {
467
459
uint32_t Index = 1 ;
468
460
for (const auto &Bucket : enumerate(Contents.getBuckets ())) {
469
461
Asm->OutStreamer ->AddComment (" Bucket " + Twine (Bucket.index ()));
@@ -472,8 +464,7 @@ void Dwarf5AccelTableWriter<DataT>::emitBuckets() const {
472
464
}
473
465
}
474
466
475
- template <typename DataT>
476
- void Dwarf5AccelTableWriter<DataT>::emitStringOffsets() const {
467
+ void Dwarf5AccelTableWriter::emitStringOffsets () const {
477
468
for (const auto &Bucket : enumerate(Contents.getBuckets ())) {
478
469
for (auto *Hash : Bucket.value ()) {
479
470
DwarfStringPoolEntryRef String = Hash->Name ;
@@ -484,8 +475,7 @@ void Dwarf5AccelTableWriter<DataT>::emitStringOffsets() const {
484
475
}
485
476
}
486
477
487
- template <typename DataT>
488
- void Dwarf5AccelTableWriter<DataT>::emitAbbrevs() const {
478
+ void Dwarf5AccelTableWriter::emitAbbrevs () const {
489
479
Asm->OutStreamer ->emitLabel (AbbrevStart);
490
480
for (const auto &Abbrev : Abbreviations) {
491
481
Asm->OutStreamer ->AddComment (" Abbrev code" );
@@ -506,8 +496,8 @@ void Dwarf5AccelTableWriter<DataT>::emitAbbrevs() const {
506
496
Asm->OutStreamer ->emitLabel (AbbrevEnd);
507
497
}
508
498
509
- template < typename DataT>
510
- void Dwarf5AccelTableWriter<DataT>::emitEntry( const DataT &Entry) const {
499
+ void Dwarf5AccelTableWriter::emitEntry (
500
+ const DWARF5AccelTableData &Entry) const {
511
501
std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet =
512
502
getIndexForEntry (Entry);
513
503
uint32_t AbbrvTag = constructAbbreviationTag (Entry.getDieTag (), EntryRet);
@@ -537,27 +527,26 @@ void Dwarf5AccelTableWriter<DataT>::emitEntry(const DataT &Entry) const {
537
527
}
538
528
}
539
529
540
- template < typename DataT> void Dwarf5AccelTableWriter<DataT> ::emitData() const {
530
+ void Dwarf5AccelTableWriter::emitData () const {
541
531
Asm->OutStreamer ->emitLabel (EntryPool);
542
532
for (auto &Bucket : Contents.getBuckets ()) {
543
533
for (auto *Hash : Bucket) {
544
534
// Remember to emit the label for our offset.
545
535
Asm->OutStreamer ->emitLabel (Hash->Sym );
546
536
for (const auto *Value : Hash->Values )
547
- emitEntry (*static_cast <const DataT *>(Value));
537
+ emitEntry (*static_cast <const DWARF5AccelTableData *>(Value));
548
538
Asm->OutStreamer ->AddComment (" End of list: " + Hash->Name .getString ());
549
539
Asm->emitInt8 (0 );
550
540
}
551
541
}
552
542
}
553
543
554
- template <typename DataT>
555
- Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
544
+ Dwarf5AccelTableWriter::Dwarf5AccelTableWriter (
556
545
AsmPrinter *Asm, const AccelTableBase &Contents,
557
546
ArrayRef<std::variant<MCSymbol *, uint64_t >> CompUnits,
558
547
ArrayRef<std::variant<MCSymbol *, uint64_t >> TypeUnits,
559
- llvm::function_ref<
560
- std::optional<DWARF5AccelTable::UnitIndexAndEncoding>( const DataT &)>
548
+ llvm::function_ref<std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(
549
+ const DWARF5AccelTableData &)>
561
550
getIndexForEntry,
562
551
bool IsSplitDwarf)
563
552
: AccelTableWriter(Asm, Contents, false ),
@@ -570,7 +559,7 @@ Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
570
559
populateAbbrevsMap ();
571
560
}
572
561
573
- template < typename DataT> void Dwarf5AccelTableWriter<DataT> ::emit() {
562
+ void Dwarf5AccelTableWriter::emit () {
574
563
Header.emit (*this );
575
564
emitCUList ();
576
565
emitTUList ();
@@ -635,7 +624,7 @@ void llvm::emitDWARF5AccelTable(
635
624
DIEInteger::BestForm (/* IsSigned*/ false , CompUnits.size () - 1 );
636
625
dwarf::Form TUIndexForm =
637
626
DIEInteger::BestForm (/* IsSigned*/ false , TypeUnits.size () - 1 );
638
- Dwarf5AccelTableWriter<DWARF5AccelTableData> (
627
+ Dwarf5AccelTableWriter (
639
628
Asm, Contents, CompUnits, TypeUnits,
640
629
[&](const DWARF5AccelTableData &Entry)
641
630
-> std::optional<DWARF5AccelTable::UnitIndexAndEncoding> {
@@ -667,8 +656,7 @@ void llvm::emitDWARF5AccelTable(
667
656
getIndexForEntry) {
668
657
std::vector<std::variant<MCSymbol *, uint64_t >> TypeUnits;
669
658
Contents.finalize (Asm, " names" );
670
- Dwarf5AccelTableWriter<DWARF5AccelTableData>(Asm, Contents, CUs, TypeUnits,
671
- getIndexForEntry, false )
659
+ Dwarf5AccelTableWriter (Asm, Contents, CUs, TypeUnits, getIndexForEntry, false )
672
660
.emit ();
673
661
}
674
662
0 commit comments