diff options
author | Devang Patel <dpatel@apple.com> | 2009-09-28 20:56:00 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2009-09-28 20:56:00 +0000 |
commit | 18f0c263e65da094ef5ba49bb7f66f58cf1cbd0f (patch) | |
tree | a620cb52376682d38df62ea959ae24f7b5f3212b /lib | |
parent | 8c050fadf6b290ae84c747f3a58cd67dec6cc801 (diff) | |
download | external_llvm-18f0c263e65da094ef5ba49bb7f66f58cf1cbd0f.zip external_llvm-18f0c263e65da094ef5ba49bb7f66f58cf1cbd0f.tar.gz external_llvm-18f0c263e65da094ef5ba49bb7f66f58cf1cbd0f.tar.bz2 |
Do not hardcode metadata names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 62856b3..b8e5ec0 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1266,6 +1266,7 @@ class AssemblyWriter { TypePrinting TypePrinter; AssemblyAnnotationWriter *AnnotationWriter; std::vector<const Type*> NumberedTypes; + DenseMap<unsigned, const char *> MDNames; public: inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, @@ -1273,6 +1274,14 @@ public: AssemblyAnnotationWriter *AAW) : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) { AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M); + // FIXME: Provide MDPrinter + Metadata &TheMetadata = M->getContext().getMetadata(); + const StringMap<unsigned> *Names = TheMetadata.getHandlerNames(); + for (StringMapConstIterator<unsigned> I = Names->begin(), + E = Names->end(); I != E; ++I) { + const StringMapEntry<unsigned> &Entry = *I; + MDNames[I->second] = Entry.getKeyData(); + } } void write(const Module *M) { printModule(M); } @@ -1991,11 +2000,16 @@ void AssemblyWriter::printInstruction(const Instruction &I) { Out << ", align " << cast<StoreInst>(I).getAlignment(); } - // Print DebugInfo + // Print Metadata info Metadata &TheMetadata = I.getContext().getMetadata(); - unsigned MDDbgKind = TheMetadata.getMDKind("dbg"); - if (const MDNode *Dbg = TheMetadata.getMD(MDDbgKind, &I)) - Out << ", dbg !" << Machine.getMetadataSlot(Dbg); + const Metadata::MDMapTy *MDMap = TheMetadata.getMDs(&I); + if (MDMap) + for (Metadata::MDMapTy::const_iterator MI = MDMap->begin(), + ME = MDMap->end(); MI != ME; ++MI) + if (const MDNode *MD = dyn_cast_or_null<MDNode>(MI->second)) + Out << ", " << MDNames[MI->first] + << " !" << Machine.getMetadataSlot(MD); + printInfoComment(I); } |