Commit Graph

42 Commits

Author SHA1 Message Date
Julien Fischer
a7a6db5112 Delete obsolete predicates from set modules.
library/diet.m:
library/fat_sparse_bitset.m:
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
library/sparse_bitset.m:
library/tree_bitset.m:
    Delete predicates and functions that have been marked as obsolete
    since at least 2019.

    Adjust documentation as required.

NEWS:
    Announce the deletions.
2022-04-13 19:53:47 +10:00
Zoltan Somogyi
8ff61f8a4b Delete quotes from `VarNames' in stdlib comments.
In the Mercury standard library, every exported predicate or function
has (or at least *should* have) a comment that documents it, including
the meanings of its arguments. About 35-40% of these modules put `'s
(left and right quotes) around the names of the variable representing
those arguments. Some tried to do it consistently (though there were spots
with unquoted or half quoted names), while some did it only a few places.
This is inconsistent: we should either do it everywhere, or nowhere.
This diff makes it nowhere, because

- this is what the majority of the standard library modules do;
- this is what virtually all of the modules in the compiler, profiler,
  deep_profiler etc directories do;
- typing all those quotes when adding new predicates in modules that
  follow this convention is a pain in the ass; and because
- on many modern terminals, `' looks non-symmetrical and weird.

Likewise, the comment explaining a predicate often started with

    % `predname(arguments)' returns ...

This diff deletes these quotes as well, since they add nothing useful.

This diff does leave in place quotes around code fragments, both terms
and goals, where this helps delineate the boundaries of that fragment.
2022-03-07 11:49:00 +11:00
Zoltan Somogyi
06f81f1cf0 Add end_module declarations ...
.. to modules which did not yet have them.
2022-01-09 10:36:15 +11:00
Zoltan Somogyi
0d7c8a7654 Specify pred or func for all pragmas.
*/*.m:
    As above.

configure.ac:
    Require the installed compiler to support this capability.
2021-06-16 15:23:58 +10:00
Zoltan Somogyi
2c68193c08 Mark some redundant library predicates obsolete.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
    Mark empty/1 and non_empty/1 as obsolete with is_empty and is_non_empty
    as suggested replacements, and mark set/1 as obsolete with list_to_set/1
    as suggested replacement.

NEWS:
    Mention the above changes.

configure.ac:
    Require the installed compiler to handle suggested replacements
    in obsolete pragmas.

compiler/analysis.m:
    Avoid calling the newly obsolete predicates.

    Remove a workaround that probably hasn't been needed in a long time.

compiler/error_util.m:
compiler/hlds_args.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/options.m:
compiler/ordering_mode_constraints.m:
compiler/par_conj_gen.m:
compiler/parse_pragma.m:
compiler/prog_ctgc.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/rbmm.live_region_analysis.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/term_constr_fixpoint.m:
compiler/term_constr_util.m:
compiler/tupling.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_annotate.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
    Avoid calling the newly obsolete predicates.
2019-09-13 20:03:01 +10:00
Zoltan Somogyi
600846b50c Reduce differences between library/set*.m.
library/set*.m:
    Add det_remove and det_remove_list predicates to the set modules
    that did not yet have them.

    Add rev_sorted_list_to_set in both predicate and function form
    to the set modules that did not yet have such functionality.
    Note: some modules had such a function, but not predicate.
    This diff leaves those modules alone.

    Document that the input to sorted_list_to_set predicates and functions
    should not have duplicates, unless the predicate in question detects
    and removes duplicates. The different set modules are inconsistent
    in this regard.

    Use consistent variable names.

NEWS:
    Announce the new predicates and functions.
2019-09-08 13:23:56 +10:00
Zoltan Somogyi
2d75427f0d Put the contents of library/set*.m into a meaningful order.
library/set.m:
    Organize the predicates of this modules a lot better, clustering
    related predicates into named groups, and imposing a meaningful order
    both within and among groups.

library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
    Put the predicates of these modules into the same order as set.m
    as far as possible given that some of these modules define predicates
    that set.m doesn't, and vice versa.

    Delete any redundant module qualifications in clause heads and predicate
    and function declarations. In calls to error, use $pred to specify the
    location.

library/Mercury.options:
    Require the order of definitions in these modules to match the order
    of declarations.
2019-09-06 02:45:45 +10:00
Zoltan Somogyi
95f8f56716 Delete unneeded $module args from calls to expect/unexpected. 2019-07-03 22:37:19 +02:00
Zoltan Somogyi
ae4b736fdd Implement warnings for suspicious recursion.
compiler/simplify_goal_call.m:
    If the --warn-suspicious-recursion option is set, and if the warning
    isn't disabled, generate warnings for two different kinds of suspicious
    recursion. They are both related to, but separate from, the warning
    we have long generated for infinite recursion, which occurs when
    the input args of a recursive call are the same as the corresponding
    args in the clause head.

    Both kinds suspicious recursion look at the input args of a recursive call
    that are NOT the same as the corresponding args in the clause head.
    Both require these args to have non-unique modes. (If they have unique
    modes, then the depth of the recursion may be controlled by state outside
    the view of the Mercury compiler, which means that a warning would be
    likely to be misleading.)

    The first kind is when all these args use state variable notation.
    Most of the time, we use state var notation to denote the data structures
    updated by the recursive code; having variables using such notation
    *controlling* the recursion is much less common, and much more likely
    to be unintended. The motivation for the new option was this infinitely
    looping code, which resulted from neglecting to s/[X | Xs]/Xs/ after
    cutting-and-pasting the clause head to the recursive call.

    p([X | Xs], !S) :-
        ...,
        p([X | Xs], !S).

    The other kind of suspicious recursive call we warn about involve
    input arguments where the base names of the input arguments (the part
    before any numeric suffixes) seem be switched between the clause head
    and the recursive call, as here:

    q(As0, Bs0, ...) :-
        ...,
        q(Bs1, As, ...).

compiler/mercury_compile_main.m:
    Disable style warnings when invoked with --make-optimization-interface
    or its transitive variant. Without this, warnings about suspicious
    recursion would get reported in such invocations.

    Move a test from a callee to a caller to allow the callee to be
    less indented.

compiler/options.m:
    Export functionality to mercury_compile_main.m to make the above possible.

library/string.m:
    Add a predicate to convert a string to *reverse* char list directly.

    Note a discrepancy between the documentation and the implementation
    of the old predicate the new one is based on (which converts a string
    to a forward char list).

NEWS:
    Note the new predicate in string.m.

compiler/cse_detection.m:
compiler/ctgc.selector.m:
compiler/dead_proc_elim.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/distance_granularity.m:
compiler/frameopt.m:
compiler/inst_util.m:
compiler/lp_rational.m:
compiler/matching.m:
compiler/modes.m:
compiler/old_type_constraints.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_arguments.m:
compiler/recompilation.usage.m:
compiler/stratify.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.indirect.m:
compiler/typeclasses.m:
compiler/use_local_vars.m:
deep_profiler/callgraph.m:
deep_profiler/canonical.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
library/calendar.m:
library/diet.m:
library/lexer.m:
library/parser.m:
library/parsing_utils.m:
library/ranges.m:
library/set_ctree234.m:
library/set_tree234.m:
library/string.parse_util.m:
library/tree234.m:
library/varset.m:
mdbcomp/program_representation.m:
mdbcomp/rtti_access.m:
profiler/demangle.m:
    Avoid warnings for suspicious recursion. In most cases, do this by
    wrapping disable_warning scopes around the affected recursive calls;
    in a few cases, do this by changing the code.

tests/warnings/suspicious_recursion.{m,exp}:
    A test case for the new warnings.

tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
    Enable the new test case.
2019-05-01 21:29:05 +10:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.

COPYING.LIB:
    Add a special linking exception to the LGPL.

*:
    Update references to COPYING.LIB.

    Clean up some minor errors that have accumulated in copyright
    messages.
2018-06-09 17:43:12 +10:00
Zoltan Somogyi
d9e576a2b2 Specify the type for inst definitions.
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
library/*.m:
mdbcomp/*.m:
ssdb/*.m:
    Specify the type constructor for every inst definition that lists
    the functors that values of that type may be bound to.

    In library/maybe.m, delete the inst maybe_errors/1, because
    (a) its name is misleading, since it is for the maybe_error/1 type (no s),
    and (b) there is already an inst with the non-misleading name maybe_error
    which had an identical definition.

    In compiler/dep_par_conj.m, delete two insts that were duplicates
    of insts defined in hlds_goal.m, and replace references to them
    accordingly.
2017-11-08 16:54:18 +11:00
Zoltan Somogyi
5057ab7e04 Use explicit streams in some library modules.
library/backjump.m:
library/exception.m:
library/getopt_io.m:
library/psqueue.m:
library/set_ctree234.m:
library/set_tree234.m:
library/tree234.m:
    Avoid using implicit streams.

library/io.m:
    Add a version of the write_cc predicate that allows callers
    to specify an explicit stream.

    Fix what seems like an old bug in read_binary_file_as_bitmap: it was not
    reading from the file at all.

    Use explicit module qualification in some places to make the code more
    readable.

library/table_statistics.m:
    Add a version of the write_table_stats predicate that allows callers
    to specify an explicit stream.

    Avoid using implicit streams inside the module as well.

library/term_io.m:
    Add versions of the predicates that read terms that allow callers
    to specify an explicit stream.

    Avoid using implicit streams inside the module as well.

library/parser.m:
    Add module qualifications that are needed after the new addition of new
    predicates to term_io.m.

library/stream.m:
library/stream.string_writer.m:
    Fix style.
2016-10-30 00:49:21 +11:00
Zoltan Somogyi
213fba5f48 Speed up set_tree234.list_to_set. 2016-07-27 12:11:06 +02:00
Zoltan Somogyi
44f9f1f405 Convert (C->T;E) to (if C then T else E). 2015-12-01 07:58:07 +11:00
Zoltan Somogyi
aaf9b2aab4 Add intersection_and_difference on sets.
library/set.m:
library/set_ordlist.m:
library/set_ctree234.m:
library/set_tree234.m:
    As above.

    Make the divide operation faster in the 234 tree modules.

    Remove unnecessary module qualifications. Give some internal predicates
    better names.

NEWS:
    Announce the new predicates.
2015-01-06 22:30:50 +11:00
Zoltan Somogyi
4d172ad8f0 Make set_tree234.sorted_list_to_set use sortedness.
Also, add set_tree234.rev_sorted_list_to_set.

library/set_tree234.m:
    As above. The implementation of both predicates is copied from tree234.m,
    mutatis mutandis.

    Add the applicable type specializations.

    Put the nearby predicates in a more logical order.

library/set_ctree234.m:
    Replace the existing implementation of set_ctree234.sorted_list_to_set
    with a copy of the one in set_tree234.m.

    Add an implementation of set_ctree234.rev_sorted_list_to_set.

library/tree234.m:
    Make some code clearer.
2015-01-05 07:19:16 +11:00
Zoltan Somogyi
7f9791aa26 Standardize divider line lengths in the library.
library/*.m:
    As above.

tool/stdlines:
    A new shell script to do the job.
2014-11-23 22:05:34 +11:00
Zoltan Somogyi
fe785c668b Consistently use set.is_empty and set.is_non_empty.
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.
2014-11-04 23:18:43 +11:00
Julien Fischer
bed96b93ff Avoid module qualification in library interfaces where possible.
NOTE: this change does not affect the io module -- I've left that for a
separate change.

library/*.m:
	As per the recent change to the coding standard, avoid module
	qualification in library interfaces where possible.

	Reformat declarations and descriptive comments to better utilise
	any space freed up by the above.
2014-10-10 15:08:24 +11:00
Zoltan Somogyi
8855df69cd Add foldl, foldl2, ... foldl6 as synonyms for fold, fold2, ... fold6.
Estimated hours taken: 1
Branches: main

library/set.m:
library/set_ordlist.m:
library/set_tree234.m:
	Add foldl, foldl2, ... foldl6 as synonyms for fold, fold2, ... fold6.
	This allows set_of_var.m to switch from tree_bitset.m to using these
	modules with just e.g. g/MODULE/s/tree_bitset/set_tree234/g.

compiler/set_of_var.m:
	Change the code to resolve an ambiguity that would otherwise arise
	after such a substitution.
2012-06-26 13:11:57 +00:00
Zoltan Somogyi
30383a8c47 Avoid some redundant work during determinism analysis.
Estimated hours taken: 3
Branches: main

Avoid some redundant work during determinism analysis. This diff speeds up
tools/speedtest by just shy of 0.7%.

compiler/det_analysis.m:
	Instead of (a) getting a list of procedures in the module and then
	(b) classifying them into three categories, do both jobs at once.
	This avoids some redundant traversals and map lookups, and avoids
	the creation of an intermediate data structure.

compiler/instmap.m:
	Instead of converting a set into a list and iterating over that list
	to check that elements of the set have a given property, iterate over
	the set elements directly.

	Put the arguments of a predicate in a more logical order.

compiler/det_util.m:
	Conform to the change in instmap.m.

compiler/set_of_var.m:
	Provide the all_true predicate needed by det_util.

library/*set*.m:
	In every module that implements sets, provide an all_true predicate.

NEWS:
	Mention the new predicates in the library.
2012-04-24 09:18:29 +00:00
Zoltan Somogyi
a54ae6232d Instead of first testing whether an inst exists in a set
Estimated hours taken: 8
Branches: main

compiler/inst_match.m:
	Instead of first testing whether an inst exists in a set
	and then inserting it if does not, use a single predicate
	that does both the membership test and the insertion (if
	the membership test failed) in one pass.

	This speeds up compilation of one version of the rcpsp_cpx
	stress test by about 9%, with negligible effect on tools/speedtest.

	Some cleanups that should have been committed before this diff follow.

	Change the structure of many of the predicates in this module from
	containing multiple clauses, to a single clause with an explicit
	disjunction, which (where relevant) now gets a require_comple_switch
	wrapper. In several cases, this change has shown that we were
	missing code for handling some kinds of insts. For example, some
	predicates handled free/0 but not free/1, even though there was
	no reason for the difference. This diff fixes such oversights
	in places where the right action seems obvious to me, and adds
	XXXs in places where I see no obvious fix.

	Rename several predicates and function symbols to avoid ambiguities.

	Add some XXXs on potential problems.

library/*set*.m:
	Implement this insert_new predicate for all the implementations
	of sets we have. The code in each case is copied from the code
	of insert, with code to return a set unchanged replaced with `fail'.

NEWS:
	Mention the new predicates.
2012-04-02 03:58:56 +00:00
Zoltan Somogyi
92343457e4 Our algorithms for performing union and intersection are linear
Estimated hours taken: 0.5
Branches: main

library/set_tree234.m:
	Our algorithms for performing union and intersection are linear
	in the size of the first argument, and logarithmic in the size
	of the second. Switch the arguments of the symmetric operations
	if their heights indicate that the first argument is significantly
	larger than the second.

	This diff allows set_tree234.m to work in not totally outrageous times
	when it is used to implement set_of_var.m. On Michael Day's nasty.m,
	this diff reduces the runtime of a such compiler by more than 94%,
	from more than 1000 seconds, to less than 60s. Of course, using
	the bitset modules, which is what set_of_var.m uses by default,
	is even faster.
2011-08-25 11:08:15 +00:00
Zoltan Somogyi
8eeb35dd7e Minor changes to allow set.m and set_ordlist.m to implement this
Estimated hours taken: 2
Branches: main

compiler/set_of_var.m:
	Minor changes to allow set.m and set_ordlist.m to implement this
	interface.

library/set_tree234.m:
library/tree_bitset.m:
	Add the functions and predicates needed to allow these modules
	to implement the functionality required by set_of_var.m.
2011-08-23 03:50:57 +00:00
Zoltan Somogyi
7c1757970e Avoid some redundant conversions between lists and sets.
Estimated hours taken: 3
Branches: main

compiler/stack_alloc.m:
	Avoid some redundant conversions between lists and sets. The main
	performance win is from avoiding a list_to_set conversion that
	requires sorting.

library/*set*.m:
	The change to stack_alloc.m requires the ability to partition a set
	based on predicate. Implement a version of filter that returns the
	false as well as the true cases in all the set modules. (Most set
	modules lacked the return-the-trues-only version of filter as well.)

NEWS:
	Mention the additions to the standard library.
2011-05-26 06:20:09 +00:00
Julien Fischer
48b14ecadd Add predicates named is_empty/1 as a synonym for empty/1 to all the modules in
Branches: main

Add predicates named is_empty/1 as a synonym for empty/1 to all the modules in
the standard library that provide sets.  The former name is less ambiguous than
the latter.

library/set*.m:
library/spare_bitset.m:
library/tree_bitset.m:
	Add is_empty/1 as a synonym for empty/1.

NEWS:
	Announce the above addition.
2011-05-10 05:26:52 +00:00
Julien Fischer
5ba6d9661c Make the interfaces of the set modules more consistent.
Branches: main

Make the interfaces of the set modules more consistent.

library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
library/set_bbbtree.m:
	Add the predicate non_empty/1 to the above modules.

	Add the from_list/1 function to those set modules that
	lack it.

library/set_bbbtree.m:
	Add the predicate count/2 and the function count/1.

	Deprecate the predicate size/2.

library/set_unordlist.m:
	Add the predicate count/2 and the function count/1.

NEWS:
	Announce the above.
2010-11-30 02:41:53 +00:00
Julien Fischer
80b5c2279c Support folds over sets with six accumulators.
Branches: main

Support folds over sets with six accumulators.

library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
	As above.

library/list.m:
	Add semidet modes for list.foldl6/14 with (mostly-) unique
	accumulators.

NEWS:
	Announce the above changes.
2010-11-13 16:49:27 +00:00
Julien Fischer
b176b9bc2c Support folds over sets with up to five accumulators in all the standard
library modules that provide sets.

Support mostly-unique and unique accumulators in set folds.
(These were provided in some set modules, but not in others.)

library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
	Add predicates for fold over sets with up to five accumulators.

	As per the coding standard, where an operation has both a
	function version and a predicate version, the declaration for
	the function version should occur first in stdlib modules.

	Fix up overlong lines.

library/set_bbbtree.m:
	Add an XXX regarding the implementation of fold.

library/list.m:
	Add additional modes to list.foldl3/8, list.foldl4/10,
	and list.foldl5/12 required by the above.

NEWS:
	Announce the changes.
2010-11-09 02:06:54 +00:00
Peter Wang
4451a4f995 Swap order of arguments of `set_tree234.member/2' to match other
Branches: main

library/set_tree234.m:
        Swap order of arguments of `set_tree234.member/2' to match other
        modules.

compiler/dead_proc_elim.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/format_call.m:
compiler/inst_match.m:
compiler/llds_out_instr.m:
compiler/passes_aux.m:
compiler/post_typecheck.m:
compiler/switch_detection.m:
compiler/typecheck.m:
library/list.m:
        Conform to change.

library/set.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_unordlist.m:
        Fix typos in documentation.
2010-11-08 03:43:43 +00:00
Zoltan Somogyi
62d7496a7e Significant further improvements in the worst-case behavior of the compiler
Estimated hours taken: 16
Branches: main

Significant further improvements in the worst-case behavior of the compiler
when working on code such as zm_eq20.m and zm_coerce_tuples.m. On my laptop,
zm_eq20.m and zm_coerce_tuples.m now compile in 2.5s and 12.9s respectively;
the times before were 86.4s and 54.0s. The sizes of the stage 110 HLDS dumps
(the stage just after lambda expansion) go from 8.5Mb and 760Mb (!) to
just 0.4Mb and 7.4Mb respectively.

compiler/polymorphism.m:
	Remember not just which typeinfos we have constructed, but also what
	type_ctor_infos, base_typeclass_infos and typeclass_infos we have
	constructed, so that we don't have to construct them again for code
	that is executed later.

	The maintenance of the additional maps adds some overhead that in
	typical code probably cannot be made back through the resulting
	reductions in the workload of later compiler passes. However,
	the avoidance of horrible worst-case behavior trumps small increases
	in normal-case runtime.

	For zm_coerce_tuples, polymorphism.m now generates as good HLDS code
	as can be expected within each lambda expression. There is still
	a lot of duplicated code, with each copy being in a different lambda
	expression, but factoring out these commonalities will require a
	fundamentally different approach.

	Avoid using the misleading prefix "TypeClassInfo_" on the names of
	variables holding base_typeclass_infos.

compiler/ml_elim_nested.m:
	Don't look for static definitions where they cannot occur anymore.

	When deciding whether a definition needs to be hoisted out,
	don't look for it being used in later static definitions,
	since all the static definitions are now elsewhere.

	In order to avoid running the compiler out of nondet stack space
	on zm_coerce_tuples.m, avoid the use of enumerating all the
	definitions in a potentially huge piece of MLDS by backtracking.

compiler/hlds_rtti.m:
	Avoid enumerating all the members of a potentially huge list
	by backtracking in order to avoid running the compiler out of nondet
	stack space on zm_coerce_tuples.m.

	I first tried to do this by constructing the list with det code,
	but this turned out not to fix the underlying problem, which was that
	almost all of the list's elements were copies of each other, and we
	then had to get rid of the copies. The actual fix is to gather the
	types we need directly as a set.

	Provide restrict_rtti_varmaps for use by lambda.m.

	Give the field names of the rtti_varmaps type a distinguishing prefix.

compiler/lambda.m:
	The fundamental reason for the bad performance of the equiv_type_hlds
	pass on zm_coerce_tuples.m was that even with the recent improvements
	to polymorphism.m, a couple of big predicates had about ten thousand
	variables each, and when lambda.m created about 200 new procedures
	from the lambda expressions inside them, it duplicated those huge
	vartypes and rtti_varmaps for each one.

	The fix is to restrict the vartypes and the rtti_varmaps of both
	the newly created procedures and the old procedure they were taken from
	to the variables that actually occur in them.

	We could potentially avoid the need to restrict the rtti_varmap
	of the original procedure for the new procedures created for lambda
	goals by having polymorphism.m give each rhs_lambda_goal its own
	rtti_varmap in the first place, but that would be future work.

	Use the "no lambda" version of quantification after the lambda pass,
	since we have just removed all the lambdas from the goal being
	quantified.

	Give the predicates of this module more expressive names.

compiler/mercury_compile.m:
	Conform to the change in lambda.m.

compiler/equiv_type_hlds.m:
	Use specialized versions of the predicates in equiv_type.m, since
	the general versions do some things (finding circularities, recording
	used modules) that this pass does not need. Use some new predicates
	from the standard library to reduce overhead.

compiler/ml_optimize.m:
	In order to avoid running the compiler out of nondet stack space
	on zm_coerce_tuples.m, avoid the use of enumerating all the members
	of a potentially huge list by backtracking.

	Move a cheap test before a more expensive one.

compiler/modes.m:
compiler/modecheck_unify.m:
	Avoid some unnecessary overheads when modechecking typeinfos and
	related variables. One overhead was iteration over a list of exactly
	one element, another is a redundant lookup of the variable's type,
	and the third is the redundant setting of the unify context.

compiler/inst_match.m:
	Use set_tree234s instead sets to keep track of expansions in one group
	of predicates indicated by benchmarking.

library/list.m:
	Add a new predicate, list.find_first_match, which is a version of
	filter that returns only the first matching item. This is for use
	in ml_elim_nested.m.

	Make list.sort_and_remove_dups remove duplicates as it goes,
	not all at the end, since this (a) allows us to avoid a separate
	duplicate-elimination pass at the end, and (b) any duplicate eliminated
	in one merge pass reduces the workload for any later merge passes.

	Put some code in its proper order, since preserving tail recursion
	in Prolog is no longer an issue.

library/map.m:
	Add  versions of map.foldl{,2,3} and map.map_foldl{,2,3} that do not
	pass the key to the higher order argument, for use by some of the
	compiler modules above.

	Group the declarations of all the foldr predicates together.

library/tree.m:
	Make the same changes as in map.m, in order to implement map.m's new
	predicates.

library/varset.m:
	Minor style improvements.

library/set_tree234.m:
	Fix a wrong comment.

NEWS:
	Mention the new additions to the library.
2009-09-16 02:32:56 +00:00
Zoltan Somogyi
544c3dfbbb Use set_tree234s instead of plain sets. Since this module does
Estimated hours taken: 0.5
Branches: main

compiler/dead_proc_elim.m:
	Use set_tree234s instead of plain sets. Since this module does
	a lot of manipulation of big sets, the faster operations allowed
	by the tree234 structure lead to a 3% speedup.

library/set_tree234.m:
	Set the language for syntax colouring to Mercury.
2009-08-19 07:31:53 +00:00
Julien Fischer
9cd94b5c72 Various minor cleanups and syntax updates for the standard library.
Estimated hours taken: 1
Branches: main

Various minor cleanups and syntax updates for the standard library.
There are no changes to any algorithms.

library/injection.m:
library/set.m:
library/sparse_bitset.m:
	Use promise_equivalent_clauses where appropriate.

library/set_ordlist.m:
library/set_unordlist.m:
	Convert these module to 4-space indentation:
		Convert these module to 4-space indentation

library/*.m:
	Convert some if-then-elses into switches.

	Remove unnecessary module qualification - this is related
	mainly to the breakup of std_util and the fact that on
	the 0.13 branche we had two versions of the all-solutions
	predicates.

	Various other style cleanups.

vim/syntax/mercury.vim:
	Highlight promise_equivalent_clauses appropriately.
2006-10-23 00:33:04 +00:00
Zoltan Somogyi
6bbcd81844 Add a version of fold with two accumulators.
Estimated hours taken: 0.1
Branches: main

library/set_ctree234.m:
library/set_tree234.m:
	Add a version of fold with two accumulators.
2006-10-01 04:14:54 +00:00
Zoltan Somogyi
ba919d3edd Fix a performance problem in mode analysis, which showed up especially badly
Estimated hours taken: 2
Branches: main

Fix a performance problem in mode analysis, which showed up especially badly
when redoing mode checking after common subexpression elimination on Peter
Ross's mas_objects.data.m test file.

compiler/inst_match.m:
	Use a logarithmic instead of linear complexity algorithm for checking
	whether we have expanded a given inst before.

library/set_tree234.m:
	Fix the underlying problem, which was that using set_tree234.member
	to *check* membership was linear in the number of set elements, due
	to the absence of an in,in mode.
2006-08-02 04:08:19 +00:00
Julien Fischer
e0f5ac47db Make it easier for vi to jump past the initial comments
Estimated hours taken: 0.1
Branches: main

library/*.m:
	Make it easier for vi to jump past the initial comments
	at the head of a module.
2006-04-19 05:18:00 +00:00
Julien Fischer
5e92224eec Improve the library reference manual by formatting the beginning of
Estimated hours taken: 0.2
Branches: main, release

library/*.m:
	Improve the library reference manual by formatting the beginning of
	library modules consistently.

library/integer.m:
	Fix some bad indentation.
2006-04-13 06:08:05 +00:00
Zoltan Somogyi
b293bd999d Replace __ with . as the module qualifier everywhere.
Estimated hours taken: 1
Branches: main

library/*.m:
	Replace __ with . as the module qualifier everywhere.

tests/hard_coded/test_injection.exp:
	Replace __ with . as the module qualifier in expected exceptions.
2006-03-07 22:23:58 +00:00
Zoltan Somogyi
57b8f436eb Convert to four-space indentation most of the library modules that
Estimated hours taken: 4
Branches: main

library/*.m:
	Convert to four-space indentation most of the library modules that
	weren't already indented that way. Use predmode syntax where possible.
	In some modules, shorten long lines by deleting module name prefixes.
	Fix departures from our coding standards.

	In some modules, simplify code, mostly using field names and/or state
	variables.

	There are no changes in algorithms, except for neg_list in integer.m.
2005-10-17 11:35:22 +00:00
Zoltan Somogyi
88c7539230 Import only one module per line, as we already do in the compiler
Estimated hours taken: 0.3
Branches: main

library/*.m:
	Import only one module per line, as we already do in the compiler
	directory.
2005-06-16 04:08:07 +00:00
Julien Fischer
c28d63e105 Standardize the positioning of descriptive comments.
Estimated hours taken: 0.5
Branches: main

library/set_ctree234.m:
library/set_tree234.m:
library/svarray.m:
library/sveqvclass.m:
library/svqueue.m:
library/svset.m:
	Standardize the positioning of descriptive comments.
2005-01-25 02:21:27 +00:00
Zoltan Somogyi
2ebbaa1a16 Add two modules that implement sets using balanced trees.
Estimated hours taken: 12
Branches: main

Add two modules that implement sets using balanced trees. At the moment,
one of those modules is used in llds_out, and this speeds up the compiler
by about one percent when using the LLDS backend. (When generating code
using an MLDS backend, the speed is not affected.)

I have tried out replacing set_ordlist with set_ctree234 as the default
implementation of sets, but this slowed down the compiler by about 9%
in the usual case, which is too much, although it did improve its performance
slightly on some inputs with large predicates, which are a kind of worst-case
situation for sets implemented as lists. Accordingly, I won't commit any
changes to set.m. However, to make such changes easier in the future, I have
removed the dependence of some test cases on the fact that sets are currently
implemented as sorted lists.

library/set_tree234.m:
	Add this module, which implements sets as 2-3-4 trees. The
	implementation is patterned after tree234.m, but stored only
	single elements in nodes instead of key-value pairs. It has
	better worst-case behavior than our current standard implementation
	of sets, set_ordlist (in particular it has logarithmic search time),
	but worse constant factors.

library/set_ctree234.m:
	Add this module, which implements sets as 2-3-4 trees augmented with
	set cardinality. This has the same virtues as set_tree234.m, but also
	allows it to be linear in the smaller input for operations such as
	union that must be linear in the size of one input set or the other.

library/library.m:
NEWS:
	Mention the new modules.

compiler/llds_out.m:
	Use set_tree234.m instead of a map with dummy values.

compiler/mercury_compile.m:
	Delete an unnecessary import.

tests/hard_coded/relation_test.{m,exp}:
	Change this test case to convert sets to ordered lists before printing
	them out, to make the test independent of the representation of sets.

tests/hard_coded/string_alignment_bug.m:
	Change this test case to use set_ordlist instead of plain sets.
2005-01-21 03:32:20 +00:00