summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-10 07:58:01 +0000
committerChris Lattner <sabre@nondot.org>2001-09-10 07:58:01 +0000
commitda9755002f3ab593b745dd055f4c3ff1ad66aac7 (patch)
treea778381d84adcc740d5211ce9894bdce55d40532 /llvm/lib/Bytecode/Reader/Reader.cpp
parentbaf08eb2a7845d48a0945f26a3bd80098f63a116 (diff)
downloadbcm5719-llvm-da9755002f3ab593b745dd055f4c3ff1ad66aac7.tar.gz
bcm5719-llvm-da9755002f3ab593b745dd055f4c3ff1ad66aac7.zip
Implement global variable support
llvm-svn: 530
Diffstat (limited to 'llvm/lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/Reader.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp
index 540768383ac..eab576e541b 100644
--- a/llvm/lib/Bytecode/Reader/Reader.cpp
+++ b/llvm/lib/Bytecode/Reader/Reader.cpp
@@ -12,6 +12,7 @@
#include "llvm/Bytecode/Reader.h"
#include "llvm/Bytecode/Format.h"
+#include "llvm/GlobalVariable.h"
#include "llvm/Module.h"
#include "llvm/BasicBlock.h"
#include "llvm/DerivedTypes.h"
@@ -312,10 +313,28 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
Module *C) {
-
if (!MethodSignatureList.empty())
return failure(true); // Two ModuleGlobal blocks?
+ // Read global variables...
+ unsigned VarType;
+ if (read_vbr(Buf, End, VarType)) return failure(true);
+ while (VarType != Type::VoidTyID) { // List is terminated by Void
+ const Type *Ty = getType(VarType);
+ if (!Ty || !Ty->isPointerType()) {
+ cerr << "Global not pointer type! Ty = " << Ty << endl;
+ return failure(true);
+ }
+
+ // Create the global variable...
+ GlobalVariable *GV = new GlobalVariable(Ty);
+ insertValue(GV, ModuleValues);
+ C->getGlobalList().push_back(GV);
+
+ if (read_vbr(Buf, End, VarType)) return failure(true);
+ BCR_TRACE(2, "Global Variable of type: " << Ty->getDescription() << endl);
+ }
+
// Read the method signatures for all of the methods that are coming, and
// create fillers in the Value tables.
unsigned MethSignature;
@@ -324,7 +343,6 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
const Type *Ty = getType(MethSignature);
if (!Ty || !Ty->isMethodType()) {
cerr << "Method not meth type! Ty = " << Ty << endl;
- if (Ty) cerr << Ty->getName(); else cerr << MethSignature; cerr << endl;
return failure(true);
}
OpenPOWER on IntegriCloud