[llvm] r225732 - IR: Split out writeMDTuple(), NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Mon Jan 12 15:45:32 PST 2015
Author: dexonsmith
Date: Mon Jan 12 17:45:31 2015
New Revision: 225732
URL: http://llvm.org/viewvc/llvm-project?rev=225732&view=rev
Log:
IR: Split out writeMDTuple(), NFC
Prepare for more subclasses of `UniquableMDNode` than `MDTuple`.
Modified:
llvm/trunk/lib/IR/AsmWriter.cpp
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=225732&r1=225731&r2=225732&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Mon Jan 12 17:45:31 2015
@@ -1249,12 +1249,9 @@ static void WriteConstantInternal(raw_os
Out << "<placeholder or erroneous Constant>";
}
-static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
- TypePrinting *TypePrinter,
- SlotTracker *Machine,
- const Module *Context) {
- if (Node->isDistinct())
- Out << "distinct ";
+static void writeMDTuple(raw_ostream &Out, const MDTuple *Node,
+ TypePrinting *TypePrinter, SlotTracker *Machine,
+ const Module *Context) {
Out << "!{";
for (unsigned mi = 0, me = Node->getNumOperands(); mi != me; ++mi) {
const Metadata *MD = Node->getOperand(mi);
@@ -1275,6 +1272,27 @@ static void WriteMDNodeBodyInternal(raw_
Out << "}";
}
+static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
+ TypePrinting *TypePrinter,
+ SlotTracker *Machine,
+ const Module *Context) {
+ assert(isa<UniquableMDNode>(Node) && "Expected uniquable MDNode");
+
+ auto *Uniquable = cast<UniquableMDNode>(Node);
+ if (Uniquable->isDistinct())
+ Out << "distinct ";
+
+ switch (Uniquable->getMetadataID()) {
+ default:
+ llvm_unreachable("Expected uniquable MDNode");
+#define HANDLE_UNIQUABLE_LEAF(CLASS) \
+ case Metadata::CLASS##Kind: \
+ write##CLASS(Out, cast<CLASS>(Uniquable), TypePrinter, Machine, Context); \
+ break;
+#include "llvm/IR/Metadata.def"
+ }
+}
+
// Full implementation of printing a Value as an operand with support for
// TypePrinting, etc.
static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
More information about the llvm-commits
mailing list