| Index: include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
|
| diff --git a/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h b/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
|
| index 58c0a5d7fa355db91828922fbf45fccab9afcfcd..0d14b411171bb6b62acd13c820d8bb2efab21502 100644
|
| --- a/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
|
| +++ b/include/llvm/Bitcode/NaCl/NaClBitstreamReader.h
|
| @@ -171,7 +171,6 @@ class NaClBitstreamCursor {
|
| NaClBitstreamReader *BitStream;
|
| size_t NextChar;
|
|
|
| -
|
| /// CurWord/word_t - This is the current data we have pulled from the stream
|
| /// but have not returned to the client. This is specifically and
|
| /// intentionally defined to follow the word size of the host machine for
|
| @@ -186,21 +185,22 @@ class NaClBitstreamCursor {
|
|
|
| // CurCodeSize - This is the declared size of code values used for the current
|
| // block, in bits.
|
| - unsigned CurCodeSize;
|
| + NaClBitcodeSelectorAbbrev CurCodeSize;
|
|
|
| /// CurAbbrevs - Abbrevs installed at in this block.
|
| std::vector<NaClBitCodeAbbrev*> CurAbbrevs;
|
|
|
| struct Block {
|
| - unsigned PrevCodeSize;
|
| + NaClBitcodeSelectorAbbrev PrevCodeSize;
|
| std::vector<NaClBitCodeAbbrev*> PrevAbbrevs;
|
| - explicit Block(unsigned PCS) : PrevCodeSize(PCS) {}
|
| + explicit Block() : PrevCodeSize() {}
|
| + explicit Block(const NaClBitcodeSelectorAbbrev& PCS)
|
| + : PrevCodeSize(PCS) {}
|
| };
|
|
|
| /// BlockScope - This tracks the codesize of parent blocks.
|
| SmallVector<Block, 8> BlockScope;
|
|
|
| -
|
| public:
|
| NaClBitstreamCursor() : BitStream(0), NextChar(0) {
|
| }
|
| @@ -213,7 +213,6 @@ public:
|
| NextChar = 0;
|
| CurWord = 0;
|
| BitsInCurWord = 0;
|
| - CurCodeSize = 2;
|
| }
|
|
|
| void init(NaClBitstreamReader &R) {
|
| @@ -223,7 +222,6 @@ public:
|
| NextChar = 0;
|
| CurWord = 0;
|
| BitsInCurWord = 0;
|
| - CurCodeSize = 2;
|
| }
|
|
|
| ~NaClBitstreamCursor() {
|
| @@ -255,7 +253,7 @@ public:
|
| }
|
|
|
| /// getAbbrevIDWidth - Return the number of bits used to encode an abbrev #.
|
| - unsigned getAbbrevIDWidth() const { return CurCodeSize; }
|
| + unsigned getAbbrevIDWidth() const { return CurCodeSize.NumBits; }
|
|
|
| /// GetCurrentBitNo - Return the bit # of the bit we are reading.
|
| uint64_t GetCurrentBitNo() const {
|
| @@ -343,7 +341,6 @@ public:
|
| }
|
| }
|
|
|
| -
|
| uint32_t Read(unsigned NumBits) {
|
| assert(NumBits && NumBits <= 32 &&
|
| "Cannot return zero or more than 32 bits!");
|
| @@ -397,6 +394,10 @@ public:
|
| return R;
|
| }
|
|
|
| + bool ReadBool() {
|
| + return Read(1);
|
| + }
|
| +
|
| uint64_t Read64(unsigned NumBits) {
|
| if (NumBits <= 32) return Read(NumBits);
|
|
|
| @@ -442,6 +443,10 @@ public:
|
| }
|
| }
|
|
|
| + int32_t ReadIntVBR(unsigned NumBits) {
|
| + return (uint32_t) NaClDecodeSignRotatedValue(ReadVBR64(NumBits));
|
| + }
|
| +
|
| private:
|
| void SkipToFourByteBoundary() {
|
| // If word_t is 64-bits and if we've read less than 32 bits, just dump
|
| @@ -459,10 +464,11 @@ private:
|
| public:
|
|
|
| unsigned ReadCode() {
|
| - return Read(CurCodeSize);
|
| + return CurCodeSize.IsFixed
|
| + ? Read(CurCodeSize.NumBits)
|
| + : ReadVBR(CurCodeSize.NumBits);
|
| }
|
|
|
| -
|
| // Block header:
|
| // [ENTER_SUBBLOCK, blockid, newcodelen, <align4bytes>, blocklen]
|
|
|
|
|