Skip to content

Commit dbcb3a9

Browse files
committed
make fmt
1 parent 3a0121d commit dbcb3a9

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 =
@@ -723,7 +726,8 @@ let close_named acc env ~let_bound_var (named : IR.named)
723726
(fun acc named -> k acc (Some named))
724727
| Prim { prim; args; loc; exn_continuation; region } ->
725728
close_primitive acc env ~let_bound_var named prim ~args loc exn_continuation
726-
~current_region:(fst (Env.find_var env region)) k
729+
~current_region:(fst (Env.find_var env region))
730+
k
727731

728732
let close_let acc env id user_visible kind defining_expr
729733
~(body : Acc.t -> Env.t -> Expr_with_acc.t) : Expr_with_acc.t =
@@ -795,7 +799,8 @@ let close_let acc env id user_visible kind defining_expr
795799
(* In spirit, this is the same as the simple case but more
796800
cumbersome to detect, we have to remove the now useless
797801
let-binding later. *)
798-
Some (Env.add_simple_to_substitute env id (Simple.symbol sym) kind)
802+
Some
803+
(Env.add_simple_to_substitute env id (Simple.symbol sym) kind)
799804
| _ ->
800805
Some (Env.add_value_approximation body_env (Name.var var) approx))
801806
)
@@ -827,17 +832,16 @@ let close_let_cont acc env ~name ~is_exn_handler ~params
827832
Misc.fatal_errorf
828833
"[Let_cont]s marked as exception handlers must be [Nonrecursive]: %a"
829834
Continuation.print name);
830-
let params_with_kinds = List.map (fun (param, user_visible, kind) ->
831-
(param, user_visible, K.With_subkind.from_lambda kind)
832-
) params
833-
in
834-
let handler_env, params =
835-
Env.add_vars_like env params_with_kinds
835+
let params_with_kinds =
836+
List.map
837+
(fun (param, user_visible, kind) ->
838+
param, user_visible, K.With_subkind.from_lambda kind)
839+
params
836840
in
841+
let handler_env, params = Env.add_vars_like env params_with_kinds in
837842
let handler_params =
838843
List.map2
839-
(fun param (_, _, kind) ->
840-
BP.create param kind)
844+
(fun param (_, _, kind) -> BP.create param kind)
841845
params params_with_kinds
842846
|> Bound_parameters.create
843847
in
@@ -1188,7 +1192,10 @@ let close_one_function acc ~code_id ~external_env ~by_function_slot decl
11881192
in
11891193
let simple = Simple.with_coercion (Simple.var var) coerce_to_deeper in
11901194
let approx = Function_slot.Map.find function_slot approx_map in
1191-
let env = Env.add_simple_to_substitute env let_rec_ident simple K.With_subkind.any_value in
1195+
let env =
1196+
Env.add_simple_to_substitute env let_rec_ident simple
1197+
K.With_subkind.any_value
1198+
in
11921199
let env = Env.add_value_approximation env (Name.var var) approx in
11931200
to_bind, env)
11941201
(Variable.Map.empty, closure_env)
@@ -1198,23 +1205,26 @@ let close_one_function acc ~code_id ~external_env ~by_function_slot decl
11981205
Ident.Map.fold
11991206
(fun id var env ->
12001207
let simple, kind = find_simple_from_id_with_kind external_env id in
1201-
Simple.pattern_match
1202-
simple
1208+
Simple.pattern_match simple
12031209
~const:(fun _ -> assert false)
12041210
~name:(fun name ~coercion:_ ->
1205-
Env.add_approximation_alias (Env.add_var env id var kind) name
1206-
(Name.var var)))
1211+
Env.add_approximation_alias
1212+
(Env.add_var env id var kind)
1213+
name (Name.var var)))
12071214
value_slots_for_idents closure_env
12081215
in
12091216
let closure_env =
12101217
List.fold_right
12111218
(fun (id, kind) env ->
1212-
let env, _var = Env.add_var_like env id User_visible (K.With_subkind.from_lambda kind) in
1219+
let env, _var =
1220+
Env.add_var_like env id User_visible (K.With_subkind.from_lambda kind)
1221+
in
12131222
env)
12141223
params closure_env
12151224
in
12161225
let closure_env, my_region =
1217-
Env.add_var_like closure_env my_region Not_user_visible K.With_subkind.region
1226+
Env.add_var_like closure_env my_region Not_user_visible
1227+
K.With_subkind.region
12181228
in
12191229
let closure_env = Env.with_depth closure_env my_depth in
12201230
let closure_env, absolute_history, relative_history =
@@ -1585,13 +1595,13 @@ let close_functions acc external_env ~current_region function_declarations =
15851595
let value_slots =
15861596
Ident.Map.fold
15871597
(fun id value_slot map ->
1588-
let external_simple, kind = find_simple_from_id_with_kind external_env id in
1598+
let external_simple, kind =
1599+
find_simple_from_id_with_kind external_env id
1600+
in
15891601
(* We're sure [external_simple] is a variable since
15901602
[value_slot_from_idents] has already filtered constants and symbols
15911603
out. *)
1592-
Value_slot.Map.add value_slot
1593-
(external_simple, kind)
1594-
map)
1604+
Value_slot.Map.add value_slot (external_simple, kind) map)
15951605
value_slots_from_idents Value_slot.Map.empty
15961606
in
15971607
let set_of_closures =
@@ -1633,15 +1643,19 @@ let close_let_rec acc env ~function_declarations
16331643
List.fold_right
16341644
(fun decl env ->
16351645
let id = Function_decl.let_rec_ident decl in
1636-
let env, _var = Env.add_var_like env id User_visible K.With_subkind.any_value in
1646+
let env, _var =
1647+
Env.add_var_like env id User_visible K.With_subkind.any_value
1648+
in
16371649
env)
16381650
function_declarations env
16391651
in
16401652
let fun_vars_map, ident_map =
16411653
List.fold_left
16421654
(fun (fun_vars_map, ident_map) decl ->
16431655
let ident = Function_decl.let_rec_ident decl in
1644-
let fun_var = VB.create (fst (Env.find_var env ident)) Name_mode.normal in
1656+
let fun_var =
1657+
VB.create (fst (Env.find_var env ident)) Name_mode.normal
1658+
in
16451659
let function_slot = Function_decl.function_slot decl in
16461660
( Function_slot.Map.add function_slot fun_var fun_vars_map,
16471661
Function_slot.Map.add function_slot ident ident_map ))
@@ -1684,7 +1698,8 @@ let close_let_rec acc env ~function_declarations
16841698
(fun function_slot (symbol, approx) env ->
16851699
let ident = Function_slot.Map.find function_slot ident_map in
16861700
let env =
1687-
Env.add_simple_to_substitute env ident (Simple.symbol symbol) K.With_subkind.any_value
1701+
Env.add_simple_to_substitute env ident (Simple.symbol symbol)
1702+
K.With_subkind.any_value
16881703
in
16891704
Env.add_value_approximation env (Name.symbol symbol) approx)
16901705
symbols env
@@ -2111,7 +2126,8 @@ let close_program (type mode) ~(mode : mode Flambda_features.mode)
21112126
let module_block_var = Variable.create "module_block" in
21122127
let return_cont = Continuation.create ~sort:Toplevel_return () in
21132128
let env, toplevel_my_region =
2114-
Env.add_var_like env toplevel_my_region Not_user_visible Flambda_kind.With_subkind.region
2129+
Env.add_var_like env toplevel_my_region Not_user_visible
2130+
Flambda_kind.With_subkind.region
21152131
in
21162132
let slot_offsets = Slot_offsets.empty in
21172133
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;
@@ -253,7 +254,8 @@ module Env = struct
253254

254255
let with_depth t depth_var = { t with current_depth = Some depth_var }
255256

256-
let add_var t id var kind = { t with variables = Ident.Map.add id (var, kind) t.variables }
257+
let add_var t id var kind =
258+
{ t with variables = Ident.Map.add id (var, kind) t.variables }
257259

258260
let add_vars t ids vars =
259261
List.fold_left2 (fun t id (var, kind) -> add_var t id var kind) t ids vars
@@ -279,7 +281,7 @@ module Env = struct
279281
| Not_user_visible -> None
280282
| User_visible -> Some ()
281283
in
282-
(Variable.create_with_same_name_as_ident ?user_visible id, kind))
284+
Variable.create_with_same_name_as_ident ?user_visible id, kind)
283285
ids
284286
in
285287
add_vars t (List.map (fun (id, _, _) -> id) ids) vars, List.map fst vars
@@ -314,7 +316,8 @@ module Env = struct
314316
Misc.fatal_errorf "Cannot redefine [Simple] associated with %a"
315317
Ident.print id;
316318
{ t with
317-
simples_to_substitute = Ident.Map.add id (simple, kind) t.simples_to_substitute
319+
simples_to_substitute =
320+
Ident.Map.add id (simple, kind) t.simples_to_substitute
318321
}
319322

320323
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)