diff options
Diffstat (limited to 'lib/Bitcode')
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 4 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp | 96 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 266 |
3 files changed, 186 insertions, 180 deletions
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index 79b6ea6cca..5317e11a27 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -1525,7 +1525,7 @@ bool NaClBitcodeReader::ParseModule(bool Resume) { if (Stream.SkipBlock()) return Error("Malformed block record"); break; - case bitc::BLOCKINFO_BLOCK_ID: + case naclbitc::BLOCKINFO_BLOCK_ID: if (Stream.ReadBlockInfoBlock()) return Error("Malformed BlockInfoBlock"); break; @@ -1825,7 +1825,7 @@ bool NaClBitcodeReader::ParseBitcodeInto(Module *M) { case NaClBitstreamEntry::SubBlock: switch (Entry.ID) { - case bitc::BLOCKINFO_BLOCK_ID: + case naclbitc::BLOCKINFO_BLOCK_ID: if (Stream.ReadBlockInfoBlock()) return Error("Malformed BlockInfoBlock"); break; diff --git a/lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp index ab8f1a5c6d..677539071b 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp @@ -33,7 +33,7 @@ void NaClBitstreamCursor::operator=(const NaClBitstreamCursor &RHS) { // Copy block scope and bump ref counts. BlockScope = RHS.BlockScope; for (size_t S = 0, e = BlockScope.size(); S != e; ++S) { - std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs; + std::vector<NaClBitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs; for (size_t i = 0, e = Abbrevs.size(); i != e; ++i) Abbrevs[i]->addRef(); } @@ -47,7 +47,7 @@ void NaClBitstreamCursor::freeState() { // Free all the Abbrevs in the block scope. for (size_t S = 0, e = BlockScope.size(); S != e; ++S) { - std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs; + std::vector<NaClBitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs; for (size_t i = 0, e = Abbrevs.size(); i != e; ++i) Abbrevs[i]->dropRef(); } @@ -71,9 +71,9 @@ bool NaClBitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) { } // Get the codesize of this block. - CurCodeSize = ReadVBR(bitc::CodeLenWidth); + CurCodeSize = ReadVBR(naclbitc::CodeLenWidth); SkipToFourByteBoundary(); - unsigned NumWords = Read(bitc::BlockSizeWidth); + unsigned NumWords = Read(naclbitc::BlockSizeWidth); if (NumWordsP) *NumWordsP = NumWords; // Validate that this block is sane. @@ -84,7 +84,7 @@ bool NaClBitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) { } void NaClBitstreamCursor::readAbbreviatedLiteral( - const BitCodeAbbrevOp &Op, + const NaClBitCodeAbbrevOp &Op, SmallVectorImpl<uint64_t> &Vals) { assert(Op.isLiteral() && "Not a literal"); // If the abbrev specifies the literal value to use, use it. @@ -92,42 +92,42 @@ void NaClBitstreamCursor::readAbbreviatedLiteral( } void NaClBitstreamCursor::readAbbreviatedField( - const BitCodeAbbrevOp &Op, + const NaClBitCodeAbbrevOp &Op, SmallVectorImpl<uint64_t> &Vals) { assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!"); // Decode the value as we are commanded. switch (Op.getEncoding()) { - case BitCodeAbbrevOp::Array: - case BitCodeAbbrevOp::Blob: + case NaClBitCodeAbbrevOp::Array: + case NaClBitCodeAbbrevOp::Blob: assert(0 && "Should not reach here"); - case BitCodeAbbrevOp::Fixed: + case NaClBitCodeAbbrevOp::Fixed: Vals.push_back(Read((unsigned)Op.getEncodingData())); break; - case BitCodeAbbrevOp::VBR: + case NaClBitCodeAbbrevOp::VBR: Vals.push_back(ReadVBR64((unsigned)Op.getEncodingData())); break; - case BitCodeAbbrevOp::Char6: - Vals.push_back(BitCodeAbbrevOp::DecodeChar6(Read(6))); + case NaClBitCodeAbbrevOp::Char6: + Vals.push_back(NaClBitCodeAbbrevOp::DecodeChar6(Read(6))); break; } } -void NaClBitstreamCursor::skipAbbreviatedField(const BitCodeAbbrevOp &Op) { +void NaClBitstreamCursor::skipAbbreviatedField(const NaClBitCodeAbbrevOp &Op) { assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!"); // Decode the value as we are commanded. switch (Op.getEncoding()) { - case BitCodeAbbrevOp::Array: - case BitCodeAbbrevOp::Blob: + case NaClBitCodeAbbrevOp::Array: + case NaClBitCodeAbbrevOp::Blob: assert(0 && "Should not reach here"); - case BitCodeAbbrevOp::Fixed: + case NaClBitCodeAbbrevOp::Fixed: (void)Read((unsigned)Op.getEncodingData()); break; - case BitCodeAbbrevOp::VBR: + case NaClBitCodeAbbrevOp::VBR: (void)ReadVBR64((unsigned)Op.getEncodingData()); break; - case BitCodeAbbrevOp::Char6: + case NaClBitCodeAbbrevOp::Char6: (void)Read(6); break; } @@ -138,7 +138,7 @@ void NaClBitstreamCursor::skipAbbreviatedField(const BitCodeAbbrevOp &Op) { /// skipRecord - Read the current record and discard it. void NaClBitstreamCursor::skipRecord(unsigned AbbrevID) { // Skip unabbreviated records by reading past their entries. - if (AbbrevID == bitc::UNABBREV_RECORD) { + if (AbbrevID == naclbitc::UNABBREV_RECORD) { unsigned Code = ReadVBR(6); (void)Code; unsigned NumElts = ReadVBR(6); @@ -147,26 +147,26 @@ void NaClBitstreamCursor::skipRecord(unsigned AbbrevID) { return; } - const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID); + const NaClBitCodeAbbrev *Abbv = getAbbrev(AbbrevID); for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { - const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); + const NaClBitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral()) continue; - if (Op.getEncoding() != BitCodeAbbrevOp::Array && - Op.getEncoding() != BitCodeAbbrevOp::Blob) { + if (Op.getEncoding() != NaClBitCodeAbbrevOp::Array && + Op.getEncoding() != NaClBitCodeAbbrevOp::Blob) { skipAbbreviatedField(Op); continue; } - if (Op.getEncoding() == BitCodeAbbrevOp::Array) { + if (Op.getEncoding() == NaClBitCodeAbbrevOp::Array) { // Array case. Read the number of elements as a vbr6. unsigned NumElts = ReadVBR(6); // Get the element encoding. assert(i+2 == e && "array op not second to last?"); - const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); + const NaClBitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); // Read all the elements. for (; NumElts; --NumElts) @@ -174,7 +174,7 @@ void NaClBitstreamCursor::skipRecord(unsigned AbbrevID) { continue; } - assert(Op.getEncoding() == BitCodeAbbrevOp::Blob); + assert(Op.getEncoding() == NaClBitCodeAbbrevOp::Blob); // Blob case. Read the number of bytes as a vbr6. unsigned NumElts = ReadVBR(6); SkipToFourByteBoundary(); // 32-bit alignment @@ -197,7 +197,7 @@ void NaClBitstreamCursor::skipRecord(unsigned AbbrevID) { unsigned NaClBitstreamCursor::readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals, StringRef *Blob) { - if (AbbrevID == bitc::UNABBREV_RECORD) { + if (AbbrevID == naclbitc::UNABBREV_RECORD) { unsigned Code = ReadVBR(6); unsigned NumElts = ReadVBR(6); for (unsigned i = 0; i != NumElts; ++i) @@ -205,28 +205,28 @@ unsigned NaClBitstreamCursor::readRecord(unsigned AbbrevID, return Code; } - const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID); + const NaClBitCodeAbbrev *Abbv = getAbbrev(AbbrevID); for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) { - const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); + const NaClBitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); if (Op.isLiteral()) { readAbbreviatedLiteral(Op, Vals); continue; } - if (Op.getEncoding() != BitCodeAbbrevOp::Array && - Op.getEncoding() != BitCodeAbbrevOp::Blob) { + if (Op.getEncoding() != NaClBitCodeAbbrevOp::Array && + Op.getEncoding() != NaClBitCodeAbbrevOp::Blob) { readAbbreviatedField(Op, Vals); continue; } - if (Op.getEncoding() == BitCodeAbbrevOp::Array) { + if (Op.getEncoding() == NaClBitCodeAbbrevOp::Array) { // Array case. Read the number of elements as a vbr6. unsigned NumElts = ReadVBR(6); // Get the element encoding. assert(i+2 == e && "array op not second to last?"); - const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); + const NaClBitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); // Read all the elements. for (; NumElts; --NumElts) @@ -234,7 +234,7 @@ unsigned NaClBitstreamCursor::readRecord(unsigned AbbrevID, continue; } - assert(Op.getEncoding() == BitCodeAbbrevOp::Blob); + assert(Op.getEncoding() == NaClBitCodeAbbrevOp::Blob); // Blob case. Read the number of bytes as a vbr6. unsigned NumElts = ReadVBR(6); SkipToFourByteBoundary(); // 32-bit alignment @@ -274,31 +274,31 @@ unsigned NaClBitstreamCursor::readRecord(unsigned AbbrevID, void NaClBitstreamCursor::ReadAbbrevRecord() { - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); unsigned NumOpInfo = ReadVBR(5); for (unsigned i = 0; i != NumOpInfo; ++i) { bool IsLiteral = Read(1) ? true : false; if (IsLiteral) { - Abbv->Add(BitCodeAbbrevOp(ReadVBR64(8))); + Abbv->Add(NaClBitCodeAbbrevOp(ReadVBR64(8))); continue; } - BitCodeAbbrevOp::Encoding E = (BitCodeAbbrevOp::Encoding)Read(3); - if (BitCodeAbbrevOp::hasEncodingData(E)) { + NaClBitCodeAbbrevOp::Encoding E = (NaClBitCodeAbbrevOp::Encoding)Read(3); + if (NaClBitCodeAbbrevOp::hasEncodingData(E)) { unsigned Data = ReadVBR64(5); // As a special case, handle fixed(0) (i.e., a fixed field with zero bits) // and vbr(0) as a literal zero. This is decoded the same way, and avoids // a slow path in Read() to have to handle reading zero bits. - if ((E == BitCodeAbbrevOp::Fixed || E == BitCodeAbbrevOp::VBR) && + if ((E == NaClBitCodeAbbrevOp::Fixed || E == NaClBitCodeAbbrevOp::VBR) && Data == 0) { - Abbv->Add(BitCodeAbbrevOp(0)); + Abbv->Add(NaClBitCodeAbbrevOp(0)); continue; } - Abbv->Add(BitCodeAbbrevOp(E, Data)); + Abbv->Add(NaClBitCodeAbbrevOp(E, Data)); } else - Abbv->Add(BitCodeAbbrevOp(E)); + Abbv->Add(NaClBitCodeAbbrevOp(E)); } CurAbbrevs.push_back(Abbv); } @@ -308,7 +308,7 @@ bool NaClBitstreamCursor::ReadBlockInfoBlock() { if (BitStream->hasBlockInfoRecords()) return SkipBlock(); - if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true; + if (EnterSubBlock(naclbitc::BLOCKINFO_BLOCK_ID)) return true; SmallVector<uint64_t, 64> Record; NaClBitstreamReader::BlockInfo *CurBlockInfo = 0; @@ -329,13 +329,13 @@ bool NaClBitstreamCursor::ReadBlockInfoBlock() { } // Read abbrev records, associate them with CurBID. - if (Entry.ID == bitc::DEFINE_ABBREV) { + if (Entry.ID == naclbitc::DEFINE_ABBREV) { if (!CurBlockInfo) return true; ReadAbbrevRecord(); // ReadAbbrevRecord installs the abbrev in CurAbbrevs. Move it to the // appropriate BlockInfo. - BitCodeAbbrev *Abbv = CurAbbrevs.back(); + NaClBitCodeAbbrev *Abbv = CurAbbrevs.back(); CurAbbrevs.pop_back(); CurBlockInfo->Abbrevs.push_back(Abbv); continue; @@ -345,11 +345,11 @@ bool NaClBitstreamCursor::ReadBlockInfoBlock() { Record.clear(); switch (readRecord(Entry.ID, Record)) { default: break; // Default behavior, ignore unknown content. - case bitc::BLOCKINFO_CODE_SETBID: + case naclbitc::BLOCKINFO_CODE_SETBID: if (Record.size() < 1) return true; CurBlockInfo = &BitStream->getOrCreateBlockInfo((unsigned)Record[0]); break; - case bitc::BLOCKINFO_CODE_BLOCKNAME: { + case naclbitc::BLOCKINFO_CODE_BLOCKNAME: { if (!CurBlockInfo) return true; if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name. std::string Name; @@ -358,7 +358,7 @@ bool NaClBitstreamCursor::ReadBlockInfoBlock() { CurBlockInfo->Name = Name; break; } - case bitc::BLOCKINFO_CODE_SETRECORDNAME: { + case naclbitc::BLOCKINFO_CODE_SETRECORDNAME: { if (!CurBlockInfo) return true; if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name. std::string Name; diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp index edaaadf681..1d7d8dc23c 100644 --- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp @@ -36,19 +36,19 @@ using namespace llvm; /// be kept in sync with the reader, but need to be consistent within this file. enum { // VALUE_SYMTAB_BLOCK abbrev id's. - VST_ENTRY_8_ABBREV = bitc::FIRST_APPLICATION_ABBREV, + VST_ENTRY_8_ABBREV = naclbitc::FIRST_APPLICATION_ABBREV, VST_ENTRY_7_ABBREV, VST_ENTRY_6_ABBREV, VST_BBENTRY_6_ABBREV, // CONSTANTS_BLOCK abbrev id's. - CONSTANTS_SETTYPE_ABBREV = bitc::FIRST_APPLICATION_ABBREV, + CONSTANTS_SETTYPE_ABBREV = naclbitc::FIRST_APPLICATION_ABBREV, CONSTANTS_INTEGER_ABBREV, CONSTANTS_CE_CAST_Abbrev, CONSTANTS_NULL_Abbrev, // FUNCTION_BLOCK abbrev id's. - FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV, + FUNCTION_INST_LOAD_ABBREV = naclbitc::FIRST_APPLICATION_ABBREV, FUNCTION_INST_BINOP_ABBREV, FUNCTION_INST_BINOP_FLAGS_ABBREV, FUNCTION_INST_CAST_ABBREV, @@ -141,12 +141,13 @@ static unsigned GetEncodedSynchScope(SynchronizationScope SynchScope) { } static void WriteStringRecord(unsigned Code, StringRef Str, - unsigned AbbrevToUse, NaClBitstreamWriter &Stream) { + unsigned AbbrevToUse, + NaClBitstreamWriter &Stream) { SmallVector<unsigned, 64> Vals; // Code: [strchar x N] for (unsigned i = 0, e = Str.size(); i != e; ++i) { - if (AbbrevToUse && !BitCodeAbbrevOp::isChar6(Str[i])) + if (AbbrevToUse && !NaClBitCodeAbbrevOp::isChar6(Str[i])) AbbrevToUse = 0; Vals.push_back(Str[i]); } @@ -228,57 +229,58 @@ static void WriteTypeTable(const NaClValueEnumerator &VE, NaClBitstreamWriter &Stream) { const NaClValueEnumerator::TypeList &TypeList = VE.getTypes(); - Stream.EnterSubblock(naclbitc::TYPE_BLOCK_ID_NEW, 4 /*count from # abbrevs */); + Stream.EnterSubblock(naclbitc::TYPE_BLOCK_ID_NEW, + 4 /*count from # abbrevs */); SmallVector<uint64_t, 64> TypeVals; uint64_t NumBits = Log2_32_Ceil(VE.getTypes().size()+1); // Abbrev for TYPE_CODE_POINTER. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::TYPE_CODE_POINTER)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits)); - Abbv->Add(BitCodeAbbrevOp(0)); // Addrspace = 0 + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_POINTER)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, NumBits)); + Abbv->Add(NaClBitCodeAbbrevOp(0)); // Addrspace = 0 unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv); // Abbrev for TYPE_CODE_FUNCTION. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::TYPE_CODE_FUNCTION)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_FUNCTION)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // isvararg + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, NumBits)); unsigned FunctionAbbrev = Stream.EmitAbbrev(Abbv); // Abbrev for TYPE_CODE_STRUCT_ANON. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_ANON)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_ANON)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // ispacked + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, NumBits)); unsigned StructAnonAbbrev = Stream.EmitAbbrev(Abbv); // Abbrev for TYPE_CODE_STRUCT_NAME. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_NAME)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_NAME)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Char6)); unsigned StructNameAbbrev = Stream.EmitAbbrev(Abbv); // Abbrev for TYPE_CODE_STRUCT_NAMED. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_NAMED)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ispacked - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_STRUCT_NAMED)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // ispacked + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, NumBits)); unsigned StructNamedAbbrev = Stream.EmitAbbrev(Abbv); // Abbrev for TYPE_CODE_ARRAY. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::TYPE_CODE_ARRAY)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // size - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, NumBits)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::TYPE_CODE_ARRAY)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 8)); // size + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, NumBits)); unsigned ArrayAbbrev = Stream.EmitAbbrev(Abbv); @@ -488,24 +490,24 @@ static void WriteModuleInfo(const Module *M, const NaClValueEnumerator &VE, unsigned SimpleGVarAbbrev = 0; if (!M->global_empty()) { // Add an abbrev for common globals with no visibility or thread localness. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::MODULE_CODE_GLOBALVAR)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::MODULE_CODE_GLOBALVAR)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, Log2_32_Ceil(MaxGlobalType+1))); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constant. - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Initializer. - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // Linkage. - if (MaxAlignment == 0) // Alignment. - Abbv->Add(BitCodeAbbrevOp(0)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // Constant. + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // Initializer. + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 4)); // Linkage. + if (MaxAlignment == 0) // Alignment. + Abbv->Add(NaClBitCodeAbbrevOp(0)); else { unsigned MaxEncAlignment = Log2_32(MaxAlignment)+1; - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, Log2_32_Ceil(MaxEncAlignment+1))); } if (SectionMap.empty()) // Section. - Abbv->Add(BitCodeAbbrevOp(0)); + Abbv->Add(NaClBitCodeAbbrevOp(0)); else - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, Log2_32_Ceil(SectionMap.size()+1))); // Don't bother emitting vis + thread local. SimpleGVarAbbrev = Stream.EmitAbbrev(Abbv); @@ -647,10 +649,10 @@ static void WriteModuleMetadata(const Module *M, Stream.EnterSubblock(naclbitc::METADATA_BLOCK_ID, 3); // Abbrev for METADATA_STRING. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::METADATA_STRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::METADATA_STRING)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 8)); MDSAbbrev = Stream.EmitAbbrev(Abbv); StartedMetadataBlock = true; } @@ -744,7 +746,8 @@ static void WriteMetadataAttachment(const Function &F, Stream.ExitBlock(); } -static void WriteModuleMetadataStore(const Module *M, NaClBitstreamWriter &Stream) { +static void WriteModuleMetadataStore(const Module *M, + NaClBitstreamWriter &Stream) { SmallVector<uint64_t, 64> Record; // Write metadata kinds @@ -817,29 +820,30 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, // If this is a constant pool for the module, emit module-specific abbrevs. if (isGlobal) { // Abbrev for CST_CODE_AGGREGATE. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_AGGREGATE)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, Log2_32_Ceil(LastVal+1))); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_AGGREGATE)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, + Log2_32_Ceil(LastVal+1))); AggregateAbbrev = Stream.EmitAbbrev(Abbv); // Abbrev for CST_CODE_STRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_STRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_STRING)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 8)); String8Abbrev = Stream.EmitAbbrev(Abbv); // Abbrev for CST_CODE_CSTRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_CSTRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_CSTRING)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 7)); CString7Abbrev = Stream.EmitAbbrev(Abbv); // Abbrev for CST_CODE_CSTRING. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_CSTRING)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); + Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_CSTRING)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Char6)); CString6Abbrev = Stream.EmitAbbrev(Abbv); } @@ -927,7 +931,7 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, Record.push_back(V); isCStr7 &= (V & 128) == 0; if (isCStrChar6) - isCStrChar6 = BitCodeAbbrevOp::isChar6(V); + isCStrChar6 = NaClBitCodeAbbrevOp::isChar6(V); } if (isCStrChar6) @@ -1111,7 +1115,8 @@ static void pushValueSigned(const Value *V, unsigned InstID, /// WriteInstruction - Emit an instruction to the specified stream. static void WriteInstruction(const Instruction &I, unsigned InstID, - NaClValueEnumerator &VE, NaClBitstreamWriter &Stream, + NaClValueEnumerator &VE, + NaClBitstreamWriter &Stream, SmallVector<unsigned, 64> &Vals) { unsigned Code = 0; unsigned AbbrevToUse = 0; @@ -1488,7 +1493,7 @@ static void WriteValueSymbolTable(const ValueSymbolTable &VST, for (const char *C = Name.getKeyData(), *E = C+Name.getKeyLength(); C != E; ++C) { if (isChar6) - isChar6 = BitCodeAbbrevOp::isChar6(*C); + isChar6 = NaClBitCodeAbbrevOp::isChar6(*C); if ((unsigned char)*C & 128) { is7Bit = false; break; // don't bother scanning the rest. @@ -1597,49 +1602,50 @@ static void WriteFunction(const Function &F, NaClValueEnumerator &VE, } // Emit blockinfo, which defines the standard abbreviations etc. -static void WriteBlockInfo(const NaClValueEnumerator &VE, NaClBitstreamWriter &Stream) { +static void WriteBlockInfo(const NaClValueEnumerator &VE, + NaClBitstreamWriter &Stream) { // We only want to emit block info records for blocks that have multiple // instances: CONSTANTS_BLOCK, FUNCTION_BLOCK and VALUE_SYMTAB_BLOCK. // Other blocks can define their abbrevs inline. Stream.EnterBlockInfoBlock(2); { // 8-bit fixed-width VST_ENTRY/VST_BBENTRY strings. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 3)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 8)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 8)); if (Stream.EmitBlockInfoAbbrev(naclbitc::VALUE_SYMTAB_BLOCK_ID, Abbv) != VST_ENTRY_8_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // 7-bit fixed width VST_ENTRY strings. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::VST_CODE_ENTRY)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::VST_CODE_ENTRY)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 8)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 7)); if (Stream.EmitBlockInfoAbbrev(naclbitc::VALUE_SYMTAB_BLOCK_ID, Abbv) != VST_ENTRY_7_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // 6-bit char6 VST_ENTRY strings. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::VST_CODE_ENTRY)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::VST_CODE_ENTRY)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 8)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Char6)); if (Stream.EmitBlockInfoAbbrev(naclbitc::VALUE_SYMTAB_BLOCK_ID, Abbv) != VST_ENTRY_6_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // 6-bit char6 VST_BBENTRY strings. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::VST_CODE_BBENTRY)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::VST_CODE_BBENTRY)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 8)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Array)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Char6)); if (Stream.EmitBlockInfoAbbrev(naclbitc::VALUE_SYMTAB_BLOCK_ID, Abbv) != VST_BBENTRY_6_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); @@ -1648,9 +1654,9 @@ static void WriteBlockInfo(const NaClValueEnumerator &VE, NaClBitstreamWriter &S { // SETTYPE abbrev for CONSTANTS_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_SETTYPE)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_SETTYPE)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, Log2_32_Ceil(VE.getTypes().size()+1))); if (Stream.EmitBlockInfoAbbrev(naclbitc::CONSTANTS_BLOCK_ID, Abbv) != CONSTANTS_SETTYPE_ABBREV) @@ -1658,29 +1664,29 @@ static void WriteBlockInfo(const NaClValueEnumerator &VE, NaClBitstreamWriter &S } { // INTEGER abbrev for CONSTANTS_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_INTEGER)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_INTEGER)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 8)); if (Stream.EmitBlockInfoAbbrev(naclbitc::CONSTANTS_BLOCK_ID, Abbv) != CONSTANTS_INTEGER_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // CE_CAST abbrev for CONSTANTS_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_CE_CAST)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // cast opc - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // typeid + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_CE_CAST)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 4)); // cast opc + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, // typeid Log2_32_Ceil(VE.getTypes().size()+1))); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // value id + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 8)); // value id if (Stream.EmitBlockInfoAbbrev(naclbitc::CONSTANTS_BLOCK_ID, Abbv) != CONSTANTS_CE_CAST_Abbrev) llvm_unreachable("Unexpected abbrev ordering!"); } { // NULL abbrev for CONSTANTS_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::CST_CODE_NULL)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::CST_CODE_NULL)); if (Stream.EmitBlockInfoAbbrev(naclbitc::CONSTANTS_BLOCK_ID, Abbv) != CONSTANTS_NULL_Abbrev) llvm_unreachable("Unexpected abbrev ordering!"); @@ -1689,66 +1695,66 @@ static void WriteBlockInfo(const NaClValueEnumerator &VE, NaClBitstreamWriter &S // FIXME: This should only use space for first class types! { // INST_LOAD abbrev for FUNCTION_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_LOAD)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Ptr - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Align - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // volatile + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_LOAD)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // Ptr + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 4)); // Align + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 1)); // volatile if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_LOAD_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // INST_BINOP abbrev for FUNCTION_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_BINOP)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_BINOP)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // LHS + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // RHS + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 4)); // opc if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_BINOP_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // INST_BINOP_FLAGS abbrev for FUNCTION_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_BINOP)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); // flags + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_BINOP)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // LHS + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // RHS + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 4)); // opc + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 7)); // flags if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_BINOP_FLAGS_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // INST_CAST abbrev for FUNCTION_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_CAST)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpVal - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_CAST)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // OpVal + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, // dest ty Log2_32_Ceil(VE.getTypes().size()+1))); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::Fixed, 4)); // opc if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_CAST_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // INST_RET abbrev for FUNCTION_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_RET)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_RET)); if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_RET_VOID_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // INST_RET abbrev for FUNCTION_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_RET)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ValID + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_RET)); + Abbv->Add(NaClBitCodeAbbrevOp(NaClBitCodeAbbrevOp::VBR, 6)); // ValID if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_RET_VAL_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } { // INST_UNREACHABLE abbrev for FUNCTION_BLOCK. - BitCodeAbbrev *Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_UNREACHABLE)); + NaClBitCodeAbbrev *Abbv = new NaClBitCodeAbbrev(); + Abbv->Add(NaClBitCodeAbbrevOp(naclbitc::FUNC_CODE_INST_UNREACHABLE)); if (Stream.EmitBlockInfoAbbrev(naclbitc::FUNCTION_BLOCK_ID, Abbv) != FUNCTION_INST_UNREACHABLE_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); |