/* -----------------------------------------------------------------------------
- * $Id: StgCRun.c,v 1.32 2002/04/18 19:12:43 ken Exp $
+ * $Id: StgCRun.c,v 1.33 2002/05/21 14:58:49 wolfgang Exp $
*
* (c) The GHC Team, 1998-2000
*
/* -----------------------------------------------------------------------------
PowerPC architecture
- We can use a simple function call as a tail call (the bl instruction places
- the return address in the Link Register, and we ignore it).
- We make GCC do the register saving. GCC does a good job
- and saves all general purpose registers with a single stmw
- (store multiple words) instruction.
+ Everything is in assembler, so we don't have to deal with GCC...
-------------------------------------------------------------------------- */
#ifdef powerpc_TARGET_ARCH
-StgThreadReturnCode
-StgRun(StgFunPtr f, StgRegTable *basereg) {
+extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg);
- unsigned char space[RESERVED_C_STACK_BYTES];
-
- f();
- __asm__ volatile (
- ".align 4\n"
- ".globl " STG_RETURN "\n"
- STG_RETURN ":"
- : : :
- "r14","r15","r16","r17","r18","r19","r20","r21","r22","r23","r24","r25","r26",
- "r27","r28","r29","r30","r31",
- "fr14","fr15","fr16","fr17","fr18","fr19","fr20",
- "fr21","fr22","fr23","fr24","fr25","fr26","fr27","fr28","fr29","fr30","fr31");
-
- return (StgThreadReturnCode)R1.i;
+void StgRunIsImplementedInAssembler()
+{
+ __asm__ volatile (
+ "\n.globl _StgRun\n"
+ "_StgRun:\n"
+ "\tmflr r0\n"
+ "\tbl saveFP # f14\n"
+ "\tstmw r14,-216(r1)\n"
+ "\tstwu r1,-8480(r1)\n"
+ "\tmtctr r3\n"
+ "\tmr r12,r3\n"
+ "\tbctr\n"
+ ".globl _StgReturn\n"
+ "_StgReturn:\n"
+ "\tmr r3,r14\n"
+ "\tla r1,8480(r1)\n"
+ "\tlmw r14,-216(r1)\n"
+ "\tb restFP # f14\n"
+ );
}
#endif