[Git][ghc/ghc][wip/supersven/riscv64-ncg] Add calling conv test for doubles

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Mon Aug 21 19:35:26 UTC 2023



Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC


Commits:
65f966a6 by Sven Tennie at 2023-08-21T21:35:01+02:00
Add calling conv test for doubles

- - - - -


3 changed files:

- testsuite/tests/codeGen/should_run/CCallConv.hs
- testsuite/tests/codeGen/should_run/CCallConv.stdout
- testsuite/tests/codeGen/should_run/CCallConv_c.c


Changes:

=====================================
testsuite/tests/codeGen/should_run/CCallConv.hs
=====================================
@@ -72,6 +72,20 @@ foreign import ccall "funFloat"
     Float# -> -- s1
     Float# -- result
 
+foreign import ccall "funDouble"
+  funDouble ::
+    Double# -> -- a0
+    Double# -> -- a1
+    Double# -> -- a2
+    Double# -> -- a3
+    Double# -> -- a4
+    Double# -> -- a5
+    Double# -> -- a6
+    Double# -> -- a7
+    Double# -> -- s0
+    Double# -> -- s1
+    Double# -- result
+
 main :: IO ()
 main =
   -- N.B. the values here aren't choosen by accident: -1 means all bits one in
@@ -89,6 +103,7 @@ main =
       res32 :: Int64# = fun32 i32 w32 i32 i32 i32 i32 i32 i32 w32 i32
       expected_res32 :: Int64 = 2 * (fromInteger . fromIntegral) (maxBound :: Word32) + 8 * (-1)
       resFloat :: Float = F# (funFloat 1.0# 1.1# 1.2# 1.3# 1.4# 1.5# 1.6# 1.7# 1.8# 1.9#)
+      resDouble :: Double = D# (funDouble 1.0## 1.1## 1.2## 1.3## 1.4## 1.5## 1.6## 1.7## 1.8## 1.9##)
    in do
         print $ "fun8 result:" ++ show (I64# res8)
         assertEqual expected_res8 (I64# res8)
@@ -98,6 +113,8 @@ main =
         assertEqual expected_res32 (I64# res32)
         print $ "funFloat result:" ++ show resFloat
         assertEqual (14.5 :: Float) resFloat
+        print $ "funDouble result:" ++ show resDouble
+        assertEqual (14.5 :: Double) resDouble
 
 assertEqual :: (Eq a, Show a) => a -> a -> IO ()
 assertEqual a b =


=====================================
testsuite/tests/codeGen/should_run/CCallConv.stdout
=====================================
@@ -2,6 +2,7 @@
 "fun16 result:131062"
 "fun32 result:8589934582"
 "funFloat result:14.5"
+"funDouble result:14.5"
 fun32:
 a0: 0xffffffff -1
 a1: 0xffffffff 4294967295
@@ -46,3 +47,14 @@ a6: 1.600000
 a7: 1.700000
 s0: 1.800000
 s1: 1.900000
+funDouble:
+a0: 1.000000
+a1: 1.100000
+a2: 1.200000
+a3: 1.300000
+a4: 1.400000
+a5: 1.500000
+a6: 1.600000
+a7: 1.700000
+s0: 1.800000
+s1: 1.900000


=====================================
testsuite/tests/codeGen/should_run/CCallConv_c.c
=====================================
@@ -72,3 +72,20 @@ float funFloat(float a0, float a1, float a2, float a3, float a4, float a5,
 
   return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + s0 + s1;
 }
+
+double funDouble(double a0, double a1, double a2, double a3, double a4, double a5,
+             double a6, double a7, double s0, double s1) {
+  printf("funDouble:\n");
+  printf("a0: %f\n", a0);
+  printf("a1: %f\n", a1);
+  printf("a2: %f\n", a2);
+  printf("a3: %f\n", a3);
+  printf("a4: %f\n", a4);
+  printf("a5: %f\n", a5);
+  printf("a6: %f\n", a6);
+  printf("a7: %f\n", a7);
+  printf("s0: %f\n", s0);
+  printf("s1: %f\n", s1);
+
+  return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + s0 + s1;
+}



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65f966a6bf0cbaed9b4bd4b11ccd3d02817f153e

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/65f966a6bf0cbaed9b4bd4b11ccd3d02817f153e
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230821/4e1cd556/attachment-0001.html>


More information about the ghc-commits mailing list