forked from OSchip/llvm-project
Remove some cruft from the BitcodeWriter, while still maintaining backward
compatibility in the BitcodeReader. llvm-svn: 143598
This commit is contained in:
parent
756ce7f9ab
commit
9589872af9
|
@ -92,7 +92,7 @@ namespace bitc {
|
||||||
TYPE_CODE_OPAQUE = 6, // OPAQUE
|
TYPE_CODE_OPAQUE = 6, // OPAQUE
|
||||||
TYPE_CODE_INTEGER = 7, // INTEGER: [width]
|
TYPE_CODE_INTEGER = 7, // INTEGER: [width]
|
||||||
TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
|
TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
|
||||||
TYPE_CODE_FUNCTION = 9, // FUNCTION: [vararg, retty, paramty x N]
|
TYPE_CODE_FUNCTION_OLD = 9, // FUNCTION: [vararg, attrid, retty, paramty x N]
|
||||||
|
|
||||||
// FIXME: This is the encoding used for structs in LLVM 2.9 and earlier.
|
// FIXME: This is the encoding used for structs in LLVM 2.9 and earlier.
|
||||||
// REMOVE this in LLVM 3.1
|
// REMOVE this in LLVM 3.1
|
||||||
|
@ -113,7 +113,9 @@ namespace bitc {
|
||||||
|
|
||||||
TYPE_CODE_STRUCT_ANON = 18, // STRUCT_ANON: [ispacked, eltty x N]
|
TYPE_CODE_STRUCT_ANON = 18, // STRUCT_ANON: [ispacked, eltty x N]
|
||||||
TYPE_CODE_STRUCT_NAME = 19, // STRUCT_NAME: [strchr x N]
|
TYPE_CODE_STRUCT_NAME = 19, // STRUCT_NAME: [strchr x N]
|
||||||
TYPE_CODE_STRUCT_NAMED = 20 // STRUCT_NAMED: [ispacked, eltty x N]
|
TYPE_CODE_STRUCT_NAMED = 20,// STRUCT_NAMED: [ispacked, eltty x N]
|
||||||
|
|
||||||
|
TYPE_CODE_FUNCTION = 21 // FUNCTION: [vararg, retty, paramty x N]
|
||||||
};
|
};
|
||||||
|
|
||||||
// The type symbol table only has one code (TST_ENTRY_CODE).
|
// The type symbol table only has one code (TST_ENTRY_CODE).
|
||||||
|
|
|
@ -615,7 +615,7 @@ bool BitcodeReader::ParseTypeTableBody() {
|
||||||
ResultTy = PointerType::get(ResultTy, AddressSpace);
|
ResultTy = PointerType::get(ResultTy, AddressSpace);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case bitc::TYPE_CODE_FUNCTION: {
|
case bitc::TYPE_CODE_FUNCTION_OLD: {
|
||||||
// FIXME: attrid is dead, remove it in LLVM 3.0
|
// FIXME: attrid is dead, remove it in LLVM 3.0
|
||||||
// FUNCTION: [vararg, attrid, retty, paramty x N]
|
// FUNCTION: [vararg, attrid, retty, paramty x N]
|
||||||
if (Record.size() < 3)
|
if (Record.size() < 3)
|
||||||
|
@ -635,6 +635,25 @@ bool BitcodeReader::ParseTypeTableBody() {
|
||||||
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case bitc::TYPE_CODE_FUNCTION: {
|
||||||
|
// FUNCTION: [vararg, retty, paramty x N]
|
||||||
|
if (Record.size() < 2)
|
||||||
|
return Error("Invalid FUNCTION type record");
|
||||||
|
std::vector<Type*> ArgTys;
|
||||||
|
for (unsigned i = 2, e = Record.size(); i != e; ++i) {
|
||||||
|
if (Type *T = getTypeByID(Record[i]))
|
||||||
|
ArgTys.push_back(T);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultTy = getTypeByID(Record[1]);
|
||||||
|
if (ResultTy == 0 || ArgTys.size() < Record.size()-2)
|
||||||
|
return Error("invalid type in function type");
|
||||||
|
|
||||||
|
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case bitc::TYPE_CODE_STRUCT_ANON: { // STRUCT: [ispacked, eltty x N]
|
case bitc::TYPE_CODE_STRUCT_ANON: { // STRUCT: [ispacked, eltty x N]
|
||||||
if (Record.size() < 1)
|
if (Record.size() < 1)
|
||||||
return Error("Invalid STRUCT type record");
|
return Error("Invalid STRUCT type record");
|
||||||
|
@ -871,7 +890,7 @@ RestartScan:
|
||||||
ResultTy = PointerType::get(ResultTy, AddressSpace);
|
ResultTy = PointerType::get(ResultTy, AddressSpace);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case bitc::TYPE_CODE_FUNCTION: {
|
case bitc::TYPE_CODE_FUNCTION_OLD: {
|
||||||
// FIXME: attrid is dead, remove it in LLVM 3.0
|
// FIXME: attrid is dead, remove it in LLVM 3.0
|
||||||
// FUNCTION: [vararg, attrid, retty, paramty x N]
|
// FUNCTION: [vararg, attrid, retty, paramty x N]
|
||||||
if (Record.size() < 3)
|
if (Record.size() < 3)
|
||||||
|
@ -889,6 +908,23 @@ RestartScan:
|
||||||
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case bitc::TYPE_CODE_FUNCTION: {
|
||||||
|
// FUNCTION: [vararg, retty, paramty x N]
|
||||||
|
if (Record.size() < 2)
|
||||||
|
return Error("Invalid FUNCTION type record");
|
||||||
|
std::vector<Type*> ArgTys;
|
||||||
|
for (unsigned i = 2, e = Record.size(); i != e; ++i) {
|
||||||
|
if (Type *Elt = getTypeByIDOrNull(Record[i]))
|
||||||
|
ArgTys.push_back(Elt);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ArgTys.size()+2 != Record.size())
|
||||||
|
break; // Something was null.
|
||||||
|
if ((ResultTy = getTypeByIDOrNull(Record[1])))
|
||||||
|
ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
|
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
|
||||||
if (Record.size() < 2)
|
if (Record.size() < 2)
|
||||||
return Error("Invalid ARRAY type record");
|
return Error("Invalid ARRAY type record");
|
||||||
|
|
|
@ -206,7 +206,6 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
|
||||||
Abbv = new BitCodeAbbrev();
|
Abbv = new BitCodeAbbrev();
|
||||||
Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_FUNCTION));
|
Abbv->Add(BitCodeAbbrevOp(bitc::TYPE_CODE_FUNCTION));
|
||||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg
|
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isvararg
|
||||||
Abbv->Add(BitCodeAbbrevOp(0)); // FIXME: DEAD value, remove in LLVM 3.0
|
|
||||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
|
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
|
||||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
|
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
|
||||||
Log2_32_Ceil(VE.getTypes().size()+1)));
|
Log2_32_Ceil(VE.getTypes().size()+1)));
|
||||||
|
@ -284,10 +283,9 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) {
|
||||||
}
|
}
|
||||||
case Type::FunctionTyID: {
|
case Type::FunctionTyID: {
|
||||||
FunctionType *FT = cast<FunctionType>(T);
|
FunctionType *FT = cast<FunctionType>(T);
|
||||||
// FUNCTION: [isvararg, attrid, retty, paramty x N]
|
// FUNCTION: [isvararg, retty, paramty x N]
|
||||||
Code = bitc::TYPE_CODE_FUNCTION;
|
Code = bitc::TYPE_CODE_FUNCTION;
|
||||||
TypeVals.push_back(FT->isVarArg());
|
TypeVals.push_back(FT->isVarArg());
|
||||||
TypeVals.push_back(0); // FIXME: DEAD: remove in llvm 3.0
|
|
||||||
TypeVals.push_back(VE.getTypeID(FT->getReturnType()));
|
TypeVals.push_back(VE.getTypeID(FT->getReturnType()));
|
||||||
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
|
for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
|
||||||
TypeVals.push_back(VE.getTypeID(FT->getParamType(i)));
|
TypeVals.push_back(VE.getTypeID(FT->getParamType(i)));
|
||||||
|
|
|
@ -175,7 +175,7 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
|
||||||
case bitc::TYPE_CODE_OPAQUE: return "OPAQUE";
|
case bitc::TYPE_CODE_OPAQUE: return "OPAQUE";
|
||||||
case bitc::TYPE_CODE_INTEGER: return "INTEGER";
|
case bitc::TYPE_CODE_INTEGER: return "INTEGER";
|
||||||
case bitc::TYPE_CODE_POINTER: return "POINTER";
|
case bitc::TYPE_CODE_POINTER: return "POINTER";
|
||||||
case bitc::TYPE_CODE_FUNCTION: return "FUNCTION";
|
case bitc::TYPE_CODE_FUNCTION_OLD: return "FUNCTION_OLD";
|
||||||
case bitc::TYPE_CODE_STRUCT_OLD: return "STRUCT_OLD";
|
case bitc::TYPE_CODE_STRUCT_OLD: return "STRUCT_OLD";
|
||||||
case bitc::TYPE_CODE_ARRAY: return "ARRAY";
|
case bitc::TYPE_CODE_ARRAY: return "ARRAY";
|
||||||
case bitc::TYPE_CODE_VECTOR: return "VECTOR";
|
case bitc::TYPE_CODE_VECTOR: return "VECTOR";
|
||||||
|
@ -186,6 +186,7 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID,
|
||||||
case bitc::TYPE_CODE_STRUCT_ANON: return "STRUCT_ANON";
|
case bitc::TYPE_CODE_STRUCT_ANON: return "STRUCT_ANON";
|
||||||
case bitc::TYPE_CODE_STRUCT_NAME: return "STRUCT_NAME";
|
case bitc::TYPE_CODE_STRUCT_NAME: return "STRUCT_NAME";
|
||||||
case bitc::TYPE_CODE_STRUCT_NAMED: return "STRUCT_NAMED";
|
case bitc::TYPE_CODE_STRUCT_NAMED: return "STRUCT_NAMED";
|
||||||
|
case bitc::TYPE_CODE_FUNCTION: return "FUNCTION";
|
||||||
}
|
}
|
||||||
|
|
||||||
case bitc::CONSTANTS_BLOCK_ID:
|
case bitc::CONSTANTS_BLOCK_ID:
|
||||||
|
|
Loading…
Reference in New Issue