summaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-30 22:46:54 +0000
committerChris Lattner <sabre@nondot.org>2001-09-30 22:46:54 +0000
commit1a1cb111fe9081cab4d666338c547253c4a437c9 (patch)
tree3f63e2d30ad41c283b1eab098b0afab00bd76d6e /lib/Bytecode
parent4cfb15331652f9a2f7e5f755485a2f6eb87a20c6 (diff)
downloadllvm-1a1cb111fe9081cab4d666338c547253c4a437c9.tar.gz
llvm-1a1cb111fe9081cab4d666338c547253c4a437c9.tar.bz2
llvm-1a1cb111fe9081cab4d666338c547253c4a437c9.tar.xz
Implement constant pointers, and null specifically in the parser, bytecode writer, and
bytecode reader. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Reader/ConstantReader.cpp13
-rw-r--r--lib/Bytecode/Writer/ConstantWriter.cpp5
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index baa367d52b..ae206daa37 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -250,7 +250,7 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
}
case Type::StructTyID: {
- const StructType *ST = (const StructType*)Ty;
+ const StructType *ST = Ty->castStructType();
const StructType::ElementTypes &ET = ST->getElementTypes();
vector<ConstPoolVal *> Elements;
@@ -267,6 +267,17 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
break;
}
+ case Type::PointerTyID: {
+ const PointerType *PT = Ty->castPointerType();
+ unsigned SubClass;
+ if (read_vbr(Buf, EndBuf, SubClass)) return failure(true);
+ if (SubClass != 0) return failure(true);
+
+
+ V = ConstPoolPointer::getNullPointer(PT);
+ break;
+ }
+
default:
cerr << __FILE__ << ":" << __LINE__
<< ": Don't know how to deserialize constant value of type '"
diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp
index 24ceaecf2e..dde47d52b1 100644
--- a/lib/Bytecode/Writer/ConstantWriter.cpp
+++ b/lib/Bytecode/Writer/ConstantWriter.cpp
@@ -141,6 +141,11 @@ bool BytecodeWriter::outputConstant(const ConstPoolVal *CPV) {
break;
}
+ case Type::PointerTyID: {
+ output_vbr((unsigned)0, Out);
+ break;
+ }
+
case Type::FloatTyID: { // Floating point types...
float Tmp = (float)((const ConstPoolFP*)CPV)->getValue();
output_data(&Tmp, &Tmp+1, Out);