Skip to content

Add Flambda2 case to Cmx_format.export_info #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/asmlibrarian.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ exception Error of error

let default_ui_export_info =
if Config.flambda then
Cmx_format.Flambda Export_info.empty
Cmx_format.Flambda1 Export_info.empty
else if Config.flambda2 then
Cmx_format.Flambda2 None
else
Cmx_format.Clambda Clambda.Value_unknown

Expand Down
10 changes: 5 additions & 5 deletions backend/asmpackager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ let make_package_object ~ppf_dump members targetobj targetname coercion
let get_export_info ui =
assert(Config.flambda);
match ui.ui_export_info with
| Clambda _ -> assert false
| Flambda info -> info
| Clambda _ | Flambda2 _ -> assert false
| Flambda1 info -> info

let get_approx ui =
assert(not Config.flambda);
match ui.ui_export_info with
| Flambda _ -> assert false
| Flambda1 _ | Flambda2 _ -> assert false
| Clambda info -> info

let build_package_cmx members cmxfile =
Expand Down Expand Up @@ -189,7 +189,7 @@ let build_package_cmx members cmxfile =
List.map (fun info ->
{ info with
ui_export_info =
Flambda
Flambda1
(Export_info_for_pack.import_for_pack ~pack_units
~pack:(Compilenv.current_unit ())
(get_export_info info)) })
Expand All @@ -208,7 +208,7 @@ let build_package_cmx members cmxfile =
(get_export_info ui))
units
in
Flambda ui_export_info
Flambda1 ui_export_info
else
Clambda (get_approx ui)
in
Expand Down
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
; The driver should be in here too, but is not at present. This might
; be tricky because it has a different name...
)
(libraries ocamlcommon stdlib))
(libraries ocamlcommon stdlib flambda2))

(executable
(name flambda_backend_main)
Expand Down
3 changes: 2 additions & 1 deletion file_formats/cmx_format.mli
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ open Misc

type export_info =
| Clambda of Clambda.value_approximation
| Flambda of Export_info.t
| Flambda1 of Export_info.t
| Flambda2 of Flambda2.Flambda_cmx_format.t option

type unit_infos =
{ mutable ui_name: modname; (* Name of unit implemented *)
Expand Down
12 changes: 7 additions & 5 deletions middle_end/compilenv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ let merged_environment = ref Export_info.empty

let default_ui_export_info =
if Config.flambda then
Cmx_format.Flambda Export_info.empty
Cmx_format.Flambda1 Export_info.empty
else if Config.flambda2 then
Cmx_format.Flambda2 None
else
Cmx_format.Clambda Value_unknown

Expand Down Expand Up @@ -223,7 +225,7 @@ let cache_unit_info ui =
let get_clambda_approx ui =
assert(not Config.flambda);
match ui.ui_export_info with
| Flambda _ -> assert false
| Flambda1 _ | Flambda2 _ -> assert false
| Clambda approx -> approx

let toplevel_approx :
Expand Down Expand Up @@ -287,12 +289,12 @@ let set_global_approx approx =
let get_flambda_export_info ui =
assert(Config.flambda);
match ui.ui_export_info with
| Clambda _ -> assert false
| Flambda ei -> ei
| Clambda _ | Flambda2 _ -> assert false
| Flambda1 ei -> ei

let set_export_info export_info =
assert(Config.flambda);
current_unit.ui_export_info <- Flambda export_info
current_unit.ui_export_info <- Flambda1 export_info

let approx_for_global comp_unit =
let id = Compilation_unit.get_persistent_ident comp_unit in
Expand Down
4 changes: 3 additions & 1 deletion tools/objinfo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ let print_cmx_infos (ui, crc) =
Format.fprintf Format.std_formatter " %a@." Printclambda.approx approx
end else
Format.printf "Clambda unit@.";
| Flambda export ->
| Flambda1 export ->
if not !no_approx || not !no_code then
printf "Flambda export information:\n"
else
Expand All @@ -167,6 +167,8 @@ let print_cmx_infos (ui, crc) =
if not !no_code then
Format.printf "functions@ %a@.@."
Export_info.print_functions export
| Flambda2 _ ->
failwith "Flambda2 objinfo support not yet merged"
end;
let pr_funs _ fns =
List.iter (fun arity -> printf " %d" arity) fns in
Expand Down