diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-20 01:03:09 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-20 01:03:09 +0000 |
commit | db6bc8bfdf1a8ae412667d9c96883545ddc02800 (patch) | |
tree | f392ba552c7cb48c4e1b809fabaa7a0272cdfebf /llvm/lib | |
parent | 6592deeab2661ae6328403936821889df9a5b93e (diff) | |
download | bcm5719-llvm-db6bc8bfdf1a8ae412667d9c96883545ddc02800.tar.gz bcm5719-llvm-db6bc8bfdf1a8ae412667d9c96883545ddc02800.zip |
Bitcode: Simplify MDNode subclass dispatch, NFC
llvm-svn: 226535
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 43af7aed99d..567e935cfa3 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -764,7 +764,7 @@ static void WriteValueAsMetadata(const ValueAsMetadata *MD, static void WriteMDTuple(const MDTuple *N, const ValueEnumerator &VE, BitstreamWriter &Stream, - SmallVectorImpl<uint64_t> &Record) { + SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { Metadata *MD = N->getOperand(i); assert(!(MD && isa<LocalAsMetadata>(MD)) && @@ -773,7 +773,7 @@ static void WriteMDTuple(const MDTuple *N, const ValueEnumerator &VE, } Stream.EmitRecord(N->isDistinct() ? bitc::METADATA_DISTINCT_NODE : bitc::METADATA_NODE, - Record); + Record, Abbrev); Record.clear(); } @@ -791,6 +791,12 @@ static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE, Record.clear(); } +static void WriteGenericDwarfNode(const GenericDwarfNode *, + const ValueEnumerator &, BitstreamWriter &, + SmallVectorImpl<uint64_t> &, unsigned) { + llvm_unreachable("unimplemented"); +} + static void WriteModuleMetadata(const Module *M, const ValueEnumerator &VE, BitstreamWriter &Stream) { @@ -810,7 +816,7 @@ static void WriteModuleMetadata(const Module *M, MDSAbbrev = Stream.EmitAbbrev(Abbv); } - unsigned LocAbbrev = 0; + unsigned MDLocationAbbrev = 0; if (VE.hasMDLocation()) { // Abbrev for METADATA_LOCATION. // @@ -823,7 +829,7 @@ static void WriteModuleMetadata(const Module *M, Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); - LocAbbrev = Stream.EmitAbbrev(Abbv); + MDLocationAbbrev = Stream.EmitAbbrev(Abbv); } unsigned NameAbbrev = 0; @@ -836,15 +842,20 @@ static void WriteModuleMetadata(const Module *M, NameAbbrev = Stream.EmitAbbrev(Abbv); } + unsigned MDTupleAbbrev = 0; + unsigned GenericDwarfNodeAbbrev = 0; SmallVector<uint64_t, 64> Record; for (const Metadata *MD : MDs) { - if (const MDLocation *Loc = dyn_cast<MDLocation>(MD)) { - WriteMDLocation(Loc, VE, Stream, Record, LocAbbrev); - continue; - } if (const MDNode *N = dyn_cast<MDNode>(MD)) { - WriteMDTuple(cast<MDTuple>(N), VE, Stream, Record); - continue; + switch (N->getMetadataID()) { + default: + llvm_unreachable("Invalid MDNode subclass"); +#define HANDLE_MDNODE_LEAF(CLASS) \ + case Metadata::CLASS##Kind: \ + Write##CLASS(cast<CLASS>(N), VE, Stream, Record, CLASS##Abbrev); \ + continue; +#include "llvm/IR/Metadata.def" + } } if (const auto *MDC = dyn_cast<ConstantAsMetadata>(MD)) { WriteValueAsMetadata(MDC, VE, Stream, Record); |