Index: include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h |
diff --git a/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h b/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h |
index 11443ebd8785632916e4a10d7ee034d9254d3124..26d9cb6b2486bc3d76c32f3a2b33d7ee633ac67e 100644 |
--- a/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h |
+++ b/include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h |
@@ -17,7 +17,7 @@ |
#include "llvm/ADT/SmallVector.h" |
#include "llvm/ADT/StringRef.h" |
-#include "llvm/Bitcode/BitCodes.h" |
+#include "llvm/Bitcode/NaCl/NaClBitCodes.h" |
#include <vector> |
namespace llvm { |
@@ -40,12 +40,12 @@ class NaClBitstreamWriter { |
unsigned BlockInfoCurBID; |
/// CurAbbrevs - Abbrevs installed at in this block. |
- std::vector<BitCodeAbbrev*> CurAbbrevs; |
+ std::vector<NaClBitCodeAbbrev*> CurAbbrevs; |
struct Block { |
unsigned PrevCodeSize; |
unsigned StartSizeWord; |
- std::vector<BitCodeAbbrev*> PrevAbbrevs; |
+ std::vector<NaClBitCodeAbbrev*> PrevAbbrevs; |
Block(unsigned PCS, unsigned SSW) : PrevCodeSize(PCS), StartSizeWord(SSW) {} |
}; |
@@ -56,7 +56,7 @@ class NaClBitstreamWriter { |
/// These describe abbreviations that all blocks of the specified ID inherit. |
struct BlockInfo { |
unsigned BlockID; |
- std::vector<BitCodeAbbrev*> Abbrevs; |
+ std::vector<NaClBitCodeAbbrev*> Abbrevs; |
}; |
std::vector<BlockInfo> BlockInfoRecords; |
@@ -210,16 +210,16 @@ public: |
void EnterSubblock(unsigned BlockID, unsigned CodeLen) { |
// Block header: |
// [ENTER_SUBBLOCK, blockid, newcodelen, <align4bytes>, blocklen] |
- EmitCode(bitc::ENTER_SUBBLOCK); |
- EmitVBR(BlockID, bitc::BlockIDWidth); |
- EmitVBR(CodeLen, bitc::CodeLenWidth); |
+ EmitCode(naclbitc::ENTER_SUBBLOCK); |
+ EmitVBR(BlockID, naclbitc::BlockIDWidth); |
+ EmitVBR(CodeLen, naclbitc::CodeLenWidth); |
FlushToWord(); |
unsigned BlockSizeWordIndex = GetWordIndex(); |
unsigned OldCodeSize = CurCodeSize; |
// Emit a placeholder, which will be replaced when the block is popped. |
- Emit(0, bitc::BlockSizeWidth); |
+ Emit(0, naclbitc::BlockSizeWidth); |
CurCodeSize = CodeLen; |
@@ -251,7 +251,7 @@ public: |
// Block tail: |
// [END_BLOCK, <align4bytes>] |
- EmitCode(bitc::END_BLOCK); |
+ EmitCode(naclbitc::END_BLOCK); |
FlushToWord(); |
// Compute the size of the block, in words, not counting the size field. |
@@ -275,7 +275,7 @@ private: |
/// EmitAbbreviatedLiteral - Emit a literal value according to its abbrev |
/// record. This is a no-op, since the abbrev specifies the literal to use. |
template<typename uintty> |
- void EmitAbbreviatedLiteral(const BitCodeAbbrevOp &Op, uintty V) { |
+ void EmitAbbreviatedLiteral(const NaClBitCodeAbbrevOp &Op, uintty V) { |
assert(Op.isLiteral() && "Not a literal"); |
// If the abbrev specifies the literal value to use, don't emit |
// anything. |
@@ -286,22 +286,22 @@ private: |
/// EmitAbbreviatedField - Emit a single scalar field value with the specified |
/// encoding. |
template<typename uintty> |
- void EmitAbbreviatedField(const BitCodeAbbrevOp &Op, uintty V) { |
+ void EmitAbbreviatedField(const NaClBitCodeAbbrevOp &Op, uintty V) { |
assert(!Op.isLiteral() && "Literals should use EmitAbbreviatedLiteral!"); |
// Encode the value as we are commanded. |
switch (Op.getEncoding()) { |
default: llvm_unreachable("Unknown encoding!"); |
- case BitCodeAbbrevOp::Fixed: |
+ case NaClBitCodeAbbrevOp::Fixed: |
if (Op.getEncodingData()) |
Emit((unsigned)V, (unsigned)Op.getEncodingData()); |
break; |
- case BitCodeAbbrevOp::VBR: |
+ case NaClBitCodeAbbrevOp::VBR: |
if (Op.getEncodingData()) |
EmitVBR64(V, (unsigned)Op.getEncodingData()); |
break; |
- case BitCodeAbbrevOp::Char6: |
- Emit(BitCodeAbbrevOp::EncodeChar6((char)V), 6); |
+ case NaClBitCodeAbbrevOp::Char6: |
+ Emit(NaClBitCodeAbbrevOp::EncodeChar6((char)V), 6); |
break; |
} |
} |
@@ -315,24 +315,24 @@ private: |
StringRef Blob) { |
const char *BlobData = Blob.data(); |
unsigned BlobLen = (unsigned) Blob.size(); |
- unsigned AbbrevNo = Abbrev-bitc::FIRST_APPLICATION_ABBREV; |
+ unsigned AbbrevNo = Abbrev-naclbitc::FIRST_APPLICATION_ABBREV; |
assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!"); |
- BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; |
+ NaClBitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo]; |
EmitCode(Abbrev); |
unsigned RecordIdx = 0; |
for (unsigned i = 0, e = static_cast<unsigned>(Abbv->getNumOperandInfos()); |
i != e; ++i) { |
- const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); |
+ const NaClBitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); |
if (Op.isLiteral()) { |
assert(RecordIdx < Vals.size() && "Invalid abbrev/record"); |
EmitAbbreviatedLiteral(Op, Vals[RecordIdx]); |
++RecordIdx; |
- } else if (Op.getEncoding() == BitCodeAbbrevOp::Array) { |
+ } else if (Op.getEncoding() == NaClBitCodeAbbrevOp::Array) { |
// Array case. |
assert(i+2 == e && "array op not second to last?"); |
- const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); |
+ const NaClBitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i); |
// If this record has blob data, emit it, otherwise we must have record |
// entries to encode this way. |
@@ -356,7 +356,7 @@ private: |
for (unsigned e = Vals.size(); RecordIdx != e; ++RecordIdx) |
EmitAbbreviatedField(EltEnc, Vals[RecordIdx]); |
} |
- } else if (Op.getEncoding() == BitCodeAbbrevOp::Blob) { |
+ } else if (Op.getEncoding() == NaClBitCodeAbbrevOp::Blob) { |
// If this record has blob data, emit it, otherwise we must have record |
// entries to encode this way. |
@@ -410,7 +410,7 @@ public: |
if (!Abbrev) { |
// If we don't have an abbrev to use, emit this in its fully unabbreviated |
// form. |
- EmitCode(bitc::UNABBREV_RECORD); |
+ EmitCode(naclbitc::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) |
@@ -468,12 +468,12 @@ public: |
private: |
// Emit the abbreviation as a DEFINE_ABBREV record. |
- void EncodeAbbrev(BitCodeAbbrev *Abbv) { |
- EmitCode(bitc::DEFINE_ABBREV); |
+ void EncodeAbbrev(NaClBitCodeAbbrev *Abbv) { |
+ EmitCode(naclbitc::DEFINE_ABBREV); |
EmitVBR(Abbv->getNumOperandInfos(), 5); |
for (unsigned i = 0, e = static_cast<unsigned>(Abbv->getNumOperandInfos()); |
i != e; ++i) { |
- const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); |
+ const NaClBitCodeAbbrevOp &Op = Abbv->getOperandInfo(i); |
Emit(Op.isLiteral(), 1); |
if (Op.isLiteral()) { |
EmitVBR64(Op.getLiteralValue(), 8); |
@@ -488,12 +488,12 @@ public: |
/// EmitAbbrev - This emits an abbreviation to the stream. Note that this |
/// method takes ownership of the specified abbrev. |
- unsigned EmitAbbrev(BitCodeAbbrev *Abbv) { |
+ unsigned EmitAbbrev(NaClBitCodeAbbrev *Abbv) { |
// Emit the abbreviation as a record. |
EncodeAbbrev(Abbv); |
CurAbbrevs.push_back(Abbv); |
return static_cast<unsigned>(CurAbbrevs.size())-1 + |
- bitc::FIRST_APPLICATION_ABBREV; |
+ naclbitc::FIRST_APPLICATION_ABBREV; |
} |
//===--------------------------------------------------------------------===// |
@@ -502,7 +502,7 @@ public: |
/// EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK. |
void EnterBlockInfoBlock(unsigned CodeWidth) { |
- EnterSubblock(bitc::BLOCKINFO_BLOCK_ID, CodeWidth); |
+ EnterSubblock(naclbitc::BLOCKINFO_BLOCK_ID, CodeWidth); |
BlockInfoCurBID = ~0U; |
} |
private: |
@@ -512,7 +512,7 @@ private: |
if (BlockInfoCurBID == BlockID) return; |
SmallVector<unsigned, 2> V; |
V.push_back(BlockID); |
- EmitRecord(bitc::BLOCKINFO_CODE_SETBID, V); |
+ EmitRecord(naclbitc::BLOCKINFO_CODE_SETBID, V); |
BlockInfoCurBID = BlockID; |
} |
@@ -530,7 +530,7 @@ public: |
/// EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified |
/// BlockID. |
- unsigned EmitBlockInfoAbbrev(unsigned BlockID, BitCodeAbbrev *Abbv) { |
+ unsigned EmitBlockInfoAbbrev(unsigned BlockID, NaClBitCodeAbbrev *Abbv) { |
SwitchToBlockID(BlockID); |
EncodeAbbrev(Abbv); |
@@ -538,7 +538,7 @@ public: |
BlockInfo &Info = getOrCreateBlockInfo(BlockID); |
Info.Abbrevs.push_back(Abbv); |
- return Info.Abbrevs.size()-1+bitc::FIRST_APPLICATION_ABBREV; |
+ return Info.Abbrevs.size()-1+naclbitc::FIRST_APPLICATION_ABBREV; |
} |
}; |