X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FAdjustorAsm.S;h=cfdef68349717788f4d48f89778ca13992e86b61;hb=a5bd056033e0f81e4d8ca30aa7c26cde3a3a132b;hp=7a4dcbf88d61473b73358531c0a9c52080f4a27e;hpb=0aca2f00f9bddce3624c1c99e9d2373a3a10a6c3;p=ghc-hetmet.git diff --git a/ghc/rts/AdjustorAsm.S b/ghc/rts/AdjustorAsm.S index 7a4dcbf..cfdef68 100644 --- a/ghc/rts/AdjustorAsm.S +++ b/ghc/rts/AdjustorAsm.S @@ -1,7 +1,9 @@ #include "../includes/ghcconfig.h" -#if defined(powerpc_TARGET_ARCH) || defined(powerpc64_TARGET_ARCH) -#if !(defined(powerpc_TARGET_ARCH) && defined(linux_TARGET_OS)) +/* ******************************** PowerPC ******************************** */ + +#if defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH) +#if !(defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS)) /* The following code applies, with some differences, to all powerpc platforms except for powerpc32-linux, whose calling convention is annoyingly complex. @@ -11,7 +13,7 @@ /* The code is "almost" the same for 32-bit and for 64-bit */ -#if defined(powerpc64_TARGET_ARCH) +#if defined(powerpc64_HOST_ARCH) #define WS 8 #define LOAD ld #define STORE std @@ -28,9 +30,9 @@ /* The following defines mirror struct AdjustorStub from Adjustor.c. Make sure to keep these in sync. */ -#if defined(powerpc_TARGET_ARCH) && defined(darwin_TARGET_OS) +#if defined(powerpc_HOST_ARCH) && defined(darwin_HOST_OS) #define HEADER_WORDS 6 -#elif defined(powerpc64_TARGET_ARCH) && defined(darwin_TARGET_OS) +#elif defined(powerpc64_HOST_ARCH) && defined(darwin_HOST_OS) #else #define HEADER_WORDS 3 #endif @@ -42,7 +44,7 @@ /* Darwin insists on register names, everyone else prefers to use numbers. */ -#if !defined(darwin_TARGET_OS) +#if !defined(darwin_HOST_OS) #define r0 0 #define r1 1 #define r2 2 @@ -82,7 +84,7 @@ adjustorCode: /* set up stack frame */ LOAD r12, FRAMESIZE_OFF(r2) -#ifdef powerpc64_TARGET_ARCH +#ifdef powerpc64_HOST_ARCH stdux r1, r1, r12 #else stwux r1, r1, r12 @@ -124,8 +126,17 @@ adjustorCode: LOAD r3, HPTR_OFF(r2) - LOAD r0, WPTR_OFF(r2) + LOAD r12, WPTR_OFF(r2) +#if defined(darwin_HOST_OS) + mtctr r12 +#else + LOAD r0, 0(r12) + /* The function we're calling will never be a nested function, + so we don't load r11. + */ mtctr r0 + LOAD r2, WS(r12) +#endif bctrl LOAD r1, 0(r1) @@ -133,5 +144,46 @@ adjustorCode: mtlr r0 blr #endif + +/* ********************************* i386 ********************************** */ + +#elif defined(i386_HOST_ARCH) && defined(darwin_HOST_OS) + +#define WS 4 +#define RETVAL_OFF 5 +#define HEADER_BYTES 8 + +#define HPTR_OFF HEADER_BYTES +#define WPTR_OFF (HEADER_BYTES + 1*WS) +#define FRAMESIZE_OFF (HEADER_BYTES + 2*WS) +#define ARGWORDS_OFF (HEADER_BYTES + 3*WS) + + .globl _adjustorCode +_adjustorCode: + popl %eax + subl $RETVAL_OFF, %eax + + pushl %ebp + movl %esp, %ebp + + subl FRAMESIZE_OFF(%eax), %esp + + pushl %esi + pushl %edi + + leal 8(%ebp), %esi + leal 12(%esp), %edi + movl ARGWORDS_OFF(%eax), %ecx + rep + movsl + + popl %edi + popl %esi + + pushl HPTR_OFF(%eax) + call *WPTR_OFF(%eax) + + leave + ret #endif