summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-05-03 13:26:01 -0400
committerBen Gamari <ben@smart-cactus.org>2022-05-03 13:31:11 -0400
commitc3a4492f53d60a79bdc4f21c2f386d049a6e9d98 (patch)
tree198867cc0d6538403e4d386f414ca5edec5b618b
parent8d346994b64f40b74c50cf426b3c49c691b19f5e (diff)
downloadhaskell-c3a4492f53d60a79bdc4f21c2f386d049a6e9d98.tar.gz
testsuite: Add test for #21465
-rw-r--r--testsuite/tests/rts/T21465/T21465.hs14
-rw-r--r--testsuite/tests/rts/T21465/T21465.stdout18
-rw-r--r--testsuite/tests/rts/T21465/T21465_c.c28
-rw-r--r--testsuite/tests/rts/T21465/all.T5
4 files changed, 65 insertions, 0 deletions
diff --git a/testsuite/tests/rts/T21465/T21465.hs b/testsuite/tests/rts/T21465/T21465.hs
new file mode 100644
index 0000000000..1465359054
--- /dev/null
+++ b/testsuite/tests/rts/T21465/T21465.hs
@@ -0,0 +1,14 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+module Main where
+
+foreign import ccall "test_c" testC :: IO ()
+
+helper :: IO ()
+helper = putStrLn "This is the helper function"
+
+foreign export ccall helper :: IO ()
+
+main :: IO ()
+main = do
+ x <- testC
+ putStrLn "Done."
diff --git a/testsuite/tests/rts/T21465/T21465.stdout b/testsuite/tests/rts/T21465/T21465.stdout
new file mode 100644
index 0000000000..bb8fe2203d
--- /dev/null
+++ b/testsuite/tests/rts/T21465/T21465.stdout
@@ -0,0 +1,18 @@
+This is the helper function
+ 0: 01 01
+ 1: 02 02
+ 2: 03 03
+ 3: 04 04
+ 4: 05 05
+ 5: 06 06
+ 6: 07 07
+ 7: 08 08
+ 8: 09 09
+ 9: 0a 0a
+10: 0b 0b
+11: 0c 0c
+12: 0d 0d
+13: 0e 0e
+14: 0f 0f
+15: 10 10
+Done.
diff --git a/testsuite/tests/rts/T21465/T21465_c.c b/testsuite/tests/rts/T21465/T21465_c.c
new file mode 100644
index 0000000000..94afcfed10
--- /dev/null
+++ b/testsuite/tests/rts/T21465/T21465_c.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+
+// Haskell function
+extern void helper();
+
+void test_c() {
+ unsigned char blah[16] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10};
+ unsigned char foo[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ // Copy blah into xmm6
+ asm (
+ "movups %[blah], %%xmm6"
+ :
+ : [blah] "m" (blah)
+ : "cc", "memory", "xmm6", "xmm7"
+ );
+ // Call to Haskell
+ helper();
+ // Copy xmm6 to foo
+ asm (
+ "movups %%xmm6, %[foo]"
+ : [foo] "=m" (foo)
+ :
+ : "cc", "memory", "xmm6", "xmm7"
+ );
+ for (int i = 0; i < 16; i++) {
+ printf("%2i: %02x %02x\n", i, blah[i], foo[i]);
+ }
+} \ No newline at end of file
diff --git a/testsuite/tests/rts/T21465/all.T b/testsuite/tests/rts/T21465/all.T
new file mode 100644
index 0000000000..1211c84762
--- /dev/null
+++ b/testsuite/tests/rts/T21465/all.T
@@ -0,0 +1,5 @@
+# Check that the full width of callee-saved XMM registers are preserved across
+# calls into Haskell on Windows (although we allow this test to run on
+# non-Linux platforms as well).
+
+test('T21465', when(not arch('x86_64'), skip), compile_and_run, ['T21465_c.c'])