mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-13 23:20:41 +00:00
Do not hardcode metadata names.
llvm-svn: 83010
This commit is contained in:
parent
3c46142f12
commit
9e2af6ed0b
@ -1266,6 +1266,7 @@ class AssemblyWriter {
|
|||||||
TypePrinting TypePrinter;
|
TypePrinting TypePrinter;
|
||||||
AssemblyAnnotationWriter *AnnotationWriter;
|
AssemblyAnnotationWriter *AnnotationWriter;
|
||||||
std::vector<const Type*> NumberedTypes;
|
std::vector<const Type*> NumberedTypes;
|
||||||
|
DenseMap<unsigned, const char *> MDNames;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
|
inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
|
||||||
@ -1273,6 +1274,14 @@ public:
|
|||||||
AssemblyAnnotationWriter *AAW)
|
AssemblyAnnotationWriter *AAW)
|
||||||
: 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
|
||||||
|
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); }
|
void write(const Module *M) { printModule(M); }
|
||||||
@ -1991,11 +2000,16 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
|||||||
Out << ", align " << cast<StoreInst>(I).getAlignment();
|
Out << ", align " << cast<StoreInst>(I).getAlignment();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print DebugInfo
|
// Print Metadata info
|
||||||
Metadata &TheMetadata = I.getContext().getMetadata();
|
Metadata &TheMetadata = I.getContext().getMetadata();
|
||||||
unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
|
const Metadata::MDMapTy *MDMap = TheMetadata.getMDs(&I);
|
||||||
if (const MDNode *Dbg = TheMetadata.getMD(MDDbgKind, &I))
|
if (MDMap)
|
||||||
Out << ", dbg !" << Machine.getMetadataSlot(Dbg);
|
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);
|
printInfoComment(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user