tools/make_optimization_options:
Instead of generating a file to be manually copied into the middle
of compiler/options.m, do that update automatically.
compiler/options.m:
Mark both ends of the region whose contents are controlled by
tools/make_optimization_options.
This implements Mantis feature request #495.
NEWS:
Announce the change.
compiler/optimization_options.m:
A new module for managing optimization options.
It defines a separate bespoke type for every boolean optimization option
to make it harder to confuse them. It defines a tuple type (opt_tuple)
for accessing optimization options quickly. It implements the turning on
(but NOT turning off) of optimizations when a given optimization level
is selected.
tools/make_optimization_options_middle:
tools/make_optimization_options_db:
The script that generates the meat of optimization_options.m,
and the database of option names, kinds and initial values
that it uses as its input. The script also generates some code
for the special_handler predicate in compiler/options.m.
tools/make_optimization_options_start:
tools/make_optimization_options_end:
The handwritten initial and final parts of optimization_options.m.
tools/make_optimization_options:
The script that pulls these parts together to form optimization_options.m.
compiler/options.m:
Make every optimization option a special option, to be handled by
the special_handler predicate. That handling consists of simply
adding a representation of the option to the end of a cord of
optimization options, to be processed later by optimization_options.m.
That processing will record the values of these options in the opt_tuple,
which is where every other part of the compiler should get them from.
Change the interface of special_handler to make the above possible.
Add an "optopt_" (optimization option) prefix to the name of
every optimization option, to make them inaccessible to the rest
of the compiler under their old name, and thus help enforce the switch
to using the opt_tuple. Any access to these options to look up
their values would fail anyway, since the option data would no longer be
e.g. bool(yes), but bool_special, but the name change makes this failure
happen at compile time, not runtime.
Reclassify a few options to make the above make sense. Some options
(unneeded_code_debug, unneeded_code_debug_pred_name, and
common_struct_preds) were classified as oc_opt even though they
control only the *debugging* of optimizations, while some options
(c_optimize and inline_alloc) were not classified as oc_opt
even though we do set them automatically at some optimization levels.
Delete the opt_level_number option, since it was not used anywhere.
Delete the code for handling -ON and --opt-space, since that is now
done in optimization_options.m.
Add some XXXs.
compiler/handle_options.m:
Switch to using getopt_io.process_options_userdata_se, as required
by the new interface of the special_handler in options.m.
In the absence of errors, invoke optimization_options.m to initialize
the opt_tuple. Then update the opt_tuple incrementally when processing
option implications that affect optimization options.
compiler/globals.m:
Put the opt_tuple into a new field of the globals structure.
compiler/accumulator.m:
compiler/add_pragma_type_spec.m:
compiler/add_trail_ops.m:
compiler/code_info.m:
compiler/code_loc_dep.m:
compiler/compile_target_code.m:
compiler/const_struct.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/disj_gen.m:
compiler/erl_code_gen.m:
compiler/format_call.m:
compiler/global_data.m:
compiler/grab_modules.m:
compiler/higher_order.m:
compiler/hlds_pred.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/ite_gen.m:
compiler/jumpopt.m:
compiler/libs.m:
compiler/llds_out_code_addr.m:
compiler/llds_out_data.m:
compiler/llds_out_file.m:
compiler/llds_out_instr.m:
compiler/llds_out_util.m:
compiler/matching.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/ml_disj_gen.m:
compiler/ml_gen_info.m:
compiler/ml_lookup_switch.m:
compiler/ml_optimize.m:
compiler/ml_proc_gen.m:
compiler/ml_simplify_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen_construct.m:
compiler/optimize.m:
compiler/pd_util.m:
compiler/peephole.m:
compiler/polymorphism.m:
compiler/proc_gen.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_scope.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/simplify_tasks.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/tag_switch.m:
compiler/tupling.m:
compiler/unify_gen_construct.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
Conform to the changes above, mostly by looking up optimization options
in the opt_tuple. In some places, replace bools containing optimization
options with the bespoke type of that specific optimization option.
library/getopt_template:
Fix a bug that screwed up an error message.
The bug happened when processing a --file option. If one of the
options in the file was a special option whose special handler failed,
the code handling that failing option returned both an error indication,
and the rest of the argument list read in from the file. The code
handling the --file option then *ignored* the error indication from
the failed special option, and returned an error message of its own
complaining about the unconsumed remaining arguments in the file,
believing them to be non-option arguments, even though these arguments
were never looked it to see if they were options.
The fix is for the code handling --flag options to check whether
the code processing the file contents found any errors, and if so,
return that error *without* looking at the list of remaining arguments.
In an unrelated change, factor out a duplicate call.