[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Oct 16 13:32:10 PDT 2003


Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.82 -> 1.83

---
Log message:

Add support for 'weak' linkage.

For now, we translate linkonce into weak linkage in the bytecode format because
we don't have enough bits to represent it.  We will rev the bytecode version 
soon anyways, so this will be fixed in the near future.



---
Diffs of the changes:  (+12 -2)

Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.82 llvm/lib/Bytecode/Reader/Reader.cpp:1.83
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.82	Mon Oct 13 09:57:53 2003
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Thu Oct 16 13:28:47 2003
@@ -318,7 +318,12 @@
       throw std::string("ParseFunction: Error reading from buffer.");
     if (LinkageType & ~0x3) 
       throw std::string("Invalid linkage type for Function.");
-    Linkage = (GlobalValue::LinkageTypes)LinkageType;
+    switch (LinkageType) {
+    case 0: Linkage = GlobalValue::ExternalLinkage; break;
+    case 1: Linkage = GlobalValue::WeakLinkage; break;
+    case 2: Linkage = GlobalValue::AppendingLinkage; break;
+    case 3: Linkage = GlobalValue::InternalLinkage; break;
+    }
   } else {
     // We used to only support two linkage models: internal and external
     unsigned isInternal;
@@ -436,7 +441,12 @@
       // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
       // bit2,3 = Linkage, bit4+ = slot#
       SlotNo = VarType >> 4;
-      Linkage = (GlobalValue::LinkageTypes)((VarType >> 2) & 3);
+      switch ((VarType >> 2) & 3) {
+      case 0: Linkage = GlobalValue::ExternalLinkage;  break;
+      case 1: Linkage = GlobalValue::WeakLinkage;      break;
+      case 2: Linkage = GlobalValue::AppendingLinkage; break;
+      case 3: Linkage = GlobalValue::InternalLinkage;  break;
+      }
     } else {
       // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
       // bit2 = isInternal, bit3+ = slot#





More information about the llvm-commits mailing list