Implement internal method support
authorChris Lattner <sabre@nondot.org>
Mon, 26 Nov 2001 18:56:10 +0000 (18:56 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 26 Nov 2001 18:56:10 +0000 (18:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1374 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/ConstantReader.cpp
lib/Bytecode/Reader/Reader.cpp
lib/Bytecode/Reader/ReaderInternals.h
lib/Bytecode/Writer/Writer.cpp

index ec39a9f64c7cc8e26cebcd704dddddfb6dcb84c3..405745d14adb806e9686c04d147a5b79f1638f52 100644 (file)
@@ -306,7 +306,8 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
          BCR_TRACE(5, "Creating new forward ref variable!\n");
 
          // Create a placeholder for the global variable reference...
-         GlobalVariable *GVar = new GlobalVariable(PT->getValueType(), false);
+         GlobalVariable *GVar =
+           new GlobalVariable(PT->getValueType(), false, true);
 
          // Keep track of the fact that we have a forward ref to recycle it
          GlobalRefs.insert(make_pair(make_pair(PT, Slot), GVar));
index a076bffb3a2c72830272734606d0ab7580afcf9d..7f02b9339f83375d5bb6fade212a4b38c71860d2 100644 (file)
@@ -265,9 +265,12 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
   const MethodType  *MTy  = dyn_cast<const MethodType>(PMTy->getValueType());
   if (MTy == 0) return failure(true);  // Not ptr to method!
 
+  unsigned isInternal;
+  if (read_vbr(Buf, EndBuf, isInternal)) return failure(true);
+
   unsigned MethSlot = MethodSignatureList.front().second;
   MethodSignatureList.pop_front();
-  Method *M = new Method(MTy);
+  Method *M = new Method(MTy, isInternal != 0);
 
   BCR_TRACE(2, "METHOD TYPE: " << MTy << endl);
 
@@ -380,8 +383,9 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
   unsigned VarType;
   if (read_vbr(Buf, End, VarType)) return failure(true);
   while (VarType != Type::VoidTyID) { // List is terminated by Void
-    // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2+ = slot#
-    const Type *Ty = getType(VarType >> 2);
+    // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
+    // bit2 = isInternal, bit3+ = slot#
+    const Type *Ty = getType(VarType >> 3);
     if (!Ty || !Ty->isPointerType()) { 
       Error = "Global not pointer type!  Ty = " + Ty->getDescription();
       return failure(true); 
@@ -404,7 +408,8 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
     }
 
     // Create the global variable...
-    GlobalVariable *GV = new GlobalVariable(ElTy, VarType & 1, Initializer);
+    GlobalVariable *GV = new GlobalVariable(ElTy, VarType & 1, VarType & 4,
+                                           Initializer);
     int DestSlot = insertValue(GV, ModuleValues);
     if (DestSlot == -1) return failure(true);
 
index 50eed193939410f9fe54dadbbe6a4ea78d4dbe89..fb34169d79501e5843bd1d2d6bd93cff707289aa 100644 (file)
@@ -149,7 +149,7 @@ struct BBPlaceHolderHelper : public BasicBlock {
 
 struct MethPlaceHolderHelper : public Method {
   MethPlaceHolderHelper(const Type *Ty) 
-    : Method(cast<const MethodType>(Ty)) {
+    : Method(cast<const MethodType>(Ty), true) {
   }
 };
 
index d0b2eb40b050f03f4bfecbb64c32dd594ef69b2a..c8ce40ba62217827cf62b74977f543a04afe9918 100644 (file)
@@ -121,9 +121,10 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
     int Slot = Table.getValSlot(GV->getType());
     assert(Slot != -1 && "Module global vars is broken!");
 
-    // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2+ = slot#
-    unsigned oSlot = ((unsigned)Slot << 2) | (GV->hasInitializer() << 1) | 
-                        GV->isConstant();
+    // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2=InternalLinkage,
+    // bit3+ = slot#
+    unsigned oSlot = ((unsigned)Slot << 3) | (GV->hasInternalLinkage() << 2) |
+                     (GV->hasInitializer() << 1) | GV->isConstant();
     output_vbr(oSlot, Out);
 
     // If we have an initializer, output it now.
@@ -150,9 +151,10 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
 
 void BytecodeWriter::processMethod(const Method *M) {
   BytecodeBlock MethodBlock(BytecodeFormat::Method, Out);
-
+  output_vbr((unsigned)M->hasInternalLinkage(), Out);
   // Only output the constant pool and other goodies if needed...
   if (!M->isExternal()) {
+
     // Get slot information about the method...
     Table.incorporateMethod(M);