Some cleanup to explicit transl_implementation_flambda return values

master
Pierre Chambart 2016-06-02 17:42:33 +02:00
parent 3d3a6829bc
commit cb388c762a
4 changed files with 27 additions and 12 deletions

View File

@ -608,6 +608,12 @@ let wrap_globals ~flambda body =
(* Compile an implementation *)
type implementation =
{ module_ident : Ident.t;
main_module_block_size : int;
required_globals : Ident.Set.t;
code : lambda }
let transl_implementation_flambda module_name (str, cc) =
reset_labels ();
primitive_declarations := [];
@ -618,16 +624,18 @@ let transl_implementation_flambda module_name (str, cc) =
(fun () -> transl_struct Location.none [] cc
(global_path module_id) str)
in
(module_id, size),
required_globals ~flambda:true body,
body
{ module_ident = module_id;
main_module_block_size = size;
required_globals = required_globals ~flambda:true body;
code = body }
let transl_implementation module_name (str, cc) =
let (module_id, _size), required_globals, module_initializer =
let implementation =
transl_implementation_flambda module_name (str, cc)
in
Lprim (Psetglobal module_id,
[wrap_required_globals required_globals module_initializer],
Lprim (Psetglobal implementation.module_ident,
[wrap_required_globals implementation.required_globals
implementation.code],
Location.none)
(* Build the list of value identifiers defined by a toplevel structure

View File

@ -24,8 +24,14 @@ val transl_store_phrases: string -> structure -> int * lambda
val transl_store_implementation:
string -> structure * module_coercion -> Lambda.program
type implementation =
{ module_ident : Ident.t;
main_module_block_size : int;
required_globals : Ident.Set.t;
code : lambda }
val transl_implementation_flambda:
string -> structure * module_coercion -> (Ident.t * int) * Ident.Set.t * lambda
string -> structure * module_coercion -> implementation
val transl_toplevel_definition: structure -> lambda
val transl_package:

View File

@ -62,7 +62,6 @@ let print_if ppf flag printer arg =
let (++) x f = f x
let (+++) (x, y) f = (x, f y)
let (++|+) (x, y, z) f = (x, y, f z)
let implementation ppf sourcefile outputprefix ~backend =
let source_provenance = Timings.File sourcefile in
@ -94,10 +93,11 @@ let implementation ppf sourcefile outputprefix ~backend =
(typedtree, coercion)
++ Timings.(time (Timings.Transl sourcefile)
(Translmod.transl_implementation_flambda modulename))
++|+ print_if ppf Clflags.dump_rawlambda Printlambda.lambda
++ Timings.time (Timings.Generate sourcefile)
(fun (modu, required_globals, body) ->
(modu, body)
(fun { Translmod.module_ident; main_module_block_size;
required_globals; code } ->
((module_ident, main_module_block_size), code)
+++ print_if ppf Clflags.dump_rawlambda Printlambda.lambda
+++ Simplif.simplify_lambda
+++ print_if ppf Clflags.dump_lambda Printlambda.lambda
++ (fun ((module_ident, size), lam) ->

View File

@ -306,7 +306,8 @@ let execute_phrase print_outcome ppf phr =
Typecore.force_delayed_checks ();
let module_ident, res, required_globals, size =
if Config.flambda then
let ((module_ident, size), required_globals, res) =
let { Translmod.module_ident; main_module_block_size = size;
required_globals; code = res } =
Translmod.transl_implementation_flambda !phrase_name
(str, Tcoerce_none)
in