[llvm-branch-commits] [llvm-branch] r133586 - in /llvm/branches/type-system-rewrite: include/llvm/Bitcode/LLVMBitCodes.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Chris Lattner
sabre at nondot.org
Tue Jun 21 17:18:42 PDT 2011
Author: lattner
Date: Tue Jun 21 19:18:42 2011
New Revision: 133586
URL: http://llvm.org/viewvc/llvm-project?rev=133586&view=rev
Log:
add support for round tripping "opaque" through bitcode, don't translate it to {}
Modified:
llvm/branches/type-system-rewrite/include/llvm/Bitcode/LLVMBitCodes.h
llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/branches/type-system-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/branches/type-system-rewrite/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
Modified: llvm/branches/type-system-rewrite/include/llvm/Bitcode/LLVMBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/include/llvm/Bitcode/LLVMBitCodes.h?rev=133586&r1=133585&r2=133586&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/include/llvm/Bitcode/LLVMBitCodes.h (original)
+++ llvm/branches/type-system-rewrite/include/llvm/Bitcode/LLVMBitCodes.h Tue Jun 21 19:18:42 2011
@@ -89,7 +89,7 @@
TYPE_CODE_FLOAT = 3, // FLOAT
TYPE_CODE_DOUBLE = 4, // DOUBLE
TYPE_CODE_LABEL = 5, // LABEL
- TYPE_CODE_OPAQUE_OLD = 6, // OPAQUE
+ TYPE_CODE_OPAQUE = 6, // OPAQUE
TYPE_CODE_INTEGER = 7, // INTEGER: [width]
TYPE_CODE_POINTER = 8, // POINTER: [pointee type]
TYPE_CODE_FUNCTION = 9, // FUNCTION: [vararg, retty, paramty x N]
Modified: llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp?rev=133586&r1=133585&r2=133586&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jun 21 19:18:42 2011
@@ -597,7 +597,7 @@
return Error("Invalid STRUCT_NAME record");
continue;
- case bitc::TYPE_CODE_STRUCT_NAMED: { // STRUCT: [ispacked, eltty x N]
+ case bitc::TYPE_CODE_STRUCT_NAMED: { // STRUCT: [ispacked, eltty x N]
if (Record.size() < 1)
return Error("Invalid STRUCT type record");
@@ -620,6 +620,24 @@
ResultTy = Res;
break;
}
+ case bitc::TYPE_CODE_OPAQUE: { // OPAQUE: []
+ if (Record.size() != 1)
+ return Error("Invalid OPAQUE type record");
+
+ if (NumRecords >= TypeList.size())
+ return Error("invalid TYPE table");
+
+ // Check to see if this was forward referenced, if so fill in the temp.
+ StructType *Res = cast_or_null<StructType>(TypeList[NumRecords]);
+ if (Res) {
+ Res->setName(TypeName);
+ TypeList[NumRecords] = 0;
+ } else // Otherwise, create a new struct with no body.
+ Res = StructType::createNamed(Context, TypeName);
+ TypeName.clear();
+ ResultTy = Res;
+ break;
+ }
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
if (Record.size() < 2)
return Error("Invalid ARRAY type record");
Modified: llvm/branches/type-system-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=133586&r1=133585&r2=133586&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Jun 21 19:18:42 2011
@@ -271,8 +271,12 @@
Code = bitc::TYPE_CODE_STRUCT_ANON;
AbbrevToUse = StructAnonAbbrev;
} else {
- Code = bitc::TYPE_CODE_STRUCT_NAMED;
- AbbrevToUse = StructNamedAbbrev;
+ if (ST->isOpaque()) {
+ Code = bitc::TYPE_CODE_OPAQUE;
+ } else {
+ Code = bitc::TYPE_CODE_STRUCT_NAMED;
+ AbbrevToUse = StructNamedAbbrev;
+ }
// Emit the name if it is present.
if (!ST->getName().empty())
Modified: llvm/branches/type-system-rewrite/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp?rev=133586&r1=133585&r2=133586&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp (original)
+++ llvm/branches/type-system-rewrite/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp Tue Jun 21 19:18:42 2011
@@ -172,7 +172,7 @@
case bitc::TYPE_CODE_FLOAT: return "FLOAT";
case bitc::TYPE_CODE_DOUBLE: return "DOUBLE";
case bitc::TYPE_CODE_LABEL: return "LABEL";
- case bitc::TYPE_CODE_OPAQUE_OLD: return "OPAQUE_OLD";
+ case bitc::TYPE_CODE_OPAQUE: return "OPAQUE";
case bitc::TYPE_CODE_INTEGER: return "INTEGER";
case bitc::TYPE_CODE_POINTER: return "POINTER";
case bitc::TYPE_CODE_FUNCTION: return "FUNCTION";
More information about the llvm-branch-commits
mailing list