From c5034798097385be1a38c8d1e1ebbcdd6ea77f83 Mon Sep 17 00:00:00 2001 From: Mark Shinwell Date: Thu, 22 Jul 2021 11:32:10 +0100 Subject: [PATCH] Add Flambda2 case to Cmx_format export info type --- backend/asmlibrarian.ml | 4 +++- backend/asmpackager.ml | 10 +++++----- dune | 2 +- file_formats/cmx_format.mli | 3 ++- middle_end/compilenv.ml | 12 +++++++----- tools/objinfo.ml | 4 +++- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/backend/asmlibrarian.ml b/backend/asmlibrarian.ml index ba1d06b2b0f..0710a67d133 100644 --- a/backend/asmlibrarian.ml +++ b/backend/asmlibrarian.ml @@ -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 diff --git a/backend/asmpackager.ml b/backend/asmpackager.ml index 604fac5e52f..8b0f78ecee7 100644 --- a/backend/asmpackager.ml +++ b/backend/asmpackager.ml @@ -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 = @@ -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)) }) @@ -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 diff --git a/dune b/dune index 26daf4cf441..7c911f973fe 100644 --- a/dune +++ b/dune @@ -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) diff --git a/file_formats/cmx_format.mli b/file_formats/cmx_format.mli index 91ad2d1ff16..3f2a792396e 100644 --- a/file_formats/cmx_format.mli +++ b/file_formats/cmx_format.mli @@ -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 *) diff --git a/middle_end/compilenv.ml b/middle_end/compilenv.ml index 247b069403d..f793100ffd7 100644 --- a/middle_end/compilenv.ml +++ b/middle_end/compilenv.ml @@ -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 @@ -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 : @@ -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 diff --git a/tools/objinfo.ml b/tools/objinfo.ml index 63b1a77e902..76b402b046c 100644 --- a/tools/objinfo.ml +++ b/tools/objinfo.ml @@ -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 @@ -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