diff gen/functions.cpp @ 920:545f54041d91

Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :) Fixed align N; in asm blocks. Fixed inreg parameter passing on x86 for ref/out params. Removed support for lazy initialization of function local static variables, I have no idea why I ever implemented this, it's not in the D spec, and DMD doesn't support it :P Some of the global variable related changes might cause minor regressions, but they should be easily fixable.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 03 Feb 2009 08:54:57 +0100
parents 94ba810ea2b0
children 7985bb036db4
line wrap: on
line diff
--- a/gen/functions.cpp	Mon Feb 02 02:35:44 2009 +0100
+++ b/gen/functions.cpp	Tue Feb 03 08:54:57 2009 +0100
@@ -209,12 +209,16 @@
             {
                 Type* t = arg->type->toBasetype();
 
-                // 32bit ints, pointers, classes, static arrays and AAs
+                // 32bit ints, pointers, classes, static arrays, AAs, ref and out params
                 // are candidate for being passed in EAX
-                if ((arg->storageClass & STCin) &&
-                    ((t->isscalar() && !t->isfloating()) ||
+                if (
+                    (arg->storageClass & (STCref|STCout))
+                    ||
+                    ((arg->storageClass & STCin) &&
+                     ((t->isscalar() && !t->isfloating()) ||
                      t->ty == Tclass || t->ty == Tsarray || t->ty == Taarray) &&
-                    (t->size() <= PTRSIZE))
+                     (t->size() <= PTRSIZE))
+                   )
                 {
                     arg->llvmAttrs |= llvm::Attribute::InReg;
                     assert((f->thisAttrs & llvm::Attribute::InReg) == 0 && "can't have two inreg args!");
@@ -618,7 +622,7 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
-void DtoDefineFunc(FuncDeclaration* fd)
+void DtoDefineFunction(FuncDeclaration* fd)
 {
     if (fd->ir.defined) return;
     fd->ir.defined = true;
@@ -628,6 +632,13 @@
     Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars());
     LOG_SCOPE;
 
+    // if this function is naked, we take over right away! no standard processing!
+    if (fd->naked)
+    {
+        DtoDefineNakedFunction(fd);
+        return;
+    }
+
     // debug info
     if (global.params.symdebug) {
         Module* mo = fd->getModule();
@@ -684,8 +695,7 @@
     
     // this hack makes sure the frame pointer elimination optimization is disabled.
     // this this eliminates a bunch of inline asm related issues.
-    // naked must always eliminate the framepointer however...
-    if (fd->inlineAsm && !fd->naked)
+    if (fd->inlineAsm)
     {
         // emit a call to llvm_eh_unwind_init
         LLFunction* hack = GET_INTRINSIC_DECL(eh_unwind_init);