[project @ 2002-05-21 14:58:49 by wolfgang]
authorwolfgang <unknown>
Tue, 21 May 2002 14:58:51 +0000 (14:58 +0000)
committerwolfgang <unknown>
Tue, 21 May 2002 14:58:51 +0000 (14:58 +0000)
Bug-fixes for PowerPC
*) Rewrote StgRun in assembler (that seems to be the cleanest way to get it to work).
*) Fixed a small typo in createAdjustor.

ghc/rts/Adjustor.c
ghc/rts/StgCRun.c

index eea4611..0fa9bfe 100644 (file)
@@ -336,7 +336,7 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for
                adj_code[6] |= ((unsigned long)wptr) >> 16;
                
                adj_code[7] = 0x3c600000;       //lis r3,hi(hptr)
-               adj_code[6] |= ((unsigned long)hptr) >> 16;
+               adj_code[7] |= ((unsigned long)hptr) >> 16;
                
                adj_code[8] = 0x60000000;       //ori r0,r0,lo(wptr)
                adj_code[8] |= ((unsigned long)wptr) & 0xFFFF; 
index 884f9c3..3e16e48 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $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
  *
@@ -457,33 +457,33 @@ StgRun(StgFunPtr f, StgRegTable *basereg)
 /* -----------------------------------------------------------------------------
    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