diff options
author | Colin Watson <cjwatson@debian.org> | 2014-04-21 22:26:56 -0500 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2014-04-21 22:26:56 -0500 |
commit | c29bf984dd20431cd4344e8a5c444d7a5be08389 (patch) | |
tree | f0b0245bdbad8b981ed37d262e28d9977dcb7b35 /rts/StgCRun.c | |
parent | a3831391e1defdf69214dc258eebcf37d92991f2 (diff) | |
download | haskell-c29bf984dd20431cd4344e8a5c444d7a5be08389.tar.gz |
ghc: initial AArch64 patches
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'rts/StgCRun.c')
-rw-r--r-- | rts/StgCRun.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/rts/StgCRun.c b/rts/StgCRun.c index 940e16dec1..f649dbe9fb 100644 --- a/rts/StgCRun.c +++ b/rts/StgCRun.c @@ -748,4 +748,70 @@ StgRun(StgFunPtr f, StgRegTable *basereg) { } #endif +#ifdef aarch64_HOST_ARCH + +StgRegTable * +StgRun(StgFunPtr f, StgRegTable *basereg) { + StgRegTable * r; + __asm__ volatile ( + /* + * save callee-saves registers on behalf of the STG code. + */ + "stp x19, x20, [sp, #-16]!\n\t" + "stp x21, x22, [sp, #-16]!\n\t" + "stp x23, x24, [sp, #-16]!\n\t" + "stp x25, x26, [sp, #-16]!\n\t" + "stp x27, x28, [sp, #-16]!\n\t" + "stp ip0, ip1, [sp, #-16]!\n\t" + "str lr, [sp, #-8]!\n\t" + + /* + * allocate some space for Stg machine's temporary storage. + * Note: RESERVER_C_STACK_BYTES has to be a round number here or + * the assembler can't assemble it. + */ + "str lr, [sp, %3]" + /* "sub sp, sp, %3\n\t" */ + /* + * Set BaseReg + */ + "mov x19, %2\n\t" + /* + * Jump to function argument. + */ + "bx %1\n\t" + + ".globl " STG_RETURN "\n\t" + ".type " STG_RETURN ", %%function\n" + STG_RETURN ":\n\t" + /* + * Free the space we allocated + */ + "ldr lr, [sp], %3\n\t" + /* "add sp, sp, %3\n\t" */ + /* + * Return the new register table, taking it from Stg's R1 (ARM64's R22). + */ + "mov %0, x22\n\t" + /* + * restore callee-saves registers. + */ + "ldr lr, [sp], #8\n\t" + "ldp ip0, ip1, [sp], #16\n\t" + "ldp x27, x28, [sp], #16\n\t" + "ldp x25, x26, [sp], #16\n\t" + "ldp x23, x24, [sp], #16\n\t" + "ldp x21, x22, [sp], #16\n\t" + "ldp x19, x20, [sp], #16\n\t" + + : "=r" (r) + : "r" (f), "r" (basereg), "i" (RESERVED_C_STACK_BYTES) + : "%x19", "%x20", "%x21", "%x22", "%x23", "%x24", "%x25", "%x26", "%x27", "%x28", + "%ip0", "%ip1", "%lr" + ); + return r; +} + +#endif + #endif /* !USE_MINIINTERPRETER */ |