Skip to content

Commit fc8e778

Browse files
flambda-backend: Move unboxed definitions from Stdlib to Stable (#2555)
* Fix `include` in expect tests * Add unboxed types to `Stable` * Add `Nativeint_u` to `Stable` * Remove `Float_u` from `Stdlib` * Remove unboxed ints from `Stdlib` * Clean up build rules * Fix mixed blocks tests * Fix parsetree tests * Fix typing-layouts tests * Fix typing-layouts-arrays tests * Fix typing-layouts-bits32 tests * Fix typing-layouts-bits64 tests * Fix typing-layouts-float64 tests * Fix typing-layouts-word tests * Fix build * Use `include` in expect tests * Define separate modules instead of opening Stable * Rename test files * Fix mixed blocks tests * Fix layouts tests --------- Co-authored-by: Diana Kalinichenko <[email protected]>
1 parent 97cf656 commit fc8e778

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1467
-1543
lines changed

Makefile.common-jst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ dune_config_targets = \
113113
$(ocamldir)/duneconf/dirs-to-ignore.inc \
114114
$(ocamldir)/duneconf/jst-extra.inc \
115115
dune-project \
116-
$(ocamldir)/stdlib/ocaml_compiler_internal_params \
117116
$(ocamldir)/dune.runtime_selection \
118117
$(ocamldir)/otherlibs/dune
119118

@@ -200,12 +199,6 @@ _install: compiler
200199
install: _install
201200
mkdir -p '$(prefix)'
202201
rsync --chmod=u+rw,go+r -rl _install/ '$(prefix)'
203-
rm -f '$(prefix)/lib/ocaml/ocaml_compiler_internal_params'
204-
# rm `ocaml_compiler_internal_params`, which is used to compile the
205-
# stdlib `Float_u` module with `-extension layouts_alpha`, because we
206-
# don't want user programs that happened to be named
207-
# `ocaml/stdlib/float_u.ml` to get the flag automatically.
208-
209202

210203
# Same as above, but relies on a successfull earlier _install
211204
install_for_opam:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

stdlib/int64_u.ml renamed to otherlibs/stable/int64_u.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ let[@inline always] of_nativeint x = of_int64 (Int64.of_nativeint x)
8484

8585
let[@inline always] to_nativeint x = Int64.to_nativeint (to_int64 x)
8686

87-
let[@inline always] of_int32_u x = of_int64 (Int64.of_int32 (Stdlib__Int32_u.to_int32 x))
87+
let[@inline always] of_int32_u x = of_int64 (Int64.of_int32 (Int32_u.to_int32 x))
8888

89-
let[@inline always] to_int32_u x = Stdlib__Int32_u.of_int32 (Int64.to_int32 (to_int64 x))
89+
let[@inline always] to_int32_u x = Int32_u.of_int32 (Int64.to_int32 (to_int64 x))
9090

9191
let[@inline always] of_nativeint_u x =
92-
of_int64 (Int64.of_nativeint (Stdlib__Nativeint_u.to_nativeint x))
92+
of_int64 (Int64.of_nativeint (Nativeint_u.to_nativeint x))
9393

9494
let[@inline always] to_nativeint_u x =
95-
Stdlib__Nativeint_u.of_nativeint (Int64.to_nativeint (to_int64 x))
95+
Nativeint_u.of_nativeint (Int64.to_nativeint (to_int64 x))
9696

9797
let[@inline always] bits_of_float x = of_int64 (Int64.bits_of_float x)
9898

File renamed without changes.

stdlib/nativeint_u.ml renamed to otherlibs/stable/nativeint_u.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ let[@inline always] of_int32 x = of_nativeint (Nativeint.of_int32 x)
9797
let[@inline always] to_int32 x = Nativeint.to_int32 (to_nativeint x)
9898

9999
let[@inline always] of_int32_u x =
100-
of_nativeint (Nativeint.of_int32 (Stdlib__Int32_u.to_int32 x))
100+
of_nativeint (Nativeint.of_int32 (Int32_u.to_int32 x))
101101

102102
let[@inline always] to_int32_u x =
103-
Stdlib__Int32_u.of_int32 (Nativeint.to_int32 (to_nativeint x))
103+
Int32_u.of_int32 (Nativeint.to_int32 (to_nativeint x))
104104

105105
let[@inline always] of_string x = of_nativeint (Nativeint.of_string x)
106106

File renamed without changes.

otherlibs/stable/stable.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
module Float_u = Stdlib__Float_u
1+
module Float_u = Float_u
2+
module Int32_u = Int32_u
3+
module Int64_u = Int64_u
4+
module Nativeint_u = Nativeint_u
25
module Iarray = Stdlib__Iarray
36
module IarrayLabels = Stdlib__IarrayLabels

otherlibs/stable/stable.mli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
module Float_u = Stdlib__Float_u
1+
module Float_u = Float_u
2+
module Int32_u = Int32_u
3+
module Int64_u = Int64_u
4+
module Nativeint_u = Nativeint_u
25
module Iarray = Stdlib__Iarray
36
module IarrayLabels = Stdlib__IarrayLabels

stdlib/.depend

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -358,16 +358,6 @@ stdlib__Float.cmx : float.ml \
358358
stdlib__Float.cmi : float.mli \
359359
stdlib.cmi \
360360
stdlib__Seq.cmi
361-
stdlib__Float_u.cmo : float_u.ml \
362-
stdlib.cmi \
363-
stdlib__Float.cmi \
364-
stdlib__Float_u.cmi
365-
stdlib__Float_u.cmx : float_u.ml \
366-
stdlib.cmx \
367-
stdlib__Float.cmx \
368-
stdlib__Float_u.cmi
369-
stdlib__Float_u.cmi : float_u.mli \
370-
stdlib.cmi
371361
stdlib__Format.cmo : format.ml \
372362
stdlib__String.cmi \
373363
stdlib.cmi \
@@ -522,16 +512,6 @@ stdlib__Int32.cmx : int32.ml \
522512
stdlib__Int32.cmi
523513
stdlib__Int32.cmi : int32.mli \
524514
stdlib.cmi
525-
stdlib__Int32_u.cmo : int32_u.ml \
526-
stdlib.cmi \
527-
stdlib__Int32.cmi \
528-
stdlib__Int32_u.cmi
529-
stdlib__Int32_u.cmx : int32_u.ml \
530-
stdlib.cmx \
531-
stdlib__Int32.cmx \
532-
stdlib__Int32_u.cmi
533-
stdlib__Int32_u.cmi : int32_u.mli \
534-
stdlib.cmi
535515
stdlib__Int64.cmo : int64.ml \
536516
stdlib.cmi \
537517
stdlib__Int64.cmi
@@ -540,20 +520,6 @@ stdlib__Int64.cmx : int64.ml \
540520
stdlib__Int64.cmi
541521
stdlib__Int64.cmi : int64.mli \
542522
stdlib.cmi
543-
stdlib__Int64_u.cmo : int64_u.ml \
544-
stdlib__Nativeint_u.cmi \
545-
stdlib__Int32_u.cmi \
546-
stdlib.cmi \
547-
stdlib__Int64.cmi \
548-
stdlib__Int64_u.cmi
549-
stdlib__Int64_u.cmx : int64_u.ml \
550-
stdlib__Nativeint_u.cmx \
551-
stdlib__Int32_u.cmx \
552-
stdlib.cmx \
553-
stdlib__Int64.cmx \
554-
stdlib__Int64_u.cmi
555-
stdlib__Int64_u.cmi : int64_u.mli \
556-
stdlib.cmi
557523
stdlib__Lazy.cmo : lazy.ml \
558524
stdlib.cmi \
559525
stdlib__Obj.cmi \
@@ -669,18 +635,6 @@ stdlib__Nativeint.cmx : nativeint.ml \
669635
stdlib__Nativeint.cmi
670636
stdlib__Nativeint.cmi : nativeint.mli \
671637
stdlib.cmi
672-
stdlib__Nativeint_u.cmo : nativeint_u.ml \
673-
stdlib__Int32_u.cmi \
674-
stdlib.cmi \
675-
stdlib__Nativeint.cmi \
676-
stdlib__Nativeint_u.cmi
677-
stdlib__Nativeint_u.cmx : nativeint_u.ml \
678-
stdlib__Int32_u.cmx \
679-
stdlib.cmx \
680-
stdlib__Nativeint.cmx \
681-
stdlib__Nativeint_u.cmi
682-
stdlib__Nativeint_u.cmi : nativeint_u.mli \
683-
stdlib.cmi
684638
stdlib__Obj.cmo : obj.ml \
685639
stdlib__Sys.cmi \
686640
stdlib.cmi \

stdlib/Makefile

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -207,30 +207,6 @@ stdlib.cmx: stdlib.ml
207207
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) \
208208
-pp "$(AWK) -f ./expand_module_aliases.awk" -c $<
209209

210-
211-
# special cases to add the extension flag when compiling float_u etc.
212-
# CR layouts: eventually these can be just [-extension layouts]
213-
stdlib__%_u.cmi:
214-
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha \
215-
-o $@ -c $(filter %.mli, $^)
216-
217-
stdlib__%_u.cmo:
218-
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha \
219-
-o $@ -c $(filter %.ml, $^)
220-
221-
stdlib__%_u.cmx:
222-
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) -extension layouts_alpha \
223-
-o $@ -c $(filter %.ml, $^)
224-
225-
%_u.cmi: %_u.mli
226-
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha -c $<
227-
228-
%_u.cmo: %_u.ml
229-
$(CAMLC) $(COMPFLAGS) -extension layouts_alpha -c $<
230-
231-
%_u.cmx: %_u.ml
232-
$(CAMLOPT) $(COMPFLAGS) $(OPTCOMPFLAGS) -extension layouts_alpha -c $<
233-
234210
%.cmi: %.mli
235211
$(V_OCAMLC)$(CAMLC) $(COMPFLAGS) -c $<
236212

stdlib/StdlibModules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,9 @@ STDLIB_MODULE_BASENAMES = \
5959
array \
6060
iarray \
6161
float \
62-
float_u \
6362
int32 \
64-
int32_u \
6563
nativeint \
66-
nativeint_u \
6764
int64 \
68-
int64_u \
6965
lexing \
7066
parsing \
7167
set \

stdlib/dune

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
(install
5858
(files
5959
Makefile.config
60-
ocaml_compiler_internal_params
6160
camlheader
6261
camlheaderd
6362
camlheaderi
@@ -122,8 +121,6 @@
122121
filename.mli
123122
float.ml
124123
float.mli
125-
float_u.ml
126-
float_u.mli
127124
format.ml
128125
format.mli
129126
fun.ml
@@ -142,12 +139,8 @@
142139
int.mli
143140
int32.ml
144141
int32.mli
145-
int32_u.ml
146-
int32_u.mli
147142
int64.ml
148143
int64.mli
149-
int64_u.ml
150-
int64_u.mli
151144
lazy.ml
152145
lazy.mli
153146
lexing.ml
@@ -166,8 +159,6 @@
166159
mutex.mli
167160
nativeint.ml
168161
nativeint.mli
169-
nativeint_u.ml
170-
nativeint_u.mli
171162
obj.ml
172163
obj.mli
173164
oo.ml
@@ -277,9 +268,6 @@
277268
.stdlib.objs/byte/stdlib__Float.cmi
278269
.stdlib.objs/byte/stdlib__Float.cmt
279270
.stdlib.objs/byte/stdlib__Float.cmti
280-
.stdlib.objs/byte/stdlib__Float_u.cmi
281-
.stdlib.objs/byte/stdlib__Float_u.cmt
282-
.stdlib.objs/byte/stdlib__Float_u.cmti
283271
.stdlib.objs/byte/stdlib__Format.cmi
284272
.stdlib.objs/byte/stdlib__Format.cmt
285273
.stdlib.objs/byte/stdlib__Format.cmti
@@ -307,15 +295,9 @@
307295
.stdlib.objs/byte/stdlib__Int32.cmi
308296
.stdlib.objs/byte/stdlib__Int32.cmt
309297
.stdlib.objs/byte/stdlib__Int32.cmti
310-
.stdlib.objs/byte/stdlib__Int32_u.cmi
311-
.stdlib.objs/byte/stdlib__Int32_u.cmt
312-
.stdlib.objs/byte/stdlib__Int32_u.cmti
313298
.stdlib.objs/byte/stdlib__Int64.cmi
314299
.stdlib.objs/byte/stdlib__Int64.cmt
315300
.stdlib.objs/byte/stdlib__Int64.cmti
316-
.stdlib.objs/byte/stdlib__Int64_u.cmi
317-
.stdlib.objs/byte/stdlib__Int64_u.cmt
318-
.stdlib.objs/byte/stdlib__Int64_u.cmti
319301
.stdlib.objs/byte/stdlib__Lazy.cmi
320302
.stdlib.objs/byte/stdlib__Lazy.cmt
321303
.stdlib.objs/byte/stdlib__Lazy.cmti
@@ -343,9 +325,6 @@
343325
.stdlib.objs/byte/stdlib__Nativeint.cmi
344326
.stdlib.objs/byte/stdlib__Nativeint.cmt
345327
.stdlib.objs/byte/stdlib__Nativeint.cmti
346-
.stdlib.objs/byte/stdlib__Nativeint_u.cmi
347-
.stdlib.objs/byte/stdlib__Nativeint_u.cmt
348-
.stdlib.objs/byte/stdlib__Nativeint_u.cmti
349328
.stdlib.objs/byte/stdlib__Obj.cmi
350329
.stdlib.objs/byte/stdlib__Obj.cmt
351330
.stdlib.objs/byte/stdlib__Obj.cmti
@@ -456,12 +435,10 @@
456435
.stdlib.objs/native/stdlib__StdLabels.cmx
457436
.stdlib.objs/native/stdlib__Weak.cmx
458437
.stdlib.objs/native/stdlib__Float.cmx
459-
.stdlib.objs/native/stdlib__Float_u.cmx
460438
.stdlib.objs/native/stdlib__Fun.cmx
461439
.stdlib.objs/native/stdlib__Bigarray.cmx
462440
.stdlib.objs/native/stdlib__Array.cmx
463441
.stdlib.objs/native/stdlib__Int32.cmx
464-
.stdlib.objs/native/stdlib__Int32_u.cmx
465442
.stdlib.objs/native/stdlib__Lexing.cmx
466443
.stdlib.objs/native/stdlib__ArrayLabels.cmx
467444
.stdlib.objs/native/stdlib__Obj.cmx
@@ -482,7 +459,6 @@
482459
.stdlib.objs/native/stdlib__Ephemeron.cmx
483460
.stdlib.objs/native/stdlib__String.cmx
484461
.stdlib.objs/native/stdlib__Nativeint.cmx
485-
.stdlib.objs/native/stdlib__Nativeint_u.cmx
486462
.stdlib.objs/native/stdlib__Set.cmx
487463
.stdlib.objs/native/stdlib__ListLabels.cmx
488464
.stdlib.objs/native/stdlib__Bool.cmx
@@ -491,7 +467,6 @@
491467
.stdlib.objs/native/stdlib__Random.cmx
492468
.stdlib.objs/native/stdlib__Int.cmx
493469
.stdlib.objs/native/stdlib__Int64.cmx
494-
.stdlib.objs/native/stdlib__Int64_u.cmx
495470
.stdlib.objs/native/stdlib__Scanf.cmx
496471
.stdlib.objs/native/stdlib__Printf.cmx
497472
.stdlib.objs/native/stdlib__Complex.cmx

stdlib/ocaml_compiler_internal_params

Lines changed: 0 additions & 10 deletions
This file was deleted.

testsuite/tests/mixed-blocks/constructor_args.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
flags = "-extension layouts_beta -extension small_numbers";
33
include beta;
44
flambda2;
5+
include stable;
56
{
67
native;
78
}{
@@ -13,10 +14,10 @@
1314
(* Prelude: Functions on unboxed numbers *)
1415

1516
module Float32_u = Beta.Float32_u
16-
module Float_u = Stdlib__Float_u
17-
module Int32_u = Stdlib__Int32_u
18-
module Int64_u = Stdlib__Int64_u
19-
module Nativeint_u = Stdlib__Nativeint_u
17+
module Float_u = Stable.Float_u
18+
module Int32_u = Stable.Int32_u
19+
module Int64_u = Stable.Int64_u
20+
module Nativeint_u = Stable.Nativeint_u
2021

2122
let print_floatu prefix x = Printf.printf "%s: %.2f\n" prefix (Float_u.to_float x)
2223
let print_float prefix x = Printf.printf "%s: %.2f\n" prefix x

testsuite/tests/mixed-blocks/generate_mixed_blocks_code.ml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,11 @@ let type_to_field_integrity_check type_ ~access1 ~access2 ~message =
233233
| Str -> "check_string", None
234234
| Imm -> "check_int", None
235235
| Float -> "check_float", None
236-
| Float64 -> "check_float", Some "Stdlib__Float_u.to_float"
236+
| Float64 -> "check_float", Some "Stable.Float_u.to_float"
237237
| Float32 -> "check_float32", Some "Beta.Float32_u.to_float32"
238-
| Bits32 -> "check_int32", Some "Stdlib__Int32_u.to_int32"
239-
| Bits64 -> "check_int64", Some "Stdlib__Int64_u.to_int64"
240-
| Word -> "check_int", Some "Stdlib__Nativeint_u.to_int"
238+
| Bits32 -> "check_int32", Some "Stable.Int32_u.to_int32"
239+
| Bits64 -> "check_int64", Some "Stable.Int64_u.to_int64"
240+
| Word -> "check_int", Some "Stable.Nativeint_u.to_int"
241241
in
242242
let transform access =
243243
match transformation with
@@ -566,7 +566,8 @@ let main n ~bytecode =
566566
in
567567
line {|(* TEST
568568
flags = "-extension layouts_beta -extension small_numbers";
569-
include beta;|};
569+
include beta;
570+
include stable;|};
570571
if bytecode then (
571572
line {| bytecode;|};
572573
) else (
@@ -581,11 +582,11 @@ let main n ~bytecode =
581582
line {|let create_int () = Random.int 0x3FFF_FFFF|};
582583
line {|let create_float () = Random.float Float.max_float|};
583584
line {|let create_float32 () = Beta.Float32.of_float (Random.float Float.max_float)|};
584-
line {|let create_float_u () = Stdlib__Float_u.of_float (create_float ())|};
585+
line {|let create_float_u () = Stable.Float_u.of_float (create_float ())|};
585586
line {|let create_float32_u () = Beta.Float32_u.of_float32 (create_float32 ())|};
586-
line {|let create_int32_u () = Stdlib__Int32_u.of_int32 (Random.int32 0x7FFF_FFFFl)|};
587-
line {|let create_int64_u () = Stdlib__Int64_u.of_int64 (Random.int64 0x7FFF_FFFF_FFFF_FFFFL)|};
588-
line {|let create_nativeint_u () = Stdlib__Nativeint_u.of_nativeint (Random.nativeint 0x7FFF_FFFF_FFFF_FFFFn)|};
587+
line {|let create_int32_u () = Stable.Int32_u.of_int32 (Random.int32 0x7FFF_FFFFl)|};
588+
line {|let create_int64_u () = Stable.Int64_u.of_int64 (Random.int64 0x7FFF_FFFF_FFFF_FFFFL)|};
589+
line {|let create_nativeint_u () = Stable.Nativeint_u.of_nativeint (Random.nativeint 0x7FFF_FFFF_FFFF_FFFFn)|};
589590
line
590591
{|let check_gen ~equal ~to_string ~message y1 y2 =
591592
if equal y1 y2 then () else

0 commit comments

Comments
 (0)