[m-rev.] diff: clean up handle_options and globals
Zoltan Somogyi
zs at cs.mu.OZ.AU
Thu Sep 1 15:28:12 AEST 2005
This diff cleans up two modules. It has no algorithmic changes.
compiler/globals.m:
Convert to four-space indentation.
Add a missing predicate variant for use in handle_options.m.
compiler/handle_options.m:
Convert to four-space indentation. Convert to state variable notation
from DCGs.
Instead of continually getting the globals from the I/O state and
stuffing back an updated version, thread the globals themselves
through the relevant predicates.
Zoltan.
cvs diff: Diffing .
Index: globals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.67
diff -u -b -r1.67 globals.m
--- globals.m 7 Apr 2005 06:32:07 -0000 1.67
+++ globals.m 31 Aug 2005 02:11:16 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1994-2005 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
@@ -39,8 +41,7 @@
% (Work in progress)
; asm. % Compile directly to assembler via the GCC back-end.
% Do not go via C, instead generate GCC's internal
- % `tree' data structure.
- % (Work in progress.)
+ % `tree' data structure. (Work in progress.)
:- type foreign_language
---> c
@@ -51,11 +52,13 @@
; il.
% A string representation of the foreign language suitable
- % for use in human-readable error messages
+ % for use in human-readable error messages.
+ %
:- func foreign_language_string(foreign_language) = string.
% A string representation of the foreign language suitable
% for use in machine-readable name mangling.
+ %
:- func simple_foreign_language_string(foreign_language) = string.
% The GC method specifies how we do garbage collection.
@@ -80,15 +83,14 @@
% than the Boehm collector, so we don't really
% support this option anymore.
- ; accurate.
- % Our own home-grown copying collector.
+ ; accurate. % Our own home-grown copying collector.
% See runtime/mercury_accurate_gc.c
% and compiler/ml_elim_nested.m.
- % Returns yes if the GC method is conservative,
- % i.e. if it is `boehm' or `mps'.
- % Conservative GC methods don't support heap
- % reclamation on failure.
+ % Returns yes if the GC method is conservative, i.e. if it is `boehm'
+ % or `mps'. Conservative GC methods don't support heap reclamation
+ % on failure.
+ %
:- func gc_is_conservative(gc_method) = bool.
:- type tags_method
@@ -142,6 +144,8 @@
:- pred globals__get_maybe_thread_safe(globals::in, maybe_thread_safe::out)
is det.
+:- pred globals__set_option(option::in, option_data::in,
+ globals::in, globals::out) is det.
:- pred globals__set_options(option_table::in, globals::in, globals::out)
is det.
:- pred globals__set_gc_method(gc_method::in, globals::in, globals::out)
@@ -174,18 +178,18 @@
% Check if static code addresses are available in the
% current grade of compilation.
-
+ %
:- pred globals__have_static_code_addresses(globals::in, bool::out) is det.
% Check if we should include variable information in the layout
% structures of call return sites.
-
+ %
:- pred globals__want_return_var_layouts(globals::in, bool::out) is det.
% globals__imported_is_constant(NonLocalGotos, AsmLabels, IsConst)
% figures out whether an imported label address is a constant.
% This depends on how we treat labels.
-
+ %
:- pred globals__imported_is_constant(bool::in, bool::in, bool::out) is det.
%-----------------------------------------------------------------------------%
@@ -373,6 +377,11 @@
globals__set_options(Options, Globals, Globals ^ options := Options).
+globals__set_option(Option, OptionData, !Globals) :-
+ globals__get_options(!.Globals, OptionTable0),
+ map__set(OptionTable0, Option, OptionData, OptionTable),
+ globals__set_options(OptionTable, !Globals).
+
globals__set_gc_method(GC_Method, Globals, Globals ^ gc_method := GC_Method).
globals__set_tags_method(Tags_Method, Globals,
@@ -459,8 +468,7 @@
;
globals__get_trace_level(Globals, TraceLevel),
globals__get_trace_suppress(Globals, TraceSuppress),
- trace_needs_return_info(TraceLevel, TraceSuppress)
- = yes
+ trace_needs_return_info(TraceLevel, TraceSuppress) = yes
)
->
WantReturnLayouts = yes
@@ -477,11 +485,11 @@
AsmLabels = no
->
%
- % with non-local gotos but no asm labels, jumps to code
- % addresses in different c_modules must be done via global
- % variables; the value of these global variables is not
- % constant (i.e. not computable at load time), since they
- % can't be initialized until we call init_modules().
+ % With non-local gotos but no asm labels, jumps to code addresses
+ % in different c_modules must be done via global variables; the value
+ % of these global variables is not constant (i.e. not computable at
+ % load time), since they can't be initialized until we call
+ % init_modules().
%
IsConst = no
;
@@ -492,8 +500,7 @@
%-----------------------------------------------------------------------------%
globals__io_init(Options, Target, GC_Method, TagsMethod, TerminationNorm,
- Termination2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe,
- !IO) :-
+ Termination2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !IO) :-
copy(Target, Target1),
copy(GC_Method, GC_Method1),
copy(TagsMethod, TagsMethod1),
@@ -507,132 +514,130 @@
TraceSuppress1, MaybeThreadSafe1, Globals),
globals__io_set_globals(Globals, !IO).
-globals__io_get_target(Target) -->
- globals__io_get_globals(Globals),
- { globals__get_target(Globals, Target) }.
-
-globals__io_get_gc_method(GC_Method) -->
- globals__io_get_globals(Globals),
- { globals__get_gc_method(Globals, GC_Method) }.
-
-globals__io_get_tags_method(Tags_Method) -->
- globals__io_get_globals(Globals),
- { globals__get_tags_method(Globals, Tags_Method) }.
-
-globals__io_get_termination_norm(TerminationNorm) -->
- globals__io_get_globals(Globals),
- { globals__get_termination_norm(Globals, TerminationNorm) }.
+globals__io_get_target(Target, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_target(Globals, Target).
+
+globals__io_get_gc_method(GC_Method, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_gc_method(Globals, GC_Method).
+
+globals__io_get_tags_method(Tags_Method, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_tags_method(Globals, Tags_Method).
+
+globals__io_get_termination_norm(TerminationNorm, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_termination_norm(Globals, TerminationNorm).
globals__io_get_termination2_norm(Termination2Norm, !IO) :-
globals__io_get_globals(Globals, !IO),
globals__get_termination2_norm(Globals, Termination2Norm).
-globals__io_get_trace_level(TraceLevel) -->
- globals__io_get_globals(Globals),
- { globals__get_trace_level(Globals, TraceLevel) }.
-
-globals__io_get_trace_suppress(TraceSuppress) -->
- globals__io_get_globals(Globals),
- { globals__get_trace_suppress(Globals, TraceSuppress) }.
+globals__io_get_trace_level(TraceLevel, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_trace_level(Globals, TraceLevel).
+
+globals__io_get_trace_suppress(TraceSuppress, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_trace_suppress(Globals, TraceSuppress).
globals__io_get_maybe_thread_safe(MaybeThreadSafe, !IO) :-
globals__io_get_globals(Globals, !IO),
globals__get_maybe_thread_safe(Globals, MaybeThreadSafe).
-globals__io_get_globals(Globals) -->
- io__get_globals(UnivGlobals),
- {
- univ_to_type(UnivGlobals, Globals0)
- ->
+globals__io_get_globals(Globals, !IO) :-
+ io__get_globals(UnivGlobals, !IO),
+ ( univ_to_type(UnivGlobals, Globals0) ->
Globals = Globals0
;
error("globals__io_get_globals: univ_to_type failed")
- }.
+ ).
-globals__io_set_globals(Globals) -->
- { type_to_univ(Globals, UnivGlobals) },
- io__set_globals(UnivGlobals).
+globals__io_set_globals(Globals, !IO) :-
+ type_to_univ(Globals, UnivGlobals),
+ io__set_globals(UnivGlobals, !IO).
%-----------------------------------------------------------------------------%
-globals__io_lookup_option(Option, OptionData) -->
- globals__io_get_globals(Globals),
- { globals__get_options(Globals, OptionTable) },
- { map__lookup(OptionTable, Option, OptionData) }.
+globals__io_lookup_option(Option, OptionData, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_options(Globals, OptionTable),
+ map__lookup(OptionTable, Option, OptionData).
-globals__io_set_option(Option, OptionData) -->
- globals__io_get_globals(Globals0),
- { globals__get_options(Globals0, OptionTable0) },
- { map__set(OptionTable0, Option, OptionData, OptionTable) },
- { globals__set_options(OptionTable, Globals0, Globals1) },
+globals__io_set_option(Option, OptionData, !IO) :-
+ globals__io_get_globals(Globals0, !IO),
+ globals__get_options(Globals0, OptionTable0),
+ map__set(OptionTable0, Option, OptionData, OptionTable),
+ globals__set_options(OptionTable, Globals0, Globals1),
% XXX there is a bit of a design flaw with regard to
% uniqueness and io__set_globals
- { unsafe_promise_unique(Globals1, Globals) },
- globals__io_set_globals(Globals).
+ unsafe_promise_unique(Globals1, Globals),
+ globals__io_set_globals(Globals, !IO).
-globals__io_set_gc_method(GC_Method) -->
- globals__io_get_globals(Globals0),
- { globals__set_gc_method(GC_Method, Globals0, Globals1) },
- { unsafe_promise_unique(Globals1, Globals) },
+globals__io_set_gc_method(GC_Method, !IO) :-
+ globals__io_get_globals(Globals0, !IO),
+ globals__set_gc_method(GC_Method, Globals0, Globals1),
+ unsafe_promise_unique(Globals1, Globals),
% XXX there is a bit of a design flaw with regard to
% uniqueness and io__set_globals
- globals__io_set_globals(Globals).
+ globals__io_set_globals(Globals, !IO).
-globals__io_set_tags_method(Tags_Method) -->
- globals__io_get_globals(Globals0),
- { globals__set_tags_method(Tags_Method, Globals0, Globals1) },
- { unsafe_promise_unique(Globals1, Globals) },
+globals__io_set_tags_method(Tags_Method, !IO) :-
+ globals__io_get_globals(Globals0, !IO),
+ globals__set_tags_method(Tags_Method, Globals0, Globals1),
+ unsafe_promise_unique(Globals1, Globals),
% XXX there is a bit of a design flaw with regard to
% uniqueness and io__set_globals
- globals__io_set_globals(Globals).
+ globals__io_set_globals(Globals, !IO).
-globals__io_set_trace_level(TraceLevel) -->
- globals__io_get_globals(Globals0),
- { globals__set_trace_level(TraceLevel, Globals0, Globals1) },
- { unsafe_promise_unique(Globals1, Globals) },
+globals__io_set_trace_level(TraceLevel, !IO) :-
+ globals__io_get_globals(Globals0, !IO),
+ globals__set_trace_level(TraceLevel, Globals0, Globals1),
+ unsafe_promise_unique(Globals1, Globals),
% XXX there is a bit of a design flaw with regard to
% uniqueness and io__set_globals
- globals__io_set_globals(Globals).
+ globals__io_set_globals(Globals, !IO).
% This predicate is needed because mercury_compile.m doesn't know
% anything about type trace_level.
-globals__io_set_trace_level_none -->
- globals__io_set_trace_level(trace_level_none).
+globals__io_set_trace_level_none(!IO) :-
+ globals__io_set_trace_level(trace_level_none, !IO).
%-----------------------------------------------------------------------------%
-globals__io_lookup_foreign_language_option(Option, ForeignLang) -->
- globals__io_lookup_string_option(Option, String),
- { convert_foreign_language(String, ForeignLang0) ->
+globals__io_lookup_foreign_language_option(Option, ForeignLang, !IO) :-
+ globals__io_lookup_string_option(Option, String, !IO),
+ ( convert_foreign_language(String, ForeignLang0) ->
ForeignLang = ForeignLang0
;
error("globals__io_lookup_foreign_language_option: "
++ "invalid foreign_language option")
- }.
+ ).
+
+globals__io_get_backend_foreign_languages(ForeignLangs, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__get_backend_foreign_languages(Globals, ForeignLangs).
-globals__io_get_backend_foreign_languages(ForeignLangs) -->
- globals__io_get_globals(Globals),
- { globals__get_backend_foreign_languages(Globals, ForeignLangs) }.
-
-globals__io_lookup_bool_option(Option, Value) -->
- globals__io_get_globals(Globals),
- { globals__lookup_bool_option(Globals, Option, Value) }.
-
-globals__io_lookup_int_option(Option, Value) -->
- globals__io_get_globals(Globals),
- { globals__lookup_int_option(Globals, Option, Value) }.
-
-globals__io_lookup_string_option(Option, Value) -->
- globals__io_get_globals(Globals),
- { globals__lookup_string_option(Globals, Option, Value) }.
-
-globals__io_lookup_maybe_string_option(Option, Value) -->
- globals__io_get_globals(Globals),
- { globals__lookup_maybe_string_option(Globals, Option, Value) }.
-
-globals__io_lookup_accumulating_option(Option, Value) -->
- globals__io_get_globals(Globals),
- { globals__lookup_accumulating_option(Globals, Option, Value) }.
+globals__io_lookup_bool_option(Option, Value, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__lookup_bool_option(Globals, Option, Value).
+
+globals__io_lookup_int_option(Option, Value, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__lookup_int_option(Globals, Option, Value).
+
+globals__io_lookup_string_option(Option, Value, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__lookup_string_option(Globals, Option, Value).
+
+globals__io_lookup_maybe_string_option(Option, Value, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__lookup_maybe_string_option(Globals, Option, Value).
+
+globals__io_lookup_accumulating_option(Option, Value, !IO) :-
+ globals__io_get_globals(Globals, !IO),
+ globals__lookup_accumulating_option(Globals, Option, Value).
%-----------------------------------------------------------------------------%
Index: handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.233
diff -u -b -r1.233 handle_options.m
--- handle_options.m 3 Aug 2005 08:58:31 -0000 1.233
+++ handle_options.m 31 Aug 2005 02:17:14 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1994-2005 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
@@ -35,6 +37,7 @@
% Process the options, but don't do any post-processing or
% modify the globals. This is mainly useful for separating
% the list of arguments into option and non-option arguments.
+ %
:- pred process_options(list(string)::in, list(string)::out, list(string)::out,
maybe_option_table(option)::out, io::di, io::uo) is det.
@@ -48,22 +51,24 @@
:- pred usage_errors(list(string)::in, io::di, io::uo) is det.
% Display usage message.
+ %
:- pred usage(io::di, io::uo) is det.
- % Display long usage message for help
+ % Display long usage message for help.
+ %
:- pred long_usage(io::di, io::uo) is det.
- % Given the current set of options, figure out
- % which grade to use.
+ % Given the current set of options, figure out which grade to use.
+ %
:- pred compute_grade(globals::in, string::out) is det.
- % The inverse of compute_grade: given a grade,
- % set the appropriate options.
+ % The inverse of compute_grade: given a grade, set the appropriate options.
+ %
:- pred convert_grade_option(string::in, option_table::in, option_table::out)
is semidet.
- % Produce the grade component of grade-specific
- % installation directories.
+ % Produce the grade component of grade-specific installation directories.
+ %
:- pred grade_directory_component(globals::in, string::out) is det.
%-----------------------------------------------------------------------------%
@@ -84,55 +89,60 @@
:- import_module std_util.
:- import_module string.
-handle_options(Args0, Errors, OptionArgs, Args, Link) -->
- % io__write_string("original arguments\n"),
- % dump_arguments(Args0),
- process_options(Args0, OptionArgs, Args, Result),
- % io__write_string("final arguments\n"),
- % dump_arguments(Args),
- postprocess_options(Result, Errors),
+handle_options(Args0, Errors, OptionArgs, Args, Link, !IO) :-
+ % io__write_string("original arguments\n", !IO),
+ % dump_arguments(Args0, !IO),
+ process_options(Args0, OptionArgs, Args, Result, !IO),
+ % io__write_string("final arguments\n", !IO),
+ % dump_arguments(Args, !IO),
+ postprocess_options(Result, Errors, !IO),
(
- { Errors = [_ | _] },
- { Link = no }
+ Errors = [_ | _],
+ Link = no
;
- { Errors = [] },
+ Errors = [],
globals__io_lookup_bool_option(generate_dependencies,
- GenerateDependencies),
- globals__io_lookup_bool_option(make_interface, MakeInterface),
+ GenerateDependencies, !IO),
+ globals__io_lookup_bool_option(make_interface, MakeInterface, !IO),
globals__io_lookup_bool_option(make_private_interface,
- MakePrivateInterface),
+ MakePrivateInterface, !IO),
globals__io_lookup_bool_option(make_short_interface,
- MakeShortInterface),
+ MakeShortInterface, !IO),
globals__io_lookup_bool_option(make_optimization_interface,
- MakeOptimizationInt),
+ MakeOptimizationInt, !IO),
globals__io_lookup_bool_option(make_transitive_opt_interface,
- MakeTransOptInt),
+ MakeTransOptInt, !IO),
globals__io_lookup_bool_option(convert_to_mercury,
- ConvertToMercury),
- globals__io_lookup_bool_option(typecheck_only, TypecheckOnly),
- globals__io_lookup_bool_option(errorcheck_only, ErrorcheckOnly),
+ ConvertToMercury, !IO),
+ globals__io_lookup_bool_option(typecheck_only, TypecheckOnly, !IO),
+ globals__io_lookup_bool_option(errorcheck_only, ErrorcheckOnly, !IO),
globals__io_lookup_bool_option(target_code_only,
- TargetCodeOnly),
- globals__io_get_target(Target),
- { GenerateIL = (if Target = il then yes else no) },
- globals__io_lookup_bool_option(compile_only, CompileOnly),
- globals__io_lookup_bool_option(aditi_only, AditiOnly),
- { bool__or_list([GenerateDependencies, MakeInterface,
+ TargetCodeOnly, !IO),
+ globals__io_get_target(Target, !IO),
+ GenerateIL = (if Target = il then yes else no),
+ globals__io_lookup_bool_option(compile_only, CompileOnly, !IO),
+ globals__io_lookup_bool_option(aditi_only, AditiOnly, !IO),
+ bool__or_list([GenerateDependencies, MakeInterface,
MakePrivateInterface, MakeShortInterface,
MakeOptimizationInt, MakeTransOptInt,
ConvertToMercury, TypecheckOnly,
ErrorcheckOnly, TargetCodeOnly,
GenerateIL, CompileOnly, AditiOnly],
- NotLink) },
- { bool__not(NotLink, Link) },
- globals__io_lookup_bool_option(smart_recompilation, Smart),
- ( { Smart = yes, Link = yes } ->
- % XXX Currently smart recompilation doesn't check
- % that all the files needed to link are present
- % and up-to-date, so disable it.
- disable_smart_recompilation("linking")
+ NotLink),
+ bool__not(NotLink, Link),
+ globals__io_lookup_bool_option(smart_recompilation, Smart, !IO),
+ (
+ Smart = yes,
+ Link = yes
+ ->
+ % XXX Currently smart recompilation doesn't check that all the
+ % files needed to link are present and up-to-date, so disable it.
+ globals__io_get_globals(Globals0, !IO),
+ disable_smart_recompilation("linking", Globals0, Globals1, !IO),
+ unsafe_promise_unique(Globals1, Globals),
+ globals__io_set_globals(Globals, !IO)
;
- []
+ true
)
).
@@ -153,10 +163,10 @@
%-----------------------------------------------------------------------------%
-% Convert string-valued options into the appropriate enumeration types,
-% and process implications among the options (i.e. situations where setting
-% one option implies setting/unsetting another one).
-
+ % Convert string-valued options into the appropriate enumeration types,
+ % and process implications among the options (i.e. situations where setting
+ % one option implies setting/unsetting another one).
+ %
:- pred postprocess_options(maybe_option_table(option)::in,
list(string)::out, io::di, io::uo) is det.
@@ -204,8 +214,8 @@
;
GC_Method = none, % dummy
add_error("Invalid GC option (must be `none', " ++
- "`conservative', `boehm', `mps', `accurate', " ++
- "or `automatic')", !Errors)
+ "`conservative', `boehm', `mps', `accurate', or `automatic')",
+ !Errors)
),
map__lookup(OptionTable0, tags, TagsMethod0),
(
@@ -255,9 +265,7 @@
"`simple', `total' or `num-data-elems').", !Errors)
),
map__lookup(OptionTable0, force_disable_tracing, ForceDisableTracing),
- (
- ForceDisableTracing = bool(yes)
- ->
+ ( ForceDisableTracing = bool(yes) ->
TraceLevel = trace_level_none
;
map__lookup(OptionTable0, trace, Trace),
@@ -293,20 +301,17 @@
TraceSuppress = TraceSuppressPrime
;
TraceSuppress = default_trace_suppress, % dummy
- add_error("Invalid argument to option `--suppress-trace'.",
- !Errors)
+ add_error("Invalid argument to option `--suppress-trace'.", !Errors)
),
map__lookup(OptionTable0, maybe_thread_safe, MaybeThreadSafeOption),
(
MaybeThreadSafeOption = string(MaybeThreadSafeString),
- convert_maybe_thread_safe(MaybeThreadSafeString,
- MaybeThreadSafe0)
+ convert_maybe_thread_safe(MaybeThreadSafeString, MaybeThreadSafe0)
->
MaybeThreadSafe = MaybeThreadSafe0
;
MaybeThreadSafe = no, % dummy
- add_error("Invalid argument to option `--maybe-thread-safe'.",
- !Errors)
+ add_error("Invalid argument to option `--maybe-thread-safe'.", !Errors)
),
map__lookup(OptionTable0, dump_hlds_alias, DumpAliasOption),
(
@@ -322,8 +327,7 @@
OptionTable)
;
OptionTable = OptionTable0, % dummy
- add_error("Invalid argument to option `--hlds-dump-alias'.",
- !Errors)
+ add_error("Invalid argument to option `--hlds-dump-alias'.", !Errors)
).
:- pred add_error(string::in, list(string)::in, list(string)::out) is det.
@@ -342,28 +346,30 @@
io::di, io::uo) is det.
postprocess_options_2(OptionTable0, Target, GC_Method, TagsMethod0,
- TermNorm, Term2Norm, TraceLevel, TraceSuppress,
- MaybeThreadSafe, !Errors) -->
- { unsafe_promise_unique(OptionTable0, OptionTable1) }, % XXX
+ TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe,
+ !Errors, !IO) :-
+ unsafe_promise_unique(OptionTable0, OptionTable1), % XXX
globals__io_init(OptionTable1, Target, GC_Method, TagsMethod0,
- TermNorm, Term2Norm, TraceLevel, TraceSuppress,
- MaybeThreadSafe),
+ TermNorm, Term2Norm, TraceLevel, TraceSuppress, MaybeThreadSafe, !IO),
+
+ some [!Globals] (
+ globals__io_get_globals(!:Globals, !IO),
% Conservative GC implies --no-reclaim-heap-*
- ( { gc_is_conservative(GC_Method) = yes } ->
- globals__io_set_option(
- reclaim_heap_on_semidet_failure, bool(no)),
- globals__io_set_option(
- reclaim_heap_on_nondet_failure, bool(no))
+ ( gc_is_conservative(GC_Method) = yes ->
+ globals__set_option(reclaim_heap_on_semidet_failure, bool(no),
+ !Globals),
+ globals__set_option(reclaim_heap_on_nondet_failure, bool(no),
+ !Globals)
;
- []
+ true
),
% --tags none implies --num-tag-bits 0.
- ( { TagsMethod0 = none } ->
- { NumTagBits0 = 0 }
+ ( TagsMethod0 = none ->
+ NumTagBits0 = 0
;
- globals__io_lookup_int_option(num_tag_bits, NumTagBits0)
+ globals__lookup_int_option(!.Globals, num_tag_bits, NumTagBits0)
),
% if --tags low but --num-tag-bits not specified,
@@ -371,39 +377,40 @@
% (the autoconf-determined value is passed from the `mc' script
% using the undocumented --conf-low-tag-bits option)
(
- { TagsMethod0 = low },
- { NumTagBits0 = -1 }
+ TagsMethod0 = low,
+ NumTagBits0 = -1
->
- globals__io_lookup_int_option(conf_low_tag_bits, NumTagBits1)
+ globals__lookup_int_option(!.Globals, conf_low_tag_bits,
+ NumTagBits1)
;
- { NumTagBits1 = NumTagBits0 }
+ NumTagBits1 = NumTagBits0
),
% if --num-tag-bits negative or unspecified, issue a warning
% and assume --num-tag-bits 0
- ( { NumTagBits1 < 0 } ->
- io__progname_base("mercury_compile", ProgName),
- report_warning(ProgName),
- report_warning(
- ": warning: --num-tag-bits invalid or unspecified\n"),
- io__write_string(ProgName),
- report_warning(": using --num-tag-bits 0 (tags disabled)\n"),
- { NumTagBits = 0 }
+ ( NumTagBits1 < 0 ->
+ io__progname_base("mercury_compile", ProgName, !IO),
+ report_warning(ProgName, !IO),
+ report_warning(": warning: --num-tag-bits invalid or unspecified\n",
+ !IO),
+ io__write_string(ProgName, !IO),
+ report_warning(": using --num-tag-bits 0 (tags disabled)\n", !IO),
+ NumTagBits = 0
;
- { NumTagBits = NumTagBits1 }
+ NumTagBits = NumTagBits1
),
- globals__io_set_option(num_tag_bits, int(NumTagBits)),
- ( { NumTagBits = 0 } ->
- { TagsMethod = none },
- globals__io_set_tags_method(TagsMethod)
+ globals__set_option(num_tag_bits, int(NumTagBits), !Globals),
+ ( NumTagBits = 0 ->
+ TagsMethod = none,
+ globals__set_tags_method(TagsMethod, !Globals)
;
- { TagsMethod = TagsMethod0 }
+ TagsMethod = TagsMethod0
),
- globals__io_lookup_bool_option(highlevel_data, HighLevelData),
- globals__io_lookup_bool_option(automatic_intermodule_optimization,
- AutoIntermodOptimization),
+ globals__lookup_bool_option(!.Globals, highlevel_data, HighLevelData),
+ globals__lookup_bool_option(!.Globals,
+ automatic_intermodule_optimization, AutoIntermodOptimization),
% Generating IL implies:
% - gc_method `automatic' and no heap reclamation on failure
@@ -453,53 +460,61 @@
% intermodule optimization pulls in a lot of code which isn't
% needed, so ensure that this dead code is removed.
- ( { Target = il } ->
- globals__io_set_gc_method(automatic),
- globals__io_set_option(gc, string("automatic")),
- globals__io_set_option(reclaim_heap_on_nondet_failure,
- bool(no)),
- globals__io_set_option(reclaim_heap_on_semidet_failure,
- bool(no)),
- globals__io_set_option(highlevel_code, bool(yes)),
- globals__io_set_option(highlevel_data, bool(yes)),
- globals__io_set_option(gcc_nested_functions, bool(no)),
- globals__io_set_option(nondet_copy_out, bool(yes)),
- globals__io_set_option(num_tag_bits, int(0)),
- globals__io_set_option(unboxed_enums, bool(no)),
- globals__io_set_option(unboxed_no_tag_types, bool(no)),
- % globals__io_set_option(num_reserved_addresses, int(1))
- globals__io_set_option(static_ground_terms, bool(no)),
-
- ( { HighLevelData = yes, AutoIntermodOptimization = yes } ->
- globals__io_set_option(intermodule_optimization,
- bool(yes)),
- globals__io_set_option(optimize_dead_procs, bool(yes))
+ ( Target = il ->
+ globals__set_gc_method(automatic, !Globals),
+ globals__set_option(gc, string("automatic"), !Globals),
+ globals__set_option(reclaim_heap_on_nondet_failure, bool(no),
+ !Globals),
+ globals__set_option(reclaim_heap_on_semidet_failure, bool(no),
+ !Globals),
+ globals__set_option(highlevel_code, bool(yes), !Globals),
+ globals__set_option(highlevel_data, bool(yes), !Globals),
+ globals__set_option(gcc_nested_functions, bool(no), !Globals),
+ globals__set_option(nondet_copy_out, bool(yes), !Globals),
+ globals__set_option(num_tag_bits, int(0), !Globals),
+ globals__set_option(unboxed_enums, bool(no), !Globals),
+ globals__set_option(unboxed_no_tag_types, bool(no), !Globals),
+ % globals__set_option(num_reserved_addresses, int(1), !Globals)
+ globals__set_option(static_ground_terms, bool(no), !Globals),
+
+ (
+ HighLevelData = yes,
+ AutoIntermodOptimization = yes
+ ->
+ globals__set_option(intermodule_optimization, bool(yes),
+ !Globals),
+ globals__set_option(optimize_dead_procs, bool(yes), !Globals)
;
- []
+ true
),
% On the .NET backend we will be using a language independent
% debugger not mdb. Thus --debug has to imply --target-debug.
- ( { given_trace_level_is_none(TraceLevel) = no } ->
- globals__io_set_option(target_debug, bool(yes))
+ ( given_trace_level_is_none(TraceLevel) = no ->
+ globals__set_option(target_debug, bool(yes), !Globals)
;
- []
+ true
)
;
- []
+ true
),
% Set --put-nondet-env-on-heap if --verifiable-code is specified,
% unless both --il-funcptr-types and --il-refany-fields
% are specified.
- globals__io_lookup_bool_option(il_funcptr_types, ILFuncPtrTypes),
- globals__io_lookup_bool_option(il_refany_fields, ILRefAnyFields),
- ( { ILFuncPtrTypes = yes, ILRefAnyFields = yes } ->
- []
+ globals__lookup_bool_option(!.Globals, il_funcptr_types,
+ ILFuncPtrTypes),
+ globals__lookup_bool_option(!.Globals, il_refany_fields,
+ ILRefAnyFields),
+ (
+ ILFuncPtrTypes = yes,
+ ILRefAnyFields = yes
+ ->
+ true
;
- option_implies(verifiable_code, put_nondet_env_on_heap,
- bool(yes))
+ option_implies(verifiable_code, put_nondet_env_on_heap, bool(yes),
+ !Globals)
),
% Generating Java implies
@@ -539,49 +554,55 @@
% - dead procedure optimization
% intermodule optimization pulls in a lot of code which isn't
% needed, so ensure that this dead code is removed.
- ( { Target = java } ->
- globals__io_set_gc_method(automatic),
- globals__io_set_option(gc, string("automatic")),
- globals__io_set_option(reclaim_heap_on_nondet_failure,
- bool(no)),
- globals__io_set_option(reclaim_heap_on_semidet_failure,
- bool(no)),
- globals__io_set_option(highlevel_code, bool(yes)),
- globals__io_set_option(highlevel_data, bool(yes)),
- globals__io_set_option(gcc_nested_functions, bool(no)),
- globals__io_set_option(nondet_copy_out, bool(yes)),
- globals__io_set_option(det_copy_out, bool(yes)),
- globals__io_set_option(num_tag_bits, int(0)),
- globals__io_set_option(unboxed_no_tag_types, bool(no)),
- globals__io_set_option(static_ground_terms, bool(no)),
- globals__io_set_option(put_nondet_env_on_heap, bool(yes)),
-
- ( { AutoIntermodOptimization = yes } ->
- globals__io_set_option(intermodule_optimization,
- bool(yes)),
- globals__io_set_option(optimize_dead_procs, bool(yes))
+
+ ( Target = java ->
+ globals__set_gc_method(automatic, !Globals),
+ globals__set_option(gc, string("automatic"), !Globals),
+ globals__set_option(reclaim_heap_on_nondet_failure, bool(no),
+ !Globals),
+ globals__set_option(reclaim_heap_on_semidet_failure, bool(no),
+ !Globals),
+ globals__set_option(highlevel_code, bool(yes), !Globals),
+ globals__set_option(highlevel_data, bool(yes), !Globals),
+ globals__set_option(gcc_nested_functions, bool(no), !Globals),
+ globals__set_option(nondet_copy_out, bool(yes), !Globals),
+ globals__set_option(det_copy_out, bool(yes), !Globals),
+ globals__set_option(num_tag_bits, int(0), !Globals),
+ globals__set_option(unboxed_no_tag_types, bool(no), !Globals),
+ globals__set_option(static_ground_terms, bool(no), !Globals),
+ globals__set_option(put_nondet_env_on_heap, bool(yes), !Globals),
+
+ (
+ AutoIntermodOptimization = yes,
+ globals__set_option(intermodule_optimization, bool(yes),
+ !Globals),
+ globals__set_option(optimize_dead_procs, bool(yes), !Globals)
;
- []
+ AutoIntermodOptimization = no
)
;
- []
+ true
),
% Generating assembler via the gcc back-end requires
% using high-level code.
- ( { Target = asm } ->
- globals__io_set_option(highlevel_code, bool(yes))
+ ( Target = asm ->
+ globals__set_option(highlevel_code, bool(yes), !Globals)
;
- []
+ true
),
% Generating high-level C or asm code requires putting each commit
% in its own function, to avoid problems with setjmp() and
% non-volatile local variables.
- ( { Target = c ; Target = asm } ->
- option_implies(highlevel_code, put_commit_in_own_func,
- bool(yes))
+ (
+ ( Target = c
+ ; Target = asm
+ )
+ ->
+ option_implies(highlevel_code, put_commit_in_own_func, bool(yes),
+ !Globals)
;
- []
+ true
),
%
@@ -589,140 +610,162 @@
%
% Shared libraries always use `--linkage shared'.
- option_implies(compile_to_shared_lib, pic, bool(yes)),
- option_implies(compile_to_shared_lib, linkage, string("shared")),
+ option_implies(compile_to_shared_lib, pic, bool(yes), !Globals),
+ option_implies(compile_to_shared_lib, linkage, string("shared"),
+ !Globals),
option_implies(compile_to_shared_lib, mercury_linkage,
- string("shared")),
+ string("shared"), !Globals),
% On x86, using PIC takes a register away from us.
- option_implies(pic, pic_reg, bool(yes)),
+ option_implies(pic, pic_reg, bool(yes), !Globals),
% --high-level-code disables the use of low-level gcc extensions
- option_implies(highlevel_code, gcc_non_local_gotos, bool(no)),
- option_implies(highlevel_code, gcc_global_registers, bool(no)),
- option_implies(highlevel_code, asm_labels, bool(no)),
+ option_implies(highlevel_code, gcc_non_local_gotos, bool(no),
+ !Globals),
+ option_implies(highlevel_code, gcc_global_registers, bool(no),
+ !Globals),
+ option_implies(highlevel_code, asm_labels, bool(no), !Globals),
% --no-gcc-nested-functions implies --no-gcc-local-labels
- option_neg_implies(gcc_nested_functions, gcc_local_labels, bool(no)),
+ option_neg_implies(gcc_nested_functions, gcc_local_labels, bool(no),
+ !Globals),
% --no-mlds-optimize implies --no-optimize-tailcalls
- option_neg_implies(optimize, optimize_tailcalls, bool(no)),
+ option_neg_implies(optimize, optimize_tailcalls, bool(no), !Globals),
% --rebuild is just like --make but always rebuilds the files
% without checking timestamps.
- option_implies(rebuild, make, bool(yes)),
+ option_implies(rebuild, make, bool(yes), !Globals),
% make.m controls generating object code and linking itself,
% so mercury_compile.m should only generate target code when
% given a module to process.
- option_implies(make, compile_only, bool(yes)),
- option_implies(make, target_code_only, bool(yes)),
+ option_implies(make, compile_only, bool(yes), !Globals),
+ option_implies(make, target_code_only, bool(yes), !Globals),
% This is needed for library installation (the library grades
% are built using `--use-grade-subdirs', and assume that
% the interface files were built using `--use-subdirs').
- option_implies(make, use_subdirs, bool(yes)),
- option_implies(invoked_by_mmc_make, use_subdirs, bool(yes)),
- option_implies(invoked_by_mmc_make, make, bool(no)),
+ option_implies(make, use_subdirs, bool(yes), !Globals),
+ option_implies(invoked_by_mmc_make, use_subdirs, bool(yes), !Globals),
+ option_implies(invoked_by_mmc_make, make, bool(no), !Globals),
% --make handles creation of the module dependencies itself,
% and they don't need to be recreated when compiling to C.
option_implies(invoked_by_mmc_make,
- generate_mmc_make_module_dependencies, bool(no)),
+ generate_mmc_make_module_dependencies, bool(no), !Globals),
% --make does not handle --transitive-intermodule-optimization.
% --transitive-intermodule-optimization is in the process of
% being rewritten anyway.
- option_implies(make, transitive_optimization, bool(no)),
- option_implies(invoked_by_mmc_make, transitive_optimization, bool(no)),
+ option_implies(make, transitive_optimization, bool(no), !Globals),
+ option_implies(invoked_by_mmc_make, transitive_optimization, bool(no),
+ !Globals),
- ( { \+ io__have_symlinks } ->
- globals__io_set_option(use_symlinks, bool(no))
+ ( io__have_symlinks ->
+ true
;
- []
+ globals__set_option(use_symlinks, bool(no), !Globals)
),
- option_implies(verbose_check_termination, check_termination,bool(yes)),
- option_implies(check_termination, termination, bool(yes)),
+ option_implies(verbose_check_termination, check_termination,bool(yes),
+ !Globals),
+ option_implies(check_termination, termination, bool(yes), !Globals),
option_implies(check_termination, warn_missing_trans_opt_files,
- bool(yes)),
+ bool(yes), !Globals),
option_implies(verbose_check_termination2, check_termination2,
- bool(yes)),
- option_implies(check_termination2, termination2, bool(yes)),
+ bool(yes), !Globals),
+ option_implies(check_termination2, termination2, bool(yes), !Globals),
option_implies(check_termination2, warn_missing_trans_opt_files,
- bool(yes)),
+ bool(yes), !Globals),
option_implies(make_transitive_opt_interface, transitive_optimization,
- bool(yes)),
+ bool(yes), !Globals),
option_implies(transitive_optimization, intermodule_optimization,
- bool(yes)),
- option_implies(use_trans_opt_files, use_opt_files, bool(yes)),
+ bool(yes), !Globals),
+ option_implies(use_trans_opt_files, use_opt_files, bool(yes),
+ !Globals),
% If we are doing full inter-module or transitive optimization,
% we need to build all `.opt' or `.trans_opt' files.
- option_implies(intermodule_optimization, use_opt_files, bool(no)),
- option_implies(transitive_optimization, use_trans_opt_files, bool(no)),
+ option_implies(intermodule_optimization, use_opt_files, bool(no),
+ !Globals),
+ option_implies(transitive_optimization, use_trans_opt_files, bool(no),
+ !Globals),
% XXX `--use-opt-files' is broken.
% When inter-module optimization is enabled, error checking
% without the extra information from the `.opt' files
% is done when making the `.opt' file. With `--use-opt-files',
% that doesn't happen.
- globals__io_set_option(use_opt_files, bool(no)),
+ globals__set_option(use_opt_files, bool(no), !Globals),
option_implies(smart_recompilation, generate_item_version_numbers,
- bool(yes)),
+ bool(yes), !Globals),
option_implies(find_all_recompilation_reasons, verbose_recompilation,
- bool(yes)),
+ bool(yes), !Globals),
%
% Disable `--smart-recompilation' for compilation options
% which either do not produce a compiled output file or
% for which smart recompilation will not work.
%
- option_implies(generate_dependencies, smart_recompilation, bool(no)),
- option_implies(convert_to_mercury, smart_recompilation, bool(no)),
- option_implies(make_private_interface, smart_recompilation, bool(no)),
- option_implies(make_interface, smart_recompilation, bool(no)),
- option_implies(make_short_interface, smart_recompilation, bool(no)),
- option_implies(output_grade_string, smart_recompilation, bool(no)),
+ option_implies(generate_dependencies, smart_recompilation, bool(no),
+ !Globals),
+ option_implies(convert_to_mercury, smart_recompilation, bool(no),
+ !Globals),
+ option_implies(make_private_interface, smart_recompilation, bool(no),
+ !Globals),
+ option_implies(make_interface, smart_recompilation, bool(no),
+ !Globals),
+ option_implies(make_short_interface, smart_recompilation, bool(no),
+ !Globals),
+ option_implies(output_grade_string, smart_recompilation, bool(no),
+ !Globals),
option_implies(make_optimization_interface,
- smart_recompilation, bool(no)),
+ smart_recompilation, bool(no), !Globals),
option_implies(make_transitive_opt_interface,
- smart_recompilation, bool(no)),
- option_implies(errorcheck_only, smart_recompilation, bool(no)),
- option_implies(typecheck_only, smart_recompilation, bool(no)),
+ smart_recompilation, bool(no), !Globals),
+ option_implies(errorcheck_only, smart_recompilation, bool(no),
+ !Globals),
+ option_implies(typecheck_only, smart_recompilation, bool(no),
+ !Globals),
% disable --line-numbers when building the `.int', `.opt', etc. files,
% since including line numbers in those would cause unnecessary
% recompilation
- option_implies(make_private_interface, line_numbers, bool(no)),
- option_implies(make_interface, line_numbers, bool(no)),
- option_implies(make_short_interface, line_numbers, bool(no)),
- option_implies(make_optimization_interface, line_numbers, bool(no)),
- option_implies(make_transitive_opt_interface, line_numbers, bool(no)),
+ option_implies(make_private_interface, line_numbers, bool(no),
+ !Globals),
+ option_implies(make_interface, line_numbers, bool(no),
+ !Globals),
+ option_implies(make_short_interface, line_numbers, bool(no),
+ !Globals),
+ option_implies(make_optimization_interface, line_numbers, bool(no),
+ !Globals),
+ option_implies(make_transitive_opt_interface, line_numbers, bool(no),
+ !Globals),
% `--aditi-only' is only used by the Aditi query shell,
% for queries which should only be compiled once.
% recompilation_check.m currently doesn't check whether
% the `.rlo' file is up to date (with `--no-aditi-only' the
- % Aditi-RL bytecode is embedded in the `.c' file.
- option_implies(aditi_only, smart_recompilation, bool(no)),
+ % Aditi-RL bytecode is embedded in the `.c' file).
+ option_implies(aditi_only, smart_recompilation, bool(no), !Globals),
% We never use version number information in `.int3',
% `.opt' or `.trans_opt' files.
option_implies(make_short_interface, generate_item_version_numbers,
- bool(no)),
+ bool(no), !Globals),
% XXX Smart recompilation does not yet work with inter-module
% optimization, but we still want to generate version numbers
% in interface files for users of a library compiled with
% inter-module optimization but not using inter-module
% optimization themselves.
- globals__io_lookup_bool_option(smart_recompilation, Smart),
+ globals__lookup_bool_option(!.Globals, smart_recompilation, Smart),
maybe_disable_smart_recompilation(Smart, intermodule_optimization, yes,
- "`--intermodule-optimization'"),
+ "`--intermodule-optimization'", !Globals, !IO),
maybe_disable_smart_recompilation(Smart, use_opt_files, yes,
- "`--use-opt-files'"),
+ "`--use-opt-files'", !Globals, !IO),
% XXX Smart recompilation does not yet work with
% `--no-target-code-only'. With `--no-target-code-only'
@@ -731,79 +774,85 @@
% By default, mmake always enables `--target-code-only' and
% processes the target code file itself, so this isn't a problem.
maybe_disable_smart_recompilation(Smart, target_code_only, no,
- "`--no-target-code-only'"),
+ "`--no-target-code-only'", !Globals, !IO),
- option_implies(use_grade_subdirs, use_subdirs, bool(yes)),
+ option_implies(use_grade_subdirs, use_subdirs, bool(yes), !Globals),
- option_implies(very_verbose, verbose, bool(yes)),
- option_implies(verbose, verbose_commands, bool(yes)),
+ option_implies(very_verbose, verbose, bool(yes), !Globals),
+ option_implies(verbose, verbose_commands, bool(yes), !Globals),
- option_implies(debug_modes_minimal, debug_modes, bool(yes)),
- option_implies(debug_modes_verbose, debug_modes, bool(yes)),
- option_implies(debug_modes_statistics, debug_modes, bool(yes)),
+ option_implies(debug_modes_minimal, debug_modes, bool(yes), !Globals),
+ option_implies(debug_modes_verbose, debug_modes, bool(yes), !Globals),
+ option_implies(debug_modes_statistics, debug_modes, bool(yes),
+ !Globals),
- globals__io_lookup_int_option(debug_liveness, DebugLiveness),
+ globals__lookup_int_option(!.Globals, debug_liveness, DebugLiveness),
(
- { DebugLiveness >= 0 },
- { convert_dump_alias("all", AllDumpOptions) }
+ DebugLiveness >= 0,
+ convert_dump_alias("all", AllDumpOptions)
->
% Programmers only enable --debug-liveness if they are
% interested in the goal annotations put on goals by
% the various phases of the liveness pass. The default
% dump options do not print these annotations.
- globals__io_lookup_string_option(dump_hlds_options,
+ globals__lookup_string_option(!.Globals, dump_hlds_options,
DumpOptions0),
- { string__append(DumpOptions0, AllDumpOptions, DumpOptions1) },
- globals__io_set_option(dump_hlds_options, string(DumpOptions1))
+ string__append(DumpOptions0, AllDumpOptions, DumpOptions1),
+ globals__set_option(dump_hlds_options, string(DumpOptions1),
+ !Globals)
;
- []
+ true
),
- option_implies(debug_modes_verbose, debug_modes, bool(yes)),
- globals__io_lookup_int_option(debug_modes_pred_id, DebugModesPredId),
- ( { DebugModesPredId > 0 } ->
- globals__io_set_option(debug_modes, bool(yes))
+ option_implies(debug_modes_verbose, debug_modes, bool(yes), !Globals),
+ globals__lookup_int_option(!.Globals, debug_modes_pred_id,
+ DebugModesPredId),
+ ( DebugModesPredId > 0 ->
+ globals__set_option(debug_modes, bool(yes), !Globals)
;
- []
+ true
),
- globals__io_lookup_int_option(debug_opt_pred_id, DebugOptPredId),
- ( { DebugOptPredId > 0 } ->
- globals__io_set_option(debug_opt, bool(yes))
+ globals__lookup_int_option(!.Globals, debug_opt_pred_id,
+ DebugOptPredId),
+ ( DebugOptPredId > 0 ->
+ globals__set_option(debug_opt, bool(yes), !Globals)
;
- []
+ true
),
- globals__io_lookup_int_option(dump_hlds_pred_id, DumpHLDSPredId),
- ( { DumpHLDSPredId >= 0 } ->
- globals__io_lookup_string_option(dump_hlds_options,
+ globals__lookup_int_option(!.Globals, dump_hlds_pred_id,
+ DumpHLDSPredId),
+ ( DumpHLDSPredId >= 0 ->
+ globals__lookup_string_option(!.Globals, dump_hlds_options,
DumpOptions2),
% Prevent the dumping of the mode and type tables.
- { string__replace_all(DumpOptions2, "M", "", DumpOptions3) },
- { string__replace_all(DumpOptions3, "T", "", DumpOptions) },
- globals__io_set_option(dump_hlds_options, string(DumpOptions))
+ string__replace_all(DumpOptions2, "M", "", DumpOptions3),
+ string__replace_all(DumpOptions3, "T", "", DumpOptions),
+ globals__set_option(dump_hlds_options, string(DumpOptions),
+ !Globals)
;
- []
+ true
),
% --split-c-files is not supported by the high-level C code generator.
- option_implies(highlevel_code, split_c_files, bool(no)),
+ option_implies(highlevel_code, split_c_files, bool(no), !Globals),
% --split-c-files implies --procs-per-c-function 1
- option_implies(split_c_files, procs_per_c_function, int(1)),
+ option_implies(split_c_files, procs_per_c_function, int(1), !Globals),
% Minimal model tabling is not compatible with high level code
% or with trailing; see the comments in runtime/mercury_grade.h.
- globals__io_lookup_bool_option(use_trail, UseTrail),
- globals__io_lookup_bool_option(highlevel_code, HighLevel),
- globals__io_lookup_bool_option(use_minimal_model_stack_copy,
+ globals__lookup_bool_option(!.Globals, use_trail, UseTrail),
+ globals__lookup_bool_option(!.Globals, highlevel_code, HighLevel),
+ globals__lookup_bool_option(!.Globals, use_minimal_model_stack_copy,
UseMinimalModelStackCopy),
- globals__io_lookup_bool_option(use_minimal_model_own_stacks,
+ globals__lookup_bool_option(!.Globals, use_minimal_model_own_stacks,
UseMinimalModelOwnStacks),
- { bool__or(UseMinimalModelStackCopy, UseMinimalModelOwnStacks,
- UseMinimalModel) },
- {
+ bool__or(UseMinimalModelStackCopy, UseMinimalModelOwnStacks,
+ UseMinimalModel),
+ (
UseMinimalModelStackCopy = yes,
UseMinimalModelOwnStacks = yes
->
@@ -823,30 +872,31 @@
"with trailing", !Errors)
;
true
- },
+ ),
- option_implies(target_debug, strip, bool(no)),
+ option_implies(target_debug, strip, bool(no), !Globals),
% Inlining happens before the deep profiling transformation, so if
% we allowed inlining to happen, then we would lose all profiling
% information about the inlined calls.
- option_implies(profile_deep, allow_inlining, bool(no)),
+ option_implies(profile_deep, allow_inlining, bool(no), !Globals),
- globals__io_lookup_string_option(experimental_complexity, ExpComp),
- ( { ExpComp = "" } ->
- { true }
+ globals__lookup_string_option(!.Globals, experimental_complexity,
+ ExpComp),
+ ( ExpComp = "" ->
+ true
;
- globals__io_set_option(allow_inlining, bool(no))
+ globals__set_option(allow_inlining, bool(no), !Globals)
),
% --decl-debug is an extension of --debug
- option_implies(decl_debug, exec_trace, bool(yes)),
+ option_implies(decl_debug, exec_trace, bool(yes), !Globals),
% We need to be able to simulate exits for calls between where an
% exception is thrown to where it is caught both in the debugger and
% for deep profiling.
- option_implies(exec_trace, stack_trace, bool(yes)),
- option_implies(profile_deep, stack_trace, bool(yes)),
+ option_implies(exec_trace, stack_trace, bool(yes), !Globals),
+ option_implies(profile_deep, stack_trace, bool(yes), !Globals),
% The `.debug' grade implies --use-trail in most cases. The reason
% for the implication is to avoid unnecessary proliferation in
@@ -864,22 +914,28 @@
% space overhead of trailing (mostly for extra code) as well unless the
% user has explicitly requested it.
- globals__io_lookup_bool_option(exec_trace, ExecTrace),
- globals__io_lookup_bool_option(decl_debug, DeclDebug),
- ( { ExecTrace = yes, DeclDebug = no, UseMinimalModel = no } ->
- globals__io_set_option(use_trail, bool(yes))
+ globals__lookup_bool_option(!.Globals, exec_trace, ExecTrace),
+ globals__lookup_bool_option(!.Globals, decl_debug, DeclDebug),
+ (
+ ExecTrace = yes,
+ DeclDebug = no,
+ UseMinimalModel = no
+ ->
+ globals__set_option(use_trail, bool(yes), !Globals)
;
- []
+ true
),
% In debugging grades, we want to generate executables in which
% one can do retries across I/O safely.
- option_implies(exec_trace, trace_table_io_all, bool(yes)),
+ option_implies(exec_trace, trace_table_io_all, bool(yes), !Globals),
% --trace-table-io-all is compulsory application of --trace-table-io
- option_implies(trace_table_io_all, trace_table_io, bool(yes)),
+ option_implies(trace_table_io_all, trace_table_io, bool(yes),
+ !Globals),
% --trace-table-io-require is compulsory application of --trace-table-io
- option_implies(trace_table_io_require, trace_table_io, bool(yes)),
+ option_implies(trace_table_io_require, trace_table_io, bool(yes),
+ !Globals),
% Execution tracing requires
% - disabling optimizations that would change
@@ -888,46 +944,46 @@
% paths across optimization levels
% - enabling stack layouts
% - enabling typeinfo liveness
- globals__io_lookup_bool_option(trace_optimized, TraceOptimized),
- ( { given_trace_level_is_none(TraceLevel) = no } ->
+ globals__lookup_bool_option(!.Globals, trace_optimized,
+ TraceOptimized),
+ ( given_trace_level_is_none(TraceLevel) = no ->
(
- { TraceOptimized = no },
+ TraceOptimized = no,
% The following options modify the structure
% of the program, which makes it difficult to
% relate the trace to the source code (although
% it can be easily related to the transformed HLDS).
- globals__io_set_option(allow_inlining, bool(no)),
- globals__io_set_option(optimize_unused_args, bool(no)),
- globals__io_set_option(optimize_higher_order, bool(no)),
- globals__io_set_option(type_specialization, bool(no)),
- globals__io_set_option(user_guided_type_specialization,
- bool(no)),
- globals__io_set_option(deforestation, bool(no)),
- globals__io_set_option(constraint_propagation,
- bool(no)),
- globals__io_set_option(local_constraint_propagation,
- bool(no)),
- globals__io_set_option(optimize_duplicate_calls,
- bool(no)),
- globals__io_set_option(optimize_constructor_last_call,
- bool(no)),
- globals__io_set_option(optimize_saved_vars_cell,
- bool(no)),
- globals__io_set_option(loop_invariants, bool(no)),
- globals__io_set_option(untuple, bool(no)),
- globals__io_set_option(tuple, bool(no)),
+ globals__set_option(allow_inlining, bool(no), !Globals),
+ globals__set_option(optimize_unused_args, bool(no), !Globals),
+ globals__set_option(optimize_higher_order, bool(no), !Globals),
+ globals__set_option(type_specialization, bool(no), !Globals),
+ globals__set_option(user_guided_type_specialization,
+ bool(no), !Globals),
+ globals__set_option(deforestation, bool(no), !Globals),
+ globals__set_option(constraint_propagation,
+ bool(no), !Globals),
+ globals__set_option(local_constraint_propagation,
+ bool(no), !Globals),
+ globals__set_option(optimize_duplicate_calls,
+ bool(no), !Globals),
+ globals__set_option(optimize_constructor_last_call,
+ bool(no), !Globals),
+ globals__set_option(optimize_saved_vars_cell,
+ bool(no), !Globals),
+ globals__set_option(loop_invariants, bool(no), !Globals),
+ globals__set_option(untuple, bool(no), !Globals),
+ globals__set_option(tuple, bool(no), !Globals),
% For the IL backend we turn off optimize_peep
% so that we don't optimize away references to the
% local variables of a procedure.
- ( { Target = il } ->
- globals__io_set_option(optimize_peep,
- bool(no))
+ ( Target = il ->
+ globals__set_option(optimize_peep, bool(no), !Globals)
;
- []
+ true
)
;
- { TraceOptimized = yes }
+ TraceOptimized = yes
),
% Disable hijacks if debugging is enabled. The
@@ -953,96 +1009,99 @@
% hijacks, it would be slower as well, except in
% procedures that would have many nested hijacks,
% and such code is extremely rare.
- globals__io_set_option(allow_hijacks, bool(no)),
+ globals__set_option(allow_hijacks, bool(no), !Globals),
% The following option prevents useless variables
% from cluttering the trace. Its explicit setting
% removes a source of variability in the goal paths
% reported by tracing.
- globals__io_set_option(excess_assign, bool(yes)),
+ globals__set_option(excess_assign, bool(yes), !Globals),
% The explicit setting of the following option
% removes a source of variability in the goal paths
% reported by tracing.
- globals__io_set_option(follow_code, bool(yes)),
+ globals__set_option(follow_code, bool(yes), !Globals),
% The following option selects a special-case
% code generator that cannot (yet) implement tracing.
- globals__io_set_option(middle_rec, bool(no)),
+ globals__set_option(middle_rec, bool(no), !Globals),
% The following options cause the info required
% by tracing to be generated.
- globals__io_set_option(trace_stack_layout, bool(yes)),
- globals__io_set_option(body_typeinfo_liveness, bool(yes)),
+ globals__set_option(trace_stack_layout, bool(yes), !Globals),
+ globals__set_option(body_typeinfo_liveness, bool(yes), !Globals),
% To support up-level printing, we need to save
% variables across a call even if the call cannot
% succeed.
- globals__io_set_option(opt_no_return_calls, bool(no))
+ globals__set_option(opt_no_return_calls, bool(no), !Globals)
;
- []
+ true
),
- option_implies(profile_deep, procid_stack_layout, bool(yes)),
- globals__io_lookup_bool_option(profile_deep, ProfileDeep),
- ( { ProfileDeep = yes } ->
+ option_implies(profile_deep, procid_stack_layout, bool(yes), !Globals),
+ globals__lookup_bool_option(!.Globals, profile_deep, ProfileDeep),
+ (
+ ProfileDeep = yes,
(
- { HighLevel = no },
- { Target = c }
+ HighLevel = no,
+ Target = c
->
- []
+ true
;
- { add_error("deep profiling is incompatible " ++
- "with high level code", !Errors) }
+ add_error("deep profiling is incompatible " ++
+ "with high level code", !Errors)
),
- globals__io_lookup_bool_option(
+ globals__lookup_bool_option(!.Globals,
use_lots_of_ho_specialization, LotsOfHOSpec),
- ( { LotsOfHOSpec = yes } ->
- { True = bool(yes) },
- globals__io_set_option(optimize_higher_order, True),
- globals__io_set_option(higher_order_size_limit,
- int(999999))
+ (
+ LotsOfHOSpec = yes,
+ True = bool(yes),
+ globals__set_option(optimize_higher_order, True, !Globals),
+ globals__set_option(higher_order_size_limit, int(999999),
+ !Globals)
;
- []
+ LotsOfHOSpec = no
)
;
- []
+ ProfileDeep = no
),
- globals__io_lookup_bool_option(record_term_sizes_as_words,
+ globals__lookup_bool_option(!.Globals, record_term_sizes_as_words,
RecordTermSizesAsWords),
- globals__io_lookup_bool_option(record_term_sizes_as_cells,
+ globals__lookup_bool_option(!.Globals, record_term_sizes_as_cells,
RecordTermSizesAsCells),
(
- { RecordTermSizesAsWords = yes },
- { RecordTermSizesAsCells = yes }
+ RecordTermSizesAsWords = yes,
+ RecordTermSizesAsCells = yes
->
- { add_error("we can't record term size " ++
- "as both words and cells", !Errors) }
+ add_error("we can't record term size " ++
+ "as both words and cells", !Errors)
;
- { RecordTermSizesAsWords = yes
+ ( RecordTermSizesAsWords = yes
; RecordTermSizesAsCells = yes
- },
- { HighLevel = yes }
+ ),
+ HighLevel = yes
->
- { add_error("term size profiling is incompatible "
- ++ "with high level code", !Errors) }
+ add_error("term size profiling is incompatible "
+ ++ "with high level code", !Errors)
;
- []
+ true
),
(
- { given_trace_level_is_none(TraceLevel) = yes
+ ( given_trace_level_is_none(TraceLevel) = yes
; HighLevel = no, Target = c
; Target = il
- }
+ )
->
- []
+ true
;
- { add_error("debugging is available only in " ++
- "low level C grades", !Errors) }
+ add_error("debugging is available only in " ++
+ "low level C grades", !Errors)
),
% The pthreads headers on some architectures (Solaris, Linux)
% don't work with -ansi.
- option_implies(parallel, ansi_c, bool(no)),
+ option_implies(parallel, ansi_c, bool(no), !Globals),
- option_neg_implies(inline_builtins, constant_propagation, bool(no)),
+ option_neg_implies(inline_builtins, constant_propagation, bool(no),
+ !Globals),
% `--optimize-constant-propagation' effectively inlines builtins.
%
@@ -1054,25 +1113,28 @@
% `--no-optimize-constant-propagation' otherwise,
% e.g. when tracing is enabled.
%
- ( { ProfileDeep = no } ->
- option_neg_implies(allow_inlining, constant_propagation,
- bool(no))
+ (
+ ProfileDeep = no,
+ option_neg_implies(allow_inlining, constant_propagation, bool(no),
+ !Globals)
;
- []
+ ProfileDeep = yes
),
% --no-reorder-conj implies --no-deforestation,
% --no-constraint-propagation and --no-local-constraint-propagation.
- option_neg_implies(reorder_conj, deforestation, bool(no)),
- option_neg_implies(reorder_conj, constraint_propagation, bool(no)),
+ option_neg_implies(reorder_conj, deforestation, bool(no), !Globals),
+ option_neg_implies(reorder_conj, constraint_propagation, bool(no),
+ !Globals),
option_neg_implies(reorder_conj, local_constraint_propagation,
- bool(no)),
+ bool(no), !Globals),
% --stack-trace requires `procid' stack layouts
- option_implies(stack_trace, procid_stack_layout, bool(yes)),
+ option_implies(stack_trace, procid_stack_layout, bool(yes), !Globals),
% `trace' stack layouts need `procid' stack layouts
- option_implies(trace_stack_layout, procid_stack_layout, bool(yes)),
+ option_implies(trace_stack_layout, procid_stack_layout, bool(yes),
+ !Globals),
% --gc accurate for the LLDS back-end requires `agc' stack layouts,
% typeinfo liveness, and needs hijacks, frameopt, and middle recursion
@@ -1109,67 +1171,70 @@
% XXX we also disable type specialization.
% This is needed because type specialization may create
% type class constraints of the form `c(t(T))'
- % (e.g. `enum(var(T)'' in library/sparse_bitset.m),
+ % (e.g. `enum(var(T))'' in library/sparse_bitset.m),
% which the current RTTI system can't handle.
%
- ( { GC_Method = accurate } ->
- globals__io_set_option(agc_stack_layout, bool(yes)),
- globals__io_set_option(body_typeinfo_liveness, bool(yes)),
- globals__io_set_option(allow_hijacks, bool(no)),
- globals__io_set_option(optimize_frames, bool(no)),
- globals__io_set_option(opt_no_return_calls, bool(no)),
- globals__io_set_option(middle_rec, bool(no)),
- globals__io_set_option(
- reclaim_heap_on_semidet_failure, bool(no)),
- globals__io_set_option(
- reclaim_heap_on_nondet_failure, bool(no)),
+ ( GC_Method = accurate ->
+ globals__set_option(agc_stack_layout, bool(yes), !Globals),
+ globals__set_option(body_typeinfo_liveness, bool(yes), !Globals),
+ globals__set_option(allow_hijacks, bool(no), !Globals),
+ globals__set_option(optimize_frames, bool(no), !Globals),
+ globals__set_option(opt_no_return_calls, bool(no), !Globals),
+ globals__set_option(middle_rec, bool(no), !Globals),
+ globals__set_option(
+ reclaim_heap_on_semidet_failure, bool(no), !Globals),
+ globals__set_option(
+ reclaim_heap_on_nondet_failure, bool(no), !Globals),
option_implies(highlevel_code, optimize_higher_order,
- bool(no)),
+ bool(no), !Globals),
- globals__io_set_option(type_specialization, bool(no)),
- globals__io_set_option(user_guided_type_specialization,
- bool(no))
+ globals__set_option(type_specialization, bool(no), !Globals),
+ globals__set_option(user_guided_type_specialization,
+ bool(no), !Globals)
;
- []
+ true
),
% ml_gen_params_base and ml_declare_env_ptr_arg, in ml_code_util.m,
% both assume (for accurate GC) that continuation environments
% are always allocated on the stack, which means that things won't
% if --gc accurate and --put-nondet-env-on-heap are both enabled.
- globals__io_lookup_bool_option(put_nondet_env_on_heap,
+ globals__lookup_bool_option(!.Globals, put_nondet_env_on_heap,
PutNondetEnvOnHeap),
(
- { HighLevel = yes },
- { GC_Method = accurate },
- { PutNondetEnvOnHeap = yes }
+ HighLevel = yes,
+ GC_Method = accurate,
+ PutNondetEnvOnHeap = yes
->
- { add_error("--gc accurate is incompatible with " ++
- "--put-nondet-env-on-heap", !Errors) }
+ add_error("--gc accurate is incompatible with " ++
+ "--put-nondet-env-on-heap", !Errors)
;
- []
+ true
),
% `procid' and `agc' stack layouts need `basic' stack layouts
- option_implies(procid_stack_layout, basic_stack_layout, bool(yes)),
- option_implies(agc_stack_layout, basic_stack_layout, bool(yes)),
+ option_implies(procid_stack_layout, basic_stack_layout, bool(yes),
+ !Globals),
+ option_implies(agc_stack_layout, basic_stack_layout, bool(yes),
+ !Globals),
% dupelim.m doesn't preserve label layout structures
% (e.g. it can change the return address in a call
% to a different label whose code is the same but
% which has a different label layout structure),
% so we need to disable it when tracing.
- option_implies(procid_stack_layout, optimize_dups, bool(no)),
+ option_implies(procid_stack_layout, optimize_dups, bool(no), !Globals),
% likewise for accurate GC
- option_implies(agc_stack_layout, optimize_dups, bool(no)),
+ option_implies(agc_stack_layout, optimize_dups, bool(no), !Globals),
% XXX deforestation and constraint propagation do not perform
% folding on polymorphic predicates correctly with
% --body-typeinfo-liveness.
- option_implies(body_typeinfo_liveness, deforestation, bool(no)),
+ option_implies(body_typeinfo_liveness, deforestation, bool(no),
+ !Globals),
option_implies(body_typeinfo_liveness, constraint_propagation,
- bool(no)),
+ bool(no), !Globals),
% XXX if trailing is enabled, middle recursion optimization
% can generate code which does not allocate a stack frame
@@ -1177,7 +1242,7 @@
% trail, if the code being optimized contains a construct which
% might save/restore the trail state, i.e. an if-then-else,
% negation, disjunction, or commit.
- option_implies(use_trail, middle_rec, bool(no)),
+ option_implies(use_trail, middle_rec, bool(no), !Globals),
% Stack copy minimal model tabling needs to be able to rewrite all
% the redoips in a given nondet stack segments. If we allow hijacks,
@@ -1186,7 +1251,8 @@
% Since we want to allow tabling in grades that do not have label
% layout info, we disable hijacks instead.
% XXX we should allow hijacks in table_builtin.m
- option_implies(use_minimal_model_stack_copy, allow_hijacks, bool(no)),
+ option_implies(use_minimal_model_stack_copy, allow_hijacks, bool(no),
+ !Globals),
% Stack copy minimal model tabling needs to generate extra code
% at possibly negated contexts to handle the pneg stack and at commits
@@ -1194,157 +1260,166 @@
% these extra pieces of code to be disabled. The disabled program will
% work only if the program doesn't actually use minimal model tabling,
% which makes it useful only for performance testing.
- globals__io_lookup_bool_option(disable_minimal_model_stack_copy_pneg,
- DisablePneg),
- globals__io_lookup_bool_option(disable_minimal_model_stack_copy_cut,
+ globals__lookup_bool_option(!.Globals,
+ disable_minimal_model_stack_copy_pneg, DisablePneg),
+ globals__lookup_bool_option(!.Globals,
+ disable_minimal_model_stack_copy_cut,
DisableCut),
(
- { UseMinimalModelStackCopy = yes },
- { DisablePneg = no }
+ UseMinimalModelStackCopy = yes,
+ DisablePneg = no
->
- globals__io_set_option(use_minimal_model_stack_copy_pneg,
- bool(yes))
+ globals__set_option(use_minimal_model_stack_copy_pneg,
+ bool(yes), !Globals)
;
- []
+ true
),
(
- { UseMinimalModelStackCopy = yes },
- { DisableCut = no }
+ UseMinimalModelStackCopy = yes,
+ DisableCut = no
->
- globals__io_set_option(use_minimal_model_stack_copy_cut,
- bool(yes))
+ globals__set_option(use_minimal_model_stack_copy_cut,
+ bool(yes), !Globals)
;
- []
+ true
),
% --dump-hlds and --statistics require compilation by phases
- globals__io_lookup_accumulating_option(dump_hlds, DumpStages),
- globals__io_lookup_bool_option(statistics, Statistics),
- ( { DumpStages \= [] ; Statistics = yes } ->
- globals__io_set_option(trad_passes, bool(no))
+ globals__lookup_accumulating_option(!.Globals, dump_hlds, DumpStages),
+ globals__lookup_bool_option(!.Globals, statistics, Statistics),
+ (
+ ( DumpStages = [_ | _]
+ ; Statistics = yes
+ )
+ ->
+ globals__set_option(trad_passes, bool(no), !Globals)
;
- []
+ true
),
% If we are doing type-specialization, we may as well take
% advantage of the declarations supplied by the programmer.
option_implies(type_specialization, user_guided_type_specialization,
- bool(yes)),
+ bool(yes), !Globals),
% The local constraint propagation transformation (constraint.m)
% is a required part of the constraint propagation transformation
% performed by deforest.m.
option_implies(constraint_propagation, local_constraint_propagation,
- bool(yes)),
+ bool(yes), !Globals),
% --intermod-unused-args implies --intermodule-optimization and
% --optimize-unused-args.
option_implies(intermod_unused_args, intermodule_optimization,
- bool(yes)),
- option_implies(intermod_unused_args, optimize_unused_args, bool(yes)),
+ bool(yes), !Globals),
+ option_implies(intermod_unused_args, optimize_unused_args, bool(yes),
+ !Globals),
% --introduce-accumulators implies --excess-assign and
% --common-struct.
- option_implies(introduce_accumulators, excess_assign, bool(yes)),
- option_implies(introduce_accumulators, common_struct, bool(yes)),
+ option_implies(introduce_accumulators, excess_assign, bool(yes),
+ !Globals),
+ option_implies(introduce_accumulators, common_struct, bool(yes),
+ !Globals),
% Don't do the unused_args optimization when making the
% optimization interface.
option_implies(make_optimization_interface, optimize_unused_args,
- bool(no)),
+ bool(no), !Globals),
% The information needed for generating the module ordering
% is only available while generating the dependencies.
option_implies(generate_module_order, generate_dependencies,
- bool(yes)),
+ bool(yes), !Globals),
% We only generate the source file mapping if the module name
% doesn't match the file name.
option_implies(generate_source_file_mapping, warn_wrong_module_name,
- bool(no)),
+ bool(no), !Globals),
% --aditi-only implies --aditi.
- option_implies(aditi_only, aditi, bool(yes)),
+ option_implies(aditi_only, aditi, bool(yes), !Globals),
% Set --aditi-user to the value of $USER if it is not set already.
% If $USER is not set, use the string "guest".
- globals__io_lookup_string_option(aditi_user, User0),
- ( { User0 = "" } ->
- io__get_environment_var("USER", MaybeUser),
- ( { MaybeUser = yes(User1) } ->
- { User = User1 }
+ globals__lookup_string_option(!.Globals, aditi_user, User0),
+ ( User0 = "" ->
+ io__get_environment_var("USER", MaybeUser, !IO),
+ (
+ MaybeUser = yes(User)
;
- { User = "guest" }
+ MaybeUser = no,
+ User = "guest"
),
- globals__io_set_option(aditi_user, string(User))
+ globals__set_option(aditi_user, string(User), !Globals)
;
- []
+ true
),
- globals__io_lookup_string_option(fullarch, FullArch),
+ globals__lookup_string_option(!.Globals, fullarch, FullArch),
%
% Add the standard library directory.
%
- globals__io_lookup_maybe_string_option(
+ globals__lookup_maybe_string_option(!.Globals,
mercury_standard_library_directory, MaybeStdLibDir),
- ( { MaybeStdLibDir = yes(StdLibDir) } ->
- globals__io_get_globals(Globals2),
- { globals__get_options(Globals2, OptionTable2) },
- { globals__set_options(
- option_table_add_mercury_library_directory(
- OptionTable2, StdLibDir),
- Globals2, Globals3) },
- { unsafe_promise_unique(Globals3, Globals4) },
- globals__io_set_globals(Globals4),
+ (
+ MaybeStdLibDir = yes(StdLibDir),
+ globals__get_options(!.Globals, OptionTable2),
+ globals__set_options(option_table_add_mercury_library_directory(
+ OptionTable2, StdLibDir), !Globals),
%
% Add `-L' and `-R' options for the location
% of the GC libraries.
%
- globals__io_lookup_accumulating_option(
+ globals__lookup_accumulating_option(!.Globals,
link_library_directories, LinkLibDirs0),
- globals__io_set_option(link_library_directories,
- accumulating(
- [StdLibDir/"lib"/FullArch | LinkLibDirs0])),
+ globals__set_option(link_library_directories,
+ accumulating([StdLibDir/"lib"/FullArch | LinkLibDirs0]),
+ !Globals),
- globals__io_lookup_accumulating_option(
+ globals__lookup_accumulating_option(!.Globals,
runtime_link_library_directories, Rpath0),
- globals__io_set_option(runtime_link_library_directories,
- accumulating([StdLibDir/"lib"/FullArch | Rpath0]))
+ globals__set_option(runtime_link_library_directories,
+ accumulating([StdLibDir/"lib"/FullArch | Rpath0]), !Globals)
;
- []
+ MaybeStdLibDir = no
),
%
% Add the path to mercury_conf.h.
%
- globals__io_lookup_maybe_string_option(
+ globals__lookup_maybe_string_option(!.Globals,
mercury_configuration_directory, MaybeConfDir),
- ( { MaybeConfDir = yes(ConfDir) } ->
- globals__io_lookup_accumulating_option(c_include_directory,
+ (
+ MaybeConfDir = yes(ConfDir),
+ globals__lookup_accumulating_option(!.Globals, c_include_directory,
CIncludeDirs0),
- globals__io_set_option(c_include_directory,
- accumulating([ConfDir/"conf" | CIncludeDirs0]))
+ globals__set_option(c_include_directory,
+ accumulating([ConfDir/"conf" | CIncludeDirs0]), !Globals)
;
- []
+ MaybeConfDir = no
),
%
% Find the configuration file.
%
- globals__io_lookup_maybe_string_option(config_file, ConfigFile),
+ globals__lookup_maybe_string_option(!.Globals, config_file,
+ ConfigFile),
% yes("") means `--config-file' was not passed on the command line.
- ( { ConfigFile = yes("") } ->
- ( { MaybeConfDir = yes(ConfDir1) } ->
- globals__io_set_option(config_file, maybe_string(yes(
- ConfDir1/"conf"/"Mercury.config")))
+ ( ConfigFile = yes("") ->
+ (
+ MaybeConfDir = yes(ConfDir1),
+ globals__set_option(config_file, maybe_string(yes(
+ ConfDir1/"conf"/"Mercury.config")), !Globals)
;
- globals__io_set_option(config_file, maybe_string(no))
+ MaybeConfDir = no,
+ globals__set_option(config_file, maybe_string(no), !Globals)
)
;
- []
+ true
),
%
@@ -1352,69 +1427,69 @@
% These couldn't be handled by options.m because they are grade
% dependent.
%
- globals__io_lookup_accumulating_option(mercury_library_directories,
- MercuryLibDirs),
- globals__io_get_globals(Globals),
- { grade_directory_component(Globals, GradeString) },
+ globals__lookup_accumulating_option(!.Globals,
+ mercury_library_directories, MercuryLibDirs),
+ grade_directory_component(!.Globals, GradeString),
(
- { MercuryLibDirs = [_|_] },
- { ExtraLinkLibDirs = list__map(
+ MercuryLibDirs = [_ | _],
+ ExtraLinkLibDirs = list__map(
(func(MercuryLibDir) =
MercuryLibDir/"lib"/GradeString/FullArch
- ), MercuryLibDirs) },
+ ), MercuryLibDirs),
- globals__io_lookup_accumulating_option(
+ globals__lookup_accumulating_option(!.Globals,
link_library_directories, LinkLibDirs),
- globals__io_set_option(link_library_directories,
- accumulating(LinkLibDirs ++ ExtraLinkLibDirs)),
+ globals__set_option(link_library_directories,
+ accumulating(LinkLibDirs ++ ExtraLinkLibDirs), !Globals),
- globals__io_lookup_accumulating_option(
+ globals__lookup_accumulating_option(!.Globals,
runtime_link_library_directories, Rpath),
- globals__io_set_option(runtime_link_library_directories,
- accumulating(Rpath ++ ExtraLinkLibDirs)),
+ globals__set_option(runtime_link_library_directories,
+ accumulating(Rpath ++ ExtraLinkLibDirs), !Globals),
- { ExtraCIncludeDirs = list__map(
+ ExtraCIncludeDirs = list__map(
(func(MercuryLibDir) =
MercuryLibDir/"lib"/GradeString/FullArch/"inc"
- ), MercuryLibDirs) },
- globals__io_lookup_accumulating_option(c_include_directory,
+ ), MercuryLibDirs),
+ globals__lookup_accumulating_option(!.Globals, c_include_directory,
CIncludeDirs),
- globals__io_set_option(c_include_directory,
- accumulating(ExtraCIncludeDirs ++ CIncludeDirs)),
+ globals__set_option(c_include_directory,
+ accumulating(ExtraCIncludeDirs ++ CIncludeDirs), !Globals),
- { ExtraIntermodDirs = list__map(
+ ExtraIntermodDirs = list__map(
(func(MercuryLibDir) =
dir__make_path_name(MercuryLibDir,
- dir__make_path_name("ints",
- GradeString
- ))
- ), MercuryLibDirs) },
- globals__io_lookup_accumulating_option(intermod_directories,
- IntermodDirs0),
- globals__io_set_option(intermod_directories,
- accumulating(ExtraIntermodDirs ++ IntermodDirs0))
+ dir__make_path_name("ints", GradeString))
+ ), MercuryLibDirs),
+ globals__lookup_accumulating_option(!.Globals,
+ intermod_directories, IntermodDirs0),
+ globals__set_option(intermod_directories,
+ accumulating(ExtraIntermodDirs ++ IntermodDirs0), !Globals)
;
- { MercuryLibDirs = [] }
+ MercuryLibDirs = []
),
% If --use-search-directories-for-intermod is true, append the
% search directories to the list of directories to search for
% .opt files.
- globals__io_lookup_bool_option(use_search_directories_for_intermod,
- UseSearchDirs),
- ( { UseSearchDirs = yes } ->
- globals__io_lookup_accumulating_option(intermod_directories,
- IntermodDirs1),
- globals__io_lookup_accumulating_option(search_directories,
- SearchDirs),
- globals__io_set_option(intermod_directories,
- accumulating(IntermodDirs1 ++ SearchDirs))
+ globals__lookup_bool_option(!.Globals,
+ use_search_directories_for_intermod, UseSearchDirs),
+ (
+ UseSearchDirs = yes,
+ globals__lookup_accumulating_option(!.Globals,
+ intermod_directories, IntermodDirs1),
+ globals__lookup_accumulating_option(!.Globals,
+ search_directories, SearchDirs),
+ globals__set_option(intermod_directories,
+ accumulating(IntermodDirs1 ++ SearchDirs), !Globals)
;
- []
+ UseSearchDirs = no
),
- globals__io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs),
- ( { UseGradeSubdirs = yes } ->
+ globals__lookup_bool_option(!.Globals, use_grade_subdirs,
+ UseGradeSubdirs),
+ (
+ UseGradeSubdirs = yes,
%
% With `--use-grade-subdirs', `.opt', `.trans_opt' and
% `.mih' files are placed in a directory named
@@ -1425,16 +1500,15 @@
% `--intermod-directory Mercury/<grade>/<fullarch>'
% to find the `.opt' files in the current directory.
%
- globals__io_lookup_accumulating_option(intermod_directories,
- IntermodDirs2),
- { GradeSubdirIntermodDirs =
+ globals__lookup_accumulating_option(!.Globals,
+ intermod_directories, IntermodDirs2),
+ GradeSubdirIntermodDirs =
["Mercury"/GradeString/FullArch |
- list__filter(isnt(unify(dir__this_directory)),
- IntermodDirs2)] },
- globals__io_set_option(intermod_directories,
- accumulating(GradeSubdirIntermodDirs))
+ list__filter(isnt(unify(dir__this_directory)), IntermodDirs2)],
+ globals__set_option(intermod_directories,
+ accumulating(GradeSubdirIntermodDirs), !Globals)
;
- []
+ UseGradeSubdirs = no
),
%
@@ -1443,110 +1517,121 @@
% name, so we need to add the full path to the
% header files in the current directory.
%
- globals__io_lookup_bool_option(use_subdirs, UseSubdirs),
+ globals__lookup_bool_option(!.Globals, use_subdirs, UseSubdirs),
(
- { UseGradeSubdirs = yes ->
- MihsSubdir =
- "Mercury"/GradeString/FullArch/"Mercury"/"mihs"
+ ( UseGradeSubdirs = yes ->
+ MihsSubdir = "Mercury"/GradeString/FullArch/"Mercury"/"mihs"
; UseSubdirs = yes ->
MihsSubdir = "Mercury"/"mihs"
;
fail
- }
+ )
->
- globals__io_lookup_accumulating_option(c_include_directory,
+ globals__lookup_accumulating_option(!.Globals, c_include_directory,
CIncludeDirs1),
- { SubdirCIncludeDirs =
- [dir__this_directory, MihsSubdir | CIncludeDirs1] },
- globals__io_set_option(c_include_directory,
- accumulating(SubdirCIncludeDirs))
+ SubdirCIncludeDirs =
+ [dir__this_directory, MihsSubdir | CIncludeDirs1],
+ globals__set_option(c_include_directory,
+ accumulating(SubdirCIncludeDirs), !Globals)
;
- []
+ true
),
% --use-opt-files implies --no-warn-missing-opt-files since
% we are expecting some to be missing.
- option_implies(use_opt_files, warn_missing_opt_files, bool(no)),
+ option_implies(use_opt_files, warn_missing_opt_files, bool(no),
+ !Globals),
% --warn-non-tail-recursion requires both --high-level-code
% and --optimize-tailcalls. It also doesn't work if you use
% --errorcheck-only.
option_requires(warn_non_tail_recursion, highlevel_code, bool(yes),
"--warn-non-tail-recursion requires --high-level-code",
- !Errors),
+ !.Globals, !Errors),
option_requires(warn_non_tail_recursion, optimize_tailcalls, bool(yes),
"--warn-non-tail-recursion requires --optimize-tailcalls",
- !Errors),
+ !.Globals, !Errors),
option_requires(warn_non_tail_recursion, errorcheck_only, bool(no),
"--warn-non-tail-recursion is incompatible with " ++
"--errorcheck-only",
- !Errors),
+ !.Globals, !Errors),
% The backend foreign languages depend on the target.
(
- { Target = c },
- { BackendForeignLanguages = ["c"] }
+ Target = c,
+ BackendForeignLanguages = ["c"]
;
- { Target = il },
- { BackendForeignLanguages = ["il", "csharp", "mc++"] }
+ Target = il,
+ BackendForeignLanguages = ["il", "csharp", "mc++"]
;
- { Target = asm },
+ Target = asm,
% XXX This is wrong! It should be asm.
- { BackendForeignLanguages = ["c"] }
+ BackendForeignLanguages = ["c"]
;
- { Target = java },
- { BackendForeignLanguages = ["java"] }
+ Target = java,
+ BackendForeignLanguages = ["java"]
),
% only set the backend foreign languages if they are unset
- globals__io_lookup_accumulating_option(backend_foreign_languages,
- CurrentBackendForeignLanguage),
+ globals__lookup_accumulating_option(!.Globals,
+ backend_foreign_languages, CurrentBackendForeignLanguage),
(
- { CurrentBackendForeignLanguage = [] }
- ->
- globals__io_set_option(backend_foreign_languages,
- accumulating(BackendForeignLanguages))
+ CurrentBackendForeignLanguage = [],
+ globals__set_option(backend_foreign_languages,
+ accumulating(BackendForeignLanguages), !Globals)
;
- []
+ CurrentBackendForeignLanguage = [_ | _]
),
- globals__io_lookup_int_option(compare_specialization, CompareSpec),
- ( { CompareSpec < 0 } ->
+ globals__lookup_int_option(!.Globals, compare_specialization,
+ CompareSpec),
+ ( CompareSpec < 0 ->
% This indicates that the option was not set by the user;
% we should set the option to the default value. This value
% may be back end specific, since different back ends have
% different performance tradeoffs.
(
- { HighLevel = no },
- globals__io_set_option(compare_specialization, int(13))
+ HighLevel = no,
+ globals__set_option(compare_specialization, int(13), !Globals)
;
- { HighLevel = yes },
- globals__io_set_option(compare_specialization, int(14))
+ HighLevel = yes,
+ globals__set_option(compare_specialization, int(14), !Globals)
)
;
- []
+ true
),
(
% In the non-C backends, it may not be possible to cast a value
% of a non-enum du type to an integer.
- { Target = c ; Target = asm },
+ ( Target = c
+ ; Target = asm
+ ),
% To ensure that all constants in general du types are
% allocated in one word, make_tags.m need to have at least one
% tag bit left over after --reserve-tags possibly takes one.
- { TagsMethod = low ; TagsMethod = high },
- { NumTagBits >= 2 }
+ ( TagsMethod = low
+ ; TagsMethod = high
+ ),
+ NumTagBits >= 2
->
- globals__io_set_option(can_compare_constants_as_ints, bool(yes))
+ globals__set_option(can_compare_constants_as_ints, bool(yes),
+ !Globals)
;
- globals__io_set_option(can_compare_constants_as_ints, bool(no))
+ globals__set_option(can_compare_constants_as_ints, bool(no),
+ !Globals)
),
- ( { HighLevel = no } ->
- postprocess_options_lowlevel
+ (
+ HighLevel = no,
+ postprocess_options_lowlevel(!Globals)
;
- []
+ HighLevel = yes
+ ),
+
+ unsafe_promise_unique(!Globals),
+ globals__io_set_globals(!.Globals, !IO)
).
% These option implications only affect the low-level (LLDS) code
@@ -1554,113 +1639,126 @@
% code generator, because sometimes the same option has different
% meanings and implications in the two backends.
%
-:- pred postprocess_options_lowlevel(io::di, io::uo) is det.
+:- pred postprocess_options_lowlevel(globals::in, globals::out) is det.
-postprocess_options_lowlevel -->
+postprocess_options_lowlevel(!Globals) :-
% The low level code generator assumes that const(_) rvals are
% really constant, and that create(_) rvals with constant
% arguments can be materialized in an assignable rval without
% further code. For float_consts, the former is true only if
% either static_ground_terms or unboxed_floats is true, and
% the latter cannot be true without static_ground_terms.
- option_neg_implies(highlevel_code, static_ground_terms, bool(yes)),
+ option_neg_implies(highlevel_code, static_ground_terms, bool(yes),
+ !Globals),
% --optimize-saved-vars-cell requires --use-local-vars for
% acceptable performance.
- option_implies(optimize_saved_vars_cell, use_local_vars, bool(yes)),
+ option_implies(optimize_saved_vars_cell, use_local_vars, bool(yes),
+ !Globals),
% --optimize-frames requires --optimize-labels and
% --optimize-jumps
- option_implies(optimize_frames, optimize_labels, bool(yes)),
- option_implies(optimize_frames, optimize_jumps, bool(yes)),
+ option_implies(optimize_frames, optimize_labels, bool(yes), !Globals),
+ option_implies(optimize_frames, optimize_jumps, bool(yes), !Globals),
% --optimize-proc-dups is implemented only with --trad-passes.
- option_implies(optimize_proc_dups, trad_passes, bool(yes)).
+ option_implies(optimize_proc_dups, trad_passes, bool(yes), !Globals).
-% option_implies(SourceBoolOption, ImpliedOption, ImpliedOptionValue, IO0, IO).
-% If the SourceBoolOption is set to yes, then the ImpliedOption is set
-% to ImpliedOptionValue.
+ % option_implies(SourceBoolOption, ImpliedOption, ImpliedOptionValue):
+ % If the SourceBoolOption is set to yes, then the ImpliedOption is set
+ % to ImpliedOptionValue.
+ %
:- pred option_implies(option::in, option::in, option_data::in,
- io::di, io::uo) is det.
+ globals::in, globals::out) is det.
-option_implies(SourceOption, ImpliedOption, ImpliedOptionValue) -->
- globals__io_lookup_bool_option(SourceOption, SourceOptionValue),
- ( { SourceOptionValue = yes } ->
- globals__io_set_option(ImpliedOption, ImpliedOptionValue)
+option_implies(SourceOption, ImpliedOption, ImpliedOptionValue, !Globals) :-
+ globals__lookup_bool_option(!.Globals, SourceOption, SourceOptionValue),
+ (
+ SourceOptionValue = yes,
+ globals__set_option(ImpliedOption, ImpliedOptionValue, !Globals)
;
- []
+ SourceOptionValue = no
).
-% option_neg_implies(SourceBoolOption, ImpliedOption,
-% ImpliedOptionValue, IO0, IO).
-% If the SourceBoolOption is set to no, then the ImpliedOption is set
-% to ImpliedOptionValue.
+ % option_neg_implies(SourceBoolOption, ImpliedOption, ImpliedOptionValue):
+ % If the SourceBoolOption is set to no, then the ImpliedOption is set
+ % to ImpliedOptionValue.
+ %
:- pred option_neg_implies(option::in, option::in, option_data::in,
- io::di, io::uo) is det.
+ globals::in, globals::out) is det.
-option_neg_implies(SourceOption, ImpliedOption, ImpliedOptionValue) -->
- globals__io_lookup_bool_option(SourceOption, SourceOptionValue),
- ( { SourceOptionValue = no } ->
- globals__io_set_option(ImpliedOption, ImpliedOptionValue)
+option_neg_implies(SourceOption, ImpliedOption, ImpliedOptionValue,
+ !Globals) :-
+ globals__lookup_bool_option(!.Globals, SourceOption, SourceOptionValue),
+ (
+ SourceOptionValue = yes
;
- []
+ SourceOptionValue = no,
+ globals__set_option(ImpliedOption, ImpliedOptionValue, !Globals)
).
-% option_requires(SourceBoolOption, RequiredOption, RequiredOptionValue,
-% ErrorMsg, !Errors):
-% If the SourceBoolOption is set to yes, and RequiredOption is not set
-% to RequiredOptionValue, then add the given error message to the list.
+ % option_requires(SourceBoolOption, RequiredOption, RequiredOptionValue,
+ % ErrorMsg, !Errors):
+ % If the SourceBoolOption is set to yes, and RequiredOption is not set
+ % to RequiredOptionValue, then add the given error message to the list.
+ %
:- pred option_requires(option::in, option::in, option_data::in, string::in,
- list(string)::in, list(string)::out, io::di, io::uo) is det.
+ globals::in, list(string)::in, list(string)::out) is det.
option_requires(SourceOption, RequiredOption, RequiredOptionValue,
- ErrorMessage, !Errors, !IO) :-
- globals__io_lookup_bool_option(SourceOption, SourceOptionValue, !IO),
- globals__io_lookup_option(RequiredOption, OptionValue, !IO),
- ( SourceOptionValue = yes, OptionValue \= RequiredOptionValue ->
+ ErrorMessage, Globals, !Errors) :-
+ globals__lookup_bool_option(Globals, SourceOption, SourceOptionValue),
+ globals__lookup_option(Globals, RequiredOption, OptionValue),
+ (
+ SourceOptionValue = yes,
+ OptionValue \= RequiredOptionValue
+ ->
add_error(ErrorMessage, !Errors)
;
true
).
- % Smart recompilation does not yet work with all
- % options (in particular `--intermodule-optimization'
- % and `--no-target-code-only'). Disable smart recompilation
- % if such an option is set, maybe issuing a warning.
+ % Smart recompilation does not yet work with all options (in particular
+ % `--intermodule-optimization' and `--no-target-code-only'). Disable smart
+ % recompilation if such an option is set, maybe issuing a warning.
+ %
:- pred maybe_disable_smart_recompilation(bool::in, option::in, bool::in,
- string::in, io::di, io::uo) is det.
+ string::in, globals::in, globals::out, io::di, io::uo) is det.
maybe_disable_smart_recompilation(Smart, ConflictingOption,
- ValueToDisableSmart, OptionDescr, !IO) :-
- globals__io_lookup_bool_option(ConflictingOption, Value, !IO),
+ ValueToDisableSmart, OptionDescr, !Globals, !IO) :-
+ globals__lookup_bool_option(!.Globals, ConflictingOption, Value),
(
Smart = yes,
Value = ValueToDisableSmart
->
- disable_smart_recompilation(OptionDescr, !IO)
+ disable_smart_recompilation(OptionDescr, !Globals, !IO)
;
true
).
-:- pred disable_smart_recompilation(string::in, io::di, io::uo) is det.
+:- pred disable_smart_recompilation(string::in, globals::in, globals::out,
+ io::di, io::uo) is det.
-disable_smart_recompilation(OptionDescr) -->
- globals__io_set_option(smart_recompilation, bool(no)),
- globals__io_lookup_bool_option(warn_smart_recompilation,
+disable_smart_recompilation(OptionDescr, !Globals, !IO) :-
+ globals__set_option(smart_recompilation, bool(no), !Globals),
+ globals__lookup_bool_option(!.Globals, warn_smart_recompilation,
WarnSmart),
- ( { WarnSmart = yes } ->
+ (
+ WarnSmart = yes,
io__write_string("Warning: smart recompilation " ++
- "does not yet work with "),
- io__write_string(OptionDescr),
- io__write_string(".\n"),
- globals__io_lookup_bool_option(halt_at_warn, Halt),
- ( { Halt = yes } ->
- io__set_exit_status(1)
+ "does not yet work with ", !IO),
+ io__write_string(OptionDescr, !IO),
+ io__write_string(".\n", !IO),
+ globals__lookup_bool_option(!.Globals, halt_at_warn, Halt),
+ (
+ Halt = yes,
+ io__set_exit_status(1, !IO)
;
- []
+ Halt = no
)
;
- []
+ WarnSmart = no
).
usage_errors(Errors, !IO) :-
cvs diff: Diffing notes
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list