Changeset View
Standalone View
llvm/include/llvm/ObjectYAML/DWARFEmitter.h
Show All 22 Lines | |||||
class raw_ostream; | class raw_ostream; | ||||
namespace DWARFYAML { | namespace DWARFYAML { | ||||
struct Data; | struct Data; | ||||
struct PubSection; | struct PubSection; | ||||
Error emitDebugAbbrev(raw_ostream &OS, const Data &DI); | Error emitDebugAbbrev(raw_ostream &OS, Data &DI); | ||||
Error emitDebugStr(raw_ostream &OS, const Data &DI); | Error emitDebugStr(raw_ostream &OS, Data &DI); | ||||
Error emitDebugAranges(raw_ostream &OS, Data &DI); | |||||
jhenderson: Would it make any sense to merge the `DWARFYAML::Data` class and `DWARFYAML::DWARFState` class… | |||||
That would definitely be nice. labath: That would definitely be nice. | |||||
I think they can be merged. But is there any particular reason to merge them? Personally, I would like to keep the DWARFYAML::DWARFState class. Here are a few concerns I would like to address:
I can be persuaded :-) Higuoxing: >>! @jhenderson :
> Would it make any sense to merge the `DWARFYAML::Data` class and `DWARFYAML… | |||||
As things stand, it mostly seems like DWARFState merely gets in the way of accessing the Data class. It seems to me like it would be easier to use if the two were one class, as you wouldn't have to keep going through an extra function call/member access.
If, rather than do all the calculations up front (e.g. mapping tables to IDs), you put the Data members behind getters, you could then add the "linking" code there. For example, with the AbbrevTable ID mapping, you could have the getAbbrevTableIndexByID method, which is the only way of getting an abbrev table from outside the class. The first time this is called (or optionally every time), it works out the mapping between ID(s) and table(s). This avoids the need for an explicit link or finalize method.
I'm not sure I agree they have different functions. The AbbrevID2Index map is just a helper variable that is directly derived from the Data struct's members. We could get rid of it entirely, and just move the getAbbrevTableIndexByID method into Data, rewriting it to just run through the list of tables each time to find the right ID. This is obviously less efficient than instantiating a mapping up front, if done repeatedly, but I think it indicates that this extra layer is not actually doing anything distinct. Similar principles apply probably for other things, although without further concrete examples, it's hard to discuss them! jhenderson: > I think they can be merged. But is there any particular reason to merge them?
As things stand… | |||||
Thanks for the explanation! Higuoxing: Thanks for the explanation! | |||||
Error emitDebugRanges(raw_ostream &OS, Data &DI); | |||||
Can you use std::unordered_map here? Do we need deterministic ordering? Might also be worth naming it something like AbbrevTableID2Index to avoid confusing with the AbbrevCode values. jhenderson: Can you use `std::unordered_map` here? Do we need deterministic ordering? Might also be worth… | |||||
Error emitDebugPubnames(raw_ostream &OS, Data &DI); | |||||
Error emitDebugPubtypes(raw_ostream &OS, Data &DI); | |||||
Error emitDebugGNUPubnames(raw_ostream &OS, Data &DI); | |||||
Error emitDebugGNUPubtypes(raw_ostream &OS, Data &DI); | |||||
Error emitDebugInfo(raw_ostream &OS, Data &DI); | |||||
Error emitDebugLine(raw_ostream &OS, Data &DI); | |||||
Error emitDebugAddr(raw_ostream &OS, Data &DI); | |||||
Error emitDebugStrOffsets(raw_ostream &OS, Data &DI); | |||||
Error emitDebugRnglists(raw_ostream &OS, Data &DI); | |||||
Error emitDebugLoclists(raw_ostream &OS, Data &DI); | |||||
Error emitDebugAranges(raw_ostream &OS, const Data &DI); | std::function<Error(raw_ostream &, Data &)> | ||||
Error emitDebugRanges(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugPubnames(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugPubtypes(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugGNUPubnames(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugInfo(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugLine(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugAddr(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugStrOffsets(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugRnglists(raw_ostream &OS, const Data &DI); | |||||
Error emitDebugLoclists(raw_ostream &OS, const Data &DI); | |||||
std::function<Error(raw_ostream &, const Data &)> | |||||
getDWARFEmitterByName(StringRef SecName); | getDWARFEmitterByName(StringRef SecName); | ||||
Expected<StringMap<std::unique_ptr<MemoryBuffer>>> | Expected<StringMap<std::unique_ptr<MemoryBuffer>>> | ||||
emitDebugSections(StringRef YAMLString, | emitDebugSections(StringRef YAMLString, | ||||
bool IsLittleEndian = sys::IsLittleEndianHost, | bool IsLittleEndian = sys::IsLittleEndianHost, | ||||
bool Is64BitAddrSize = true); | bool Is64BitAddrSize = true); | ||||
} // end namespace DWARFYAML | } // end namespace DWARFYAML | ||||
} // end namespace llvm | } // end namespace llvm | ||||
#endif // LLVM_OBJECTYAML_DWARFEMITTER_H | #endif // LLVM_OBJECTYAML_DWARFEMITTER_H |
Would it make any sense to merge the DWARFYAML::Data class and DWARFYAML::DWARFState class at all?