Remove MetadataBase class because it is not adding significant value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94243 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2010-01-22 22:52:10 +00:00
parent 5d74e1f644
commit bc5201f837
7 changed files with 12 additions and 29 deletions

View File

@ -30,27 +30,11 @@ template<typename ValueSubClass, typename ItemParentClass>
class SymbolTableListTraits;
//===----------------------------------------------------------------------===//
// MetadataBase - A base class for MDNode and MDString.
class MetadataBase : public Value {
protected:
MetadataBase(const Type *Ty, unsigned scid)
: Value(Ty, scid) {}
public:
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const MetadataBase *) { return true; }
static bool classof(const Value *V) {
return V->getValueID() == MDStringVal || V->getValueID() == MDNodeVal;
}
};
//===----------------------------------------------------------------------===//
/// MDString - a single uniqued string.
/// These are used to efficiently contain a byte sequence for metadata.
/// MDString is always unnamd.
class MDString : public MetadataBase {
class MDString : public Value {
MDString(const MDString &); // DO NOT IMPLEMENT
StringRef Str;
@ -87,7 +71,7 @@ class MDNodeOperand;
//===----------------------------------------------------------------------===//
/// MDNode - a tuple of other values.
class MDNode : public MetadataBase, public FoldingSetNode {
class MDNode : public Value, public FoldingSetNode {
MDNode(const MDNode &); // DO NOT IMPLEMENT
void operator=(const MDNode &); // DO NOT IMPLEMENT
friend class MDNodeOperand;

View File

@ -29,7 +29,6 @@ namespace llvm {
class Instruction;
class Constant;
class GlobalValue;
class MetadataBase;
class MDString;
class MDNode;

View File

@ -140,7 +140,7 @@ void ValueEnumerator::setInstructionID(const Instruction *I) {
}
unsigned ValueEnumerator::getValueID(const Value *V) const {
if (isa<MetadataBase>(V)) {
if (isa<MDNode>(V) || isa<MDString>(V)) {
ValueMapType::const_iterator I = MDValueMap.find(V);
assert(I != MDValueMap.end() && "Value not in slotcalculator!");
return I->second-1;
@ -229,7 +229,8 @@ void ValueEnumerator::EnumerateNamedMDNode(const NamedMDNode *MD) {
MDValueMap[MD] = Values.size();
}
void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) {
void ValueEnumerator::EnumerateMetadata(const Value *MD) {
assert(isa<MDNode>(MD) || isa<MDString>(MD) && "Invalid metadata kind");
// Check to see if it's already in!
unsigned &MDValueID = MDValueMap[MD];
if (MDValueID) {
@ -262,8 +263,8 @@ void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) {
void ValueEnumerator::EnumerateValue(const Value *V) {
assert(!V->getType()->isVoidTy() && "Can't insert void values!");
if (const MetadataBase *MB = dyn_cast<MetadataBase>(V))
return EnumerateMetadata(MB);
if (isa<MDNode>(V) || isa<MDString>(V))
return EnumerateMetadata(V);
else if (const NamedMDNode *NMD = dyn_cast<NamedMDNode>(V))
return EnumerateNamedMDNode(NMD);

View File

@ -127,7 +127,7 @@ public:
private:
void OptimizeConstants(unsigned CstStart, unsigned CstEnd);
void EnumerateMetadata(const MetadataBase *MD);
void EnumerateMetadata(const Value *MD);
void EnumerateNamedMDNode(const NamedMDNode *NMD);
void EnumerateValue(const Value *V);
void EnumerateType(const Type *T);

View File

@ -1910,8 +1910,7 @@ void DwarfDebug::collectVariableInfo() {
MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo();
for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(),
VE = VMap.end(); VI != VE; ++VI) {
MetadataBase *MB = VI->first;
MDNode *Var = dyn_cast_or_null<MDNode>(MB);
MDNode *Var = VI->first;
if (!Var) continue;
DIVariable DV (Var);
std::pair< unsigned, MDNode *> VP = VI->second;

View File

@ -392,7 +392,7 @@ static Value *RemapOperand(const Value *In,
assert(!isa<GlobalValue>(CPV) && "Unmapped global?");
llvm_unreachable("Unknown type of derived type constant value!");
}
} else if (isa<MetadataBase>(In)) {
} else if (isa<MDNode>(In) || isa<MDString>(In)) {
Result = const_cast<Value*>(In);
} else if (isa<InlineAsm>(In)) {
Result = const_cast<Value*>(In);

View File

@ -28,7 +28,7 @@ using namespace llvm;
//
MDString::MDString(LLVMContext &C, StringRef S)
: MetadataBase(Type::getMetadataTy(C), Value::MDStringVal), Str(S) {}
: Value(Type::getMetadataTy(C), Value::MDStringVal), Str(S) {}
MDString *MDString::get(LLVMContext &Context, StringRef Str) {
LLVMContextImpl *pImpl = Context.pImpl;
@ -93,7 +93,7 @@ static MDNodeOperand *getOperandPtr(MDNode *N, unsigned Op) {
MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
bool isFunctionLocal)
: MetadataBase(Type::getMetadataTy(C), Value::MDNodeVal) {
: Value(Type::getMetadataTy(C), Value::MDNodeVal) {
NumOperands = NumVals;
if (isFunctionLocal)