diff options
author | Peter Trommler <ptrommler@acm.org> | 2015-07-03 19:09:06 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-07-03 19:09:06 +0200 |
commit | d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984 (patch) | |
tree | 6d18388d249d0186c851c2f50f345020001fef7f /rts | |
parent | bdf7f133d1d4bcc7ca3c0bbadda51ef542cccfb0 (diff) | |
download | haskell-d3c1dda60d0ec07fc7f593bfd83ec9457dfa7984.tar.gz |
Implement PowerPC 64-bit native code backend for Linux
Extend the PowerPC 32-bit native code generator for "64-bit
PowerPC ELF Application Binary Interface Supplement 1.9" by
Ian Lance Taylor and "Power Architecture 64-Bit ELF V2 ABI Specification --
OpenPOWER ABI for Linux Supplement" by IBM.
The latter ABI is mainly used on POWER7/7+ and POWER8
Linux systems running in little-endian mode. The code generator
supports both static and dynamic linking. PowerPC 64-bit
code for ELF ABI 1.9 and 2 is mostly position independent
anyway, and thus so is all the code emitted by the code
generator. In other words, -fPIC does not make a difference.
rts/stg/SMP.h support is implemented.
Following the spirit of the introductory comment in
PPC/CodeGen.hs, the rest of the code is a straightforward
extension of the 32-bit implementation.
Limitations:
* Code is generated only in the medium code model, which
is also gcc's default
* Local symbols are not accessed directly, which seems to
also be the case for 32-bit
* LLVM does not work, but this does not work on 32-bit either
* Must use the system runtime linker in GHCi, because the
GHC linker for "static" object files (rts/Linker.c) for
PPC 64-bit is not implemented. The system runtime
(dynamic) linker works.
* The handling of the system stack (register 1) is not ELF-
compliant so stack traces break. Instead of allocating a new
stack frame, spill code should use the "official" spill area
in the current stack frame and deallocation code should restore
the back chain
* DWARF support is missing
Fixes #9863
Test Plan: validate (on powerpc, too)
Reviewers: simonmar, trofi, erikd, austin
Reviewed By: trofi
Subscribers: bgamari, arnons1, kgardas, thomie
Differential Revision: https://phabricator.haskell.org/D629
GHC Trac Issues: #9863
Diffstat (limited to 'rts')
-rw-r--r-- | rts/StgCRun.c | 10 | ||||
-rw-r--r-- | rts/StgCRunAsm.S | 114 | ||||
-rw-r--r-- | rts/ghc.mk | 3 |
3 files changed, 126 insertions, 1 deletions
diff --git a/rts/StgCRun.c b/rts/StgCRun.c index 02ec532d4b..29039117ad 100644 --- a/rts/StgCRun.c +++ b/rts/StgCRun.c @@ -662,11 +662,19 @@ StgRunIsImplementedInAssembler(void) } #else // linux_HOST_OS -#error Only linux support for power64 right now. +#error Only Linux support for power64 right now. #endif #endif +#ifdef powerpc64le_HOST_ARCH +/* ----------------------------------------------------------------------------- + PowerPC 64 little endian architecture + + Really everything is in assembler, so we don't have to deal with GCC... + -------------------------------------------------------------------------- */ +#endif + /* ----------------------------------------------------------------------------- ARM architecture -------------------------------------------------------------------------- */ diff --git a/rts/StgCRunAsm.S b/rts/StgCRunAsm.S new file mode 100644 index 0000000000..bb860ca287 --- /dev/null +++ b/rts/StgCRunAsm.S @@ -0,0 +1,114 @@ +#include "ghcconfig.h" +#include "rts/Constants.h" +#ifdef powerpc64le_HOST_ARCH +#ifdef linux_HOST_OS +#define STACK_FRAME_SIZE RESERVED_C_STACK_BYTES+304 + .file "StgCRun.c" + .abiversion 2 + .section ".toc","aw" + .section ".text" + .align 2 +.globl StgRun +.hidden StgRun +.type StgRun,@function +StgRun: +.localentry StgRun,.-StgRun + mflr 0 + mr 5, 1 + std 0, 16(1) + stdu 1, -(STACK_FRAME_SIZE)(1) + std 2, -296(5) + std 14, -288(5) + std 15, -280(5) + std 16, -272(5) + std 17, -264(5) + std 18, -256(5) + std 19, -248(5) + std 20, -240(5) + std 21, -232(5) + std 22, -224(5) + std 23, -216(5) + std 24, -208(5) + std 25, -200(5) + std 26, -192(5) + std 27, -184(5) + std 28, -176(5) + std 29, -168(5) + std 30, -160(5) + std 31, -152(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 + mr 12, 3 + bctr +.globl StgReturn +.type StgReturn,@function +StgReturn: +.localentry StgReturn,.-StgReturn + mr 3,14 + la 5, STACK_FRAME_SIZE(1) + ld 2, -296(5) + ld 14, -288(5) + ld 15, -280(5) + ld 16, -272(5) + ld 17, -264(5) + ld 18, -256(5) + ld 19, -248(5) + ld 20, -240(5) + ld 21, -232(5) + ld 22, -224(5) + ld 23, -216(5) + ld 24, -208(5) + ld 25, -200(5) + ld 26, -192(5) + ld 27, -184(5) + ld 28, -176(5) + ld 29, -168(5) + ld 30, -160(5) + ld 31, -152(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 + ld 0, 16(1) + mtlr 0 + blr + + .section .note.GNU-stack,"",@progbits +#else // linux_HOST_OS +#error Only Linux support for power64 little endian right now. +#endif + +#endif diff --git a/rts/ghc.mk b/rts/ghc.mk index 7fa36b6f17..797e76ba16 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -45,6 +45,9 @@ ifneq "$(PORTING_HOST)" "YES" ifneq "$(findstring $(TargetArch_CPP), i386 powerpc powerpc64)" "" rts_S_SRCS += rts/AdjustorAsm.S endif +ifneq "$(findstring $(TargetArch_CPP), powerpc64le)" "" +rts_S_SRCS += rts/StgCRunAsm.S +endif endif ifeq "$(GhcUnregisterised)" "YES" |