diff options
author | Doug Smith <dsmith47@nd.edu> | 2019-04-09 04:32:46 -0400 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2023-01-12 10:46:27 +0100 |
commit | bb4f0dd25108802cb66e664e0fed4286653f63f1 (patch) | |
tree | 1997c3db936b3e5651d4304deccadb134288d573 /driver/optcompile.ml | |
parent | f9aeb7012fc1b4ceb5662c5213362393e287e94d (diff) | |
download | ocaml-bb4f0dd25108802cb66e664e0fed4286653f63f1.tar.gz |
Added lambda option to -stop-after comiler flag and logic to compile_common, compile, and optcompile to terminate compilation after lambdas are resolved based on this option.
Co-authored-by: Doug Smith <dsmith47@nd.edu>
Co-authored-by: Dmitrii Kosarev <Dmitrii.Kosarev@pm.me>
Diffstat (limited to 'driver/optcompile.ml')
-rw-r--r-- | driver/optcompile.ml | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/driver/optcompile.ml b/driver/optcompile.ml index 44aa91c9da..fd2f26eb21 100644 --- a/driver/optcompile.ml +++ b/driver/optcompile.ml @@ -38,32 +38,39 @@ let flambda i backend Typedtree.{structure; coercion; _} = Clflags.unbox_free_vars_of_closures := false; Clflags.unbox_specialised_args := false end; + (structure, coercion) |> Profile.(record transl) (Translmod.transl_implementation_flambda i.module_name) |> Profile.(record generate) (fun {Lambda.module_ident; main_module_block_size; required_globals; code } -> - ((module_ident, main_module_block_size), code) - |>> print_if i.ppf_dump Clflags.dump_rawlambda Printlambda.lambda - |>> Simplif.simplify_lambda - |>> print_if i.ppf_dump Clflags.dump_lambda Printlambda.lambda - |> (fun ((module_ident, main_module_block_size), code) -> - let program : Lambda.program = - { Lambda. - module_ident; - main_module_block_size; - required_globals; - code; - } + let () = + let (module_ident, main_module_block_size), code = + ((module_ident, main_module_block_size), code) + |>> print_if i.ppf_dump Clflags.dump_rawlambda Printlambda.lambda + |>> Simplif.simplify_lambda + |>> print_if i.ppf_dump Clflags.dump_lambda Printlambda.lambda + in + + if Clflags.(should_stop_after Compiler_pass.Lambda) then () else ( + let program : Lambda.program = + { Lambda. + module_ident; + main_module_block_size; + required_globals; + code; + } + in + Asmgen.compile_implementation + ~backend + ~prefixname:i.output_prefix + ~middle_end:Flambda_middle_end.lambda_to_clambda + ~ppf_dump:i.ppf_dump + program) in - Asmgen.compile_implementation - ~backend - ~prefixname:i.output_prefix - ~middle_end:Flambda_middle_end.lambda_to_clambda - ~ppf_dump:i.ppf_dump - program); - Compilenv.save_unit_info (cmx i)) + Compilenv.save_unit_info (cmx i)) + let clambda i backend Typedtree.{structure; coercion; _} = Clflags.use_inlining_arguments_set Clflags.classic_arguments; @@ -76,12 +83,16 @@ let clambda i backend Typedtree.{structure; coercion; _} = let code = Simplif.simplify_lambda program.Lambda.code in { program with Lambda.code } |> print_if i.ppf_dump Clflags.dump_lambda Printlambda.program - |> Asmgen.compile_implementation + |>(fun lambda -> + if Clflags.(should_stop_after Compiler_pass.Lambda) then () else + Asmgen.compile_implementation ~backend ~prefixname:i.output_prefix ~middle_end:Closure_middle_end.lambda_to_clambda - ~ppf_dump:i.ppf_dump; - Compilenv.save_unit_info (cmx i)) + ~ppf_dump:i.ppf_dump + lambda; + Compilenv.save_unit_info (cmx i))) + (* Emit assembly directly from Linear IR *) let emit i = |