diff options
author | Jim Laskey <jlaskey@mac.com> | 2006-02-23 16:58:18 +0000 |
---|---|---|
committer | Jim Laskey <jlaskey@mac.com> | 2006-02-23 16:58:18 +0000 |
commit | f4afdd9f413c472e5785355f0d69847eaf729192 (patch) | |
tree | 14c0603e75177e28318cb17d6b4a00765ec58956 /lib/CodeGen/MachineDebugInfo.cpp | |
parent | 7718658064a67b23403a96e5c1d309a338966b41 (diff) |
DwarfWriter reading basic type information from llvm-gcc4 code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26331 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/MachineDebugInfo.cpp | 91 |
1 files changed, 88 insertions, 3 deletions
diff --git a/lib/CodeGen/MachineDebugInfo.cpp b/lib/CodeGen/MachineDebugInfo.cpp index b801cad379..44b71fae53 100644 --- a/lib/CodeGen/MachineDebugInfo.cpp +++ b/lib/CodeGen/MachineDebugInfo.cpp @@ -197,6 +197,7 @@ public: /// virtual void Apply(int &Field) { ++Count; } virtual void Apply(unsigned &Field) { ++Count; } + virtual void Apply(uint64_t &Field) { ++Count; } virtual void Apply(bool &Field) { ++Count; } virtual void Apply(std::string &Field) { ++Count; } virtual void Apply(DebugInfoDesc *&Field) { ++Count; } @@ -230,6 +231,10 @@ public: Constant *C = CI->getOperand(I++); Field = cast<ConstantUInt>(C)->getValue(); } + virtual void Apply(uint64_t &Field) { + Constant *C = CI->getOperand(I++); + Field = cast<ConstantUInt>(C)->getValue(); + } virtual void Apply(bool &Field) { Constant *C = CI->getOperand(I++); Field = cast<ConstantBool>(C)->getValue(); @@ -271,6 +276,9 @@ public: virtual void Apply(unsigned &Field) { Elements.push_back(ConstantUInt::get(Type::UIntTy, Field)); } + virtual void Apply(uint64_t &Field) { + Elements.push_back(ConstantUInt::get(Type::UIntTy, Field)); + } virtual void Apply(bool &Field) { Elements.push_back(ConstantBool::get(Field)); } @@ -327,6 +335,9 @@ public: virtual void Apply(unsigned &Field) { Fields.push_back(Type::UIntTy); } + virtual void Apply(uint64_t &Field) { + Fields.push_back(Type::UIntTy); + } virtual void Apply(bool &Field) { Fields.push_back(Type::BoolTy); } @@ -377,6 +388,10 @@ public: Constant *C = CI->getOperand(I++); IsValid = IsValid && isa<ConstantInt>(C); } + virtual void Apply(uint64_t &Field) { + Constant *C = CI->getOperand(I++); + IsValid = IsValid && isa<ConstantInt>(C); + } virtual void Apply(bool &Field) { Constant *C = CI->getOperand(I++); IsValid = IsValid && isa<ConstantBool>(C); @@ -414,6 +429,7 @@ DebugInfoDesc *DebugInfoDesc::DescFactory(unsigned Tag) { 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(); default: break; } return NULL; @@ -545,6 +561,75 @@ void CompileUnitDesc::dump() { //===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// + +TypeDesc::TypeDesc(unsigned T) +: DebugInfoDesc(T) +, Context(NULL) +, Name("") +, Size(0) +{} + +/// ApplyToFields - Target the visitor to the fields of the TypeDesc. +/// +void TypeDesc::ApplyToFields(DIVisitor *Visitor) { + DebugInfoDesc::ApplyToFields(Visitor); + + Visitor->Apply(Context); + Visitor->Apply(Name); + Visitor->Apply(Size); +} + +/// getDescString - Return a string used to compose global names and labels. +/// +const char *TypeDesc::getDescString() const { + return "llvm.dbg.type"; +} + +/// getTypeString - Return a string used to label this descriptor's type. +/// +const char *TypeDesc::getTypeString() const { + return "llvm.dbg.type.type"; +} + +#ifndef NDEBUG +void TypeDesc::dump() { + std::cerr << getDescString() << " " + << "Tag(" << getTag() << "), " + << "Context(" << Context << "), " + << "Name(\"" << Name << "\"), " + << "Size(" << Size << ")\n"; +} +#endif + +//===----------------------------------------------------------------------===// + +BasicTypeDesc::BasicTypeDesc() +: TypeDesc(DI_TAG_basictype) +, Encoding(0) +{} + +/// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc. +/// +void BasicTypeDesc::ApplyToFields(DIVisitor *Visitor) { + TypeDesc::ApplyToFields(Visitor); + + Visitor->Apply(Encoding); +} + +#ifndef NDEBUG +void BasicTypeDesc::dump() { + std::cerr << getDescString() << " " + << "Tag(" << getTag() << "), " + << "Context(" << getContext() << "), " + << "Name(\"" << getName() << "\"), " + << "Size(" << getSize() << "), " + << "Encoding(" << Encoding << ")\n"; +} +#endif + +//===----------------------------------------------------------------------===// + GlobalDesc::GlobalDesc(unsigned T) : AnchoredDesc(T) , Context(0) @@ -561,7 +646,7 @@ void GlobalDesc::ApplyToFields(DIVisitor *Visitor) { Visitor->Apply(Context); Visitor->Apply(Name); - Visitor->Apply(TyDesc); + Visitor->Apply((DebugInfoDesc *&)TyDesc); Visitor->Apply(IsStatic); Visitor->Apply(IsDefinition); } @@ -606,6 +691,7 @@ void GlobalVariableDesc::dump() { << "Tag(" << getTag() << "), " << "Anchor(" << getAnchor() << "), " << "Name(\"" << getName() << "\"), " + << "Type(\"" << getTypeDesc() << "\"), " << "IsStatic(" << (isStatic() ? "true" : "false") << "), " << "IsDefinition(" << (isDefinition() ? "true" : "false") << "), " << "Global(" << Global << "), " @@ -649,13 +735,12 @@ void SubprogramDesc::dump() { << "Tag(" << getTag() << "), " << "Anchor(" << getAnchor() << "), " << "Name(\"" << getName() << "\"), " + << "Type(\"" << getTypeDesc() << "\"), " << "IsStatic(" << (isStatic() ? "true" : "false") << "), " << "IsDefinition(" << (isDefinition() ? "true" : "false") << ")\n"; } #endif -//===----------------------------------------------------------------------===// - DebugInfoDesc *DIDeserializer::Deserialize(Value *V) { return Deserialize(getGlobalVariable(V)); } |