From 2897be77123bf31cad1c60dd5560eba7f2f021ce Mon Sep 17 00:00:00 2001 From: Peter Trommler Date: Sat, 18 Jun 2016 12:28:41 +0200 Subject: PPC NCG: Fix float parameter passing on 64-bit. On Linux 64-bit PowerPC the first 13 floating point parameters are passed in registers. We only passed the first 8 floating point params. The alignment of a floating point single precision value in ELF v1.9 is the second word of a doubleword. For ELF v2 we support only little endian and the least significant word of a doubleword is the first word, so no special handling is required. Add a regression test. Test Plan: validate on powerpc Linux and AIX Reviewers: erikd, hvr, austin, simonmar, bgamari Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2327 GHC Trac Issues: #12134 --- testsuite/tests/ffi/should_run/T12134.hs | 8 ++++++++ testsuite/tests/ffi/should_run/T12134.stdout | 15 +++++++++++++++ testsuite/tests/ffi/should_run/T12134_c.c | 8 ++++++++ testsuite/tests/ffi/should_run/all.T | 6 ++++++ 4 files changed, 37 insertions(+) create mode 100644 testsuite/tests/ffi/should_run/T12134.hs create mode 100644 testsuite/tests/ffi/should_run/T12134.stdout create mode 100644 testsuite/tests/ffi/should_run/T12134_c.c (limited to 'testsuite/tests/ffi') diff --git a/testsuite/tests/ffi/should_run/T12134.hs b/testsuite/tests/ffi/should_run/T12134.hs new file mode 100644 index 0000000000..f07d892b19 --- /dev/null +++ b/testsuite/tests/ffi/should_run/T12134.hs @@ -0,0 +1,8 @@ +import Foreign.C.Types + +foreign import ccall "many_floats" many :: CFloat -> CFloat -> + CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> + CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> + CDouble -> IO () + +main = many 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5 12.5 13.5 14.5 15.5 diff --git a/testsuite/tests/ffi/should_run/T12134.stdout b/testsuite/tests/ffi/should_run/T12134.stdout new file mode 100644 index 0000000000..798f1a2e38 --- /dev/null +++ b/testsuite/tests/ffi/should_run/T12134.stdout @@ -0,0 +1,15 @@ +1.500000 +2.500000 +3.500000 +4.500000 +5.500000 +6.500000 +7.500000 +8.500000 +9.500000 +10.500000 +11.500000 +12.500000 +13.500000 +14.500000 +15.500000 diff --git a/testsuite/tests/ffi/should_run/T12134_c.c b/testsuite/tests/ffi/should_run/T12134_c.c new file mode 100644 index 0000000000..0e616707eb --- /dev/null +++ b/testsuite/tests/ffi/should_run/T12134_c.c @@ -0,0 +1,8 @@ +#include + +void many_floats(float f1, float f2, float f3, float f4, float f5, + float f6, float f7, float f8, float f9, float f10, + float f11, float f12, float f13, float f14, double f15) { + printf("%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n", + f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15); +} diff --git a/testsuite/tests/ffi/should_run/all.T b/testsuite/tests/ffi/should_run/all.T index eb2c15279f..efb696906e 100644 --- a/testsuite/tests/ffi/should_run/all.T +++ b/testsuite/tests/ffi/should_run/all.T @@ -217,3 +217,9 @@ test('ffi023', [ omit_ways(['ghci']), # ffi023_stub.h before compiling ffi023_c.c, which # needs it. compile_and_run, ['ffi023_c.c']) + +test('T12134', + [omit_ways(['ghci']), extra_clean(['T12134_c.o'])], + compile_and_run, + ['T12134_c.c']) + -- cgit v1.2.1