s/class Metadata/class MetadataContext/g

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83019 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2009-09-28 21:41:20 +00:00
parent a2148402ce
commit e30e678865
12 changed files with 38 additions and 38 deletions

View File

@ -18,7 +18,7 @@
namespace llvm { namespace llvm {
class LLVMContextImpl; class LLVMContextImpl;
class Metadata; class MetadataContext;
/// This is an important class for using LLVM in a threaded context. It /// This is an important class for using LLVM in a threaded context. It
/// (opaquely) owns and manages the core "global" data of LLVM's core /// (opaquely) owns and manages the core "global" data of LLVM's core
/// infrastructure, including the type and constant uniquing tables. /// infrastructure, including the type and constant uniquing tables.
@ -30,7 +30,7 @@ class LLVMContext {
void operator=(LLVMContext&); void operator=(LLVMContext&);
public: public:
LLVMContextImpl* pImpl; LLVMContextImpl* pImpl;
Metadata &getMetadata(); MetadataContext &getMetadata();
bool RemoveDeadMetadata(); bool RemoveDeadMetadata();
LLVMContext(); LLVMContext();
~LLVMContext(); ~LLVMContext();

View File

@ -304,10 +304,10 @@ public:
}; };
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// Metadata - /// MetadataContext -
/// Metadata manages metadata used in a context. /// MetadataContext manages metadata used in a context.
class Metadata { class MetadataContext {
public: public:
typedef std::pair<unsigned, WeakVH> MDPairTy; typedef std::pair<unsigned, WeakVH> MDPairTy;
typedef SmallVector<MDPairTy, 2> MDMapTy; typedef SmallVector<MDPairTy, 2> MDMapTy;

View File

@ -42,7 +42,7 @@ class raw_ostream;
class AssemblyAnnotationWriter; class AssemblyAnnotationWriter;
class ValueHandleBase; class ValueHandleBase;
class LLVMContext; class LLVMContext;
class Metadata; class MetadataContext;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Value Class // Value Class
@ -83,7 +83,7 @@ private:
friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name. friend class ValueSymbolTable; // Allow ValueSymbolTable to directly mod Name.
friend class SymbolTable; // Allow SymbolTable to directly poke Name. friend class SymbolTable; // Allow SymbolTable to directly poke Name.
friend class ValueHandleBase; friend class ValueHandleBase;
friend class Metadata; friend class MetadataContext;
friend class AbstractTypeUser; friend class AbstractTypeUser;
ValueName *Name; ValueName *Name;

View File

@ -1038,7 +1038,7 @@ bool LLParser::ParseOptionalDbgInfo() {
MetadataBase *Node; MetadataBase *Node;
if (ParseMDNode(Node)) return true; if (ParseMDNode(Node)) return true;
Metadata &TheMetadata = M->getContext().getMetadata(); MetadataContext &TheMetadata = M->getContext().getMetadata();
unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
if (!MDDbgKind) if (!MDDbgKind)
MDDbgKind = TheMetadata.RegisterMDKind("dbg"); MDDbgKind = TheMetadata.RegisterMDKind("dbg");
@ -2656,7 +2656,7 @@ bool LLParser::ParseBasicBlock(PerFunctionState &PFS) {
ParseOptionalDbgInfo(); ParseOptionalDbgInfo();
// Set metadata attached with this instruction. // Set metadata attached with this instruction.
Metadata &TheMetadata = M->getContext().getMetadata(); MetadataContext &TheMetadata = M->getContext().getMetadata();
for (SmallVector<std::pair<unsigned, MDNode *>, 2>::iterator for (SmallVector<std::pair<unsigned, MDNode *>, 2>::iterator
MDI = MDsOnInst.begin(), MDE = MDsOnInst.end(); MDI != MDE; ++MDI) MDI = MDsOnInst.begin(), MDE = MDsOnInst.end(); MDI != MDE; ++MDI)
TheMetadata.setMD(MDI->first, MDI->second, Inst); TheMetadata.setMD(MDI->first, MDI->second, Inst);

View File

@ -839,7 +839,7 @@ bool BitcodeReader::ParseMetadata() {
unsigned Kind = Record[0]; unsigned Kind = Record[0];
for (unsigned i = 1; i != RecordLength; ++i) for (unsigned i = 1; i != RecordLength; ++i)
Name[i-1] = Record[i]; Name[i-1] = Record[i];
Metadata &TheMetadata = Context.getMetadata(); MetadataContext &TheMetadata = Context.getMetadata();
assert(TheMetadata.MDHandlerNames.find(Name.str()) assert(TheMetadata.MDHandlerNames.find(Name.str())
== TheMetadata.MDHandlerNames.end() && == TheMetadata.MDHandlerNames.end() &&
"Already registered MDKind!"); "Already registered MDKind!");
@ -1556,7 +1556,7 @@ bool BitcodeReader::ParseMetadataAttachment() {
if (Stream.EnterSubBlock(bitc::METADATA_ATTACHMENT_ID)) if (Stream.EnterSubBlock(bitc::METADATA_ATTACHMENT_ID))
return Error("Malformed block record"); return Error("Malformed block record");
Metadata &TheMetadata = Context.getMetadata(); MetadataContext &TheMetadata = Context.getMetadata();
SmallVector<uint64_t, 64> Record; SmallVector<uint64_t, 64> Record;
while(1) { while(1) {
unsigned Code = Stream.ReadCode(); unsigned Code = Stream.ReadCode();

View File

@ -562,15 +562,15 @@ static void WriteMetadataAttachment(const Function &F,
// Write metadata attachments // Write metadata attachments
// METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]] // METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]]
Metadata &TheMetadata = F.getContext().getMetadata(); MetadataContext &TheMetadata = F.getContext().getMetadata();
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
I != E; ++I) { I != E; ++I) {
const Metadata::MDMapTy *P = TheMetadata.getMDs(I); const MetadataContext::MDMapTy *P = TheMetadata.getMDs(I);
if (!P) continue; if (!P) continue;
bool RecordedInstruction = false; bool RecordedInstruction = false;
for (Metadata::MDMapTy::const_iterator PI = P->begin(), PE = P->end(); for (MetadataContext::MDMapTy::const_iterator PI = P->begin(),
PI != PE; ++PI) { PE = P->end(); PI != PE; ++PI) {
if (MDNode *ND = dyn_cast_or_null<MDNode>(PI->second)) { if (MDNode *ND = dyn_cast_or_null<MDNode>(PI->second)) {
if (RecordedInstruction == false) { if (RecordedInstruction == false) {
Record.push_back(VE.getInstructionID(I)); Record.push_back(VE.getInstructionID(I));
@ -601,7 +601,7 @@ static void WriteModuleMetadataStore(const Module *M,
// Write metadata kinds // Write metadata kinds
// METADATA_KIND - [n x [id, name]] // METADATA_KIND - [n x [id, name]]
Metadata &TheMetadata = M->getContext().getMetadata(); MetadataContext &TheMetadata = M->getContext().getMetadata();
const StringMap<unsigned> *Kinds = TheMetadata.getHandlerNames(); const StringMap<unsigned> *Kinds = TheMetadata.getHandlerNames();
for (StringMap<unsigned>::const_iterator for (StringMap<unsigned>::const_iterator
I = Kinds->begin(), E = Kinds->end(); I != E; ++I) { I = Kinds->begin(), E = Kinds->end(); I != E; ++I) {

View File

@ -86,7 +86,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
I != E; ++I) I != E; ++I)
EnumerateType(I->getType()); EnumerateType(I->getType());
Metadata &TheMetadata = F->getContext().getMetadata(); MetadataContext &TheMetadata = F->getContext().getMetadata();
for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB) for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){ for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I){
for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
@ -99,9 +99,9 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
EnumerateAttributes(II->getAttributes()); EnumerateAttributes(II->getAttributes());
// Enumerate metadata attached with this instruction. // Enumerate metadata attached with this instruction.
const Metadata::MDMapTy *MDs = TheMetadata.getMDs(I); const MetadataContext::MDMapTy *MDs = TheMetadata.getMDs(I);
if (MDs) if (MDs)
for (Metadata::MDMapTy::const_iterator MI = MDs->begin(), for (MetadataContext::MDMapTy::const_iterator MI = MDs->begin(),
ME = MDs->end(); MI != ME; ++MI) ME = MDs->end(); MI != ME; ++MI)
if (MDNode *MDN = dyn_cast_or_null<MDNode>(MI->second)) if (MDNode *MDN = dyn_cast_or_null<MDNode>(MI->second))
EnumerateMetadata(MDN); EnumerateMetadata(MDN);

View File

@ -372,7 +372,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
BasicBlock::iterator Begin, BasicBlock::iterator Begin,
BasicBlock::iterator End) { BasicBlock::iterator End) {
SDL->setCurrentBasicBlock(BB); SDL->setCurrentBasicBlock(BB);
Metadata &TheMetadata = LLVMBB->getParent()->getContext().getMetadata(); MetadataContext &TheMetadata = LLVMBB->getParent()->getContext().getMetadata();
unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
// Lower all of the non-terminator instructions. If a call is emitted // Lower all of the non-terminator instructions. If a call is emitted
@ -655,7 +655,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
#endif #endif
); );
Metadata &TheMetadata = Fn.getContext().getMetadata(); MetadataContext &TheMetadata = Fn.getContext().getMetadata();
unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
// Iterate over all basic blocks in the function. // Iterate over all basic blocks in the function.

View File

@ -678,7 +678,7 @@ void SlotTracker::processFunction() {
ST_DEBUG("Inserting Instructions:\n"); ST_DEBUG("Inserting Instructions:\n");
Metadata &TheMetadata = TheFunction->getContext().getMetadata(); MetadataContext &TheMetadata = TheFunction->getContext().getMetadata();
// Add all of the basic blocks and instructions with no names. // Add all of the basic blocks and instructions with no names.
for (Function::const_iterator BB = TheFunction->begin(), for (Function::const_iterator BB = TheFunction->begin(),
@ -695,9 +695,9 @@ void SlotTracker::processFunction() {
CreateMetadataSlot(N); CreateMetadataSlot(N);
// Process metadata attached with this instruction. // Process metadata attached with this instruction.
const Metadata::MDMapTy *MDs = TheMetadata.getMDs(I); const MetadataContext::MDMapTy *MDs = TheMetadata.getMDs(I);
if (MDs) if (MDs)
for (Metadata::MDMapTy::const_iterator MI = MDs->begin(), for (MetadataContext::MDMapTy::const_iterator MI = MDs->begin(),
ME = MDs->end(); MI != ME; ++MI) ME = MDs->end(); MI != ME; ++MI)
if (MDNode *MDN = dyn_cast_or_null<MDNode>(MI->second)) if (MDNode *MDN = dyn_cast_or_null<MDNode>(MI->second))
CreateMetadataSlot(MDN); CreateMetadataSlot(MDN);
@ -1275,7 +1275,7 @@ public:
: Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) { : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) {
AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M); AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M);
// FIXME: Provide MDPrinter // FIXME: Provide MDPrinter
Metadata &TheMetadata = M->getContext().getMetadata(); MetadataContext &TheMetadata = M->getContext().getMetadata();
const StringMap<unsigned> *Names = TheMetadata.getHandlerNames(); const StringMap<unsigned> *Names = TheMetadata.getHandlerNames();
for (StringMapConstIterator<unsigned> I = Names->begin(), for (StringMapConstIterator<unsigned> I = Names->begin(),
E = Names->end(); I != E; ++I) { E = Names->end(); I != E; ++I) {
@ -2001,10 +2001,10 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
} }
// Print Metadata info // Print Metadata info
Metadata &TheMetadata = I.getContext().getMetadata(); MetadataContext &TheMetadata = I.getContext().getMetadata();
const Metadata::MDMapTy *MDMap = TheMetadata.getMDs(&I); const MetadataContext::MDMapTy *MDMap = TheMetadata.getMDs(&I);
if (MDMap) if (MDMap)
for (Metadata::MDMapTy::const_iterator MI = MDMap->begin(), for (MetadataContext::MDMapTy::const_iterator MI = MDMap->begin(),
ME = MDMap->end(); MI != ME; ++MI) ME = MDMap->end(); MI != ME; ++MI)
if (const MDNode *MD = dyn_cast_or_null<MDNode>(MI->second)) if (const MDNode *MD = dyn_cast_or_null<MDNode>(MI->second))
Out << ", " << MDNames[MI->first] Out << ", " << MDNames[MI->first]

View File

@ -71,6 +71,6 @@ bool LLVMContext::RemoveDeadMetadata() {
return Changed; return Changed;
} }
Metadata &LLVMContext::getMetadata() { MetadataContext &LLVMContext::getMetadata() {
return pImpl->TheMetadata; return pImpl->TheMetadata;
} }

View File

@ -179,7 +179,7 @@ public:
typedef DenseMap<Value*, ValueHandleBase*> ValueHandlesTy; typedef DenseMap<Value*, ValueHandleBase*> ValueHandlesTy;
ValueHandlesTy ValueHandles; ValueHandlesTy ValueHandles;
Metadata TheMetadata; MetadataContext TheMetadata;
LLVMContextImpl(LLVMContext &C) : TheTrueVal(0), TheFalseVal(0), LLVMContextImpl(LLVMContext &C) : TheTrueVal(0), TheFalseVal(0),
VoidTy(C, Type::VoidTyID), VoidTy(C, Type::VoidTyID),
LabelTy(C, Type::LabelTyID), LabelTy(C, Type::LabelTyID),

View File

@ -259,7 +259,7 @@ NamedMDNode::~NamedMDNode() {
/// RegisterMDKind - Register a new metadata kind and return its ID. /// RegisterMDKind - Register a new metadata kind and return its ID.
/// A metadata kind can be registered only once. /// A metadata kind can be registered only once.
unsigned Metadata::RegisterMDKind(const char *Name) { unsigned MetadataContext::RegisterMDKind(const char *Name) {
unsigned Count = MDHandlerNames.size(); unsigned Count = MDHandlerNames.size();
StringMap<unsigned>::iterator I = MDHandlerNames.find(Name); StringMap<unsigned>::iterator I = MDHandlerNames.find(Name);
assert(I == MDHandlerNames.end() && "Already registered MDKind!"); assert(I == MDHandlerNames.end() && "Already registered MDKind!");
@ -269,7 +269,7 @@ unsigned Metadata::RegisterMDKind(const char *Name) {
/// getMDKind - Return metadata kind. If the requested metadata kind /// getMDKind - Return metadata kind. If the requested metadata kind
/// is not registered then return 0. /// is not registered then return 0.
unsigned Metadata::getMDKind(const char *Name) { unsigned MetadataContext::getMDKind(const char *Name) {
StringMap<unsigned>::iterator I = MDHandlerNames.find(Name); StringMap<unsigned>::iterator I = MDHandlerNames.find(Name);
if (I == MDHandlerNames.end()) if (I == MDHandlerNames.end())
return 0; return 0;
@ -278,7 +278,7 @@ unsigned Metadata::getMDKind(const char *Name) {
} }
/// setMD - Attach the metadata of given kind with an Instruction. /// setMD - Attach the metadata of given kind with an Instruction.
void Metadata::setMD(unsigned MDKind, MDNode *Node, Instruction *Inst) { void MetadataContext::setMD(unsigned MDKind, MDNode *Node, Instruction *Inst) {
MDStoreTy::iterator I = MetadataStore.find(Inst); MDStoreTy::iterator I = MetadataStore.find(Inst);
Inst->HasMetadata = true; Inst->HasMetadata = true;
if (I == MetadataStore.end()) { if (I == MetadataStore.end()) {
@ -295,7 +295,7 @@ void Metadata::setMD(unsigned MDKind, MDNode *Node, Instruction *Inst) {
/// getMD - Get the metadata of given kind attached with an Instruction. /// getMD - Get the metadata of given kind attached with an Instruction.
/// If the metadata is not found then return 0. /// If the metadata is not found then return 0.
MDNode *Metadata::getMD(unsigned MDKind, const Instruction *Inst) { MDNode *MetadataContext::getMD(unsigned MDKind, const Instruction *Inst) {
MDNode *Node = NULL; MDNode *Node = NULL;
MDStoreTy::iterator I = MetadataStore.find(Inst); MDStoreTy::iterator I = MetadataStore.find(Inst);
if (I == MetadataStore.end()) if (I == MetadataStore.end())
@ -309,7 +309,7 @@ MDNode *Metadata::getMD(unsigned MDKind, const Instruction *Inst) {
} }
/// getMDs - Get the metadata attached with an Instruction. /// getMDs - Get the metadata attached with an Instruction.
const Metadata::MDMapTy *Metadata::getMDs(const Instruction *Inst) { const MetadataContext::MDMapTy *MetadataContext::getMDs(const Instruction *Inst) {
MDStoreTy::iterator I = MetadataStore.find(Inst); MDStoreTy::iterator I = MetadataStore.find(Inst);
if (I == MetadataStore.end()) if (I == MetadataStore.end())
return NULL; return NULL;
@ -319,13 +319,13 @@ const Metadata::MDMapTy *Metadata::getMDs(const Instruction *Inst) {
/// getHandlerNames - Get handler names. This is used by bitcode /// getHandlerNames - Get handler names. This is used by bitcode
/// writer. /// writer.
const StringMap<unsigned> *Metadata::getHandlerNames() { const StringMap<unsigned> *MetadataContext::getHandlerNames() {
return &MDHandlerNames; return &MDHandlerNames;
} }
/// ValueIsDeleted - This handler is used to update metadata store /// ValueIsDeleted - This handler is used to update metadata store
/// when a value is deleted. /// when a value is deleted.
void Metadata::ValueIsDeleted(const Instruction *Inst) { void MetadataContext::ValueIsDeleted(const Instruction *Inst) {
// Find Metadata handles for this instruction. // Find Metadata handles for this instruction.
MDStoreTy::iterator I = MetadataStore.find(Inst); MDStoreTy::iterator I = MetadataStore.find(Inst);
if (I == MetadataStore.end()) if (I == MetadataStore.end())
@ -341,7 +341,7 @@ void Metadata::ValueIsDeleted(const Instruction *Inst) {
/// ValueIsCloned - This handler is used to update metadata store /// ValueIsCloned - This handler is used to update metadata store
/// when In1 is cloned to create In2. /// when In1 is cloned to create In2.
void Metadata::ValueIsCloned(const Instruction *In1, Instruction *In2) { void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) {
// Find Metadata handles for In1. // Find Metadata handles for In1.
MDStoreTy::iterator I = MetadataStore.find(In1); MDStoreTy::iterator I = MetadataStore.find(In1);
if (I == MetadataStore.end()) if (I == MetadataStore.end())