mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
DI: Remove unnecessary DICompositeTypeBase
Remove unnecessary and confusing common base class for `DICompositeType` and `DISubroutineType`. While at a high-level `DISubroutineType` is a sort of composite of other types, it has no shared code paths, and its fields are completely disjoint. This relationship was left over from the old debug info hierarchy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243160 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
24b6acf971
commit
e5f2fce18a
3 files changed
+51
-85
No files matched your search
@@ -745,92 +745,23 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Base class for DICompositeType and DISubroutineType.
|
|
||||||
///
|
|
||||||
/// TODO: Delete; they're not really related.
|
|
||||||
class DICompositeTypeBase : public DIType {
|
|
||||||
unsigned RuntimeLang;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
DICompositeTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
|
|
||||||
unsigned Tag, unsigned Line, unsigned RuntimeLang,
|
|
||||||
uint64_t SizeInBits, uint64_t AlignInBits,
|
|
||||||
uint64_t OffsetInBits, unsigned Flags,
|
|
||||||
ArrayRef<Metadata *> Ops)
|
|
||||||
: DIType(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
|
|
||||||
Flags, Ops),
|
|
||||||
RuntimeLang(RuntimeLang) {}
|
|
||||||
~DICompositeTypeBase() = default;
|
|
||||||
|
|
||||||
public:
|
|
||||||
//// Get the base type this is derived from, if any.
|
|
||||||
DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
|
|
||||||
|
|
||||||
/// \brief Get the elements of the composite type.
|
|
||||||
///
|
|
||||||
/// \note Calling this is only valid for \a DICompositeType. This assertion
|
|
||||||
/// can be removed once \a DISubroutineType has been separated from
|
|
||||||
/// "composite types".
|
|
||||||
DINodeArray getElements() const {
|
|
||||||
assert(!isa<DISubroutineType>(this) && "no elements for DISubroutineType");
|
|
||||||
return cast_or_null<MDTuple>(getRawElements());
|
|
||||||
}
|
|
||||||
DITypeRef getVTableHolder() const { return DITypeRef(getRawVTableHolder()); }
|
|
||||||
DITemplateParameterArray getTemplateParams() const {
|
|
||||||
return cast_or_null<MDTuple>(getRawTemplateParams());
|
|
||||||
}
|
|
||||||
StringRef getIdentifier() const { return getStringOperand(7); }
|
|
||||||
unsigned getRuntimeLang() const { return RuntimeLang; }
|
|
||||||
|
|
||||||
Metadata *getRawBaseType() const { return getOperand(3); }
|
|
||||||
Metadata *getRawElements() const { return getOperand(4); }
|
|
||||||
Metadata *getRawVTableHolder() const { return getOperand(5); }
|
|
||||||
Metadata *getRawTemplateParams() const { return getOperand(6); }
|
|
||||||
MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
|
|
||||||
|
|
||||||
/// \brief Replace operands.
|
|
||||||
///
|
|
||||||
/// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
|
|
||||||
/// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
|
|
||||||
/// of its movement if necessary.
|
|
||||||
/// @{
|
|
||||||
void replaceElements(DINodeArray Elements) {
|
|
||||||
#ifndef NDEBUG
|
|
||||||
for (DINode *Op : getElements())
|
|
||||||
assert(std::find(Elements->op_begin(), Elements->op_end(), Op) &&
|
|
||||||
"Lost a member during member list replacement");
|
|
||||||
#endif
|
|
||||||
replaceOperandWith(4, Elements.get());
|
|
||||||
}
|
|
||||||
void replaceVTableHolder(DITypeRef VTableHolder) {
|
|
||||||
replaceOperandWith(5, VTableHolder);
|
|
||||||
}
|
|
||||||
void replaceTemplateParams(DITemplateParameterArray TemplateParams) {
|
|
||||||
replaceOperandWith(6, TemplateParams.get());
|
|
||||||
}
|
|
||||||
/// @}
|
|
||||||
|
|
||||||
static bool classof(const Metadata *MD) {
|
|
||||||
return MD->getMetadataID() == DICompositeTypeKind ||
|
|
||||||
MD->getMetadataID() == DISubroutineTypeKind;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// \brief Composite types.
|
/// \brief Composite types.
|
||||||
///
|
///
|
||||||
/// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
|
/// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
|
||||||
/// TODO: Create a custom, unrelated node for DW_TAG_array_type.
|
/// TODO: Create a custom, unrelated node for DW_TAG_array_type.
|
||||||
class DICompositeType : public DICompositeTypeBase {
|
class DICompositeType : public DIType {
|
||||||
friend class LLVMContextImpl;
|
friend class LLVMContextImpl;
|
||||||
friend class MDNode;
|
friend class MDNode;
|
||||||
|
|
||||||
|
unsigned RuntimeLang;
|
||||||
|
|
||||||
DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
|
DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
|
||||||
unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
|
unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
|
||||||
uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
|
uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
|
||||||
ArrayRef<Metadata *> Ops)
|
ArrayRef<Metadata *> Ops)
|
||||||
: DICompositeTypeBase(C, DICompositeTypeKind, Storage, Tag, Line,
|
: DIType(C, DICompositeTypeKind, Storage, Tag, Line, SizeInBits,
|
||||||
RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
|
AlignInBits, OffsetInBits, Flags, Ops),
|
||||||
Flags, Ops) {}
|
RuntimeLang(RuntimeLang) {}
|
||||||
~DICompositeType() = default;
|
~DICompositeType() = default;
|
||||||
|
|
||||||
static DICompositeType *
|
static DICompositeType *
|
||||||
@@ -888,6 +819,45 @@ public:
|
|||||||
|
|
||||||
TempDICompositeType clone() const { return cloneImpl(); }
|
TempDICompositeType clone() const { return cloneImpl(); }
|
||||||
|
|
||||||
|
DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
|
||||||
|
DINodeArray getElements() const {
|
||||||
|
return cast_or_null<MDTuple>(getRawElements());
|
||||||
|
}
|
||||||
|
DITypeRef getVTableHolder() const { return DITypeRef(getRawVTableHolder()); }
|
||||||
|
DITemplateParameterArray getTemplateParams() const {
|
||||||
|
return cast_or_null<MDTuple>(getRawTemplateParams());
|
||||||
|
}
|
||||||
|
StringRef getIdentifier() const { return getStringOperand(7); }
|
||||||
|
unsigned getRuntimeLang() const { return RuntimeLang; }
|
||||||
|
|
||||||
|
Metadata *getRawBaseType() const { return getOperand(3); }
|
||||||
|
Metadata *getRawElements() const { return getOperand(4); }
|
||||||
|
Metadata *getRawVTableHolder() const { return getOperand(5); }
|
||||||
|
Metadata *getRawTemplateParams() const { return getOperand(6); }
|
||||||
|
MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
|
||||||
|
|
||||||
|
/// \brief Replace operands.
|
||||||
|
///
|
||||||
|
/// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
|
||||||
|
/// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
|
||||||
|
/// of its movement if necessary.
|
||||||
|
/// @{
|
||||||
|
void replaceElements(DINodeArray Elements) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
for (DINode *Op : getElements())
|
||||||
|
assert(std::find(Elements->op_begin(), Elements->op_end(), Op) &&
|
||||||
|
"Lost a member during member list replacement");
|
||||||
|
#endif
|
||||||
|
replaceOperandWith(4, Elements.get());
|
||||||
|
}
|
||||||
|
void replaceVTableHolder(DITypeRef VTableHolder) {
|
||||||
|
replaceOperandWith(5, VTableHolder);
|
||||||
|
}
|
||||||
|
void replaceTemplateParams(DITemplateParameterArray TemplateParams) {
|
||||||
|
replaceOperandWith(6, TemplateParams.get());
|
||||||
|
}
|
||||||
|
/// @}
|
||||||
|
|
||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == DICompositeTypeKind;
|
return MD->getMetadataID() == DICompositeTypeKind;
|
||||||
}
|
}
|
||||||
@@ -903,17 +873,15 @@ template <class T> TypedDINodeRef<T> TypedDINodeRef<T>::get(const T *N) {
|
|||||||
|
|
||||||
/// \brief Type array for a subprogram.
|
/// \brief Type array for a subprogram.
|
||||||
///
|
///
|
||||||
/// TODO: Detach from CompositeType, and fold the array of types in directly
|
/// TODO: Fold the array of types in directly as operands.
|
||||||
/// as operands.
|
class DISubroutineType : public DIType {
|
||||||
class DISubroutineType : public DICompositeTypeBase {
|
|
||||||
friend class LLVMContextImpl;
|
friend class LLVMContextImpl;
|
||||||
friend class MDNode;
|
friend class MDNode;
|
||||||
|
|
||||||
DISubroutineType(LLVMContext &C, StorageType Storage, unsigned Flags,
|
DISubroutineType(LLVMContext &C, StorageType Storage, unsigned Flags,
|
||||||
ArrayRef<Metadata *> Ops)
|
ArrayRef<Metadata *> Ops)
|
||||||
: DICompositeTypeBase(C, DISubroutineTypeKind, Storage,
|
: DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type,
|
||||||
dwarf::DW_TAG_subroutine_type, 0, 0, 0, 0, 0, Flags,
|
0, 0, 0, 0, Flags, Ops) {}
|
||||||
Ops) {}
|
|
||||||
~DISubroutineType() = default;
|
~DISubroutineType() = default;
|
||||||
|
|
||||||
static DISubroutineType *getImpl(LLVMContext &Context, unsigned Flags,
|
static DISubroutineType *getImpl(LLVMContext &Context, unsigned Flags,
|
||||||
@@ -942,7 +910,7 @@ public:
|
|||||||
DITypeRefArray getTypeArray() const {
|
DITypeRefArray getTypeArray() const {
|
||||||
return cast_or_null<MDTuple>(getRawTypeArray());
|
return cast_or_null<MDTuple>(getRawTypeArray());
|
||||||
}
|
}
|
||||||
Metadata *getRawTypeArray() const { return getRawElements(); }
|
Metadata *getRawTypeArray() const { return getOperand(3); }
|
||||||
|
|
||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == DISubroutineTypeKind;
|
return MD->getMetadataID() == DISubroutineTypeKind;
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ HANDLE_SPECIALIZED_MDNODE_BRANCH(DIScope)
|
|||||||
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIType)
|
HANDLE_SPECIALIZED_MDNODE_BRANCH(DIType)
|
||||||
HANDLE_SPECIALIZED_MDNODE_LEAF(DIBasicType)
|
HANDLE_SPECIALIZED_MDNODE_LEAF(DIBasicType)
|
||||||
HANDLE_SPECIALIZED_MDNODE_LEAF(DIDerivedType)
|
HANDLE_SPECIALIZED_MDNODE_LEAF(DIDerivedType)
|
||||||
HANDLE_SPECIALIZED_MDNODE_BRANCH(DICompositeTypeBase)
|
|
||||||
HANDLE_SPECIALIZED_MDNODE_LEAF(DICompositeType)
|
HANDLE_SPECIALIZED_MDNODE_LEAF(DICompositeType)
|
||||||
HANDLE_SPECIALIZED_MDNODE_LEAF(DISubroutineType)
|
HANDLE_SPECIALIZED_MDNODE_LEAF(DISubroutineType)
|
||||||
HANDLE_SPECIALIZED_MDNODE_LEAF(DIFile)
|
HANDLE_SPECIALIZED_MDNODE_LEAF(DIFile)
|
||||||
|
|||||||
@@ -295,8 +295,7 @@ DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context,
|
|||||||
StorageType Storage,
|
StorageType Storage,
|
||||||
bool ShouldCreate) {
|
bool ShouldCreate) {
|
||||||
DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, TypeArray));
|
DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, TypeArray));
|
||||||
Metadata *Ops[] = {nullptr, nullptr, nullptr, nullptr,
|
Metadata *Ops[] = {nullptr, nullptr, nullptr, TypeArray};
|
||||||
TypeArray, nullptr, nullptr, nullptr};
|
|
||||||
DEFINE_GETIMPL_STORE(DISubroutineType, (Flags), Ops);
|
DEFINE_GETIMPL_STORE(DISubroutineType, (Flags), Ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user