Move accelerator table defines and constants to Dwarf.h since

we're proposing it for DWARF5.

No functional change intended.

llvm-svn: 190074
This commit is contained in:
Eric Christopher 2013-09-05 18:20:16 +00:00
parent 8f60cdd54b
commit cf7289f6d9
6 changed files with 56 additions and 56 deletions

View File

@ -763,6 +763,32 @@ const char *MacinfoString(unsigned Encoding);
/// CallFrameString - Return the string for the specified call frame instruction
/// encodings.
const char *CallFrameString(unsigned Encoding);
// Constants for the DWARF5 Accelerator Table Proposal
enum AcceleratorTable {
// Data layout descriptors.
DW_ATOM_null = 0u, // Marker as the end of a list of atoms.
DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
// item in question.
DW_ATOM_die_tag = 3u, // A tag entry.
DW_ATOM_type_flags = 4u, // Set of flags for a type.
// DW_ATOM_type_flags values.
// Always set for C++, only set for ObjC if this is the @implementation for a
// class.
DW_FLAG_type_implementation = 2u,
// Hash functions.
// Daniel J. Bernstein hash.
DW_hash_function_djb = 0u
};
/// AtomTypeString - Return the string for the specified Atom type.
const char *AtomTypeString(unsigned Atom);
} // End of namespace dwarf
} // End of namespace llvm

View File

@ -24,24 +24,6 @@
using namespace llvm;
const char *DwarfAccelTable::Atom::AtomTypeString(enum AtomType AT) {
switch (AT) {
case eAtomTypeNULL:
return "eAtomTypeNULL";
case eAtomTypeDIEOffset:
return "eAtomTypeDIEOffset";
case eAtomTypeCUOffset:
return "eAtomTypeCUOffset";
case eAtomTypeTag:
return "eAtomTypeTag";
case eAtomTypeNameFlags:
return "eAtomTypeNameFlags";
case eAtomTypeTypeFlags:
return "eAtomTypeTypeFlags";
}
llvm_unreachable("invalid AtomType!");
}
// The length of the header data is always going to be 4 + 4 + 4*NumAtoms.
DwarfAccelTable::DwarfAccelTable(ArrayRef<DwarfAccelTable::Atom> atomList)
: Header(8 + (atomList.size() * 4)), HeaderData(atomList),
@ -134,7 +116,7 @@ void DwarfAccelTable::EmitHeader(AsmPrinter *Asm) {
Asm->EmitInt32(HeaderData.Atoms.size());
for (size_t i = 0; i < HeaderData.Atoms.size(); i++) {
Atom A = HeaderData.Atoms[i];
Asm->OutStreamer.AddComment(Atom::AtomTypeString(A.type));
Asm->OutStreamer.AddComment(dwarf::AtomTypeString(A.type));
Asm->EmitInt16(A.type);
Asm->OutStreamer.AddComment(dwarf::FormEncodingString(A.form));
Asm->EmitInt16(A.form);

View File

@ -67,10 +67,6 @@ class DwarfUnits;
class DwarfAccelTable {
enum HashFunctionType {
eHashFunctionDJB = 0u
};
static uint32_t HashDJB(StringRef Str) {
uint32_t h = 5381;
for (unsigned i = 0, e = Str.size(); i != e; ++i)
@ -96,8 +92,9 @@ class DwarfAccelTable {
static const uint32_t MagicHash = 0x48415348;
TableHeader(uint32_t data_len)
: magic(MagicHash), version(1), hash_function(eHashFunctionDJB),
bucket_count(0), hashes_count(0), header_data_len(data_len) {}
: magic(MagicHash), version(1),
hash_function(dwarf::DW_hash_function_djb), bucket_count(0),
hashes_count(0), header_data_len(data_len) {}
#ifndef NDEBUG
void print(raw_ostream &O) {
@ -123,37 +120,17 @@ public:
// uint32_t die_offset_base
// uint32_t atom_count
// atom_count Atoms
enum AtomType {
eAtomTypeNULL = 0u,
eAtomTypeDIEOffset = 1u, // DIE offset, check form for encoding
eAtomTypeCUOffset = 2u, // DIE offset of the compiler unit header that
// contains the item in question
eAtomTypeTag = 3u, // DW_TAG_xxx value, should be encoded as
// DW_FORM_data1 (if no tags exceed 255) or
// DW_FORM_data2.
eAtomTypeNameFlags = 4u, // Flags from enum NameFlags
eAtomTypeTypeFlags = 5u // Flags from enum TypeFlags
};
enum TypeFlags {
eTypeFlagClassMask = 0x0000000fu,
// Always set for C++, only set for ObjC if this is the
// @implementation for a class.
eTypeFlagClassIsImplementation = (1u << 1)
};
// Make these public so that they can be used as a general interface to
// the class.
struct Atom {
AtomType type; // enum AtomType
uint16_t type; // enum AtomType
uint16_t form; // DWARF DW_FORM_ defines
Atom(AtomType type, uint16_t form) : type(type), form(form) {}
static const char *AtomTypeString(enum AtomType);
Atom(uint16_t type, uint16_t form) : type(type), form(form) {}
#ifndef NDEBUG
void print(raw_ostream &O) {
O << "Type: " << AtomTypeString(type) << "\n"
O << "Type: " << dwarf::AtomTypeString(type) << "\n"
<< "Form: " << dwarf::FormEncodingString(form) << "\n";
}
void dump() { print(dbgs()); }

View File

@ -796,8 +796,7 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
IsImplementation = (CT.getRunTimeLang() == 0) ||
CT.isObjcClassComplete();
}
unsigned Flags = IsImplementation ?
DwarfAccelTable::eTypeFlagClassIsImplementation : 0;
unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0;
addAccelType(Ty.getName(), std::make_pair(TyDIE, Flags));
}

View File

@ -2120,7 +2120,7 @@ void DwarfDebug::emitEndOfLineMatrix(unsigned SectionEnd) {
// Emit visible names into a hashed accelerator table section.
void DwarfDebug::emitAccelNames() {
DwarfAccelTable AT(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
DwarfAccelTable AT(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
E = CUMap.end(); I != E; ++I) {
@ -2149,7 +2149,7 @@ void DwarfDebug::emitAccelNames() {
// Emit objective C classes and categories into a hashed accelerator table
// section.
void DwarfDebug::emitAccelObjC() {
DwarfAccelTable AT(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
DwarfAccelTable AT(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
E = CUMap.end(); I != E; ++I) {
@ -2177,7 +2177,7 @@ void DwarfDebug::emitAccelObjC() {
// Emit namespace dies into a hashed accelerator table.
void DwarfDebug::emitAccelNamespaces() {
DwarfAccelTable AT(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
DwarfAccelTable AT(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
E = CUMap.end(); I != E; ++I) {
@ -2206,11 +2206,11 @@ void DwarfDebug::emitAccelNamespaces() {
// Emit type dies into a hashed accelerator table.
void DwarfDebug::emitAccelTypes() {
std::vector<DwarfAccelTable::Atom> Atoms;
Atoms.push_back(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeDIEOffset,
Atoms.push_back(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4));
Atoms.push_back(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeTag,
Atoms.push_back(DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag,
dwarf::DW_FORM_data2));
Atoms.push_back(DwarfAccelTable::Atom(DwarfAccelTable::eAtomTypeTypeFlags,
Atoms.push_back(DwarfAccelTable::Atom(dwarf::DW_ATOM_type_flags,
dwarf::DW_FORM_data1));
DwarfAccelTable AT(Atoms);
for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),

View File

@ -723,3 +723,19 @@ const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
}
return 0;
}
const char *llvm::dwarf::AtomTypeString(unsigned AT) {
switch (AT) {
case dwarf::DW_ATOM_null:
return "DW_ATOM_null";
case dwarf::DW_ATOM_die_offset:
return "DW_ATOM_die_offset";
case DW_ATOM_cu_offset:
return "DW_ATOM_cu_offset";
case DW_ATOM_die_tag:
return "DW_ATOM_die_tag";
case DW_ATOM_type_flags:
return "DW_ATOM_type_flags";
}
return 0;
}