changeset 1181:204197eb9eb5

Fix up some naked asm output for mingw32
author Kelly Wilson <wilsonk cpsc.ucalgary.ca>
date Mon, 30 Mar 2009 18:18:23 -0600
parents f5729209a1d4
children 5e8f7ad442ba
files gen/naked.cpp
diffstat 1 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gen/naked.cpp	Tue Mar 31 01:18:35 2009 +0200
+++ b/gen/naked.cpp	Mon Mar 30 18:18:23 2009 -0600
@@ -136,6 +136,38 @@
     }
     // this works on linux x86 32 and 64 bit
     // assume it works everywhere else as well for now
+    // this needed a slight modification for Win
+    else
+    {
+        const char* linkage = "globl";
+        std::string section = "text";
+        if (DtoIsTemplateInstance(fd))
+        {
+            linkage = "weak";
+            tmpstr << "section\t.gnu.linkonce.t." << mangle << ",\"ax\",@progbits";
+            section = tmpstr.str();
+        }
+        asmstr << "\t." << section << std::endl;
+        asmstr << "\t.align\t16" << std::endl;
+        
+        if (global.params.os == OSWindows)
+        {
+            std::string def = "def";
+            std::string endef = "endef";
+            asmstr << "\t." << def << "\t" << mangle << ";";
+            // hard code these two numbers for now since gas ignores .scl and llvm
+            // is defaulting to .type 32 for everything I have seen
+            asmstr << "\t.scl 2; .type 32;\t" << "." << endef << std::endl;
+        } else
+        {
+            asmstr << "\t." << linkage << "\t" << mangle << std::endl;
+            asmstr << "\t.type\t" << mangle << ",@function" << std::endl;
+        }
+        
+        asmstr << mangle << ":" << std::endl;
+            
+    }
+    /*
     else
     {
         const char* linkage = "globl";
@@ -151,7 +183,7 @@
         asmstr << "\t." << linkage << "\t" << mangle << std::endl;
         asmstr << "\t.type\t" << mangle << ",@function" << std::endl;
         asmstr << mangle << ":" << std::endl;
-    }
+        }*/
 
     // emit body
     fd->fbody->toNakedIR(gIR);