Skip to content

Commit bc430cb

Browse files
mshinwellpoechsel
authored andcommitted
flambda-backend: Add Clflags.is_flambda2 (#62)
1 parent ed87247 commit bc430cb

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

lambda/translmod.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ let record_primitive = function
217217
upstreamed. At that point this helper can move into that module. *)
218218

219219
let preallocate_letrec ~bindings ~body =
220-
assert Config.flambda2;
220+
assert (Clflags.is_flambda2 ());
221221
let caml_update_dummy_prim =
222222
Primitive.simple ~name:"caml_update_dummy" ~arity:2 ~alloc:true
223223
in
@@ -739,7 +739,7 @@ and transl_structure ~scopes loc fields cc rootpath final_env = function
739739
transl_structure ~scopes loc (List.rev_append ids fields)
740740
cc rootpath final_env rem
741741
in
742-
if Config.flambda2 then
742+
if Clflags.is_flambda2 () then
743743
preallocate_letrec ~bindings:class_bindings ~body, size
744744
else
745745
let class_bindings =
@@ -1193,7 +1193,7 @@ let transl_store_structure ~scopes glob map prims aliases str =
11931193
let (ids, class_bindings) = transl_class_bindings ~scopes cl_list in
11941194
let body = store_idents Loc_unknown ids in
11951195
let lam =
1196-
if Config.flambda2 then
1196+
if Clflags.is_flambda2 () then
11971197
preallocate_letrec
11981198
~bindings:class_bindings
11991199
~body
@@ -1570,7 +1570,7 @@ let transl_toplevel_item ~scopes item =
15701570
let (ids, class_bindings) = transl_class_bindings ~scopes cl_list in
15711571
List.iter set_toplevel_unique_name ids;
15721572
let body = make_sequence toploop_setvalue_id ids in
1573-
if Config.flambda2 then
1573+
if Clflags.is_flambda2 () then
15741574
preallocate_letrec ~bindings:class_bindings ~body
15751575
else
15761576
let class_bindings =

utils/clflags.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ let set_save_ir_after pass enabled =
546546
in
547547
save_ir_after := new_passes
548548

549+
550+
let is_flambda2 () =
551+
Config.flambda2 && !native_code
552+
549553
module String = Misc.Stdlib.String
550554

551555
let arg_spec = ref []

utils/clflags.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ val should_stop_after : Compiler_pass.t -> bool
253253
val set_save_ir_after : Compiler_pass.t -> bool -> unit
254254
val should_save_ir_after : Compiler_pass.t -> bool
255255

256+
val is_flambda2 : unit -> bool
257+
256258
val arg_spec : (string * Arg.spec * string) list ref
257259

258260
(* [add_arguments __LOC__ args] will add the arguments from [args] at

0 commit comments

Comments
 (0)