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

Anton Korobeynikov asl at math.spbu.ru
Thu Sep 14 11:24:07 PDT 2006



Changes in directory llvm/lib/Bytecode/Writer:

Writer.cpp updated: 1.123 -> 1.124
---
Log message:

Adding dllimport, dllexport and external weak linkage types.
DLL* linkages got full (I hope) codegeneration support in C & both x86 
assembler backends.
External weak linkage added for future use, we don't provide any 
codegeneration, etc. support for it.


---
Diffs of the changes:  (+26 -9)

 Writer.cpp |   35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)


Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.123 llvm/lib/Bytecode/Writer/Writer.cpp:1.124
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.123	Fri Jul 28 17:07:54 2006
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Thu Sep 14 13:23:26 2006
@@ -938,11 +938,14 @@
 static unsigned getEncodedLinkage(const GlobalValue *GV) {
   switch (GV->getLinkage()) {
   default: assert(0 && "Invalid linkage!");
-  case GlobalValue::ExternalLinkage:  return 0;
-  case GlobalValue::WeakLinkage:      return 1;
-  case GlobalValue::AppendingLinkage: return 2;
-  case GlobalValue::InternalLinkage:  return 3;
-  case GlobalValue::LinkOnceLinkage:  return 4;
+  case GlobalValue::ExternalLinkage:     return 0;
+  case GlobalValue::WeakLinkage:         return 1;
+  case GlobalValue::AppendingLinkage:    return 2;
+  case GlobalValue::InternalLinkage:     return 3;
+  case GlobalValue::LinkOnceLinkage:     return 4;
+  case GlobalValue::DLLImportLinkage:    return 5;
+  case GlobalValue::DLLExportLinkage:    return 6;
+  case GlobalValue::ExternalWeakLinkage: return 7;
   }
 }
 
@@ -973,7 +976,7 @@
       unsigned oSlot = ((unsigned)Slot << 5) | (getEncodedLinkage(I) << 2) |
                         (I->hasInitializer() << 1) | (unsigned)I->isConstant();
       output_vbr(oSlot);
-    } else {
+    } else {  
       unsigned oSlot = ((unsigned)Slot << 5) | (3 << 2) |
                         (0 << 1) | (unsigned)I->isConstant();
       output_vbr(oSlot);
@@ -1018,16 +1021,30 @@
     if (I->isExternal())   // If external, we don't have an FunctionInfo block.
       ID |= 1 << 4;
     
-    if (I->getAlignment() || I->hasSection() || (CC & ~15) != 0)
+    if (I->getAlignment() || I->hasSection() || (CC & ~15) != 0 ||
+        (I->isExternal() && I->hasDLLImportLinkage()) ||
+        (I->isExternal() && I->hasExternalWeakLinkage())
+       )
       ID |= 1 << 31;       // Do we need an extension word?
     
     output_vbr(ID);
     
     if (ID & (1 << 31)) {
       // Extension byte: bits 0-4 = alignment, bits 5-9 = top nibble of calling
-      // convention, bit 10 = hasSectionID.
+      // convention, bit 10 = hasSectionID., bits 11-12 = external linkage type
+      unsigned extLinkage = 0;
+
+      if (I->isExternal()) {
+        if (I->hasDLLImportLinkage()) {
+          extLinkage = 1;
+        } else if (I->hasExternalWeakLinkage()) {
+          extLinkage = 2;
+        }
+      }
+
       ID = (Log2_32(I->getAlignment())+1) | ((CC >> 4) << 5) | 
-           (I->hasSection() << 10);
+        (I->hasSection() << 10) |
+        ((extLinkage & 3) << 11);
       output_vbr(ID);
       
       // Give section names unique ID's.






More information about the llvm-commits mailing list