From b41a80cefc6ae7aa235627c2d0ed8175a13c79ca Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Sun, 24 Aug 2008 16:51:17 +0200 Subject: [PATCH] Reverted some changes in the Tango patch, splitting asm block is simply not supported by llvm. --- gen/asmstmt.cpp | 3 ++ runtime/llvmdc.diff | 83 ++++++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 2d39df50..c62a1d2a 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -177,6 +177,9 @@ AsmStatement::toIR(IRState * irs) Logger::println("AsmStatement::toIR(): %s", loc.toChars()); LOG_SCOPE; + // sanity check + assert(irs->func()->decl->inlineAsm); + // get asm block IRAsmBlock* asmblock = irs->asmBlock; assert(asmblock); diff --git a/runtime/llvmdc.diff b/runtime/llvmdc.diff index e05b9d06..d8009d01 100644 --- a/runtime/llvmdc.diff +++ b/runtime/llvmdc.diff @@ -88,33 +88,54 @@ Index: lib/common/tango/core/Thread.d =================================================================== --- lib/common/tango/core/Thread.d (revision 3899) +++ lib/common/tango/core/Thread.d (working copy) -@@ -255,6 +255,10 @@ +@@ -244,8 +244,30 @@ + } + body + { +- version( D_InlineAsm_X86 ) ++ version( LLVMDC) { - __builtin_unwind_init(); - } -+ else version( LLVMDC ) -+ { -+ pragma(msg, "don't know how to push registers on the stack for this architecture with LLVMDC"); ++ version(X86) ++ { ++ uint eax,ecx,edx,ebx,ebp,esi,edi; ++ asm ++ { ++ //pushad ; ++ mov eax[EBP], EAX ; ++ mov ecx[EBP], ECX ; ++ mov edx[EBP], EDX ; ++ mov ebx[EBP], EBX ; ++ mov ebp[EBP], EBP ; ++ mov esi[EBP], ESI ; ++ mov edi[EBP], EDI ; ++ } ++ } ++ else ++ { ++ static assert( false, "Architecture not supported." ); ++ } + } - else - { - static assert( false, "Architecture not supported." ); -@@ -308,6 +312,10 @@ - { - // registers will be popped automatically - } -+ else version( LLVMDC ) ++ else version( D_InlineAsm_X86 ) + { -+ // TODO + asm + { + pushad; +@@ -297,6 +319,10 @@ + } + } + ++ version( LLVMDC) ++ { ++ // nothing to pop + } - else + version( D_InlineAsm_X86 ) { - static assert( false, "Architecture not supported." ); + asm Index: lib/gc/basic/gcx.d =================================================================== --- lib/gc/basic/gcx.d (revision 3899) +++ lib/gc/basic/gcx.d (working copy) -@@ -2178,6 +2178,21 @@ +@@ -2178,6 +2178,29 @@ __builtin_unwind_init(); sp = & sp; } @@ -122,37 +143,35 @@ Index: lib/gc/basic/gcx.d + { + version(X86) + { ++ uint eax,ecx,edx,ebx,ebp,esi,edi; + asm + { -+ pushad ; ++ pushad ; ++ mov eax[EBP], EAX ; ++ mov ecx[EBP], ECX ; ++ mov edx[EBP], EDX ; ++ mov ebx[EBP], EBX ; ++ mov ebp[EBP], EBP ; ++ mov esi[EBP], ESI ; ++ mov edi[EBP], EDI ; + mov sp[EBP],ESP ; + } + } + else + { -+ pragma(msg, "don't know how to push registers on the stack for this architecture with llvmdc"); ++ static assert( false, "Architecture not supported." ); + } + } else { asm -@@ -2191,6 +2206,20 @@ +@@ -2191,6 +2214,10 @@ { // nothing to do } + else version(LLVMDC) + { -+ version(X86) -+ { -+ asm -+ { -+ popad ; -+ } -+ } -+ else -+ { -+ // TODO -+ } ++ // nothing to do + } else {