Estimated hours taken: 0.5
Branches: main
Replace a pair with a specific d.u. type.
compiler/mlds.m:
Use a specific d.u. type to represent switches in the MLDS instead
of a pair.
compiler/ml_closure_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_tailcall.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Conform to the above change.
Estimated hours taken: 1
Branches: main
Rename some function symbols in the MLDS in order avoid ambiguities.
Fix an omission in the MLDS backend's handling of switches on foreign
enumerations.
compiler/mlds.m:
Add the prefix `ml_stmt_' to the constructors of the mlds_stmt/0 type.
The current names conflict with those in the HLDS and LLDS.
compiler/ml_simplify_switch.m:
Fix the above omission.
Try to avoid something similar occurring again by change the semidet
predicate is_integral_type/1 into a boolean function that switches
on the type mlds_type/0.
compiler/ml_elim_nested.m:
Turn some if-then-elses into the switches.
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
Conform to the above change.
Estimated hours taken: 2
Branches: main
Fix a problem that was causing warnings from the C compiler for some of the
versions of the Java parser.
There is no test case, since we don't have a test mechanism for C compiler
warnings.
compiler/foreign.m:
Return MR_Tuple as the C type that represents Mercury tuples in C,
since the hlc backend requires this. (We used to generate MR_Word,
which is what lead to the problem.)
Rename the functions that generated the foreign language type names,
both to make their names more expressive and to eliminate the ambiguity
between them.
Add a comment about my remaining concerns, and note the link between
this code and code elsewhere.
Rename some function symbols to avoid ambiguity.
compiler/ml_code_util.m:
Rename a predicate to avoid an ambiguity.
compiler/*.m:
Conform to the renamed predicates and functions.
runtime/mercury_types.h:
runtime/mercury_hlc_types.h:
Move the definition of MR_Tuple from mercury_hlc_types to
mercury_types, since foreign.m now generates references to it
for the low level backend as well.
Estimated hours take: 4
Branches: main
Add some preliminary infrastructure for an HLDS->Erlang code generator.
compiler/globals.m:
compiler/options.m:
Recognise "erlang" as a valid compilation target.
Add new options: `--erlang' and `--erlang-only' as synonyms
for `--target erlang' and `--target erlang --target-code-only'.
XXX the new options are currently undocumented.
compiler/hlds_data.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
Recognise "Erlang" as a valid language for foreign code.
compiler/handle_options.m:
For erlang targets, set the gc_method to automatic and disable
optimize_constructor_last_call.
compiler/add_pragma.m:
compiler/add_type.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/export.m:
compiler/foreign.m:
compiler/granularity.m:
compiler/intermod.m:
compiler/llds_out.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_gen.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/modules.m:
compiler/pragma_c_gen.m:
compiler/prog_foreign.m:
compiler/simplify.m:
Conform to the above changes.
Estimated hours taken: 12
Branches: main
Fix a bug that caused bootchecks with --optimize-constructor-last-call to fail.
The problem was not in lco.m, but in follow_code.m. In some cases,
(specifically, the LCMC version of insert_2 in sparse_bitset.m),
follow_code.m moved an impure goal (store_at_ref) into the arms of an
if-then-else without marking those arms, or the if-then-else, as impure.
The next pass, simplify, then deleted the entire if-then-else, since it
had no outputs. (The store_at_ref that originally appeared after the
if-then-else was the only consumer of its only output.)
The fix is to get follow_code.m to make branched control structures such as
if-then-elses, as well as their arms, semipure or impure if a goal being moved
into them is semipure or impure, or if they came from an semipure or impure
conjunction.
Improve the optimization of the LCMC version of sparse_bitset.insert_2, which
had a foreign_proc invocation of bits_per_int in it: replace such invocations
with a unification of the bits_per_int constant if not cross compiling.
Add a new option, --optimize-constructor-last-call-null. When set, LCMC will
assign NULLs to the fields not yet filled in, to avoid any junk happens to be
there from being followed by the garbage collector's mark phase.
This diff also makes several other changes that helped me to track down
the bug above.
compiler/follow_code.m:
Make the fix described above.
Delete all the provisions for --prev-code; it won't be implemented.
Don't export a predicate that is not now used anywhere else.
compiler/simplify.m:
Make the optimization described above.
compiler/lco.m:
Make sure that the LCMC specialized procedure is a predicate, not a
function: having a function with the mode LCMC_insert_2(in, in) = in
looks wrong.
To avoid name collisions when a function and a predicate with the same
name and arity have LCMC applied to them, include the predicate vs
function status of the original procedure included in the name of the
new procedure.
Update the sym_name of calls to LCMC variants, not just the pred_id,
because without that, the HLDS dump looks misleading.
compiler/pred_table.m:
Don't have optimizations like LCMC insert new predicates at the front
of the list of predicates. Maintain the list of predicates in the
module as a two part list, to allow efficient addition of new pred_ids
at the (logical) end without using O(N^2) algorithms. Having predicates
in chronological order makes it easier to look at HLDS dumps and
.c files.
compiler/hlds_module.m:
Make module_info_predids return a module_info that is physically
updated though logically unchanged.
compiler/options.m:
Add --optimize-constructor-last-call-null.
Make the options --dump-hlds-pred-id, --debug-opt-pred-id and
--debug-opt-pred-name into accumulating options, to allow the user
to specify more than one predicate to be dumped (e.g. insert_2 and
its LCMC variant).
Delete --prev-code.
doc/user_guide.texi:
Document the changes in options.m.
compiler/code_info.m:
Record the value of --optimize-constructor-last-call-null in the
code_info, to avoid lookup at every cell construction.
compiler/unify_gen.m:
compiler/var_locn.m:
When deciding whether a cell can be static or not, make sure that
we never make static a cell that has some fields initialized with
dummy zeros, to be filled in for real later.
compiler/hlds_out.m:
For goals that are semipure or impure, note this fact. This info was
lost when I changed the representation of impurity from markers to a
field.
mdbcomp/prim_data.m:
Rename some ambiguous function symbols.
compiler/intermod.m:
compiler/trans_opt.m:
Rename the main predicates (and some function symbols) of these modules
to avoid ambiguity and to make them more expressive.
compiler/llds.m:
Don't print line numbers for foreign_code fragments if the user has
specified --no-line-numbers.
compiler/make.dependencies.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.usage.m:
Don't use io.write to write out information to files we may need to
parse again, because this is vulnerable to changes to the names of
function symbols (e.g. the one to mdbcomp/prim_data.m).
The compiler still contains some uses of io.write, but they are
for debugging. I added an item to the todo list of the one exception,
ilasm.m.
compiler/recompilation.m:
Rename a misleading function symbol name.
compiler/parse_tree.m:
Don't import recompilation.m here. It is not needed (all the components
of parse_tree that need recompilation.m already import it themselves),
and deleting the import avoids recompiling almost everything when
recompilation.m changes.
compiler/*.m:
Conform to the changes above.
compiler/*.m:
browser/*.m:
slice/*.m:
Conform to the change to mdbcomp.
library/sparse_bitset.m:
Use some better variable names.
Estimated hours taken: 2
Branches: main
Add some preliminary infrastructure for the LLDS->x86_64 assembler
code generator that Fransiska is working on.
compiler/globals.m:
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
Recognise "x86_64" as a valid compilation target.
Add new options: `--x86_64' and `--x86_64-only' as synonyms
for `--target x86_64' and `--target x86_64 --target-code-only'.
In the backend passes for the lowlevel backend branch
appropriately depending on whether we are generating C or
x86_64 assembler.
compiler/foreign.m:
compiler/prog_foreign.m:
When compiling to x86_64 assembler use C as the preferred foreign
language.
compiler/mlds.m:
compiler/ml_code_gen.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
Handle "x86_64" as a target in the MLDS backend. This does
(and should) cause a compiler abort since "x86_64" is intended
to be an MLDS target language.
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/modules.m:
Add placeholders for --target x86_64 in the build systems.
compiler/make_hlds_passes.m.
We don't currently support mutables with --target x86_64.
compiler/simplify.m:
We don't currently support runtime conditions on trace goals
with --target x86_64.
compiler/add_type.m:
compiler/compile_target_code.m:
compiler/granularity.m:
compiler/intermod.m:
Conform to the above changes.
Estimated hours taken: 25 (though some were spent learning build system, etc.)
Branches: main
Bug fixes for the MLDS accurate garbage collector.
compiler/mlds.m:
Change type of mlds_maybe_gc_trace_code to a discriminated union,
mlds_gc_statement to allow separation of initialisation and variable
tracing code, rather than the standard maybe type.
compiler/ml_elim_nested.m:
- Update extract_gc_trace_code (now extract_gc_statments) to
provide initialisation and variable tracing code separately.
- Change method of flattening so that hoisting of variables into
structs and changing references to those structs are
sequenced, not interleaved. This fixes a bug where references to
a variable could be processed before that variable was hoisted
into a struct, and thus the references not properly updated.
- Conform to the change in mlds.m.
compiler/ml_closure_gen.m:
- Flag GC initialisation code as such as it must be executed before
GC tracing code.
- Conform to the change in mlds.m.
compiler/ml_code_util.m:
compiler/ml_code_gen.m:
compiler/ml_call_gen.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_type_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/rtti_to_mlds.m:
Conform to the change in mlds.m.
Estimated hours taken: 3
Branches: main
Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.
analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
Remove unused module imports.
Fix some minor departures from our coding standards.
analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
Set --no-warn-unused-imports for those modules that are used as
packages or otherwise break --warn-unused-imports, e.g. because they
contain predicates with both foreign and Mercury clauses and some of
the imports only depend on the latter.
Estimated hours taken: 6
Branches: main
Document my recent change implementing coverage testing. At the same time,
eliminate the old hack that allowed a file containing a list of file names to
be considered a trace count file. We haven't needed it since the addition of
mtc_union, and it can lead to incomprensible error messages. (The presence
of the old hack made documenting coverage testing harder.)
In the process, fix the tools code for rerunning failed test cases only.
doc/user_guide.texi:
Document my recent change implementing coverage testing, and the
elimination of the old hack.
mdbcomp/trace_counts.m:
Modify the predicates for reading in trace count files along the lines
above.
mdbcomp/slice_and_dice.m:
Modify the predicates for reading in slices and dices along the lines
above.
Rename some function symbols to avoid ambiguities.
compiler/tupling.m:
slice/mcov.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_declarative.c:
Conform to the changes above.
slice/mcov.m:
Fix the usage message, which referred to this program by its old name
mct.
Allow the output to be restricted to a set of named modules only.
This is to make testing easier.
slice/mtc_diff.m:
Rename the long form of the -o option from --out to --output-file,
to make it consistent with the other programs.
tests/run_one_test:
tools/bootcheck:
Modify the algorithm we use to gather trace counts for the Mercury
compiler from both passed and failed test cases to run mtc_union
periodically instead of gathering all the trace counts file and keeping
them to the end (which takes far too much disk space).
Fix an old bug: gather trace counts from executions of the Mercury
compiler only.
tests/debugger/Mmakefile:
tests/debugger/dice.passes:
Modify the dice test case to compute the union of the trace counts for
the passed versions of this test case to use mtc_union to create
dice.passes, instead of having dice.passes statically contain the list
of the names of the passed trace count files (since that capability
is deleted by this diff).
tools/bootcheck:
tests/Mmake.common:
Fix the code for rerunning failed tests only.
mdbcomp/prim_data.m:
Eliminate some ambiguities in predicate names.
compiler/*.m:
Conform to the change to prim_data.m.
compiler/error_util.m:
Add reading files as a phase in error messages.
compiler/mercury_compile.m:
Use the new facilities in error_util for printing an error message.
Estimated hours taken: 6
Branches: main
This diff contains no algorithmic changes. It merely renames apart a bunch more
function symbols to reduce ambiguity.
After this diff, the summary line from the mdb command "ambiguity -f" is
Total: 351 names used 975 times, maximum 31, average: 2.78
browser/*.m:
compiler/*.m:
Rename function symbols to eliminate ambiguities.
tests/debugger/declarative/dependency.exp:
tests/debugger/declarative/dependency2.exp:
Update the expected out where some internal function symbol names
appear in the output of the debugger. (This output is meant for
implementors only.)
Estimated hours taken: 5
Branches: main
One of Hans Boehm's papers says that heap cells allocated by GC_MALLOC_ATOMIC
are grouped together into pages, and these pages aren't scanned during the
sweep phase of the garbage collector. I therefore modified the compiler
to use GC_MALLOC_ATOMIC instead of GC_MALLOC whereever possible, i.e
when the cell being allocated is guaranteed not to have any pointer to
GCable memory inside it.
My first benchmarking run showed a speedup of 4.5% in asm_fast.gc:
EXTRA_MCFLAGS = --use-atomic-cells
mercury_compile.01 average of 6 with ignore=1 18.30
EXTRA_MCFLAGS = --no-use-atomic-cells
mercury_compile.02 average of 6 with ignore=1 19.17
However, later benchmarks, after the upgrade to version 7.0 of boehm_gc,
show a less favourable and more mixed picture, with e.g. a 4% speedup
in hlc.gc at -O3, a 3% slowdown in asm_fast.gc at -O4, and little effect
otherwise:
EXTRA_MCFLAGS = -O1 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.01 average of 6 with ignore=1 23.30
EXTRA_MCFLAGS = -O1 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.02 average of 6 with ignore=1 23.28
EXTRA_MCFLAGS = -O2 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.03 average of 6 with ignore=1 18.51
EXTRA_MCFLAGS = -O2 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.04 average of 6 with ignore=1 18.66
EXTRA_MCFLAGS = -O3 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.05 average of 6 with ignore=1 18.44
EXTRA_MCFLAGS = -O3 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.06 average of 6 with ignore=1 18.48
EXTRA_MCFLAGS = -O4 --use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.07 average of 6 with ignore=1 18.28
EXTRA_MCFLAGS = -O4 --no-use-atomic-cells
GRADE = asm_fast.gc
mercury_compile.08 average of 6 with ignore=1 17.70
EXTRA_MCFLAGS = -O1 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.09 average of 6 with ignore=1 24.78
EXTRA_MCFLAGS = -O1 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.10 average of 6 with ignore=1 24.69
EXTRA_MCFLAGS = -O2 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.11 average of 6 with ignore=1 19.36
EXTRA_MCFLAGS = -O2 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.12 average of 6 with ignore=1 19.26
EXTRA_MCFLAGS = -O3 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.13 average of 6 with ignore=1 18.64
EXTRA_MCFLAGS = -O3 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.14 average of 6 with ignore=1 19.38
EXTRA_MCFLAGS = -O4 --use-atomic-cells
GRADE = hlc.gc
mercury_compile.15 average of 6 with ignore=1 19.39
EXTRA_MCFLAGS = -O4 --no-use-atomic-cells
GRADE = hlc.gc
mercury_compile.16 average of 6 with ignore=1 19.41
runtime/mercury_heap.h:
Define atomic equivalents of the few heap allocation macros
that didn't already have one. These macros are used by the LLDS
backend.
runtime/mercury.h:
Define an atomic equivalent of the MR_new_object macro.
These macros are used by the MLDS backend.
Use MR_new_object_atomic instead of MR_new_object to box floats.
compiler/hlds_data.m:
compiler/llds.m:
compiler/mlds.m:
Modify the representations of the heap allocations constructs
to include a flag that says whether we should use the atomic variants
of the heap allocation macros.
compiler/llds_out.m:
compiler/mlds_to_c.m:
Respect this extract flag when emitting C code.
In mlds_to_c.m, also add some white space that makes the code easier
for humans to read.
compiler/type_util.m:
Add a mechanism for finding out whether we can put a value of a given
type into an atomic cell.
Put the definitions of functions and predicates in this module
in the same order as their declarations.
Turn some predicates into functions. Change the argument order of
some predicates to conform to our usual conventions.
compiler/unify_gen.m:
compiler/ml_unify_gen.m:
Use the new mechanism in type_util.m to generate code that creates
atomic heap cells if this is possible and is requested.
compiler/code_info.m:
compiler/var_locn.m:
Act on the information provided by unify_gen.m.
compiler/options.m:
doc/user_guide.texi:
Add an option to control whether the compiler should try to use
atomic cells.
compiler/dupelim.m:
compiler/dupproc.m:
compiler/exprn_aux.m:
compiler/higher_order.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/polymorphism.m:
compiler/reassign.m:
compiler/size_prof.m:
compiler/structure_sharing.domain.m:
compiler/use_local_vars.m:
Minor diffs to conform to the changes above.
compiler/structure_reuse.direct.choose_reuse.m:
Add an XXX comment about the interaction of the new capability
with structure reuse.
Estimated hours taken: 5
Branches: main
Implement the trace goal construct for the hlc grades.
compiler/mlds.m:
Extend the MLDS in a similar way to how the previous diff extended
the LLDS. This means extending lvals to allow references to global
variables representing the initial snapshots of environment variables,
and recording the set of environment variables referred to by each
definition.
compiler/mlds_to_c.m:
Handle the extensions to the MLDS.
compiler/llds_out.m:
util/mkinit.c:
Note that mlds_to_c.m now also depends on the naming scheme for the
global variables representing environment variables.
compiler/ml_code_gen.m:
When generating code for a procedure, remember the set of environment
variables it refers to.
When generating code for the special form of call_foreign_proc created
by the transformation of trace goals with runtime conditions by
simplify.m, generate the appropriate boolean expression involving
references to environment variables.
compiler/ml_code_util.m:
Provide storage space for recording the set of environment variables
used in functions.
compiler/mlds_to_il.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
Abort if asked to translate functions that include references to
environment variables, since this is preferable to silently doing
the wrong thing.
compiler/*.m:
Misc changes required to conform to the change to the MLDS.
Estimated hours taken: 1.5
Branches: main
This diff contains no algorithmic changes.
compiler/llds.m:
compiler/mlds.m:
Rename some function symbols and field names to avoid ambiguities
with respect to language keywords.
compiler/*.m:
Conform to the changes in llds.m and mlds.m.
Estimated hours taken: 60
Branches: main
Provide a mechanism for collecting statistics about tabling operations,
and provide a much more convenient mechanism for resetting tables.
Since it would too complex to do this while preserving the capability
of setting --tabling-via-extra-args to no, eliminate that capability
and the option. That option was useful only for measurements of the
performance boost from setting --tabling-via-extra-args to yes in any case,
so users lose no functionality.
Previously, the only way to debug the low level details of the tabling
mechanism was to build a runtime with a specific C macro (MR_TABLE_DEBUG)
and link with that runtime; this was cumbersome. Change that so that
every one of the debuggable tabling macros has a bool argument that says
whether debugging is enabled or not. The compiler can then set this to
MR_TRUE if the new option --table-debug is given, and to MR_FALSE otherwise.
If set to MR_FALSE, the C compiler should optimize away the debug code,
with zero impact on program size or speed.
Since these changes to macros require nontrivial bootstrapping, which we don't
want to do unnecessarily, modify the interface of the tabling macros as
required to support size limits on tables. This diff also implements the
parsing of size limit specifications on tables, but does not implement them
yet; that is for a future change.
To make the syntax simpler, this diff deletes the free-standing fast_loose_memo
pragma. The same functionality is now available with a fast_loose annotation
on an ordinary memo pragma.
Make a bunch of changes to improve readability and maintainability
in the process. These mostly take the form of renaming ambiguous and/or
not sufficiently expressive function symbols.
runtime/mercury_stack_layout.h:
runtime/mercury_tabling.h:
Move the description of structure of tables from mercury_stack_layout.h
to mercury_tabling.h, since we now need it for statistics even if
execution tracing is not enabled.
Modify those data structures to have room for the statistics.
Don't distinguish "strict", "fast_loose" and "specified" memoing
as separate eval methods; treat them as just different kinds
of the same eval method: "memo".
Remove underscores from the names of some types that the style guide
says shouldn't be there.
runtime/mercury_tabling_preds.h:
runtime/mercury_tabling_macros.h:
Modify the approach we use for macros that implement the predicates
of library/table_builtin.m. Instead of selecting between debug and
nondebug based on whether MR_TABLE_DEBUG is defined or not, add
an explicit argument controlling this to each debuggable macro.
The advantage of the new arrangement is that it scales. Another
argument controls whether we are computing statistics (and if yes,
where do we put it), and a third argument controls whether we maintain
back links in the tries and hash tables (this last argument is present
but is ignored for now).
Since the values of the arguments will be known when the .c files
containing calls to these macros are compiled, we pay the space and
time cost of debugging, statistics gathering and the maintenance of
back links if and only we need the revelant functionality.
Provide macros for limited backward compatibility with the old set
of macros; these allow workspaces created by old compilers to work
with the new macros in the runtime. The old macros followed the
naming scheme MR_table_*, the new ones are named MR_tbl_*.
runtime/mercury_table_int_fix_index_body.h:
runtime/mercury_table_int_start_index_body.h:
runtime/mercury_table_type_body.h:
New files containing parts of the old mercury_tabling.c. Each of these
files contains the body of the functions that used to be in
mercury_tabling.c. The new mercury_tabling.c #includes each of these
files more than once, to provide more than one variant of the old
function. These variants differ in aspects such as whether debugging
is enabled or statistics is being collected. Each variant therefore
incurs only the time costs it needs to. (We pay the space cost of
having all these variants all the time of course, but this cost
is negligible.)
runtime/mercury_tabling_stats_defs.h:
runtime/mercury_tabling_stats_nodefs.h:
runtime/mercury_tabling_stats_undefs.h:
New files that serve as wrappers around the newly #included files,
controlling how they handle statistics.
runtime/mercury_tabling.c:
Delete functions now in the new files, and #include them instead.
Delete the data structures that used to contain summary statistics;
the new approach keeps statistics in compiler-generated,
procedure-specific data structures.
runtime/mercury_trace_base.c:
Use the new versions of the tabling macros to access the I/O table.
runtime/mercury_type_info.h:
Update some documentation for the movement of code out of
mercury_tabling.c.
runtime/mercury_types.h:
Provide forward declarations of the identifiers denoting the new types
in mercury_tabling.h.
runtime/mercury_grade.h:
Increment the exec trace version number, since we have changed
a part of the exec trace structure.
runtime/mercury_bootstrap.h:
Fix some temporary issues that arise from some renames above.
runtime/mercury_hash_lookup_or_add_body.h:
Fix comment.
runtime/Mmakefile:
Mention the new files and the dependencies that involve them.
library/table_builtin.m:
Provide a type for representing statistics and a predicate for
printing statistics.
Use the updated versions of the macros in
runtime/mercury_tabling_preds.h.
compiler/prog_item.m:
Change representation of tabling pragmas to allow room for the new
attributes.
Allow an item to be marked as being generated by the compiler
as a result of a pragma memo attribute. We use this for the reset
and statistics predicates.
compiler/mercury_to_mercury.m:
Write out the new attributes of the tabling pragma.
compiler/prog_data.m:
compiler/hlds_data.m:
Change the cons_id that used to refer to a procedure's call table root
to refer to the entirety of the new data structure now containing it.
The compiler now needs a way to refer to the other components of this
new data structure, since it contains the statistics.
As in the runtime, don't distinguish "strict", "fast_loose" and
"specified" memoing as separate eval methods; treat them as just
different kinds of the same eval method: "memo".
Rename some of the uses of the function symbols "c", "java", "il".
compiler/hlds_pred.m:
Add an extra field in proc_infos for storing any tabling attributes.
Change the existing proc_info field that records information about
the kinds of arguments of tabled procedures to record the information
needed by the debugger too. This was needed to allow us to shift all
the RTTI for procedure-specific tables (as opposed to the RTTI for
the global I/O table) from mercury_stack_layout.h to mercury_tabling.h
without duplicating the data (which would be a maintenance problem).
Reformat some comments to make them easier to read.
compiler/layout.m:
compiler/layout_out.m:
Delete the part of the exec trace information that used to record
RTTI for tables, since this information is not generated only as
part of the debugger data structures anymore.
compiler/prog_io_pragma.m:
Recognize the updated syntax for tabling pragmas.
compiler/add_pragma.m:
When processing tabling pragmas for inclusion in the HLDS, create
any reset and statistics predicates they ask for.
compiler/make_hlds_passes.m:
Export a predicate now needed by add_pragma.m.
Handle the new attributes on tabling pragmas
compiler/globals.m:
Change the function symbols of the types describing backends and
foreign languages to say what they are. Previously, both types (as well
as several others) included the function symbol "c"; now, they are
target_c and lang_c respectively.
compiler/table_gen.m:
Implement the changes described at the top.
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/goal_util.m:
compiler/hlds_goal.m:
When passing around varsets and vartypes, pass the arguments in the
standard order.
compiler/rtti.m:
Provide types for representing the runtime's data structures for
tabling (which are now significantly more complex than a single word)
and predicates for manipulating them, for use by both the ml and ll
backends.
compiler/llds.m:
Replace the comp_gen_c_var type with the tabling_info_struct type,
which contains the information needed to create the per-procedure
tabling data structures.
Replace references to call tables with references to the various
components of the new tabling data structures.
compiler/llds_out.m:
Add code to write out tabling_info_structs.
Delete the code required for the old, hacky way of resetting tables.
Reorder some code more logically.
compiler/proc_gen.m:
Generate tabling_info_structs.
compiler/stack_layout.m:
Don't generate the information now generated in proc_gen.m.
compiler/mlds.m:
Give mlds_proc_labels their own function symbols, instead of using
a pair. Rename some other function symbols to avoid ambiguity and add
expressiveness.
Provide for the representation of references to the various components
of the new tabling data structures, and for the representation of their
types.
compiler/ml_code_gen.m:
When generating code for a tabled procedure, generate also the data
structures required for its table.
compiler/rtti_to_mlds.m:
compiler/ml_util.m:
Move some predicates from rtti_to_mlds.m to ml_util.m, since we
now also want to call them from ml_code_gen.m.
compiler/name_mangle.m:
Add some utility predicates.
compiler/options.m:
Delete the old --allow-table-reset option.
Add the new --table-debug option.
Comment out an implementor-only option.
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_trail_ops.m:
compiler/add_type.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/compile_target_code.m:
compiler/complexity.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/foreign.m:
compiler/global_data.m:
compiler/globals.m:
compiler/handle_options.m:
compiler/higher_order.m:
compiler/hlds_code_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_label.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_item.m:
compiler/prog_mutable.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/prog_util.m:
compiler/recompilation.version.m:
compiler/size_prof.m:
compiler/special_pred.m:
compiler/switch_util.m:
compiler/transform_llds.m:
compiler/tupling.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
Conform to the changes above, and/or improve some comments.
mdbcomp/prim_data.m:
Make the names of the function symbols of the proc_label type more
expressive and less ambiguous.
mdbcomp/prim_data.m:
mdbcomp/mdbcomp.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
Use . instead of __ as module qualifier.
Conform to the change to prim_data.m.
browser/declarative_execution.m:
browser/declarative_oracle.m:
browser/declarative_tree.m:
Conform the change to mdbcomp/prim_data.m.
tests/debugger/Mercury.options:
Don't specify --allow-table-reset for fib.m, since that option
doesn't exist anymore.
tests/debugger/fib.m:
Use the new mechanism for resetting the table.
tests/debugger/print_table.m:
Use the new syntax for pragma memo attributes.
tests/invalid/specified.{m,err_exp}:
Use to the new syntax and reset method for pragma memo attributes.
Test the handling of errors in the new attribute syntax.
tests/tabling/Mercury.options:
Don't specify --allow-table-reset for specified.m, since that option
doesn't exist anymore.
tests/tabling/specified.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables. We could also use this test case
for testing the printing of statistics, but the format of that
output is still not final.
tests/tabling/fast_loose.m:
Use the new syntax for pragma memo attributes, and use the new
mechanism for resetting tables.
trace/mercury_trace.c:
trace/mercury_trace_cmd_developer.c:
Conform to the changes in the RTTI data structures regarding tabling.
Remove underscores from the names of some types that the style guide
says shouldn't be there.
library/robdd.m:
Comment out the tabling pragma until this change is bootstrapped.
Without this, the conflict between the old calls to macros generated
by the existing compiler and the new definition of those macros
in the runtime would cause errors from the C compiler.
Estimated hours taken: 18
Branches: main
Move the univ, maybe, pair and unit types from std_util into their own
modules. std_util still contains the general purpose higher-order programming
constructs.
library/std_util.m:
Move univ, maybe, pair and unit (plus any other related types
and procedures) into their own modules.
library/maybe.m:
New module. This contains the maybe and maybe_error types and
the associated procedures.
library/pair.m:
New module. This contains the pair type and associated procedures.
library/unit.m:
New module. This contains the types unit/0 and unit/1.
library/univ.m:
New module. This contains the univ type and associated procedures.
library/library.m:
Add the new modules.
library/private_builtin.m:
Update the declaration of the type_ctor_info struct for univ.
runtime/mercury.h:
Update the declaration for the type_ctor_info struct for univ.
runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
Update the definition of MR_Univ.
runtime/mercury_init.h:
Fix a comment: ML_type_name is now exported from type_desc.m.
compiler/mlds_to_il.m:
Update the the name of the module that defines univs (which are
handled specially by the il code generator.)
library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
Conform to the above changes. Import the new modules where they
are needed; don't import std_util where it isn't needed.
Fix formatting in lots of modules. Delete duplicate module
imports.
tests/*:
Update the test suite to confrom to the above changes.
Estimated hours taken: 6
Branches: main
compiler/*.m:
Convert almost all the compiler modules to use . instead of __ as
the module qualifier.
In some cases, change the names of predicates and types to make them
meaningful without the module qualifier. In particular, most of the
types that used to be referred to with an "mlds__" prefix have been
changed to have a "mlds_" prefix instead of changing the prefix to
"mlds.".
There are no algorithmic changes.
Estimated hours taken: 4
Branches: main
compiler/*.m:
Use expect/3 in place of require/2 throughout most of the
compiler.
Use unexpected/2 (or sorry/2) in place of error/1 in more
places.
Fix more dodgy assertion error messages.
s/map(prog_var, mer_type)/vartypes/ where the latter is meant.
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.
Estimated hours taken: 8
Branches: main
compiler/*.m:
Rename the types 'type', 'inst' and 'mode' to 'mer_type', 'mer_inst'
and 'mer_mode'. This is to avoid the need to parenthesize these type
names in some contexts, and to prepare for the possibility of a parser
that considers those words to be reserved words.
Rename some other uses of those names (e.g. as item types in
recompilation.m).
Delete some redundant synonyms (prog_type, mercury_type) for mer_type.
Change some type names (e.g. mlds__type) and predicate names (e.g.
deforest__goal) to make them unique even without module qualification.
Rename the function symbols (e.g. pure, &) that need to be renamed
to avoid the need to parenthesize them. Make their replacement names
more expressive.
Convert some more modules to four space indentation.
Avoid excessively long lines, such as those resulting from the
automatic substitution of 'mer_type' for 'type'.
Estimated hours taken: 8
Branches: main
Add language and compiler support for finalise declarations.
NEWS:
Mention finalise declarations.
compiler/prog_data.m:
Add a new item type for finalise declarations.
Add a new kind of item origin - items can now be introduced as part of
the source-to-source transformation that implements finalise
declarations.
compiler/prog_io.m:
Parse finalise declarations.
compiler/modules.m:
Don't write out finalise declarations in private interfaces.
compiler/hlds_module.m:
Add a slot to the HLDS that stores the names of the predicates in
finalise declarations.
Add access predicates for the above.
compiler/add_pragma.m:
compiler/make_hlds_passes.m:
Fix in incorrect comment: we add initialise declarations on third, not
second, pass.
Restore the code that use the enhanced switch detection capability.
Implement the source-to-source transformation that implements finalise
declarations. This is almost identical to that for intitialise
declarations.
compiler/llds.m:
compiler/llds_out.m:
compiler/transform_llds.m:
Add a slot to the LLDS to hold the name of the predicates specified in
the finalise declarations.
Emit the necessary code to call these predicates after main has finished.
compiler/mlds.m:
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
As above, but for the MLDS.
compiler/mercury_compile.m:
Conform to changes in the MLDS.
XXX This module probably shouldn't manipulating the MLDS directly.
compiler/module_qual.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
Conform to the above changes.
library/ops.m:
Add `finalise' as an operator.
runtime/mercury_wrapper.c:
Call any user specified finalise predicates from
mercury_runtime_terminate.
doc/reference_manual.texi:
Document finalise declarations.
tests/hard_coded/Mmakefile:
tests/hard_coded/finalise_decl.m:
tests/hard_coded/finalise_decl.exp:
Tests finalise declarations.
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/finalise_child.m:
tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/finalise_parent.{exp,exp2}:
Test finalise declarations and sub-modules. There are two expected
outputs because the order of execution between a parent module and its
children of any finalisers is arbitrary.
tests/invalid/Mmakefile:
tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_finalise_decl.err_exp:
Test error messages associated with finalise declarations.
Estimated hours taken: 2
Branches: main
compiler/ml_*.m:
Convert these modules to four space indentation, and clean up
departures from our coding standards.
Estimated hours taken: 1.5
Branches: main
Implement initialise declarations for the high-level C backend.
compiler/mlds.m:
Add a slot to the MLDS to hold the name of module intialisation
predicates.
XXX We should use a higher level representation of the names
here in case we need to treat them differently in the other
target languages.
compiler/mlds_to_c.m:
Output the necessary INIT and REQUIRED_INIT comments.
compiler/mercury_compile.m:
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
Handle the extra field in the MLDS.
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/mlds_to_gcc.m:
Handle the extra field in the MLDS. We don't
yet support initialise declarations on these backends.
Estimated hours taken: 4
Branches: main
compiler/*.m:
Change a bunch of modules to import only one module per line, even
from the library.
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
Convert these modules to our current coding style. Use state variables
where appropriate. Use predmode declarations where possible.
Estimated hours taken: 0.1
Branches: main
compiler/ml_optimize.m:
Delete the function maybe_apply from this module and
just use the equivalent map_maybe function from the
standard library.
Estimated hours taken: 17
Branches: main
This adds a module mdbcomp__trace_counts that reads in the
.mercury_trace_counts files produced by the compiler's trace mechanism.
The format of said files was slightly changed.
As the new module is to be used by the compiler and the debugger, it is
placed in the mdbcomp module. This required bringing some types from the
compiler into a new module within mdbcomp.
browser/trace_counts.m:
New module for reading execution trace summaries.
browser/prim_data.m:
New module holding types and predicates moved in from the compiler.
Types:
pred_or_func, sym_name, module_name, proc_label,
special_pred_id, trace_port
Predicates:
string_to_sym_name, insert_module_qualifier
The mode field of proc_label is now an int instead of a proc_id
to avoid pulling proc_id into mdbcomp.
browser/mdbcomp.m:
Add trace_counts and prim_data to the mdbcomp module.
browser/declarative_execution.m:
Renamed mdb's definition of module_name to flat_module_name
to avoid conflicts with the definition in mdbcomp__prim_data.
runtime/mercury_trace_base.c:
In the format of .mercury_trace_counts, write module and predicate
names now use quoted atom syntax so that names with spaces and
non-printable characters can be machine-parsed.
browser/:
compiler/:
Many changes to account for movement of types, and the change to
proc_label.
Estimated hours taken: 24
Branches: main
Some work towards getting the "browser" directory to build in grade java.
In particular, this is a step towards fixing a problem in the Java
back-end with sub-modules. When compiling code that uses sub-modules,
we run up against a Java restriction that a class which is in a package
is not allowed to have the same name as the package. The work-around
is to use names starting with an uppercase letter for Java class names,
and names starting with a lower-case letter for Java package names.
XXX This diff is a partial step: it uses names starting with an
uppercase letter for Java class names that correspond to Mercury types.
It does not yet use an uppercase letter for Java classes that correspond
to Mercury modules.
XXX With this diff, we just flip the case of the initial letter,
which just works around the problem by avoiding the clashing cases,
rather than eliminating them. We should use a more complicated mangling
that eliminates the problem completely, e.g. map lowercase Mercury names
to uppercase, map uppercase Mercury names to "U_" followed by the name.
compiler/mlds_to_java.m:
Output type names with an initial uppercase letter.
compiler/mlds.m:
Add a new enumeration type qual_kind, with values type_qual
and module_qual.
Add a qual_kind field to the fully_qualified_type type.
Add a qual_kind argument to the append_class_qualifier function,
and if the qual_kind is module_qual, adjust the case of the
qualifier appropriately for the back-end.
compiler/ml*.m:
compiler/rtti_to_mlds.m:
Fill in the new qual_kind field, and pass qual_kind to
append_class_qualifier.
library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
library/io.m:
library/rtti_implementation.m:
Use type names with an initial uppercase letter.
browser/Mmakefile:
Work around problems where Java compilers don't like the file names
generated by mmc for code using sub-modules.
For IL and Java, build with --allow-stubs --no-warn-stubs.
browser/declarative_execution.m:
Give a Java definition for the "proc_layout" type.
This is needed to avoid compilation errors in grade java.
Estimated hours taken: 8
Branches: main
compiler/modules.m:
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/bytecode_data.m:
compiler/prog_io_util.m:
Bring these modules up to date with our current coding style. Use
predmode declarations and state variable syntax where appropriate.
Fix inconsistent indentation. Print more error messages using
error_util.m for printing error messages.
compiler/trace_param.m:
Add a new predicate for use by the updated code in handle_options.m.
compiler/error_util.m:
compiler/hlds_error_util.m:
Make error_util.m to be a submodule of parse_tree.m, not hlds.m.
Most of its predicates are not dependent on HLDS data structures.
Move the ones that are into a new module, hlds_error_util, that
is a submodule of hlds.m. Overall, this reduces the dependence
of submodules of parse_tree.m, including modules.m, on submodules
of hlds.m.
compiler/notes/compiler_design.html:
Update the documentation of compiler modes to account for
hlds_error_util.m.
compiler/hlds.m:
compiler/parse_tree.m:
Update the list of included submodules.
compiler/*.m:
Update module imports and module qualifications as needed for the
change above.
tests/invalid/*.{exp,exp2}:
Update the expected outputs of a bunch of test cases to reflect the new
format of some warning messages due to the user error_util; they now
observe line length limits, and print contexts in some cases where they
were previously missing.
Estimated hours taken: 1
Branches: main
Remove any unnecessary nesting of blocks in the mlds. This allows us
to avoid a fixed limit of nesting in the MS Visual C compiler when
compiling xml.parse.chars.m.
compiler/ml_optimize.m:
If a list of statements contains a block with no local
variables, then bring the block up one level.
Estimated hours taken: 8
Branches: main
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
Bring the modules in the language-independent part of the MLDS backend
up to date with our current coding standards.
Use predmode declarations where appropriate.
Use state variable syntax where appropriate. Reorder arguments where
required to make this possible. For predicates that only read the
ml_gen_info and aren't likely to write it in the future, delete the
output ml_gen_info argument.
Change large lambda expressions into named predicates where this
improves readability, and in one case factor out duplicated code
in lambda expressions.
Standardize indentation. Shorten some variable names (e.g. by removing
MLDS prefixes) where the new names are unambiguous, to make some goals
fit on fewer lines.
Estimated hours taken: 12
Branches: main
Bug fixes for the Java back-end.
compiler/mlds_to_java.m:
Fix a bug where we were outputting an incorrect type for nested
structure initializers
Fix a bug where we were outputting invalid syntax for some
array initializers.
Fix a bug where the code output for string comparisons was not properly
parenthesized.
compiler/mlds.m:
Add a new argument to init_struct that specifies the type of
the structure being initialized. This is needed to handled
nested structure initializers for the Java back-end.
compiler/rtti.m:
Add new alternatives to ctor_rtti_name for all the types which
are used as nested components of RTTI structures. This is
needed in order to have appropriate RTTI types to use in
rtti_to_mlds.m for the new field of init_struct.
compiler/rtti_to_mlds.m:
Substantial changes to fill in the new field of init_struct
in all the generated initializers.
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
Minor changes to handle the new argument to init_struct.
compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
Minor changes to handle the new alternatives for ctor_rtti_name.
compiler/mlds_to_gcc.m:
Fix a bug where it was generating a structure type, rather
than an array thereof, for res_name_ordered_table.
Estimated hours taken: 2
Branches: main
compiler/*.m:
Import only one compiler module per line. Sort the blocks of imports.
This makes it easier to merge in changes.
In a couple of places, remove unnecessary imports.
Estimated hours taken: 40
Branches: main
Output Managed C++ code using the same mechanisms as we do for C#
code, rather than using pragma_c_gen to generate MC++ code. This
fixes the problem that functions couldn't be defined in MC++, and also
should make the code more maintainable in the future as MC++ is much
more similar to C# than to C.
compiler/mlds.m:
Add a new field to outline_foreign_proc. This field has
information which links the mlds variables with the variable
names used in the foreign code.
compiler/ml_code_gen.m:
Generate a foreign proc for MC++ the same way we generate a
foreign proc for C#.
Generate the data for the new field in outline_foreign_proc.
Use the context of the string which contains the pragma foreign
proc body for the context of the foreign proc. This ensures that
error messages refer to the correct line number.
compiler/mlds_to_il.m:
Add to the list of foreign languages defined in the module to
include those which don't have a foreign_proc defined in them.
Move the relevant code from atomic_statement_to_il to
generate_method so that we handle external procedures correctly.
compiler/mlds_to_ilasm.m:
Call mlds_to_managed.
compiler/ml_backend.m:
Add the new module and remove mlds_to_mcpp and mlds_to_csharp.
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
Minor changes to handling the new field in outline_foreign_proc.
compiler/mlds_to_csharp.m:
compiler/mlds_to_mcpp.m:
Removed files whose functionality has been subsumed by
mlds_to_managed.
library/construct.m:
library/float.m:
library/io.m:
library/std_util.m:
library/type_desc.m:
Changes required to get the library to be able compile in the
ilc grade.
Estimated hours taken: 2
Branches: main
A performance improvement for accurate GC.
compiler/mercury_compile.m:
Fix an XXX comment: invoke tail call optimization before
ml_elim_nested.m. This ensures that the stack setup code for
accurate garbage collection gets put outside the tail-recursive
loop rather than inside the loop.
compiler/ml_optimize.m:
When optimizing tail calls, generate assignments rather than
initializers for the temporary variables. This is needed now
that tail call optimization is done before ml_elim_nested.m.
Also mark those temporary variables as not needing GC.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.
compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
New files. One module for each of the major components of the
Mercury compiler. These modules contain (as separate sub-modules)
all the other modules in the Mercury compiler, except gcc.m and
mlds_to_gcc.m.
Mmakefile:
compiler/Mmakefile:
Handle the fact that the top-level module is now `top_level',
not `mercury_compile' (since `mercury_compile' is a sub-module
of `top_level').
compiler/Mmakefile:
Update settings of *FLAGS-<modulename> to use the appropriate
nested module names.
compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
Convert the `recompilation_*' modules into sub-modules of the
`recompilation' module.
compiler/*.m:
compiler/*.pp:
Module-qualify the module names in `:- module', `:- import_module',
and `:- use_module' declarations.
compiler/base_type_info.m:
compiler/base_type_layout.m:
Deleted these unused empty modules.
compiler/prog_data.m:
compiler/globals.m:
Move the `foreign_language' type from prog_data to globals.
compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
Import `globals', for `foreign_language'.
Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
Rename the %.check.c targets as %.check_hdr.c,
to avoid conflicts with compiler/recompilation.check.c.
Estimated hours taken: 0.5
Branches: main
Improve the efficiency of code generated for
`--restore-hp-on-failure' with the MLDS back-end.
compiler/ml_optimize.m:
Convert calls to private_builtin:mark_hp() and
private_builtin:restore_hp() into the MLDS builtin
mark_hp and restore_hp statements, so that they
get generated as inline code.
Estimated hours taken: 24
Branches: main
Generate closure layouts for the MLDS back-end.
compiler/ml_unify_gen.m:
Add code to generate closure layouts.
XXX Note that we still don't fill in the MR_closure_id field yet.
compiler/stack_layout.m:
Export stack_layout__represent_locn_as_int,
for use by ml_unify_gen.m.
compiler/mercury_compile.m:
Invoke the arg_info.m pass for the MLDS back-end, since the
arg_infos are needed by the code in continuation_info.m which
ml_unify_gen.m calls to generate closure layouts.
compiler/ml_elim_nested.m:
compiler/ml_util.m:
compiler/ml_code_util.m:
Fix a bug, exposed by the changes above, which led to some
dangling references. The bug was that it was not hoisting out
local static RTTI data even when this data was referred to by
other static constants were being hoisted, because it was only
checking for references via `var(mlds__var)' lvals, not via
`data_addr_const(data_addr)' rvals. The fix was to change the code
for *_contains_var so that it accepts a data_name rather than
a var_name, and counts references via data_addr_consts,
and to change the code for ml_decl_is_static_const so that
it just checks for `data(_)' rather than `data(var(_))'.
Hoisting RTTI data also required adding code to ml_elim_nested.m
to eliminate duplicate definitions.
compiler/rtti_to_mlds.m:
Mark RTTI definitions as `final'; this is needed to ensure
that they have the same flags (apart from the access) as
ml_static_const_flags, so that ml_decl_is_static_const succeeeds
for these.
compiler/ml_optimize.m:
Update to reflect the interface changes in ml_util.m.
runtime/mercury_deep_copy_body.h:
Delete a call to MR_fatal_error(), since it is no longer needed.
tests/hard_coded/Mmakefile:
Re-enable the copy_pred and copy_pred_2 test cases for the
MLDS back-end, since they now pass.
Estimated hours taken: 2
Branches: main
Implement tail call optimization for the Java back-end.
compiler/mlds.m:
Add support for C-style `break' and `continue' statements:
change the argument of the MLDS `goto' statement from a label
to a new type `goto_target' which is either `break', `continue',
or a label.
compiler/ml_optimize.m:
Add a new predicate `target_supports_break_and_continue',
and for targets where this predicate succeeds, generate tail
recursion using while/break/continue rather than label/goto.
compiler/ml_simplify_switch.m:
compiler/ml_string_switch.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
Minor changes to handle the new type for the argument of the
`goto' statement.
Estimated hours taken: 10
Branches: main
Add a new MLDS->MLDS optimization option, --eliminate-local-variables.
The aim of this pass is to improve performance in cases where local
variables are costly -- for nondeterministic procedures,
for MLDS->C accurate GC, and for the .NET back-end.
compiler/ml_optimize.m:
Add a pass to eliminate local variables.
Also, don't optimize tail calls unless --optimize-tailcalls is set.
compiler/mercury_compile.m:
Invoke the ml_optimize pass once before ml_elim_nested
(with --optimize-tailcalls disabled), as well as once after it.
compiler/options.m:
doc/user_guide.texi:
Add an option --eliminate-local-variables to enable the new
optimization.
compiler/ml_elim_nested.m:
compiler/ml_util.m:
Move statement_contains_var and definition_contains_var
from ml_elim_nested.m to ml_util.m, for use by ml_optimize.m.
compiler/ml_elim_nested.m:
- Handle local variables with initializers; this is neccessary
now that ml_optimize gets run before ml_elim_nested.
- Don't allocate a stack frame struct and link it into the chain
if there are no local variables that contain pointers.
- In fixup_atomic_statement, handle foreign_proc_code more consistently.
- Add some comments.
Branches: main
Estimated hours taken: 50
Another substantial step towards supporting accurate garbage
collection for the MLDS->C back-end: generate code for the
GC tracing functions.
compiler/mlds.m:
Add new fields to store, with each local variable or argument
declaration, the code for the GC to trace that local variable
or argument.
compiler/ml_code_util.m:
Add a new procedure ml_gen_maybe_gc_trace_code to generate the
code for GC tracing a variable. The generated MLDS code calls
private_builtin:gc_trace/1, passing the variable's address and
the type_info for that variable. This code is generated by
invoking polymorphism__make_type_info_var to generate HLDS code
to build the type_infos needed, and then calling ml_code_gen.m
to convert that to MLDS.
library/private_builtin.m:
Add a new procedure gc_trace, which calls MR_agc_deep_copy().
This gets invoked by the code generated by ml_code_util.m.
compiler/polymorphism.m:
Export polymorphism__make_type_info_var, for use by ml_code_util.m.
compiler/mercury_compile.m:
Invoke the chain_gc_stack_frames pass before invoking the
hoist_nested_functions pass, since otherwise it doesn't work.
compiler/handle_options.m
Add a couple of checks for options that are not supported
in combination with `--gc accurate'.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/rtti_to_mlds.m:
Various changes to handle the GC trace code field for variable and
argument declarations.
Estimated hours taken: 2
Branches: main
Merge changes to add attributes to the HLDS, MLDS and ILDS from the
dotnet-foreign branch. We don't merge the changes to add syntax for
attributes, as the syntax is still very experimental.
compiler/hlds_pred.m:
compiler/prog_data.m:
Add attributes to the pred_info (they are a bit like markers,
but are more than just boolean flags).
compiler/ilasm.m:
Add custom attributes to appropriate positions (on assemblies,
IL types and methods).
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_util.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
Add mlds__attributes, which are the MLDS version of custom attributes.
Convert hlds_pred__attributes into mlds__attributes.
Add a list of mlds__attributes to the mlds__function defn.
compiler/mlds_to_il.m:
Convert MLDS attributes to IL custom attributes.
Estimated hours taken: 0.75
Branches: main
Use a new mlds__function_body type to represent function bodies, as the old
usage of maybe/1 was error prone ("no" meant the function had been declared
using :- pragma external, not merely that the body was missing).
compiler/mlds.m:
Add mlds__function_body type.
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
Handle this change.
Estimated hours taken: 40
Branches: main
Refactor the top level of mlds_to_il so that we only do one pass over
the MLDS to generate the ILDS. As a side effect of this change nondet
code now works again.
compiler/mlds_to_il.m:
Do a MLDS to MLDS transformation which places all the procedures and
data into the mercury_code class. Then modify all the qualifiers to
take account of this change to the code.
Rewrite the top level so that it only does one pass over the MLDS
data structure.
Examine the flags when deciding which attributes to place on a
method, field or class.
compiler/mlds.m:
Add a new field to mlds__class_defn which is the list of
defns which are constructors for this class.
Add the functions mlds__append_mercury_code and mlds__append_name
which append either "mercury_code" or an arbitary string to the
module qualifier of a name.
compiler/ml_elim_nested.m:
Rather then hardcoding the generation of the constructor for the
environment class, we generate it here as an MLDS method.
On the IL backend the mercury code is placed in a seperate class to
the environment data, so the env_type decls must be public so as to
be accessible from the code.
compiler/ml_code_util.m:
Wrapper functions should be static methods not instance methods.
Fix ml_gen_label_func_decl_flags to make this true.
compiler/rtti_to_mlds.m:
Rtti data structures should be one_copy (ie static) not per_instance.
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_java.m:
Misc changes to handle the additon of a list of constructors to the
mlds__class_defn.
compiler/mlds_to_csharp.m:
compiler/mlds_to_mcpp.m:
Use the function class_name rather then mercury_module_name_to_mlds.
Estimated hours taken: 4
Branches: main
The .NET backend requires that names are not only qualified with their
namespace but the source package the name comes from. In this change we
back out a previous solution to this problem and implement a much
neater solution where we hide the package name in the abstract type
mlds_module_name.
This solution is neater because the package name shouldn't change once
the name is defined. All that we may have to change is the qualifiers
to the name.
compiler/mlds.m:
Add the package name to the abstract type mlds_module_name.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/rtti_to_mlds.m:
Back out previous solution.
Estimated hours taken: 16
Branches: main
The .NET backend requires that names are not only qualified with their
namespace but the source package the name comes from. In this change we
add to the name type the name of the source package which this name is
defined in. This change will be needed for implementing foreign_class
in the .NET backend where it will no longer be possible to determine
the package name from the fully qualified name.
compiler/mlds.m:
Add the new field to the mlds__fully_qualified_name type.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/rtti_to_mlds.m:
Propogate the changes around.
Estimated hours taken: 45
Branches: main
Implement a C# interface for the .NET backend.
To use it, you currently need to set
--backend-foreign-language csharp --use-foreign-language csharp
in your MCFLAGS.
The C# foreign language interface works by introducing a new sort of
MLDS statement called outline_foreign_proc. outline_foreign_proc is expected
to be turned into a separate procedure in a separate file. This is
quite different to normal foreign code which has been renamed as inline
target code, as it is really intended to be generated inline, inside the
generated code.
Because outline_foreign_proc is expected to be generated outside the
normal code, we don't need to generate variable renamings,
initializations, casts and other complicated interfacing code.
Any marshalling is done by the backend, which knows how to marshall
arguments across the boundary into the outline code and back. In the
case of marshalling to C# from the .NET backend, we currently don't do
anything special (part of the point of .NET is that data
representation don't have to change very often just because you are
using different languages, so this is a property we should try to
preserve).
The actual implementation of the foreign code is therefore very simple.
Simply generate an appropriate procedure, and insert the user's code in
the middle.
The bulk of this change to delay the mangling of MLDS var names, so we
can still use the original user's var name when we output the outline
procedure (since the user's foreign code will refer to these var names,
it's important to keep them around).
compiler/foreign.m:
Handle the csharp foreign language.
compiler/globals.m:
Fix an XXX about converting to lowercase to do language name
comparisons.
Add new predicates to make conversion of foreign languages
to strings more uniform.
compiler/handle_options.m:
Don't set backend_foreign_language to the default if it has
already been set by hand.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
Delay the mangling of MLDS var names by keeping the variable
number around until the output phase.
Slightly generalize the handling of foreign language interfacing.
Handle C# foreign language interfacing.
Add value_output_vars to the ml_gen_info, which are the variables
returned rather than passed by reference. We need to know
these variables for C# interfacing so that we can handle the return
value of the forwarding function.
Mark the beginning and end of the MLDS foreign language processing as
a "sub-module" (in comments at least). Later I may put this code
into a separate module.
Rename some predicates from c_code to foreign_code.
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/rtti_to_mlds.m:
Handle the new var_name type, and the new target_code constructors.
compiler/mlds.m:
Add outline_foreign_proc which is handled differently to the old
target_code (which has been renamed inline_target_code).
Change the definiton for mlds__var_name.
compiler/mlds_to_c.m:
Factor out mlds_output_to_file.
Handle the new var_name type, and the new target_code constructors.
compiler/mlds_to_csharp.m:
A new module to generate C# code suitable for foreign language
interfacing. This is largely lifted from the MC++ code, with a few
changes to the output syntax.
compiler/mlds_to_il.m:
Return the set of foreign languages processed instead of a bool
saying wither MC++ was present. This is so we can generate the
appropriate output .cs or .cpp files, and because we need to keep
track of all the external assembly references we need to put in the
.il file.
Handle the inline_target_code and mlds__var_name changes.
compiler/mlds_to_ilasm.m:
Output .cpp and .cs files conditionally.
Factor out output_to_file.
Move MC++ output code to mlds_to_mcpp.m
compiler/mlds_to_java.m:
Factor out output_to_file.
Handle the new var_name type, and the new target_code constructors.
compiler/mlds_to_mcpp.m:
New file to handle generating MC++ code suitable for foreign language
interfacing.
compiler/options.m:
Add a way of setting the backend-foreign-language option.
compiler/passes_aux.m:
Add output_to_file which is used by the MLDS backend to generate
output files.
compiler/prog_data.m:
Uncomment csharp as a foreign language.
Estimated hours taken: 20
General improvements and bug fixes to the MLDS backend, most
of which were prompted by working on the Java backend.
The definition of mlds__lval now includes type information for
variables. This is necessary because if enumerations are treated
as objects (as in the Java backend) rather than integers we need to know
when to create new objects. At the level this occurs there was
previously no way to distinguish between an integer that is an integer,
and one that represents an enumeration.
Added the access specifier `local' to the declaration flags. This fixes
a bug in which the local variables of a function were being declared
`private'.
Redefined ctor_name so that they are fully qualified. This was necessary
because the Java backend represents discriminated unions as nested
classes and we need to be able to determine the fully qualified name of
the constructor in order to call it, do casts, etc.
Added `mlds__unknown_type' to `mlds__type'. This is due to the change
in the definition of mlds_lval above. In ml_code_util.m, env_ptr's are
created as dangling references. The new definition of mlds__lval expects
there to be a type as well, but at this point it hasn't been
generated (and won't be until the ml_elim_nested pass). Rather than just
guess the type we should declare the type to be unknown and print out an
error message if an unknown type makes it through to one of the backends.
Fixed a bug in the `--det-copy-out' option.
Shifted code for detecting entry point to main/2 from mercury_compile.m
to ml_util.m
compiler/mercury_compile.m:
compiler/ml_util.m:
Shifted code for detecting entry point to main/2 from mercury_compile.m
to ml_util.m
compiler/mlds.m:
Added `local' as an access specifier.
Extended definition of mlds__lval to include type information
for variables.
Added `mlds__unknown_type' to the mlds types so that when
the compiler generates variables without yet knowing their
type we can mark them as this, rather than hoping that the
correct types eventually get added.
Redefined ctor_name so that it is fully qualified.
Made changes to comments to reflect above changes.
compiler/ml_code_gen.m:
Mark the generated functions as `one_copy' rather than `per_instance',
so that they get generated as static methods for the Java back-end.
Fixed a bug with the --det-copy-out option.
compiler/ml_code_util.m:
Fixed a bug that was causing the wrong declaration flags to be
set for fields in du constructors.
Changed the name of the predicate `ml_qualify_var' to
`ml_gen_var_lval'.
compiler/ml_type_gen.m:
Mark the generated types as `one_copy' rather than `per_instance',
so that they get generated as static nested classes for the Java
back-end.
Changed comments to reflect that classes and enumeration constants
should be static.
Export functions that generate declaration flags because they
are used in other modules as well.
Added a new predicate `ml_gen_mlds_field_decl' that correctly
generates fields of classes in discriminated unions.
compiler/ml_unify_gen.m:
Changed the code that generates ctor_id's so that it generates
the new sort.
compiler/ml_call_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_tailcall.m:
compiler/mlds_to_il.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_ilasm.m:
compiler/rtti_to_mlds.m:
Fixed things so that they conform to the changes above.
Estimated hours taken: 0.25
Address juliensf's review comments on my recent change to add an MLDS
optimization to convert assignments into initializers.
compiler/ml_optimize.m:
doc/user_guide.texi:
Fix some typos.
compiler/options.m:
Wrap some long lines.
Estimated hours taken: 1.5
Add an MLDS optimization to convert assignments into
initializers.
compiler/options.m:
doc/user_guide.texi:
Add new option `--optimize-initializations'.
compiler/ml_optimize.m:
Implement the new optimization.
compiler/ml_elim_nested.m:
compiler/ml_util.m:
Move initializer_contains_var, rval_contains_var and related
predicates from ml_elim_nested.m to ml_util.m, for use by
ml_optimize.m.
Estimated hours taken: 16
Add an MLDS to MLDS transformation that converts MLDS switches
into computed gotos or if-then-else chains. (Eventually we
should make this code also handle binary searches.)
This transformation should allow tag switch optimization to work for
the IL back-end. It also replaces ml_dense_switch.m and lets us
simplify ml_string_switch.m.
compiler/mlds.m:
Add a new `switch_range' field to the `switch' stmt.
compiler/ml_simplify_switch.m:
The new transformation. This converts MLDS switches into
computed gotos or if-then-else chains.
It uses the new `switch_range' field to determine how big
it would need to make the jump table to cover all cases.
compiler/ml_switch_gen.m:
compiler/ml_string_switch.m:
compiler/ml_tag_switch.m:
compiler/ml_dense_switch.m:
Generate the new field.
Change the places that generate switches so that after
generating the switch they invoke the new transformation.
Delete ml_dense_switch.m, since it is now redundant,
and significantly simplify ml_string_switch.m.
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
Trivial changes to handle the new field.
compiler/switch_util.m:
compiler/dense_switch.m:
Move most of the code from the `type_range' procedure from
dense_switch.m to switch_util.m, so we can use it in
ml_switch_gen.m for computing the switch range.