Skip to content

Commit a7960dd

Browse files
authored
flambda-backend: Move flambda-backend specific flags out of ocaml/ subdirectory (#382)
1 parent bf7b1a8 commit a7960dd

File tree

7 files changed

+41
-1156
lines changed

7 files changed

+41
-1156
lines changed

boot/ocamlc

-19.9 KB
Binary file not shown.

driver/compenv.ml

Lines changed: 12 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,20 @@ let set_compiler_pass ppf ~name v flag ~filter =
220220
(* 'can-discard=' specifies which arguments can be discarded without warning
221221
because they are not understood by some versions of OCaml. *)
222222
let can_discard = ref []
223+
let warnings_for_discarded_params = ref false
224+
225+
let extra_params = ref None
226+
let set_extra_params params = extra_params := params
223227

224228
let read_one_param ppf position name v =
225229
let set name options s = setter ppf (fun b -> b) name options s in
226230
let clear name options s = setter ppf (fun b -> not b) name options s in
231+
let handled =
232+
match !extra_params with
233+
| Some h -> h ppf position name v
234+
| None -> false
235+
in
236+
if not handled then
227237
match name with
228238
| "g" -> set "g" [ Clflags.debug ] v
229239
| "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v
@@ -359,112 +369,9 @@ let read_one_param ppf position name v =
359369
set "cmm-invariants" [ cmm_invariants ] v
360370
| "linscan" ->
361371
set "linscan" [ use_linscan ] v
362-
| "ocamlcfg" ->
363-
set "ocamlcfg" [ use_ocamlcfg ] v
364372
| "insn-sched" -> set "insn-sched" [ insn_sched ] v
365373
| "no-insn-sched" -> clear "insn-sched" [ insn_sched ] v
366374

367-
| "flambda2-join-points" ->
368-
set "flambda2-join-points"
369-
[Flambda2.join_points] v
370-
| "no-flambda2-join-points" ->
371-
clear "flambda2-join-points"
372-
[Flambda2.join_points] v
373-
| "flambda2-unbox-along-intra-function-control-flow" ->
374-
set "flambda2-unbox-along-intra-function-control-flow"
375-
[Flambda2.unbox_along_intra_function_control_flow] v
376-
| "no-flambda2-unbox-along-intra-function-control-flow" ->
377-
clear "flambda2-unbox-along-intra-function-control-flow"
378-
[Flambda2.unbox_along_intra_function_control_flow] v
379-
| "flambda2-backend-cse-at-toplevel" ->
380-
set "flambda2-backend-cse-at-toplevel"
381-
[Flambda2.backend_cse_at_toplevel] v
382-
| "no-flambda2-backend-cse-at-toplevel" ->
383-
clear "flambda2-backend-cse-at-toplevel"
384-
[Flambda2.backend_cse_at_toplevel] v
385-
| "flambda2-cse-depth" ->
386-
int_setter ppf "flambda2-cse-depth" Flambda2.cse_depth v
387-
| "flambda2-expert-inline-effects-in-cmm" ->
388-
set "flambda2-expert-inline-effects-in-cmm"
389-
[Flambda2.Expert.inline_effects_in_cmm] v
390-
| "no-flambda2-expert-inline-effects-in-cmm" ->
391-
clear "flambda2-expert-inline-effects-in-cmm"
392-
[Flambda2.Expert.inline_effects_in_cmm] v
393-
| "flambda2-expert-phantom-lets" ->
394-
set "flambda2-expert-phantom-lets"
395-
[Flambda2.Expert.phantom_lets] v
396-
| "no-flambda2-expert-phantom-lets" ->
397-
clear "flambda2-expert-phantom-lets"
398-
[Flambda2.Expert.phantom_lets] v
399-
| "flambda2-expert-max-unboxing-depth" ->
400-
int_setter ppf "flambda2-expert-max-unboxing-depth"
401-
Flambda2.Expert.max_unboxing_depth v
402-
| "flambda2-expert-can-inline-recursive-functions" ->
403-
set "flambda2-expert-can-inline-recursive-functions"
404-
[Flambda2.Expert.can_inline_recursive_functions] v
405-
| "no-flambda2-expert-can-inline-recursive-functions" ->
406-
clear "flambda2-expert-can-inline-recursive-functions"
407-
[Flambda2.Expert.can_inline_recursive_functions] v
408-
| "flambda2-inline-max-depth" ->
409-
Int_arg_helper.parse v
410-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-max-depth'"
411-
Flambda2.Inlining.max_depth
412-
| "flambda2-inline-max-rec-depth" ->
413-
Int_arg_helper.parse v
414-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-max-rec-depth'"
415-
Flambda2.Inlining.max_rec_depth
416-
| "flambda2-inline-call-cost" ->
417-
Float_arg_helper.parse v
418-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-call-cost'"
419-
Flambda2.Inlining.call_cost
420-
| "flambda2-inline-alloc-cost" ->
421-
Float_arg_helper.parse v
422-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-alloc-cost'"
423-
Flambda2.Inlining.alloc_cost
424-
| "flambda2-inline-prim-cost" ->
425-
Float_arg_helper.parse v
426-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-prim-cost'"
427-
Flambda2.Inlining.prim_cost
428-
| "flambda2-inline-branch-cost" ->
429-
Float_arg_helper.parse v
430-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-branch-cost'"
431-
Flambda2.Inlining.branch_cost
432-
| "flambda2-inline-indirect-cost" ->
433-
Float_arg_helper.parse v
434-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-indirect-cost'"
435-
Flambda2.Inlining.indirect_call_cost
436-
| "flambda2-inline-poly-compare-cost" ->
437-
Float_arg_helper.parse v
438-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-poly-compare-cost'"
439-
Flambda2.Inlining.poly_compare_cost
440-
| "flambda2-inline-small-function-size" ->
441-
Int_arg_helper.parse v
442-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-small-function-size'"
443-
Flambda2.Inlining.small_function_size
444-
| "flambda2-inline-large-function-size" ->
445-
Int_arg_helper.parse v
446-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-large-function-size'"
447-
Flambda2.Inlining.large_function_size
448-
| "flambda2-inline-threshold" ->
449-
Float_arg_helper.parse v
450-
"Bad syntax in OCAMLPARAM for 'flambda2-inline-threshold'"
451-
Flambda2.Inlining.threshold
452-
| "flambda2-speculative-inlining-only-if-arguments-useful" ->
453-
set "flambda2-speculative-inlining-only-if-arguments-useful"
454-
[Flambda2.Inlining.speculative_inlining_only_if_arguments_useful] v
455-
| "flambda2-treat-invalid-code-as-unreachable" ->
456-
set "flambda2-treat-invalid-code-as-unreachable"
457-
[Flambda2.treat_invalid_code_as_unreachable] v
458-
| "no-flambda2-treat-invalid-code-as-unreachable" ->
459-
clear "flambda2-treat-invalid-code-as-unreachable"
460-
[Flambda2.treat_invalid_code_as_unreachable] v
461-
| "flambda2-inlining-report-bin" ->
462-
set "flambda2-inlining-report-bin"
463-
[Flambda2.Inlining.report_bin] v
464-
| "no-flambda2-inlining-report-bin" ->
465-
clear "flambda2-inlining-report-bin"
466-
[Flambda2.Inlining.report_bin] v
467-
468375
(* color output *)
469376
| "color" ->
470377
begin match color_reader.parse v with
@@ -563,7 +470,8 @@ let read_one_param ppf position name v =
563470
end
564471

565472
| _ ->
566-
if not (List.mem name !can_discard) then begin
473+
if !warnings_for_discarded_params &&
474+
not (List.mem name !can_discard) then begin
567475
can_discard := name :: !can_discard;
568476
Printf.ksprintf (print_error ppf)
569477
"Warning: discarding value of variable %S in OCAMLPARAM\n%!"

driver/compenv.mli

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ type readenv_position =
4444
Before_args | Before_compile of filename | Before_link
4545

4646
val readenv : Format.formatter -> readenv_position -> unit
47+
val set_extra_params :
48+
(Format.formatter -> readenv_position -> string -> string -> bool) option ->
49+
unit
50+
(* Enable/disable warning about discarding any unknown arguments. *)
51+
val warnings_for_discarded_params : bool ref
52+
53+
val setter :
54+
Format.formatter -> (bool -> 'a) -> string -> 'a ref list -> string -> unit
55+
val int_setter : Format.formatter -> string -> int ref -> string -> unit
56+
val check_bool : Format.formatter -> string -> string -> bool
4757

4858
(* [is_unit_name name] returns true only if [name] can be used as a
4959
correct module name *)

0 commit comments

Comments
 (0)