///
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; }
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();
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));
}
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);
}
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);
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;
//===----------------------------------------------------------------------===//
+//===----------------------------------------------------------------------===//
+
+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)
Visitor->Apply(Context);
Visitor->Apply(Name);
- Visitor->Apply(TyDesc);
+ Visitor->Apply((DebugInfoDesc *&)TyDesc);
Visitor->Apply(IsStatic);
Visitor->Apply(IsDefinition);
}
GlobalDesc::ApplyToFields(Visitor);
Visitor->Apply(Global);
+ Visitor->Apply(Line);
}
/// getDescString - Return a string used to compose global names and labels.
<< "Tag(" << getTag() << "), "
<< "Anchor(" << getAnchor() << "), "
<< "Name(\"" << getName() << "\"), "
+ << "Type(\"" << getTypeDesc() << "\"), "
<< "IsStatic(" << (isStatic() ? "true" : "false") << "), "
<< "IsDefinition(" << (isDefinition() ? "true" : "false") << "), "
- << "Global(" << Global << ")\n";
+ << "Global(" << Global << "), "
+ << "Line(" << Line << ")\n";
}
#endif
<< "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));
}
return false;
}
-/// Deserialize - Convert a Value to a debug information descriptor.
+/// getDescFor - Convert a Value to a debug information descriptor.
///
-DebugInfoDesc *MachineDebugInfo::Deserialize(Value *V) {
+// FIXME - use new Value type when available.
+DebugInfoDesc *MachineDebugInfo::getDescFor(Value *V) {
return DR.Deserialize(V);
}
/// SetupCompileUnits - Set up the unique vector of compile units.
///
void MachineDebugInfo::SetupCompileUnits(Module &M) {
- // Get vector of all debug compile units.
- CompileUnitDesc CompileUnit;
- std::vector<GlobalVariable*> Globals =
- getGlobalVariablesUsing(M, CompileUnit.getAnchorString());
+ std::vector<CompileUnitDesc *>CU = getAnchoredDescriptors<CompileUnitDesc>(M);
- // Scan all compile unit globals.
- for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
- // Add compile unit to result.
- CompileUnits.insert(
- static_cast<CompileUnitDesc *>(DR.Deserialize(Globals[i])));
+ for (unsigned i = 0, N = CU.size(); i < N; i++) {
+ CompileUnits.insert(CU[i]);
}
}
return CompileUnits;
}
-/// getGlobalVariables - Return a vector of debug GlobalVariables.
-///
-std::vector<GlobalVariableDesc *>
-MachineDebugInfo::getGlobalVariables(Module &M) {
- // Get vector of all debug global objects.
- GlobalVariableDesc Global;
- std::vector<GlobalVariable*> Globals =
- getGlobalVariablesUsing(M, Global.getAnchorString());
-
- // Accumulation of GlobalVariables.
- std::vector<GlobalVariableDesc *> GlobalVariables;
-
- // Scan all globals.
- for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
- GlobalVariable *GV = Globals[i];
- GlobalVariableDesc *GVD =
- static_cast<GlobalVariableDesc *>(DR.Deserialize(GV));
- GlobalVariables.push_back(GVD);
- }
-
- return GlobalVariables;
+/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
+/// named GlobalVariable.
+std::vector<GlobalVariable*>
+MachineDebugInfo::getGlobalVariablesUsing(Module &M,
+ const std::string &RootName) {
+ return ::getGlobalVariablesUsing(M, RootName);
}
-