[llvm-commits] [llvm-gcc-4.2] r63204 - in /llvm-gcc-4.2/branches/release_25/gcc: llvm-debug.cpp llvm-debug.h
Tanya Lattner
tonic at nondot.org
Wed Jan 28 07:39:51 PST 2009
Author: tbrethou
Date: Wed Jan 28 09:39:51 2009
New Revision: 63204
URL: http://llvm.org/viewvc/llvm-project?rev=63204&view=rev
Log:
Merge from mainline.
Refactor code. No functionality change.
Modified:
llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.cpp
llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.h
Modified: llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.cpp?rev=63204&r1=63203&r2=63204&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.cpp Wed Jan 28 09:39:51 2009
@@ -338,41 +338,319 @@
}
-/// getOrCreateType - Get the type from the cache or create a new type if
-/// necessary.
-/// FIXME - I hate jumbo methods - split up.
-DIType DebugInfo::getOrCreateType(tree type) {
- DEBUGASSERT(type != NULL_TREE && type != error_mark_node &&
- "Not a type.");
- if (type == NULL_TREE || type == error_mark_node) return DIType();
+/// createBasicType - Create BasicType.
+DIType DebugInfo::createBasicType(tree type) {
- // Should only be void if a pointer/reference/return type. Returning NULL
- // allows the caller to produce a non-derived type.
- if (TREE_CODE(type) == VOID_TYPE) return DIType();
+ const char *TypeName = GetNodeName(type);
+ uint64_t Size = NodeSizeInBits(type);
+ uint64_t Align = NodeAlignInBits(type);
+
+ unsigned Encoding = 0;
- // Check to see if the compile unit already has created this type.
- DIType &Slot = TypeCache[type];
- if (!Slot.isNull())
- return Slot;
+ switch (TREE_CODE(type)) {
+ case INTEGER_TYPE:
+ if (TYPE_STRING_FLAG (type)) {
+ if (TYPE_UNSIGNED (type))
+ Encoding = DW_ATE_unsigned_char;
+ else
+ Encoding = DW_ATE_signed_char;
+ }
+ else if (TYPE_UNSIGNED (type))
+ Encoding = DW_ATE_unsigned;
+ else
+ Encoding = DW_ATE_signed;
+ break;
+ case REAL_TYPE:
+ Encoding = DW_ATE_float;
+ break;
+ case COMPLEX_TYPE:
+ Encoding = TREE_CODE(TREE_TYPE(type)) == REAL_TYPE ?
+ DW_ATE_complex_float : DW_ATE_lo_user;
+ break;
+ case BOOLEAN_TYPE:
+ Encoding = DW_ATE_boolean;
+ break;
+ default: {
+ DEBUGASSERT(0 && "Basic type case missing");
+ Encoding = DW_ATE_signed;
+ Size = BITS_PER_WORD;
+ Align = BITS_PER_WORD;
+ break;
+ }
+ }
+ return DebugFactory.CreateBasicType(MainCompileUnit, TypeName,
+ MainCompileUnit, 0, Size, Align,
+ 0, 0, Encoding);
+}
+
+/// createMethodType - Create MethodType.
+DIType DebugInfo::createMethodType(tree type) {
+
+ llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
- DIType MainTy;
- if (type != TYPE_MAIN_VARIANT(type)) {
- if (TYPE_NEXT_VARIANT(type) && type != TYPE_NEXT_VARIANT(type))
- MainTy = getOrCreateType(TYPE_NEXT_VARIANT(type));
- else if (TYPE_MAIN_VARIANT(type))
- MainTy = getOrCreateType(TYPE_MAIN_VARIANT(type));
+ // Add the result type at least.
+ EltTys.push_back(getOrCreateType(TREE_TYPE(type)));
+
+ // Set up remainder of arguments.
+ for (tree arg = TYPE_ARG_TYPES(type); arg; arg = TREE_CHAIN(arg)) {
+ tree formal_type = TREE_VALUE(arg);
+ if (formal_type == void_type_node) break;
+ EltTys.push_back(getOrCreateType(formal_type));
}
+
+ llvm::DIArray EltTypeArray =
+ DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
+
+ return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
+ MainCompileUnit, "",
+ MainCompileUnit, 0, 0, 0, 0, 0,
+ llvm::DIType(), EltTypeArray);
+}
- // Get the name and location early to assist debugging.
- const char *TypeName = GetNodeName(type);
- expanded_location Loc = GetNodeLocation(type);
+/// createPointerType - Create PointerType.
+DIType DebugInfo::createPointerType(tree type) {
+
+ DIType FromTy = getOrCreateType(TREE_TYPE(type));
+ // type* and type&
+ // FIXME: Should BLOCK_POINTER_TYP have its own DW_TAG?
+ unsigned Tag = (TREE_CODE(type) == POINTER_TYPE ||
+ TREE_CODE(type) == BLOCK_POINTER_TYPE) ?
+ DW_TAG_pointer_type :
+ DW_TAG_reference_type;
+ return DebugFactory.CreateDerivedType(Tag, MainCompileUnit, "",
+ MainCompileUnit, 0 /*line no*/,
+ NodeSizeInBits(type),
+ NodeAlignInBits(type),
+ 0 /*offset */,
+ 0 /* flags */,
+ FromTy);
+}
+
+/// createArrayType - Create ArrayType.
+DIType DebugInfo::createArrayType(tree type) {
+
+ // type[n][m]...[p]
+ if (TYPE_STRING_FLAG(type) && TREE_CODE(TREE_TYPE(type)) == INTEGER_TYPE){
+ DEBUGASSERT(0 && "Don't support pascal strings");
+ return DIType();
+ }
- // Bit size and align of the type.
- uint64_t Size = NodeSizeInBits(type);
- uint64_t Align = NodeAlignInBits(type);
+ unsigned Tag = 0;
+
+ if (TREE_CODE(type) == VECTOR_TYPE)
+ Tag = DW_TAG_vector_type;
+ else
+ Tag = DW_TAG_array_type;
+
+ // Add the dimensions of the array. FIXME: This loses CV qualifiers from
+ // interior arrays, do we care? Why aren't nested arrays represented the
+ // obvious/recursive way?
+ llvm::SmallVector<llvm::DIDescriptor, 8> Subscripts;
+
+ // There will be ARRAY_TYPE nodes for each rank. Followed by the derived
+ // type.
+ tree atype = type;
+ tree EltTy = TREE_TYPE(atype);
+ for (; TREE_CODE(atype) == ARRAY_TYPE; atype = TREE_TYPE(atype)) {
+ tree Domain = TYPE_DOMAIN(atype);
+ if (Domain) {
+ // FIXME - handle dynamic ranges
+ tree MinValue = TYPE_MIN_VALUE(Domain);
+ tree MaxValue = TYPE_MAX_VALUE(Domain);
+ if (MinValue && MaxValue &&
+ isInt64(MinValue, 0) && isInt64(MaxValue, 0)) {
+ uint64_t Low = getInt64(MinValue, 0);
+ uint64_t Hi = getInt64(MaxValue, 0);
+ Subscripts.push_back(DebugFactory.GetOrCreateSubrange(Low, Hi));
+ }
+ }
+ EltTy = TREE_TYPE(atype);
+ }
+
+ llvm::DIArray SubscriptArray =
+ DebugFactory.GetOrCreateArray(&Subscripts[0], Subscripts.size());
+
+ return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type,
+ MainCompileUnit, "",
+ MainCompileUnit,
+ 0, NodeSizeInBits(type),
+ NodeAlignInBits(type), 0, 0,
+ getOrCreateType(EltTy),
+ SubscriptArray);
+}
+
+/// createEnumType - Create EnumType.
+DIType DebugInfo::createEnumType(tree type) {
+ // enum { a, b, ..., z };
+ llvm::SmallVector<llvm::DIDescriptor, 32> Elements;
+
+ if (TYPE_SIZE(type)) {
+ for (tree Link = TYPE_VALUES(type); Link; Link = TREE_CHAIN(Link)) {
+ tree EnumValue = TREE_VALUE(Link);
+ int64_t Value = getInt64(EnumValue, tree_int_cst_sgn(EnumValue) > 0);
+ const char *EnumName = IDENTIFIER_POINTER(TREE_PURPOSE(Link));
+ Elements.push_back(DebugFactory.CreateEnumerator(EnumName, Value));
+ }
+ }
+
+ llvm::DIArray EltArray =
+ DebugFactory.GetOrCreateArray(&Elements[0], Elements.size());
+
+ expanded_location Loc = GetNodeLocation(TREE_CHAIN(type), false);
+ std::string Filename, Directory;
+ DirectoryAndFile(Loc.file, Directory, Filename);
+ return DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
+ MainCompileUnit, GetNodeName(type),
+ MainCompileUnit, Loc.line,
+ NodeSizeInBits(type),
+ NodeAlignInBits(type), 0, 0,
+ llvm::DIType(), EltArray,
+ &Filename, &Directory);
+}
+
+/// createStructType - Create StructType for struct or union or class.
+DIType DebugInfo::createStructType(tree type) {
+ // struct { a; b; ... z; }; | union { a; b; ... z; };
+ unsigned Tag = TREE_CODE(type) == RECORD_TYPE ? DW_TAG_structure_type :
+ DW_TAG_union_type;
+
+ // Records and classes and unions can all be recursive. To handle them,
+ // we first generate a debug descriptor for the struct as a forward
+ // declaration. Then (if it is a definition) we go through and get debug
+ // info for all of its members. Finally, we create a descriptor for the
+ // complete type (which may refer to the forward decl if the struct is
+ // recursive) and replace all uses of the forward declaration with the
+ // final definition.
+ expanded_location Loc = GetNodeLocation(TREE_CHAIN(type), false);
+ std::string Filename, Directory;
+ DirectoryAndFile(Loc.file, Directory, Filename);
+ llvm::DIType FwdDecl =
+ DebugFactory.CreateCompositeType(Tag, MainCompileUnit, GetNodeName(type),
+ MainCompileUnit, Loc.line,
+ 0, 0, 0, llvm::DIType::FlagFwdDecl,
+ llvm::DIType(), llvm::DIArray(),
+ &Filename, &Directory);
+
+
+ // forward declaration,
+ if (TYPE_SIZE(type) == 0)
+ return FwdDecl;
+
+ // Insert into the TypeCache so that recursive uses will find it.
+ TypeCache[type] = FwdDecl;
+
+ // Convert all the elements.
+ llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
+
+ if (tree binfo = TYPE_BINFO(type)) {
+ VEC (tree, gc) *accesses = BINFO_BASE_ACCESSES (binfo);
+
+ for (unsigned i = 0, e = BINFO_N_BASE_BINFOS(binfo); i != e; ++i) {
+ tree BInfo = BINFO_BASE_BINFO(binfo, i);
+ tree BInfoType = BINFO_TYPE (BInfo);
+ DIType BaseClass = getOrCreateType(BInfoType);
+
+ // FIXME : name, size, align etc...
+ DIType DTy =
+ DebugFactory.CreateDerivedType(DW_TAG_inheritance,
+ MainCompileUnit,"",
+ MainCompileUnit, 0,0,0,
+ getInt64(BINFO_OFFSET(BInfo), 0),
+ 0, BaseClass);
+ EltTys.push_back(DTy);
+ }
+ }
+
+ // Now add members of this class.
+ for (tree Member = TYPE_FIELDS(type); Member;
+ Member = TREE_CHAIN(Member)) {
+ // Should we skip.
+ if (DECL_P(Member) && DECL_IGNORED_P(Member)) continue;
+
+ if (TREE_CODE(Member) == FIELD_DECL) {
+
+ if (DECL_FIELD_OFFSET(Member) == 0 ||
+ TREE_CODE(DECL_FIELD_OFFSET(Member)) != INTEGER_CST)
+ // FIXME: field with variable position, skip it for now.
+ continue;
+
+ /* Ignore nameless fields. */
+ if (DECL_NAME (Member) == NULL_TREE)
+ continue;
+
+ // Get the location of the member.
+ expanded_location MemLoc = GetNodeLocation(Member, false);
+ std::string MemFilename, MemDirectory;
+ DirectoryAndFile(MemLoc.file, MemDirectory, MemFilename);
+
+ // Field type is the declared type of the field.
+ tree FieldNodeType = FieldType(Member);
+ DIType MemberType = getOrCreateType(FieldNodeType);
+ const char *MemberName = GetNodeName(Member);
+ unsigned Flags = 0;
+ if (TREE_PROTECTED(Member))
+ Flags = llvm::DIType::FlagProtected;
+ else if (TREE_PRIVATE(Member))
+ Flags = llvm::DIType::FlagPrivate;
+
+ DIType DTy =
+ DebugFactory.CreateDerivedType(DW_TAG_member, MainCompileUnit,
+ MemberName, MainCompileUnit,
+ MemLoc.line, NodeSizeInBits(Member),
+ NodeAlignInBits(FieldNodeType),
+ int_bit_position(Member),
+ Flags, MemberType,
+ &MemFilename, &MemDirectory);
+ EltTys.push_back(DTy);
+ } else {
+ DEBUGASSERT(0 && "Unsupported member tree code!");
+ }
+ }
+
+ for (tree Member = TYPE_METHODS(type); Member;
+ Member = TREE_CHAIN(Member)) {
+
+ if (DECL_ABSTRACT_ORIGIN (Member)) continue;
+
+ // Get the location of the member.
+ expanded_location MemLoc = GetNodeLocation(Member, false);
+ std::string MemFilename, MemDirectory;
+ DirectoryAndFile(MemLoc.file, MemDirectory, MemFilename);
+
+ const char *MemberName = GetNodeName(Member);
+ DIType SPTy = getOrCreateType(TREE_TYPE(Member));
+ DISubprogram SP =
+ DebugFactory.CreateSubprogram(MainCompileUnit, MemberName, MemberName,
+ MemberName, MainCompileUnit,
+ MemLoc.line, SPTy, false, false,
+ &MemFilename, &MemDirectory);
+
+ EltTys.push_back(SP);
+ }
+
+ llvm::DIArray Elements =
+ DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
+
+ llvm::DIType RealDecl =
+ DebugFactory.CreateCompositeType(Tag, MainCompileUnit,
+ GetNodeName(type),
+ MainCompileUnit, Loc.line,
+ NodeSizeInBits(type), NodeAlignInBits(type),
+ 0, 0, llvm::DIType(), Elements,
+ &Filename, &Directory);
+
+ // Now that we have a real decl for the struct, replace anything using the
+ // old decl with the new one. This will recursively update the debug info.
+ FwdDecl.getGV()->replaceAllUsesWith(RealDecl.getGV());
+ FwdDecl.getGV()->eraseFromParent();
+ return RealDecl;
+}
+
+/// createVarinatType - Create variant type or return MainTy.
+DIType DebugInfo::createVariantType(tree type, DIType MainTy) {
+
DIType Ty;
- // Do we have a typedef?
if (tree Name = TYPE_NAME(type)) {
if (TREE_CODE(Name) == TYPE_DECL && DECL_ORIGINAL_TYPE(Name)) {
expanded_location TypeDefLoc = GetNodeLocation(Name);
@@ -393,7 +671,8 @@
}
if (TYPE_VOLATILE(type)) {
- Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type, MainCompileUnit, "",
+ Ty = DebugFactory.CreateDerivedType(DW_TAG_volatile_type,
+ MainCompileUnit, "",
MainCompileUnit, 0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
@@ -404,7 +683,8 @@
}
if (TYPE_READONLY(type))
- Ty = DebugFactory.CreateDerivedType(DW_TAG_const_type, MainCompileUnit, "",
+ Ty = DebugFactory.CreateDerivedType(DW_TAG_const_type,
+ MainCompileUnit, "",
MainCompileUnit, 0 /*line no*/,
NodeSizeInBits(type),
NodeAlignInBits(type),
@@ -418,8 +698,36 @@
}
// If, for some reason, main type varaint type is seen then use it.
- if (!MainTy.isNull())
- return MainTy;
+ return MainTy;
+}
+
+/// getOrCreateType - Get the type from the cache or create a new type if
+/// necessary.
+DIType DebugInfo::getOrCreateType(tree type) {
+ DEBUGASSERT(type != NULL_TREE && type != error_mark_node &&
+ "Not a type.");
+ if (type == NULL_TREE || type == error_mark_node) return DIType();
+
+ // Should only be void if a pointer/reference/return type. Returning NULL
+ // allows the caller to produce a non-derived type.
+ if (TREE_CODE(type) == VOID_TYPE) return DIType();
+
+ // Check to see if the compile unit already has created this type.
+ DIType &Slot = TypeCache[type];
+ if (!Slot.isNull())
+ return Slot;
+
+ DIType MainTy;
+ if (type != TYPE_MAIN_VARIANT(type)) {
+ if (TYPE_NEXT_VARIANT(type) && type != TYPE_NEXT_VARIANT(type))
+ MainTy = getOrCreateType(TYPE_NEXT_VARIANT(type));
+ else if (TYPE_MAIN_VARIANT(type))
+ MainTy = getOrCreateType(TYPE_MAIN_VARIANT(type));
+ }
+
+ DIType Ty = createVariantType(type, MainTy);
+ if (!Ty.isNull())
+ return Ty;
// Work out details of type.
switch (TREE_CODE(type)) {
@@ -433,25 +741,9 @@
case POINTER_TYPE:
case REFERENCE_TYPE:
- case BLOCK_POINTER_TYPE: {
-
- DIType FromTy = getOrCreateType(TREE_TYPE(type));
- // type* and type&
- // FIXME: Should BLOCK_POINTER_TYP have its own DW_TAG?
- unsigned Tag = (TREE_CODE(type) == POINTER_TYPE ||
- TREE_CODE(type) == BLOCK_POINTER_TYPE) ?
- DW_TAG_pointer_type :
- DW_TAG_reference_type;
- Ty = DebugFactory.CreateDerivedType(Tag, MainCompileUnit, "",
- MainCompileUnit, 0 /*line no*/,
- NodeSizeInBits(type),
- NodeAlignInBits(type),
- 0 /*offset */,
- 0 /* flags */,
- FromTy);
-
+ case BLOCK_POINTER_TYPE:
+ Ty = createPointerType(type);
break;
- }
case OFFSET_TYPE: {
// gen_type_die(TYPE_OFFSET_BASETYPE(type), context_die);
@@ -461,292 +753,31 @@
}
case FUNCTION_TYPE:
- case METHOD_TYPE: {
- llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
-
- // Add the result type at least.
- EltTys.push_back(getOrCreateType(TREE_TYPE(type)));
-
- // Set up remainder of arguments.
- for (tree arg = TYPE_ARG_TYPES(type); arg; arg = TREE_CHAIN(arg)) {
- tree formal_type = TREE_VALUE(arg);
- if (formal_type == void_type_node) break;
- EltTys.push_back(getOrCreateType(formal_type));
- }
-
- llvm::DIArray EltTypeArray =
- DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
-
- Ty = DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
- MainCompileUnit, "",
- MainCompileUnit, 0, 0, 0, 0, 0,
- llvm::DIType(), EltTypeArray);
+ case METHOD_TYPE:
+ Ty = createMethodType(type);
break;
- }
case VECTOR_TYPE:
- case ARRAY_TYPE: {
- // type[n][m]...[p]
- if (TYPE_STRING_FLAG(type) && TREE_CODE(TREE_TYPE(type)) == INTEGER_TYPE){
- DEBUGASSERT(0 && "Don't support pascal strings");
- return DIType();
- }
-
- unsigned Tag = 0;
-
- if (TREE_CODE(type) == VECTOR_TYPE)
- Tag = DW_TAG_vector_type;
- else
- Tag = DW_TAG_array_type;
-
- // Add the dimensions of the array. FIXME: This loses CV qualifiers from
- // interior arrays, do we care? Why aren't nested arrays represented the
- // obvious/recursive way?
- llvm::SmallVector<llvm::DIDescriptor, 8> Subscripts;
-
- // There will be ARRAY_TYPE nodes for each rank. Followed by the derived
- // type.
- tree atype = type;
- tree EltTy = TREE_TYPE(atype);
- for (; TREE_CODE(atype) == ARRAY_TYPE; atype = TREE_TYPE(atype)) {
- tree Domain = TYPE_DOMAIN(atype);
- if (Domain) {
- // FIXME - handle dynamic ranges
- tree MinValue = TYPE_MIN_VALUE(Domain);
- tree MaxValue = TYPE_MAX_VALUE(Domain);
- if (MinValue && MaxValue &&
- isInt64(MinValue, 0) && isInt64(MaxValue, 0)) {
- uint64_t Low = getInt64(MinValue, 0);
- uint64_t Hi = getInt64(MaxValue, 0);
- Subscripts.push_back(DebugFactory.GetOrCreateSubrange(Low, Hi));
- }
- }
- EltTy = TREE_TYPE(atype);
- }
-
- llvm::DIArray SubscriptArray =
- DebugFactory.GetOrCreateArray(&Subscripts[0], Subscripts.size());
-
- Ty = DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_array_type,
- MainCompileUnit, "",
- MainCompileUnit,
- 0, Size, Align, 0, 0,
- getOrCreateType(EltTy),
- SubscriptArray);
+ case ARRAY_TYPE:
+ Ty = createArrayType(type);
break;
- }
- case ENUMERAL_TYPE: {
- // enum { a, b, ..., z };
- llvm::SmallVector<llvm::DIDescriptor, 32> Elements;
-
- if (TYPE_SIZE(type)) {
- for (tree Link = TYPE_VALUES(type); Link; Link = TREE_CHAIN(Link)) {
- tree EnumValue = TREE_VALUE(Link);
- int64_t Value = getInt64(EnumValue, tree_int_cst_sgn(EnumValue) > 0);
- const char *EnumName = IDENTIFIER_POINTER(TREE_PURPOSE(Link));
- Elements.push_back(DebugFactory.CreateEnumerator(EnumName, Value));
- }
- }
-
- llvm::DIArray EltArray =
- DebugFactory.GetOrCreateArray(&Elements[0], Elements.size());
-
- expanded_location Loc = GetNodeLocation(TREE_CHAIN(type), false);
- std::string Filename, Directory;
- DirectoryAndFile(Loc.file, Directory, Filename);
- Ty = DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_enumeration_type,
- MainCompileUnit, TypeName,
- MainCompileUnit, Loc.line,
- Size, Align, 0, 0,
- llvm::DIType(), EltArray,
- &Filename, &Directory);
+ case ENUMERAL_TYPE:
+ Ty = createEnumType(type);
break;
- }
case RECORD_TYPE:
case QUAL_UNION_TYPE:
- case UNION_TYPE: {
- // struct { a; b; ... z; }; | union { a; b; ... z; };
- unsigned Tag = TREE_CODE(type) == RECORD_TYPE ? DW_TAG_structure_type :
- DW_TAG_union_type;
-
- // Records and classes and unions can all be recursive. To handle them,
- // we first generate a debug descriptor for the struct as a forward
- // declaration. Then (if it is a definition) we go through and get debug
- // info for all of its members. Finally, we create a descriptor for the
- // complete type (which may refer to the forward decl if the struct is
- // recursive) and replace all uses of the forward declaration with the
- // final definition.
- expanded_location Loc = GetNodeLocation(TREE_CHAIN(type), false);
- std::string Filename, Directory;
- DirectoryAndFile(Loc.file, Directory, Filename);
- llvm::DIType FwdDecl =
- DebugFactory.CreateCompositeType(Tag, MainCompileUnit, TypeName,
- MainCompileUnit, Loc.line,
- 0, 0, 0, llvm::DIType::FlagFwdDecl,
- llvm::DIType(), llvm::DIArray(),
- &Filename, &Directory);
-
-
- // forward declaration,
- if (TYPE_SIZE(type) == 0) {
- Ty = FwdDecl;
- break;
- }
-
- // Insert into the TypeCache so that recursive uses will find it.
- TypeCache[type] = FwdDecl;
-
- // Convert all the elements.
- llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
-
- if (tree binfo = TYPE_BINFO(type)) {
- VEC (tree, gc) *accesses = BINFO_BASE_ACCESSES (binfo);
-
- for (unsigned i = 0, e = BINFO_N_BASE_BINFOS(binfo); i != e; ++i) {
- tree BInfo = BINFO_BASE_BINFO(binfo, i);
- tree BInfoType = BINFO_TYPE (BInfo);
- DIType BaseClass = getOrCreateType(BInfoType);
-
- // FIXME : name, size, align etc...
- DIType DTy =
- DebugFactory.CreateDerivedType(DW_TAG_inheritance,
- MainCompileUnit,"",
- MainCompileUnit, 0,0,0,
- getInt64(BINFO_OFFSET(BInfo), 0),
- 0, BaseClass);
- EltTys.push_back(DTy);
- }
- }
-
- // Now add members of this class.
- for (tree Member = TYPE_FIELDS(type); Member;
- Member = TREE_CHAIN(Member)) {
- // Should we skip.
- if (DECL_P(Member) && DECL_IGNORED_P(Member)) continue;
-
- if (TREE_CODE(Member) == FIELD_DECL) {
-
- if (DECL_FIELD_OFFSET(Member) == 0 ||
- TREE_CODE(DECL_FIELD_OFFSET(Member)) != INTEGER_CST)
- // FIXME: field with variable position, skip it for now.
- continue;
-
- /* Ignore nameless fields. */
- if (DECL_NAME (Member) == NULL_TREE)
- continue;
-
- // Get the location of the member.
- expanded_location MemLoc = GetNodeLocation(Member, false);
- std::string MemFilename, MemDirectory;
- DirectoryAndFile(MemLoc.file, MemDirectory, MemFilename);
-
- // Field type is the declared type of the field.
- tree FieldNodeType = FieldType(Member);
- DIType MemberType = getOrCreateType(FieldNodeType);
- const char *MemberName = GetNodeName(Member);
- unsigned Flags = 0;
- if (TREE_PROTECTED(Member))
- Flags = llvm::DIType::FlagProtected;
- else if (TREE_PRIVATE(Member))
- Flags = llvm::DIType::FlagPrivate;
-
- DIType DTy =
- DebugFactory.CreateDerivedType(DW_TAG_member, MainCompileUnit,
- MemberName, MainCompileUnit,
- MemLoc.line, NodeSizeInBits(Member),
- NodeAlignInBits(FieldNodeType),
- int_bit_position(Member),
- Flags, MemberType,
- &MemFilename, &MemDirectory);
- EltTys.push_back(DTy);
- } else {
- DEBUGASSERT(0 && "Unsupported member tree code!");
- }
- }
-
- for (tree Member = TYPE_METHODS(type); Member;
- Member = TREE_CHAIN(Member)) {
-
- if (DECL_ABSTRACT_ORIGIN (Member)) continue;
-
- // Get the location of the member.
- expanded_location MemLoc = GetNodeLocation(Member, false);
- std::string MemFilename, MemDirectory;
- DirectoryAndFile(MemLoc.file, MemDirectory, MemFilename);
-
- const char *MemberName = GetNodeName(Member);
- DIType SPTy = getOrCreateType(TREE_TYPE(Member));
- DISubprogram SP =
- DebugFactory.CreateSubprogram(MainCompileUnit, MemberName, MemberName,
- MemberName, MainCompileUnit,
- MemLoc.line, SPTy, false, false,
- &MemFilename, &MemDirectory);
-
- EltTys.push_back(SP);
- }
-
- llvm::DIArray Elements =
- DebugFactory.GetOrCreateArray(&EltTys[0], EltTys.size());
-
- llvm::DIType RealDecl =
- DebugFactory.CreateCompositeType(Tag, MainCompileUnit, TypeName,
- MainCompileUnit, Loc.line, Size,
- Align, 0, 0, llvm::DIType(), Elements,
- &Filename, &Directory);
-
- // Now that we have a real decl for the struct, replace anything using the
- // old decl with the new one. This will recursively update the debug info.
- FwdDecl.getGV()->replaceAllUsesWith(RealDecl.getGV());
- FwdDecl.getGV()->eraseFromParent();
- Ty = RealDecl;
-
+ case UNION_TYPE:
+ Ty = createStructType(type);
break;
- }
case INTEGER_TYPE:
case REAL_TYPE:
case COMPLEX_TYPE:
- case BOOLEAN_TYPE: {
-
- unsigned Encoding = 0;
-
- switch (TREE_CODE(type)) {
- case INTEGER_TYPE:
- if (TYPE_STRING_FLAG (type)) {
- if (TYPE_UNSIGNED (type))
- Encoding = DW_ATE_unsigned_char;
- else
- Encoding = DW_ATE_signed_char;
- }
- else if (TYPE_UNSIGNED (type))
- Encoding = DW_ATE_unsigned;
- else
- Encoding = DW_ATE_signed;
- break;
- case REAL_TYPE:
- Encoding = DW_ATE_float;
- break;
- case COMPLEX_TYPE:
- Encoding = TREE_CODE(TREE_TYPE(type)) == REAL_TYPE ?
- DW_ATE_complex_float : DW_ATE_lo_user;
- break;
- case BOOLEAN_TYPE:
- Encoding = DW_ATE_boolean;
- break;
- default: {
- DEBUGASSERT(0 && "Basic type case missing");
- Encoding = DW_ATE_signed;
- Size = BITS_PER_WORD;
- Align = BITS_PER_WORD;
- break;
- }
- }
- Ty = DebugFactory.CreateBasicType(MainCompileUnit, TypeName,
- MainCompileUnit, 0, Size, Align,
- 0, 0, Encoding);
- }
+ case BOOLEAN_TYPE:
+ Ty = createBasicType(type);
+ break;
}
TypeCache[type] = Ty;
return Ty;
Modified: llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.h?rev=63204&r1=63203&r2=63204&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/branches/release_25/gcc/llvm-debug.h Wed Jan 28 09:39:51 2009
@@ -108,6 +108,27 @@
/// necessary.
DIType getOrCreateType(tree_node *type);
+ /// createBasicType - Create BasicType.
+ DIType createBasicType(tree_node *type);
+
+ /// createMethodType - Create MethodType.
+ DIType createMethodType(tree_node *type);
+
+ /// createPointerType - Create PointerType.
+ DIType createPointerType(tree_node *type);
+
+ /// createArrayType - Create ArrayType.
+ DIType createArrayType(tree_node *type);
+
+ /// createEnumType - Create EnumType.
+ DIType createEnumType(tree_node *type);
+
+ /// createStructType - Create StructType for struct or union or class.
+ DIType createStructType(tree_node *type);
+
+ /// createVarinatType - Create variant type or return MainTy.
+ DIType createVariantType(tree_node *type, DIType MainTy);
+
/// createCompileUnit - Create a new compile unit.
DICompileUnit createCompileUnit(const std::string &FullPath);
More information about the llvm-commits
mailing list