diff --git a/ocaml/testsuite/tests/typing-layouts-float64/alloc.ml b/ocaml/testsuite/tests/typing-layouts-float64/alloc.ml index eba22c61adb..816db8b5ddb 100644 --- a/ocaml/testsuite/tests/typing-layouts-float64/alloc.ml +++ b/ocaml/testsuite/tests/typing-layouts-float64/alloc.ml @@ -6,30 +6,15 @@ (* A test comparing allocations with unboxed floats to allocations with boxed floats. *) -(* CR layouts v2: Delete this `Float_u` module and use the one we add to the - standard library instead. *) -module type Float_u = sig - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - val ( + ) : float# -> float# -> float# - val ( - ) : float# -> float# -> float# - val ( * ) : float# -> float# -> float# - val ( / ) : float# -> float# -> float# - val ( ** ) : float# -> float# -> float# - val ( > ) : float# -> float# -> bool -end - -module Float_u : Float_u = struct - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - let ( + ) x y = of_float ((to_float x) +. (to_float y)) - let ( - ) x y = of_float ((to_float x) -. (to_float y)) - let ( * ) x y = of_float ((to_float x) *. (to_float y)) - let ( / ) x y = of_float ((to_float x) /. (to_float y)) - let ( ** ) x y = of_float ((to_float x) ** (to_float y)) - let ( > ) x y = (to_float x) > (to_float y) +module Float_u = struct + include Stdlib__Float_u + + let ( + ) = add + let ( - ) = sub + let ( * ) = mul + let ( / ) = div + let ( ** ) = pow + let ( > ) x y = (compare x y) > 0 end let alloc = ref 0.0 diff --git a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.compilers.reference b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.compilers.reference index bdd5cc8d3fe..c89d2a2a147 100644 --- a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.compilers.reference +++ b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.compilers.reference @@ -1,4 +1,4 @@ -File "unboxed_floats.ml", line 21, characters 22-28: -21 | external to_float : float# -> (float[@local_opt]) = "%box_float" - ^^^^^^ -Error: This construct requires the alpha version of the extension "layouts", which is disabled and cannot be used +File "unboxed_floats.ml", line 74, characters 11-18: +74 | type ('a : float64) t_float64 = 'a + ^^^^^^^ +Error: Layout float64 is used here, but the appropriate layouts extension is not enabled diff --git a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.ml b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.ml index fde0cc869ca..e715f44f62b 100644 --- a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.ml +++ b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats.ml @@ -17,35 +17,17 @@ (*****************************************) (* Prelude: Functions on unboxed floats. *) -module type Float_u = sig - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - val ( + ) : float# -> float# -> float# - val ( - ) : float# -> float# -> float# - val ( * ) : float# -> float# -> float# - val ( / ) : float# -> float# -> float# - val ( ** ) : float# -> float# -> float# - val ( > ) : float# -> float# -> bool +module Float_u = struct + include Stdlib__Float_u + + let ( + ) = add + let ( - ) = sub + let ( * ) = mul + let ( / ) = div + let ( ** ) = pow + let ( > ) x y = (compare x y) > 0 end -module Float_u : Float_u = struct - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - (* We may in the future add primitives for these, but for now this has proven - to be good enough - the boxing/unboxing is eliminated on all - middle-ends. *) - let[@inline always] ( + ) x y = of_float ((to_float x) +. (to_float y)) - let[@inline always] ( - ) x y = of_float ((to_float x) -. (to_float y)) - let[@inline always] ( * ) x y = of_float ((to_float x) *. (to_float y)) - let[@inline always] ( / ) x y = of_float ((to_float x) /. (to_float y)) - let[@inline always] ( ** ) x y = of_float ((to_float x) ** (to_float y)) - let[@inline always] ( > ) x y = (to_float x) > (to_float y) -end - -(* CR layouts v2: move this into a stand-alone [Float_u] module *) - (*********************************) (* Test 1: some basic arithmetic *) diff --git a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_alpha.ml b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_alpha.ml index 6f1a5a6d1f9..bde12e86733 100644 --- a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_alpha.ml +++ b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_alpha.ml @@ -11,35 +11,17 @@ (*****************************************) (* Prelude: Functions on unboxed floats. *) -module type Float_u = sig - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - val ( + ) : float# -> float# -> float# - val ( - ) : float# -> float# -> float# - val ( * ) : float# -> float# -> float# - val ( / ) : float# -> float# -> float# - val ( ** ) : float# -> float# -> float# - val ( > ) : float# -> float# -> bool +module Float_u = struct + include Stdlib__Float_u + + let ( + ) = add + let ( - ) = sub + let ( * ) = mul + let ( / ) = div + let ( ** ) = pow + let ( > ) x y = (compare x y) > 0 end -module Float_u : Float_u = struct - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - (* We may in the future add primitives for these, but for now this has proven - to be good enough - the boxing/unboxing is eliminated on all - middle-ends. *) - let[@inline always] ( + ) x y = of_float ((to_float x) +. (to_float y)) - let[@inline always] ( - ) x y = of_float ((to_float x) -. (to_float y)) - let[@inline always] ( * ) x y = of_float ((to_float x) *. (to_float y)) - let[@inline always] ( / ) x y = of_float ((to_float x) /. (to_float y)) - let[@inline always] ( ** ) x y = of_float ((to_float x) ** (to_float y)) - let[@inline always] ( > ) x y = (to_float x) > (to_float y) -end - -(* CR layouts v2: move this into a stand-alone [Float_u] module *) - (*********************************) (* Test 1: some basic arithmetic *) diff --git a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.compilers.reference b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.compilers.reference index 6c4a93e135e..003bda1cb3b 100644 --- a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.compilers.reference +++ b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.compilers.reference @@ -1,4 +1,4 @@ -File "unboxed_floats_beta.ml", line 21, characters 22-28: -21 | external to_float : float# -> (float[@local_opt]) = "%box_float" - ^^^^^^ -Error: This construct requires the alpha version of the extension "layouts", which is disabled and cannot be used +File "unboxed_floats_beta.ml", line 74, characters 11-18: +74 | type ('a : float64) t_float64 = 'a + ^^^^^^^ +Error: Layout float64 is used here, but the appropriate layouts extension is not enabled diff --git a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.ml b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.ml index 0032d72389f..490523454a7 100644 --- a/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.ml +++ b/ocaml/testsuite/tests/typing-layouts-float64/unboxed_floats_beta.ml @@ -17,35 +17,17 @@ (*****************************************) (* Prelude: Functions on unboxed floats. *) -module type Float_u = sig - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - val ( + ) : float# -> float# -> float# - val ( - ) : float# -> float# -> float# - val ( * ) : float# -> float# -> float# - val ( / ) : float# -> float# -> float# - val ( ** ) : float# -> float# -> float# - val ( > ) : float# -> float# -> bool +module Float_u = struct + include Stdlib__Float_u + + let ( + ) = add + let ( - ) = sub + let ( * ) = mul + let ( / ) = div + let ( ** ) = pow + let ( > ) x y = (compare x y) > 0 end -module Float_u : Float_u = struct - external to_float : float# -> (float[@local_opt]) = "%box_float" - external of_float : (float[@local_opt]) -> float# = "%unbox_float" - - (* We may in the future add primitives for these, but for now this has proven - to be good enough - the boxing/unboxing is eliminated on all - middle-ends. *) - let[@inline always] ( + ) x y = of_float ((to_float x) +. (to_float y)) - let[@inline always] ( - ) x y = of_float ((to_float x) -. (to_float y)) - let[@inline always] ( * ) x y = of_float ((to_float x) *. (to_float y)) - let[@inline always] ( / ) x y = of_float ((to_float x) /. (to_float y)) - let[@inline always] ( ** ) x y = of_float ((to_float x) ** (to_float y)) - let[@inline always] ( > ) x y = (to_float x) > (to_float y) -end - -(* CR layouts v2: move this into a stand-alone [Float_u] module *) - (*********************************) (* Test 1: some basic arithmetic *)