Skip to content

Commit caa8dff

Browse files
gretay-jsmshinwell
authored andcommitted
Let's fix instead of reverting flambda_backend_args (#396)
* Revert "Revert "Move flambda-backend specific flags out of ocaml/ subdirectory (#382)" (#395)" This reverts commit 2a9c5ef. * Propagate -o2,-o3,-oclassic flambda-backend flags correctly * Rename Flambda_backend_options module for readability To distinguish it from the module type with the same name. * Add documentation comments to Flambda_backend_arg * Remove underscores in Flambda_backend_options * Move "how to add a new flag" to HACKING
1 parent c74c286 commit caa8dff

File tree

19 files changed

+1379
-1190
lines changed

19 files changed

+1379
-1190
lines changed

HACKING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ want to modify the Flambda backend. Jump to:
1616
- [Pulling changes onto a release branch](#pulling-changes-onto-a-release-branch)
1717
- [Rebasing to a new major version of the upstream compiler](#rebasing-to-a-new-major-version-of-the-upstream-compiler)
1818
- [How to add a new intrinsic to the compiler](#how-to-add-a-new-intrinsic-to-the-compiler)
19+
- [How to add a new command line option](#how-to-add-a-new-command-line-option)
1920
- [Installation tree comparison script](#installation-tree-comparison-script)
2021

2122
## Branches, pull requests, etc.
@@ -293,6 +294,17 @@ library, and then the compiler.
293294
relies on the library tests to avoid duplication. Library tests use
294295
`Core`, but the library itself does not.
295296

297+
## How to add a new command line option
298+
299+
1) Add a ref to `flambda_backend_flags.ml{i}`
300+
2) Add the flag's constructor `mk_<flag>` in `flambda_backend_args.ml`
301+
3) Add the callback for the new flag to `Flambda_backend_options` module type
302+
in `flambda_backend_args.ml{i}`
303+
4) List the flag in the body of `Make_flambda_backend_options` functor
304+
5) Implement the flag in `Flambda_backend_options_impl`
305+
by setting the corresponding ref in Flambda_backend_flags
306+
6) Add the flag to `Extra_params` if it can be set via `OCAMLPARAM`
307+
296308
## Installation tree comparison script
297309

298310
A target `make compare` exists to run a comparison script that finds differences

backend/asmgen.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,14 @@ let compile_fundecl ~ppf_dump fd_cmm =
222222
++ Profile.record ~accumulate:true "linearize" (fun (f : Mach.fundecl) ->
223223
let res = Linearize.fundecl f in
224224
(* CR xclerc for xclerc: temporary, for testing. *)
225-
if !Clflags.use_ocamlcfg then begin
225+
if !Flambda_backend_flags.use_ocamlcfg then begin
226226
test_cfgize f res;
227227
end;
228228
res)
229229
++ pass_dump_linear_if ppf_dump dump_linear "Linearized code"
230230
++ Compiler_hooks.execute_and_pipe Compiler_hooks.Linear
231231
++ (fun (fd : Linear.fundecl) ->
232-
if !use_ocamlcfg then begin
232+
if !Flambda_backend_flags.use_ocamlcfg then begin
233233
fd
234234
++ Profile.record ~accumulate:true "linear_to_cfg"
235235
(Linear_to_cfg.run ~preserve_orig_labels:true)

0 commit comments

Comments
 (0)