Index: lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
similarity index 84% |
copy from lib/Bitcode/Reader/BitcodeReader.cpp |
copy to lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
index 5878b47376bf93c0cf82e6b09ef7ff356a669c99..79b6ea6cca60163ff85f1b738b00d147c1dc78df 100644 |
--- a/lib/Bitcode/Reader/BitcodeReader.cpp |
+++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
@@ -1,4 +1,5 @@ |
-//===- BitcodeReader.cpp - Internal BitcodeReader implementation ----------===// |
+//===- NaClBitcodeReader.cpp ----------------------------------------------===// |
+// Internal NaClBitcodeReader implementation |
// |
// The LLVM Compiler Infrastructure |
// |
@@ -7,8 +8,8 @@ |
// |
//===----------------------------------------------------------------------===// |
-#include "llvm/Bitcode/ReaderWriter.h" |
-#include "BitcodeReader.h" |
+#include "llvm/Bitcode/NaCl/NaClReaderWriter.h" |
+#include "NaClBitcodeReader.h" |
#include "llvm/ADT/SmallString.h" |
#include "llvm/ADT/SmallVector.h" |
#include "llvm/AutoUpgrade.h" |
@@ -28,14 +29,14 @@ enum { |
SWITCH_INST_MAGIC = 0x4B5 // May 2012 => 1205 => Hex |
}; |
-void BitcodeReader::materializeForwardReferencedFunctions() { |
+void NaClBitcodeReader::materializeForwardReferencedFunctions() { |
while (!BlockAddrFwdRefs.empty()) { |
Function *F = BlockAddrFwdRefs.begin()->first; |
F->Materialize(); |
} |
} |
-void BitcodeReader::FreeState() { |
+void NaClBitcodeReader::FreeState() { |
if (BufferOwned) |
delete Buffer; |
Buffer = 0; |
@@ -114,79 +115,79 @@ static GlobalVariable::ThreadLocalMode GetDecodedThreadLocalMode(unsigned Val) { |
static int GetDecodedCastOpcode(unsigned Val) { |
switch (Val) { |
default: return -1; |
- case bitc::CAST_TRUNC : return Instruction::Trunc; |
- case bitc::CAST_ZEXT : return Instruction::ZExt; |
- case bitc::CAST_SEXT : return Instruction::SExt; |
- case bitc::CAST_FPTOUI : return Instruction::FPToUI; |
- case bitc::CAST_FPTOSI : return Instruction::FPToSI; |
- case bitc::CAST_UITOFP : return Instruction::UIToFP; |
- case bitc::CAST_SITOFP : return Instruction::SIToFP; |
- case bitc::CAST_FPTRUNC : return Instruction::FPTrunc; |
- case bitc::CAST_FPEXT : return Instruction::FPExt; |
- case bitc::CAST_PTRTOINT: return Instruction::PtrToInt; |
- case bitc::CAST_INTTOPTR: return Instruction::IntToPtr; |
- case bitc::CAST_BITCAST : return Instruction::BitCast; |
+ case naclbitc::CAST_TRUNC : return Instruction::Trunc; |
+ case naclbitc::CAST_ZEXT : return Instruction::ZExt; |
+ case naclbitc::CAST_SEXT : return Instruction::SExt; |
+ case naclbitc::CAST_FPTOUI : return Instruction::FPToUI; |
+ case naclbitc::CAST_FPTOSI : return Instruction::FPToSI; |
+ case naclbitc::CAST_UITOFP : return Instruction::UIToFP; |
+ case naclbitc::CAST_SITOFP : return Instruction::SIToFP; |
+ case naclbitc::CAST_FPTRUNC : return Instruction::FPTrunc; |
+ case naclbitc::CAST_FPEXT : return Instruction::FPExt; |
+ case naclbitc::CAST_PTRTOINT: return Instruction::PtrToInt; |
+ case naclbitc::CAST_INTTOPTR: return Instruction::IntToPtr; |
+ case naclbitc::CAST_BITCAST : return Instruction::BitCast; |
} |
} |
static int GetDecodedBinaryOpcode(unsigned Val, Type *Ty) { |
switch (Val) { |
default: return -1; |
- case bitc::BINOP_ADD: |
+ case naclbitc::BINOP_ADD: |
return Ty->isFPOrFPVectorTy() ? Instruction::FAdd : Instruction::Add; |
- case bitc::BINOP_SUB: |
+ case naclbitc::BINOP_SUB: |
return Ty->isFPOrFPVectorTy() ? Instruction::FSub : Instruction::Sub; |
- case bitc::BINOP_MUL: |
+ case naclbitc::BINOP_MUL: |
return Ty->isFPOrFPVectorTy() ? Instruction::FMul : Instruction::Mul; |
- case bitc::BINOP_UDIV: return Instruction::UDiv; |
- case bitc::BINOP_SDIV: |
+ case naclbitc::BINOP_UDIV: return Instruction::UDiv; |
+ case naclbitc::BINOP_SDIV: |
return Ty->isFPOrFPVectorTy() ? Instruction::FDiv : Instruction::SDiv; |
- case bitc::BINOP_UREM: return Instruction::URem; |
- case bitc::BINOP_SREM: |
+ case naclbitc::BINOP_UREM: return Instruction::URem; |
+ case naclbitc::BINOP_SREM: |
return Ty->isFPOrFPVectorTy() ? Instruction::FRem : Instruction::SRem; |
- case bitc::BINOP_SHL: return Instruction::Shl; |
- case bitc::BINOP_LSHR: return Instruction::LShr; |
- case bitc::BINOP_ASHR: return Instruction::AShr; |
- case bitc::BINOP_AND: return Instruction::And; |
- case bitc::BINOP_OR: return Instruction::Or; |
- case bitc::BINOP_XOR: return Instruction::Xor; |
+ case naclbitc::BINOP_SHL: return Instruction::Shl; |
+ case naclbitc::BINOP_LSHR: return Instruction::LShr; |
+ case naclbitc::BINOP_ASHR: return Instruction::AShr; |
+ case naclbitc::BINOP_AND: return Instruction::And; |
+ case naclbitc::BINOP_OR: return Instruction::Or; |
+ case naclbitc::BINOP_XOR: return Instruction::Xor; |
} |
} |
static AtomicRMWInst::BinOp GetDecodedRMWOperation(unsigned Val) { |
switch (Val) { |
default: return AtomicRMWInst::BAD_BINOP; |
- case bitc::RMW_XCHG: return AtomicRMWInst::Xchg; |
- case bitc::RMW_ADD: return AtomicRMWInst::Add; |
- case bitc::RMW_SUB: return AtomicRMWInst::Sub; |
- case bitc::RMW_AND: return AtomicRMWInst::And; |
- case bitc::RMW_NAND: return AtomicRMWInst::Nand; |
- case bitc::RMW_OR: return AtomicRMWInst::Or; |
- case bitc::RMW_XOR: return AtomicRMWInst::Xor; |
- case bitc::RMW_MAX: return AtomicRMWInst::Max; |
- case bitc::RMW_MIN: return AtomicRMWInst::Min; |
- case bitc::RMW_UMAX: return AtomicRMWInst::UMax; |
- case bitc::RMW_UMIN: return AtomicRMWInst::UMin; |
+ case naclbitc::RMW_XCHG: return AtomicRMWInst::Xchg; |
+ case naclbitc::RMW_ADD: return AtomicRMWInst::Add; |
+ case naclbitc::RMW_SUB: return AtomicRMWInst::Sub; |
+ case naclbitc::RMW_AND: return AtomicRMWInst::And; |
+ case naclbitc::RMW_NAND: return AtomicRMWInst::Nand; |
+ case naclbitc::RMW_OR: return AtomicRMWInst::Or; |
+ case naclbitc::RMW_XOR: return AtomicRMWInst::Xor; |
+ case naclbitc::RMW_MAX: return AtomicRMWInst::Max; |
+ case naclbitc::RMW_MIN: return AtomicRMWInst::Min; |
+ case naclbitc::RMW_UMAX: return AtomicRMWInst::UMax; |
+ case naclbitc::RMW_UMIN: return AtomicRMWInst::UMin; |
} |
} |
static AtomicOrdering GetDecodedOrdering(unsigned Val) { |
switch (Val) { |
- case bitc::ORDERING_NOTATOMIC: return NotAtomic; |
- case bitc::ORDERING_UNORDERED: return Unordered; |
- case bitc::ORDERING_MONOTONIC: return Monotonic; |
- case bitc::ORDERING_ACQUIRE: return Acquire; |
- case bitc::ORDERING_RELEASE: return Release; |
- case bitc::ORDERING_ACQREL: return AcquireRelease; |
+ case naclbitc::ORDERING_NOTATOMIC: return NotAtomic; |
+ case naclbitc::ORDERING_UNORDERED: return Unordered; |
+ case naclbitc::ORDERING_MONOTONIC: return Monotonic; |
+ case naclbitc::ORDERING_ACQUIRE: return Acquire; |
+ case naclbitc::ORDERING_RELEASE: return Release; |
+ case naclbitc::ORDERING_ACQREL: return AcquireRelease; |
default: // Map unknown orderings to sequentially-consistent. |
- case bitc::ORDERING_SEQCST: return SequentiallyConsistent; |
+ case naclbitc::ORDERING_SEQCST: return SequentiallyConsistent; |
} |
} |
static SynchronizationScope GetDecodedSynchScope(unsigned Val) { |
switch (Val) { |
- case bitc::SYNCHSCOPE_SINGLETHREAD: return SingleThread; |
+ case naclbitc::SYNCHSCOPE_SINGLETHREAD: return SingleThread; |
default: // Map unknown scopes to cross-thread. |
- case bitc::SYNCHSCOPE_CROSSTHREAD: return CrossThread; |
+ case naclbitc::SYNCHSCOPE_CROSSTHREAD: return CrossThread; |
} |
} |
@@ -226,7 +227,7 @@ struct OperandTraits<ConstantPlaceHolder> : |
} |
-void BitcodeReaderValueList::AssignValue(Value *V, unsigned Idx) { |
+void NaClBitcodeReaderValueList::AssignValue(Value *V, unsigned Idx) { |
if (Idx == size()) { |
push_back(V); |
return; |
@@ -255,7 +256,7 @@ void BitcodeReaderValueList::AssignValue(Value *V, unsigned Idx) { |
} |
-Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, |
+Constant *NaClBitcodeReaderValueList::getConstantFwdRef(unsigned Idx, |
Type *Ty) { |
if (Idx >= size()) |
resize(Idx + 1); |
@@ -271,7 +272,7 @@ Constant *BitcodeReaderValueList::getConstantFwdRef(unsigned Idx, |
return C; |
} |
-Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, Type *Ty) { |
+Value *NaClBitcodeReaderValueList::getValueFwdRef(unsigned Idx, Type *Ty) { |
if (Idx >= size()) |
resize(Idx + 1); |
@@ -296,7 +297,7 @@ Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, Type *Ty) { |
/// building/reuniquing the constant. Instead of doing this, we look at all the |
/// uses and rewrite all the place holders at once for any constant that uses |
/// a placeholder. |
-void BitcodeReaderValueList::ResolveConstantForwardRefs() { |
+void NaClBitcodeReaderValueList::ResolveConstantForwardRefs() { |
// Sort the values by-pointer so that they are efficient to look up with a |
// binary search. |
std::sort(ResolveConstants.begin(), ResolveConstants.end()); |
@@ -371,7 +372,7 @@ void BitcodeReaderValueList::ResolveConstantForwardRefs() { |
} |
} |
-void BitcodeReaderMDValueList::AssignValue(Value *V, unsigned Idx) { |
+void NaClBitcodeReaderMDValueList::AssignValue(Value *V, unsigned Idx) { |
if (Idx == size()) { |
push_back(V); |
return; |
@@ -395,7 +396,7 @@ void BitcodeReaderMDValueList::AssignValue(Value *V, unsigned Idx) { |
MDValuePtrs[Idx] = V; |
} |
-Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) { |
+Value *NaClBitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) { |
if (Idx >= size()) |
resize(Idx + 1); |
@@ -410,7 +411,7 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) { |
return V; |
} |
-Type *BitcodeReader::getTypeByID(unsigned ID) { |
+Type *NaClBitcodeReader::getTypeByID(unsigned ID) { |
// The type table size is always specified correctly. |
if (ID >= TypeList.size()) |
return 0; |
@@ -448,8 +449,8 @@ static void decodeLLVMAttributesForBitcode(AttrBuilder &B, |
(EncodedAttrs & 0xffff)); |
} |
-bool BitcodeReader::ParseAttributeBlock() { |
- if (Stream.EnterSubBlock(bitc::PARAMATTR_BLOCK_ID)) |
+bool NaClBitcodeReader::ParseAttributeBlock() { |
+ if (Stream.EnterSubBlock(naclbitc::PARAMATTR_BLOCK_ID)) |
return Error("Malformed block record"); |
if (!MAttributes.empty()) |
@@ -461,15 +462,15 @@ bool BitcodeReader::ParseAttributeBlock() { |
// Read all the records. |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
return Error("Error at end of PARAMATTR block"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -479,7 +480,7 @@ bool BitcodeReader::ParseAttributeBlock() { |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: // Default behavior: ignore. |
break; |
- case bitc::PARAMATTR_CODE_ENTRY_OLD: { // ENTRY: [paramidx0, attr0, ...] |
+ case naclbitc::PARAMATTR_CODE_ENTRY_OLD: { // ENTRY: [paramidx0, attr0, ...] |
// FIXME: Remove in 4.0. |
if (Record.size() & 1) |
return Error("Invalid ENTRY record"); |
@@ -494,7 +495,7 @@ bool BitcodeReader::ParseAttributeBlock() { |
Attrs.clear(); |
break; |
} |
- case bitc::PARAMATTR_CODE_ENTRY: { // ENTRY: [attrgrp0, attrgrp1, ...] |
+ case naclbitc::PARAMATTR_CODE_ENTRY: { // ENTRY: [attrgrp0, attrgrp1, ...] |
for (unsigned i = 0, e = Record.size(); i != e; ++i) |
Attrs.push_back(MAttributeGroups[Record[i]]); |
@@ -506,8 +507,8 @@ bool BitcodeReader::ParseAttributeBlock() { |
} |
} |
-bool BitcodeReader::ParseAttributeGroupBlock() { |
- if (Stream.EnterSubBlock(bitc::PARAMATTR_GROUP_BLOCK_ID)) |
+bool NaClBitcodeReader::ParseAttributeGroupBlock() { |
+ if (Stream.EnterSubBlock(naclbitc::PARAMATTR_GROUP_BLOCK_ID)) |
return Error("Malformed block record"); |
if (!MAttributeGroups.empty()) |
@@ -517,15 +518,15 @@ bool BitcodeReader::ParseAttributeGroupBlock() { |
// Read all the records. |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
return Error("Error at end of PARAMATTR_GROUP block"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -535,7 +536,8 @@ bool BitcodeReader::ParseAttributeGroupBlock() { |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: // Default behavior: ignore. |
break; |
- case bitc::PARAMATTR_GRP_CODE_ENTRY: { // ENTRY: [grpid, idx, a0, a1, ...] |
+ case naclbitc::PARAMATTR_GRP_CODE_ENTRY: { |
+ // ENTRY: [grpid, idx, a0, a1, ...] |
if (Record.size() < 3) |
return Error("Invalid ENTRY record"); |
@@ -581,14 +583,14 @@ bool BitcodeReader::ParseAttributeGroupBlock() { |
} |
} |
-bool BitcodeReader::ParseTypeTable() { |
- if (Stream.EnterSubBlock(bitc::TYPE_BLOCK_ID_NEW)) |
+bool NaClBitcodeReader::ParseTypeTable() { |
+ if (Stream.EnterSubBlock(naclbitc::TYPE_BLOCK_ID_NEW)) |
return Error("Malformed block record"); |
return ParseTypeTableBody(); |
} |
-bool BitcodeReader::ParseTypeTableBody() { |
+bool NaClBitcodeReader::ParseTypeTableBody() { |
if (!TypeList.empty()) |
return Error("Multiple TYPE_BLOCKs found!"); |
@@ -599,18 +601,18 @@ bool BitcodeReader::ParseTypeTableBody() { |
// Read all the records for this type table. |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
Error("Error in the type table block"); |
return true; |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
if (NumRecords != TypeList.size()) |
return Error("Invalid type forward reference in TYPE_BLOCK"); |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -620,50 +622,50 @@ bool BitcodeReader::ParseTypeTableBody() { |
Type *ResultTy = 0; |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: return Error("unknown type in type table"); |
- case bitc::TYPE_CODE_NUMENTRY: // TYPE_CODE_NUMENTRY: [numentries] |
+ case naclbitc::TYPE_CODE_NUMENTRY: // TYPE_CODE_NUMENTRY: [numentries] |
// TYPE_CODE_NUMENTRY contains a count of the number of types in the |
// type list. This allows us to reserve space. |
if (Record.size() < 1) |
return Error("Invalid TYPE_CODE_NUMENTRY record"); |
TypeList.resize(Record[0]); |
continue; |
- case bitc::TYPE_CODE_VOID: // VOID |
+ case naclbitc::TYPE_CODE_VOID: // VOID |
ResultTy = Type::getVoidTy(Context); |
break; |
- case bitc::TYPE_CODE_HALF: // HALF |
+ case naclbitc::TYPE_CODE_HALF: // HALF |
ResultTy = Type::getHalfTy(Context); |
break; |
- case bitc::TYPE_CODE_FLOAT: // FLOAT |
+ case naclbitc::TYPE_CODE_FLOAT: // FLOAT |
ResultTy = Type::getFloatTy(Context); |
break; |
- case bitc::TYPE_CODE_DOUBLE: // DOUBLE |
+ case naclbitc::TYPE_CODE_DOUBLE: // DOUBLE |
ResultTy = Type::getDoubleTy(Context); |
break; |
- case bitc::TYPE_CODE_X86_FP80: // X86_FP80 |
+ case naclbitc::TYPE_CODE_X86_FP80: // X86_FP80 |
ResultTy = Type::getX86_FP80Ty(Context); |
break; |
- case bitc::TYPE_CODE_FP128: // FP128 |
+ case naclbitc::TYPE_CODE_FP128: // FP128 |
ResultTy = Type::getFP128Ty(Context); |
break; |
- case bitc::TYPE_CODE_PPC_FP128: // PPC_FP128 |
+ case naclbitc::TYPE_CODE_PPC_FP128: // PPC_FP128 |
ResultTy = Type::getPPC_FP128Ty(Context); |
break; |
- case bitc::TYPE_CODE_LABEL: // LABEL |
+ case naclbitc::TYPE_CODE_LABEL: // LABEL |
ResultTy = Type::getLabelTy(Context); |
break; |
- case bitc::TYPE_CODE_METADATA: // METADATA |
+ case naclbitc::TYPE_CODE_METADATA: // METADATA |
ResultTy = Type::getMetadataTy(Context); |
break; |
- case bitc::TYPE_CODE_X86_MMX: // X86_MMX |
+ case naclbitc::TYPE_CODE_X86_MMX: // X86_MMX |
ResultTy = Type::getX86_MMXTy(Context); |
break; |
- case bitc::TYPE_CODE_INTEGER: // INTEGER: [width] |
+ case naclbitc::TYPE_CODE_INTEGER: // INTEGER: [width] |
if (Record.size() < 1) |
return Error("Invalid Integer type record"); |
ResultTy = IntegerType::get(Context, Record[0]); |
break; |
- case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or |
+ case naclbitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or |
// [pointee type, address space] |
if (Record.size() < 1) |
return Error("Invalid POINTER type record"); |
@@ -675,7 +677,7 @@ bool BitcodeReader::ParseTypeTableBody() { |
ResultTy = PointerType::get(ResultTy, AddressSpace); |
break; |
} |
- case bitc::TYPE_CODE_FUNCTION_OLD: { |
+ case naclbitc::TYPE_CODE_FUNCTION_OLD: { |
// FIXME: attrid is dead, remove it in LLVM 4.0 |
// FUNCTION: [vararg, attrid, retty, paramty x N] |
if (Record.size() < 3) |
@@ -695,7 +697,7 @@ bool BitcodeReader::ParseTypeTableBody() { |
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]); |
break; |
} |
- case bitc::TYPE_CODE_FUNCTION: { |
+ case naclbitc::TYPE_CODE_FUNCTION: { |
// FUNCTION: [vararg, retty, paramty x N] |
if (Record.size() < 2) |
return Error("Invalid FUNCTION type record"); |
@@ -714,7 +716,7 @@ bool BitcodeReader::ParseTypeTableBody() { |
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]); |
break; |
} |
- case bitc::TYPE_CODE_STRUCT_ANON: { // STRUCT: [ispacked, eltty x N] |
+ case naclbitc::TYPE_CODE_STRUCT_ANON: { // STRUCT: [ispacked, eltty x N] |
if (Record.size() < 1) |
return Error("Invalid STRUCT type record"); |
SmallVector<Type*, 8> EltTys; |
@@ -729,12 +731,12 @@ bool BitcodeReader::ParseTypeTableBody() { |
ResultTy = StructType::get(Context, EltTys, Record[0]); |
break; |
} |
- case bitc::TYPE_CODE_STRUCT_NAME: // STRUCT_NAME: [strchr x N] |
+ case naclbitc::TYPE_CODE_STRUCT_NAME: // STRUCT_NAME: [strchr x N] |
if (ConvertToString(Record, 0, TypeName)) |
return Error("Invalid STRUCT_NAME record"); |
continue; |
- case bitc::TYPE_CODE_STRUCT_NAMED: { // STRUCT: [ispacked, eltty x N] |
+ case naclbitc::TYPE_CODE_STRUCT_NAMED: { // STRUCT: [ispacked, eltty x N] |
if (Record.size() < 1) |
return Error("Invalid STRUCT type record"); |
@@ -763,7 +765,7 @@ bool BitcodeReader::ParseTypeTableBody() { |
ResultTy = Res; |
break; |
} |
- case bitc::TYPE_CODE_OPAQUE: { // OPAQUE: [] |
+ case naclbitc::TYPE_CODE_OPAQUE: { // OPAQUE: [] |
if (Record.size() != 1) |
return Error("Invalid OPAQUE type record"); |
@@ -781,7 +783,7 @@ bool BitcodeReader::ParseTypeTableBody() { |
ResultTy = Res; |
break; |
} |
- case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty] |
+ case naclbitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty] |
if (Record.size() < 2) |
return Error("Invalid ARRAY type record"); |
if ((ResultTy = getTypeByID(Record[1]))) |
@@ -789,7 +791,7 @@ bool BitcodeReader::ParseTypeTableBody() { |
else |
return Error("Invalid ARRAY type element"); |
break; |
- case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] |
+ case naclbitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] |
if (Record.size() < 2) |
return Error("Invalid VECTOR type record"); |
if ((ResultTy = getTypeByID(Record[1]))) |
@@ -807,8 +809,8 @@ bool BitcodeReader::ParseTypeTableBody() { |
} |
} |
-bool BitcodeReader::ParseValueSymbolTable() { |
- if (Stream.EnterSubBlock(bitc::VALUE_SYMTAB_BLOCK_ID)) |
+bool NaClBitcodeReader::ParseValueSymbolTable() { |
+ if (Stream.EnterSubBlock(naclbitc::VALUE_SYMTAB_BLOCK_ID)) |
return Error("Malformed block record"); |
SmallVector<uint64_t, 64> Record; |
@@ -816,15 +818,15 @@ bool BitcodeReader::ParseValueSymbolTable() { |
// Read all the records for this value table. |
SmallString<128> ValueName; |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
return Error("malformed value symbol table block"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -834,7 +836,7 @@ bool BitcodeReader::ParseValueSymbolTable() { |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: // Default behavior: unknown type. |
break; |
- case bitc::VST_CODE_ENTRY: { // VST_ENTRY: [valueid, namechar x N] |
+ case naclbitc::VST_CODE_ENTRY: { // VST_ENTRY: [valueid, namechar x N] |
if (ConvertToString(Record, 1, ValueName)) |
return Error("Invalid VST_ENTRY record"); |
unsigned ValueID = Record[0]; |
@@ -846,7 +848,7 @@ bool BitcodeReader::ParseValueSymbolTable() { |
ValueName.clear(); |
break; |
} |
- case bitc::VST_CODE_BBENTRY: { |
+ case naclbitc::VST_CODE_BBENTRY: { |
if (ConvertToString(Record, 1, ValueName)) |
return Error("Invalid VST_BBENTRY record"); |
BasicBlock *BB = getBasicBlock(Record[0]); |
@@ -861,26 +863,26 @@ bool BitcodeReader::ParseValueSymbolTable() { |
} |
} |
-bool BitcodeReader::ParseMetadata() { |
+bool NaClBitcodeReader::ParseMetadata() { |
unsigned NextMDValueNo = MDValueList.size(); |
- if (Stream.EnterSubBlock(bitc::METADATA_BLOCK_ID)) |
+ if (Stream.EnterSubBlock(naclbitc::METADATA_BLOCK_ID)) |
return Error("Malformed block record"); |
SmallVector<uint64_t, 64> Record; |
// Read all the records. |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
Error("malformed metadata block"); |
return true; |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -892,7 +894,7 @@ bool BitcodeReader::ParseMetadata() { |
switch (Code) { |
default: // Default behavior: ignore. |
break; |
- case bitc::METADATA_NAME: { |
+ case naclbitc::METADATA_NAME: { |
// Read name of the named metadata. |
SmallString<8> Name(Record.begin(), Record.end()); |
Record.clear(); |
@@ -900,7 +902,7 @@ bool BitcodeReader::ParseMetadata() { |
// METADATA_NAME is always followed by METADATA_NAMED_NODE. |
unsigned NextBitCode = Stream.readRecord(Code, Record); |
- assert(NextBitCode == bitc::METADATA_NAMED_NODE); (void)NextBitCode; |
+ assert(NextBitCode == naclbitc::METADATA_NAMED_NODE); (void)NextBitCode; |
// Read named metadata elements. |
unsigned Size = Record.size(); |
@@ -913,10 +915,10 @@ bool BitcodeReader::ParseMetadata() { |
} |
break; |
} |
- case bitc::METADATA_FN_NODE: |
+ case naclbitc::METADATA_FN_NODE: |
IsFunctionLocal = true; |
// fall-through |
- case bitc::METADATA_NODE: { |
+ case naclbitc::METADATA_NODE: { |
if (Record.size() % 2 == 1) |
return Error("Invalid METADATA_NODE record"); |
@@ -937,13 +939,13 @@ bool BitcodeReader::ParseMetadata() { |
MDValueList.AssignValue(V, NextMDValueNo++); |
break; |
} |
- case bitc::METADATA_STRING: { |
+ case naclbitc::METADATA_STRING: { |
SmallString<8> String(Record.begin(), Record.end()); |
Value *V = MDString::get(Context, String); |
MDValueList.AssignValue(V, NextMDValueNo++); |
break; |
} |
- case bitc::METADATA_KIND: { |
+ case naclbitc::METADATA_KIND: { |
if (Record.size() < 2) |
return Error("Invalid METADATA_KIND record"); |
@@ -961,7 +963,7 @@ bool BitcodeReader::ParseMetadata() { |
/// decodeSignRotatedValue - Decode a signed value stored with the sign bit in |
/// the LSB for dense VBR encoding. |
-uint64_t BitcodeReader::decodeSignRotatedValue(uint64_t V) { |
+uint64_t NaClBitcodeReader::decodeSignRotatedValue(uint64_t V) { |
if ((V & 1) == 0) |
return V >> 1; |
if (V != 1) |
@@ -972,7 +974,7 @@ uint64_t BitcodeReader::decodeSignRotatedValue(uint64_t V) { |
/// ResolveGlobalAndAliasInits - Resolve all of the initializers for global |
/// values and aliases that we can. |
-bool BitcodeReader::ResolveGlobalAndAliasInits() { |
+bool NaClBitcodeReader::ResolveGlobalAndAliasInits() { |
std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInitWorklist; |
std::vector<std::pair<GlobalAlias*, unsigned> > AliasInitWorklist; |
@@ -1011,13 +1013,13 @@ bool BitcodeReader::ResolveGlobalAndAliasInits() { |
static APInt ReadWideAPInt(ArrayRef<uint64_t> Vals, unsigned TypeBits) { |
SmallVector<uint64_t, 8> Words(Vals.size()); |
std::transform(Vals.begin(), Vals.end(), Words.begin(), |
- BitcodeReader::decodeSignRotatedValue); |
+ NaClBitcodeReader::decodeSignRotatedValue); |
return APInt(TypeBits, Words); |
} |
-bool BitcodeReader::ParseConstants() { |
- if (Stream.EnterSubBlock(bitc::CONSTANTS_BLOCK_ID)) |
+bool NaClBitcodeReader::ParseConstants() { |
+ if (Stream.EnterSubBlock(naclbitc::CONSTANTS_BLOCK_ID)) |
return Error("Malformed block record"); |
SmallVector<uint64_t, 64> Record; |
@@ -1026,13 +1028,13 @@ bool BitcodeReader::ParseConstants() { |
Type *CurTy = Type::getInt32Ty(Context); |
unsigned NextCstNo = ValueList.size(); |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
return Error("malformed block record in AST file"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
if (NextCstNo != ValueList.size()) |
return Error("Invalid constant reference!"); |
@@ -1040,7 +1042,7 @@ bool BitcodeReader::ParseConstants() { |
// references. |
ValueList.ResolveConstantForwardRefs(); |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -1051,25 +1053,25 @@ bool BitcodeReader::ParseConstants() { |
unsigned BitCode = Stream.readRecord(Entry.ID, Record); |
switch (BitCode) { |
default: // Default behavior: unknown constant |
- case bitc::CST_CODE_UNDEF: // UNDEF |
+ case naclbitc::CST_CODE_UNDEF: // UNDEF |
V = UndefValue::get(CurTy); |
break; |
- case bitc::CST_CODE_SETTYPE: // SETTYPE: [typeid] |
+ case naclbitc::CST_CODE_SETTYPE: // SETTYPE: [typeid] |
if (Record.empty()) |
return Error("Malformed CST_SETTYPE record"); |
if (Record[0] >= TypeList.size()) |
return Error("Invalid Type ID in CST_SETTYPE record"); |
CurTy = TypeList[Record[0]]; |
continue; // Skip the ValueList manipulation. |
- case bitc::CST_CODE_NULL: // NULL |
+ case naclbitc::CST_CODE_NULL: // NULL |
V = Constant::getNullValue(CurTy); |
break; |
- case bitc::CST_CODE_INTEGER: // INTEGER: [intval] |
+ case naclbitc::CST_CODE_INTEGER: // INTEGER: [intval] |
if (!CurTy->isIntegerTy() || Record.empty()) |
return Error("Invalid CST_INTEGER record"); |
V = ConstantInt::get(CurTy, decodeSignRotatedValue(Record[0])); |
break; |
- case bitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval] |
+ case naclbitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval] |
if (!CurTy->isIntegerTy() || Record.empty()) |
return Error("Invalid WIDE_INTEGER record"); |
@@ -1079,7 +1081,7 @@ bool BitcodeReader::ParseConstants() { |
break; |
} |
- case bitc::CST_CODE_FLOAT: { // FLOAT: [fpval] |
+ case naclbitc::CST_CODE_FLOAT: { // FLOAT: [fpval] |
if (Record.empty()) |
return Error("Invalid FLOAT record"); |
if (CurTy->isHalfTy()) |
@@ -1109,7 +1111,7 @@ bool BitcodeReader::ParseConstants() { |
break; |
} |
- case bitc::CST_CODE_AGGREGATE: {// AGGREGATE: [n x value number] |
+ case naclbitc::CST_CODE_AGGREGATE: {// AGGREGATE: [n x value number] |
if (Record.empty()) |
return Error("Invalid CST_AGGREGATE record"); |
@@ -1136,17 +1138,17 @@ bool BitcodeReader::ParseConstants() { |
} |
break; |
} |
- case bitc::CST_CODE_STRING: // STRING: [values] |
- case bitc::CST_CODE_CSTRING: { // CSTRING: [values] |
+ case naclbitc::CST_CODE_STRING: // STRING: [values] |
+ case naclbitc::CST_CODE_CSTRING: { // CSTRING: [values] |
if (Record.empty()) |
return Error("Invalid CST_STRING record"); |
SmallString<16> Elts(Record.begin(), Record.end()); |
V = ConstantDataArray::getString(Context, Elts, |
- BitCode == bitc::CST_CODE_CSTRING); |
+ BitCode == naclbitc::CST_CODE_CSTRING); |
break; |
} |
- case bitc::CST_CODE_DATA: {// DATA: [n x value] |
+ case naclbitc::CST_CODE_DATA: {// DATA: [n x value] |
if (Record.empty()) |
return Error("Invalid CST_DATA record"); |
@@ -1198,7 +1200,7 @@ bool BitcodeReader::ParseConstants() { |
break; |
} |
- case bitc::CST_CODE_CE_BINOP: { // CE_BINOP: [opcode, opval, opval] |
+ case naclbitc::CST_CODE_CE_BINOP: { // CE_BINOP: [opcode, opval, opval] |
if (Record.size() < 3) return Error("Invalid CE_BINOP record"); |
int Opc = GetDecodedBinaryOpcode(Record[0], CurTy); |
if (Opc < 0) { |
@@ -1212,15 +1214,15 @@ bool BitcodeReader::ParseConstants() { |
Opc == Instruction::Sub || |
Opc == Instruction::Mul || |
Opc == Instruction::Shl) { |
- if (Record[3] & (1 << bitc::OBO_NO_SIGNED_WRAP)) |
+ if (Record[3] & (1 << naclbitc::OBO_NO_SIGNED_WRAP)) |
Flags |= OverflowingBinaryOperator::NoSignedWrap; |
- if (Record[3] & (1 << bitc::OBO_NO_UNSIGNED_WRAP)) |
+ if (Record[3] & (1 << naclbitc::OBO_NO_UNSIGNED_WRAP)) |
Flags |= OverflowingBinaryOperator::NoUnsignedWrap; |
} else if (Opc == Instruction::SDiv || |
Opc == Instruction::UDiv || |
Opc == Instruction::LShr || |
Opc == Instruction::AShr) { |
- if (Record[3] & (1 << bitc::PEO_EXACT)) |
+ if (Record[3] & (1 << naclbitc::PEO_EXACT)) |
Flags |= SDivOperator::IsExact; |
} |
} |
@@ -1228,7 +1230,7 @@ bool BitcodeReader::ParseConstants() { |
} |
break; |
} |
- case bitc::CST_CODE_CE_CAST: { // CE_CAST: [opcode, opty, opval] |
+ case naclbitc::CST_CODE_CE_CAST: { // CE_CAST: [opcode, opty, opval] |
if (Record.size() < 3) return Error("Invalid CE_CAST record"); |
int Opc = GetDecodedCastOpcode(Record[0]); |
if (Opc < 0) { |
@@ -1241,8 +1243,8 @@ bool BitcodeReader::ParseConstants() { |
} |
break; |
} |
- case bitc::CST_CODE_CE_INBOUNDS_GEP: |
- case bitc::CST_CODE_CE_GEP: { // CE_GEP: [n x operands] |
+ case naclbitc::CST_CODE_CE_INBOUNDS_GEP: |
+ case naclbitc::CST_CODE_CE_GEP: { // CE_GEP: [n x operands] |
if (Record.size() & 1) return Error("Invalid CE_GEP record"); |
SmallVector<Constant*, 16> Elts; |
for (unsigned i = 0, e = Record.size(); i != e; i += 2) { |
@@ -1253,10 +1255,10 @@ bool BitcodeReader::ParseConstants() { |
ArrayRef<Constant *> Indices(Elts.begin() + 1, Elts.end()); |
V = ConstantExpr::getGetElementPtr(Elts[0], Indices, |
BitCode == |
- bitc::CST_CODE_CE_INBOUNDS_GEP); |
+ naclbitc::CST_CODE_CE_INBOUNDS_GEP); |
break; |
} |
- case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#] |
+ case naclbitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#] |
if (Record.size() < 3) return Error("Invalid CE_SELECT record"); |
V = ConstantExpr::getSelect( |
ValueList.getConstantFwdRef(Record[0], |
@@ -1264,7 +1266,8 @@ bool BitcodeReader::ParseConstants() { |
ValueList.getConstantFwdRef(Record[1],CurTy), |
ValueList.getConstantFwdRef(Record[2],CurTy)); |
break; |
- case bitc::CST_CODE_CE_EXTRACTELT: { // CE_EXTRACTELT: [opty, opval, opval] |
+ case naclbitc::CST_CODE_CE_EXTRACTELT: { |
+ // CE_EXTRACTELT: [opty, opval, opval] |
if (Record.size() < 3) return Error("Invalid CE_EXTRACTELT record"); |
VectorType *OpTy = |
dyn_cast_or_null<VectorType>(getTypeByID(Record[0])); |
@@ -1275,7 +1278,7 @@ bool BitcodeReader::ParseConstants() { |
V = ConstantExpr::getExtractElement(Op0, Op1); |
break; |
} |
- case bitc::CST_CODE_CE_INSERTELT: { // CE_INSERTELT: [opval, opval, opval] |
+ case naclbitc::CST_CODE_CE_INSERTELT: {// CE_INSERTELT: [opval, opval, opval] |
VectorType *OpTy = dyn_cast<VectorType>(CurTy); |
if (Record.size() < 3 || OpTy == 0) |
return Error("Invalid CE_INSERTELT record"); |
@@ -1287,7 +1290,7 @@ bool BitcodeReader::ParseConstants() { |
V = ConstantExpr::getInsertElement(Op0, Op1, Op2); |
break; |
} |
- case bitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval] |
+ case naclbitc::CST_CODE_CE_SHUFFLEVEC: { // CE_SHUFFLEVEC: [opval, opval, opval] |
VectorType *OpTy = dyn_cast<VectorType>(CurTy); |
if (Record.size() < 3 || OpTy == 0) |
return Error("Invalid CE_SHUFFLEVEC record"); |
@@ -1299,7 +1302,7 @@ bool BitcodeReader::ParseConstants() { |
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); |
break; |
} |
- case bitc::CST_CODE_CE_SHUFVEC_EX: { // [opty, opval, opval, opval] |
+ case naclbitc::CST_CODE_CE_SHUFVEC_EX: { // [opty, opval, opval, opval] |
VectorType *RTy = dyn_cast<VectorType>(CurTy); |
VectorType *OpTy = |
dyn_cast_or_null<VectorType>(getTypeByID(Record[0])); |
@@ -1313,7 +1316,7 @@ bool BitcodeReader::ParseConstants() { |
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); |
break; |
} |
- case bitc::CST_CODE_CE_CMP: { // CE_CMP: [opty, opval, opval, pred] |
+ case naclbitc::CST_CODE_CE_CMP: { // CE_CMP: [opty, opval, opval, pred] |
if (Record.size() < 4) return Error("Invalid CE_CMP record"); |
Type *OpTy = getTypeByID(Record[0]); |
if (OpTy == 0) return Error("Invalid CE_CMP record"); |
@@ -1328,7 +1331,7 @@ bool BitcodeReader::ParseConstants() { |
} |
// This maintains backward compatibility, pre-asm dialect keywords. |
// FIXME: Remove with the 4.0 release. |
- case bitc::CST_CODE_INLINEASM_OLD: { |
+ case naclbitc::CST_CODE_INLINEASM_OLD: { |
if (Record.size() < 2) return Error("Invalid INLINEASM record"); |
std::string AsmStr, ConstrStr; |
bool HasSideEffects = Record[0] & 1; |
@@ -1351,7 +1354,7 @@ bool BitcodeReader::ParseConstants() { |
} |
// This version adds support for the asm dialect keywords (e.g., |
// inteldialect). |
- case bitc::CST_CODE_INLINEASM: { |
+ case naclbitc::CST_CODE_INLINEASM: { |
if (Record.size() < 2) return Error("Invalid INLINEASM record"); |
std::string AsmStr, ConstrStr; |
bool HasSideEffects = Record[0] & 1; |
@@ -1374,7 +1377,7 @@ bool BitcodeReader::ParseConstants() { |
InlineAsm::AsmDialect(AsmDialect)); |
break; |
} |
- case bitc::CST_CODE_BLOCKADDRESS:{ |
+ case naclbitc::CST_CODE_BLOCKADDRESS:{ |
if (Record.size() < 3) return Error("Invalid CE_BLOCKADDRESS record"); |
Type *FnTy = getTypeByID(Record[0]); |
if (FnTy == 0) return Error("Invalid CE_BLOCKADDRESS record"); |
@@ -1411,23 +1414,23 @@ bool BitcodeReader::ParseConstants() { |
} |
} |
-bool BitcodeReader::ParseUseLists() { |
- if (Stream.EnterSubBlock(bitc::USELIST_BLOCK_ID)) |
+bool NaClBitcodeReader::ParseUseLists() { |
+ if (Stream.EnterSubBlock(naclbitc::USELIST_BLOCK_ID)) |
return Error("Malformed block record"); |
SmallVector<uint64_t, 64> Record; |
// Read all the records. |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
return Error("malformed use list block"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -1437,7 +1440,7 @@ bool BitcodeReader::ParseUseLists() { |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: // Default behavior: unknown type. |
break; |
- case bitc::USELIST_CODE_ENTRY: { // USELIST_CODE_ENTRY: TBD. |
+ case naclbitc::USELIST_CODE_ENTRY: { // USELIST_CODE_ENTRY: TBD. |
unsigned RecordLength = Record.size(); |
if (RecordLength < 1) |
return Error ("Invalid UseList reader!"); |
@@ -1451,7 +1454,7 @@ bool BitcodeReader::ParseUseLists() { |
/// RememberAndSkipFunctionBody - When we see the block for a function body, |
/// remember where it is and then skip it. This lets us lazily deserialize the |
/// functions. |
-bool BitcodeReader::RememberAndSkipFunctionBody() { |
+bool NaClBitcodeReader::RememberAndSkipFunctionBody() { |
// Get the function we are talking about. |
if (FunctionsWithBodies.empty()) |
return Error("Insufficient function protos"); |
@@ -1469,7 +1472,7 @@ bool BitcodeReader::RememberAndSkipFunctionBody() { |
return false; |
} |
-bool BitcodeReader::GlobalCleanup() { |
+bool NaClBitcodeReader::GlobalCleanup() { |
// Patch the initializers for globals and aliases up. |
ResolveGlobalAndAliasInits(); |
if (!GlobalInits.empty() || !AliasInits.empty()) |
@@ -1495,10 +1498,10 @@ bool BitcodeReader::GlobalCleanup() { |
return false; |
} |
-bool BitcodeReader::ParseModule(bool Resume) { |
+bool NaClBitcodeReader::ParseModule(bool Resume) { |
if (Resume) |
Stream.JumpToBit(NextUnreadBit); |
- else if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID)) |
+ else if (Stream.EnterSubBlock(naclbitc::MODULE_BLOCK_ID)) |
return Error("Malformed block record"); |
SmallVector<uint64_t, 64> Record; |
@@ -1507,16 +1510,16 @@ bool BitcodeReader::ParseModule(bool Resume) { |
// Read all the records for this module. |
while (1) { |
- BitstreamEntry Entry = Stream.advance(); |
+ NaClBitstreamEntry Entry = Stream.advance(); |
switch (Entry.Kind) { |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::Error: |
Error("malformed module block"); |
return true; |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return GlobalCleanup(); |
- case BitstreamEntry::SubBlock: |
+ case NaClBitstreamEntry::SubBlock: |
switch (Entry.ID) { |
default: // Skip unknown content. |
if (Stream.SkipBlock()) |
@@ -1526,32 +1529,32 @@ bool BitcodeReader::ParseModule(bool Resume) { |
if (Stream.ReadBlockInfoBlock()) |
return Error("Malformed BlockInfoBlock"); |
break; |
- case bitc::PARAMATTR_BLOCK_ID: |
+ case naclbitc::PARAMATTR_BLOCK_ID: |
if (ParseAttributeBlock()) |
return true; |
break; |
- case bitc::PARAMATTR_GROUP_BLOCK_ID: |
+ case naclbitc::PARAMATTR_GROUP_BLOCK_ID: |
if (ParseAttributeGroupBlock()) |
return true; |
break; |
- case bitc::TYPE_BLOCK_ID_NEW: |
+ case naclbitc::TYPE_BLOCK_ID_NEW: |
if (ParseTypeTable()) |
return true; |
break; |
- case bitc::VALUE_SYMTAB_BLOCK_ID: |
+ case naclbitc::VALUE_SYMTAB_BLOCK_ID: |
if (ParseValueSymbolTable()) |
return true; |
SeenValueSymbolTable = true; |
break; |
- case bitc::CONSTANTS_BLOCK_ID: |
+ case naclbitc::CONSTANTS_BLOCK_ID: |
if (ParseConstants() || ResolveGlobalAndAliasInits()) |
return true; |
break; |
- case bitc::METADATA_BLOCK_ID: |
+ case naclbitc::METADATA_BLOCK_ID: |
if (ParseMetadata()) |
return true; |
break; |
- case bitc::FUNCTION_BLOCK_ID: |
+ case naclbitc::FUNCTION_BLOCK_ID: |
// If this is the first function body we've seen, reverse the |
// FunctionsWithBodies list. |
if (!SeenFirstFunctionBody) { |
@@ -1574,14 +1577,14 @@ bool BitcodeReader::ParseModule(bool Resume) { |
return false; |
} |
break; |
- case bitc::USELIST_BLOCK_ID: |
+ case naclbitc::USELIST_BLOCK_ID: |
if (ParseUseLists()) |
return true; |
break; |
} |
continue; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -1590,7 +1593,7 @@ bool BitcodeReader::ParseModule(bool Resume) { |
// Read a record. |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: break; // Default behavior, ignore unknown content. |
- case bitc::MODULE_CODE_VERSION: { // VERSION: [version#] |
+ case naclbitc::MODULE_CODE_VERSION: { // VERSION: [version#] |
if (Record.size() < 1) |
return Error("Malformed MODULE_CODE_VERSION"); |
// Only version #0 and #1 are supported so far. |
@@ -1606,7 +1609,7 @@ bool BitcodeReader::ParseModule(bool Resume) { |
} |
break; |
} |
- case bitc::MODULE_CODE_TRIPLE: { // TRIPLE: [strchr x N] |
+ case naclbitc::MODULE_CODE_TRIPLE: { // TRIPLE: [strchr x N] |
std::string S; |
if (ConvertToString(Record, 0, S)) |
return Error("Invalid MODULE_CODE_TRIPLE record"); |
@@ -1621,21 +1624,21 @@ bool BitcodeReader::ParseModule(bool Resume) { |
TheModule->setTargetTriple(S); |
break; |
} |
- case bitc::MODULE_CODE_DATALAYOUT: { // DATALAYOUT: [strchr x N] |
+ case naclbitc::MODULE_CODE_DATALAYOUT: { // DATALAYOUT: [strchr x N] |
std::string S; |
if (ConvertToString(Record, 0, S)) |
return Error("Invalid MODULE_CODE_DATALAYOUT record"); |
TheModule->setDataLayout(S); |
break; |
} |
- case bitc::MODULE_CODE_ASM: { // ASM: [strchr x N] |
+ case naclbitc::MODULE_CODE_ASM: { // ASM: [strchr x N] |
std::string S; |
if (ConvertToString(Record, 0, S)) |
return Error("Invalid MODULE_CODE_ASM record"); |
TheModule->setModuleInlineAsm(S); |
break; |
} |
- case bitc::MODULE_CODE_DEPLIB: { // DEPLIB: [strchr x N] |
+ case naclbitc::MODULE_CODE_DEPLIB: { // DEPLIB: [strchr x N] |
// FIXME: Remove in 4.0. |
std::string S; |
if (ConvertToString(Record, 0, S)) |
@@ -1643,14 +1646,14 @@ bool BitcodeReader::ParseModule(bool Resume) { |
// Ignore value. |
break; |
} |
- case bitc::MODULE_CODE_SECTIONNAME: { // SECTIONNAME: [strchr x N] |
+ case naclbitc::MODULE_CODE_SECTIONNAME: { // SECTIONNAME: [strchr x N] |
std::string S; |
if (ConvertToString(Record, 0, S)) |
return Error("Invalid MODULE_CODE_SECTIONNAME record"); |
SectionTable.push_back(S); |
break; |
} |
- case bitc::MODULE_CODE_GCNAME: { // SECTIONNAME: [strchr x N] |
+ case naclbitc::MODULE_CODE_GCNAME: { // SECTIONNAME: [strchr x N] |
std::string S; |
if (ConvertToString(Record, 0, S)) |
return Error("Invalid MODULE_CODE_GCNAME record"); |
@@ -1660,7 +1663,7 @@ bool BitcodeReader::ParseModule(bool Resume) { |
// GLOBALVAR: [pointer type, isconst, initid, |
// linkage, alignment, section, visibility, threadlocal, |
// unnamed_addr] |
- case bitc::MODULE_CODE_GLOBALVAR: { |
+ case naclbitc::MODULE_CODE_GLOBALVAR: { |
if (Record.size() < 6) |
return Error("Invalid MODULE_CODE_GLOBALVAR record"); |
Type *Ty = getTypeByID(Record[0]); |
@@ -1713,7 +1716,7 @@ bool BitcodeReader::ParseModule(bool Resume) { |
} |
// FUNCTION: [type, callingconv, isproto, linkage, paramattr, |
// alignment, section, visibility, gc, unnamed_addr] |
- case bitc::MODULE_CODE_FUNCTION: { |
+ case naclbitc::MODULE_CODE_FUNCTION: { |
if (Record.size() < 8) |
return Error("Invalid MODULE_CODE_FUNCTION record"); |
Type *Ty = getTypeByID(Record[0]); |
@@ -1761,7 +1764,7 @@ bool BitcodeReader::ParseModule(bool Resume) { |
} |
// ALIAS: [alias type, aliasee val#, linkage] |
// ALIAS: [alias type, aliasee val#, linkage, visibility] |
- case bitc::MODULE_CODE_ALIAS: { |
+ case naclbitc::MODULE_CODE_ALIAS: { |
if (Record.size() < 3) |
return Error("Invalid MODULE_ALIAS record"); |
Type *Ty = getTypeByID(Record[0]); |
@@ -1779,7 +1782,7 @@ bool BitcodeReader::ParseModule(bool Resume) { |
break; |
} |
/// MODULE_CODE_PURGEVALS: [numvals] |
- case bitc::MODULE_CODE_PURGEVALS: |
+ case naclbitc::MODULE_CODE_PURGEVALS: |
// Trim down the value list to the specified size. |
if (Record.size() < 1 || Record[0] > ValueList.size()) |
return Error("Invalid MODULE_PURGEVALS record"); |
@@ -1790,7 +1793,7 @@ bool BitcodeReader::ParseModule(bool Resume) { |
} |
} |
-bool BitcodeReader::ParseBitcodeInto(Module *M) { |
+bool NaClBitcodeReader::ParseBitcodeInto(Module *M) { |
TheModule = 0; |
if (InitStream()) return true; |
@@ -1810,23 +1813,23 @@ bool BitcodeReader::ParseBitcodeInto(Module *M) { |
if (Stream.AtEndOfStream()) |
return false; |
- BitstreamEntry Entry = |
- Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs); |
+ NaClBitstreamEntry Entry = |
+ Stream.advance(NaClBitstreamCursor::AF_DontAutoprocessAbbrevs); |
switch (Entry.Kind) { |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::Error: |
Error("malformed module file"); |
return true; |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::SubBlock: |
+ case NaClBitstreamEntry::SubBlock: |
switch (Entry.ID) { |
case bitc::BLOCKINFO_BLOCK_ID: |
if (Stream.ReadBlockInfoBlock()) |
return Error("Malformed BlockInfoBlock"); |
break; |
- case bitc::MODULE_BLOCK_ID: |
+ case naclbitc::MODULE_BLOCK_ID: |
// Reject multiple MODULE_BLOCK's in a single bitstream. |
if (TheModule) |
return Error("Multiple MODULE_BLOCKs in same stream"); |
@@ -1841,7 +1844,7 @@ bool BitcodeReader::ParseBitcodeInto(Module *M) { |
break; |
} |
continue; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// There should be no records in the top-level of blocks. |
// The ranlib in Xcode 4 will align archive members by appending newlines |
@@ -1857,23 +1860,23 @@ bool BitcodeReader::ParseBitcodeInto(Module *M) { |
} |
} |
-bool BitcodeReader::ParseModuleTriple(std::string &Triple) { |
- if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID)) |
+bool NaClBitcodeReader::ParseModuleTriple(std::string &Triple) { |
+ if (Stream.EnterSubBlock(naclbitc::MODULE_BLOCK_ID)) |
return Error("Malformed block record"); |
SmallVector<uint64_t, 64> Record; |
// Read all the records for this module. |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
return Error("malformed module block"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -1881,7 +1884,7 @@ bool BitcodeReader::ParseModuleTriple(std::string &Triple) { |
// Read a record. |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: break; // Default behavior, ignore unknown content. |
- case bitc::MODULE_CODE_TRIPLE: { // TRIPLE: [strchr x N] |
+ case naclbitc::MODULE_CODE_TRIPLE: { // TRIPLE: [strchr x N] |
std::string S; |
if (ConvertToString(Record, 0, S)) |
return Error("Invalid MODULE_CODE_TRIPLE record"); |
@@ -1893,7 +1896,7 @@ bool BitcodeReader::ParseModuleTriple(std::string &Triple) { |
} |
} |
-bool BitcodeReader::ParseTriple(std::string &Triple) { |
+bool NaClBitcodeReader::ParseTriple(std::string &Triple) { |
if (InitStream()) return true; |
// Sniff for the signature. |
@@ -1908,17 +1911,17 @@ bool BitcodeReader::ParseTriple(std::string &Triple) { |
// We expect a number of well-defined blocks, though we don't necessarily |
// need to understand them all. |
while (1) { |
- BitstreamEntry Entry = Stream.advance(); |
+ NaClBitstreamEntry Entry = Stream.advance(); |
switch (Entry.Kind) { |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::Error: |
Error("malformed module file"); |
return true; |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::SubBlock: |
- if (Entry.ID == bitc::MODULE_BLOCK_ID) |
+ case NaClBitstreamEntry::SubBlock: |
+ if (Entry.ID == naclbitc::MODULE_BLOCK_ID) |
return ParseModuleTriple(Triple); |
// Ignore other sub-blocks. |
@@ -1928,7 +1931,7 @@ bool BitcodeReader::ParseTriple(std::string &Triple) { |
} |
continue; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
Stream.skipRecord(Entry.ID); |
continue; |
} |
@@ -1936,21 +1939,21 @@ bool BitcodeReader::ParseTriple(std::string &Triple) { |
} |
/// ParseMetadataAttachment - Parse metadata attachments. |
-bool BitcodeReader::ParseMetadataAttachment() { |
- if (Stream.EnterSubBlock(bitc::METADATA_ATTACHMENT_ID)) |
+bool NaClBitcodeReader::ParseMetadataAttachment() { |
+ if (Stream.EnterSubBlock(naclbitc::METADATA_ATTACHMENT_ID)) |
return Error("Malformed block record"); |
SmallVector<uint64_t, 64> Record; |
while (1) { |
- BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
+ NaClBitstreamEntry Entry = Stream.advanceSkippingSubblocks(); |
switch (Entry.Kind) { |
- case BitstreamEntry::SubBlock: // Handled for us already. |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::SubBlock: // Handled for us already. |
+ case NaClBitstreamEntry::Error: |
return Error("malformed metadata block"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
return false; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -1960,7 +1963,7 @@ bool BitcodeReader::ParseMetadataAttachment() { |
switch (Stream.readRecord(Entry.ID, Record)) { |
default: // Default behavior: ignore. |
break; |
- case bitc::METADATA_ATTACHMENT: { |
+ case naclbitc::METADATA_ATTACHMENT: { |
unsigned RecordLength = Record.size(); |
if (Record.empty() || (RecordLength - 1) % 2 == 1) |
return Error ("Invalid METADATA_ATTACHMENT reader!"); |
@@ -1981,8 +1984,8 @@ bool BitcodeReader::ParseMetadataAttachment() { |
} |
/// ParseFunctionBody - Lazily parse the specified function body block. |
-bool BitcodeReader::ParseFunctionBody(Function *F) { |
- if (Stream.EnterSubBlock(bitc::FUNCTION_BLOCK_ID)) |
+bool NaClBitcodeReader::ParseFunctionBody(Function *F) { |
+ if (Stream.EnterSubBlock(naclbitc::FUNCTION_BLOCK_ID)) |
return Error("Malformed block record"); |
InstructionList.clear(); |
@@ -2002,37 +2005,37 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
// Read all the records. |
SmallVector<uint64_t, 64> Record; |
while (1) { |
- BitstreamEntry Entry = Stream.advance(); |
+ NaClBitstreamEntry Entry = Stream.advance(); |
switch (Entry.Kind) { |
- case BitstreamEntry::Error: |
+ case NaClBitstreamEntry::Error: |
return Error("Bitcode error in function block"); |
- case BitstreamEntry::EndBlock: |
+ case NaClBitstreamEntry::EndBlock: |
goto OutOfRecordLoop; |
- case BitstreamEntry::SubBlock: |
+ case NaClBitstreamEntry::SubBlock: |
switch (Entry.ID) { |
default: // Skip unknown content. |
if (Stream.SkipBlock()) |
return Error("Malformed block record"); |
break; |
- case bitc::CONSTANTS_BLOCK_ID: |
+ case naclbitc::CONSTANTS_BLOCK_ID: |
if (ParseConstants()) return true; |
NextValueNo = ValueList.size(); |
break; |
- case bitc::VALUE_SYMTAB_BLOCK_ID: |
+ case naclbitc::VALUE_SYMTAB_BLOCK_ID: |
if (ParseValueSymbolTable()) return true; |
break; |
- case bitc::METADATA_ATTACHMENT_ID: |
+ case naclbitc::METADATA_ATTACHMENT_ID: |
if (ParseMetadataAttachment()) return true; |
break; |
- case bitc::METADATA_BLOCK_ID: |
+ case naclbitc::METADATA_BLOCK_ID: |
if (ParseMetadata()) return true; |
break; |
} |
continue; |
- case BitstreamEntry::Record: |
+ case NaClBitstreamEntry::Record: |
// The interesting case. |
break; |
} |
@@ -2044,7 +2047,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
switch (BitCode) { |
default: // Default behavior: reject |
return Error("Unknown instruction"); |
- case bitc::FUNC_CODE_DECLAREBLOCKS: // DECLAREBLOCKS: [nblocks] |
+ case naclbitc::FUNC_CODE_DECLAREBLOCKS: // DECLAREBLOCKS: [nblocks] |
if (Record.size() < 1 || Record[0] == 0) |
return Error("Invalid DECLAREBLOCKS record"); |
// Create all the basic blocks for the function. |
@@ -2054,7 +2057,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
CurBB = FunctionBBs[0]; |
continue; |
- case bitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN |
+ case naclbitc::FUNC_CODE_DEBUG_LOC_AGAIN: // DEBUG_LOC_AGAIN |
// This record indicates that the last instruction is at the same |
// location as the previous instruction with a location. |
I = 0; |
@@ -2071,7 +2074,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
I = 0; |
continue; |
- case bitc::FUNC_CODE_DEBUG_LOC: { // DEBUG_LOC: [line, col, scope, ia] |
+ case naclbitc::FUNC_CODE_DEBUG_LOC: { // DEBUG_LOC: [line, col, scope, ia] |
I = 0; // Get the last instruction emitted. |
if (CurBB && !CurBB->empty()) |
I = &CurBB->back(); |
@@ -2093,7 +2096,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
continue; |
} |
- case bitc::FUNC_CODE_INST_BINOP: { // BINOP: [opval, ty, opval, opcode] |
+ case naclbitc::FUNC_CODE_INST_BINOP: { // BINOP: [opval, ty, opval, opcode] |
unsigned OpNum = 0; |
Value *LHS, *RHS; |
if (getValueTypePair(Record, OpNum, NextValueNo, LHS) || |
@@ -2110,15 +2113,15 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
Opc == Instruction::Sub || |
Opc == Instruction::Mul || |
Opc == Instruction::Shl) { |
- if (Record[OpNum] & (1 << bitc::OBO_NO_SIGNED_WRAP)) |
+ if (Record[OpNum] & (1 << naclbitc::OBO_NO_SIGNED_WRAP)) |
cast<BinaryOperator>(I)->setHasNoSignedWrap(true); |
- if (Record[OpNum] & (1 << bitc::OBO_NO_UNSIGNED_WRAP)) |
+ if (Record[OpNum] & (1 << naclbitc::OBO_NO_UNSIGNED_WRAP)) |
cast<BinaryOperator>(I)->setHasNoUnsignedWrap(true); |
} else if (Opc == Instruction::SDiv || |
Opc == Instruction::UDiv || |
Opc == Instruction::LShr || |
Opc == Instruction::AShr) { |
- if (Record[OpNum] & (1 << bitc::PEO_EXACT)) |
+ if (Record[OpNum] & (1 << naclbitc::PEO_EXACT)) |
cast<BinaryOperator>(I)->setIsExact(true); |
} else if (isa<FPMathOperator>(I)) { |
FastMathFlags FMF; |
@@ -2139,7 +2142,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
} |
break; |
} |
- case bitc::FUNC_CODE_INST_CAST: { // CAST: [opval, opty, destty, castopc] |
+ case naclbitc::FUNC_CODE_INST_CAST: { // CAST: [opval, opty, destty, castopc] |
unsigned OpNum = 0; |
Value *Op; |
if (getValueTypePair(Record, OpNum, NextValueNo, Op) || |
@@ -2154,8 +2157,8 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_INBOUNDS_GEP: |
- case bitc::FUNC_CODE_INST_GEP: { // GEP: [n x operands] |
+ case naclbitc::FUNC_CODE_INST_INBOUNDS_GEP: |
+ case naclbitc::FUNC_CODE_INST_GEP: { // GEP: [n x operands] |
unsigned OpNum = 0; |
Value *BasePtr; |
if (getValueTypePair(Record, OpNum, NextValueNo, BasePtr)) |
@@ -2171,12 +2174,12 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
I = GetElementPtrInst::Create(BasePtr, GEPIdx); |
InstructionList.push_back(I); |
- if (BitCode == bitc::FUNC_CODE_INST_INBOUNDS_GEP) |
+ if (BitCode == naclbitc::FUNC_CODE_INST_INBOUNDS_GEP) |
cast<GetElementPtrInst>(I)->setIsInBounds(true); |
break; |
} |
- case bitc::FUNC_CODE_INST_EXTRACTVAL: { |
+ case naclbitc::FUNC_CODE_INST_EXTRACTVAL: { |
// EXTRACTVAL: [opty, opval, n x indices] |
unsigned OpNum = 0; |
Value *Agg; |
@@ -2197,7 +2200,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_INSERTVAL: { |
+ case naclbitc::FUNC_CODE_INST_INSERTVAL: { |
// INSERTVAL: [opty, opval, opty, opval, n x indices] |
unsigned OpNum = 0; |
Value *Agg; |
@@ -2221,7 +2224,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_SELECT: { // SELECT: [opval, ty, opval, opval] |
+ case naclbitc::FUNC_CODE_INST_SELECT: { // SELECT: [opval, ty, opval, opval] |
// obsolete form of select |
// handles select i1 ... in old bitcode |
unsigned OpNum = 0; |
@@ -2236,7 +2239,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_VSELECT: {// VSELECT: [ty,opval,opval,predty,pred] |
+ case naclbitc::FUNC_CODE_INST_VSELECT: {// VSELECT: [ty,opval,opval,predty,pred] |
// new form of select |
// handles select i1 or select [N x i1] |
unsigned OpNum = 0; |
@@ -2263,7 +2266,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_EXTRACTELT: { // EXTRACTELT: [opty, opval, opval] |
+ case naclbitc::FUNC_CODE_INST_EXTRACTELT: { // EXTRACTELT: [opty, opval, opval] |
unsigned OpNum = 0; |
Value *Vec, *Idx; |
if (getValueTypePair(Record, OpNum, NextValueNo, Vec) || |
@@ -2274,7 +2277,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_INSERTELT: { // INSERTELT: [ty, opval,opval,opval] |
+ case naclbitc::FUNC_CODE_INST_INSERTELT: { // INSERTELT: [ty, opval,opval,opval] |
unsigned OpNum = 0; |
Value *Vec, *Elt, *Idx; |
if (getValueTypePair(Record, OpNum, NextValueNo, Vec) || |
@@ -2287,7 +2290,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_SHUFFLEVEC: {// SHUFFLEVEC: [opval,ty,opval,opval] |
+ case naclbitc::FUNC_CODE_INST_SHUFFLEVEC: {// SHUFFLEVEC: [opval,ty,opval,opval] |
unsigned OpNum = 0; |
Value *Vec1, *Vec2, *Mask; |
if (getValueTypePair(Record, OpNum, NextValueNo, Vec1) || |
@@ -2301,11 +2304,11 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_CMP: // CMP: [opty, opval, opval, pred] |
+ case naclbitc::FUNC_CODE_INST_CMP: // CMP: [opty, opval, opval, pred] |
// Old form of ICmp/FCmp returning bool |
// Existed to differentiate between icmp/fcmp and vicmp/vfcmp which were |
// both legal on vectors but had different behaviour. |
- case bitc::FUNC_CODE_INST_CMP2: { // CMP2: [opty, opval, opval, pred] |
+ case naclbitc::FUNC_CODE_INST_CMP2: { // CMP2: [opty, opval, opval, pred] |
// FCmp/ICmp returning bool or vector of bool |
unsigned OpNum = 0; |
@@ -2323,7 +2326,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>] |
+ case naclbitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>] |
{ |
unsigned Size = Record.size(); |
if (Size == 0) { |
@@ -2343,7 +2346,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_BR: { // BR: [bb#, bb#, opval] or [bb#] |
+ case naclbitc::FUNC_CODE_INST_BR: { // BR: [bb#, bb#, opval] or [bb#] |
if (Record.size() != 1 && Record.size() != 3) |
return Error("Invalid BR record"); |
BasicBlock *TrueDest = getBasicBlock(Record[0]); |
@@ -2365,7 +2368,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
} |
break; |
} |
- case bitc::FUNC_CODE_INST_SWITCH: { // SWITCH: [opty, op0, op1, ...] |
+ case naclbitc::FUNC_CODE_INST_SWITCH: { // SWITCH: [opty, op0, op1, ...] |
// Check magic |
if ((Record[0] >> 16) == SWITCH_INST_MAGIC) { |
// New SwitchInst format with case ranges. |
@@ -2448,7 +2451,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
I = SI; |
break; |
} |
- case bitc::FUNC_CODE_INST_INDIRECTBR: { // INDIRECTBR: [opty, op0, op1, ...] |
+ case naclbitc::FUNC_CODE_INST_INDIRECTBR: { // INDIRECTBR: [opty, op0, op1, ...] |
if (Record.size() < 2) |
return Error("Invalid INDIRECTBR record"); |
Type *OpTy = getTypeByID(Record[0]); |
@@ -2470,7 +2473,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_INVOKE: { |
+ case naclbitc::FUNC_CODE_INST_INVOKE: { |
// INVOKE: [attrs, cc, normBB, unwindBB, fnty, op0,op1,op2, ...] |
if (Record.size() < 4) return Error("Invalid INVOKE record"); |
AttributeSet PAL = getAttributes(Record[0]); |
@@ -2519,7 +2522,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
cast<InvokeInst>(I)->setAttributes(PAL); |
break; |
} |
- case bitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval] |
+ case naclbitc::FUNC_CODE_INST_RESUME: { // RESUME: [opval] |
unsigned Idx = 0; |
Value *Val = 0; |
if (getValueTypePair(Record, Idx, NextValueNo, Val)) |
@@ -2528,11 +2531,11 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_UNREACHABLE: // UNREACHABLE |
+ case naclbitc::FUNC_CODE_INST_UNREACHABLE: // UNREACHABLE |
I = new UnreachableInst(Context); |
InstructionList.push_back(I); |
break; |
- case bitc::FUNC_CODE_INST_PHI: { // PHI: [ty, val0,bb0, ...] |
+ case naclbitc::FUNC_CODE_INST_PHI: { // PHI: [ty, val0,bb0, ...] |
if (Record.size() < 1 || ((Record.size()-1)&1)) |
return Error("Invalid PHI record"); |
Type *Ty = getTypeByID(Record[0]); |
@@ -2558,7 +2561,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_LANDINGPAD: { |
+ case naclbitc::FUNC_CODE_INST_LANDINGPAD: { |
// LANDINGPAD: [ty, val, val, num, (id0,val0 ...)?] |
unsigned Idx = 0; |
if (Record.size() < 4) |
@@ -2597,7 +2600,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
break; |
} |
- case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align] |
+ case naclbitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align] |
if (Record.size() != 4) |
return Error("Invalid ALLOCA record"); |
PointerType *Ty = |
@@ -2610,7 +2613,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_LOAD: { // LOAD: [opty, op, align, vol] |
+ case naclbitc::FUNC_CODE_INST_LOAD: { // LOAD: [opty, op, align, vol] |
unsigned OpNum = 0; |
Value *Op; |
if (getValueTypePair(Record, OpNum, NextValueNo, Op) || |
@@ -2621,7 +2624,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_LOADATOMIC: { |
+ case naclbitc::FUNC_CODE_INST_LOADATOMIC: { |
// LOADATOMIC: [opty, op, align, vol, ordering, synchscope] |
unsigned OpNum = 0; |
Value *Op; |
@@ -2643,7 +2646,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_STORE: { // STORE2:[ptrty, ptr, val, align, vol] |
+ case naclbitc::FUNC_CODE_INST_STORE: { // STORE2:[ptrty, ptr, val, align, vol] |
unsigned OpNum = 0; |
Value *Val, *Ptr; |
if (getValueTypePair(Record, OpNum, NextValueNo, Ptr) || |
@@ -2656,7 +2659,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_STOREATOMIC: { |
+ case naclbitc::FUNC_CODE_INST_STOREATOMIC: { |
// STOREATOMIC: [ptrty, ptr, val, align, vol, ordering, synchscope] |
unsigned OpNum = 0; |
Value *Val, *Ptr; |
@@ -2679,7 +2682,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_CMPXCHG: { |
+ case naclbitc::FUNC_CODE_INST_CMPXCHG: { |
// CMPXCHG:[ptrty, ptr, cmp, new, vol, ordering, synchscope] |
unsigned OpNum = 0; |
Value *Ptr, *Cmp, *New; |
@@ -2699,7 +2702,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_ATOMICRMW: { |
+ case naclbitc::FUNC_CODE_INST_ATOMICRMW: { |
// ATOMICRMW:[ptrty, ptr, val, op, vol, ordering, synchscope] |
unsigned OpNum = 0; |
Value *Ptr, *Val; |
@@ -2721,7 +2724,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_FENCE: { // FENCE:[ordering, synchscope] |
+ case naclbitc::FUNC_CODE_INST_FENCE: { // FENCE:[ordering, synchscope] |
if (2 != Record.size()) |
return Error("Invalid FENCE record"); |
AtomicOrdering Ordering = GetDecodedOrdering(Record[0]); |
@@ -2733,7 +2736,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
InstructionList.push_back(I); |
break; |
} |
- case bitc::FUNC_CODE_INST_CALL: { |
+ case naclbitc::FUNC_CODE_INST_CALL: { |
// CALL: [paramattrs, cc, fnty, fnid, arg0, arg1...] |
if (Record.size() < 3) |
return Error("Invalid CALL record"); |
@@ -2784,7 +2787,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { |
cast<CallInst>(I)->setAttributes(PAL); |
break; |
} |
- case bitc::FUNC_CODE_INST_VAARG: { // VAARG: [valistty, valist, instty] |
+ case naclbitc::FUNC_CODE_INST_VAARG: { // VAARG: [valistty, valist, instty] |
if (Record.size() < 3) |
return Error("Invalid VAARG record"); |
Type *OpTy = getTypeByID(Record[0]); |
@@ -2863,7 +2866,7 @@ OutOfRecordLoop: |
} |
/// FindFunctionInStream - Find the function body in the bitcode stream |
-bool BitcodeReader::FindFunctionInStream(Function *F, |
+bool NaClBitcodeReader::FindFunctionInStream(Function *F, |
DenseMap<Function*, uint64_t>::iterator DeferredFunctionInfoIterator) { |
while (DeferredFunctionInfoIterator->second == 0) { |
if (Stream.AtEndOfStream()) |
@@ -2880,7 +2883,7 @@ bool BitcodeReader::FindFunctionInStream(Function *F, |
//===----------------------------------------------------------------------===// |
-bool BitcodeReader::isMaterializable(const GlobalValue *GV) const { |
+bool NaClBitcodeReader::isMaterializable(const GlobalValue *GV) const { |
if (const Function *F = dyn_cast<Function>(GV)) { |
return F->isDeclaration() && |
DeferredFunctionInfo.count(const_cast<Function*>(F)); |
@@ -2888,7 +2891,7 @@ bool BitcodeReader::isMaterializable(const GlobalValue *GV) const { |
return false; |
} |
-bool BitcodeReader::Materialize(GlobalValue *GV, std::string *ErrInfo) { |
+bool NaClBitcodeReader::Materialize(GlobalValue *GV, std::string *ErrInfo) { |
Function *F = dyn_cast<Function>(GV); |
// If it's not a function or is already material, ignore the request. |
if (!F || !F->isMaterializable()) return false; |
@@ -2923,7 +2926,7 @@ bool BitcodeReader::Materialize(GlobalValue *GV, std::string *ErrInfo) { |
return false; |
} |
-bool BitcodeReader::isDematerializable(const GlobalValue *GV) const { |
+bool NaClBitcodeReader::isDematerializable(const GlobalValue *GV) const { |
const Function *F = dyn_cast<Function>(GV); |
if (!F || F->isDeclaration()) |
return false; |
@@ -2940,7 +2943,7 @@ bool BitcodeReader::isDematerializable(const GlobalValue *GV) const { |
return DeferredFunctionInfo.count(const_cast<Function*>(F)); |
} |
-void BitcodeReader::Dematerialize(GlobalValue *GV) { |
+void NaClBitcodeReader::Dematerialize(GlobalValue *GV) { |
Function *F = dyn_cast<Function>(GV); |
// If this function isn't dematerializable, this is a noop. |
if (!F || !isDematerializable(F)) |
@@ -2953,9 +2956,9 @@ void BitcodeReader::Dematerialize(GlobalValue *GV) { |
} |
-bool BitcodeReader::MaterializeModule(Module *M, std::string *ErrInfo) { |
+bool NaClBitcodeReader::MaterializeModule(Module *M, std::string *ErrInfo) { |
assert(M == TheModule && |
- "Can only Materialize the Module this BitcodeReader is attached to."); |
+ "Can only Materialize the Module this NaClBitcodeReader is attached to."); |
// Iterate over the module, deserializing any functions that are still on |
// disk. |
for (Module::iterator F = TheModule->begin(), E = TheModule->end(); |
@@ -2992,17 +2995,18 @@ bool BitcodeReader::MaterializeModule(Module *M, std::string *ErrInfo) { |
return false; |
} |
-bool BitcodeReader::InitStream() { |
+bool NaClBitcodeReader::InitStream() { |
if (LazyStreamer) return InitLazyStream(); |
return InitStreamFromBuffer(); |
} |
-bool BitcodeReader::InitStreamFromBuffer() { |
+bool NaClBitcodeReader::InitStreamFromBuffer() { |
const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart(); |
const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); |
if (Buffer->getBufferSize() & 3) { |
- if (!isRawBitcode(BufPtr, BufEnd) && !isBitcodeWrapper(BufPtr, BufEnd)) |
+ if (!isNaClRawBitcode(BufPtr, BufEnd) && |
+ !isNaClBitcodeWrapper(BufPtr, BufEnd)) |
return Error("Invalid bitcode signature"); |
else |
return Error("Bitcode stream should be a multiple of 4 bytes in length"); |
@@ -3010,34 +3014,34 @@ bool BitcodeReader::InitStreamFromBuffer() { |
// If we have a wrapper header, parse it and ignore the non-bc file contents. |
// The magic number is 0x0B17C0DE stored in little endian. |
- if (isBitcodeWrapper(BufPtr, BufEnd)) |
- if (SkipBitcodeWrapperHeader(BufPtr, BufEnd, true)) |
+ if (isNaClBitcodeWrapper(BufPtr, BufEnd)) |
+ if (SkipNaClBitcodeWrapperHeader(BufPtr, BufEnd, true)) |
return Error("Invalid bitcode wrapper header"); |
- StreamFile.reset(new BitstreamReader(BufPtr, BufEnd)); |
+ StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd)); |
Stream.init(*StreamFile); |
return false; |
} |
-bool BitcodeReader::InitLazyStream() { |
- // Check and strip off the bitcode wrapper; BitstreamReader expects never to |
- // see it. |
+bool NaClBitcodeReader::InitLazyStream() { |
+ // Check and strip off the bitcode wrapper; NaClBitstreamReader expects |
+ // never to see it. |
StreamingMemoryObject *Bytes = new StreamingMemoryObject(LazyStreamer); |
- StreamFile.reset(new BitstreamReader(Bytes)); |
+ StreamFile.reset(new NaClBitstreamReader(Bytes)); |
Stream.init(*StreamFile); |
unsigned char buf[16]; |
if (Bytes->readBytes(0, 16, buf, NULL) == -1) |
return Error("Bitcode stream must be at least 16 bytes in length"); |
- if (!isBitcode(buf, buf + 16)) |
+ if (!isNaClBitcode(buf, buf + 16)) |
return Error("Invalid bitcode signature"); |
- if (isBitcodeWrapper(buf, buf + 4)) { |
+ if (isNaClBitcodeWrapper(buf, buf + 4)) { |
const unsigned char *bitcodeStart = buf; |
const unsigned char *bitcodeEnd = buf + 16; |
- SkipBitcodeWrapperHeader(bitcodeStart, bitcodeEnd, false); |
+ SkipNaClBitcodeWrapperHeader(bitcodeStart, bitcodeEnd, false); |
Bytes->dropLeadingBytes(bitcodeStart - buf); |
Bytes->setKnownObjectSize(bitcodeEnd - bitcodeStart); |
} |
@@ -3048,13 +3052,13 @@ bool BitcodeReader::InitLazyStream() { |
// External interface |
//===----------------------------------------------------------------------===// |
-/// getLazyBitcodeModule - lazy function-at-a-time loading from a file. |
+/// getNaClLazyBitcodeModule - lazy function-at-a-time loading from a file. |
/// |
-Module *llvm::getLazyBitcodeModule(MemoryBuffer *Buffer, |
- LLVMContext& Context, |
- std::string *ErrMsg) { |
+Module *llvm::getNaClLazyBitcodeModule(MemoryBuffer *Buffer, |
+ LLVMContext& Context, |
+ std::string *ErrMsg) { |
Module *M = new Module(Buffer->getBufferIdentifier(), Context); |
- BitcodeReader *R = new BitcodeReader(Buffer, Context); |
+ NaClBitcodeReader *R = new NaClBitcodeReader(Buffer, Context); |
M->setMaterializer(R); |
if (R->ParseBitcodeInto(M)) { |
if (ErrMsg) |
@@ -3063,7 +3067,7 @@ Module *llvm::getLazyBitcodeModule(MemoryBuffer *Buffer, |
delete M; // Also deletes R. |
return 0; |
} |
- // Have the BitcodeReader dtor delete 'Buffer'. |
+ // Have the NaClBitcodeReader dtor delete 'Buffer'. |
R->setBufferOwned(true); |
R->materializeForwardReferencedFunctions(); |
@@ -3074,12 +3078,12 @@ Module *llvm::getLazyBitcodeModule(MemoryBuffer *Buffer, |
} |
-Module *llvm::getStreamedBitcodeModule(const std::string &name, |
- DataStreamer *streamer, |
- LLVMContext &Context, |
- std::string *ErrMsg) { |
+Module *llvm::getNaClStreamedBitcodeModule(const std::string &name, |
+ DataStreamer *streamer, |
+ LLVMContext &Context, |
+ std::string *ErrMsg) { |
Module *M = new Module(name, Context); |
- BitcodeReader *R = new BitcodeReader(streamer, Context); |
+ NaClBitcodeReader *R = new NaClBitcodeReader(streamer, Context); |
M->setMaterializer(R); |
if (R->ParseBitcodeInto(M)) { |
if (ErrMsg) |
@@ -3096,18 +3100,18 @@ Module *llvm::getStreamedBitcodeModule(const std::string &name, |
return M; |
} |
-/// ParseBitcodeFile - Read the specified bitcode file, returning the module. |
+/// NaClParseBitcodeFile - Read the specified bitcode file, returning the module. |
/// If an error occurs, return null and fill in *ErrMsg if non-null. |
-Module *llvm::ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext& Context, |
- std::string *ErrMsg){ |
- Module *M = getLazyBitcodeModule(Buffer, Context, ErrMsg); |
+Module *llvm::NaClParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext& Context, |
+ std::string *ErrMsg){ |
+ Module *M = getNaClLazyBitcodeModule(Buffer, Context, ErrMsg); |
if (!M) return 0; |
- // Don't let the BitcodeReader dtor delete 'Buffer', regardless of whether |
+ // Don't let the NaClBitcodeReader dtor delete 'Buffer', regardless of whether |
// there was an error. |
- static_cast<BitcodeReader*>(M->getMaterializer())->setBufferOwned(false); |
+ static_cast<NaClBitcodeReader*>(M->getMaterializer())->setBufferOwned(false); |
- // Read in the entire module, and destroy the BitcodeReader. |
+ // Read in the entire module, and destroy the NaClBitcodeReader. |
if (M->MaterializeAllPermanently(ErrMsg)) { |
delete M; |
return 0; |
@@ -3118,19 +3122,3 @@ Module *llvm::ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext& Context, |
return M; |
} |
- |
-std::string llvm::getBitcodeTargetTriple(MemoryBuffer *Buffer, |
- LLVMContext& Context, |
- std::string *ErrMsg) { |
- BitcodeReader *R = new BitcodeReader(Buffer, Context); |
- // Don't let the BitcodeReader dtor delete 'Buffer'. |
- R->setBufferOwned(false); |
- |
- std::string Triple(""); |
- if (R->ParseTriple(Triple)) |
- if (ErrMsg) |
- *ErrMsg = R->getErrorString(); |
- |
- delete R; |
- return Triple; |
-} |