+ assert(BlobData == 0 &&
+ "Blob data specified for record that doesn't use it!");
+ }
+
+public:
+
+ /// EmitRecord - Emit the specified record to the stream, using an abbrev if
+ /// we have one to compress the output.
+ template<typename uintty>
+ void EmitRecord(unsigned Code, SmallVectorImpl<uintty> &Vals,
+ unsigned Abbrev = 0) {
+ if (!Abbrev) {
+ // If we don't have an abbrev to use, emit this in its fully unabbreviated
+ // form.
+ EmitCode(bitc::UNABBREV_RECORD);
+ EmitVBR(Code, 6);
+ EmitVBR(static_cast<uint32_t>(Vals.size()), 6);
+ for (unsigned i = 0, e = static_cast<unsigned>(Vals.size()); i != e; ++i)
+ EmitVBR64(Vals[i], 6);
+ return;
+ }
+
+ // Insert the code into Vals to treat it uniformly.
+ Vals.insert(Vals.begin(), Code);
+
+ EmitRecordWithAbbrev(Abbrev, Vals);
+ }
+
+ /// EmitRecordWithAbbrev - Emit a record with the specified abbreviation.
+ /// Unlike EmitRecord, the code for the record should be included in Vals as
+ /// the first entry.
+ template<typename uintty>
+ void EmitRecordWithAbbrev(unsigned Abbrev, SmallVectorImpl<uintty> &Vals) {
+ EmitRecordWithAbbrevImpl(Abbrev, Vals, 0, 0);
+ }
+
+ /// EmitRecordWithBlob - Emit the specified record to the stream, using an
+ /// abbrev that includes a blob at the end. The blob data to emit is
+ /// specified by the pointer and length specified at the end. In contrast to
+ /// EmitRecord, this routine expects that the first entry in Vals is the code
+ /// of the record.
+ template<typename uintty>
+ void EmitRecordWithBlob(unsigned Abbrev, SmallVectorImpl<uintty> &Vals,
+ const char *BlobData, unsigned BlobLen) {
+ EmitRecordWithAbbrevImpl(Abbrev, Vals, BlobData, BlobLen);