Skip to content

Commit 0256599

Browse files
authored
Remove recursive modules in types/ (#292)
1 parent 673e763 commit 0256599

File tree

173 files changed

+8072
-7954
lines changed

Some content is hidden

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

173 files changed

+8072
-7954
lines changed

middle_end/flambda2/algorithms/patricia_tree.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,10 @@ struct
965965
let mapi f t =
966966
fold (fun key datum result -> add key (f key datum) result) t empty
967967

968+
(* CR lmaurer: Implement this one properly even if [map] isn't efficient yet,
969+
since not sharing makes _other things_ (including row-like types) less
970+
efficient. *)
971+
968972
let map_sharing = map
969973

970974
let to_seq t =

middle_end/flambda2/cmx/flambda_cmx.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
[@@@ocaml.warning "+a-4-30-40-41-42"]
1818

19-
module T = Flambda_type
20-
module TE = Flambda_type.Typing_env
19+
module T = Flambda2_types
20+
module TE = Flambda2_types.Typing_env
2121

2222
let rec load_cmx_file_contents ~get_global_info comp_unit ~imported_units
2323
~imported_names ~imported_code =

middle_end/flambda2/cmx/flambda_cmx.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ val load_cmx_file_contents :
2323
get_global_info:
2424
(Flambda2_identifiers.Compilation_unit.t -> Flambda_cmx_format.t option) ->
2525
Compilation_unit.t ->
26-
imported_units:Flambda_type.Typing_env.t option Compilation_unit.Map.t ref ->
26+
imported_units:Flambda2_types.Typing_env.t option Compilation_unit.Map.t ref ->
2727
imported_names:Name.Set.t ref ->
2828
imported_code:Exported_code.t ref ->
29-
Flambda_type.Typing_env.t option
29+
Flambda2_types.Typing_env.t option
3030

3131
val prepare_cmx_file_contents :
32-
final_typing_env:Flambda_type.Typing_env.t option ->
32+
final_typing_env:Flambda2_types.Typing_env.t option ->
3333
module_symbol:Symbol.t ->
3434
used_closure_vars:Var_within_closure.Set.t ->
3535
Exported_code.t ->

middle_end/flambda2/cmx/flambda_cmx_format.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type table_data =
3131

3232
type t0 =
3333
{ original_compilation_unit : Compilation_unit.t;
34-
final_typing_env : Flambda_type.Typing_env.Serializable.t;
34+
final_typing_env : Flambda2_types.Typing_env.Serializable.t;
3535
all_code : Exported_code.t;
3636
exported_offsets : Exported_offsets.t;
3737
used_closure_vars : Var_within_closure.Set.t;
@@ -42,7 +42,7 @@ type t = t0 list
4242

4343
let create ~final_typing_env ~all_code ~exported_offsets ~used_closure_vars =
4444
let typing_env_exported_ids =
45-
Flambda_type.Typing_env.Serializable.all_ids_for_export final_typing_env
45+
Flambda2_types.Typing_env.Serializable.all_ids_for_export final_typing_env
4646
in
4747
let all_code_exported_ids = Exported_code.all_ids_for_export all_code in
4848
let exported_ids =
@@ -127,7 +127,7 @@ let import_typing_env_and_code0 t =
127127
~continuations ~used_closure_vars
128128
in
129129
let typing_env =
130-
Flambda_type.Typing_env.Serializable.apply_renaming t.final_typing_env
130+
Flambda2_types.Typing_env.Serializable.apply_renaming t.final_typing_env
131131
renaming
132132
in
133133
let all_code = Exported_code.apply_renaming code_ids renaming t.all_code in
@@ -142,7 +142,7 @@ let import_typing_env_and_code t =
142142
(fun (typing_env, code) t0 ->
143143
let typing_env0, code0 = import_typing_env_and_code0 t0 in
144144
let typing_env =
145-
Flambda_type.Typing_env.Serializable.merge typing_env typing_env0
145+
Flambda2_types.Typing_env.Serializable.merge typing_env typing_env0
146146
in
147147
let code = Exported_code.merge code code0 in
148148
typing_env, code)
@@ -219,7 +219,7 @@ let print0 ppf t =
219219
Compilation_unit.set_current t.original_compilation_unit;
220220
let typing_env, code = import_typing_env_and_code0 t in
221221
Format.fprintf ppf "@[<hov>Typing env:@ %a@]@;"
222-
Flambda_type.Typing_env.Serializable.print typing_env;
222+
Flambda2_types.Typing_env.Serializable.print typing_env;
223223
Format.fprintf ppf "@[<hov>Code:@ %a@]@;" Exported_code.print code;
224224
Format.fprintf ppf "@[<hov>Offsets:@ %a@]@;" Exported_offsets.print
225225
t.exported_offsets

middle_end/flambda2/cmx/flambda_cmx_format.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
type t
2222

2323
val create :
24-
final_typing_env:Flambda_type.Typing_env.Serializable.t ->
24+
final_typing_env:Flambda2_types.Typing_env.Serializable.t ->
2525
all_code:Exported_code.t ->
2626
exported_offsets:Exported_offsets.t ->
2727
used_closure_vars:Var_within_closure.Set.t ->
2828
t
2929

3030
val import_typing_env_and_code :
31-
t -> Flambda_type.Typing_env.Serializable.t * Exported_code.t
31+
t -> Flambda2_types.Typing_env.Serializable.t * Exported_code.t
3232

3333
val exported_offsets : t -> Exported_offsets.t
3434

middle_end/flambda2/identifiers/reg_width_things.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ module Simple = struct
697697
end
698698

699699
let with_coercion t new_coercion =
700-
if Coercion.is_id new_coercion
700+
if Coercion.is_id new_coercion || Id.flags t = const_flags
701701
then t
702702
else if Coercion.is_id (coercion t)
703703
then

middle_end/flambda2/lattices/or_bottom.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ let all ts =
4444
if List.compare_lengths ts contents <> 0 then Bottom else Ok contents
4545

4646
let bind t ~f = match t with Bottom -> Bottom | Ok contents -> f contents
47+
48+
module Let_syntax = struct
49+
let ( let<* ) x f = bind x ~f
50+
51+
let ( let<+ ) x f = map x ~f
52+
end

middle_end/flambda2/lattices/or_bottom.mli

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ val value_map : 'a t -> bottom:'b -> f:('a -> 'b) -> 'b
3131
val all : 'a t list -> 'a list t
3232

3333
val bind : 'a t -> f:('a -> 'b t) -> 'b t
34+
35+
module Let_syntax : sig
36+
val ( let<* ) : 'a t -> ('a -> 'b t) -> 'b t
37+
38+
val ( let<+ ) : 'a t -> ('a -> 'b) -> 'b t
39+
end

middle_end/flambda2/lattices/or_unknown.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ let equal equal_contents t1 t2 =
4444
| Known contents1, Known contents2 -> equal_contents contents1 contents2
4545
| Unknown, Known _ | Known _, Unknown -> false
4646

47+
let bind t ~f = match t with Known contents -> f contents | Unknown -> Unknown
48+
4749
let map t ~f =
4850
match t with Known contents -> Known (f contents) | Unknown -> Unknown
4951

@@ -90,3 +92,9 @@ module Lift (I : Container_types.S) = struct
9092
let output _ _ = Misc.fatal_error "Not yet implemented"
9193
end)
9294
end
95+
96+
module Let_syntax = struct
97+
let ( let>* ) x f = bind x ~f
98+
99+
let ( let>+ ) x f = map x ~f
100+
end

middle_end/flambda2/lattices/or_unknown.mli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
2626

2727
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
2828

29+
val bind : 'a t -> f:('a -> 'b t) -> 'b t
30+
2931
val map : 'a t -> f:('a -> 'b) -> 'b t
3032

3133
val map_sharing : 'a t -> f:('a -> 'a) -> 'a t
@@ -41,3 +43,9 @@ module Lift (I : Container_types.S) : sig
4143

4244
include Container_types.S with type t := t
4345
end
46+
47+
module Let_syntax : sig
48+
val ( let>* ) : 'a t -> ('a -> 'b t) -> 'b t
49+
50+
val ( let>+ ) : 'a t -> ('a -> 'b) -> 'b t
51+
end

middle_end/flambda2/lattices/or_unknown_or_bottom.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ let equal eq_contents t1 t2 =
3434
| Bottom, Bottom -> true
3535
| (Unknown | Ok _ | Bottom), _ -> false
3636

37+
let bind t ~f =
38+
match t with
39+
| Unknown -> Unknown
40+
| Bottom -> Bottom
41+
| Ok contents -> f contents
42+
3743
let map t ~f =
3844
match t with
3945
| Unknown -> Unknown
@@ -49,3 +55,9 @@ let map_sharing t ~f =
4955

5056
let of_or_unknown (unk : _ Or_unknown.t) : _ t =
5157
match unk with Known contents -> Ok contents | Unknown -> Unknown
58+
59+
module Let_syntax = struct
60+
let ( let<>* ) x f = bind x ~f
61+
62+
let ( let<>+ ) x f = map x ~f
63+
end

middle_end/flambda2/lattices/or_unknown_or_bottom.mli

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ val print : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit
2525

2626
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
2727

28+
val bind : 'a t -> f:('a -> 'b t) -> 'b t
29+
2830
val map : 'a t -> f:('a -> 'b) -> 'b t
2931

3032
val map_sharing : 'a t -> f:('a -> 'a) -> 'a t
3133

3234
val of_or_unknown : 'a Or_unknown.t -> 'a t
35+
36+
module Let_syntax : sig
37+
val ( let<>* ) : 'a t -> ('a -> 'b t) -> 'b t
38+
39+
val ( let<>+ ) : 'a t -> ('a -> 'b) -> 'b t
40+
end

middle_end/flambda2/nominal/with_delayed_permutation.ml

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

middle_end/flambda2/nominal/with_delayed_permutation.mli

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

middle_end/flambda2/simplify/common_subexpression_elimination.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ module BP = Bound_parameter
2525
module NM = Name_mode
2626
module P = Flambda_primitive
2727
module RI = Apply_cont_rewrite_id
28-
module T = Flambda_type
29-
module TE = Flambda_type.Typing_env
28+
module T = Flambda2_types
29+
module TE = Flambda2_types.Typing_env
3030
module List = ListLabels
3131

3232
type t =
@@ -188,12 +188,12 @@ let cse_with_eligible_lhs ~typing_env_at_fork ~cse_at_each_use ~params prev_cse
188188
let aliases =
189189
TE.aliases_of_simple env_at_use ~min_name_mode:NM.normal
190190
bound_to
191-
|> Aliases.Alias_set.filter ~f:(fun simple ->
191+
|> TE.Alias_set.filter ~f:(fun simple ->
192192
not (is_param simple))
193193
in
194194
(* CR lmaurer: Do we need to make sure there's only one alias?
195195
If not, we can use [Aliases.Alias_set.find_best] here. *)
196-
Aliases.Alias_set.get_singleton aliases
196+
TE.Alias_set.get_singleton aliases
197197
in
198198
match bound_to with
199199
| None -> eligible

middle_end/flambda2/simplify/common_subexpression_elimination.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ module EPA = Continuation_extra_params_and_args
2323
module BP = Bound_parameter
2424
module P = Flambda_primitive
2525
module RI = Apply_cont_rewrite_id
26-
module T = Flambda_type
27-
module TE = Flambda_type.Typing_env
26+
module T = Flambda2_types
27+
module TE = Flambda2_types.Typing_env
2828

2929
type t
3030

middle_end/flambda2/simplify/env/continuation_env_and_param_types.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
[@@@ocaml.warning "+a-4-30-40-41-42"]
1818

19-
module T = Flambda_type
20-
module TE = Flambda_type.Typing_env
19+
module T = Flambda2_types
20+
module TE = Flambda2_types.Typing_env
2121

2222
type arg_at_use =
2323
{ arg_type : T.t;

middle_end/flambda2/simplify/env/continuation_env_and_param_types.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
[@@@ocaml.warning "+a-4-30-40-41-42"]
1818

1919
type arg_at_use =
20-
{ arg_type : Flambda_type.t;
21-
typing_env : Flambda_type.Typing_env.t
20+
{ arg_type : Flambda2_types.t;
21+
typing_env : Flambda2_types.Typing_env.t
2222
}
2323

2424
type t =

middle_end/flambda2/simplify/env/continuation_uses.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
[@@@ocaml.warning "+a-30-40-41-42"]
1818

1919
module DE = Downwards_env
20-
module T = Flambda_type
20+
module T = Flambda2_types
2121
module U = One_continuation_use
2222

2323
type t =

0 commit comments

Comments
 (0)