compiler/*.m:
deep_profiler/*.m:
As above.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Add is_non_empty to the set modules that did not already have it.
(Some did, some didn't.)
Make the documentation of empty, is_empty, non_empty and is_non_empty
consistent.
compiler/*.m:
Module qualify the end_module declarations. In some cases, add them.
compiler/table_gen.m:
Remove an unused predicate, and inline another in the only place
where it is used.
compiler/add_pragma.m:
Give some predicates more meaningful names.
Branches: main, 11.07 (partial)
Fix bug #248: make the argument order of the singleton_set/2 predicates in the
various set modules in the standard library consistent. (This breaks backwards
compatibility but in a fairly minor way.)
Add the predicate is_singleton/2 to those set modules that do not already
provide it.
Fix a bug in the implementation of set_unordlist.singleton_set/2.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_unordlist.m:
Swap the argument order of singleton_set/2.
Add is_singleton/2 where it wasn't already present.
library/set_unordlist.m:
Fix a bug: singleton_set/2 failed to take account of
the fact that the representation could contain duplicates
in the singleton_setT::out, set_unordlist(T)::in) mode.
The fix is to sort and remove the duplicates before checking
whether the set is singleton.
NEWS:
Announce the above changes.
library/eqvclass.m:
library/tree234.m:
compiler/accumulator.m:
compiler/code_info.m:
compiler/graph_colour.m:
compiler/higher_order.m:
compiler/lp_rational.m:
compiler/ml_tag_switch.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/proc_gen.m:
compiler/prog_mode.m:
compiler/term_pass1.m:
compiler/type_constraints.m:
compiler/unneeded_code.m:
compiler/var_locn.m:
deep_profiler/autopar_costs.m:
deep_profiler/var_use_analysis.m:
tests/general/set_test.m:
Conform to the above changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/singleton_dups.{m,exp}:
Add a regression test for the problem with set_unordlist.singleton_set/2.
Estimated hours taken: 24
Branches: main
Predicates with many variables, such as some of those in zm_enums.m,
tickle pretty bad behavior in the liveness and stack_alloc passes.
This is because those passes manipulate sets of variables, which in
such cases are large sets of variables, and the quadratic behavior
of repeated operations on sets represents as sorted lists hurts us.
This diff changes the representation of the sets of variables involved
in those two passes, which are the prebirth, postbirth, predeath and postdeath
sets in goal_infos, to be values of an abstract type (set_of_progvar).
By default, these are implemented using tree_bitsets, which have much better
worst case behaviour that set_ordlists.
When compiling zm_enums with debugging enabled, this diff speeds up
the liveness pass by about half and the stack alloc pass by about a third,
with the overall speedup being about 6% (due to some other expensive passes).
On tools/speedtest -l, the result is a 3.4% slowdown. Since the slowdown
worsens slightly if I make the abstract representation of sets of prog_vars
be the existing representation (an ordinary set), I think this slowdown is
due to the conversions that are now required in some places between the
abstract representation and an explicit set(prog_var) representation.
As such, as other uses of set(progvar) get converted to set_of_progvar,
this slowdown should disappear.
compiler/set_of_var.m:
The new module that contains the set_of_progvar abstract data type.
This module also contains a copy of the code of the graph_colour
module. Since the set_of_progvar type is private, this is necessary
if we want all the set operations done by graph colouring (which does
the bulk of the work of the stack alloc pass) to use the preferred
set representation.
compiler/graph_colour.m:
Note that this module is no longer used.
compiler/stack_alloc.m:
compiler/liveness.m:
Switch over to using the new module.
compiler/parse_tree.m:
Include set_of_var among the modules of this package. (It is in this
package because the prog_var type is defined in this package.)
compiler/test_bitset.m:
A module that allows new set implementations to be tested. It is
an extended and specialized version of the bitset_tester module
from tests/hard_coded.
compiler/hlds_llds.m:
Use the set_of_progvar type for the prebirth, postbirth, predeath
and postdeath sets in goal_infos, and for other liveness-related
sets of variables.
compiler/code_info.m:
Some of the fields of the code_info structure represent sets of
variables, and some of the predicates defined by this module have
arguments that are sets of variables. If these sets represent entities
that are computed from prebirth, postbirth, predeath and postdeath
sets or from other goal_info fields that have been changed to the
set_of_progvar representation, change them to use the set_of_progvar
representation as well, or, in a few cases, to plain sorted lists.
Conform to the above change.
compiler/proc_type.m:
Add a utility predicate to operate of set_of_progvar.
Replace a lambda expression with a named predicate.
compiler/quantification.m:
Until now, quantification.m used its own private abstract type
(defined as tree_bitset) to represent sets. Make it use set_of_progvar
instead, since it has the same purpose. This eliminates a potential
maintenance problem.
compiler/call_gen.m:
compiler/code_gen.m:
compiler/commit_gen.m:
compiler/delay_construct.m:
compiler/disj_gen.m:
compiler/hlds_out_goal.m:
compiler/hlds_rtti.m:
compiler/interval.m:
compiler/ite_gen.m:
compiler/live_vars.m:
compiler/lookup_switch.m:
compiler/lookup_util.m:
compiler/matching.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/pragma_c_gen.m:
compiler/proc_gen.m:
compiler/simplify.m:
compiler/stack_opt.m:
compiler/store_alloc.m:
compiler/string_switch.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_sharing.domain.m:
compiler/switch_util.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/unify_gen.m:
compiler/unused_args.m:
Conform to the above change.
library/map.m:
Add a utility predicate, map.select_sorted_list, which functions the
same way as map.select, but takes a sorted list as argument instead of
a set.
library/set_ordlist.m:
Bring the interface of this module closer to set.m and tree_bitset.m
to make them more easily interchangeable. This required adding the
predicates is_non_empty and is_singleton, as well as adding predicate
forms of union_list and intersect_list.
I also added missing type_spec pragmas for some predicates frequently
used by the compiler.
library/tree_bitset.m:
Bring the interface of this module closer to set.m and set_ordlist.m
to make them more easily interchangeable. This required adding the
predicates is_non_empty and is_singleton, and both function and
predicate forms of union_list and intersect_list.
Fix an old bug in the difference operation. Given SetA - SetB,
if SetA was the empty set, then this operation would correctly
return the empty set if SetB was small (represented by a leaf list),
but would incorrectly return SetB if it was large (represented by
an interior node list).
Estimated hours taken: 6
Branches: main
compiler/*.m:
Convert almost all remaining modules in the compiler to use
"$module, $pred" instead of "this_file" in error messages.
In a few cases, the old error message was misleading, since it
contained an incorrect, out-of-date or cut-and-pasted predicate name.
tests/invalid/unresolved_overloading.err_exp:
Update an expected output containing an updated error message.
Branches: main
Change the argument ordering of predicates in the set module.
library/set.m:
Change predicate argument orders to match the versions
in the svset module.
Group function definitions with the corresponding predicates
rather than at the end of the file.
Delete Ralph's comments regarding the argument order in the
module interface: readers of the library reference guide are
unlikely to be interested in his opinion of the argument ordering
ten or so years ago.
Add extra modes for set.map/3 and set.map_fold/5.
library/svset.m:
library/eqvclass.m:
library/tree234.m:
library/varset.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
mdbcomp/trace_counts.m:
extras/moose/grammar.m:
extras/moose/lalr.m:
extras/moose/moose.m:
tests/hard_coded/bitset_tester.m:
Conform to the above change.
NEWS:
Announce the above changes.
Estimated hours taken: 2
Branches: main
Add the predicates sorry, unexpected and expect to library/error.m.
compiler/compiler_util.m:
library/error.m:
Move the predicates sorry, unexpected and expect from compiler_util
to error.
Put the predicates in error.m into the same order as their
declarations.
compiler/*.m:
Change imports as needed.
compiler/lp.m:
compiler/lp_rational.m:
Change imports as needed, and some minor cleanups.
deep_profiler/*.m:
Switch to using the new library predicates, instead of calling error
directly. Some other minor cleanups.
NEWS:
Mention the new predicates in the standard library.
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
Various cleanups for the modules in the compiler directory. The are
no changes to algorithms except the replacement of some if-then-elses
that would naturally be switches with switches and the replacement of
most of the calls to error/1.
compiler/*.m:
Convert calls to error/1 to calls to unexpected/2 or sorry/2 as
appropriate throughout most or the compiler.
Fix inaccurate assertion failure messages, e.g. identifying the
assertion failure as taking place in the wrong module.
Add :- end_module declarations.
Fix formatting problems and bring the positioning of comments
into line with our current coding standards.
Fix some overlong lines.
Convert some more modules to 4-space indentation. Fix some spots
where previous conversions to 4-space indentation have stuffed
the formatting of the code up.
Fix a bunch of typos in comments.
Use state variables in more places; use library predicates
from the sv* modules where appropriate.
Delete unnecessary and duplicate module imports.
Misc. other small cleanups.
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: 4
Branches: main
compiler/*.m:
Convert a bunch of modules to four-space indentation.
In the process, fix departures from our coding standards.
In some cases, do minor other cleanups such as changing argument orders
to be friendly to state variables.
There are no algorithmic changes.
Estimated hours taken: 3
Branches: main
compiler/*.m:
Import only one module per line in the modules of the compiler
where my previous diff did not already do so.
Misc other cleanups.
Where relevant, use the new mechanism in tree.m.
compiler/tree.m:
Fix a performance problem I noticed while update :- import_module
items. Instead of supplying a function to convert lists of trees
to a tree, make the tree data structure able to hold a list of
subtrees directly. This reduces the number of times where we have to
convert list of trees to trees that are sticks just to stay within
the old definition of what a tree is.
Estimated hours taken: 8
Branches: main
analysis/analysis.m:
browser/browse.m:
compiler/accumulator.m:
compiler/assertion.m:
compiler/atsort.m:
compiler/c_util.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_model.m:
compiler/const_prop.m:
compiler/constraint.m:
compiler/dead_proc_elim.m:
compiler/delay_construct.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/export.m:
compiler/fact_table.m:
compiler/follow_code.m:
compiler/graph_colour.m:
compiler/hlds_module.m:
compiler/inlining.m:
compiler/llds.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
compiler/ml_tailcall.m:
compiler/ml_unify_gen.m:
compiler/mmc_analysis.m:
compiler/mode_errors.m:
compiler/passes_aux.m:
compiler/post_typecheck.m:
compiler/size_prof.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_errors.m:
compiler/transform_llds.m:
compiler/type_util.m:
compiler/unify_gen.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
Bring these modules up to our current coding standards. Use predmode
declarations and state variable syntax where relevant. Reorder
arguments where this is needed for the use state variables. Make the
orders of predicate definitions correspond to the order of their
declarations. Replace some overly large lambda expressions with named
predicates. Convert some predicates to functions where this makes
their use more convenient. Use field access notation where convenient.
Fix any inconsistent indentation. Remove module prefixes on predicate
names where this is necessary to allow sane indentation.
In several places, use predicates from error_util.m to print error
messages. Apart from this, there are no changes in algorithms.
In some places, conform to the changes below.
compiler/error_util.m:
compiler/hlds_error_util.m:
Add new variants of existing predicates for use in some of the
changed modules above.
compiler/hlds_out.m:
Add some functions to convert values of some HLDS types as strings,
for use in preparing the arguments of the new calls to predicates in
error_util.m. Change the implementations of the predicates that print
values of those types to call those functions instead of allowing
code duplication.
compiler/llds.m:
Add some field names to allow use of field updates where relevant.
tests/invalid/assert_in_interface.err_exp:
tests/invalid/multisoln_func.err_exp:
tests/invalid/tricky_assert1.err_exp:
Update the expected outputs of these test cases to allow for them being
generated by error_util.m, and hence being better formatted than
before.
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.75
library/*.m:
compiler/*.m:
Undo Zoltan's bogus update of all the copyright dates.
The dates in the copyright header should reflect the years
in which the file was modified (and no, changes to the
copyright header itself don't count as modifications).
Estimated hours taken: 2
compiler/graph_colour.m:
Add a comment about why a bit of code is commented out.
compiler/quantification.m:
Fix a bug - lambda variables in parallel scopes were not
being renamed apart properly and this was causing spurious
type errors (thanks philip for the bug report).
compiler/*:
Add copyright messages.
Change all occurences of *.nl in comments to *.m.
compiler/mercury_compile.pp:
Change the output to the .dep files to use *.m rather than *.nl.
(NOTE: this means that `mmake' will not work any more if you
call your files *.nl!!!)
code_info.nl, unify_gen.nl:
Fix bugs introduced by zoltan's mods to llds.
live_vars.nl:
Change the way that stack slot reuse is done. The
problem is now reduced to a graph colouring problem,
rather than having a wishy-washy inline algorithm.
set.nl:
Fix a bug in the interface imports introduced by zs.
graph_colour.*:
A module for grouping *things* by colour. The algorithm
is *correct* but not necessarily optimal or efficient. :-)