X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FStgCRun.c;h=f88f28ee8923f4421c887ea6ec97f98494c2420c;hb=6d353fcbc9480b46cc675b5d7f077fd6cecee377;hp=0ef550c7d30941e9359af03f34e84aec4b2f09aa;hpb=cb5ccf0a7588f9d67835d99a8135b02f3f5ba884;p=ghc-hetmet.git diff --git a/ghc/rts/StgCRun.c b/ghc/rts/StgCRun.c index 0ef550c..f88f28e 100644 --- a/ghc/rts/StgCRun.c +++ b/ghc/rts/StgCRun.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgCRun.c,v 1.34 2002/06/03 13:08:41 matthewc Exp $ + * $Id: StgCRun.c,v 1.37 2002/12/11 15:36:51 simonmar Exp $ * * (c) The GHC Team, 1998-2000 * @@ -84,7 +84,7 @@ register double fake_f9 __asm__("$f9"); extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg STG_UNUSED) { while (f) { - IF_DEBUG(evaluator, + IF_DEBUG(interpreter, fprintf(stderr,"Jumping to "); printPtr((P_)f); fflush(stdout); fprintf(stderr,"\n"); @@ -465,7 +465,7 @@ StgRun(StgFunPtr f, StgRegTable *basereg) extern StgThreadReturnCode StgRun(StgFunPtr f, StgRegTable *basereg); -void StgRunIsImplementedInAssembler(void) +static void StgRunIsImplementedInAssembler(void) { __asm__ volatile ( "\n.globl _StgRun\n" @@ -483,7 +483,7 @@ void StgRunIsImplementedInAssembler(void) "\tla r1,8480(r1)\n" "\tlmw r14,-216(r1)\n" "\tb restFP # f14\n" - ); + ); /* RESERVED_C_STACK_BYTES + stack frame size == 8192 + 288 == 8480 */ } #endif @@ -491,7 +491,13 @@ void StgRunIsImplementedInAssembler(void) /* ----------------------------------------------------------------------------- IA64 architecture - Again, in assembler - so we can fiddle with the register stack. + Again, in assembler - so we can fiddle with the register stack, and because + gcc doesn't handle asm-clobbered callee-saves correctly. + + loc0 - loc15: preserved locals + loc16 - loc28: STG registers + loc29: saved ar.pfs + loc30: saved b0 -------------------------------------------------------------------------- */ #ifdef ia64_TARGET_ARCH @@ -500,26 +506,42 @@ void StgRunIsImplementedInAssembler(void) #undef RESERVED_C_STACK_BYTES #define RESERVED_C_STACK_BYTES 1024 -void StgRunIsImplementedInAssembler(void) +static void StgRunIsImplementedInAssembler(void) { __asm__ volatile( ".global StgRun\n" "StgRun:\n" - "\talloc r55 = ar.pfs, 0, 24, 8, 0\n" /* setup register frame */ - "\tmov r54 = b0\n" /* save return address */ - "\tadds sp = -%0, sp\n" /* setup stack */ - "\tld8 r16=[r32],8 ;;\n" /* branch to f using descriptor */ - "\tld8 r1=[r32]\n" - "\tmov b6=r16\n" - "\tbr.few b6 ;;\n" + "\talloc loc29 = ar.pfs, 0, 31, 8, 0\n" /* setup register frame */ + "\tld8 r18 = [r32],8\n" /* get procedure address */ + "\tadds sp = -%0, sp ;;\n" /* setup stack */ + "\tld8 gp = [r32]\n" /* get procedure GP */ + "\tadds r16 = %0-(6*16), sp\n" + "\tadds r17 = %0-(5*16), sp ;;\n" + "\tstf.spill [r16] = f16,32\n" /* spill callee-saved fp regs */ + "\tstf.spill [r17] = f17,32\n" + "\tmov b6 = r18 ;;\n" /* set target address */ + "\tstf.spill [r16] = f18,32\n" + "\tstf.spill [r17] = f19,32\n" + "\tmov loc30 = b0 ;;\n" /* save return address */ + "\tstf.spill [r16] = f20,32\n" + "\tstf.spill [r17] = f21,32\n" + "\tbr.few b6 ;;\n" /* branch to function */ ".global StgReturn\n" "StgReturn:\n" - "\tmov r8 = 0\n" /* return value in r8 */ - "\tmov ar.pfs = r55\n" /* restore register frame */ - "\tmov b0 = r54\n" /* restore return address */ + "\tmov r8 = loc16\n" /* return value in r8 */ + "\tadds r16 = %0-(6*16), sp\n" + "\tadds r17 = %0-(5*16), sp ;;\n" + "\tldf.fill f16 = [r16],32\n" /* start restoring fp regs */ + "\tldf.fill f17 = [r17],32\n" + "\tmov ar.pfs = loc29 ;;\n" /* restore register frame */ + "\tldf.fill f18 = [r16],32\n" + "\tldf.fill f19 = [r17],32\n" + "\tmov b0 = loc30 ;;\n" /* restore return address */ + "\tldf.fill f20 = [r16],32\n" + "\tldf.fill f21 = [r17],32\n" "\tadds sp = %0, sp\n" /* restore stack */ "\tbr.ret.sptk.many b0 ;;\n" /* return */ - : : "i"(RESERVED_C_STACK_BYTES)); + : : "i"(RESERVED_C_STACK_BYTES + 6*16)); } #endif