[NFC] Refactor Apple Accelerator Tables
This patch completely overhauls the accelerator table and makes them
truly generic. There have been several attempts to do this in the past:
- D8215 & D8216: Using a union and partial hardcoding.
- D11805: Using inheritance.
- D42246: Using a callback.
In the end I didn't like either of them, because for some reason or
another parts of it felt hacky or decreased runtime performance. I
didn't want to completely rewrite them as I was hoping that we could
reuse parts for the successor in the DWARF standard. However, it seems
less and less likely that there will be a lot of opportunities for
sharing code and/or an interface. I just went for what I think is the
proper solution to our problem.
A quick summary for why these changes are necessary: dsymutil likes to
reuse the current implementation of the Apple accelerator tables.
However, LLDB expects a slightly different interface than what is
currently emitted. Additionally, in dsymutil we only have offsets and no
actual DIEs.
Although a lot of code seems to have changed, in the end this change is
pretty straightforward:
- We turned HashDataContents into a template parameter.
- We created two implementations of this class, one for type tables and one for everything else. There will be a third one for dsymutil with just an offset.
- We use the supplied class to deduct the atoms for the header which makes the structure of the table fully self contained.
- We renamed the prefix from DWARF- to Apple- to make space for the future implementation of .debug_names.
One could argue that the latter should've been a separate patch, but
since this refactoring touches almost every line, it doesn't really
matter.
The disadvantage of this is of course that a lot of the code is moved to
the header. One mitigation was splitting off the header class so we could
have the ::Emit() method implemented in the cpp file. With regards to
includes we only need to import two more headers than before
(CodeGen/AsmPrinter.h and llvm/MC/MCStreamer.h) which seems
reasonable.
Can you be specific as to which variant of accel table this is referring to?