changeset 243:4d006f7b2ada trunk

[svn r260] Changed some of the LLVMDC specific code in the Tango core and did some minor cleanups.
author lindquist
date Mon, 09 Jun 2008 03:02:14 +0200
parents ab43d1e1bf2a
children a95056b3c996
files dmd/mtype.c gen/toir.cpp tango/lib/common/tango/core/Thread.d tango/lib/gc/basic/gc.d
diffstat 4 files changed, 49 insertions(+), 162 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/mtype.c	Mon Jun 09 02:05:02 2008 +0200
+++ b/dmd/mtype.c	Mon Jun 09 03:02:14 2008 +0200
@@ -223,36 +223,28 @@
 
     tvoidptr = tvoid->pointerTo();
 
+    // set size_t / ptrdiff_t types
     if (global.params.is64bit)
     {
-	PTRSIZE = 8;
-#if !IN_LLVM
-	if (global.params.isLinux)
-	    REALSIZE = 10;
-	else
-	    REALSIZE = 8;
-#else
+    Tsize_t = Tuns64;
+    Tptrdiff_t = Tint64;
+    }
+    else
+    {
+    Tsize_t = Tuns32;
+    Tptrdiff_t = Tint32;
+    }
+
+    // set real size and padding
+    if (global.params.useFP80)
+    {
+    REALSIZE = 12;
+    REALPAD = 2;
+    }
+    else
+    {
     REALSIZE = 8;
     REALPAD = 0;
-#endif
-	Tsize_t = Tuns64;
-	Tptrdiff_t = Tint64;
-    }
-    else
-    {
-	PTRSIZE = 4;
-#if IN_LLVM
-    REALSIZE = 8;
-    REALPAD = 0;
-#elif TARGET_LINUX
-	REALSIZE = 12;
-	REALPAD = 2;
-#else
-	REALSIZE = 10;
-	REALPAD = 0;
-#endif
-	Tsize_t = Tuns32;
-	Tptrdiff_t = Tint32;
     }
 }
 
--- a/gen/toir.cpp	Mon Jun 09 02:05:02 2008 +0200
+++ b/gen/toir.cpp	Mon Jun 09 03:02:14 2008 +0200
@@ -1199,6 +1199,8 @@
                 palist = palist.addAttr(j+1, llvm::ParamAttr::ByVal);
 
             // this hack is necessary :/
+            // thing is DMD doesn't create correct signatures for the DMD generated calls to the runtime.
+            // only the return type is right, no arguments (parameters==NULL) ...
             if (dfn && dfn->func && dfn->func->runTimeHack) {
                 llvm::Function* fn = dfn->func->ir.irFunc->func;
                 assert(fn);
@@ -1302,76 +1304,6 @@
     LOG_SCOPE;
 
     assert(0 && "SymOffExp::toElem should no longer be called :/");
-
-    if (VarDeclaration* vd = var->isVarDeclaration())
-    {
-        Logger::println("VarDeclaration");
-
-        // handle forward reference
-        if (!vd->ir.declared && vd->isDataseg()) {
-            vd->toObjFile(); // TODO
-        }
-
-        assert(vd->ir.getIrValue());
-        Type* t = DtoDType(type);
-        Type* tnext = DtoDType(t->next);
-        Type* vdtype = DtoDType(vd->type);
-
-        LLValue* llvalue = vd->nestedref ? DtoNestedVariable(vd) : vd->ir.getIrValue();
-        LLValue* varmem = 0;
-
-        if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) {
-            Logger::println("struct");
-            TypeStruct* vdt = (TypeStruct*)vdtype;
-            assert(vdt->sym);
-
-            const LLType* llt = DtoType(t);
-            if (offset == 0) {
-                varmem = p->ir->CreateBitCast(llvalue, llt, "tmp");
-            }
-            else {
-                DStructIndexVector dst;
-                varmem = DtoIndexStruct(llvalue,vdt->sym, tnext, offset, dst);
-            }
-        }
-        else if (vdtype->ty == Tsarray) {
-            Logger::println("sarray");
-
-            assert(llvalue);
-            //e->arg = llvalue; // TODO
-
-            const LLType* llt = DtoType(t);
-            LLValue* off = 0;
-            if (offset != 0) {
-                Logger::println("offset = %d\n", offset);
-            }
-            if (offset == 0) {
-                varmem = llvalue;
-            }
-            else {
-                const LLType* elemtype = llvalue->getType()->getContainedType(0)->getContainedType(0);
-                size_t elemsz = getABITypeSize(elemtype);
-                varmem = DtoGEPi(llvalue, 0, offset / elemsz, "tmp");
-            }
-        }
-        else if (offset == 0) {
-            Logger::println("normal symoff");
-
-            assert(llvalue);
-            varmem = llvalue;
-
-            const LLType* llt = DtoType(t);
-            if (llvalue->getType() != llt) {
-                varmem = p->ir->CreateBitCast(varmem, llt, "tmp");
-            }
-        }
-        else {
-            assert(0);
-        }
-        return new DFieldValue(type, varmem, true);
-    }
-
-    assert(0);
     return 0;
 }
 
@@ -1459,19 +1391,6 @@
 
             DStructIndexVector vdoffsets;
             arrptr = DtoIndexClass(src, tc->sym, vd->type, vd->offset, vdoffsets);
-
-            /*std::vector<unsigned> vdoffsets(1,0);
-            tc->sym->offsetToIndex(vd->type, vd->offset, vdoffsets);
-
-            LLValue* src = l->getRVal();
-
-            Logger::println("indices:");
-            for (size_t i=0; i<vdoffsets.size(); ++i)
-                Logger::println("%d", vdoffsets[i]);
-
-            Logger::cout() << "src: " << *src << '\n';
-            arrptr = DtoGEP(src,vdoffsets,"tmp",p->scopebb());
-            Logger::cout() << "dst: " << *arrptr << '\n';*/
         }
         else
             assert(0);
@@ -1517,8 +1436,6 @@
             funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type)));
             Logger::cout() << "funcval casted: " << *funcval << '\n';
         #endif
-            //assert(funcval->getType() == DtoType(fdecl->type));
-            //cc = DtoCallingConv(fdecl->linkage);
         }
         // static call
         else {
@@ -3153,40 +3070,6 @@
 
 void obj_includelib(char*){}
 
-/* this has moved to asmstmt.cpp
-AsmStatement::AsmStatement(Loc loc, Token *tokens) :
-    Statement(loc)
-{
-    this->tokens = tokens;
-}
-Statement *AsmStatement::syntaxCopy()
-{
-    //error("%s: inline asm is not yet implemented", loc.toChars());
-    //fatal();
-    //assert(0);
-    return 0;
-}
-
-Statement *AsmStatement::semantic(Scope *sc)
-{
-    return Statement::semantic(sc);
-}
-
-
-void AsmStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
-{
-    Statement::toCBuffer(buf, hgs);
-}
-
-int AsmStatement::comeFrom()
-{
-    //error("%s: inline asm is not yet implemented", loc.toChars());
-    //fatal();
-    //assert(0);
-    return 0;
-}
-*/
-
 void
 backend_init()
 {
--- a/tango/lib/common/tango/core/Thread.d	Mon Jun 09 02:05:02 2008 +0200
+++ b/tango/lib/common/tango/core/Thread.d	Mon Jun 09 03:02:14 2008 +0200
@@ -244,7 +244,30 @@
         }
         body
         {
-            version( D_InlineAsm_X86 )
+            version( LLVMDC )
+            {
+                // put registers on the stack
+                version(D_InlineAsm_X86)
+                {
+                uint _eax, _ecx, _edx, _ebx, _esp, _ebp, _esi, _edi;
+                asm
+                {
+                    mov _eax, EAX;
+                    mov _ecx, ECX;
+                    mov _edx, EDX;
+                    mov _ebx, EBX;
+                    mov _esp, ESP;
+                    mov _ebp, EBP;
+                    mov _esi, ESI;
+                    mov _edi, EDI;
+                }
+                }
+                else
+                {
+                    // FIXME
+                }
+            }
+            else version( D_InlineAsm_X86 )
             {
                 asm
                 {
@@ -255,10 +278,6 @@
             {
                 __builtin_unwind_init();
             }
-            else version( LLVMDC )
-            {
-                // TODO below as well
-            }
             else
             {
                 static assert( false, "Architecture not supported." );
@@ -301,7 +320,11 @@
                 }
             }
 
-            version( D_InlineAsm_X86 )
+            version( LLVMDC )
+            {
+                // nothing to do
+            }
+            else version( D_InlineAsm_X86 )
             {
                 asm
                 {
@@ -312,10 +335,6 @@
             {
                 // registers will be popped automatically
             }
-            else version( LLVMDC )
-            {
-                // TODO
-            }
             else
             {
                 static assert( false, "Architecture not supported." );
--- a/tango/lib/gc/basic/gc.d	Mon Jun 09 02:05:02 2008 +0200
+++ b/tango/lib/gc/basic/gc.d	Mon Jun 09 03:02:14 2008 +0200
@@ -69,15 +69,8 @@
     //
     // NOTE: Due to popular demand, this has been re-enabled.  It still has
     //       the problems mentioned above though, so I guess we'll see.
-    version(LLVMDC)
-    {
-    // currently crashes a lot
-    }
-    else
-    {
     _gc.fullCollectNoStack(); // not really a 'collect all' -- still scans
                               // static data area, roots, and ranges.
-    }
     _gc.Dtor();
 }