1 (**************************************************************************)
2 (* *)
3 (* OCaml *)
4 (* *)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6 (* *)
7 (* Copyright 2005 Institut National de Recherche en Informatique et *)
8 (* en Automatique. *)
9 (* *)
10 (* All rights reserved. This file is distributed under the terms of *)
11 (* the GNU Lesser General Public License version 2.1, with the *)
12 (* special exception on linking described in the file LICENSE. *)
13 (* *)
14 (**************************************************************************)
15
16 (** Command line flags *)
17
18 (** Optimization parameters represented as ints indexed by round number. *)
19 module Int_arg_helper : sig
20 type parsed
21
22 val parse : string -> string -> parsed ref -> unit
23
24 type parse_result =
25 | Ok
26 | Parse_failed of exn
27 val parse_no_error : string -> parsed ref -> parse_result
28
29 val get : key:int -> parsed -> int
30 end
31
32 (** Optimization parameters represented as floats indexed by round number. *)
33 module Float_arg_helper : sig
34 type parsed
35
36 val parse : string -> string -> parsed ref -> unit
37
38 type parse_result =
39 | Ok
40 | Parse_failed of exn
41 val parse_no_error : string -> parsed ref -> parse_result
42
43 val get : key:int -> parsed -> float
44 end
45
46 type inlining_arguments = {
47 inline_call_cost : int option;
48 inline_alloc_cost : int option;
49 inline_prim_cost : int option;
50 inline_branch_cost : int option;
51 inline_indirect_cost : int option;
52 inline_lifting_benefit : int option;
53 inline_branch_factor : float option;
54 inline_max_depth : int option;
55 inline_max_unroll : int option;
56 inline_threshold : float option;
57 inline_toplevel_threshold : int option;
58 }
59
60 val classic_arguments : inlining_arguments
61 val o1_arguments : inlining_arguments
62 val o2_arguments : inlining_arguments
63 val o3_arguments : inlining_arguments
64
65 (** Set all the inlining arguments for a round.
66 The default is set if no round is provided. *)
67 val use_inlining_arguments_set : ?round:int -> inlining_arguments -> unit
68
69 val objfiles : string list ref
70 val ccobjs : string list ref
71 val dllibs : string list ref
72 val compile_only : bool ref
73 val output_name : string option ref
74 val include_dirs : string list ref
75 val no_std_include : bool ref
76 val print_types : bool ref
77 val make_archive : bool ref
78 val debug : bool ref
79 val debug_full : bool ref
80 val unsafe : bool ref
81 val use_linscan : bool ref
82 val link_everything : bool ref
83 val custom_runtime : bool ref
84 val no_check_prims : bool ref
85 val bytecode_compatible_32 : bool ref
86 val output_c_object : bool ref
87 val output_complete_object : bool ref
88 val output_complete_executable : bool ref
89 val all_ccopts : string list ref
90 val classic : bool ref
91 val nopervasives : bool ref
92 val match_context_rows : int ref
93 val open_modules : string list ref
94 val preprocessor : string option ref
95 val all_ppx : string list ref
96 val absname : bool ref
97 val annotations : bool ref
98 val binary_annotations : bool ref
99 val use_threads : bool ref
100 val noassert : bool ref
101 val verbose : bool ref
102 val noprompt : bool ref
103 val nopromptcont : bool ref
104 val init_file : string option ref
105 val noinit : bool ref
106 val noversion : bool ref
107 val use_prims : string ref
108 val use_runtime : string ref
109 val plugin : bool ref
110 val principal : bool ref
111 val real_paths : bool ref
112 val recursive_types : bool ref
113 val strict_sequence : bool ref
114 val strict_formats : bool ref
115 val applicative_functors : bool ref
116 val make_runtime : bool ref
117 val c_compiler : string option ref
118 val no_auto_link : bool ref
119 val dllpaths : string list ref
120 val make_package : bool ref
121 val for_package : string option ref
122 val error_size : int ref
123 val float_const_prop : bool ref
124 val transparent_modules : bool ref
125 val unique_ids : bool ref
126 val dump_source : bool ref
127 val dump_parsetree : bool ref
128 val dump_typedtree : bool ref
129 val dump_rawlambda : bool ref
130 val dump_lambda : bool ref
131 val dump_rawclambda : bool ref
132 val dump_clambda : bool ref
133 val dump_rawflambda : bool ref
134 val dump_flambda : bool ref
135 val dump_flambda_let : int option ref
136 val dump_instr : bool ref
137 val keep_camlprimc_file : bool ref
138 val keep_asm_file : bool ref
139 val optimize_for_speed : bool ref
140 val dump_cmm : bool ref
141 val dump_selection : bool ref
142 val dump_cse : bool ref
143 val dump_live : bool ref
144 val dump_avail : bool ref
145 val debug_runavail : bool ref
146 val dump_spill : bool ref
147 val dump_split : bool ref
148 val dump_interf : bool ref
149 val dump_prefer : bool ref
150 val dump_regalloc : bool ref
151 val dump_reload : bool ref
152 val dump_scheduling : bool ref
153 val dump_linear : bool ref
154 val dump_interval : bool ref
155 val keep_startup_file : bool ref
156 val dump_combine : bool ref
157 val native_code : bool ref
158 val default_inline_threshold : float
159 val inline_threshold : Float_arg_helper.parsed ref
160 val inlining_report : bool ref
161 val simplify_rounds : int option ref
162 val default_simplify_rounds : int ref
163 val rounds : unit -> int
164 val default_inline_max_unroll : int
165 val inline_max_unroll : Int_arg_helper.parsed ref
166 val default_inline_toplevel_threshold : int
167 val inline_toplevel_threshold : Int_arg_helper.parsed ref
168 val default_inline_call_cost : int
169 val default_inline_alloc_cost : int
170 val default_inline_prim_cost : int
171 val default_inline_branch_cost : int
172 val default_inline_indirect_cost : int
173 val default_inline_lifting_benefit : int
174 val inline_call_cost : Int_arg_helper.parsed ref
175 val inline_alloc_cost : Int_arg_helper.parsed ref
176 val inline_prim_cost : Int_arg_helper.parsed ref
177 val inline_branch_cost : Int_arg_helper.parsed ref
178 val inline_indirect_cost : Int_arg_helper.parsed ref
179 val inline_lifting_benefit : Int_arg_helper.parsed ref
180 val default_inline_branch_factor : float
181 val inline_branch_factor : Float_arg_helper.parsed ref
182 val dont_write_files : bool ref
183 val std_include_flag : string -> string
184 val std_include_dir : unit -> string list
185 val shared : bool ref
186 val dlcode : bool ref
187 val pic_code : bool ref
188 val runtime_variant : string ref
189 val with_runtime : bool ref
190 val force_slash : bool ref
191 val keep_docs : bool ref
192 val keep_locs : bool ref
193 val unsafe_string : bool ref
194 val opaque : bool ref
195 val profile_columns : Profile.column list ref
196 val flambda_invariant_checks : bool ref
197 val unbox_closures : bool ref
198 val unbox_closures_factor : int ref
199 val default_unbox_closures_factor : int
200 val unbox_free_vars_of_closures : bool ref
201 val unbox_specialised_args : bool ref
202 val clambda_checks : bool ref
203 val default_inline_max_depth : int
204 val inline_max_depth : Int_arg_helper.parsed ref
205 val remove_unused_arguments : bool ref
206 val dump_flambda_verbose : bool ref
207 val classic_inlining : bool ref
208 val afl_instrument : bool ref
209 val afl_inst_ratio : int ref
210 val function_sections : bool ref
211
212 val all_passes : string list ref
213 val dumped_pass : string -> bool
214 val set_dumped_pass : string -> bool -> unit
215
216 val dump_into_file : bool ref
217
218 (* Support for flags that can also be set from an environment variable *)
219 type 'a env_reader = {
220 parse : string -> 'a option;
221 print : 'a -> string;
222 usage : string;
223 env_var : string;
224 }
225
226 val color : Misc.Color.setting option ref
227 val color_reader : Misc.Color.setting env_reader
228
229 val error_style : Misc.Error_style.setting option ref
230 val error_style_reader : Misc.Error_style.setting env_reader
231
232 val unboxed_types : bool ref
233
234 val insn_sched : bool ref
235 val insn_sched_default : bool
236
237 module Compiler_pass : sig
238 type t = Parsing | Typing
239 val of_string : string -> t option
240 val to_string : t -> string
241 val passes : t list
242 val pass_names : string list
243 end
244 val stop_after : Compiler_pass.t option ref
245 val should_stop_after : Compiler_pass.t -> bool
246
247 val arg_spec : (string * Arg.spec * string) list ref
248
249 (* [add_arguments __LOC__ args] will add the arguments from [args] at
250 the end of [arg_spec], checking that they have not already been
251 added by [add_arguments] before. A warning is printed showing the
252 locations of the function from which the argument was previously
253 added. *)
254 val add_arguments : string -> (string * Arg.spec * string) list -> unit
255
256 (* [parse_arguments anon_arg usage] will parse the arguments, using
257 the arguments provided in [Clflags.arg_spec].
258 *)
259 val parse_arguments : Arg.anon_fun -> string -> unit
260
261 (* [print_arguments usage] print the standard usage message *)
262 val print_arguments : string -> unit
263
264 (* [reset_arguments ()] clear all declared arguments *)
265 val reset_arguments : unit -> unit
266