diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-12 23:45:31 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-12 23:45:31 +0000 |
| commit | a6de6a4013ca744b377f742e699fb95e39b29f83 (patch) | |
| tree | 198adb25e7533ef58b3c63a00b372f6834c1751a /llvm/lib | |
| parent | a4c30d6509260cce67904710bccb3cd07d396971 (diff) | |
| download | bcm5719-llvm-a6de6a4013ca744b377f742e699fb95e39b29f83.tar.gz bcm5719-llvm-a6de6a4013ca744b377f742e699fb95e39b29f83.zip | |
IR: Split out writeMDTuple(), NFC
Prepare for more subclasses of `UniquableMDNode` than `MDTuple`.
llvm-svn: 225732
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index dc2c5934c2a..ea7e0aa5266 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1249,12 +1249,9 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, 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_ostream &Out, const MDNode *Node, 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, |

