From c7363f1147f8d06c34683480b0cb7e24a395a534 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 13 Feb 2015 01:10:38 +0000 Subject: AsmWriter/Bitcode: MDSubrange llvm-svn: 229003 --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Bitcode/Writer') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 1c2424ce11b..3d1e82d8f8c 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -809,11 +809,23 @@ static void WriteGenericDebugNode(const GenericDebugNode *N, Record.clear(); } -static void WriteMDSubrange(const MDSubrange *, const ValueEnumerator &, - BitstreamWriter &, SmallVectorImpl &, - unsigned) { - llvm_unreachable("write not implemented"); +static uint64_t rotateSign(int64_t I) { + uint64_t U = I; + return I < 0 ? ~(U << 1) : U << 1; +} + +static void WriteMDSubrange(const MDSubrange *N, const ValueEnumerator &, + BitstreamWriter &Stream, + SmallVectorImpl &Record, + unsigned Abbrev) { + Record.push_back(N->isDistinct()); + Record.push_back(N->getCount()); + Record.push_back(rotateSign(N->getLo())); + + Stream.EmitRecord(bitc::METADATA_SUBRANGE, Record, Abbrev); + Record.clear(); } + static void WriteMDEnumerator(const MDEnumerator *, const ValueEnumerator &, BitstreamWriter &, SmallVectorImpl &, unsigned) { -- cgit v1.2.3