diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/DwarfWriter.cpp | 34 | ||||
-rw-r--r-- | lib/CodeGen/MachineDebugInfo.cpp | 124 |
2 files changed, 103 insertions, 55 deletions
diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index 5ce4349a96..58dc6dd813 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -1070,42 +1070,20 @@ DIE *DwarfWriter::NewType(DIE *Context, TypeDesc *TyDesc) { unsigned Encoding = BasicTy->getEncoding(); Ty->AddUInt (DW_AT_encoding, DW_FORM_data1, Encoding); } else if (DerivedTypeDesc *DerivedTy = dyn_cast<DerivedTypeDesc>(TyDesc)) { - // Determine which derived type. - unsigned T = 0; - switch (DerivedTy->getTag()) { - case DI_TAG_typedef: T = DW_TAG_typedef; break; - case DI_TAG_pointer: T = DW_TAG_pointer_type; break; - case DI_TAG_reference: T = DW_TAG_reference_type; break; - case DI_TAG_const: T = DW_TAG_const_type; break; - case DI_TAG_volatile: T = DW_TAG_volatile_type; break; - case DI_TAG_restrict: T = DW_TAG_restrict_type; break; - default: assert( 0 && "Unknown tag on derived type"); - } - // Create specific DIE. - Slot = Ty = new DIE(T); + Slot = Ty = new DIE(DerivedTy->getTag()); // Map to main type, void will not have a type. if (TypeDesc *FromTy = DerivedTy->getFromType()) { Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy)); } } else if (CompositeTypeDesc *CompTy = dyn_cast<CompositeTypeDesc>(TyDesc)) { - // Determine which composite type. - unsigned T = 0; - switch (CompTy->getTag()) { - case DI_TAG_array: T = DW_TAG_array_type; break; - case DI_TAG_struct: T = DW_TAG_structure_type; break; - case DI_TAG_union: T = DW_TAG_union_type; break; - case DI_TAG_enum: T = DW_TAG_enumeration_type; break; - default: assert( 0 && "Unknown tag on composite type"); - } - // Create specific DIE. - Slot = Ty = new DIE(T); + Slot = Ty = new DIE(CompTy->getTag()); std::vector<DebugInfoDesc *> &Elements = CompTy->getElements(); switch (CompTy->getTag()) { - case DI_TAG_array: { + case DW_TAG_array_type: { // Add element type. if (TypeDesc *FromTy = CompTy->getFromType()) { Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, NewType(Context, FromTy)); @@ -1139,13 +1117,13 @@ DIE *DwarfWriter::NewType(DIE *Context, TypeDesc *TyDesc) { break; } - case DI_TAG_struct: { + case DW_TAG_structure_type: { break; } - case DI_TAG_union: { + case DW_TAG_union_type: { break; } - case DI_TAG_enum: { + case DW_TAG_enumeration_type: { break; } default: break; diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index 98d07d3e2f..46163a777e 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -20,6 +20,7 @@ #include <iostream> using namespace llvm; +using namespace llvm::dwarf; // Handle the Pass registration stuff necessary to use TargetData's. namespace { @@ -492,29 +493,29 @@ public: /// GlobalVariable. unsigned DebugInfoDesc::TagFromGlobal(GlobalVariable *GV) { ConstantUInt *C = getUIntOperand(GV, 0); - return C ? (unsigned)C->getValue() : (unsigned)DIInvalid; + return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid; } /// DescFactory - Create an instance of debug info descriptor based on Tag. /// Return NULL if not a recognized Tag. DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) { switch (Tag) { - case DI_TAG_anchor: return new AnchorDesc(); - case DI_TAG_compile_unit: return new CompileUnitDesc(); - case DI_TAG_global_variable: return new GlobalVariableDesc(); - case DI_TAG_subprogram: return new SubprogramDesc(); - case DI_TAG_basictype: return new BasicTypeDesc(); - case DI_TAG_typedef: - case DI_TAG_pointer: - case DI_TAG_reference: - case DI_TAG_const: - case DI_TAG_volatile: - case DI_TAG_restrict: return new DerivedTypeDesc(Tag); - case DI_TAG_array: - case DI_TAG_struct: - case DI_TAG_union: - case DI_TAG_enum: return new CompositeTypeDesc(Tag); - case DI_TAG_subrange: return new SubrangeDesc(); + case DW_TAG_anchor: return new AnchorDesc(); + case DW_TAG_compile_unit: return new CompileUnitDesc(); + case DW_TAG_variable: return new GlobalVariableDesc(); + case DW_TAG_subprogram: return new SubprogramDesc(); + case DW_TAG_base_type: return new BasicTypeDesc(); + case DW_TAG_typedef: + case DW_TAG_pointer_type: + case DW_TAG_reference_type: + case DW_TAG_const_type: + case DW_TAG_volatile_type: + case DW_TAG_restrict_type: return new DerivedTypeDesc(Tag); + case DW_TAG_array_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: return new CompositeTypeDesc(Tag); + case DW_TAG_subrange_type: return new SubrangeDesc(); default: break; } return NULL; @@ -534,6 +535,20 @@ void DebugInfoDesc::ApplyToFields(DIVisitor *Visitor) { //===----------------------------------------------------------------------===// +AnchorDesc::AnchorDesc() +: DebugInfoDesc(DW_TAG_anchor) +, Name("") +{} +AnchorDesc::AnchorDesc(const std::string &N) +: DebugInfoDesc(DW_TAG_anchor) +, Name(N) +{} + +// Implement isa/cast/dyncast. +bool AnchorDesc::classof(const DebugInfoDesc *D) { + return D->getTag() == DW_TAG_anchor; +} + /// getLinkage - get linkage appropriate for this type of descriptor. /// GlobalValue::LinkageTypes AnchorDesc::getLinkage() const { @@ -586,7 +601,7 @@ void AnchoredDesc::ApplyToFields(DIVisitor *Visitor) { //===----------------------------------------------------------------------===// CompileUnitDesc::CompileUnitDesc() -: AnchoredDesc(DI_TAG_compile_unit) +: AnchoredDesc(DW_TAG_compile_unit) , DebugVersion(LLVMDebugVersion) , Language(0) , FileName("") @@ -594,11 +609,16 @@ CompileUnitDesc::CompileUnitDesc() , Producer("") {} +// Implement isa/cast/dyncast. +bool CompileUnitDesc::classof(const DebugInfoDesc *D) { + return D->getTag() == DW_TAG_compile_unit; +} + /// DebugVersionFromGlobal - Returns the version number from a compile unit /// GlobalVariable. unsigned CompileUnitDesc::DebugVersionFromGlobal(GlobalVariable *GV) { ConstantUInt *C = getUIntOperand(GV, 2); - return C ? (unsigned)C->getValue() : (unsigned)DIInvalid; + return C ? (unsigned)C->getValue() : (unsigned)DW_TAG_invalid; } /// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc. @@ -693,10 +713,15 @@ void TypeDesc::dump() { //===----------------------------------------------------------------------===// BasicTypeDesc::BasicTypeDesc() -: TypeDesc(DI_TAG_basictype) +: TypeDesc(DW_TAG_base_type) , Encoding(0) {} +// Implement isa/cast/dyncast. +bool BasicTypeDesc::classof(const DebugInfoDesc *D) { + return D->getTag() == DW_TAG_base_type; +} + /// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc. /// void BasicTypeDesc::ApplyToFields(DIVisitor *Visitor) { @@ -735,6 +760,22 @@ DerivedTypeDesc::DerivedTypeDesc(unsigned T) , FromType(NULL) {} +// Implement isa/cast/dyncast. +bool DerivedTypeDesc::classof(const DebugInfoDesc *D) { + unsigned T = D->getTag(); + switch (T) { + case DW_TAG_typedef: + case DW_TAG_pointer_type: + case DW_TAG_reference_type: + case DW_TAG_const_type: + case DW_TAG_volatile_type: + case DW_TAG_restrict_type: + return true; + default: break; + } + return false; +} + /// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc. /// void DerivedTypeDesc::ApplyToFields(DIVisitor *Visitor) { @@ -775,6 +816,20 @@ CompositeTypeDesc::CompositeTypeDesc(unsigned T) , Elements() {} +// Implement isa/cast/dyncast. +bool CompositeTypeDesc::classof(const DebugInfoDesc *D) { + unsigned T = D->getTag(); + switch (T) { + case DW_TAG_array_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_enumeration_type: + return true; + default: break; + } + return false; +} + /// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc. /// void CompositeTypeDesc::ApplyToFields(DIVisitor *Visitor) { @@ -812,11 +867,16 @@ void CompositeTypeDesc::dump() { //===----------------------------------------------------------------------===// SubrangeDesc::SubrangeDesc() -: DebugInfoDesc(DI_TAG_subrange) +: DebugInfoDesc(DW_TAG_subrange_type) , Lo(0) , Hi(0) {} +// Implement isa/cast/dyncast. +bool SubrangeDesc::classof(const DebugInfoDesc *D) { + return D->getTag() == DW_TAG_subrange_type; +} + /// ApplyToFields - Target the visitor to the fields of the SubrangeDesc. /// void SubrangeDesc::ApplyToFields(DIVisitor *Visitor) { @@ -873,10 +933,15 @@ void GlobalDesc::ApplyToFields(DIVisitor *Visitor) { //===----------------------------------------------------------------------===// GlobalVariableDesc::GlobalVariableDesc() -: GlobalDesc(DI_TAG_global_variable) +: GlobalDesc(DW_TAG_variable) , Global(NULL) {} +// Implement isa/cast/dyncast. +bool GlobalVariableDesc::classof(const DebugInfoDesc *D) { + return D->getTag() == DW_TAG_variable; +} + /// ApplyToFields - Target the visitor to the fields of the GlobalVariableDesc. /// void GlobalVariableDesc::ApplyToFields(DIVisitor *Visitor) { @@ -921,9 +986,14 @@ void GlobalVariableDesc::dump() { //===----------------------------------------------------------------------===// SubprogramDesc::SubprogramDesc() -: GlobalDesc(DI_TAG_subprogram) +: GlobalDesc(DW_TAG_subprogram) {} +// Implement isa/cast/dyncast. +bool SubprogramDesc::classof(const DebugInfoDesc *D) { + return D->getTag() == DW_TAG_subprogram; +} + /// ApplyToFields - Target the visitor to the fields of the /// SubprogramDesc. void SubprogramDesc::ApplyToFields(DIVisitor *Visitor) { @@ -977,7 +1047,7 @@ DebugInfoDesc *DIDeserializer::Deserialize(GlobalVariable *GV) { unsigned Tag = DebugInfoDesc::TagFromGlobal(GV); // Get the debug version if a compile unit. - if (Tag == DI_TAG_compile_unit) { + if (Tag == DW_TAG_compile_unit) { DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV); } @@ -1123,12 +1193,12 @@ bool DIVerifier::Verify(GlobalVariable *GV) { // Get the Tag unsigned Tag = DebugInfoDesc::TagFromGlobal(GV); - if (Tag == DIInvalid) return false; + if (Tag == DW_TAG_invalid) return false; // If a compile unit we need the debug version. - if (Tag == DI_TAG_compile_unit) { + if (Tag == DW_TAG_compile_unit) { DebugVersion = CompileUnitDesc::DebugVersionFromGlobal(GV); - if (DebugVersion == DIInvalid) return false; + if (DebugVersion == DW_TAG_invalid) return false; } // Construct an empty DebugInfoDesc. |