1 #include "../includes/ghcconfig.h"
3 /* ******************************** PowerPC ******************************** */
5 #if defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH)
6 #if !(defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS))
7 /* The following code applies, with some differences,
8 to all powerpc platforms except for powerpc32-linux,
9 whose calling convention is annoyingly complex.
13 /* The code is "almost" the same for
16 #if defined(powerpc64_HOST_ARCH)
26 /* Some info about stack frame layout */
27 #define LINK_SLOT (2*WS)
28 #define LINKAGE_AREA_SIZE (6*WS)
30 /* The following defines mirror struct AdjustorStub
31 from Adjustor.c. Make sure to keep these in sync.
33 #if defined(powerpc_HOST_ARCH) && defined(darwin_HOST_OS)
34 #define HEADER_WORDS 6
35 #elif defined(powerpc64_HOST_ARCH) && defined(darwin_HOST_OS)
37 #define HEADER_WORDS 3
40 #define HPTR_OFF ((HEADER_WORDS )*WS)
41 #define WPTR_OFF ((HEADER_WORDS + 1)*WS)
42 #define FRAMESIZE_OFF ((HEADER_WORDS + 2)*WS)
43 #define EXTRA_WORDS_OFF ((HEADER_WORDS + 3)*WS)
45 /* Darwin insists on register names, everyone else prefers
47 #if !defined(darwin_HOST_OS)
68 #if LEADING_UNDERSCORE
73 /* Note that we don't build a function descriptor
74 for AIX-derived ABIs here. This will happen at runtime
79 /* On entry, r2 will point to the AdjustorStub data structure. */
83 STORE r0, LINK_SLOT(r1)
85 /* set up stack frame */
86 LOAD r12, FRAMESIZE_OFF(r2)
87 #ifdef powerpc64_HOST_ARCH
93 /* Save some regs so that we can use them.
94 Note that we use the "Red Zone" below the stack pointer.
102 LOAD r12, EXTRA_WORDS_OFF(r2)
106 LOAD r0, LINKAGE_AREA_SIZE + 8*WS(r30)
107 STORE r0, LINKAGE_AREA_SIZE + 10*WS(r31)
113 /* Restore r30 and r31 now.
118 STORE r10, LINKAGE_AREA_SIZE + 9*WS(r1)
119 STORE r9, LINKAGE_AREA_SIZE + 8*WS(r1)
127 LOAD r3, HPTR_OFF(r2)
129 LOAD r12, WPTR_OFF(r2)
130 #if defined(darwin_HOST_OS)
134 /* The function we're calling will never be a nested function,
135 so we don't load r11.
143 LOAD r0, LINK_SLOT(r1)
148 /* ********************************* i386 ********************************** */
150 #elif defined(i386_HOST_ARCH) && defined(darwin_HOST_OS)
154 #define HEADER_BYTES 8
156 #define HPTR_OFF HEADER_BYTES
157 #define WPTR_OFF (HEADER_BYTES + 1*WS)
158 #define FRAMESIZE_OFF (HEADER_BYTES + 2*WS)
159 #define ARGWORDS_OFF (HEADER_BYTES + 3*WS)
164 subl $RETVAL_OFF, %eax
169 subl FRAMESIZE_OFF(%eax), %esp
176 movl ARGWORDS_OFF(%eax), %ecx