diff --git a/Makefile.common-jst b/Makefile.common-jst index 2ba2ae863ba..2224cb3c34e 100644 --- a/Makefile.common-jst +++ b/Makefile.common-jst @@ -262,18 +262,8 @@ install_for_test: _install _runtest/testsuite/lib/ cp $(main_build)/testsuite/lib/.testing.objs/native/testing.cm* \ _runtest/testsuite/lib/ - # replace backend-specific testsuite/tests/asmcomp with their new versions - rm _runtest/testsuite/tests/asmcomp/* - cp -a flambda-backend/testsuite/tests/asmcomp/* _runtest/testsuite/tests/asmcomp/ - # replace backend-specific testsuite/tests/asmgen with their new versions - rm _runtest/testsuite/tests/asmgen/* - cp -a flambda-backend/testsuite/tests/asmgen/* _runtest/testsuite/tests/asmgen/ - # replace backend-specific testsuite/tests/unboxed-primitive-args with their new versions - rm _runtest/testsuite/tests/unboxed-primitive-args/* - cp -a flambda-backend/testsuite/tests/unboxed-primitive-args/* _runtest/testsuite/tests/unboxed-primitive-args/ - # add extension library tests that are not supported by the upstream compiler - rm _runtest/testsuite/tests/lib-extensions/* - cp -a flambda-backend/testsuite/tests/lib-extensions/* _runtest/testsuite/tests/lib-extensions + # replace backend-specific testsuite/tests with their new versions + cp -a flambda-backend/testsuite/tests/* _runtest/testsuite/tests/ cp $(ocamldir)/Makefile.* _runtest/ diff --git a/testsuite/tests/asmcomp/0001-test.compilers.reference b/testsuite/tests/asmcomp/0001-test.compilers.reference deleted file mode 100644 index caa67d4cbc5..00000000000 --- a/testsuite/tests/asmcomp/0001-test.compilers.reference +++ /dev/null @@ -1,2 +0,0 @@ -File "0001-test.ml", line 1: -Warning 24 [bad-module-name]: bad source file name: "0001-test" is not a valid module name. diff --git a/testsuite/tests/asmcomp/0001-test.ml b/testsuite/tests/asmcomp/0001-test.ml deleted file mode 100644 index bffd6f1ccaa..00000000000 --- a/testsuite/tests/asmcomp/0001-test.ml +++ /dev/null @@ -1 +0,0 @@ -(* TEST *) diff --git a/testsuite/tests/asmcomp/bind_tuples.ml b/testsuite/tests/asmcomp/bind_tuples.ml deleted file mode 100644 index 384965b4280..00000000000 --- a/testsuite/tests/asmcomp/bind_tuples.ml +++ /dev/null @@ -1,44 +0,0 @@ -(* TEST - native; -*) - -(* Check the effectiveness of optimized compilation of tuple binding - - Ref: http://caml.inria.fr/mantis/view.php?id=4800 -*) - -let f () = - let x0 = Gc.allocated_bytes () in - let x1 = Gc.allocated_bytes () in - - let r = ref 0 in - for i = 1 to 20 do - let (x, y) = - try - if i mod 2 = 0 then (1, i * 2) - else if i mod 5 = 0 then raise Exit - else (-1, i * 3) - with Exit -> - (1, -1) - in - r := !r * x + y - done; - let x2 = Gc.allocated_bytes () in - assert (!r = 82); - assert(x1 -. x0 = x2 -. x1) (* check no allocation between x1 and x2 *) - [@@inline never] - -let () = f () - - - -(* MPR#7680 *) - -let f () = - let (a,b) = - try (1,2) - with _ -> assert false - in - if a + b = 3 then raise Not_found - -let () = try f (); assert false with Not_found -> () diff --git a/testsuite/tests/asmcomp/compare.ml b/testsuite/tests/asmcomp/compare.ml deleted file mode 100644 index 1a14c4dd328..00000000000 --- a/testsuite/tests/asmcomp/compare.ml +++ /dev/null @@ -1,10 +0,0 @@ -(* TEST - native; -*) -let[@inline never] float () = print_string "hello\n"; 42. -let[@inline never] f () = compare (float ()) 0.5;; -let _ = f () - -let[@inline never] myint () = print_string "bye\n"; 42 -let[@inline never] g () = compare (myint ()) 5;; -let _ = g () diff --git a/testsuite/tests/asmcomp/compare.reference b/testsuite/tests/asmcomp/compare.reference deleted file mode 100644 index 410ca140225..00000000000 --- a/testsuite/tests/asmcomp/compare.reference +++ /dev/null @@ -1,2 +0,0 @@ -hello -bye diff --git a/testsuite/tests/asmcomp/evaluation_order.ml b/testsuite/tests/asmcomp/evaluation_order.ml deleted file mode 100644 index f9cce72ef5b..00000000000 --- a/testsuite/tests/asmcomp/evaluation_order.ml +++ /dev/null @@ -1,77 +0,0 @@ -(* TEST *) -external unsafe_get : 'a array -> int -> 'a = "%array_unsafe_get" -external caml_bytes_get_16 : bytes -> int -> int = "%caml_bytes_get16" -external caml_bytes_set_16 : bytes -> int -> int -> unit = "%caml_bytes_set16" - -open Bigarray -type bigstring = (char, int8_unsigned_elt, c_layout) Array1.t - -external caml_bigstring_get_16 : - bigstring -> int -> int = "%caml_bigstring_get16" - -external caml_bigstring_set_16 : - bigstring -> int -> int -> unit = "%caml_bigstring_set16" - -let bigstring_of_string s = - let a = Array1.create char c_layout (String.length s) in - for i = 0 to String.length s - 1 do - a.{i} <- s.[i] - done; - a - -let () = - (* stringref_safe *) - String.get (print_endline "hello"; "foo") (print_endline "world"; 0) - |> Printf.printf "%c\n"; - - (* string_load *) - caml_bytes_get_16 (print_endline "hello"; Bytes.make 10 '\x00') - (print_endline "world"; 0) - |> Printf.printf "%x\n"; - - (* bigstring_load *) - caml_bigstring_get_16 (print_endline "hello"; - bigstring_of_string (String.make 10 '\x00')) - (print_endline "world"; 0) - |> Printf.printf "%x\n"; - - (* bytes_set *) - caml_bytes_set_16 (print_endline "a"; Bytes.make 10 '\x00') - (print_endline "b"; 0) - (print_endline "c"; 0xFF); - - (* bigstring_set *) - caml_bigstring_set_16 (print_endline "a"; - bigstring_of_string (String.make 10 '\x00')) - (print_endline "b"; 0) - (print_endline "c"; 0xFF); - - (* mk_compare_ints_untagged *) - print_int (compare (print_endline "A"; Sys.opaque_identity (2)) - (print_endline "B"; Sys.opaque_identity (3))); - print_newline (); - - (* mk_compare_floats *) - print_int (compare (print_endline "A"; Sys.opaque_identity (2.0)) - (print_endline "B"; Sys.opaque_identity (3.5))); - print_newline (); - - (* bytesset_safe *) - Bytes.set (print_endline "a"; Bytes.make 10 '\x00') - (print_endline "b"; 0) - (print_endline "c"; 'c'); - - (* safe_div_bi *) - Printf.printf "%nd\n" - (Nativeint.div (print_endline "A"; Sys.opaque_identity (6n)) - (print_endline "B"; Sys.opaque_identity (3n))); - - (* arrayref_unsafe *) - let[@inline never] test_arrayref_unsafe - : type t . t array -> int -> (t -> string) -> unit = - fun a i c -> - print_endline (c (Array.unsafe_get (print_endline "A"; a) (print_endline "B"; i))) - in - test_arrayref_unsafe [| "1";"2";"3" |] 0 Fun.id; - - () diff --git a/testsuite/tests/asmcomp/evaluation_order.reference b/testsuite/tests/asmcomp/evaluation_order.reference deleted file mode 100644 index 26082b114e5..00000000000 --- a/testsuite/tests/asmcomp/evaluation_order.reference +++ /dev/null @@ -1,30 +0,0 @@ -world -hello -f -world -hello -0 -world -hello -0 -c -b -a -c -b -a -B -A --1 -B -A --1 -c -b -a -B -A -2 -B -A -1 diff --git a/testsuite/tests/asmcomp/evaluation_order_broken.ml b/testsuite/tests/asmcomp/evaluation_order_broken.ml deleted file mode 100644 index 6862a8ca6df..00000000000 --- a/testsuite/tests/asmcomp/evaluation_order_broken.ml +++ /dev/null @@ -1,33 +0,0 @@ -(* TEST - bytecode; -*) - -(* The following examples have different output on bytecode and native. - The order of evaluation of arguments in cmm_helpers needs to be fixed. *) -open Bigarray -let () = -(* CR gyorsh: fix bigarray_get *) - let[@inline never] test_bigarray_get - (a : (Complex.t, complex32_elt, c_layout) Array1.t) - (i : int) = - print_float (Array1.unsafe_get (print_endline "A"; a) - (print_endline "B"; i)).Complex.re; - print_newline () - in - test_bigarray_get (Array1.init complex32 c_layout 3 (fun _ -> Complex.one)) 0; - - (* CR gyorsh: fix bigarray_set *) - let[@inline never] test_bigarray_set - (a : (Complex.t, complex32_elt, c_layout) Array1.t) - (i : int) = - Array1.unsafe_set (print_endline "A"; a) (print_endline "B"; i) - (print_endline "C"; Complex.i); - print_endline "?" - in - test_bigarray_set (Array1.create complex32 c_layout 3) 0; - - (* CR gyorsh: fix send *) - let[@inline never] test_send o x = - (print_endline "A"; o)#m (print_endline "B"; x) - in - test_send (object method m (_ : int) = print_endline "m" end) 1 diff --git a/testsuite/tests/asmcomp/evaluation_order_broken.reference b/testsuite/tests/asmcomp/evaluation_order_broken.reference deleted file mode 100644 index f67c856a55e..00000000000 --- a/testsuite/tests/asmcomp/evaluation_order_broken.reference +++ /dev/null @@ -1,10 +0,0 @@ -B -A -1. -C -B -A -? -B -A -m diff --git a/testsuite/tests/asmcomp/func_sections.arm.reference b/testsuite/tests/asmcomp/func_sections.arm.reference deleted file mode 100644 index b6a7d89c68e..00000000000 --- a/testsuite/tests/asmcomp/func_sections.arm.reference +++ /dev/null @@ -1 +0,0 @@ -16 diff --git a/testsuite/tests/asmcomp/func_sections.ml b/testsuite/tests/asmcomp/func_sections.ml deleted file mode 100644 index bdfcaf4529f..00000000000 --- a/testsuite/tests/asmcomp/func_sections.ml +++ /dev/null @@ -1,78 +0,0 @@ -(* TEST - flags = "-S -function-sections"; - function_sections; - { - arch_arm; - reference = "${test_source_directory}/func_sections.arm.reference"; - native; - }{ - arch_arm64; - reference = "${test_source_directory}/func_sections.arm.reference"; - native; - }{ - arch_amd64; - reference = "${test_source_directory}/func_sections.reference"; - native; - }{ - arch_i386; - reference = "${test_source_directory}/func_sections.reference"; - native; - } -*) - -(* We have a separate reference output for ARM because - it doesn't emit .text after jump tables. *) - -(* Test for anonymous functions which result in a mangled symbol *) -let f4 list = - List.map (fun s -> String.length s) list - -let test1 () = - f4 ["a";"asfda";"afda"] - -(* Test for jump tables*) - -let g1 s = s^"*" -let g2 s = "*"^s -let g3 s = "*"^s^"*" - -let f5 = function - | 1 -> g1 "a" - | 2 -> g2 "b" - | 3 -> g3 "c" - | 4 -> g1 "d" - | 5 -> g2 "e" - | 6 -> g3 "f" - | _ -> "x" - -let test2 () = - let list = [f5 5; - f5 7; - f5 15; - f5 26] - in - ignore list - -let iter = 1_000 - -let f0 x = x - 7; -[@@inline never] - -let f1 x = x + iter -[@@inline never] - -let f2 x = f1(x) -[@@inline never] - -let f3 x = f2(x)*f0(x) -[@@inline never] - -let test3 () = - f3 iter - - -let () = - ignore (test1 ()); - ignore (test2 ()); - ignore (test3 ()); - () diff --git a/testsuite/tests/asmcomp/func_sections.reference b/testsuite/tests/asmcomp/func_sections.reference deleted file mode 100644 index 98d9bcb75a6..00000000000 --- a/testsuite/tests/asmcomp/func_sections.reference +++ /dev/null @@ -1 +0,0 @@ -17 diff --git a/testsuite/tests/asmcomp/func_sections.run b/testsuite/tests/asmcomp/func_sections.run deleted file mode 100755 index 05f406fcbfd..00000000000 --- a/testsuite/tests/asmcomp/func_sections.run +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -exec > "${output}" 2>&1 - -# first, run the program to make sure it doesn't crash -${program} - -# now check the assembly file produced during compilation -asm=${test_build_directory}/func_sections.s -grep -E "\.section \.text\.caml\.(camlFunc_sections__|_ZN13Func_sections)" "$asm" | wc -l | tr -d ' ' | sed '/^$/d' diff --git a/testsuite/tests/asmcomp/is_in_static_data.c b/testsuite/tests/asmcomp/is_in_static_data.c deleted file mode 100644 index ccf0582c0ad..00000000000 --- a/testsuite/tests/asmcomp/is_in_static_data.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "caml/address_class.h" - -value caml_is_in_static_data(value v) { - return(Val_bool(Is_in_static_data(v))); -} diff --git a/testsuite/tests/asmcomp/is_static.ml b/testsuite/tests/asmcomp/is_static.ml deleted file mode 100644 index 78fb16bad4c..00000000000 --- a/testsuite/tests/asmcomp/is_static.ml +++ /dev/null @@ -1,40 +0,0 @@ -(* TEST - modules = "is_in_static_data.c"; - naked_pointers; - native; -*) - -(* Data that should be statically allocated by the compiler (all versions) *) - -external is_in_static_data : 'a -> bool = "caml_is_in_static_data" - -(* Basic constant blocks should be static *) -let block1 = (1,2) -let () = assert(is_in_static_data block1) - -(* as pattern shouldn't prevent it *) -let (a, b) as block2 = (1,2) -let () = assert(is_in_static_data block2) - -(* Also in functions *) -let f () = - let block = (1,2) in - assert(is_in_static_data block) - -let () = (f [@inlined never]) () - -(* Closed functions should be static *) -let closed_function x = x + 1 (* + is a primitive, it cannot be in the closure*) -let () = assert(is_in_static_data closed_function) - -(* And functions using closed functions *) -let almost_closed_function x = - (closed_function [@inlined never]) x -let () = assert(is_in_static_data almost_closed_function) - -(* Recursive constant functions should be static *) -let rec f1 a = g1 a -and g1 a = f1 a -let () = - assert(is_in_static_data f1); - assert(is_in_static_data g1) diff --git a/testsuite/tests/asmcomp/is_static_flambda.ml b/testsuite/tests/asmcomp/is_static_flambda.ml deleted file mode 100644 index 768c7ad5e2f..00000000000 --- a/testsuite/tests/asmcomp/is_static_flambda.ml +++ /dev/null @@ -1,207 +0,0 @@ -(* TEST - modules = "is_in_static_data.c is_static_flambda_dep.ml"; - flambda; - naked_pointers; - native; -*) - -(* Data that should be statically allocated by the compiler (flambda only) *) - -external is_in_static_data : 'a -> bool = "caml_is_in_static_data" - -(* Also after inlining *) -let g x = - let block = (1,x) in - assert(is_in_static_data block) - -let () = (g [@inlined always]) 2 - -(* Toplevel immutable blocks should be static *) -let block3 = (Sys.opaque_identity 1, Sys.opaque_identity 2) -let () = assert(is_in_static_data block3) - -(* Not being bound shouldn't prevent it *) -let () = - assert(is_in_static_data (Sys.opaque_identity 1, Sys.opaque_identity 2)) - -(* Only with rounds >= 2 currently ! -(* Also after inlining *) -let h x = - let block = (Sys.opaque_identity 1,x) in - assert(is_in_static_data block) - -let () = (h [@inlined always]) (Sys.opaque_identity 2) -*) - -(* Recursive constant values should be static *) -let rec a = 1 :: b -and b = 2 :: a -let () = - assert(is_in_static_data a); - assert(is_in_static_data b) - -(* And a mix *) -type e = E : 'a -> e - -let rec f1 a = E (g1 a, l1) -and g1 a = E (f1 a, l2) -and l1 = E (f1, l2) -and l2 = E (g1, l1) - -let () = - assert(is_in_static_data f1); - assert(is_in_static_data g1); - assert(is_in_static_data l1); - assert(is_in_static_data l2) - -(* Also in functions *) -let i () = - let rec f1 a = E (g1 a, l1) - and g1 a = E (f1 a, l2) - and l1 = E (f1, l2) - and l2 = E (g1, l1) in - - assert(is_in_static_data f1); - assert(is_in_static_data g1); - assert(is_in_static_data l1); - assert(is_in_static_data l2) - -let () = (i [@inlined never]) () - -module type P = module type of Stdlib -(* Top-level modules should be static *) -let () = assert(is_in_static_data (module Stdlib:P)) - -(* Not constant let rec to test extraction to initialize_symbol *) -let r = ref 0 -let rec a = (incr r; !r) :: b -and b = (incr r; !r) :: a - -let next = - let r = ref 0 in - fun () -> incr r; !r - -let () = - assert(is_in_static_data next) - -(* Exceptions without arguments should be static *) -exception No_argument -let () = assert(is_in_static_data No_argument) - -(* And also with constant arguments *) -exception Some_argument of string -let () = assert(is_in_static_data (Some_argument "some string")) - -(* Even when exposed by inlining *) -let () = - let exn = - try (failwith [@inlined always]) "some other string" with exn -> exn - in - assert(is_in_static_data exn) - -(* Verify that approximation intersection correctly loads exported - approximations. - - Is_static_flambda_dep.pair is a pair with 1 as first element. The - intersection of approximations should return a block with - approximation: [tag 0: [tag 0: Int 1, Unknown], Unknown] *) -let f x = - let pair = - if Sys.opaque_identity x then - (1, 2), 3 - else - Is_static_flambda_dep.pair, 4 - in - let n = fst (fst pair) in - let res = n, n in - assert(is_in_static_data res) - [@@inline never] - -let () = - f true; - f false - -(* Verify that physical equality/inequality is correctly propagated *) - -(* In these tests, tuple can be statically allocated only if it is a - known constant since the function is never inlined (hence this - code is never at toplevel) *) - -let () = - let f () = - let v = (1, 2) in - (* eq is supposed to be considered always true since v is a - constant, hence aliased to a symbol. - It is not yet optimized away if it is not constant *) - let eq = v == v in - let n = if eq then 1 else 2 in - let tuple = (n,n) in - assert(is_in_static_data tuple) - in - (f [@inlined never]) () - -let () = - let f () = - let v = (1, 2) in - (* same with inequality *) - let eq = v != v in - let n = if eq then 1 else 2 in - let tuple = (n,n) in - assert(is_in_static_data tuple) - in - (f [@inlined never]) () - -let () = - let f x = - let v1 = Some x in - let v2 = None in - let eq = v1 == v2 in - (* The values are structurally different, so must be physically - different *) - let n = if eq then 1 else 2 in - let tuple = (n,n) in - assert(is_in_static_data tuple) - in - (f [@inlined never]) () - -let () = - let f x = - let v1 = Some x in - let v2 = None in - let eq = v1 != v2 in - (* same with inequality *) - let n = if eq then 1 else 2 in - let tuple = (n,n) in - assert(is_in_static_data tuple) - in - (f [@inlined never]) () - -let () = - let f x = - let v1 = (1, 2) in - let v2 = (3, 2) in - let eq = v1 == v2 in - (* difference is deeper *) - let n = if eq then 1 else 2 in - let tuple = (n,n) in - assert(is_in_static_data tuple) - in - (f [@inlined never]) () - -module Int = struct - type t = int - let compare (a:int) b = compare a b -end -module IntMap = Map.Make (Int) - -let () = - let f () = - let a = IntMap.empty in - let b = (IntMap.add [@inlined]) 1 (Some 1) a in - assert(is_in_static_data b); - let c = (IntMap.add [@inlined]) 1 (Some 2) b in - assert(is_in_static_data c); - let d = (IntMap.add [@inlined]) 1 (Some 2) c in - assert(is_in_static_data d); - in - (f [@inlined never]) () diff --git a/testsuite/tests/asmcomp/is_static_flambda_dep.ml b/testsuite/tests/asmcomp/is_static_flambda_dep.ml deleted file mode 100644 index 3a50f7cad4d..00000000000 --- a/testsuite/tests/asmcomp/is_static_flambda_dep.ml +++ /dev/null @@ -1 +0,0 @@ -let pair = 1, 12 diff --git a/testsuite/tests/asmcomp/lift_mutable_let_flambda.ml b/testsuite/tests/asmcomp/lift_mutable_let_flambda.ml deleted file mode 100644 index 7f2758ef945..00000000000 --- a/testsuite/tests/asmcomp/lift_mutable_let_flambda.ml +++ /dev/null @@ -1,29 +0,0 @@ -(* TEST - flambda; - native; -*) - -type t = T of { pos : int } - -let[@inline always] find_pos i = - let i = ref i in - let pos = !i in - T {pos} - -let[@inline always] use_pos i = - let (T {pos}) = find_pos i in - pos * 2 - - -let f () = - let x0 = Gc.allocated_bytes () in - let x1 = Gc.allocated_bytes () in - - let n : int = (Sys.opaque_identity use_pos) 10 in - - let x2 = Gc.allocated_bytes () in - assert (n = 20); - assert(x1 -. x0 = x2 -. x1) (* check no allocation between x1 and x2 *) - [@@inline never] - -let () = f () diff --git a/testsuite/tests/asmcomp/optargs.ml b/testsuite/tests/asmcomp/optargs.ml deleted file mode 100644 index f7fec0117bb..00000000000 --- a/testsuite/tests/asmcomp/optargs.ml +++ /dev/null @@ -1,44 +0,0 @@ -(* TEST - flags = "-g"; - native; -*) - -(* Check the effectiveness of inlining the wrapper which fills in - default values for optional arguments. - - Ref: http://caml.inria.fr/mantis/view.php?id=6345 -*) - - -let rec f ?(flag = false) ?(acc = 0) = function - | [] -> if flag then acc else acc + 1 - | hd :: tl -> f ~flag ~acc:(acc + hd) tl - -let () = - let l = [1;2;3;4;5;6;7;8;9] in - let x0 = Gc.allocated_bytes () in - let x1 = Gc.allocated_bytes () in - for i = 1 to 1000 do - ignore (f l) - done; - let x2 = Gc.allocated_bytes () in - assert(x1 -. x0 = x2 -. x1) - (* check that we have not allocated anything between x1 and x2 *) - - -(* Check that 'ocaml.inline always' is not broken due to the split - into a worker+wrapper. *) - - -let[@ocaml.inline always] f ?(x = 1.) a b = a +. b *. x -let () = - let r = ref 0. in - let x0 = Gc.allocated_bytes () in - let x1 = Gc.allocated_bytes () in - for _ = 1 to 1000 do - r := !r +. f 1. 1. - done; - let x2 = Gc.allocated_bytes () in - assert(x1 -. x0 = x2 -. x1) - (* If the body of `f` itself were not inlined, we would get float - boxing allocations. *) diff --git a/testsuite/tests/asmcomp/poll_attr_both.compilers.reference b/testsuite/tests/asmcomp/poll_attr_both.compilers.reference deleted file mode 100644 index 9d549ca219a..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_both.compilers.reference +++ /dev/null @@ -1,13 +0,0 @@ -File "poll_attr_both.ml", lines 16-22, characters 19-13: -16 | ...................x = -17 | let y = Sys.opaque_identity(ref 42) in -18 | let x2 = v x in -19 | for c = 0 to x2 do -20 | ignore(Sys.opaque_identity(42)) -21 | done; -22 | x2 + !y -Error: Function with poll-error attribute contains polling points: - inserted poll - allocation at File "poll_attr_both.ml", line 17, characters 29-37 - function call at File "poll_attr_both.ml", line 18, characters 13-16 - diff --git a/testsuite/tests/asmcomp/poll_attr_both.ml b/testsuite/tests/asmcomp/poll_attr_both.ml deleted file mode 100644 index d86363b461d..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_both.ml +++ /dev/null @@ -1,37 +0,0 @@ -(* TEST_BELOW -(* Blank lines added here to preserve locations. *) - - - - - - - - - -*) - -let[@inline never][@local never] v x = x + 1 - -let[@poll error] c x = - let y = Sys.opaque_identity(ref 42) in - let x2 = v x in - for c = 0 to x2 do - ignore(Sys.opaque_identity(42)) - done; - x2 + !y - -(* TEST - poll-insertion; - { - setup-ocamlopt.byte-build-env; - ocamlopt_byte_exit_status = "2"; - ocamlopt.byte; - check-ocamlopt.byte-output; - }{ - setup-ocamlopt.opt-build-env; - ocamlopt_opt_exit_status = "2"; - ocamlopt.opt; - check-ocamlopt.opt-output; - } -*) diff --git a/testsuite/tests/asmcomp/poll_attr_inserted.compilers.reference b/testsuite/tests/asmcomp/poll_attr_inserted.compilers.reference deleted file mode 100644 index 8b02c70cbf8..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_inserted.compilers.reference +++ /dev/null @@ -1,8 +0,0 @@ -File "poll_attr_inserted.ml", lines 16-19, characters 19-6: -16 | ...................x = -17 | for c = 0 to 2 do -18 | ignore(Sys.opaque_identity(42)) -19 | done -Error: Function with poll-error attribute contains polling points (inserted by the compiler) - inserted poll - diff --git a/testsuite/tests/asmcomp/poll_attr_inserted.ml b/testsuite/tests/asmcomp/poll_attr_inserted.ml deleted file mode 100644 index 9a0b434e297..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_inserted.ml +++ /dev/null @@ -1,19 +0,0 @@ -(* TEST - poll-insertion; - { - setup-ocamlopt.byte-build-env; - ocamlopt_byte_exit_status = "2"; - ocamlopt.byte; - check-ocamlopt.byte-output; - }{ - setup-ocamlopt.opt-build-env; - ocamlopt_opt_exit_status = "2"; - ocamlopt.opt; - check-ocamlopt.opt-output; - } -*) - -let[@poll error] c x = - for c = 0 to 2 do - ignore(Sys.opaque_identity(42)) - done diff --git a/testsuite/tests/asmcomp/poll_attr_prologue.compilers.reference b/testsuite/tests/asmcomp/poll_attr_prologue.compilers.reference deleted file mode 100644 index 7467e58fc10..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_prologue.compilers.reference +++ /dev/null @@ -1,8 +0,0 @@ -File "poll_attr_prologue.ml", lines 14-17, characters 36-38: -14 | ....................................x l = -15 | match l with -16 | | [] -> 0 -17 | | _ :: tl -> (d[@tailcall]) (x+1) tl -Error: Function with poll-error attribute contains polling points: - function call at File "poll_attr_prologue.ml", line 17, characters 15-38 - diff --git a/testsuite/tests/asmcomp/poll_attr_prologue.ml b/testsuite/tests/asmcomp/poll_attr_prologue.ml deleted file mode 100644 index d1859c3dfa3..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_prologue.ml +++ /dev/null @@ -1,37 +0,0 @@ -(* TEST_BELOW -(* Blank lines added here to preserve locations. *) - - - - - - - - - -*) - -let[@poll error] rec c x l = - match l with - | [] -> 0 - | _ :: tl -> (d[@tailcall]) (x+1) tl - -and d x l = - match l with - | [] -> 0 - | _ :: tl -> (c[@tailcall]) (x+1) tl - -(* TEST - poll-insertion; - { - setup-ocamlopt.byte-build-env; - ocamlopt_byte_exit_status = "2"; - ocamlopt.byte; - check-ocamlopt.byte-output; - }{ - setup-ocamlopt.opt-build-env; - ocamlopt_opt_exit_status = "2"; - ocamlopt.opt; - check-ocamlopt.opt-output; - } -*) diff --git a/testsuite/tests/asmcomp/poll_attr_user.compilers.reference b/testsuite/tests/asmcomp/poll_attr_user.compilers.reference deleted file mode 100644 index 4bcb9d585e2..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_user.compilers.reference +++ /dev/null @@ -1,13 +0,0 @@ -File "poll_attr_user.ml", lines 16-22, characters 19-13: -16 | ...................x = -17 | let y = Sys.opaque_identity(ref 42) in -18 | let x2 = v x in -19 | for c = 0 to x2 do -20 | ignore(Sys.opaque_identity(ref 42)) -21 | done; -22 | x2 + !y -Error: Function with poll-error attribute contains polling points: - allocation at File "poll_attr_user.ml", line 17, characters 29-37 - function call at File "poll_attr_user.ml", line 18, characters 13-16 - allocation at File "poll_attr_user.ml", line 20, characters 34-42 - diff --git a/testsuite/tests/asmcomp/poll_attr_user.ml b/testsuite/tests/asmcomp/poll_attr_user.ml deleted file mode 100644 index 331cdf81c3b..00000000000 --- a/testsuite/tests/asmcomp/poll_attr_user.ml +++ /dev/null @@ -1,37 +0,0 @@ -(* TEST_BELOW -(* Blank lines added here to preserve locations. *) - - - - - - - - - -*) - -let[@inline never][@local never] v x = x + 1 - -let[@poll error] c x = - let y = Sys.opaque_identity(ref 42) in - let x2 = v x in - for c = 0 to x2 do - ignore(Sys.opaque_identity(ref 42)) - done; - x2 + !y - -(* TEST - poll-insertion; - { - setup-ocamlopt.byte-build-env; - ocamlopt_byte_exit_status = "2"; - ocamlopt.byte; - check-ocamlopt.byte-output; - }{ - setup-ocamlopt.opt-build-env; - ocamlopt_opt_exit_status = "2"; - ocamlopt.opt; - check-ocamlopt.opt-output; - } -*) diff --git a/testsuite/tests/asmcomp/polling.c b/testsuite/tests/asmcomp/polling.c deleted file mode 100644 index a69affc0f45..00000000000 --- a/testsuite/tests/asmcomp/polling.c +++ /dev/null @@ -1,30 +0,0 @@ -#define CAML_INTERNALS - -#include -#include -#include -#if CAML_RUNTIME_5 -#include -#include -#endif - -CAMLprim value request_minor_gc(value v) { - Caml_state->requested_minor_gc = 1; - Caml_state->requested_major_slice = 1; - /* - This is massively unsafe in multicore but the polling - tests are only run in a single domain, so we're probably - good. - */ - Caml_state->young_limit = (uintnat)Caml_state->young_end; - - return Val_unit; -} - -CAMLprim value minor_gcs(value v) { -#if CAML_RUNTIME_5 - return Val_long(atomic_load(&caml_minor_collections_count)); -#else - return Val_long(Caml_state->stat_minor_collections); -#endif -} diff --git a/testsuite/tests/asmcomp/polling_insertion.ml b/testsuite/tests/asmcomp/polling_insertion.ml deleted file mode 100644 index 6ebb7e1daf6..00000000000 --- a/testsuite/tests/asmcomp/polling_insertion.ml +++ /dev/null @@ -1,294 +0,0 @@ -(* TEST - modules = "polling.c"; - compare_programs = "false"; - poll-insertion; - arch64; - native; -*) - -(* This set of tests examine poll insertion behaviour. We do this by requesting - and checking the number of minor collections at various points to determine - whether a poll was correctly added. There are some subtleties because - [caml_empty_minor_heap] will not increment the minor_collections stat if - nothing has been allocated on the minor heap, so we sometimes need to - add an allocation before we call [request_minor_gc]. The [minor_gcs] - function returns the number of minor collections so far without allocating. - - ignore(Sys.opaque_identity(ref 41)) is used wherever we want to do an - allocation in order to use some minor heap so the minor collections stat is - incremented. - - ignore(Sys.opaque_identity(ref 42)) is used wherever we want an allocation - for the purposes of testing whether a poll would be elided or not. -*) - -external request_minor_gc : unit -> unit = "request_minor_gc" -external minor_gcs : unit -> int = "minor_gcs" - -(* This function tests that polls are added to loops *) -let polls_added_to_loops () = - let minors_before = minor_gcs () in - request_minor_gc (); - for a = 0 to 1 do - ignore (Sys.opaque_identity 42) - done; - let minors_now = minor_gcs () in - assert (minors_before < minors_now) - - -(* This function should have no prologue poll but will have - one in the loop. *) -let func_with_added_poll_because_loop () = - (* We do two loop iterations so that the poll is triggered whether - in poll-at-top or poll-at-bottom mode. *) - for a = 0 to Sys.opaque_identity(1) do - ignore (Sys.opaque_identity 42) - done - [@@inline never] - -let func_with_no_prologue_poll () = - (* this function does not have indirect or 'forward' tail call nor - does it call a synthesised function with suppressed polls. *) - ignore(Sys.opaque_identity(minor_gcs ())) - [@@inline never] - -let prologue_polls_in_functions () = - ignore(Sys.opaque_identity(ref 41)); - let minors_before = minor_gcs () in - request_minor_gc (); - func_with_added_poll_because_loop (); - let minors_now = minor_gcs () in - assert (minors_before < minors_now); - - ignore(Sys.opaque_identity(ref 41)); - let minors_before = minor_gcs () in - request_minor_gc (); - func_with_no_prologue_poll (); - let minors_now = minor_gcs () in - assert (minors_before = minors_now) - -(* These next functions test that polls are not added to functions that - unconditionally allocate. - [allocating_func] allocates unconditionally - [allocating_func_if] allocates unconditionally but does so - on two separate branches *) -let allocating_func minors_before = - let minors_now = minor_gcs () in - assert (minors_before = minors_now); - (* No poll yet *) - ignore (Sys.opaque_identity (ref 42)); - let minors_now2 = minor_gcs () in - assert (minors_before + 1 = minors_now2); - (* Polled at alloc *) - [@@inline never] - -let allocating_func_if minors_before = - let minors_now = minor_gcs () in - assert (minors_before = minors_now); - (* No poll yet *) - if minors_before > 0 then ignore (Sys.opaque_identity (ref 42)) - else ignore (Sys.opaque_identity (ref 42)); - let minors_now2 = minor_gcs () in - assert (minors_before < minors_now2); - (* Polled at alloc *) - [@@inline never] - -let allocating_func_nested_ifs minors_before = - let minors_now = minor_gcs () in - assert (minors_before = minors_now); - (* No poll yet *) - if Sys.opaque_identity(minors_before) > 0 then - if Sys.opaque_identity(minors_before) > 1 then - ignore (Sys.opaque_identity (ref 42)) - else - ignore (Sys.opaque_identity (ref 42)) - else - if Sys.opaque_identity(minors_before) < 5 then - ignore (Sys.opaque_identity (ref 42)) - else - ignore (Sys.opaque_identity (ref 42)); - let minors_now2 = minor_gcs () in - assert (minors_before < minors_now2); - (* Polled at alloc *) - [@@inline never] - -let allocating_func_match minors_before = - let minors_now = minor_gcs () in - assert (minors_before = minors_now); - (* No poll yet *) - match minors_before with - | 0 -> ignore (Sys.opaque_identity (ref 42)) - | _ -> ignore (Sys.opaque_identity (ref 42)); - let minors_now2 = minor_gcs () in - assert (minors_before < minors_now2); - (* Polled at alloc *) - [@@inline never] - -let polls_not_added_unconditionally_allocating_functions () = - let minors_before = minor_gcs () in - ignore(Sys.opaque_identity(ref 41)); - request_minor_gc (); - allocating_func minors_before; - let minors_before = minor_gcs () in - ignore(Sys.opaque_identity(ref 41)); - request_minor_gc (); - allocating_func_if minors_before; - let minors_before = minor_gcs () in - ignore(Sys.opaque_identity(ref 41)); - request_minor_gc (); - allocating_func_nested_ifs minors_before; - let minors_before = minor_gcs () in - ignore(Sys.opaque_identity(ref 41)); - request_minor_gc (); - allocating_func_match minors_before - -(* This function tests that polls are not added to the back edge of - where loop bodies allocate unconditionally *) -let polls_not_added_to_allocating_loops () = - let current_minors = ref (minor_gcs ()) in - request_minor_gc (); - for a = 0 to 1 do - (* Since the loop body allocates there should be no poll points *) - let minors_now = minor_gcs () in - assert(minors_now = !current_minors); - ignore(Sys.opaque_identity(ref 42)); - let minors_now2 = minor_gcs () in - assert(minors_now < minors_now2); - current_minors := minors_now2; - ignore(Sys.opaque_identity(ref 41)); - request_minor_gc () - done - -(* this next set of functions tests that self tail recursive functions - have polls added correctly *) -let rec self_rec_func n = - match n with - | 0 -> 0 - | _ -> - begin - let n1 = Sys.opaque_identity(n-1) in - (self_rec_func[@tailcall]) n1 - end - -let polls_added_to_self_recursive_functions () = - let minors_before = minor_gcs () in - request_minor_gc (); - ignore(self_rec_func 2); - let minors_after = minor_gcs () in - (* should be at least one minor gc from polls in self_rec_func *) - assert(minors_before < minors_after) - -(* this pair of mutually recursive functions is to test that a poll is - correctly placed in the first one compiled *) -let rec mut_rec_func_even d = - match d with - | 0 -> 0 - | _ -> mut_rec_func_odd (d-1) -and mut_rec_func_odd d = - mut_rec_func_even (d-1) -and mut_rec_func d = - match d with - | n when n mod 2 == 0 - -> mut_rec_func_even n - | n -> mut_rec_func_odd n - -let polls_added_to_mutually_recursive_functions () = - let minors_before = minor_gcs () in - request_minor_gc (); - ignore(mut_rec_func 3); - let minors_after = minor_gcs () in - (* should be at least one minor gc from polls in mut_rec_func *) - assert(minors_before < minors_after) - -(* this is to test that indirect tail calls (which might result in a self - call) have polls inserted in them. - These correspond to Itailcall_ind at Mach *) -let do_indirect_tail_call f n = - f (n-1) - [@@inline never] - -let polls_added_to_indirect_tail_calls () = - let f = fun n -> n+1 in - let minors_before = minor_gcs () in - request_minor_gc (); - ignore(do_indirect_tail_call f 3); - let minors_after = minor_gcs () in - (* should be at one minor gc from the poll in do_indirect_tail_call *) - assert(minors_before < minors_after) - -(* this is to test that indirect non-tail calls do not have a poll placed - in them. These correspond to Icall_ind at Mach *) -let do_indirect_call f n = - n * f (n-1) - [@@inline never] - -let polls_not_added_to_indirect_calls () = - let f = fun n -> n+1 in - let minors_before = minor_gcs () in - request_minor_gc (); - ignore(do_indirect_call f 3); - let minors_after = minor_gcs () in - (* should be at one minor gc from the poll in do_indirect_tail_call *) - assert(minors_before = minors_after) - -(* this set of functions tests that we don't poll for immediate - (non-tail) calls. These correspond to Icall_imm at Mach *) -let call_func1 n = - Sys.opaque_identity(n-1) - [@@inline never] - -let call_func2 n = - n * (call_func1 (Sys.opaque_identity(n+1))) - [@@inline never] - -let polls_not_added_to_immediate_calls () = - let minors_before = minor_gcs () in - request_minor_gc (); - ignore(call_func1 100); - let minors_after = minor_gcs () in - (* should be no minor collections *) - assert(minors_before = minors_after) - -let[@inline never][@local never] app minors_before f x y = - let minors_after_prologue = minor_gcs () in - assert(minors_before < minors_after_prologue); - request_minor_gc (); - f x y - -let polls_not_added_in_caml_apply () = - let minors_before = minor_gcs() in - request_minor_gc(); - ignore(Sys.opaque_identity(app minors_before (fun x y -> x * y) 5 4)); - let minors_after = minor_gcs() in - assert(minors_before < minors_after) - -let () = - ignore(Sys.opaque_identity(ref 41)); - polls_added_to_loops (); (* relies on there being some minor heap usage *) - - ignore(Sys.opaque_identity(ref 41)); - prologue_polls_in_functions (); - - ignore(Sys.opaque_identity(ref 41)); - polls_added_to_self_recursive_functions (); - - ignore(Sys.opaque_identity(ref 41)); - polls_added_to_mutually_recursive_functions (); - - ignore(Sys.opaque_identity(ref 41)); - polls_added_to_indirect_tail_calls (); - - ignore(Sys.opaque_identity(ref 41)); - polls_not_added_to_indirect_calls (); - - ignore(Sys.opaque_identity(ref 41)); - polls_not_added_to_immediate_calls (); - - ignore(Sys.opaque_identity(ref 41)); - polls_not_added_unconditionally_allocating_functions (); - - ignore(Sys.opaque_identity(ref 41)); - polls_not_added_to_allocating_loops (); - - ignore(Sys.opaque_identity(ref 41)); - polls_not_added_in_caml_apply () diff --git a/testsuite/tests/asmcomp/prevent_fma.ml b/testsuite/tests/asmcomp/prevent_fma.ml deleted file mode 100644 index 79506c9c888..00000000000 --- a/testsuite/tests/asmcomp/prevent_fma.ml +++ /dev/null @@ -1,22 +0,0 @@ -(* TEST - native; -*) - -let ( *. ) x y = Sys.opaque_identity (x *. y) -(* Using opaque_identity should prevent use of FMA. *) - -let f x = (x *. x -. x *. x) - (* The expression above can be compiled in two ways: - 1. First evaluating x' = x *. x, then x' -. x' - The result is obviously zero. - 2. First evaluating x' = x *. x, then x *. x -. x' as a single evaluation - step, using fused-multiply-add (or rather sub here). - FMA computes with increased precision because no rounding of the - intermediate computation happens. - In this case, the result is not always exactly 0. - - See issue #10323. *) - - -let () = - assert (Int64.bits_of_float (f (sqrt 2.0)) = 0L) diff --git a/testsuite/tests/asmcomp/register_typing.ml b/testsuite/tests/asmcomp/register_typing.ml deleted file mode 100644 index 424aa16ab32..00000000000 --- a/testsuite/tests/asmcomp/register_typing.ml +++ /dev/null @@ -1,24 +0,0 @@ -(* TEST - native; -*) - -type 'a typ = Int : int typ | Ptr : int list typ - -let f (type a) (t : a typ) (p : int list) : a = - match t with - | Int -> 100 - | Ptr -> p - -let allocate_garbage () = - for i = 0 to 100 do - ignore (Array.make 200 0.0) - done - -let g (t : int list typ) x = - Gc.minor (); - let x = f t ([x; x; x; x; x]) in - Gc.minor (); - allocate_garbage (); - ignore (String.length (String.concat " " (List.map Int.to_string x))) - -let () = g Ptr 5 diff --git a/testsuite/tests/asmcomp/register_typing_switch.ml b/testsuite/tests/asmcomp/register_typing_switch.ml deleted file mode 100644 index f6a3367d7b8..00000000000 --- a/testsuite/tests/asmcomp/register_typing_switch.ml +++ /dev/null @@ -1,25 +0,0 @@ -(* TEST - native; -*) - -type 'a typ = Int : int typ | Ptr : int list typ | Int2 : int typ - -let f (type a) (t : a typ) (p : int list) : a = - match t with - | Int -> 100 - | Ptr -> p - | Int2 -> 200 - -let allocate_garbage () = - for i = 0 to 100 do - ignore (Array.make 200 0.0) - done - -let g (t : int list typ) x = - Gc.minor (); - let x = f t ([x; x; x; x; x]) in - Gc.minor (); - allocate_garbage (); - ignore (String.length (String.concat " " (List.map Int.to_string x))) - -let () = g Ptr 5 diff --git a/testsuite/tests/asmcomp/regression_value_kinds.ml b/testsuite/tests/asmcomp/regression_value_kinds.ml deleted file mode 100644 index 0b274d3cc09..00000000000 --- a/testsuite/tests/asmcomp/regression_value_kinds.ml +++ /dev/null @@ -1,21 +0,0 @@ -(* TEST - native; -*) - -type r = { foo : float } - -type 'a t = Left of 'a | Right of r - -type 'a ty = - | Float : float ty - | Anything : 'a ty - -let f (type a) (ty : a ty) (x : a t) = - match ty, x with - | Float, Right { foo = (((3.5 : a) as a) : float) } - | _, Left a -> ignore (Sys.opaque_identity a) - | _, _ -> () - -let f = Sys.opaque_identity f - -let () = f Anything (Left 0) diff --git a/testsuite/tests/asmcomp/run.ml b/testsuite/tests/asmcomp/run.ml deleted file mode 100644 index feb4bf7902f..00000000000 --- a/testsuite/tests/asmcomp/run.ml +++ /dev/null @@ -1,9 +0,0 @@ -external run_prog : int -> int -> int -> unit = "run_prog" - -let arg n = - if n < Array.length Sys.argv then - int_of_string Sys.argv.(n) - else - 0 - -let () = run_prog (arg 1) (arg 2) (arg 3) diff --git a/testsuite/tests/asmcomp/select_addr.ml b/testsuite/tests/asmcomp/select_addr.ml deleted file mode 100644 index 25718bbc327..00000000000 --- a/testsuite/tests/asmcomp/select_addr.ml +++ /dev/null @@ -1,14 +0,0 @@ -(* TEST *) - -let[@inline never][@local never] f n = - let n = Int64.of_int n in - let open Int64 in - to_int (add n (of_int Int.min_int)) - -let _ = - (* The test only works on architectures where Sys.int_size is 63, - as it depends on the exact value of Int.min_int. *) - if Sys.int_size <> 63 then - Printf.printf "0x4000000000000001\n" - else - Printf.printf "0x%x\n%!" (f 1) diff --git a/testsuite/tests/asmcomp/select_addr.reference b/testsuite/tests/asmcomp/select_addr.reference deleted file mode 100644 index f7cd3db8cbb..00000000000 --- a/testsuite/tests/asmcomp/select_addr.reference +++ /dev/null @@ -1 +0,0 @@ -0x4000000000000001 diff --git a/testsuite/tests/asmcomp/simple_float_const.ml b/testsuite/tests/asmcomp/simple_float_const.ml deleted file mode 100644 index 1aca414f7e5..00000000000 --- a/testsuite/tests/asmcomp/simple_float_const.ml +++ /dev/null @@ -1 +0,0 @@ -let f = 3.14 diff --git a/testsuite/tests/asmcomp/simple_float_const_opaque.ml b/testsuite/tests/asmcomp/simple_float_const_opaque.ml deleted file mode 100644 index 1aca414f7e5..00000000000 --- a/testsuite/tests/asmcomp/simple_float_const_opaque.ml +++ /dev/null @@ -1 +0,0 @@ -let f = 3.14 diff --git a/testsuite/tests/asmcomp/static_float_array_flambda.ml b/testsuite/tests/asmcomp/static_float_array_flambda.ml deleted file mode 100644 index 3314db1c5e6..00000000000 --- a/testsuite/tests/asmcomp/static_float_array_flambda.ml +++ /dev/null @@ -1,26 +0,0 @@ -(* TEST - modules = "is_in_static_data.c simple_float_const.ml"; - flambda; - flat-float-array; - naked_pointers; - native; -*) - -external is_in_static_data : 'a -> bool = "caml_is_in_static_data" - -let a = [|0.; 1.|] -let f = 1.23 -let b = [|0.; f; f|] -let g = Sys.opaque_identity 1.23 -let c = [|0.; g|] -let d = [|0.; Simple_float_const.f|] - -let () = assert(is_in_static_data a) -let () = assert(is_in_static_data f) -let () = assert(is_in_static_data b) - -let () = assert(not (is_in_static_data c)) -(* In fact this one could be static by preallocating the array then - patching it when g is available *) - -let () = assert(is_in_static_data d) diff --git a/testsuite/tests/asmcomp/static_float_array_flambda_opaque.ml b/testsuite/tests/asmcomp/static_float_array_flambda_opaque.ml deleted file mode 100644 index 33dad7cfe3a..00000000000 --- a/testsuite/tests/asmcomp/static_float_array_flambda_opaque.ml +++ /dev/null @@ -1,30 +0,0 @@ -(* TEST - modules = "is_in_static_data.c simple_float_const_opaque.ml"; - flags = "-opaque"; - flambda; - flat-float-array; - naked_pointers; - native; -*) - -external is_in_static_data : 'a -> bool = "caml_is_in_static_data" - -let a = [|0.; 1.|] -let f = 1.23 -let b = [|0.; f; f|] -let g = Sys.opaque_identity 1.23 -let c = [|0.; g|] -let d = [|0.; Simple_float_const_opaque.f|] - -let () = assert(is_in_static_data a) -let () = assert(is_in_static_data f) -let () = assert(is_in_static_data b) - -let () = assert(not (is_in_static_data c)) -(* In fact this one could be static by preallocating the array then - patching it when g is available *) - -let () = assert(not (is_in_static_data d)) -(* The dependency Simple_float_const_opaque is built with opaque, - hence the value of Simple_float_const_opaque.f cannot be known - preventing the static allocation of d *) diff --git a/testsuite/tests/asmcomp/staticalloc.ml b/testsuite/tests/asmcomp/staticalloc.ml deleted file mode 100644 index 38d5587f0f5..00000000000 --- a/testsuite/tests/asmcomp/staticalloc.ml +++ /dev/null @@ -1,24 +0,0 @@ -(* TEST - include config; - flags = "config.cmx"; - native; -*) - -(* Check the effectiveness of structured constant propagation and - static allocation. - - Ref: http://caml.inria.fr/mantis/view.php?id=5779 -*) - -let () = - let x0 = Gc.allocated_bytes () in - let x1 = Gc.allocated_bytes () in - let pair x y = (x, y) in - let a = pair 1 2 in - let b = pair a ["x";"y"] in - let[@local never] g () = (a, fst b) in - assert (g () == ((1,2), (1,2))); - assert (fst (pair a a) == (1, 2)); - let x2 = Gc.allocated_bytes () in - assert(x1 -. x0 = x2 -. x1) - (* check that we did not allocated anything between x1 and x2 *) diff --git a/testsuite/tests/asmcomp/try_checkbound.ml b/testsuite/tests/asmcomp/try_checkbound.ml deleted file mode 100644 index 8dd980ce158..00000000000 --- a/testsuite/tests/asmcomp/try_checkbound.ml +++ /dev/null @@ -1,12 +0,0 @@ -(* TEST *) - -(* See PR#10339 *) - -let access (a: string array) n = - try - ignore (a.(n)); -1 - with _ -> - n - -let _ = - assert (access [||] 1 = 1) diff --git a/testsuite/tests/asmcomp/unrolling_flambda.ml b/testsuite/tests/asmcomp/unrolling_flambda.ml deleted file mode 100644 index c7c47b33832..00000000000 --- a/testsuite/tests/asmcomp/unrolling_flambda.ml +++ /dev/null @@ -1,11 +0,0 @@ -(* TEST - flambda; - native; -*) - -let rec f x = - if x > 0 then f (x - 1) - else 0 -[@@inline] - -let _ = f 0 diff --git a/testsuite/tests/asmcomp/unrolling_flambda2.ml b/testsuite/tests/asmcomp/unrolling_flambda2.ml deleted file mode 100644 index 70843c69eca..00000000000 --- a/testsuite/tests/asmcomp/unrolling_flambda2.ml +++ /dev/null @@ -1,24 +0,0 @@ -(* TEST - flambda; - native; -*) - -type t = { fn : t -> t -> int -> unit -> unit } - -let rec foo f b n x = - if n < 0 then () - else begin - foo f b (n - 1) x; - b.fn f b (n - 1) x - end -[@@specialise always] - -let rec bar f b n x = - if n < 0 then () - else begin - bar f b (n - 1) x; - f.fn f b (n - 1) x - end -[@@specialise always] - -let () = foo {fn = foo} {fn = bar} 10 () diff --git a/testsuite/tests/asmgen/arith.cmm b/testsuite/tests/asmgen/arith.cmm deleted file mode 100644 index 981f10eddfa..00000000000 --- a/testsuite/tests/asmgen/arith.cmm +++ /dev/null @@ -1,227 +0,0 @@ -(* TEST - readonly_files = "mainarith.c asan_report_wrappers.c"; - arguments = "mainarith.c asan_report_wrappers.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(* Regression test for arithmetic instructions *) - -(function "testarith" () - (let r "R" - (let d "D" - (let x (load int "X") - (let y (load int "Y") - (let f (load float "F") - (let g (load float "G") - (addraset r 0 0) - (addraset r 1 1) - (addraset r 2 -1) - (addraset r 3 256) - (addraset r 4 65536) - (addraset r 5 16777216) - (addraset r 6 -256) - (addraset r 7 -65536) - (addraset r 8 -16777216) - - (addraset r 9 (+ x y)) - (addraset r 10 (+ x 1)) - (addraset r 11 (+ x -1)) - - (addraset r 12 (+a "R" 8)) - (addraset r 13 (+a "R" y)) - - (addraset r 14 (- x y)) - (addraset r 15 (- x 1)) - (addraset r 16 (- x -1)) - - (addraset r 17 (- "R" 8)) - (addraset r 18 (- "R" y)) - - (addraset r 19 ( * x 2)) - (addraset r 20 ( * 2 x)) - (addraset r 21 ( * x 16)) - (addraset r 22 ( * 16 x)) - (addraset r 23 ( * x 12345)) - (addraset r 24 ( * 12345 x)) - (addraset r 25 ( * x y)) - - (addraset r 26 (/ x 2)) - (addraset r 27 (/ x 16)) - (addraset r 28 (/ x 7)) - (addraset r 29 (if (!= y 0) (/ x y) 0)) - - (addraset r 30 (mod x 2)) - (addraset r 31 (mod x 16)) - (addraset r 32 (if (!= y 0) (mod x y) 0)) - - (addraset r 33 (and x y)) - (addraset r 34 (and x 3)) - (addraset r 35 (and 3 x)) - - (addraset r 36 (or x y)) - (addraset r 37 (or x 3)) - (addraset r 38 (or 3 x)) - - (addraset r 39 (xor x y)) - (addraset r 40 (xor x 3)) - (addraset r 41 (xor 3 x)) - - (addraset r 42 (<< x y)) - (addraset r 43 (<< x 1)) - (addraset r 44 (<< x 8)) - - (addraset r 45 (>>u x y)) - (addraset r 46 (>>u x 1)) - (addraset r 47 (>>u x 8)) - - (addraset r 48 (>>s x y)) - (addraset r 49 (>>s x 1)) - (addraset r 50 (>>s x 8)) - - (addraset r 51 (== x y)) - (addraset r 52 (!= x y)) - (addraset r 53 (< x y)) - (addraset r 54 (> x y)) - (addraset r 55 (<= x y)) - (addraset r 56 (>= x y)) - (addraset r 57 (== x 1)) - (addraset r 58 (!= x 1)) - (addraset r 59 (< x 1)) - (addraset r 60 (> x 1)) - (addraset r 61 (<= x 1)) - (addraset r 62 (>= x 1)) - - (addraset r 63 (==a x y)) - (addraset r 64 (!=a x y)) - (addraset r 65 (a x y)) - (addraset r 67 (<=a x y)) - (addraset r 68 (>=a x y)) - (addraset r 69 (==a x 1)) - (addraset r 70 (!=a x 1)) - (addraset r 71 (a x 1)) - (addraset r 73 (<=a x 1)) - (addraset r 74 (>=a x 1)) - - (addraset r 75 (+ x (<< y 1))) - (addraset r 76 (+ x (<< y 2))) - (addraset r 77 (+ x (<< y 3))) - (addraset r 78 (- x (<< y 1))) - (addraset r 79 (- x (<< y 2))) - (addraset r 80 (- x (<< y 3))) - - (floataset d 0 0.0) - (floataset d 1 1.0) - (floataset d 2 -1.0) - (floataset d 3 (+f f g)) - (floataset d 4 (-f f g)) - (floataset d 5 ( *f f g)) - (floataset d 6 (/f f g)) - - (floataset d 7 (+f f (+f g 1.0))) - (floataset d 8 (-f f (+f g 1.0))) - (floataset d 9 ( *f f (+f g 1.0))) - (floataset d 10 (/f f (+f g 1.0))) - - (floataset d 11 (+f (+f f 1.0) g)) - (floataset d 12 (-f (+f f 1.0) g)) - (floataset d 13 ( *f (+f f 1.0) g)) - (floataset d 14 (/f (+f f 1.0) g)) - - (floataset d 15 (+f (+f f 1.0) (+f g 1.0))) - (floataset d 16 (-f (+f f 1.0) (+f g 1.0))) - (floataset d 17 ( *f (+f f 1.0) (+f g 1.0))) - (floataset d 18 (/f (+f f 1.0) (+f g 1.0))) - - (addraset r 81 (==f f g)) - (addraset r 82 (!=f f g)) - (addraset r 83 (f f g)) - (addraset r 85 (<=f f g)) - (addraset r 86 (>=f f g)) - - (floataset d 19 (floatofint x)) - (addraset r 87 (intoffloat f)) - - (if (and (>= x 0) (< x y)) - (seq (checkbound y x) (addraset r 88 1)) - (addraset r 88 0)) - - (if (< 0 y) - (seq (checkbound y 0) (addraset r 89 1)) - (addraset r 89 0)) - - (if (< 5 y) - (seq (checkbound y 5) (addraset r 90 1)) - (addraset r 90 0)) - - (addraset r 91 (letmut res int 1 (if (==f f g) [] (assign res 0)) res)) - (addraset r 92 (letmut res int 1 (if (!=f f g) [] (assign res 0)) res)) - (addraset r 93 (letmut res int 1 (if (f f g) [] (assign res 0)) res)) - (addraset r 95 (letmut res int 1 (if (<=f f g) [] (assign res 0)) res)) - (addraset r 96 (letmut res int 1 (if (>=f f g) [] (assign res 0)) res)) - - (addraset r 97 (==f (+f f 1.0) (+f g 1.0))) - (addraset r 98 (!=f (+f f 1.0) (+f g 1.0))) - (addraset r 99 (f (+f f 1.0) (+f g 1.0))) - (addraset r 101 (<=f (+f f 1.0) (+f g 1.0))) - (addraset r 102 (>=f (+f f 1.0) (+f g 1.0))) - - (addraset r 103 (==f f (+f g 1.0))) - (addraset r 104 (!=f f (+f g 1.0))) - (addraset r 105 (f f (+f g 1.0))) - (addraset r 107 (<=f f (+f g 1.0))) - (addraset r 108 (>=f f (+f g 1.0))) - - (addraset r 109 (==f (+f f 1.0) g)) - (addraset r 110 (!=f (+f f 1.0) g)) - (addraset r 111 (f (+f f 1.0) g)) - (addraset r 113 (<=f (+f f 1.0) g)) - (addraset r 114 (>=f (+f f 1.0) g)) - - (floataset d 20 (+f (floatofint x) 1.0)) - (addraset r 115 (intoffloat (+f f 1.0))) - - (floataset d 21 (+f f (load float "G"))) - (floataset d 22 (+f (load float "G") f)) - (floataset d 23 (-f f (load float "G"))) - (floataset d 24 (-f (load float "G") f)) - (floataset d 25 ( *f f (load float "G"))) - (floataset d 26 ( *f (load float "G") f)) - (floataset d 27 (/f f (load float "G"))) - (floataset d 28 (/f (load float "G") f)) - - (floataset d 29 (+f ( *f f 2.0) (load float "G"))) - (floataset d 30 (+f (load float "G") ( *f f 2.0))) - (floataset d 31 (-f ( *f f 2.0) (load float "G"))) - (floataset d 32 (-f (load float "G") ( *f f 2.0))) - (floataset d 33 ( *f ( +f f 2.0) (load float "G"))) - (floataset d 34 ( *f (load float "G") ( +f f 2.0))) - (floataset d 35 (/f ( *f f 2.0) (load float "G"))) - (floataset d 36 (/f (load float "G") ( *f f 2.0))) - - (floataset d 37 (-f f)) - (floataset d 38 (absf f)) - - (addraset r 116 (mulh x y)) -))))))) diff --git a/testsuite/tests/asmgen/asan_report_wrappers.c b/testsuite/tests/asmgen/asan_report_wrappers.c deleted file mode 100644 index 46ca8a0d0e6..00000000000 --- a/testsuite/tests/asmgen/asan_report_wrappers.c +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -#ifdef WITH_ADDRESS_SANITIZER - -#define CREATE_ASAN_REPORT_WRAPPER(memory_access, size) \ -void __asan_report_ ## memory_access ## size ## _noabort(const void* addr); \ -CAMLexport void __attribute__((preserve_all)) caml_asan_report_ ## memory_access ## size ## _noabort(const void* addr) { \ - return __asan_report_ ## memory_access ## size ## _noabort(addr); \ -} - -CREATE_ASAN_REPORT_WRAPPER(load, 1) -CREATE_ASAN_REPORT_WRAPPER(load, 2) -CREATE_ASAN_REPORT_WRAPPER(load, 4) -CREATE_ASAN_REPORT_WRAPPER(load, 8) -CREATE_ASAN_REPORT_WRAPPER(load, 16) -CREATE_ASAN_REPORT_WRAPPER(store, 1) -CREATE_ASAN_REPORT_WRAPPER(store, 2) -CREATE_ASAN_REPORT_WRAPPER(store, 4) -CREATE_ASAN_REPORT_WRAPPER(store, 8) -CREATE_ASAN_REPORT_WRAPPER(store, 16) - -#undef CREATE_ASAN_REPORT_WRAPPER - -#else -// Prevents triggering [-Wempty-translation-unit], which is enabled by [-Wpedantic]. -static void __attribute__((used)) unused_function_to_avoid_c_compiler_warning(void) {} -#endif diff --git a/testsuite/tests/asmgen/catch-float.cmm b/testsuite/tests/asmgen/catch-float.cmm deleted file mode 100644 index e679a0e2912..00000000000 --- a/testsuite/tests/asmgen/catch-float.cmm +++ /dev/null @@ -1,11 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DFLOAT_CATCH -DFUN=catch_float main.c"; - asmgen; -*) - -(function "catch_float" (b:int) - (+f 10.0 - (catch - (exit lbl 100.0) - with (lbl x:float) (+f x 1000.0)))) diff --git a/testsuite/tests/asmgen/catch-multiple.cmm b/testsuite/tests/asmgen/catch-multiple.cmm deleted file mode 100644 index 498235ad721..00000000000 --- a/testsuite/tests/asmgen/catch-multiple.cmm +++ /dev/null @@ -1,20 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=catch_multiple main.c"; - asmgen; -*) - -(* -Expected output: -catch_multiple(0) == -1 -catch_multiple(1) == 1 -*) - -(function "catch_multiple" (b:int) - (let x - (catch - (if (== b 0) (exit zero) - (exit other)) - with (zero) -1 - and (other) ( * b b)) - x)) diff --git a/testsuite/tests/asmgen/catch-rec-deadhandler.cmm b/testsuite/tests/asmgen/catch-rec-deadhandler.cmm deleted file mode 100644 index 69bfe1f231b..00000000000 --- a/testsuite/tests/asmgen/catch-rec-deadhandler.cmm +++ /dev/null @@ -1,16 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DUNIT_INT -DFUN=catch_rec_deadhandler main.c"; - asmgen; - run; - check-program-output; -*) - -(function "catch_rec_deadhandler" () - (let x - (catch - (exit one) - with (one) 1 - and (two) (exit three) - and (three) 3) - x)) diff --git a/testsuite/tests/asmgen/catch-rec-deadhandler.reference b/testsuite/tests/asmgen/catch-rec-deadhandler.reference deleted file mode 100644 index 6ac08fb05e1..00000000000 --- a/testsuite/tests/asmgen/catch-rec-deadhandler.reference +++ /dev/null @@ -1,6 +0,0 @@ - catch rec - exit(1) - with(1) - catch rec - exit(1) - with(1) diff --git a/testsuite/tests/asmgen/catch-rec-deadhandler.run b/testsuite/tests/asmgen/catch-rec-deadhandler.run deleted file mode 100644 index 20ec67d0c60..00000000000 --- a/testsuite/tests/asmgen/catch-rec-deadhandler.run +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -exec > "${output}" 2>&1 - -cat "${reference}" diff --git a/testsuite/tests/asmgen/catch-rec.cmm b/testsuite/tests/asmgen/catch-rec.cmm deleted file mode 100644 index 37288f8dab5..00000000000 --- a/testsuite/tests/asmgen/catch-rec.cmm +++ /dev/null @@ -1,11 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=catch_fact main.c"; - asmgen; -*) - -(function "catch_fact" (b:int) - (catch (exit fact b 1) - with (fact c:val acc:val) - (if (== c 0) acc - (exit fact (- c 1) ( * c acc))))) diff --git a/testsuite/tests/asmgen/catch-try-float.cmm b/testsuite/tests/asmgen/catch-try-float.cmm deleted file mode 100644 index 7aa72343958..00000000000 --- a/testsuite/tests/asmgen/catch-try-float.cmm +++ /dev/null @@ -1,12 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DFLOAT_CATCH -DFUN=catch_try_float main.c"; - asmgen; -*) - -(function "catch_try_float" (b:float) - (+f 10.0 - (catch - (try (exit lbl 100.0) - with var 456.0) - with (lbl x:float) (+f x 1000.0)))) diff --git a/testsuite/tests/asmgen/catch-try.cmm b/testsuite/tests/asmgen/catch-try.cmm deleted file mode 100644 index b5253843ed2..00000000000 --- a/testsuite/tests/asmgen/catch-try.cmm +++ /dev/null @@ -1,12 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=catch_exit main.c"; - asmgen; -*) - -(function "catch_exit" (b:int) - (+ 33 - (catch - (try (exit lbl 12) - with var 456) - with (lbl x:val) (+ x 789)))) diff --git a/testsuite/tests/asmgen/checkbound.cmm b/testsuite/tests/asmgen/checkbound.cmm deleted file mode 100644 index a2607b49d2a..00000000000 --- a/testsuite/tests/asmgen/checkbound.cmm +++ /dev/null @@ -1,26 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DCHECKBOUND main.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "checkbound2" (x: int y: int) - (checkbound x y)) - -(function "checkbound1" (x: int) - (checkbound x 2)) diff --git a/testsuite/tests/asmgen/even-odd-spill-float.cmm b/testsuite/tests/asmgen/even-odd-spill-float.cmm deleted file mode 100644 index a907b71fc27..00000000000 --- a/testsuite/tests/asmgen/even-odd-spill-float.cmm +++ /dev/null @@ -1,27 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_FLOAT -DFUN=is_even main.c"; - asmgen; -*) - -("format_odd": string "odd %d\n\000") -("format_even": string "even %d\n\000") - -(function "force_spill" (a:int) 0) -(function "force_spill_float" (f:float) 0.0) - -(function "is_even" (b:int) - (catch (exit even b 0.0) - with (odd v:val f:float) - (if (== v 0) f - (seq - (extcall "printf_int" "format_odd" v unit) - (let v2 (- v 1) - (app "force_spill" 0 int) - (app "force_spill_float" 0.0 float) - (exit even v2 (+f 1.0 f))))) - and (even v:val f:float) - (if (== v 0) f - (seq - (extcall "printf_int" "format_even" v unit) - (exit odd (- v 1) (+f 1.0 f)))))) diff --git a/testsuite/tests/asmgen/even-odd-spill.cmm b/testsuite/tests/asmgen/even-odd-spill.cmm deleted file mode 100644 index 7d3a8040b53..00000000000 --- a/testsuite/tests/asmgen/even-odd-spill.cmm +++ /dev/null @@ -1,25 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=is_even main.c"; - asmgen; -*) - -("format_odd": string "odd %d\n\000") -("format_even": string "even %d\n\000") - -(function "force_spill" (a:int) 0) - -(function "is_even" (b:int) - (catch (exit even b) - with (odd v:val) - (if (== v 0) 0 - (seq - (extcall "printf_int" "format_odd" v unit) - (let v2 (- v 1) - (app "force_spill" 0 int) - (exit even v2)))) - and (even v:val) - (if (== v 0) 1 - (seq - (extcall "printf_int" "format_even" v unit) - (exit odd (- v 1)))))) diff --git a/testsuite/tests/asmgen/even-odd.cmm b/testsuite/tests/asmgen/even-odd.cmm deleted file mode 100644 index 51431017015..00000000000 --- a/testsuite/tests/asmgen/even-odd.cmm +++ /dev/null @@ -1,14 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=is_even main.c"; - asmgen; -*) - -(function "is_even" (b:int) - (catch (exit even b) - with (odd v:val) - (if (== v 0) 0 - (exit even (- v 1))) - and (even v:val) - (if (== v 0) 1 - (exit odd (- v 1))))) diff --git a/testsuite/tests/asmgen/fib.cmm b/testsuite/tests/asmgen/fib.cmm deleted file mode 100644 index 6399a6c6cdf..00000000000 --- a/testsuite/tests/asmgen/fib.cmm +++ /dev/null @@ -1,26 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=fib main.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "fib" (n: int) - (if (< n 2) - 1 - (+ (app "fib" (- n 1) int) - (app "fib" (- n 2) int)))) diff --git a/testsuite/tests/asmgen/immediates.cmm b/testsuite/tests/asmgen/immediates.cmm deleted file mode 100644 index de848b877f9..00000000000 --- a/testsuite/tests/asmgen/immediates.cmm +++ /dev/null @@ -1,48 +0,0 @@ -(* TEST - readonly_files = "mainimmed.c asan_report_wrappers.c"; - arguments = "-I ${test_source_directory} mainimmed.c asan_report_wrappers.c"; - asmgen; -*) -(* Regenerate with cpp -P immediates.cmmpp > immediates.cmm *) -(function "testimm" () - (let x (load int "X") - (let r "R" - (letmut i int 0 -(addraset r i (+ x 0)) (assign i (+ i 1)) (addraset r i (- x 0)) (assign i (+ i 1)) (addraset r i ( * x 0)) (assign i (+ i 1)) (addraset r i (and x 0)) (assign i (+ i 1)) (addraset r i (or x 0)) (assign i (+ i 1)) (addraset r i (xor x 0)) (assign i (+ i 1)) (addraset r i (< x 0)) (assign i (+ i 1)) (checkbound i 0) -(addraset r i (+ x 1)) (assign i (+ i 1)) (addraset r i (- x 1)) (assign i (+ i 1)) (addraset r i ( * x 1)) (assign i (+ i 1)) (addraset r i (and x 1)) (assign i (+ i 1)) (addraset r i (or x 1)) (assign i (+ i 1)) (addraset r i (xor x 1)) (assign i (+ i 1)) (addraset r i (< x 1)) (assign i (+ i 1)) (checkbound i 1) -(addraset r i (+ x 0xFF)) (assign i (+ i 1)) (addraset r i (- x 0xFF)) (assign i (+ i 1)) (addraset r i ( * x 0xFF)) (assign i (+ i 1)) (addraset r i (and x 0xFF)) (assign i (+ i 1)) (addraset r i (or x 0xFF)) (assign i (+ i 1)) (addraset r i (xor x 0xFF)) (assign i (+ i 1)) (addraset r i (< x 0xFF)) (assign i (+ i 1)) (checkbound i 0xFF) -(addraset r i (+ x 0x100)) (assign i (+ i 1)) (addraset r i (- x 0x100)) (assign i (+ i 1)) (addraset r i ( * x 0x100)) (assign i (+ i 1)) (addraset r i (and x 0x100)) (assign i (+ i 1)) (addraset r i (or x 0x100)) (assign i (+ i 1)) (addraset r i (xor x 0x100)) (assign i (+ i 1)) (addraset r i (< x 0x100)) (assign i (+ i 1)) (checkbound i 0x100) -(addraset r i (+ x 0x3FC)) (assign i (+ i 1)) (addraset r i (- x 0x3FC)) (assign i (+ i 1)) (addraset r i ( * x 0x3FC)) (assign i (+ i 1)) (addraset r i (and x 0x3FC)) (assign i (+ i 1)) (addraset r i (or x 0x3FC)) (assign i (+ i 1)) (addraset r i (xor x 0x3FC)) (assign i (+ i 1)) (addraset r i (< x 0x3FC)) (assign i (+ i 1)) (checkbound i 0x3FC) -(addraset r i (+ x 0x3FF)) (assign i (+ i 1)) (addraset r i (- x 0x3FF)) (assign i (+ i 1)) (addraset r i ( * x 0x3FF)) (assign i (+ i 1)) (addraset r i (and x 0x3FF)) (assign i (+ i 1)) (addraset r i (or x 0x3FF)) (assign i (+ i 1)) (addraset r i (xor x 0x3FF)) (assign i (+ i 1)) (addraset r i (< x 0x3FF)) (assign i (+ i 1)) (checkbound i 0x3FF) -(addraset r i (+ x 0x7FF)) (assign i (+ i 1)) (addraset r i (- x 0x7FF)) (assign i (+ i 1)) (addraset r i ( * x 0x7FF)) (assign i (+ i 1)) (addraset r i (and x 0x7FF)) (assign i (+ i 1)) (addraset r i (or x 0x7FF)) (assign i (+ i 1)) (addraset r i (xor x 0x7FF)) (assign i (+ i 1)) (addraset r i (< x 0x7FF)) (assign i (+ i 1)) (checkbound i 0x7FF) -(addraset r i (+ x 0x800)) (assign i (+ i 1)) (addraset r i (- x 0x800)) (assign i (+ i 1)) (addraset r i ( * x 0x800)) (assign i (+ i 1)) (addraset r i (and x 0x800)) (assign i (+ i 1)) (addraset r i (or x 0x800)) (assign i (+ i 1)) (addraset r i (xor x 0x800)) (assign i (+ i 1)) (addraset r i (< x 0x800)) (assign i (+ i 1)) (checkbound i 0x800) -(addraset r i (+ x 0x801)) (assign i (+ i 1)) (addraset r i (- x 0x801)) (assign i (+ i 1)) (addraset r i ( * x 0x801)) (assign i (+ i 1)) (addraset r i (and x 0x801)) (assign i (+ i 1)) (addraset r i (or x 0x801)) (assign i (+ i 1)) (addraset r i (xor x 0x801)) (assign i (+ i 1)) (addraset r i (< x 0x801)) (assign i (+ i 1)) (checkbound i 0x801) -(addraset r i (+ x 0xFFF)) (assign i (+ i 1)) (addraset r i (- x 0xFFF)) (assign i (+ i 1)) (addraset r i ( * x 0xFFF)) (assign i (+ i 1)) (addraset r i (and x 0xFFF)) (assign i (+ i 1)) (addraset r i (or x 0xFFF)) (assign i (+ i 1)) (addraset r i (xor x 0xFFF)) (assign i (+ i 1)) (addraset r i (< x 0xFFF)) (assign i (+ i 1)) (checkbound i 0xFFF) -(addraset r i (+ x 0x1000)) (assign i (+ i 1)) (addraset r i (- x 0x1000)) (assign i (+ i 1)) (addraset r i ( * x 0x1000)) (assign i (+ i 1)) (addraset r i (and x 0x1000)) (assign i (+ i 1)) (addraset r i (or x 0x1000)) (assign i (+ i 1)) (addraset r i (xor x 0x1000)) (assign i (+ i 1)) (addraset r i (< x 0x1000)) (assign i (+ i 1)) (checkbound i 0x1000) -(addraset r i (+ x 0x1001)) (assign i (+ i 1)) (addraset r i (- x 0x1001)) (assign i (+ i 1)) (addraset r i ( * x 0x1001)) (assign i (+ i 1)) (addraset r i (and x 0x1001)) (assign i (+ i 1)) (addraset r i (or x 0x1001)) (assign i (+ i 1)) (addraset r i (xor x 0x1001)) (assign i (+ i 1)) (addraset r i (< x 0x1001)) (assign i (+ i 1)) (checkbound i 0x1001) -(addraset r i (+ x 0x7FFF)) (assign i (+ i 1)) (addraset r i (- x 0x7FFF)) (assign i (+ i 1)) (addraset r i ( * x 0x7FFF)) (assign i (+ i 1)) (addraset r i (and x 0x7FFF)) (assign i (+ i 1)) (addraset r i (or x 0x7FFF)) (assign i (+ i 1)) (addraset r i (xor x 0x7FFF)) (assign i (+ i 1)) (addraset r i (< x 0x7FFF)) (assign i (+ i 1)) (checkbound i 0x7FFF) -(addraset r i (+ x 0x8000)) (assign i (+ i 1)) (addraset r i (- x 0x8000)) (assign i (+ i 1)) (addraset r i ( * x 0x8000)) (assign i (+ i 1)) (addraset r i (and x 0x8000)) (assign i (+ i 1)) (addraset r i (or x 0x8000)) (assign i (+ i 1)) (addraset r i (xor x 0x8000)) (assign i (+ i 1)) (addraset r i (< x 0x8000)) (assign i (+ i 1)) (checkbound i 0x8000) -(addraset r i (+ x 0x8001)) (assign i (+ i 1)) (addraset r i (- x 0x8001)) (assign i (+ i 1)) (addraset r i ( * x 0x8001)) (assign i (+ i 1)) (addraset r i (and x 0x8001)) (assign i (+ i 1)) (addraset r i (or x 0x8001)) (assign i (+ i 1)) (addraset r i (xor x 0x8001)) (assign i (+ i 1)) (addraset r i (< x 0x8001)) (assign i (+ i 1)) (checkbound i 0x8001) -(addraset r i (+ x 0xFFF000)) (assign i (+ i 1)) (addraset r i (- x 0xFFF000)) (assign i (+ i 1)) (addraset r i ( * x 0xFFF000)) (assign i (+ i 1)) (addraset r i (and x 0xFFF000)) (assign i (+ i 1)) (addraset r i (or x 0xFFF000)) (assign i (+ i 1)) (addraset r i (xor x 0xFFF000)) (assign i (+ i 1)) (addraset r i (< x 0xFFF000)) (assign i (+ i 1)) (checkbound i 0xFFF000) -(addraset r i (+ x 0xFFFFFF)) (assign i (+ i 1)) (addraset r i (- x 0xFFFFFF)) (assign i (+ i 1)) (addraset r i ( * x 0xFFFFFF)) (assign i (+ i 1)) (addraset r i (and x 0xFFFFFF)) (assign i (+ i 1)) (addraset r i (or x 0xFFFFFF)) (assign i (+ i 1)) (addraset r i (xor x 0xFFFFFF)) (assign i (+ i 1)) (addraset r i (< x 0xFFFFFF)) (assign i (+ i 1)) (checkbound i 0xFFFFFF) -(addraset r i (+ x 0x1000000)) (assign i (+ i 1)) (addraset r i (- x 0x1000000)) (assign i (+ i 1)) (addraset r i ( * x 0x1000000)) (assign i (+ i 1)) (addraset r i (and x 0x1000000)) (assign i (+ i 1)) (addraset r i (or x 0x1000000)) (assign i (+ i 1)) (addraset r i (xor x 0x1000000)) (assign i (+ i 1)) (addraset r i (< x 0x1000000)) (assign i (+ i 1)) (checkbound i 0x1000000) -(addraset r i (+ x 0x1000001)) (assign i (+ i 1)) (addraset r i (- x 0x1000001)) (assign i (+ i 1)) (addraset r i ( * x 0x1000001)) (assign i (+ i 1)) (addraset r i (and x 0x1000001)) (assign i (+ i 1)) (addraset r i (or x 0x1000001)) (assign i (+ i 1)) (addraset r i (xor x 0x1000001)) (assign i (+ i 1)) (addraset r i (< x 0x1000001)) (assign i (+ i 1)) (checkbound i 0x1000001) -(addraset r i (+ x -1)) (assign i (+ i 1)) (addraset r i (- x -1)) (assign i (+ i 1)) (addraset r i ( * x -1)) (assign i (+ i 1)) (addraset r i (and x -1)) (assign i (+ i 1)) (addraset r i (or x -1)) (assign i (+ i 1)) (addraset r i (xor x -1)) (assign i (+ i 1)) (addraset r i (< x -1)) (assign i (+ i 1)) (checkbound i -1) -(addraset r i (+ x -0xFF)) (assign i (+ i 1)) (addraset r i (- x -0xFF)) (assign i (+ i 1)) (addraset r i ( * x -0xFF)) (assign i (+ i 1)) (addraset r i (and x -0xFF)) (assign i (+ i 1)) (addraset r i (or x -0xFF)) (assign i (+ i 1)) (addraset r i (xor x -0xFF)) (assign i (+ i 1)) (addraset r i (< x -0xFF)) (assign i (+ i 1)) (checkbound i -0xFF) -(addraset r i (+ x -0x100)) (assign i (+ i 1)) (addraset r i (- x -0x100)) (assign i (+ i 1)) (addraset r i ( * x -0x100)) (assign i (+ i 1)) (addraset r i (and x -0x100)) (assign i (+ i 1)) (addraset r i (or x -0x100)) (assign i (+ i 1)) (addraset r i (xor x -0x100)) (assign i (+ i 1)) (addraset r i (< x -0x100)) (assign i (+ i 1)) (checkbound i -0x100) -(addraset r i (+ x -0x3FC)) (assign i (+ i 1)) (addraset r i (- x -0x3FC)) (assign i (+ i 1)) (addraset r i ( * x -0x3FC)) (assign i (+ i 1)) (addraset r i (and x -0x3FC)) (assign i (+ i 1)) (addraset r i (or x -0x3FC)) (assign i (+ i 1)) (addraset r i (xor x -0x3FC)) (assign i (+ i 1)) (addraset r i (< x -0x3FC)) (assign i (+ i 1)) (checkbound i -0x3FC) -(addraset r i (+ x -0x3FF)) (assign i (+ i 1)) (addraset r i (- x -0x3FF)) (assign i (+ i 1)) (addraset r i ( * x -0x3FF)) (assign i (+ i 1)) (addraset r i (and x -0x3FF)) (assign i (+ i 1)) (addraset r i (or x -0x3FF)) (assign i (+ i 1)) (addraset r i (xor x -0x3FF)) (assign i (+ i 1)) (addraset r i (< x -0x3FF)) (assign i (+ i 1)) (checkbound i -0x3FF) -(addraset r i (+ x -0x7FF)) (assign i (+ i 1)) (addraset r i (- x -0x7FF)) (assign i (+ i 1)) (addraset r i ( * x -0x7FF)) (assign i (+ i 1)) (addraset r i (and x -0x7FF)) (assign i (+ i 1)) (addraset r i (or x -0x7FF)) (assign i (+ i 1)) (addraset r i (xor x -0x7FF)) (assign i (+ i 1)) (addraset r i (< x -0x7FF)) (assign i (+ i 1)) (checkbound i -0x7FF) -(addraset r i (+ x -0x800)) (assign i (+ i 1)) (addraset r i (- x -0x800)) (assign i (+ i 1)) (addraset r i ( * x -0x800)) (assign i (+ i 1)) (addraset r i (and x -0x800)) (assign i (+ i 1)) (addraset r i (or x -0x800)) (assign i (+ i 1)) (addraset r i (xor x -0x800)) (assign i (+ i 1)) (addraset r i (< x -0x800)) (assign i (+ i 1)) (checkbound i -0x800) -(addraset r i (+ x -0x801)) (assign i (+ i 1)) (addraset r i (- x -0x801)) (assign i (+ i 1)) (addraset r i ( * x -0x801)) (assign i (+ i 1)) (addraset r i (and x -0x801)) (assign i (+ i 1)) (addraset r i (or x -0x801)) (assign i (+ i 1)) (addraset r i (xor x -0x801)) (assign i (+ i 1)) (addraset r i (< x -0x801)) (assign i (+ i 1)) (checkbound i -0x801) -(addraset r i (+ x -0xFFF)) (assign i (+ i 1)) (addraset r i (- x -0xFFF)) (assign i (+ i 1)) (addraset r i ( * x -0xFFF)) (assign i (+ i 1)) (addraset r i (and x -0xFFF)) (assign i (+ i 1)) (addraset r i (or x -0xFFF)) (assign i (+ i 1)) (addraset r i (xor x -0xFFF)) (assign i (+ i 1)) (addraset r i (< x -0xFFF)) (assign i (+ i 1)) (checkbound i -0xFFF) -(addraset r i (+ x -0x1000)) (assign i (+ i 1)) (addraset r i (- x -0x1000)) (assign i (+ i 1)) (addraset r i ( * x -0x1000)) (assign i (+ i 1)) (addraset r i (and x -0x1000)) (assign i (+ i 1)) (addraset r i (or x -0x1000)) (assign i (+ i 1)) (addraset r i (xor x -0x1000)) (assign i (+ i 1)) (addraset r i (< x -0x1000)) (assign i (+ i 1)) (checkbound i -0x1000) -(addraset r i (+ x -0x1001)) (assign i (+ i 1)) (addraset r i (- x -0x1001)) (assign i (+ i 1)) (addraset r i ( * x -0x1001)) (assign i (+ i 1)) (addraset r i (and x -0x1001)) (assign i (+ i 1)) (addraset r i (or x -0x1001)) (assign i (+ i 1)) (addraset r i (xor x -0x1001)) (assign i (+ i 1)) (addraset r i (< x -0x1001)) (assign i (+ i 1)) (checkbound i -0x1001) -(addraset r i (+ x -0x7FFF)) (assign i (+ i 1)) (addraset r i (- x -0x7FFF)) (assign i (+ i 1)) (addraset r i ( * x -0x7FFF)) (assign i (+ i 1)) (addraset r i (and x -0x7FFF)) (assign i (+ i 1)) (addraset r i (or x -0x7FFF)) (assign i (+ i 1)) (addraset r i (xor x -0x7FFF)) (assign i (+ i 1)) (addraset r i (< x -0x7FFF)) (assign i (+ i 1)) (checkbound i -0x7FFF) -(addraset r i (+ x -0x8000)) (assign i (+ i 1)) (addraset r i (- x -0x8000)) (assign i (+ i 1)) (addraset r i ( * x -0x8000)) (assign i (+ i 1)) (addraset r i (and x -0x8000)) (assign i (+ i 1)) (addraset r i (or x -0x8000)) (assign i (+ i 1)) (addraset r i (xor x -0x8000)) (assign i (+ i 1)) (addraset r i (< x -0x8000)) (assign i (+ i 1)) (checkbound i -0x8000) -(addraset r i (+ x -0x8001)) (assign i (+ i 1)) (addraset r i (- x -0x8001)) (assign i (+ i 1)) (addraset r i ( * x -0x8001)) (assign i (+ i 1)) (addraset r i (and x -0x8001)) (assign i (+ i 1)) (addraset r i (or x -0x8001)) (assign i (+ i 1)) (addraset r i (xor x -0x8001)) (assign i (+ i 1)) (addraset r i (< x -0x8001)) (assign i (+ i 1)) (checkbound i -0x8001) -(addraset r i (+ x -0xFFF000)) (assign i (+ i 1)) (addraset r i (- x -0xFFF000)) (assign i (+ i 1)) (addraset r i ( * x -0xFFF000)) (assign i (+ i 1)) (addraset r i (and x -0xFFF000)) (assign i (+ i 1)) (addraset r i (or x -0xFFF000)) (assign i (+ i 1)) (addraset r i (xor x -0xFFF000)) (assign i (+ i 1)) (addraset r i (< x -0xFFF000)) (assign i (+ i 1)) (checkbound i -0xFFF000) -(addraset r i (+ x -0xFFFFFF)) (assign i (+ i 1)) (addraset r i (- x -0xFFFFFF)) (assign i (+ i 1)) (addraset r i ( * x -0xFFFFFF)) (assign i (+ i 1)) (addraset r i (and x -0xFFFFFF)) (assign i (+ i 1)) (addraset r i (or x -0xFFFFFF)) (assign i (+ i 1)) (addraset r i (xor x -0xFFFFFF)) (assign i (+ i 1)) (addraset r i (< x -0xFFFFFF)) (assign i (+ i 1)) (checkbound i -0xFFFFFF) -(addraset r i (+ x -0x1000000)) (assign i (+ i 1)) (addraset r i (- x -0x1000000)) (assign i (+ i 1)) (addraset r i ( * x -0x1000000)) (assign i (+ i 1)) (addraset r i (and x -0x1000000)) (assign i (+ i 1)) (addraset r i (or x -0x1000000)) (assign i (+ i 1)) (addraset r i (xor x -0x1000000)) (assign i (+ i 1)) (addraset r i (< x -0x1000000)) (assign i (+ i 1)) (checkbound i -0x1000000) -(addraset r i (+ x -0x1000001)) (assign i (+ i 1)) (addraset r i (- x -0x1000001)) (assign i (+ i 1)) (addraset r i ( * x -0x1000001)) (assign i (+ i 1)) (addraset r i (and x -0x1000001)) (assign i (+ i 1)) (addraset r i (or x -0x1000001)) (assign i (+ i 1)) (addraset r i (xor x -0x1000001)) (assign i (+ i 1)) (addraset r i (< x -0x1000001)) (assign i (+ i 1)) (checkbound i -0x1000001) -)))) diff --git a/testsuite/tests/asmgen/immediates.cmmpp b/testsuite/tests/asmgen/immediates.cmmpp deleted file mode 100644 index 3a997af2598..00000000000 --- a/testsuite/tests/asmgen/immediates.cmmpp +++ /dev/null @@ -1,26 +0,0 @@ -#define T TEST - -(* T -readonly_files = "mainimmed.c" -arguments = "-I ${test_source_directory} mainimmed.c" -* asmgen -*) - -(* Regenerate with cpp -P immediates.cmmpp > immediates.cmm *) - -#define F(N) \ - (addraset r i (+ x N)) (assign i (+ i 1)) \ - (addraset r i (- x N)) (assign i (+ i 1)) \ - (addraset r i ( * x N)) (assign i (+ i 1)) \ - (addraset r i (and x N)) (assign i (+ i 1)) \ - (addraset r i (or x N)) (assign i (+ i 1)) \ - (addraset r i (xor x N)) (assign i (+ i 1)) \ - (addraset r i (< x N)) (assign i (+ i 1)) \ - (checkbound i N) - -(function "testimm" () - (let x (load int "X") - (let r "R" - (letmut i int 0 -#include "immediates.tbl" -)))) diff --git a/testsuite/tests/asmgen/immediates.tbl b/testsuite/tests/asmgen/immediates.tbl deleted file mode 100644 index f5f6c230554..00000000000 --- a/testsuite/tests/asmgen/immediates.tbl +++ /dev/null @@ -1,37 +0,0 @@ -F(0) -F(1) -F(0xFF) -F(0x100) -F(0x3FC) -F(0x3FF) -F(0x7FF) -F(0x800) -F(0x801) -F(0xFFF) -F(0x1000) -F(0x1001) -F(0x7FFF) -F(0x8000) -F(0x8001) -F(0xFFF000) -F(0xFFFFFF) -F(0x1000000) -F(0x1000001) -F(-1) -F(-0xFF) -F(-0x100) -F(-0x3FC) -F(-0x3FF) -F(-0x7FF) -F(-0x800) -F(-0x801) -F(-0xFFF) -F(-0x1000) -F(-0x1001) -F(-0x7FFF) -F(-0x8000) -F(-0x8001) -F(-0xFFF000) -F(-0xFFFFFF) -F(-0x1000000) -F(-0x1000001) diff --git a/testsuite/tests/asmgen/integr.cmm b/testsuite/tests/asmgen/integr.cmm deleted file mode 100644 index 4ebee453fa9..00000000000 --- a/testsuite/tests/asmgen/integr.cmm +++ /dev/null @@ -1,39 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_FLOAT -DFUN=test main.c"; - reason = "This test is currently broken"; - skip; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "square" (x: float) - ( *f x x)) - -(function "integr" (f: addr low: float high: float n: int) - (let (h (/f (-f high low) (floatofint n)) - x low - s 0.0 - i n) - (while (> i 0) - (assign s (+f s (app f x float))) - (assign x (+f x h)) - (assign i (- i 1))) - ( *f s h))) - -(function "test" (n: int) - (app "integr" "square" 0.0 1.0 n float)) diff --git a/testsuite/tests/asmgen/invariants.cmm b/testsuite/tests/asmgen/invariants.cmm deleted file mode 100644 index 8409ade0cb6..00000000000 --- a/testsuite/tests/asmgen/invariants.cmm +++ /dev/null @@ -1,24 +0,0 @@ -(* TEST - native-compiler; - setup-simple-build-env; - codegen_exit_status = "2"; - codegen; -*) - -(* -This test is here to ensure that the Cmm invariant checks -correctly catch broken Cmm programs. -*) - -(function "bad_continuations" (x:int) - (* Bad arity *) - (catch - (exit cont 0) - with (cont) 1) - (* Multiple handler definition *) - (catch - (exit cont 0) - with (cont y:int) y) - (* Exit out of scope of its handler *) - (exit cont 0) -) diff --git a/testsuite/tests/asmgen/main.c b/testsuite/tests/asmgen/main.c deleted file mode 100644 index b0fe2efe9d1..00000000000 --- a/testsuite/tests/asmgen/main.c +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#include -#include -#include -#include - -/* This stub isn't needed for msvc32, since it's already in asmgen_i386nt.asm */ -#if !defined(_MSC_VER) || !defined(_M_IX86) -void caml_call_gc(void) -{ - -} -void caml_call_realloc_stack(void) -{ - -}; -#endif - -void caml_ml_array_bound_error(void) -{ - fprintf(stderr, "Fatal error: out-of-bound access in array or string\n"); - exit(2); -} - -void print_string(char * s) -{ - fputs(s, stdout); -} - -void printf_int(char * fmt, int arg) -{ - printf(fmt, arg); -} - -#define FLOATTEST(arg,res) \ - { double result = (res); \ - if (arg < result || arg > result) { \ - printf("Failed test \"%s == %s\": " \ - "result %.15g, expected %.15g\n", \ - #arg, #res, arg, result); \ - return(2); \ - } \ - } - -#ifdef SORT - -int cmpint(const void * i, const void * j) -{ - long vi = *((long *) i); - long vj = *((long *) j); - if (vi == vj) return 0; - if (vi < vj) return -1; - return 1; -} - -#endif - -int main(int argc, char **argv) -{ -#ifdef UNIT_INT - { extern long FUN(void); - extern long call_gen_code(long (*)(void)); - printf("%ld\n", call_gen_code(FUN)); - } -#else - if (argc < 2) { - fprintf(stderr, "Usage: %s [int arg]\n", argv[0]); - exit(2); - } -#ifdef INT_INT - { extern long FUN(long); - extern long call_gen_code(long (*)(long), long); - printf("%ld\n", call_gen_code(FUN, atoi(argv[1]))); - } -#endif -#ifdef INT_FLOAT - { extern double FUN(long); - extern double call_gen_code(double (*)(long), long); - printf("%f\n", call_gen_code(FUN, atoi(argv[1]))); - } -#endif -#ifdef FLOAT_CATCH - { extern double FUN(long); - extern double call_gen_code(double (*)(long), long); - double result = call_gen_code(FUN, 1); - FLOATTEST(result, 1110.0) - printf("%f\n", result); - } -#endif -#ifdef SORT - { extern void FUN(long, long, long *); - extern void call_gen_code(void (*)(long, long, long *), long, long, long *); - long n; - long * a, * b; - long i; - - srand(argc >= 3 ? atoi(argv[2]) : time((time_t *) 0)); - n = atoi(argv[1]); - a = (long *) malloc(n * sizeof(long)); - for (i = 0 ; i < n; i++) a[i] = rand() & 0xFFF; -#ifdef DEBUG - for (i = 0; i < n; i++) printf("%ld ", a[i]); printf("\n"); -#endif - b = (long *) malloc(n * sizeof(long)); - for (i = 0; i < n; i++) b[i] = a[i]; - call_gen_code(FUN, 0, n-1, a); -#ifdef DEBUG - for (i = 0; i < n; i++) printf("%ld ", a[i]); printf("\n"); -#endif - qsort(b, n, sizeof(long), cmpint); - for (i = 0; i < n; i++) { - if (a[i] != b[i]) { printf("Bug!\n"); return 2; } - } - printf("OK\n"); - } -#endif -#endif -#ifdef CHECKBOUND - { extern void checkbound1(long), checkbound2(long, long); - extern void call_gen_code(void *, ...); - long x, y; - x = atoi(argv[1]); - if (argc >= 3) { - y = atoi(argv[2]); - if ((unsigned long) x < (unsigned long) y) - printf("Should not trap\n"); - else - printf("Should trap\n"); - call_gen_code(checkbound2, y, x); - } else { - if (2 < (unsigned long) x) - printf("Should not trap\n"); - else - printf("Should trap\n"); - call_gen_code(checkbound1, x); - } - printf("OK\n"); - } -#endif - return 0; -} diff --git a/testsuite/tests/asmgen/mainarith.c b/testsuite/tests/asmgen/mainarith.c deleted file mode 100644 index fce523767a4..00000000000 --- a/testsuite/tests/asmgen/mainarith.c +++ /dev/null @@ -1,350 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#include -#include -#include -#include -#include - -#include -#define FMT ARCH_INTNAT_PRINTF_FORMAT - -void caml_call_poll(void) -{ -} - -void caml_ml_array_bound_error(void) -{ - fprintf(stderr, "Fatal error: out-of-bound access in array or string\n"); - exit(2); -} - -intnat R[200]; -double D[40]; -intnat X, Y; -double F, G; -volatile double H; - -#define INTTEST(arg,res) \ - { intnat result = (res); \ - if (arg != result) \ - printf("Failed test \"%s == %s\" for X=%"FMT"d and Y=%"FMT"d: " \ - "result %"FMT"d, expected %"FMT"d\n", \ - #arg, #res, X, Y, arg, result); \ - } -#define INTFLOATTEST(arg,res) \ - { intnat result = (res); \ - if (arg != result) \ - printf("Failed test \"%s == %s\" for F=%.15g and G=%.15g: "\ - "result %"FMT"d, expected %"FMT"d\n", \ - #arg, #res, F, G, arg, result); \ - } -#define FLOATTEST(arg,res) \ - { double result; \ - H = (res); \ - result = H; \ - if (arg < result || arg > result) \ - printf("Failed test \"%s == %s\" for F=%.15g and G=%.15g: "\ - "result %.15g, expected %.15g\n", \ - #arg, #res, F, G, arg, result); \ - } -#define FLOATINTTEST(arg,res) \ - { double result = (res); \ - if (arg < result || arg > result) \ - printf("Failed test \"%s == %s\" for X=%"FMT"d and Y=%"FMT"d: "\ - "result %.15g, expected %.15g\n", \ - #arg, #res, X, Y, arg, result); \ - } - -extern void call_gen_code(void (*)(void)); -extern void testarith(void); -static intnat mulhs(intnat x, intnat y); - -void do_test(void) -{ - call_gen_code(testarith); - - INTTEST(R[0], 0); - INTTEST(R[1], 1); - INTTEST(R[2], -1); - INTTEST(R[3], 256); - INTTEST(R[4], 65536); - INTTEST(R[5], 16777216); - INTTEST(R[6], -256); - INTTEST(R[7], -65536); - INTTEST(R[8], -16777216); - - INTTEST(R[9], (X + Y)); - INTTEST(R[10], (X + 1)); - INTTEST(R[11], (X + -1)); - - INTTEST(R[12], ((intnat) ((char *)R + 8))); - INTTEST(R[13], ((intnat) ((char *)R + Y))); - - INTTEST(R[14], (X - Y)); - INTTEST(R[15], (X - 1)); - INTTEST(R[16], (X - -1)); - - INTTEST(R[17], ((intnat) ((uintnat)R - 8))); - INTTEST(R[18], ((intnat) ((char *)R - Y))); - - INTTEST(R[19], (X * 2)); - INTTEST(R[20], (2 * X)); - INTTEST(R[21], (X * 16)); - INTTEST(R[22], (16 * X)); - INTTEST(R[23], (X * 12345)); - INTTEST(R[24], (12345 * X)); - INTTEST(R[25], (X * Y)); - - INTTEST(R[26], (X / 2)); - INTTEST(R[27], (X / 16)); - INTTEST(R[28], (X / 7)); - INTTEST(R[29], (Y != 0 ? X / Y : 0)); - - INTTEST(R[30], (X % 2)); - INTTEST(R[31], (X % 16)); - INTTEST(R[32], (Y != 0 ? X % Y : 0)); - - INTTEST(R[33], (X & Y)); - INTTEST(R[34], (X & 3)); - INTTEST(R[35], (3 & X)); - - INTTEST(R[36], (X | Y)); - INTTEST(R[37], (X | 3)); - INTTEST(R[38], (3 | X)); - - INTTEST(R[39], (X ^ Y)); - INTTEST(R[40], (X ^ 3)); - INTTEST(R[41], (3 ^ X)); - - INTTEST(R[42], (X << Y)); - INTTEST(R[43], (X << 1)); - INTTEST(R[44], (X << 8)); - - INTTEST(R[45], ((uintnat) X >> Y)); - INTTEST(R[46], ((uintnat) X >> 1)); - INTTEST(R[47], ((uintnat) X >> 8)); - - INTTEST(R[48], (X >> Y)); - INTTEST(R[49], (X >> 1)); - INTTEST(R[50], (X >> 8)); - - INTTEST(R[51], (X == Y)); - INTTEST(R[52], (X != Y)); - INTTEST(R[53], (X < Y)); - INTTEST(R[54], (X > Y)); - INTTEST(R[55], (X <= Y)); - INTTEST(R[56], (X >= Y)); - INTTEST(R[57], (X == 1)); - INTTEST(R[58], (X != 1)); - INTTEST(R[59], (X < 1)); - INTTEST(R[60], (X > 1)); - INTTEST(R[61], (X <= 1)); - INTTEST(R[62], (X >= 1)); - - INTTEST(R[63], ((char *)X == (char *)Y)); - INTTEST(R[64], ((char *)X != (char *)Y)); - INTTEST(R[65], ((char *)X < (char *)Y)); - INTTEST(R[66], ((char *)X > (char *)Y)); - INTTEST(R[67], ((char *)X <= (char *)Y)); - INTTEST(R[68], ((char *)X >= (char *)Y)); - INTTEST(R[69], ((char *)X == (char *)1)); - INTTEST(R[70], ((char *)X != (char *)1)); - INTTEST(R[71], ((char *)X < (char *)1)); - INTTEST(R[72], ((char *)X > (char *)1)); - INTTEST(R[73], ((char *)X <= (char *)1)); - INTTEST(R[74], ((char *)X >= (char *)1)); - - INTTEST(R[75], (X + (Y << 1))); - INTTEST(R[76], (X + (Y << 2))); - INTTEST(R[77], (X + (Y << 3))); - INTTEST(R[78], (X - (Y << 1))); - INTTEST(R[79], (X - (Y << 2))); - INTTEST(R[80], (X - (Y << 3))); - - FLOATTEST(D[0], 0.0); - FLOATTEST(D[1], 1.0); - FLOATTEST(D[2], -1.0); - FLOATTEST(D[3], (F + G)); - FLOATTEST(D[4], (F - G)); - FLOATTEST(D[5], (F * G)); - FLOATTEST(D[6], F / G); - - FLOATTEST(D[7], (F + (G + 1.0))); - FLOATTEST(D[8], (F - (G + 1.0))); - FLOATTEST(D[9], (F * (G + 1.0))); - FLOATTEST(D[10], F / (G + 1.0)); - - FLOATTEST(D[11], ((F + 1.0) + G)); - FLOATTEST(D[12], ((F + 1.0) - G)); - FLOATTEST(D[13], ((F + 1.0) * G)); - FLOATTEST(D[14], (F + 1.0) / G); - - FLOATTEST(D[15], ((F + 1.0) + (G + 1.0))); - FLOATTEST(D[16], ((F + 1.0) - (G + 1.0))); - FLOATTEST(D[17], ((F + 1.0) * (G + 1.0))); - FLOATTEST(D[18], (F + 1.0) / (G + 1.0)); - - INTFLOATTEST(R[81], (F == G)); - INTFLOATTEST(R[82], (F != G)); - INTFLOATTEST(R[83], (F < G)); - INTFLOATTEST(R[84], (F > G)); - INTFLOATTEST(R[85], (F <= G)); - INTFLOATTEST(R[86], (F >= G)); - - FLOATINTTEST(D[19], (double) X); - INTFLOATTEST(R[87], (intnat) F); - - INTTEST(R[88], (X >= 0) && (X < Y)); - INTTEST(R[89], (0 < Y)); - INTTEST(R[90], (5 < Y)); - - INTFLOATTEST(R[91], (F == G)); - INTFLOATTEST(R[92], (F != G)); - INTFLOATTEST(R[93], (F < G)); - INTFLOATTEST(R[94], (F > G)); - INTFLOATTEST(R[95], (F <= G)); - INTFLOATTEST(R[96], (F >= G)); - - INTFLOATTEST(R[97], (F + 1.0 == G + 1.0)); - INTFLOATTEST(R[98], (F + 1.0 != G + 1.0)); - INTFLOATTEST(R[99], (F + 1.0 < G + 1.0)); - INTFLOATTEST(R[100], (F + 1.0 > G + 1.0)); - INTFLOATTEST(R[101], (F + 1.0 <= G + 1.0)); - INTFLOATTEST(R[102], (F + 1.0 >= G + 1.0)); - - INTFLOATTEST(R[103], (F == G + 1.0)); - INTFLOATTEST(R[104], (F != G + 1.0)); - INTFLOATTEST(R[105], (F < G + 1.0)); - INTFLOATTEST(R[106], (F > G + 1.0)); - INTFLOATTEST(R[107], (F <= G + 1.0)); - INTFLOATTEST(R[108], (F >= G + 1.0)); - - INTFLOATTEST(R[109], (F + 1.0 == G)); - INTFLOATTEST(R[110], (F + 1.0 != G)); - INTFLOATTEST(R[111], (F + 1.0 < G)); - INTFLOATTEST(R[112], (F + 1.0 > G)); - INTFLOATTEST(R[113], (F + 1.0 <= G)); - INTFLOATTEST(R[114], (F + 1.0 >= G)); - - FLOATINTTEST(D[20], ((double) X) + 1.0); - INTFLOATTEST(R[115], (intnat)(F + 1.0)); - - FLOATTEST(D[21], F + G); - FLOATTEST(D[22], G + F); - FLOATTEST(D[23], F - G); - FLOATTEST(D[24], G - F); - FLOATTEST(D[25], F * G); - FLOATTEST(D[26], G * F); - FLOATTEST(D[27], F / G); - FLOATTEST(D[28], G / F); - - FLOATTEST(D[29], (F * 2.0) + G); - FLOATTEST(D[30], G + (F * 2.0)); - FLOATTEST(D[31], (F * 2.0) - G); - FLOATTEST(D[32], G - (F * 2.0)); - FLOATTEST(D[33], (F + 2.0) * G); - FLOATTEST(D[34], G * (F + 2.0)); - FLOATTEST(D[35], (F * 2.0) / G); - FLOATTEST(D[36], G / (F * 2.0)); - - FLOATTEST(D[37], - F); - FLOATTEST(D[38], fabs(F)); - - INTTEST(R[116], mulhs(X, Y)); -} - -/* Multiply-high signed. Hacker's Delight section 8.2 */ - -#define HALFSIZE (4 * sizeof(intnat)) -#define HALFMASK (((intnat)1 << HALFSIZE) - 1) - -static intnat mulhs(intnat u, intnat v) -{ - uintnat u0, v0, w0; - intnat u1, v1, w1, w2, t; - u0 = u & HALFMASK; u1 = u >> HALFSIZE; - v0 = v & HALFMASK; v1 = v >> HALFSIZE; - w0 = u0*v0; - t = u1*v0 + (w0 >> HALFSIZE); - w1 = t & HALFMASK; - w2 = t >> HALFSIZE; - w1 = u0*v1 + w1; - return u1*v1 + w2 + (w1 >> HALFSIZE); -} - -/* A simple linear congruential PRNG */ - -#ifdef ARCH_SIXTYFOUR -#define RAND_A 6364136223846793005ULL -#define RAND_C 1442695040888963407ULL -#else -#define RAND_A 214013U -#define RAND_C 2531011U -#endif - -static intnat rnd(void) -{ - static uintnat seed = 0; - seed = seed * RAND_A + RAND_C; - return (intnat) seed; -} - -/* Test harness */ - -#define NUM_RANDOM_ITERATIONS 1000000 - -int main(int argc, char **argv) -{ - int i; - double weird[4]; - - if (argc >= 5) { - X = atoi(argv[1]); - Y = atoi(argv[2]); - sscanf(argv[3], "%lf", &F); - sscanf(argv[4], "%lf", &G); - do_test(); - return 0; - } - printf("Testing -2...2\n"); - for(Y = -2; Y <= 2; Y++) { - for (X = -2; X <= 2; X++) { - F = X; G = Y; do_test(); - } - } - if (!(argc >= 2 && strcmp(argv[1], "noinf"))) { - printf("Testing special FP values\n"); - weird[0] = 0.0; - weird[1] = 1.0 / weird[0]; /* +infty */ - weird[2] = -1.0 / weird[0]; /* -infty */ - weird[3] = 0.0 / weird[0]; /* NaN */ - for (X = 0; X < 4; X++) { - for (Y = 0; Y < 4; Y++) { - F = weird[X]; G = weird[Y]; do_test(); - } - } - } - printf("Testing %d random values\n", NUM_RANDOM_ITERATIONS); - for (i = 0; i < NUM_RANDOM_ITERATIONS; i++) { - X = rnd(); - Y = rnd(); - F = X / 1e3; - G = Y / 1e3; - do_test(); - } - return 0; -} diff --git a/testsuite/tests/asmgen/mainimmed.c b/testsuite/tests/asmgen/mainimmed.c deleted file mode 100644 index 6e120424591..00000000000 --- a/testsuite/tests/asmgen/mainimmed.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include - -#define NUMTESTS 37 -intnat R[NUMTESTS][7]; -intnat X; - -extern void call_gen_code(void (*)(void)); -extern void testimm(void); - -void caml_ml_array_bound_error(void) -{ - fprintf(stderr, "Fatal error: out-of-bound access in array or string\n"); - exit(2); -} - -/* One round of testing */ - -#define FMT ARCH_INTNAT_PRINTF_FORMAT - -static void check(int i, intnat x, intnat result, intnat expected) -{ - if (result != expected) { - printf("Test %d, argument %"FMT"d: got %"FMT"d, expected %"FMT"d\n", - i, x, result, expected); - } -} - -static void test_one(int i, intnat x, intnat y) -{ - check(i, x, R[i][0], x + y); - check(i, x, R[i][1], x - y); - check(i, x, R[i][2], x * y); - check(i, x, R[i][3], x & y); - check(i, x, R[i][4], x | y); - check(i, x, R[i][5], x ^ y); - check(i, x, R[i][6], x < y); -} - -static void do_test(intnat x) -{ - int i; - - X = x; - call_gen_code(testimm); - i = 0; -#define F(N) test_one(i++, x, N); -#include "immediates.tbl" -} - -/* A simple linear congruential PRNG */ - -#ifdef ARCH_SIXTYFOUR -#define RAND_A 6364136223846793005ULL -#define RAND_C 1442695040888963407ULL -#else -#define RAND_A 214013U -#define RAND_C 2531011U -#endif - -static intnat rnd(void) -{ - static uintnat seed = 0; - seed = seed * RAND_A + RAND_C; - return (intnat) seed; -} - -/* Test harness */ - -#define NUM_RANDOM_ITERATIONS 1000000 - -int main(int argc, char **argv) -{ - int i; - for (i = 0; i < NUM_RANDOM_ITERATIONS; i++) do_test(rnd()); - return 0; -} diff --git a/testsuite/tests/asmgen/pgcd.cmm b/testsuite/tests/asmgen/pgcd.cmm deleted file mode 100644 index 1c669f1f3ca..00000000000 --- a/testsuite/tests/asmgen/pgcd.cmm +++ /dev/null @@ -1,15 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=pgcd_30030 main.c"; - asmgen; -*) - -(function "pgcd_30030" (a:int) - (catch (exit pgcd a 30030) - with (pgcd n:val m:val) - (if (> n m) - (exit pgcd m n) - (if (== n 0) - m - (let (r (mod m n)) - (exit pgcd r n)))))) diff --git a/testsuite/tests/asmgen/quicksort.cmm b/testsuite/tests/asmgen/quicksort.cmm deleted file mode 100644 index a5b16fb0337..00000000000 --- a/testsuite/tests/asmgen/quicksort.cmm +++ /dev/null @@ -1,50 +0,0 @@ -(* TEST - readonly_files = "main.c asan_report_wrappers.c"; - arguments = "-DSORT -DFUN=quicksort main.c asan_report_wrappers.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "quicksort" (lo: int hi: int a: val) - (if (< lo hi) - (letmut (i int lo - j int hi - pivot int (addraref a hi)) - (while (< i j) - (catch - (while 1 - (if (>= i hi) (exit n25) []) - (if (> (addraref a i) pivot) (exit n25) []) - (assign i (+ i 1))) - with (n25) []) - (catch - (while 1 - (if (<= j lo) (exit n35) []) - (if (< (addraref a j) pivot) (exit n35) []) - (assign j (- j 1))) - with (n35) []) - (if (< i j) - (let temp (addraref a i) - (addraset a i (addraref a j)) - (addraset a j temp)) - [])) - (let temp (addraref a i) - (addraset a i (addraref a hi)) - (addraset a hi temp)) - (app "quicksort" lo (- i 1) a unit) - (app "quicksort" (+ i 1) hi a unit)) - [])) diff --git a/testsuite/tests/asmgen/quicksort2.cmm b/testsuite/tests/asmgen/quicksort2.cmm deleted file mode 100644 index 690d7554477..00000000000 --- a/testsuite/tests/asmgen/quicksort2.cmm +++ /dev/null @@ -1,56 +0,0 @@ -(* TEST - readonly_files = "main.c asan_report_wrappers.c"; - arguments = "-DSORT -DFUN=quicksort main.c asan_report_wrappers.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "cmp" (i: int j: int) - (- i j)) - -(function "quick" (lo: int hi: int a: val cmp: val) - (if (< lo hi) - (letmut (i int lo - j int hi - pivot int (intaref a hi)) - (while (< i j) - (catch - (while 1 - (if (>= i hi) (exit n25) []) - (if (> (app cmp (intaref a i) pivot int) 0) (exit n25) []) - (assign i (+ i 1))) - with (n25) []) - (catch - (while 1 - (if (<= j lo) (exit n35) []) - (if (< (app cmp (intaref a j) pivot int) 0) (exit n35) []) - (assign j (- j 1))) - with (n35) []) - (if (< i j) - (let temp (intaref a i) - (intaset a i (intaref a j)) - (intaset a j temp)) - [])) - (let temp (intaref a i) - (intaset a i (intaref a hi)) - (intaset a hi temp)) - (app "quick" lo (- i 1) a cmp unit) - (app "quick" (+ i 1) hi a cmp unit)) - [])) - -(function "quicksort" (lo: int hi: int a: val) - (app "quick" lo hi a "cmp" unit)) diff --git a/testsuite/tests/asmgen/soli.cmm b/testsuite/tests/asmgen/soli.cmm deleted file mode 100644 index 74f6ccf9ec2..00000000000 --- a/testsuite/tests/asmgen/soli.cmm +++ /dev/null @@ -1,117 +0,0 @@ -(* TEST - readonly_files = "main.c asan_report_wrappers.c"; - arguments = "-DUNIT_INT -DFUN=solitaire main.c asan_report_wrappers.c"; - no-tsan; (* The asmgen action does not support TSan *) - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -("d1": int 0 int 1 - "d2": int 1 int 0 - "d3": int 0 int -1 - "d4": int -1 int 0 - "dir": val "d1" val "d2" val "d3" val "d4") - -("counter": int 0) - -(* Out = 0 Empty = 1 Peg = 2 *) - -("line0": int 0 int 0 int 0 int 0 int 0 int 0 int 0 int 0 int 0 - "line1": int 0 int 0 int 0 int 2 int 2 int 2 int 0 int 0 int 0 - "line2": int 0 int 0 int 0 int 2 int 2 int 2 int 0 int 0 int 0 - "line3": int 0 int 2 int 2 int 2 int 2 int 2 int 2 int 2 int 0 - "line4": int 0 int 2 int 2 int 2 int 1 int 2 int 2 int 2 int 0 - "line5": int 0 int 2 int 2 int 2 int 2 int 2 int 2 int 2 int 0 - "line6": int 0 int 0 int 0 int 2 int 2 int 2 int 0 int 0 int 0 - "line7": int 0 int 0 int 0 int 2 int 2 int 2 int 0 int 0 int 0 - "line8": int 0 int 0 int 0 int 0 int 0 int 0 int 0 int 0 int 0 - "board": val "line0" val "line1" val "line2" val "line3" - val "line4" val "line5" val "line6" val "line7" val "line8") - -("format": string "%d\n\000") - -(function "solve" (m: int) - (store int "counter" (+ (load int "counter") 1)) - (if (== m 31) - (== (intaref (addraref "board" 4) 4) 2) - (try - (if (== (mod (load int "counter") 500) 0) - (extcall "printf_int" "format" (load int "counter") unit) - []) - (letmut i int 1 - (while (<= i 7) - (letmut j int 1 - (while (<= j 7) - (if (== (intaref (addraref "board" i) j) 2) - (seq - (letmut k int 0 - (while (<= k 3) - (let (d1 (intaref (addraref "dir" k) 0) - d2 (intaref (addraref "dir" k) 1) - i1 (+ i d1) - i2 (+ i1 d1) - j1 (+ j d2) - j2 (+ j1 d2)) - (if (== (intaref (addraref "board" i1) j1) 2) - (if (== (intaref (addraref "board" i2) j2) 1) - (seq - (intaset (addraref "board" i) j 1) - (intaset (addraref "board" i1) j1 1) - (intaset (addraref "board" i2) j2 2) - (if (app "solve" (+ m 1) int) - (raise_notrace 0) - []) - (intaset (addraref "board" i) j 2) - (intaset (addraref "board" i1) j1 2) - (intaset (addraref "board" i2) j2 1)) - []) - [])) - (assign k (+ k 1))))) - []) - (assign j (+ j 1)))) - (assign i (+ i 1)))) - 0 - with bucket - 1))) - -("format_out": string ".\000") -("format_empty": string " \000") -("format_peg": string "$\000") -("format_newline": string "\n\000") - -(function "print_board" () - (letmut i int 0 - (while (< i 9) - (letmut j int 0 - (while (< j 9) - (switch 3 (intaref (addraref "board" i) j) - case 0: - (extcall "print_string" "format_out" unit) - case 1: - (extcall "print_string" "format_empty" unit) - case 2: - (extcall "print_string" "format_peg" unit)) - (assign j (+ j 1)))) - (extcall "print_string" "format_newline" unit) - (assign i (+ i 1))))) - -(function "solitaire" () - (seq - (if (app "solve" 0 int) - (app "print_board" [] unit) - []) - 0)) diff --git a/testsuite/tests/asmgen/tagged-fib.cmm b/testsuite/tests/asmgen/tagged-fib.cmm deleted file mode 100644 index 7ff1255d489..00000000000 --- a/testsuite/tests/asmgen/tagged-fib.cmm +++ /dev/null @@ -1,25 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DINT_INT -DFUN=fib main.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "fib" (n: int) - (if (< n 5) - 3 - (- (+ (app "fib" (- n 2) int) (app "fib" (- n 4) int)) 1))) diff --git a/testsuite/tests/asmgen/tagged-integr.cmm b/testsuite/tests/asmgen/tagged-integr.cmm deleted file mode 100644 index cec3e46b4df..00000000000 --- a/testsuite/tests/asmgen/tagged-integr.cmm +++ /dev/null @@ -1,51 +0,0 @@ -(* TEST - readonly_files = "main.c asan_report_wrappers.c"; - arguments = "-DINT_FLOAT -DFUN=test main.c asan_report_wrappers.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -("res_square": skip 8) -("h": skip 8) -("x": skip 8) -("s": skip 8) -("res_integr": skip 8) - -(function "square" (x: val) - (let r "res_square" - (store float r ( *f (load float x) (load float x))) - r)) - -(function "integr" (f: val low: val high: val n: int) - (letmut (h val "h" x val "x" s val "s" i int n) - (store float h (/f (-f (load float high) (load float low)) (floatofint n))) - (store float x (load float low)) - (store float s 0.0) - (while (> i 0) - (store float s (+f (load float s) (load float (app f x val)))) - (store float x (+f (load float x) (load float h))) - (assign i (- i 1))) - (store float "res_integr" ( *f (load float s) (load float h))) - "res_integr")) - -("low": skip 8) -("hi": skip 8) - -(function "test" (n: int) - (store float "low" 0.0) - (store float "hi" 1.0) - (load float (app "integr" "square" "low" "hi" n val))) diff --git a/testsuite/tests/asmgen/tagged-quicksort.cmm b/testsuite/tests/asmgen/tagged-quicksort.cmm deleted file mode 100644 index 41422efd447..00000000000 --- a/testsuite/tests/asmgen/tagged-quicksort.cmm +++ /dev/null @@ -1,53 +0,0 @@ -(* TEST - readonly_files = "main.c asan_report_wrappers.c"; - arguments = "-DSORT -DFUN=quicksort main.c asan_report_wrappers.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "quick" (lo: int hi: int a: val) - (if (< lo hi) - (letmut (i int lo - j int hi - pivot int (addraref a (>>s hi 1))) - (while (< i j) - (catch - (while 1 - (if (>= i hi) (exit n25) []) - (if (> (addraref a (>>s i 1)) pivot) (exit n25) []) - (assign i (+ i 2))) - with (n25) []) - (catch - (while 1 - (if (<= j lo) (exit n35) []) - (if (< (addraref a (>>s j 1)) pivot) (exit n35) []) - (assign j (- j 2))) - with (n35) []) - (if (< i j) - (let temp (addraref a (>>s i 1)) - (addraset a (>>s i 1) (addraref a (>>s j 1))) - (addraset a (>>s j 1) temp)) - [])) - (let temp (addraref a (>>s i 1)) - (addraset a (>>s i 1) (addraref a (>>s hi 1))) - (addraset a (>>s hi 1) temp)) - (app "quick" lo (- i 2) a unit) - (app "quick" (+ i 2) hi a unit)) - [])) - -(function "quicksort" (lo: int hi: int a: val) - (app "quick" (+ (<< lo 1) 1) (+ (<< hi 1) 1) a unit)) diff --git a/testsuite/tests/asmgen/tagged-tak.cmm b/testsuite/tests/asmgen/tagged-tak.cmm deleted file mode 100644 index 0a79f660eb5..00000000000 --- a/testsuite/tests/asmgen/tagged-tak.cmm +++ /dev/null @@ -1,30 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DUNIT_INT -DFUN=takmain main.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "tak" (x:int y:int z:int) - (if (> x y) - (app "tak" (app "tak" (- x 2) y z int) - (app "tak" (- y 2) z x int) - (app "tak" (- z 2) x y int) int) - z)) - -(function "takmain" (dummy: int) - (app "tak" 37 25 13 int)) diff --git a/testsuite/tests/asmgen/tak.cmm b/testsuite/tests/asmgen/tak.cmm deleted file mode 100644 index 0d7220885ed..00000000000 --- a/testsuite/tests/asmgen/tak.cmm +++ /dev/null @@ -1,30 +0,0 @@ -(* TEST - readonly_files = "main.c"; - arguments = "-DUNIT_INT -DFUN=takmain main.c"; - asmgen; -*) - -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(function "tak" (x:int y:int z:int) - (if (> x y) - (app "tak" (app "tak" (- x 1) y z int) - (app "tak" (- y 1) z x int) - (app "tak" (- z 1) x y int) int) - z)) - -(function "takmain" (dummy: int) - (app "tak" 18 12 6 int)) diff --git a/testsuite/tests/callback/callback_effects_gc.ml b/testsuite/tests/callback/callback_effects_gc.ml deleted file mode 100644 index e51c8b764d1..00000000000 --- a/testsuite/tests/callback/callback_effects_gc.ml +++ /dev/null @@ -1,30 +0,0 @@ -(* TEST - runtime5; - ocamlrunparam += ",s=512"; - native; -*) - -let count = ref 0 - -let queue = Queue.create () - -let callback (i:int) (ts: int64) = - (* add items to queue *) - incr count; - Queue.push ( (i, ts, ())) queue - -external caml_callback : ('a -> 'b -> 'c) -> 'a -> 'b -> 'c = "caml_callback2_exn" - -(* main loop *) -let main () = - for i = 0 to 10000 do - caml_callback callback (-1) (Int64.of_int i) - done - -(* a dummy effect handler *) -let () = - Effect.Deep.match_with main () { - retc = ignore; - exnc = raise; - effc = fun _ -> None - } diff --git a/testsuite/tests/callback/callbackprim.c b/testsuite/tests/callback/callbackprim.c deleted file mode 100644 index 06b354429bc..00000000000 --- a/testsuite/tests/callback/callbackprim.c +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1995 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#include -#include "caml/mlvalues.h" -#include "caml/memory.h" -#include "caml/callback.h" - -value mycallback1(value fun, value arg) -{ - value res; - res = caml_callback(fun, arg); - return res; -} - -value mycallback2(value fun, value arg1, value arg2) -{ - value res; - res = caml_callback2(fun, arg1, arg2); - return res; -} - -value mycallback3(value fun, value arg1, value arg2, value arg3) -{ - value res; - res = caml_callback3(fun, arg1, arg2, arg3); - return res; -} - -value mycallback4(value fun, value arg1, value arg2, value arg3, value arg4) -{ - value args[4]; - value res; - args[0] = arg1; - args[1] = arg2; - args[2] = arg3; - args[3] = arg4; - res = caml_callbackN(fun, 4, args); - return res; -} - -value mypushroot(value v, value fun, value arg) -{ - CAMLparam1(v); - caml_callback(fun, arg); - CAMLreturn(v); -} - -value mycamlparam (value v, value fun, value arg) -{ - CAMLparam3 (v, fun, arg); - CAMLlocal2 (x, y); - x = v; - y = caml_callback (fun, arg); - v = x; - CAMLreturn (v); -} - -value raise_sigusr1(value unused) -{ - raise(SIGUSR1); - return Val_unit; -} diff --git a/testsuite/tests/callback/minor_named.ml b/testsuite/tests/callback/minor_named.ml deleted file mode 100644 index 902c1a9fde9..00000000000 --- a/testsuite/tests/callback/minor_named.ml +++ /dev/null @@ -1,16 +0,0 @@ -(* TEST - modules = "minor_named_.c"; - flags = "-alert -unsafe_multidomain"; -*) - -(* Tests Callback.register and caml_named_value on a young object *) - -external incr_ref : unit -> unit = "incr_ref" - -let () = - let r = ref 40 in - Callback.register "incr_ref" r; - incr_ref (); - Gc.minor (); - incr_ref (); - Printf.printf "%d\n" !r diff --git a/testsuite/tests/callback/minor_named.reference b/testsuite/tests/callback/minor_named.reference deleted file mode 100644 index d81cc0710eb..00000000000 --- a/testsuite/tests/callback/minor_named.reference +++ /dev/null @@ -1 +0,0 @@ -42 diff --git a/testsuite/tests/callback/minor_named_.c b/testsuite/tests/callback/minor_named_.c deleted file mode 100644 index 2d8ad2d3846..00000000000 --- a/testsuite/tests/callback/minor_named_.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -value incr_ref(value unit) { - static const value* v; - if (!v) v = caml_named_value("incr_ref"); - caml_modify(&Field(*v, 0), Val_int(Int_val(Field(*v, 0)) + 1)); - return Val_unit; -} diff --git a/testsuite/tests/callback/nested_fiber.ml b/testsuite/tests/callback/nested_fiber.ml deleted file mode 100644 index ccef709d1df..00000000000 --- a/testsuite/tests/callback/nested_fiber.ml +++ /dev/null @@ -1,55 +0,0 @@ -(* TEST - modules = "nested_fiber_.c"; - runtime5; - { - bytecode; - }{ - native; - } -*) - -external caml_to_c : (unit -> 'a) -> 'a = "caml_to_c" - -open Effect -open Effect.Deep - -type _ t += E : unit t - -type 'a tree = Empty | Node of 'a tree * 'a tree - -let rec make d = - match d with - | 0 -> Node(Empty, Empty) - | _ -> let d = d - 1 in Node(make d, make d) - -let rec check = function Empty -> 0 | Node(l, r) -> 1 + check l + check r - -let g () = - caml_to_c (fun () -> - Gc.full_major (); - let x = make 10 in - Printf.printf "g() check %d\n%!" (check x)) - -let f () = - let x = make 3 in - let z = ref 1 in - match_with g () - { retc = (fun () -> Printf.printf "g() returned: %d\n%!" !z); - exnc = (fun e -> raise e); - effc = fun (type a) (e : a t) -> - match e with - | E -> Some (fun (k : (a, _) continuation) -> assert false) - | _ -> None }; - Printf.printf "f() check: %d\n%!" (check x) - -let () = - let x = make 3 in - let z = ref 2 in - match_with f () - { retc = (fun () -> Printf.printf "f() returned: %d\n%!" !z); - exnc = (fun e -> raise e); - effc = fun (type a) (e : a t) -> - match e with - | E -> Some (fun k -> assert false) - | _ -> None }; - Printf.printf "() check: %d\n%!" (check x) diff --git a/testsuite/tests/callback/nested_fiber.reference b/testsuite/tests/callback/nested_fiber.reference deleted file mode 100644 index 12358fbb2c4..00000000000 --- a/testsuite/tests/callback/nested_fiber.reference +++ /dev/null @@ -1,5 +0,0 @@ -g() check 2047 -g() returned: 1 -f() check: 15 -f() returned: 2 -() check: 15 diff --git a/testsuite/tests/callback/nested_fiber_.c b/testsuite/tests/callback/nested_fiber_.c deleted file mode 100644 index 0978ac9b20c..00000000000 --- a/testsuite/tests/callback/nested_fiber_.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -value caml_to_c (value f) { - return caml_callback(f, Val_unit); -} diff --git a/testsuite/tests/callback/signals_alloc.ml b/testsuite/tests/callback/signals_alloc.ml deleted file mode 100644 index af044f7c158..00000000000 --- a/testsuite/tests/callback/signals_alloc.ml +++ /dev/null @@ -1,36 +0,0 @@ -(* TEST - include unix; - flags = "-alert -unsafe_multidomain"; - modules = "callbackprim.c"; - libunix; - { - bytecode; - }{ - native; - } -*) -external raise_sigusr1 : unit -> unit = "raise_sigusr1" - -let do_test () = - let seen_states = Array.make 5 (-1) in - let pos = ref 0 in - let sighandler signo = - (* These two instructions are duplicated everywhere, but we cannot - encapsulate them in a function, because function calls check - for signals in bytecode mode. *) - seen_states.(!pos) <- 3; pos := !pos + 1; - in - seen_states.(!pos) <- 0; pos := !pos + 1; - Sys.set_signal Sys.sigusr1 (Sys.Signal_handle sighandler); - seen_states.(!pos) <- 1; pos := !pos + 1; - raise_sigusr1 (); - seen_states.(!pos) <- 2; pos := !pos + 1; - let _ = Sys.opaque_identity (ref 1) in - seen_states.(!pos) <- 4; pos := !pos + 1; - Sys.set_signal Sys.sigusr1 Sys.Signal_default; - Array.iter (Printf.printf "%d") seen_states; - print_newline () - -let () = - for _ = 0 to 10 do do_test () done; - Printf.printf "OK\n" diff --git a/testsuite/tests/callback/signals_alloc.reference b/testsuite/tests/callback/signals_alloc.reference deleted file mode 100644 index 3e5c37f9417..00000000000 --- a/testsuite/tests/callback/signals_alloc.reference +++ /dev/null @@ -1,12 +0,0 @@ -01234 -01234 -01234 -01234 -01234 -01234 -01234 -01234 -01234 -01234 -01234 -OK diff --git a/testsuite/tests/callback/stack_overflow.ml b/testsuite/tests/callback/stack_overflow.ml deleted file mode 100644 index a39182b1d2b..00000000000 --- a/testsuite/tests/callback/stack_overflow.ml +++ /dev/null @@ -1,33 +0,0 @@ -(* TEST - modules = "stack_overflow_.c"; - runtime5; - { - bytecode; - }{ - native; - } -*) - -external caml_to_c : (unit -> 'a) -> 'a = "caml_to_c" - -let rec deep = function - | 0 -> - ref 42 - | n -> - caml_to_c (fun () -> deep (n-1)) - -open Effect -open Effect.Deep - -type _ t += E : unit t - -let () = - Printf.printf "%d\n%!" (!(deep 1000)); - Printf.printf "%d\n%!" - (match_with deep 1000 - { retc = (fun x -> !x); - exnc = (fun e -> raise e); - effc = fun (type a) (e : a t) -> - match e with - | E -> Some (fun k -> assert false) - | _ -> None }) diff --git a/testsuite/tests/callback/stack_overflow.reference b/testsuite/tests/callback/stack_overflow.reference deleted file mode 100644 index daaac9e3030..00000000000 --- a/testsuite/tests/callback/stack_overflow.reference +++ /dev/null @@ -1,2 +0,0 @@ -42 -42 diff --git a/testsuite/tests/callback/stack_overflow_.c b/testsuite/tests/callback/stack_overflow_.c deleted file mode 100644 index 0978ac9b20c..00000000000 --- a/testsuite/tests/callback/stack_overflow_.c +++ /dev/null @@ -1,6 +0,0 @@ -#include -#include - -value caml_to_c (value f) { - return caml_callback(f, Val_unit); -} diff --git a/testsuite/tests/callback/tcallback.reference b/testsuite/tests/callback/tcallback.reference deleted file mode 100644 index b35993aa2c0..00000000000 --- a/testsuite/tests/callback/tcallback.reference +++ /dev/null @@ -1,8 +0,0 @@ -7 -7 -7 -7 -7 -aaaaa -aaaaa -bbbbb diff --git a/testsuite/tests/callback/test1.ml b/testsuite/tests/callback/test1.ml deleted file mode 100644 index f6ad4356cfd..00000000000 --- a/testsuite/tests/callback/test1.ml +++ /dev/null @@ -1,53 +0,0 @@ -(* TEST - modules = "test1_.c"; -*) - -(**************************************************************************) - -external mycallback1 : ('a -> 'b) -> 'a -> 'b = "mycallback1" -external mycallback2 : ('a -> 'b -> 'c) -> 'a -> 'b -> 'c = "mycallback2" -external mycallback3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd - = "mycallback3" -external mycallback4 : - ('a -> 'b -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e = "mycallback4" - -let rec growstack n = - if n <= 0 then 0 else 1 + growstack (n - 1) - -let rec tak (x, y, z as _tuple) = - if x > y then tak(tak (x-1, y, z), tak (y-1, z, x), tak (z-1, x, y)) - else z - -let tak2 x (y, z) = tak (x, y, z) - -let tak3 x y z = tak (x, y, z) - -let tak4 x y z u = tak (x, y, z + u) - -let raise_exit () = (raise Exit : unit) - -let trapexit () = - begin try - mycallback1 raise_exit () - with Exit -> - () - end; - tak (18, 12, 6) - -external mypushroot : 'a -> ('b -> 'c) -> 'b -> 'a = "mypushroot" -external mycamlparam : 'a -> ('b -> 'c) -> 'b -> 'a = "mycamlparam" - -let tripwire f = - let s = String.make 5 'a' in - f s trapexit () - -let _ = - print_int(mycallback1 tak (18, 12, 6)); print_newline(); - print_int(mycallback2 tak2 18 (12, 6)); print_newline(); - print_int(mycallback3 tak3 18 12 6); print_newline(); - print_int(mycallback4 tak4 18 12 3 3); print_newline(); - print_int(trapexit ()); print_newline(); - print_string(tripwire mypushroot); print_newline(); - print_string(tripwire mycamlparam); print_newline(); - begin try ignore (mycallback1 growstack 1_000); raise Exit - with Exit -> () end diff --git a/testsuite/tests/callback/test1.reference b/testsuite/tests/callback/test1.reference deleted file mode 100644 index 8b2262dc5c0..00000000000 --- a/testsuite/tests/callback/test1.reference +++ /dev/null @@ -1,7 +0,0 @@ -7 -7 -7 -7 -7 -aaaaa -aaaaa diff --git a/testsuite/tests/callback/test1_.c b/testsuite/tests/callback/test1_.c deleted file mode 100644 index bdce0b17855..00000000000 --- a/testsuite/tests/callback/test1_.c +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1995 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#include "caml/mlvalues.h" -#include "caml/memory.h" -#include "caml/callback.h" - -value mycallback1(value fun, value arg) -{ - value res; - res = caml_callback(fun, arg); - return res; -} - -value mycallback2(value fun, value arg1, value arg2) -{ - value res; - res = caml_callback2(fun, arg1, arg2); - return res; -} - -value mycallback3(value fun, value arg1, value arg2, value arg3) -{ - value res; - res = caml_callback3(fun, arg1, arg2, arg3); - return res; -} - -value mycallback4(value fun, value arg1, value arg2, value arg3, value arg4) -{ - value args[4]; - value res; - args[0] = arg1; - args[1] = arg2; - args[2] = arg3; - args[3] = arg4; - res = caml_callbackN(fun, 4, args); - return res; -} - -value mypushroot(value v, value fun, value arg) -{ - CAMLparam1(v); - caml_callback(fun, arg); - CAMLreturn(v); -} - -value mycamlparam (value v, value fun, value arg) -{ - CAMLparam3 (v, fun, arg); - CAMLlocal2 (x, y); - x = v; - y = caml_callback (fun, arg); - v = x; - CAMLreturn (v); -} diff --git a/testsuite/tests/callback/test2.ml b/testsuite/tests/callback/test2.ml deleted file mode 100644 index b25be523fd5..00000000000 --- a/testsuite/tests/callback/test2.ml +++ /dev/null @@ -1,22 +0,0 @@ -(* TEST - modules = "test2_.c"; - flags = "-alert -unsafe_multidomain"; -*) - -(* Tests nested calls from C (main C) to OCaml (main OCaml) to C (caml_to_c) to - * OCaml (c_to_caml) to C (printf functions). *) - -let printf = Printf.printf - -let c_to_caml () = - printf "[Caml] Enter c_to_caml\n%!"; - printf "[Caml] Leave c_to_caml\n%!" - -let _ = Callback.register "c_to_caml" c_to_caml - -external caml_to_c : unit -> unit = "caml_to_c" - -let _ = - printf "[Caml] Call caml_to_c\n%!"; - caml_to_c (); - printf "[Caml] Return from caml_to_c\n%!" diff --git a/testsuite/tests/callback/test2.reference b/testsuite/tests/callback/test2.reference deleted file mode 100644 index d8c3417bae9..00000000000 --- a/testsuite/tests/callback/test2.reference +++ /dev/null @@ -1,8 +0,0 @@ -[Caml] Call caml_to_c -[C] Enter caml_to_c -[C] Call c_to_caml -[Caml] Enter c_to_caml -[Caml] Leave c_to_caml -[C] Return from c_to_caml -[C] Leave caml_to_c -[Caml] Return from caml_to_c diff --git a/testsuite/tests/callback/test2_.c b/testsuite/tests/callback/test2_.c deleted file mode 100644 index 344864b2134..00000000000 --- a/testsuite/tests/callback/test2_.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -value caml_to_c (value unit) { - CAMLparam1 (unit); - printf ("[C] Enter caml_to_c\n"); - - static const value* c_to_caml_closure = NULL; - - if (!c_to_caml_closure) - c_to_caml_closure = caml_named_value("c_to_caml"); - - printf ("[C] Call c_to_caml\n"); - fflush(stdout); - caml_callback(*c_to_caml_closure, Val_unit); - printf ("[C] Return from c_to_caml\n"); - - printf ("[C] Leave caml_to_c\n"); - fflush(stdout); - CAMLreturn (Val_unit); -} diff --git a/testsuite/tests/callback/test3.ml b/testsuite/tests/callback/test3.ml deleted file mode 100644 index 0813fe4dd9c..00000000000 --- a/testsuite/tests/callback/test3.ml +++ /dev/null @@ -1,42 +0,0 @@ -(* TEST - modules = "test3_.c"; - flags = "-alert -unsafe_multidomain"; - no-tsan; (* TSan does not support call stacks bigger than 64k frames *) - { - bytecode; - }{ - native; - } -*) - -(* Tests nested calls from C (main C) to OCaml (main OCaml) to C (caml_to_c) to - * OCaml (c_to_caml) to C (printf functions). A stack overflow and a heap - * overflow are triggered in c_to_caml. *) - -let printf = Printf.printf - -let rec mk_list length acc = - if length < 1 then acc - else mk_list (length-1) ((length-1)::acc) - -let rec sum n = if n = 0 then 0 else n + sum (n-1) - -let c_to_caml () = - printf "[Caml] Enter c_to_caml\n%!"; - (* Heap overflow *) - let l = mk_list 1000 [] in - Printf.printf "%d\n" (List.hd l); - (* Stack overflow *) - let s = sum 100000 in - Printf.printf "%s\n" - (if s = Int64.to_int 5000050000L then "ok" else "error"); - printf "[Caml] Leave c_to_caml\n%!" - -let _ = Callback.register "c_to_caml" c_to_caml - -external caml_to_c : unit -> unit = "caml_to_c" - -let _ = - printf "[Caml] Call caml_to_c\n%!"; - caml_to_c (); - printf "[Caml] Return from caml_to_c\n%!" diff --git a/testsuite/tests/callback/test3.reference b/testsuite/tests/callback/test3.reference deleted file mode 100644 index 2d5ddac7eb1..00000000000 --- a/testsuite/tests/callback/test3.reference +++ /dev/null @@ -1,10 +0,0 @@ -[Caml] Call caml_to_c -[C] Enter caml_to_c -[C] Call c_to_caml -[Caml] Enter c_to_caml -0 -ok -[Caml] Leave c_to_caml -[C] Return from c_to_caml -[C] Leave caml_to_c -[Caml] Return from caml_to_c diff --git a/testsuite/tests/callback/test3_.c b/testsuite/tests/callback/test3_.c deleted file mode 100644 index 344864b2134..00000000000 --- a/testsuite/tests/callback/test3_.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -value caml_to_c (value unit) { - CAMLparam1 (unit); - printf ("[C] Enter caml_to_c\n"); - - static const value* c_to_caml_closure = NULL; - - if (!c_to_caml_closure) - c_to_caml_closure = caml_named_value("c_to_caml"); - - printf ("[C] Call c_to_caml\n"); - fflush(stdout); - caml_callback(*c_to_caml_closure, Val_unit); - printf ("[C] Return from c_to_caml\n"); - - printf ("[C] Leave caml_to_c\n"); - fflush(stdout); - CAMLreturn (Val_unit); -} diff --git a/testsuite/tests/callback/test4.ml b/testsuite/tests/callback/test4.ml deleted file mode 100644 index 070fc7012c3..00000000000 --- a/testsuite/tests/callback/test4.ml +++ /dev/null @@ -1,28 +0,0 @@ -(* TEST - modules = "test4_.c"; - flags = "-alert -unsafe_multidomain"; -*) - -(* Tests nested calls from C (main C) to OCaml (main OCaml) to C (caml_to_c) to - * OCaml (c_to_caml) to C (printf functions). Exception is raised in a - * Callback, which unwinds the C stack and gets caught in OCaml. *) - -exception E - -let printf = Printf.printf - -let c_to_caml () = - printf "[Caml] Enter c_to_caml\n%!"; - printf "[Caml] c_to_caml: raise exception\n%!"; - raise E - -let _ = Callback.register "c_to_caml" c_to_caml - -external caml_to_c : unit -> unit = "caml_to_c" - -let _ = - try - printf "[Caml] Call caml_to_c\n%!"; - caml_to_c (); - printf "[Caml] Return from caml_to_c\n%!" - with E -> printf "[Caml] Caught exception\n%!" diff --git a/testsuite/tests/callback/test4.reference b/testsuite/tests/callback/test4.reference deleted file mode 100644 index 4b41fb97876..00000000000 --- a/testsuite/tests/callback/test4.reference +++ /dev/null @@ -1,6 +0,0 @@ -[Caml] Call caml_to_c -[C] Enter caml_to_c -[C] Call c_to_caml -[Caml] Enter c_to_caml -[Caml] c_to_caml: raise exception -[Caml] Caught exception diff --git a/testsuite/tests/callback/test4_.c b/testsuite/tests/callback/test4_.c deleted file mode 100644 index 344864b2134..00000000000 --- a/testsuite/tests/callback/test4_.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -value caml_to_c (value unit) { - CAMLparam1 (unit); - printf ("[C] Enter caml_to_c\n"); - - static const value* c_to_caml_closure = NULL; - - if (!c_to_caml_closure) - c_to_caml_closure = caml_named_value("c_to_caml"); - - printf ("[C] Call c_to_caml\n"); - fflush(stdout); - caml_callback(*c_to_caml_closure, Val_unit); - printf ("[C] Return from c_to_caml\n"); - - printf ("[C] Leave caml_to_c\n"); - fflush(stdout); - CAMLreturn (Val_unit); -} diff --git a/testsuite/tests/callback/test5.ml b/testsuite/tests/callback/test5.ml deleted file mode 100644 index 9c528bc41bb..00000000000 --- a/testsuite/tests/callback/test5.ml +++ /dev/null @@ -1,26 +0,0 @@ -(* TEST - modules = "test5_.c"; - flags = "-alert -unsafe_multidomain"; -*) - -(* Tests nested calls from C (main C) to OCaml (main OCaml) to C (caml_to_c) to - * OCaml (c_to_caml) to C (printf functions). Test calls with arguments passed - * on the stack from C to OCaml and OCaml to C. *) - -let printf = Printf.printf - -let c_to_caml n = - printf "[Caml] Enter c_to_caml\n%!"; - printf "c_to_caml: n=%d\n" n; - printf "[Caml] Leave c_to_caml\n%!" - -let _ = Callback.register "c_to_caml" c_to_caml - -external caml_to_c : int -> int -> int -> int -> int - -> int -> int -> int -> int -> int - -> int -> unit = "caml_to_c_bytecode" "caml_to_c_native" - -let _ = - printf "[Caml] Call caml_to_c\n%!"; - caml_to_c 1 2 3 4 5 6 7 8 9 10 11; - printf "[Caml] Return from caml_to_c\n%!" diff --git a/testsuite/tests/callback/test5.reference b/testsuite/tests/callback/test5.reference deleted file mode 100644 index a42f9b6dd0d..00000000000 --- a/testsuite/tests/callback/test5.reference +++ /dev/null @@ -1,9 +0,0 @@ -[Caml] Call caml_to_c -[C] Enter caml_to_c -[C] Call c_to_caml -[Caml] Enter c_to_caml -c_to_caml: n=66 -[Caml] Leave c_to_caml -[C] Return from c_to_caml -[C] Leave caml_to_c -[Caml] Return from caml_to_c diff --git a/testsuite/tests/callback/test5_.c b/testsuite/tests/callback/test5_.c deleted file mode 100644 index 042c8603686..00000000000 --- a/testsuite/tests/callback/test5_.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include -#include - -value caml_to_c_native (value a1, value a2, value a3, value a4, value a5, - value a6, value a7, value a8, value a9, value a10, - value a11) -{ - CAMLparam0 (); - long l; - - printf ("[C] Enter caml_to_c\n"); - - static const value* c_to_caml_closure = NULL; - if (!c_to_caml_closure) - c_to_caml_closure = caml_named_value("c_to_caml"); - - l = Long_val (a1) + Long_val (a2) + Long_val (a3) + Long_val (a4) - + Long_val (a5) + Long_val (a6) + Long_val (a7) + Long_val (a8) - + Long_val (a9) + Long_val (a10) + Long_val (a11); - - printf ("[C] Call c_to_caml\n"); - fflush(stdout); - caml_callback(*c_to_caml_closure, Val_long(l)); - printf ("[C] Return from c_to_caml\n"); - - printf ("[C] Leave caml_to_c\n"); - fflush(stdout); - CAMLreturn (Val_unit); -} - -value caml_to_c_bytecode (value * argv, int argn) { - return caml_to_c_native (argv[0], argv[1], argv[2], argv[3], argv[4], - argv[5], argv[6], argv[7], argv[8], argv[9], - argv[10]); -} diff --git a/testsuite/tests/callback/test6.ml b/testsuite/tests/callback/test6.ml deleted file mode 100644 index 7a336775453..00000000000 --- a/testsuite/tests/callback/test6.ml +++ /dev/null @@ -1,31 +0,0 @@ -(* TEST - modules = "test6_.c"; - flags = "-alert -unsafe_multidomain"; -*) - -(* Tests nested calls from C (main C) to OCaml (main OCaml) to C (caml_to_c) to - * OCaml (c_to_caml) to C (printf functions). Exception is raised in a - * Callback, which unwinds the C stack and gets caught in OCaml. *) - -exception E - -let printf = Printf.printf - -let c_to_caml () = - printf "[Caml] Enter c_to_caml\n%!"; - printf "[Caml] c_to_caml: raise exception\n%!"; - raise E - -let _ = Callback.register "c_to_caml" c_to_caml - -external caml_to_c : unit -> unit = "caml_to_c" - -let _ = - try - printf "[Caml] Call caml_to_c\n%!"; - caml_to_c (); - printf "[Caml] Return from caml_to_c\n%!" - with E -> - (printf "[Caml] Caught exception\n%!"; - try caml_to_c() with E -> printf "[Caml] Caught exceception again\n%!"; - printf "[Caml] Done\n%!") diff --git a/testsuite/tests/callback/test6.reference b/testsuite/tests/callback/test6.reference deleted file mode 100644 index 4d687ba89de..00000000000 --- a/testsuite/tests/callback/test6.reference +++ /dev/null @@ -1,12 +0,0 @@ -[Caml] Call caml_to_c -[C] Enter caml_to_c -[C] Call c_to_caml -[Caml] Enter c_to_caml -[Caml] c_to_caml: raise exception -[Caml] Caught exception -[C] Enter caml_to_c -[C] Call c_to_caml -[Caml] Enter c_to_caml -[Caml] c_to_caml: raise exception -[Caml] Caught exceception again -[Caml] Done diff --git a/testsuite/tests/callback/test6_.c b/testsuite/tests/callback/test6_.c deleted file mode 100644 index 344864b2134..00000000000 --- a/testsuite/tests/callback/test6_.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -value caml_to_c (value unit) { - CAMLparam1 (unit); - printf ("[C] Enter caml_to_c\n"); - - static const value* c_to_caml_closure = NULL; - - if (!c_to_caml_closure) - c_to_caml_closure = caml_named_value("c_to_caml"); - - printf ("[C] Call c_to_caml\n"); - fflush(stdout); - caml_callback(*c_to_caml_closure, Val_unit); - printf ("[C] Return from c_to_caml\n"); - - printf ("[C] Leave caml_to_c\n"); - fflush(stdout); - CAMLreturn (Val_unit); -} diff --git a/testsuite/tests/callback/test7.ml b/testsuite/tests/callback/test7.ml deleted file mode 100644 index 984b1f4da83..00000000000 --- a/testsuite/tests/callback/test7.ml +++ /dev/null @@ -1,47 +0,0 @@ -(* TEST - modules = "test7_.c"; - runtime5; - libunix; - { - bytecode; - }{ - native; - } -*) - -(* Tests nested calls from C (main C) to OCaml (main OCaml) to C (caml_to_c) to - * OCaml (c_to_caml) to C (printf functions). Effect E is performed in the - * callback, which does not have a handler. *) - -[@@@ocaml.alert "-unsafe_multidomain"] - -open Effect -open Effect.Deep - -type _ t += E : unit t - -let printf = Printf.printf - -let c_to_caml () = - printf "[Caml] Enter c_to_caml\n%!"; - printf "[Caml] c_to_caml: perform effect\n%!"; - perform E - -let _ = Callback.register "c_to_caml" c_to_caml - -external caml_to_c : unit -> unit = "caml_to_c" - -let _ = - try_with (fun () -> - printf "[Caml] Call caml_to_c\n%!"; - begin try - caml_to_c () - with Effect.Unhandled E -> - (printf "[Caml] Caught Effect.Unhandled, perform effect\n%!"; - perform E) - end; - printf "[Caml] Return from caml_to_c\n%!") () - { effc = fun (type a) (e : a t) -> - match e with - | E -> Some (fun k -> printf "[Caml] Caught effect\n%!") - | _ -> None } diff --git a/testsuite/tests/callback/test7.reference b/testsuite/tests/callback/test7.reference deleted file mode 100644 index 2e2acfc6f7b..00000000000 --- a/testsuite/tests/callback/test7.reference +++ /dev/null @@ -1,7 +0,0 @@ -[Caml] Call caml_to_c -[C] Enter caml_to_c -[C] Call c_to_caml -[Caml] Enter c_to_caml -[Caml] c_to_caml: perform effect -[Caml] Caught Effect.Unhandled, perform effect -[Caml] Caught effect diff --git a/testsuite/tests/callback/test7_.c b/testsuite/tests/callback/test7_.c deleted file mode 100644 index 344864b2134..00000000000 --- a/testsuite/tests/callback/test7_.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -value caml_to_c (value unit) { - CAMLparam1 (unit); - printf ("[C] Enter caml_to_c\n"); - - static const value* c_to_caml_closure = NULL; - - if (!c_to_caml_closure) - c_to_caml_closure = caml_named_value("c_to_caml"); - - printf ("[C] Call c_to_caml\n"); - fflush(stdout); - caml_callback(*c_to_caml_closure, Val_unit); - printf ("[C] Return from c_to_caml\n"); - - printf ("[C] Leave caml_to_c\n"); - fflush(stdout); - CAMLreturn (Val_unit); -} diff --git a/testsuite/tests/callback/test_finaliser_gc.ml b/testsuite/tests/callback/test_finaliser_gc.ml deleted file mode 100644 index 97c98cf89a2..00000000000 --- a/testsuite/tests/callback/test_finaliser_gc.ml +++ /dev/null @@ -1,30 +0,0 @@ -(* TEST *) - -let z = ref (0, 1, 2, 3, 4, 5, 6, 7) -let finaliser_pending = ref true - -let force_gc_fn _ = - print_string "Finaliser has run!"; print_newline(); - finaliser_pending := false; - Gc.full_major () - -let trigger_finaliser () = - (* Construct finaliser which when run will force - a major cycle *) - Gc.finalise force_gc_fn (ref 0); - (* Allocate a block in the minor heap *) - let s = String.make 5 'b' in - (* Spin on the minor heap allocating but keep [s] in a - register and force a major cycle such that the - finaliser runs. - NB: we quit after ~8B words allocated should something - be broken with finalisers *) - let x = ref 0 in - while (!x < 1_000_000_000) && !finaliser_pending do - z := (!x, !x, !x, !x, !x, !x, !x, !x); - incr x; - done; - s - -let _ = - print_string (trigger_finaliser ()); print_newline(); diff --git a/testsuite/tests/callback/test_finaliser_gc.reference b/testsuite/tests/callback/test_finaliser_gc.reference deleted file mode 100644 index 8afdc9181bb..00000000000 --- a/testsuite/tests/callback/test_finaliser_gc.reference +++ /dev/null @@ -1,2 +0,0 @@ -Finaliser has run! -bbbbb diff --git a/testsuite/tests/callback/test_signalhandler.ml b/testsuite/tests/callback/test_signalhandler.ml deleted file mode 100644 index 98e2bf73669..00000000000 --- a/testsuite/tests/callback/test_signalhandler.ml +++ /dev/null @@ -1,83 +0,0 @@ -(* TEST - include unix; - flags = "-alert -unsafe_multidomain"; - modules = "test_signalhandler_.c"; - libunix; - { - bytecode; - }{ - native; - } -*) - -(**************************************************************************) - -external mycallback1 : ('a -> 'b) -> 'a -> 'b = "mycallback1" -external mycallback2 : ('a -> 'b -> 'c) -> 'a -> 'b -> 'c = "mycallback2" -external mycallback3 : ('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd - = "mycallback3" -external mycallback4 : - ('a -> 'b -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e = "mycallback4" - -let rec tak (x, y, z as _tuple) = - if x > y then tak(tak (x-1, y, z), tak (y-1, z, x), tak (z-1, x, y)) - else z - -let tak2 x (y, z) = tak (x, y, z) - -let tak3 x y z = tak (x, y, z) - -let tak4 x y z u = tak (x, y, z + u) - -let raise_exit () = (raise Exit : unit) - -let trapexit () = - begin try - mycallback1 raise_exit () - with Exit -> - () - end; - tak (18, 12, 6) - -external mypushroot : 'a -> ('b -> 'c) -> 'b -> 'a = "mypushroot" -external mycamlparam : 'a -> ('b -> 'c) -> 'b -> 'a = "mycamlparam" - -let tripwire f = - let s = String.make 5 'a' in - f s trapexit () - -(* Test callbacks performed to handle signals *) - -let sighandler signo = -(* - print_string "Got signal, triggering garbage collection..."; - print_newline(); -*) - (* Thoroughly wipe the minor heap *) - ignore (tak (18, 12, 6)) - -external mykill : int -> int -> unit = "mykill" [@@noalloc] - -let callbacksig () = - let pid = Unix.getpid () in - (* Allocate a block in the minor heap *) - let s = String.make 5 'b' in - (* Send a signal to self. We want s to remain in a register and - not be spilled on the stack, hence we use [mykill] - (which is [@@noalloc] and doesn't trigger signal handling) - instead of [Unix.kill]. *) - mykill pid Sys.sigusr1; - (* Allocate some more so that the signal will be tested *) - let u = (s, s) in - fst u - -let _ = - print_int(mycallback1 tak (18, 12, 6)); print_newline(); - print_int(mycallback2 tak2 18 (12, 6)); print_newline(); - print_int(mycallback3 tak3 18 12 6); print_newline(); - print_int(mycallback4 tak4 18 12 3 3); print_newline(); - print_int(trapexit ()); print_newline(); - print_string(tripwire mypushroot); print_newline(); - print_string(tripwire mycamlparam); print_newline(); - Sys.set_signal Sys.sigusr1 (Sys.Signal_handle sighandler); - print_string(callbacksig ()); print_newline() diff --git a/testsuite/tests/callback/test_signalhandler.reference b/testsuite/tests/callback/test_signalhandler.reference deleted file mode 100644 index b35993aa2c0..00000000000 --- a/testsuite/tests/callback/test_signalhandler.reference +++ /dev/null @@ -1,8 +0,0 @@ -7 -7 -7 -7 -7 -aaaaa -aaaaa -bbbbb diff --git a/testsuite/tests/callback/test_signalhandler_.c b/testsuite/tests/callback/test_signalhandler_.c deleted file mode 100644 index 3f7b77240c8..00000000000 --- a/testsuite/tests/callback/test_signalhandler_.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1995 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#include - -#define CAML_INTERNALS - -#include "caml/mlvalues.h" -#include "caml/memory.h" -#include "caml/callback.h" -#include "caml/signals.h" - -value mycallback1(value fun, value arg) -{ - value res; - res = caml_callback(fun, arg); - return res; -} - -value mycallback2(value fun, value arg1, value arg2) -{ - value res; - res = caml_callback2(fun, arg1, arg2); - return res; -} - -value mycallback3(value fun, value arg1, value arg2, value arg3) -{ - value res; - res = caml_callback3(fun, arg1, arg2, arg3); - return res; -} - -value mycallback4(value fun, value arg1, value arg2, value arg3, value arg4) -{ - value args[4]; - value res; - args[0] = arg1; - args[1] = arg2; - args[2] = arg3; - args[3] = arg4; - res = caml_callbackN(fun, 4, args); - return res; -} - -value mypushroot(value v, value fun, value arg) -{ - CAMLparam1(v); - caml_callback(fun, arg); - CAMLreturn(v); -} - -value mycamlparam (value v, value fun, value arg) -{ - CAMLparam3 (v, fun, arg); - CAMLlocal2 (x, y); - x = v; - y = caml_callback (fun, arg); - v = x; - CAMLreturn (v); -} - -value mykill(value pid, value signal) -{ - int sig; - sig = caml_convert_signal_number(Int_val(signal)); - kill(Int_val(pid), sig); - return Val_unit; -} diff --git a/testsuite/tests/lib-extensions/modules.ml b/testsuite/tests/lib-extensions/modules.ml deleted file mode 100644 index 0ea4a207c07..00000000000 --- a/testsuite/tests/lib-extensions/modules.ml +++ /dev/null @@ -1,9 +0,0 @@ -(* TEST - { - bytecode; - }{ - native; - } -*) - -(* Check that extension library modules exist. *) diff --git a/testsuite/tests/unboxed-primitive-args/README b/testsuite/tests/unboxed-primitive-args/README deleted file mode 100644 index 4bd7601e511..00000000000 --- a/testsuite/tests/unboxed-primitive-args/README +++ /dev/null @@ -1,26 +0,0 @@ -This directory contains tests to check that OCaml values are correctly -passed between OCaml and C when a primitive takes some or all of its -arguments unboxed/untagged and/or return its result unboxed/untagged. - -To test one primitive we do: -- write all its argument and expected result in buffer A -- call the C external using arguments read from buffer A -- the C function write all the arguments it receive into buffer B -- the C function read the result from buffer A and returns it -- on the OCaml side we write the received result into buffer B -- the test is successful if A and B have the same contents - -Between each call, we call a function with 128 value arguments set to -0 and a function with 32 unboxed float arguments set to 0., just to -clean-up the registers and stacks in case garbage would make a test -succeed. We don't pass more floats as it doesn't build on arm32. - -We construct the set of primitives to test as follow: -- all combination of unboxed int32/int64/float arguments for functions - taking up to 6 arguments (with more than 6 ocamlopt takes a really - long time to compile the test files) -- a bunch of manual tests for the rest and specific patterns. - The list is [Gen_test.manual_tests] - -We test the set of primitives a thousand times, with different random -data each time. diff --git a/testsuite/tests/unboxed-primitive-args/common.ml b/testsuite/tests/unboxed-primitive-args/common.ml deleted file mode 100644 index f3ed7ca9e78..00000000000 --- a/testsuite/tests/unboxed-primitive-args/common.ml +++ /dev/null @@ -1,321 +0,0 @@ -open StdLabels - -open Bigarray - -type 'a typ = - | Int : int typ - | Int32 : int32 typ - | Int64 : int64 typ - | Nativeint : nativeint typ - | Float : float typ - | Float64x2 : float64x2 typ - | Int64x2 : int64x2 typ - -type 'a proto = - | Ret : 'a typ -> 'a proto - | Abs : 'a typ * 'b proto -> ('a -> 'b) proto - -let ( ** ) x y = Abs (x, y) - -(* This form is easier to process programmatically. We don't expose it as - ocamlopt takes a really really long time to compile a constant list - of these. *) -type simplified_test = Test : string * 'a * 'a proto -> simplified_test - -type test = - | T1 : string * ('a -> 'b) * 'a typ * 'b typ -> test - | T2 : string * ('a -> 'b -> 'c) * 'a typ * 'b typ * 'c typ -> test - | T3 : string * ('a -> 'b -> 'c -> 'd) * - 'a typ * 'b typ * 'c typ * 'd typ -> test - | T4 : string * ('a -> 'b -> 'c -> 'd -> 'e) * - 'a typ * 'b typ * 'c typ * 'd typ * 'e typ -> test - | T5 : string * ('a -> 'b -> 'c -> 'd -> 'e -> 'f) * - 'a typ * 'b typ * 'c typ * 'd typ * 'e typ * 'f typ -> test - | T6 : string * ('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) * - 'a typ * 'b typ * 'c typ * 'd typ * 'e typ * 'f typ * 'g typ -> test - | T : string * 'a * 'a proto -> test - -let expand_test = function - | T1 (s, fn, a, b) -> Test (s, fn, a ** Ret b) - | T2 (s, fn, a, b, c) -> Test (s, fn, a ** b ** Ret c) - | T3 (s, fn, a, b, c, d) -> Test (s, fn, a ** b ** c ** Ret d) - | T4 (s, fn, a, b, c, d, e) -> Test (s, fn, a ** b ** c ** d ** Ret e) - | T5 (s, fn, a, b, c, d, e, f) -> - Test (s, fn, a ** b ** c ** d ** e ** Ret f) - | T6 (s, fn, a, b, c, d, e, f, g) -> - Test (s, fn, a ** b ** c ** d ** e ** f ** Ret g) - | T (s, fn, p) -> Test (s, fn, p) - -external int64x2_of_int64s : int64 -> int64 -> int64x2 = "" "vec128_of_int64s" [@@noalloc] [@@unboxed] -external int64x2_low_int64 : int64x2 -> int64 = "" "vec128_low_int64" [@@noalloc] [@@unboxed] -external int64x2_high_int64 : int64x2 -> int64 = "" "vec128_high_int64" [@@noalloc] [@@unboxed] - -external float64x2_of_int64s : int64 -> int64 -> float64x2 = "" "vec128_of_int64s" [@@noalloc] [@@unboxed] -external float64x2_low_int64 : float64x2 -> int64 = "" "vec128_low_int64" [@@noalloc] [@@unboxed] -external float64x2_high_int64 : float64x2 -> int64 = "" "vec128_high_int64" [@@noalloc] [@@unboxed] - -let string_of : type a. a typ -> a -> string = function - | Int -> Int.to_string - | Int32 -> Printf.sprintf "%ldl" - | Int64 -> Printf.sprintf "%LdL" - | Nativeint -> Printf.sprintf "%ndn" - | Float -> - fun f -> Printf.sprintf "float_of_bits 0x%LxL" (Int64.bits_of_float f) - | Int64x2 -> - fun v -> Printf.sprintf "int64x2 %016Lx:%016Lx" (int64x2_high_int64 v) (int64x2_low_int64 v) - | Float64x2 -> - fun v -> Printf.sprintf "float64x2 %016Lx:%016Lx" (float64x2_high_int64 v) (float64x2_low_int64 v) - -let rec arity : type a. a proto -> int = function - | Ret _ -> 0 - | Abs (_, p) -> 1 + arity p - -module Buffer = struct - type t = (char, int8_unsigned_elt, c_layout) Array1.t - - let arg_size = 16 - - let create ~arity : t = - Array1.create char c_layout ((arity + 1) * arg_size) - - let clear (t : t) = Array1.fill t '\000' - - let length : t -> int = Array1.dim - - external init_c_side : ocaml_buffer:t -> c_buffer:t -> unit - = "test_set_buffers" - - external get_int32 : t -> int -> int32 = "%caml_bigstring_get32" - external get_int64 : t -> int -> int64 = "%caml_bigstring_get64" - external set_int32 : t -> int -> int32 -> unit = "%caml_bigstring_set32" - external set_int64 : t -> int -> int64 -> unit = "%caml_bigstring_set64" - - let get_int64x2 buf ~arg = - let low, high = get_int64 buf (arg * arg_size), get_int64 buf (arg * arg_size + 8) in - int64x2_of_int64s low high - - let set_int64x2 buf ~arg x = - set_int64 buf (arg * arg_size) (int64x2_low_int64 x); - set_int64 buf ((arg * arg_size) + 8) (int64x2_high_int64 x) - - let get_float64x2 buf ~arg = - let low, high = get_int64 buf (arg * arg_size), get_int64 buf (arg * arg_size + 8) in - float64x2_of_int64s low high - - let set_float64x2 buf ~arg x = - set_int64 buf (arg * arg_size) (float64x2_low_int64 x); - set_int64 buf ((arg * arg_size) + 8) (float64x2_high_int64 x) - - let get_int32 t ~arg = get_int32 t (arg * arg_size) - let get_int64 t ~arg = get_int64 t (arg * arg_size) - let set_int32 t ~arg x = set_int32 t (arg * arg_size) x - let set_int64 t ~arg x = set_int64 t (arg * arg_size) x - - let get_nativeint, set_nativeint = - match Sys.word_size with - | 32 -> ((fun t ~arg -> get_int32 t ~arg |> Nativeint.of_int32), - (fun t ~arg x -> set_int32 t ~arg (Nativeint.to_int32 x))) - | 64 -> ((fun t ~arg -> get_int64 t ~arg |> Int64.to_nativeint), - (fun t ~arg x -> set_int64 t ~arg (Int64.of_nativeint x))) - | n -> Printf.ksprintf failwith "unknown word size (%d)" n - - let get_int = - if Sys.word_size = 32 then - fun buf ~arg -> get_int32 buf ~arg |> Int32.to_int - else - fun buf ~arg -> get_int64 buf ~arg |> Int64.to_int - - let set_int = - if Sys.word_size = 32 then - fun buf ~arg x -> set_int32 buf ~arg (Int32.of_int x) - else - fun buf ~arg x -> set_int64 buf ~arg (Int64.of_int x) - - let get_float buf ~arg = get_int64 buf ~arg |> Int64.float_of_bits - let set_float buf ~arg x = set_int64 buf ~arg (Int64.bits_of_float x) - - let get : type a. a typ -> t -> arg:int -> a = function - | Int -> get_int - | Int32 -> get_int32 - | Int64 -> get_int64 - | Nativeint -> get_nativeint - | Float -> get_float - | Int64x2 -> get_int64x2 - | Float64x2 -> get_float64x2 - - let set : type a. a typ -> t -> arg:int -> a -> unit = function - | Int -> set_int - | Int32 -> set_int32 - | Int64 -> set_int64 - | Nativeint -> set_nativeint - | Float -> set_float - | Int64x2 -> set_int64x2 - | Float64x2 -> set_float64x2 - - (* This is almost a memcpy except that we use get/set which should - ensure that the values in [dst] don't overflow. *) - let copy_args ~src ~dst proto = - let rec loop : type a. a proto -> int -> unit = fun proto arg -> - match proto with - | Ret typ -> - set typ dst ~arg (get typ src ~arg) - | Abs (typ, rest) -> - set typ dst ~arg (get typ src ~arg); - loop rest (arg + 1) - in - loop proto 0 -end - -let exec proto f ~ocaml_buffer ~c_buffer = - let rec loop : type a. a proto -> a -> int -> unit = fun proto f arg -> - match proto with - | Ret typ -> - Buffer.set typ c_buffer ~arg f - | Abs (typ, rest) -> - let x = Buffer.get typ ocaml_buffer ~arg in - loop rest (f x) (arg + 1) - in - loop proto f 0 - -let strings_of_test_instance name proto buffer = - let rec loop : type a. a proto -> int -> string list -> string list * string = - fun proto arg acc -> - match proto with - | Ret typ -> - (List.rev acc, string_of typ (Buffer.get typ buffer ~arg)) - | Abs (typ, rest) -> - let s = string_of typ (Buffer.get typ buffer ~arg) in - loop rest (arg + 1) (s :: acc) - in - loop proto 0 [] - -let typ_size : type a. a typ -> int = function - | Int -> Sys.word_size / 8 - | Int32 -> 4 - | Int64 -> 8 - | Nativeint -> Sys.word_size / 8 - | Float -> 8 - | Int64x2 | Float64x2 -> 16 - -let rec sizes : type a. a proto -> int list = function - | Ret typ -> [typ_size typ] - | Abs (typ, rest) -> typ_size typ :: sizes rest - -let print_hex ~sizes ~arity buffer = - let printf = Printf.printf in - printf "("; - for i = 0 to arity do - if i = arity then - printf ") -> " - else if i > 0 then - printf ", "; - for ofs = i * Buffer.arg_size to i * Buffer.arg_size + sizes.(i) - 1 do - printf "%02x" (Char.code buffer.{ofs}); - done; - done - -let printed_mismatches = ref 0 - -let print_mismatch name proto ~ocaml_buffer ~c_buffer = - let printf = Printf.printf in - printf "Mismatch for %s\n" name; - let o_args, o_res = strings_of_test_instance name proto ocaml_buffer in - let c_args, c_res = strings_of_test_instance name proto c_buffer in - let o_args, c_args = - (* Align arguments *) - List.map2 o_args c_args ~f:(fun a b -> - let len_a = String.length a and len_b = String.length b in - let len = max len_a len_b in - (Printf.sprintf "%*s" len a, - Printf.sprintf "%*s" len b)) - |> List.split - in - printf "ocaml side : (%s) -> %s\n" (String.concat ~sep:", " o_args) o_res; - printf "c side : (%s) -> %s\n" (String.concat ~sep:", " c_args) c_res; - let sizes = sizes proto |> Array.of_list in - let arity = arity proto in - printf "ocaml side : "; print_hex ~sizes ~arity ocaml_buffer; printf "\n"; - printf "c side : "; print_hex ~sizes ~arity c_buffer; printf "\n"; - incr printed_mismatches; - if !printed_mismatches >= 1000 then begin - printf "Output truncated at 1000 failures."; - exit 0 - end - -external cleanup_normal - : int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int -> int -> int -> int -> int -> int -> int -> int - -> int = "" "test_cleanup_normal" [@@noalloc] - -external cleanup_float - : float -> float -> float -> float -> float -> float -> float -> float - -> float -> float -> float -> float -> float -> float -> float -> float - -> float -> float -> float -> float -> float -> float -> float -> float - -> float -> float -> float -> float -> float -> float -> float -> float - -> float = "" "test_cleanup_float" [@@noalloc] [@@unboxed] - -let cleanup_args_and_stack () = - let _ : int = - cleanup_normal - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - in - let _ : float = - cleanup_float - 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. - 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. - in - () - -let run_test ~random_data ~ocaml_buffer ~c_buffer (Test (name, f, proto)) = - Buffer.clear ocaml_buffer; - Buffer.clear c_buffer; - Buffer.copy_args ~src:random_data ~dst:ocaml_buffer proto; - cleanup_args_and_stack (); - exec proto f ~ocaml_buffer ~c_buffer; - let success = ocaml_buffer = c_buffer in - if not success then print_mismatch name proto ~ocaml_buffer ~c_buffer; - success - -let run_tests tests = - let tests = List.map tests ~f:expand_test in - let max_args = - List.fold_left tests ~init:0 ~f:(fun acc (Test (_, _, p)) -> - max acc (arity p)) - in - - let ocaml_buffer = Buffer.create ~arity:max_args - and c_buffer = Buffer.create ~arity:max_args in - Buffer.init_c_side ~ocaml_buffer ~c_buffer; - - let random_data = Buffer.create ~arity:max_args in - let new_random_data () = - for i = 0 to Buffer.length random_data - 1 do - random_data.{i} <- char_of_int (Random.int 256) - done - in - - let failure = ref false in - for i = 1 to 1000 do - new_random_data (); - List.iter tests ~f:(fun test -> - if not (run_test ~random_data ~ocaml_buffer ~c_buffer test) then - failure := true) - done; - exit (if !failure then 1 else 0) diff --git a/testsuite/tests/unboxed-primitive-args/common.mli b/testsuite/tests/unboxed-primitive-args/common.mli deleted file mode 100644 index 454c589ffb5..00000000000 --- a/testsuite/tests/unboxed-primitive-args/common.mli +++ /dev/null @@ -1,31 +0,0 @@ -(** Type of arguments/result *) -type 'a typ = - | Int : int typ - | Int32 : int32 typ - | Int64 : int64 typ - | Nativeint : nativeint typ - | Float : float typ - | Float64x2 : float64x2 typ - | Int64x2 : int64x2 typ - -type 'a proto = - | Ret : 'a typ -> 'a proto - | Abs : 'a typ * 'b proto -> ('a -> 'b) proto - -(** Same as [Abs]. We choose this operator for its associativity. *) -val ( ** ) : 'a typ -> 'b proto -> ('a -> 'b) proto - -type test = - | T1 : string * ('a -> 'b) * 'a typ * 'b typ -> test - | T2 : string * ('a -> 'b -> 'c) * 'a typ * 'b typ * 'c typ -> test - | T3 : string * ('a -> 'b -> 'c -> 'd) * - 'a typ * 'b typ * 'c typ * 'd typ -> test - | T4 : string * ('a -> 'b -> 'c -> 'd -> 'e) * - 'a typ * 'b typ * 'c typ * 'd typ * 'e typ -> test - | T5 : string * ('a -> 'b -> 'c -> 'd -> 'e -> 'f) * - 'a typ * 'b typ * 'c typ * 'd typ * 'e typ * 'f typ -> test - | T6 : string * ('a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g) * - 'a typ * 'b typ * 'c typ * 'd typ * 'e typ * 'f typ * 'g typ -> test - | T : string * 'a * 'a proto -> test - -val run_tests : test list -> unit diff --git a/testsuite/tests/unboxed-primitive-args/gen_test.ml b/testsuite/tests/unboxed-primitive-args/gen_test.ml deleted file mode 100644 index 5c54dc0996a..00000000000 --- a/testsuite/tests/unboxed-primitive-args/gen_test.ml +++ /dev/null @@ -1,275 +0,0 @@ -(* This programs generate stubs with various prototype combinations *) - -open StdLabels - -type boxed_integer = Pnativeint | Pint32 | Pint64 - -type boxed_vector = Pint64x2 | Pfloat64x2 - -type native_repr = - | Same_as_ocaml_repr - | Unboxed_float - | Unboxed_integer of boxed_integer - | Untagged_int - | Unboxed_vector of boxed_vector - -(* Generate primitives with up to this number of arguments *) -let test_all_combination_up_to_n_args = 5 - -(* Generate primitives using all combination of these argument - representations. No need to test all combination of other - representations: regarding the calling convention - [Same_as_ocaml_repr], [Untagged_int] and - [Unboxed_integer Pnativeint] are all the same, and are the - same as [Unboxed_integer Pint]. - - We have specific tests for the other representations and for the - result representation in [manual_tests]. -*) -let test_all_args_combination_of = - [ Unboxed_float - ; Unboxed_integer Pint32 - ; Unboxed_integer Pint64 - ; Unboxed_vector Pint64x2 - ; Unboxed_vector Pfloat64x2 - ] - -let code_of_repr = function - | Same_as_ocaml_repr -> "v" (* for "value" *) - | Unboxed_float -> "f" - | Unboxed_integer Pint32 -> "l" - | Unboxed_integer Pint64 -> "L" - | Unboxed_integer Pnativeint -> "n" - | Untagged_int -> "i" - | Unboxed_vector Pint64x2 -> "I" - | Unboxed_vector Pfloat64x2 -> "x" - -let repr_of_code = function - | 'v' -> Same_as_ocaml_repr - | 'f' -> Unboxed_float - | 'l' -> Unboxed_integer Pint32 - | 'L' -> Unboxed_integer Pint64 - | 'n' -> Unboxed_integer Pnativeint - | 'i' -> Untagged_int - | 'x' -> Unboxed_vector Pfloat64x2 - | 'I' -> Unboxed_vector Pint64x2 - | _ -> assert false - -let manual_tests = - [ "v_v" - ; "f_f" - ; "l_l" - ; "L_L" - ; "n_n" - ; "i_i" - ; "x_x" - ; "f_fffff" - ; "f_ffffff" - ; "f_fffffff" - ; "f_fffffffffffffffff" - ; "x_xxxxx" - ; "x_xxxxxx" - ; "x_xxxxxxx" - ; "x_xxxxxxxxxxxxxxxxx" - ; "v_iiiiiiiiiiiiiiiii" - ; "v_lllllllllllllllll" - ; "v_LLLLLLLLLLLLLLLLL" - ; "v_iLiLiLiLiLiLiLiLi" - ; "v_LiLiLiLiLiLiLiLiL" - ; "v_flflflflflflflflflflflflflflflflflfl" - ; "v_fLfLfLfLfLfLfLfLfLfLfLfLfLfLfLfLfLfL" - ; "v_xfxfxfxfxfxfxfxfx" - ; "v_fxfxfxfxfxfxfxfxf" - ; "v_lfxlfxlfxlfxlfxlfx" - ; "v_lflxlxlflflxlxlflx" - ; "v_llllllfffffflxxllxx" - ] - -let ocaml_type_of_repr = function - (* Doesn't really matters what we choose for this case *) - | Same_as_ocaml_repr -> "int" - | Unboxed_float -> "(float [@unboxed])" - | Unboxed_integer Pint32 -> "(int32 [@unboxed])" - | Unboxed_integer Pint64 -> "(int64 [@unboxed])" - | Unboxed_integer Pnativeint -> "(nativeint [@unboxed])" - | Untagged_int -> "(int [@untagged])" - | Unboxed_vector Pfloat64x2 -> "(float64x2 [@unboxed])" - | Unboxed_vector Pint64x2 -> "(int64x2 [@unboxed])" - -let ocaml_type_gadt_of_repr = function - (* Doesn't really matters what we choose for this case *) - | Same_as_ocaml_repr -> "Int" - | Unboxed_float -> "Float" - | Unboxed_integer Pint32 -> "Int32" - | Unboxed_integer Pint64 -> "Int64" - | Unboxed_integer Pnativeint -> "Nativeint" - | Untagged_int -> "Int" - | Unboxed_vector Pfloat64x2 -> "Float64x2" - | Unboxed_vector Pint64x2 -> "Int64x2" - -let c_type_of_repr = function - | Same_as_ocaml_repr -> "value" - | Unboxed_float -> "double" - | Unboxed_integer Pint32 -> "int32_t" - | Unboxed_integer Pint64 -> "int64_t" - | Unboxed_integer Pnativeint -> "intnat" - | Untagged_int -> "intnat" - | Unboxed_vector Pfloat64x2 -> "__m128d" - | Unboxed_vector Pint64x2 -> "__m128i" - -type proto = - { params : native_repr list - ; return : native_repr - } - -let rec explode s = - let rec loop i acc = - if i < 0 then - acc - else - loop (i - 1) (s.[i] :: acc) - in - loop (String.length s - 1) [] - -let proto_of_str s = - Scanf.sscanf s "%c_%s" (fun return params -> - { params = List.map (explode params) ~f:repr_of_code - ; return = repr_of_code return - }) - -let function_name_of_proto proto = - Printf.sprintf "test_%s_%s" (code_of_repr proto.return) - (String.concat ~sep:"" (List.map proto.params ~f:code_of_repr)) - -let ocaml_type_gadt_of_proto proto = - Printf.sprintf "%s ** Ret %s" - (String.concat ~sep:" ** " - (List.map proto.params ~f:ocaml_type_gadt_of_repr)) - (ocaml_type_gadt_of_repr proto.return) - -let ocaml_type_of_proto proto = - String.concat ~sep:" -> " - (List.map proto.params ~f:ocaml_type_of_repr - @ [ocaml_type_of_repr proto.return]) - -let c_args_of_proto proto = - String.concat ~sep:", " - (List.mapi proto.params ~f:(fun i p -> - Printf.sprintf "%s x%d" (c_type_of_repr p) i)) - -let manual_protos = List.map manual_tests ~f:proto_of_str - -let iter_protos ~f = - let iter_for_arity arity = - let rec loop params to_gen = - List.iter test_all_args_combination_of ~f:(fun repr -> - let params = repr :: params in - let to_gen = to_gen - 1 in - if to_gen = 0 then - f { params = List.rev params - ; return = Same_as_ocaml_repr - } - else - loop params to_gen) - in - loop [] arity - in - let rec iter_arities arity = - if arity <= test_all_combination_up_to_n_args then begin - iter_for_arity arity; - iter_arities (arity + 1) - end - in - List.iter manual_protos ~f; - iter_arities 1 - -let pr fmt = Printf.ksprintf (fun s -> print_string s; print_char '\n') fmt - -let generate_ml () = - let close, print_test = - let n = 2048 in - let i = ref 0 in - let file = ref None in - let close () = - match !file with - | Some file -> - Printf.fprintf file "\nlet run () = run_tests (List.rev tests)\n%!"; - Out_channel.close file - | None -> () - in - let new_file () = - close (); - let next = open_out (Printf.sprintf "test%d.ml" (!i / n)) in - pr "let () = Test%d.run ()" (!i / n); - file := Some next; - Printf.fprintf next "open Common\n"; - Printf.fprintf next "let tests = []\n\n"; - in - close, fun ext test -> - if !i mod n = 0 then new_file (); - Printf.fprintf (Option.get !file) "%s\n%s\n" ext test; - incr i - in - iter_protos ~f:(fun proto -> - let name = function_name_of_proto proto in - let ext = Format.sprintf "external %s : %s = \"\" %S [@@@@noalloc]" - name (ocaml_type_of_proto proto) name in - let name = function_name_of_proto proto in - let arity = List.length proto.params in - let test = if arity <= 6 then - Format.sprintf "let tests = T%d (%S, %s, %s, %s) :: tests" - arity name name - (List.map proto.params ~f:ocaml_type_gadt_of_repr - |> String.concat ~sep:", ") - (ocaml_type_gadt_of_repr proto.return) - else - Format.sprintf "let tests = T (%S, %s, %s) :: tests" - name name (ocaml_type_gadt_of_proto proto) in - print_test ext test); - close () - -let generate_stubs () = - pr "#include "; - pr "#include "; - pr "#include \"test_common.h\""; - iter_protos ~f:(fun proto -> - let name = function_name_of_proto proto in - pr ""; - pr "%s %s(%s)" - (c_type_of_repr proto.return) - name - (c_args_of_proto proto); - pr "{"; - List.iteri proto.params ~f:(fun i p -> - pr " %(%d%d%);" - (match p with - | Same_as_ocaml_repr -> "set_intnat(%d, Long_val(x%d))" - | Unboxed_float -> "set_double(%d, x%d)" - | Unboxed_integer Pint32 -> "set_int32(%d, x%d)" - | Unboxed_integer Pint64 -> "set_int64(%d, x%d)" - | Unboxed_integer Pnativeint -> "set_intnat(%d, x%d)" - | Untagged_int -> "set_intnat(%d, x%d)" - | Unboxed_vector Pint64x2 -> "set_int128(%d, x%d)" - | Unboxed_vector Pfloat64x2 -> "set_float128(%d, x%d)") - i i); - pr " return %(%d%);" - (match proto.return with - | Same_as_ocaml_repr -> "Val_long(get_intnat(%d))" - | Unboxed_float -> "get_double(%d)" - | Unboxed_integer Pint32 -> "get_int32(%d)" - | Unboxed_integer Pint64 -> "get_int64(%d)" - | Unboxed_integer Pnativeint -> "get_intnat(%d)" - | Untagged_int -> "get_intnat(%d)" - | Unboxed_vector Pint64x2 -> "get_int128(%d)" - | Unboxed_vector Pfloat64x2 -> "get_float128(%d)") - (List.length proto.params); - pr "}" - ) - -let () = - match Sys.argv with - | [|_; "ml"|] -> generate_ml () - | [|_; "c" |] -> generate_stubs () - | _ -> - prerr_endline "Usage: ocaml gen_test.ml {ml|c}"; - exit 2 diff --git a/testsuite/tests/unboxed-primitive-args/test.ml b/testsuite/tests/unboxed-primitive-args/test.ml deleted file mode 100644 index 325c3206bbb..00000000000 --- a/testsuite/tests/unboxed-primitive-args/test.ml +++ /dev/null @@ -1,19 +0,0 @@ -(* TEST - readonly_files = "common.mli common.ml test_common.c test_common.h"; - flambda2; - setup-ocamlopt.opt-build-env; - test_file = "${test_source_directory}/gen_test.ml"; - ocaml_script_as_argument = "true"; - arguments = "c"; - compiler_output = "stubs.c"; - ocaml; - arguments = "ml"; - compiler_output = "main.ml"; - ocaml; - ocamlopt_flags = "-extension simd -cc '${cc} -msse4.2' -ccopt '${cflags}'"; - all_modules = "test_common.c stubs.c common.mli common.ml test0.ml test1.ml main.ml"; - ocamlopt.opt; - run; - check-program-output; -*) -(* We use flambda2 above as a proxy to indicate SIMD is supported *) diff --git a/testsuite/tests/unboxed-primitive-args/test.reference b/testsuite/tests/unboxed-primitive-args/test.reference deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/testsuite/tests/unboxed-primitive-args/test_common.c b/testsuite/tests/unboxed-primitive-args/test_common.c deleted file mode 100644 index 9f453c354ce..00000000000 --- a/testsuite/tests/unboxed-primitive-args/test_common.c +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Jeremie Dimino, Jane Street Europe */ -/* */ -/* Copyright 2015 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#include -#include -#include -#include - -char *ocaml_buffer; -char *c_buffer; - -value test_set_buffers(value v_ocaml_buffer, value v_c_buffer) -{ - ocaml_buffer = Caml_ba_data_val(v_ocaml_buffer); - c_buffer = Caml_ba_data_val(v_c_buffer); - return Val_unit; -} - -value test_cleanup_normal(void) -{ - return Val_int(0); -} - -double test_cleanup_float(void) -{ - return 0.; -} - -int64_t vec128_low_int64(__m128i v) -{ - return _mm_extract_epi64(v, 0); -} - -int64_t vec128_high_int64(__m128i v) -{ - return _mm_extract_epi64(v, 1); -} - -__m128i vec128_of_int64s(int64_t low, int64_t high) -{ - return _mm_set_epi64x(high, low); -} diff --git a/testsuite/tests/unboxed-primitive-args/test_common.h b/testsuite/tests/unboxed-primitive-args/test_common.h deleted file mode 100644 index 93e9a85b680..00000000000 --- a/testsuite/tests/unboxed-primitive-args/test_common.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Jeremie Dimino, Jane Street Europe */ -/* */ -/* Copyright 2015 Institut National de Recherche en Informatique et */ -/* en Automatique. */ -/* */ -/* All rights reserved. This file is distributed under the terms of */ -/* the GNU Lesser General Public License version 2.1, with the */ -/* special exception on linking described in the file LICENSE. */ -/* */ -/**************************************************************************/ - -#ifndef __TEST_COMMON_H -#define __TEST_COMMON_H - -#include - -/* Where the OCaml side stores the arguments and result for a test - case. The C function will read the result it is supposed to return - from this buffer. - - Argument [n] is stored at [n * 8] and the result is stored at - [arity * 8]. -*/ -extern char *ocaml_buffer; - -/* Where the C function stores the arguments it receive for a test - case. The OCaml side will store the result from the C function in - this buffer. At the of a test case, both these buffers must be - equal. */ -extern char *c_buffer; - -#define STRIDE 16 - -#define get_intnat(n) *(intnat*)(ocaml_buffer+((n)*STRIDE)) -#define get_int32(n) *(int32_t*)(ocaml_buffer+((n)*STRIDE)) -#define get_int64(n) *(int64_t*)(ocaml_buffer+((n)*STRIDE)) -#define get_double(n) *(double*)(ocaml_buffer+((n)*STRIDE)) -#define get_int128(n) _mm_loadu_si128((__m128i*)(ocaml_buffer+((n)*STRIDE))) -#define get_float128(n) _mm_loadu_pd((double*)(ocaml_buffer+((n)*STRIDE))) - -#define set_intnat(n, x) *(intnat*)(c_buffer+((n)*STRIDE)) = (x) -#define set_int32(n, x) *(int32_t*)(c_buffer+((n)*STRIDE)) = (x) -#define set_int64(n, x) *(int64_t*)(c_buffer+((n)*STRIDE)) = (x) -#define set_double(n, x) *(double*)(c_buffer+((n)*STRIDE)) = (x) -#define set_int128(n, x) _mm_storeu_si128((__m128i*)(c_buffer+((n)*STRIDE)), (x)) -#define set_float128(n, x) _mm_storeu_pd((double*)(c_buffer+((n)*STRIDE)), (x)) - -#endif /* __TEST_COMMON_H */