Adding dllimport, dllexport and external weak linkage types.
[oota-llvm.git] / lib / Target / X86 / X86ATTAsmPrinter.cpp
index b17cde18de28a2a8e4ed58c66a6520274bcdab7f..1ce24fda0cffe35b9944d65e3ca43b55d409e742 100755 (executable)
@@ -48,10 +48,13 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
     SwitchToTextSection(TAI->getTextSection(), F);
     EmitAlignment(4, F);     // FIXME: This should be parameterized somewhere.
     break;
+  case Function::DLLExportLinkage:
+    DLLExportedFns.insert(Mang->makeNameProper(F->getName(), ""));
+    //FALLS THROUGH
   case Function::ExternalLinkage:
     SwitchToTextSection(TAI->getTextSection(), F);
     EmitAlignment(4, F);     // FIXME: This should be parameterized somewhere.
-    O << "\t.globl\t" << CurrentFnName << "\n";
+    O << "\t.globl\t" << CurrentFnName << "\n";    
     break;
   case Function::WeakLinkage:
   case Function::LinkOnceLinkage:
@@ -179,8 +182,9 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
     bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
     if (!isMemOp && !isCallOp) O << '$';
 
-    GlobalValue *GV = MO.getGlobal();
+    GlobalValue *GV = MO.getGlobal();    
     std::string Name = Mang->getValueName(GV);
+    
     bool isExt = (GV->isExternal() || GV->hasWeakLinkage() ||
                   GV->hasLinkOnceLinkage());
     if (X86PICStyle == PICStyle::Stub &&
@@ -196,13 +200,27 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
           GVStubs.insert(Name);
           O << "L" << Name << "$non_lazy_ptr";
         }
-      } else
+      } else {
+        if (GV->hasDLLImportLinkage()) {
+          // FIXME: This should be fixed with full support of stdcall & fastcall
+          // CC's
+          O << "__imp_";          
+        } 
         O << Name;
+      }
+      
       if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_)
         O << "-\"L" << getFunctionNumber() << "$pb\"";
-    } else
+    } else {
+      if (GV->hasDLLImportLinkage()) {
+        // FIXME: This should be fixed with full support of stdcall & fastcall
+        // CC's
+        O << "__imp_";          
+      }       
       O << Name;
-
+   
+    }
+    
     int Offset = MO.getOffset();
     if (Offset > 0)
       O << "+" << Offset;