| Index: lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp
|
| diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp
|
| similarity index 88%
|
| copy from lib/Bitcode/Reader/BitstreamReader.cpp
|
| copy to lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp
|
| index 942346b44e32e8d85582929de55222b17d52c59f..ab8f1a5c6da8fc526dbc039b7fb38d13a98a3128 100644
|
| --- a/lib/Bitcode/Reader/BitstreamReader.cpp
|
| +++ b/lib/Bitcode/NaCl/Reader/NaClBitstreamReader.cpp
|
| @@ -1,4 +1,5 @@
|
| -//===- BitstreamReader.cpp - BitstreamReader implementation ---------------===//
|
| +//===- NaClBitstreamReader.cpp --------------------------------------------===//
|
| +// NaClBitstreamReader implementation
|
| //
|
| // The LLVM Compiler Infrastructure
|
| //
|
| @@ -7,15 +8,15 @@
|
| //
|
| //===----------------------------------------------------------------------===//
|
|
|
| -#include "llvm/Bitcode/BitstreamReader.h"
|
| +#include "llvm/Bitcode/NaCl/NaClBitstreamReader.h"
|
|
|
| using namespace llvm;
|
|
|
| //===----------------------------------------------------------------------===//
|
| -// BitstreamCursor implementation
|
| +// NaClBitstreamCursor implementation
|
| //===----------------------------------------------------------------------===//
|
|
|
| -void BitstreamCursor::operator=(const BitstreamCursor &RHS) {
|
| +void NaClBitstreamCursor::operator=(const NaClBitstreamCursor &RHS) {
|
| freeState();
|
|
|
| BitStream = RHS.BitStream;
|
| @@ -38,7 +39,7 @@ void BitstreamCursor::operator=(const BitstreamCursor &RHS) {
|
| }
|
| }
|
|
|
| -void BitstreamCursor::freeState() {
|
| +void NaClBitstreamCursor::freeState() {
|
| // Free all the Abbrevs.
|
| for (size_t i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
| CurAbbrevs[i]->dropRef();
|
| @@ -55,13 +56,13 @@ void BitstreamCursor::freeState() {
|
|
|
| /// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter
|
| /// the block, and return true if the block has an error.
|
| -bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
|
| +bool NaClBitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
|
| // Save the current block's state on BlockScope.
|
| BlockScope.push_back(Block(CurCodeSize));
|
| BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
|
|
|
| // Add the abbrevs specific to this block to the CurAbbrevs list.
|
| - if (const BitstreamReader::BlockInfo *Info =
|
| + if (const NaClBitstreamReader::BlockInfo *Info =
|
| BitStream->getBlockInfo(BlockID)) {
|
| for (size_t i = 0, e = Info->Abbrevs.size(); i != e; ++i) {
|
| CurAbbrevs.push_back(Info->Abbrevs[i]);
|
| @@ -82,15 +83,17 @@ bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
|
| return false;
|
| }
|
|
|
| -void BitstreamCursor::readAbbreviatedLiteral(const BitCodeAbbrevOp &Op,
|
| - SmallVectorImpl<uint64_t> &Vals) {
|
| +void NaClBitstreamCursor::readAbbreviatedLiteral(
|
| + const BitCodeAbbrevOp &Op,
|
| + SmallVectorImpl<uint64_t> &Vals) {
|
| assert(Op.isLiteral() && "Not a literal");
|
| // If the abbrev specifies the literal value to use, use it.
|
| Vals.push_back(Op.getLiteralValue());
|
| }
|
|
|
| -void BitstreamCursor::readAbbreviatedField(const BitCodeAbbrevOp &Op,
|
| - SmallVectorImpl<uint64_t> &Vals) {
|
| +void NaClBitstreamCursor::readAbbreviatedField(
|
| + const BitCodeAbbrevOp &Op,
|
| + SmallVectorImpl<uint64_t> &Vals) {
|
| assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!");
|
|
|
| // Decode the value as we are commanded.
|
| @@ -110,7 +113,7 @@ void BitstreamCursor::readAbbreviatedField(const BitCodeAbbrevOp &Op,
|
| }
|
| }
|
|
|
| -void BitstreamCursor::skipAbbreviatedField(const BitCodeAbbrevOp &Op) {
|
| +void NaClBitstreamCursor::skipAbbreviatedField(const BitCodeAbbrevOp &Op) {
|
| assert(!Op.isLiteral() && "Use ReadAbbreviatedLiteral for literals!");
|
|
|
| // Decode the value as we are commanded.
|
| @@ -133,7 +136,7 @@ void BitstreamCursor::skipAbbreviatedField(const BitCodeAbbrevOp &Op) {
|
|
|
|
|
| /// skipRecord - Read the current record and discard it.
|
| -void BitstreamCursor::skipRecord(unsigned AbbrevID) {
|
| +void NaClBitstreamCursor::skipRecord(unsigned AbbrevID) {
|
| // Skip unabbreviated records by reading past their entries.
|
| if (AbbrevID == bitc::UNABBREV_RECORD) {
|
| unsigned Code = ReadVBR(6);
|
| @@ -191,9 +194,9 @@ void BitstreamCursor::skipRecord(unsigned AbbrevID) {
|
| }
|
| }
|
|
|
| -unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
|
| - SmallVectorImpl<uint64_t> &Vals,
|
| - StringRef *Blob) {
|
| +unsigned NaClBitstreamCursor::readRecord(unsigned AbbrevID,
|
| + SmallVectorImpl<uint64_t> &Vals,
|
| + StringRef *Blob) {
|
| if (AbbrevID == bitc::UNABBREV_RECORD) {
|
| unsigned Code = ReadVBR(6);
|
| unsigned NumElts = ReadVBR(6);
|
| @@ -270,7 +273,7 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
|
| }
|
|
|
|
|
| -void BitstreamCursor::ReadAbbrevRecord() {
|
| +void NaClBitstreamCursor::ReadAbbrevRecord() {
|
| BitCodeAbbrev *Abbv = new BitCodeAbbrev();
|
| unsigned NumOpInfo = ReadVBR(5);
|
| for (unsigned i = 0; i != NumOpInfo; ++i) {
|
| @@ -300,7 +303,7 @@ void BitstreamCursor::ReadAbbrevRecord() {
|
| CurAbbrevs.push_back(Abbv);
|
| }
|
|
|
| -bool BitstreamCursor::ReadBlockInfoBlock() {
|
| +bool NaClBitstreamCursor::ReadBlockInfoBlock() {
|
| // If this is the second stream to get to the block info block, skip it.
|
| if (BitStream->hasBlockInfoRecords())
|
| return SkipBlock();
|
| @@ -308,19 +311,19 @@ bool BitstreamCursor::ReadBlockInfoBlock() {
|
| if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;
|
|
|
| SmallVector<uint64_t, 64> Record;
|
| - BitstreamReader::BlockInfo *CurBlockInfo = 0;
|
| + NaClBitstreamReader::BlockInfo *CurBlockInfo = 0;
|
|
|
| // Read all the records for this module.
|
| while (1) {
|
| - BitstreamEntry Entry = advanceSkippingSubblocks(AF_DontAutoprocessAbbrevs);
|
| + NaClBitstreamEntry Entry = advanceSkippingSubblocks(AF_DontAutoprocessAbbrevs);
|
|
|
| switch (Entry.Kind) {
|
| - case llvm::BitstreamEntry::SubBlock: // Handled for us already.
|
| - case llvm::BitstreamEntry::Error:
|
| + case llvm::NaClBitstreamEntry::SubBlock: // Handled for us already.
|
| + case llvm::NaClBitstreamEntry::Error:
|
| return true;
|
| - case llvm::BitstreamEntry::EndBlock:
|
| + case llvm::NaClBitstreamEntry::EndBlock:
|
| return false;
|
| - case llvm::BitstreamEntry::Record:
|
| + case llvm::NaClBitstreamEntry::Record:
|
| // The interesting case.
|
| break;
|
| }
|
| @@ -368,4 +371,3 @@ bool BitstreamCursor::ReadBlockInfoBlock() {
|
| }
|
| }
|
| }
|
| -
|
|
|