Skip to content

Commit 0210bff

Browse files
committed
make fmt
1 parent 2626d9f commit 0210bff

File tree

10 files changed

+228
-135
lines changed

10 files changed

+228
-135
lines changed

middle_end/flambda2/compare/compare.ml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,16 +631,26 @@ let unary_prim_ops env (prim_op1 : Flambda_primitive.unary_primitive)
631631
Flambda_primitive.Project_function_slot
632632
{ move_from = move_from1'; move_to = move_to1' })
633633
| ( Project_value_slot
634-
{ project_from = function_slot1; value_slot = value_slot1; kind = kind1 },
634+
{ project_from = function_slot1;
635+
value_slot = value_slot1;
636+
kind = kind1
637+
},
635638
Project_value_slot
636-
{ project_from = function_slot2; value_slot = value_slot2; kind = kind2 } ) ->
637-
triples ~f1:function_slots ~f2:value_slots ~f3:(Comparator.of_predicate Flambda_kind.With_subkind.equal)
639+
{ project_from = function_slot2;
640+
value_slot = value_slot2;
641+
kind = kind2
642+
} ) ->
643+
triples ~f1:function_slots ~f2:value_slots
644+
~f3:(Comparator.of_predicate Flambda_kind.With_subkind.equal)
638645
env
639646
(function_slot1, value_slot1, kind1)
640647
(function_slot2, value_slot2, kind2)
641648
|> Comparison.map ~f:(fun (function_slot1', value_slot1', kind1') ->
642649
Flambda_primitive.Project_value_slot
643-
{ project_from = function_slot1'; value_slot = value_slot1'; kind = kind1' })
650+
{ project_from = function_slot1';
651+
value_slot = value_slot1';
652+
kind = kind1'
653+
})
644654
| _, _ ->
645655
if Flambda_primitive.equal_unary_primitive prim_op1 prim_op2
646656
then Equivalent

middle_end/flambda2/from_lambda/closure_conversion.ml

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ let declare_symbol_for_function_slot env ident function_slot : Env.t * Symbol.t
5959
(Compilation_unit.get_current_exn ())
6060
(Linkage_name.of_string (Function_slot.to_string function_slot))
6161
in
62-
let env = Env.add_simple_to_substitute env ident (Simple.symbol symbol) K.With_subkind.any_value in
62+
let env =
63+
Env.add_simple_to_substitute env ident (Simple.symbol symbol)
64+
K.With_subkind.any_value
65+
in
6366
env, symbol
6467

6568
let register_const0 acc constant name =
@@ -726,7 +729,8 @@ let close_named acc env ~let_bound_var (named : IR.named)
726729
(fun acc named -> k acc (Some named))
727730
| Prim { prim; args; loc; exn_continuation; region } ->
728731
close_primitive acc env ~let_bound_var named prim ~args loc exn_continuation
729-
~current_region:(fst (Env.find_var env region)) k
732+
~current_region:(fst (Env.find_var env region))
733+
k
730734

731735
let close_let acc env id user_visible kind defining_expr
732736
~(body : Acc.t -> Env.t -> Expr_with_acc.t) : Expr_with_acc.t =
@@ -798,7 +802,8 @@ let close_let acc env id user_visible kind defining_expr
798802
(* In spirit, this is the same as the simple case but more
799803
cumbersome to detect, we have to remove the now useless
800804
let-binding later. *)
801-
Some (Env.add_simple_to_substitute env id (Simple.symbol sym) kind)
805+
Some
806+
(Env.add_simple_to_substitute env id (Simple.symbol sym) kind)
802807
| _ ->
803808
Some (Env.add_value_approximation body_env (Name.var var) approx))
804809
)
@@ -830,17 +835,16 @@ let close_let_cont acc env ~name ~is_exn_handler ~params
830835
Misc.fatal_errorf
831836
"[Let_cont]s marked as exception handlers must be [Nonrecursive]: %a"
832837
Continuation.print name);
833-
let params_with_kinds = List.map (fun (param, user_visible, kind) ->
834-
(param, user_visible, K.With_subkind.from_lambda kind)
835-
) params
836-
in
837-
let handler_env, params =
838-
Env.add_vars_like env params_with_kinds
838+
let params_with_kinds =
839+
List.map
840+
(fun (param, user_visible, kind) ->
841+
param, user_visible, K.With_subkind.from_lambda kind)
842+
params
839843
in
844+
let handler_env, params = Env.add_vars_like env params_with_kinds in
840845
let handler_params =
841846
List.map2
842-
(fun param (_, _, kind) ->
843-
BP.create param kind)
847+
(fun param (_, _, kind) -> BP.create param kind)
844848
params params_with_kinds
845849
|> Bound_parameters.create
846850
in
@@ -1191,7 +1195,10 @@ let close_one_function acc ~code_id ~external_env ~by_function_slot decl
11911195
in
11921196
let simple = Simple.with_coercion (Simple.var var) coerce_to_deeper in
11931197
let approx = Function_slot.Map.find function_slot approx_map in
1194-
let env = Env.add_simple_to_substitute env let_rec_ident simple K.With_subkind.any_value in
1198+
let env =
1199+
Env.add_simple_to_substitute env let_rec_ident simple
1200+
K.With_subkind.any_value
1201+
in
11951202
let env = Env.add_value_approximation env (Name.var var) approx in
11961203
to_bind, env)
11971204
(Variable.Map.empty, closure_env)
@@ -1201,23 +1208,26 @@ let close_one_function acc ~code_id ~external_env ~by_function_slot decl
12011208
Ident.Map.fold
12021209
(fun id var env ->
12031210
let simple, kind = find_simple_from_id_with_kind external_env id in
1204-
Simple.pattern_match
1205-
simple
1211+
Simple.pattern_match simple
12061212
~const:(fun _ -> assert false)
12071213
~name:(fun name ~coercion:_ ->
1208-
Env.add_approximation_alias (Env.add_var env id var kind) name
1209-
(Name.var var)))
1214+
Env.add_approximation_alias
1215+
(Env.add_var env id var kind)
1216+
name (Name.var var)))
12101217
value_slots_for_idents closure_env
12111218
in
12121219
let closure_env =
12131220
List.fold_right
12141221
(fun (id, kind) env ->
1215-
let env, _var = Env.add_var_like env id User_visible (K.With_subkind.from_lambda kind) in
1222+
let env, _var =
1223+
Env.add_var_like env id User_visible (K.With_subkind.from_lambda kind)
1224+
in
12161225
env)
12171226
params closure_env
12181227
in
12191228
let closure_env, my_region =
1220-
Env.add_var_like closure_env my_region Not_user_visible K.With_subkind.region
1229+
Env.add_var_like closure_env my_region Not_user_visible
1230+
K.With_subkind.region
12211231
in
12221232
let closure_env = Env.with_depth closure_env my_depth in
12231233
let closure_env, absolute_history, relative_history =
@@ -1588,13 +1598,13 @@ let close_functions acc external_env ~current_region function_declarations =
15881598
let value_slots =
15891599
Ident.Map.fold
15901600
(fun id value_slot map ->
1591-
let external_simple, kind = find_simple_from_id_with_kind external_env id in
1601+
let external_simple, kind =
1602+
find_simple_from_id_with_kind external_env id
1603+
in
15921604
(* We're sure [external_simple] is a variable since
15931605
[value_slot_from_idents] has already filtered constants and symbols
15941606
out. *)
1595-
Value_slot.Map.add value_slot
1596-
(external_simple, kind)
1597-
map)
1607+
Value_slot.Map.add value_slot (external_simple, kind) map)
15981608
value_slots_from_idents Value_slot.Map.empty
15991609
in
16001610
let set_of_closures =
@@ -1636,15 +1646,19 @@ let close_let_rec acc env ~function_declarations
16361646
List.fold_right
16371647
(fun decl env ->
16381648
let id = Function_decl.let_rec_ident decl in
1639-
let env, _var = Env.add_var_like env id User_visible K.With_subkind.any_value in
1649+
let env, _var =
1650+
Env.add_var_like env id User_visible K.With_subkind.any_value
1651+
in
16401652
env)
16411653
function_declarations env
16421654
in
16431655
let fun_vars_map, ident_map =
16441656
List.fold_left
16451657
(fun (fun_vars_map, ident_map) decl ->
16461658
let ident = Function_decl.let_rec_ident decl in
1647-
let fun_var = VB.create (fst (Env.find_var env ident)) Name_mode.normal in
1659+
let fun_var =
1660+
VB.create (fst (Env.find_var env ident)) Name_mode.normal
1661+
in
16481662
let function_slot = Function_decl.function_slot decl in
16491663
( Function_slot.Map.add function_slot fun_var fun_vars_map,
16501664
Function_slot.Map.add function_slot ident ident_map ))
@@ -1687,7 +1701,8 @@ let close_let_rec acc env ~function_declarations
16871701
(fun function_slot (symbol, approx) env ->
16881702
let ident = Function_slot.Map.find function_slot ident_map in
16891703
let env =
1690-
Env.add_simple_to_substitute env ident (Simple.symbol symbol) K.With_subkind.any_value
1704+
Env.add_simple_to_substitute env ident (Simple.symbol symbol)
1705+
K.With_subkind.any_value
16911706
in
16921707
Env.add_value_approximation env (Name.symbol symbol) approx)
16931708
symbols env
@@ -2114,7 +2129,8 @@ let close_program (type mode) ~(mode : mode Flambda_features.mode)
21142129
let module_block_var = Variable.create "module_block" in
21152130
let return_cont = Continuation.create ~sort:Toplevel_return () in
21162131
let env, toplevel_my_region =
2117-
Env.add_var_like env toplevel_my_region Not_user_visible Flambda_kind.With_subkind.region
2132+
Env.add_var_like env toplevel_my_region Not_user_visible
2133+
Flambda_kind.With_subkind.region
21182134
in
21192135
let slot_offsets = Slot_offsets.empty in
21202136
let acc = Acc.create ~symbol_for_global ~slot_offsets in

middle_end/flambda2/from_lambda/closure_conversion_aux.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ module Env = struct
130130
type t =
131131
{ variables : (Variable.t * Flambda_kind.With_subkind.t) Ident.Map.t;
132132
globals : Symbol.t Numeric_types.Int.Map.t;
133-
simples_to_substitute : (Simple.t * Flambda_kind.With_subkind.t) Ident.Map.t;
133+
simples_to_substitute :
134+
(Simple.t * Flambda_kind.With_subkind.t) Ident.Map.t;
134135
current_unit_id : Ident.t;
135136
current_depth : Variable.t option;
136137
symbol_for_global : Ident.t -> Symbol.t;
@@ -249,7 +250,8 @@ module Env = struct
249250

250251
let with_depth t depth_var = { t with current_depth = Some depth_var }
251252

252-
let add_var t id var kind = { t with variables = Ident.Map.add id (var, kind) t.variables }
253+
let add_var t id var kind =
254+
{ t with variables = Ident.Map.add id (var, kind) t.variables }
253255

254256
let add_vars t ids vars =
255257
List.fold_left2 (fun t id (var, kind) -> add_var t id var kind) t ids vars
@@ -275,7 +277,7 @@ module Env = struct
275277
| Not_user_visible -> None
276278
| User_visible -> Some ()
277279
in
278-
(Variable.create_with_same_name_as_ident ?user_visible id, kind))
280+
Variable.create_with_same_name_as_ident ?user_visible id, kind)
279281
ids
280282
in
281283
add_vars t (List.map (fun (id, _, _) -> id) ids) vars, List.map fst vars
@@ -310,7 +312,8 @@ module Env = struct
310312
Misc.fatal_errorf "Cannot redefine [Simple] associated with %a"
311313
Ident.print id;
312314
{ t with
313-
simples_to_substitute = Ident.Map.add id (simple, kind) t.simples_to_substitute
315+
simples_to_substitute =
316+
Ident.Map.add id (simple, kind) t.simples_to_substitute
314317
}
315318

316319
let add_simple_to_substitute_map t map =

middle_end/flambda2/from_lambda/closure_conversion_aux.mli

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,23 @@ module Env : sig
110110

111111
val add_var : t -> Ident.t -> Variable.t -> Flambda_kind.With_subkind.t -> t
112112

113-
val add_vars : t -> Ident.t list -> (Variable.t * Flambda_kind.With_subkind.t) list -> t
113+
val add_vars :
114+
t -> Ident.t list -> (Variable.t * Flambda_kind.With_subkind.t) list -> t
114115

115-
val add_var_map : t -> (Variable.t * Flambda_kind.With_subkind.t) Ident.Map.t -> t
116+
val add_var_map :
117+
t -> (Variable.t * Flambda_kind.With_subkind.t) Ident.Map.t -> t
116118

117-
val add_var_like : t -> Ident.t -> IR.user_visible -> Flambda_kind.With_subkind.t -> t * Variable.t
119+
val add_var_like :
120+
t ->
121+
Ident.t ->
122+
IR.user_visible ->
123+
Flambda_kind.With_subkind.t ->
124+
t * Variable.t
118125

119126
val add_vars_like :
120-
t -> (Ident.t * IR.user_visible * Flambda_kind.With_subkind.t) list -> t * Variable.t list
127+
t ->
128+
(Ident.t * IR.user_visible * Flambda_kind.With_subkind.t) list ->
129+
t * Variable.t list
121130

122131
val find_name : t -> Ident.t -> Name.t
123132

@@ -127,17 +136,21 @@ module Env : sig
127136

128137
val find_var_exn : t -> Ident.t -> Variable.t * Flambda_kind.With_subkind.t
129138

130-
val find_vars : t -> Ident.t list -> (Variable.t * Flambda_kind.With_subkind.t) list
139+
val find_vars :
140+
t -> Ident.t list -> (Variable.t * Flambda_kind.With_subkind.t) list
131141

132142
val add_global : t -> int -> Symbol.t -> t
133143

134144
val find_global : t -> int -> Symbol.t
135145

136-
val add_simple_to_substitute : t -> Ident.t -> Simple.t -> Flambda_kind.With_subkind.t -> t
146+
val add_simple_to_substitute :
147+
t -> Ident.t -> Simple.t -> Flambda_kind.With_subkind.t -> t
137148

138-
val add_simple_to_substitute_map : t -> (Simple.t * Flambda_kind.With_subkind.t) Ident.Map.t -> t
149+
val add_simple_to_substitute_map :
150+
t -> (Simple.t * Flambda_kind.With_subkind.t) Ident.Map.t -> t
139151

140-
val find_simple_to_substitute_exn : t -> Ident.t -> Simple.t * Flambda_kind.With_subkind.t
152+
val find_simple_to_substitute_exn :
153+
t -> Ident.t -> Simple.t * Flambda_kind.With_subkind.t
141154

142155
val add_value_approximation : t -> Name.t -> value_approximation -> t
143156

0 commit comments

Comments
 (0)