diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2016-03-24 21:00:17 +0100 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2016-03-24 23:26:58 +0100 |
commit | df26b95559fd467abc0a3a4151127c95cb5011b9 (patch) | |
tree | 921aa2442ffbb01079f5900fd5cf6bcab29fcc19 /rts/StgCRunAsm.S | |
parent | 24149528a0a2d17ff9b5b087e0a8249c8c9cef98 (diff) | |
download | haskell-df26b95559fd467abc0a3a4151127c95cb5011b9.tar.gz |
Add NCG support for AIX/ppc32
This extends the previous work to revive the unregisterised GHC build
for AIX/ppc32. Strictly speaking, AIX runs on POWER4 (and later)
hardware, but the PPC32 instructions implemented in the PPC NCG
represent a compatible subset of the POWER4 ISA.
IBM AIX follows the PowerOpen ABI (and shares many similiarites with the
Linux PPC64 ELF V1 NCG backend) but uses the rather limited XCOFF
format (compared to ELF).
This doesn't support dynamic libraries yet.
A major limiting factor is that the AIX assembler does not support the
`@ha`/`@l` relocation types nor the ha16()/lo16() functions Darwin's
assembler supports. Therefore we need to avoid emitting those. In case
of numeric literals we simply compute the functions ourselves, while for
labels we have to use local TOCs and hope everything fits into a 16bit
offset (for ppc32 this gives us at most 16384 entries per TOC section,
which is enough to compile GHC).
Another issue is that XCOFF doesn't seem to have a relocation type for
label-differences, and therefore the label-differences placed into
tables-next-to-code can't be relocated, but the linker may rearrange
different sections, so we need to place all read-only sections into the
same `.text[PR]` section to workaround this.
Finally, the PowerOpen ABI distinguishes between function-descriptors
and actualy entry-point addresses. For AIX we need to be specific when
emitting assembler code whether we want the address of the function
descriptor `printf`) or for the entry-point (`.printf`). So we let the
asm pretty-printer prefix a dot to all emitted subroutine
calls (i.e. `BL`) on AIX only. For now, STG routines' entry-point labels
are not prefixed by a label and don't have any associated
function-descriptor.
Reviewers: austin, trommler, erikd, bgamari
Reviewed By: trommler, erikd, bgamari
Differential Revision: https://phabricator.haskell.org/D2019
Diffstat (limited to 'rts/StgCRunAsm.S')
-rw-r--r-- | rts/StgCRunAsm.S | 81 |
1 files changed, 75 insertions, 6 deletions
diff --git a/rts/StgCRunAsm.S b/rts/StgCRunAsm.S index bb860ca287..9274a445b5 100644 --- a/rts/StgCRunAsm.S +++ b/rts/StgCRunAsm.S @@ -1,8 +1,9 @@ #include "ghcconfig.h" #include "rts/Constants.h" -#ifdef powerpc64le_HOST_ARCH -#ifdef linux_HOST_OS -#define STACK_FRAME_SIZE RESERVED_C_STACK_BYTES+304 + +#if defined(powerpc64le_HOST_ARCH) +# ifdef linux_HOST_OS +# define STACK_FRAME_SIZE RESERVED_C_STACK_BYTES+304 .file "StgCRun.c" .abiversion 2 .section ".toc","aw" @@ -107,8 +108,76 @@ StgReturn: blr .section .note.GNU-stack,"",@progbits -#else // linux_HOST_OS -#error Only Linux support for power64 little endian right now. -#endif +# else // linux_HOST_OS +# error Only Linux support for power64 little endian right now. +# endif + +#elif defined(powerpc_HOST_ARCH) +# if defined(aix_HOST_OS) +# define STACK_FRAME_SIZE RESERVED_C_STACK_BYTES+224 + .toc + .csect StgRun[DS] + .globl StgRun[DS] + .long .StgRun, TOC[TC0], 0 + .csect .text[PR] + .globl .StgRun +.StgRun: + mflr 0 + mr 5,1 + stw 0,8(1) + stwu 1,-(STACK_FRAME_SIZE)(1) + stw 2,-224(5) + stmw 13,-220(5) + stfd 14,-144(5) + stfd 15,-136(5) + stfd 16,-128(5) + stfd 17,-120(5) + stfd 18,-112(5) + stfd 19,-104(5) + stfd 20,-96(5) + stfd 21,-88(5) + stfd 22,-80(5) + stfd 23,-72(5) + stfd 24,-64(5) + stfd 25,-56(5) + stfd 26,-48(5) + stfd 27,-40(5) + stfd 28,-32(5) + stfd 29,-24(5) + stfd 30,-16(5) + stfd 31,-8(5) + mr 27,4 + mtctr 3 + bctr + + .globl StgReturn +StgReturn: + mr 3,14 + la 5,(STACK_FRAME_SIZE)(1) + lwz 2,-224(5) + lmw 13,-220(5) + lfd 14,-144(5) + lfd 15,-136(5) + lfd 16,-128(5) + lfd 17,-120(5) + lfd 18,-112(5) + lfd 19,-104(5) + lfd 20,-96(5) + lfd 21,-88(5) + lfd 22,-80(5) + lfd 23,-72(5) + lfd 24,-64(5) + lfd 25,-56(5) + lfd 26,-48(5) + lfd 27,-40(5) + lfd 28,-32(5) + lfd 29,-24(5) + lfd 30,-16(5) + lfd 31,-8(5) + mr 1,5 + lwz 0,8(1) + mtlr 0 + blr +# endif // aix_HOST_OS #endif |