Commit Graph

37 Commits

Author SHA1 Message Date
Zoltan Somogyi
ee0f9f73d7 Add library/fatter_sparse_bitset.m.
library/fatter_sparse_bitset.m:
    Add this version of fat_sparse_bitset.m, which stores *two* words
    worth of bits in each cell, not one. This word would otherwise be unused,
    because the Boehm-Demers-Weiser allocator rounds up requests for three
    word cells to four.

library/MODULES_DOC:
library/library.m:
    Add the new module to the list of library modules.

library/fat_sparse_bitset.m:
library/sparse_bitset.m:
library/tree_bitset.m:
    Update the documentation of all these other bitset modules. Copy
    the same basic introduction to all the relevant modules. Add documentation
    of the differences to tree_bitset.m and fatter_sparse_bitset.m, with
    a pointer in fat_sparse_bitset.m to fatter_sparse_bitset.m.

library/test_bitset.m:
    Test the new module as well as the others.

tests/hard_coded/speedtest_bitset.m:
    Extend the benchmarking of list_to_set operations to the new module.
    To allow the benchmarking to be tough enough to be informative, comment
    out the benchmarking of the old_list_to_set operations.
2023-01-31 18:36:16 +11:00
Zoltan Somogyi
0497e18e7b Clarity the prereqs of sorted_list_to_set for bitsets. 2023-01-23 00:20:48 +11:00
Zoltan Somogyi
56ed26f650 Improve the remove_{leq,gt} sparse bitset ops.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
    Speed up the remove_leq and remove_gt operations by moving a
    loop invariant computation, the conversion of the boundary item's index
    into an <offset,bitposn> pair, out of the loop.

    Eliminate some unnecessary differences between the two modules,
    e.g. clear_bit being a predicate rather than a function.

library/test_bitset.m:
    Add facilities to test the remove_leq and remove_gt operations
    of sparse_bitset.m, fat_sparse_bitset.m, and tree_bitset.m
    against the same operations on plain old set_ordlists.

    Bring this module up to date by requiring set elements to be
    members of the uenum typeclass, not the enum typeclass.

    Make the test_bitset type a bespoke type.

library/tree_bitset.m:
    Add predicate versions of the remove_leq and remove_gt operations
    alongside the existing function versions, to allow the new code
    in test_bitset.m to work the same way regardless of which bitset module
    it is testing.

    For uniformity with the other bitset modules, require set elements to be
    members of the uenum typeclass, not the enum typeclass.

    Change the other integers, such as level numbers, to be unsigned
    as well, to avoid the need for casts.

NEWS:
    Announce the new additions and changes.

tests/hard_coded/test_tree_bitset.{m,exp}:
    Use those new facilities to test those operations, and add some
    test sets designed for that purpose.

    Add a comment about the limitations of this testing strategy.

tests/hard_coded/bitset_tester.m:
    Delete this long-unused module. (It was the original basis of
    the test_bitset.m module in the library directory, but it became unused
    when test_tree_bitset.m switched to using that module a long time ago.)
2023-01-19 14:42:34 +11:00
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
b0e8c56092 Make the remaining set modules follow our standard order.
library/diet.m:
library/fat_sparse_bitset.m:
library/sparse_bitset.m:
library/test_bitset.m:
library/tree_bitset.m:
    As above. Also, mark as obsolete the same predicates as were marked obsolete
    in the other set modules recently.

compiler/mode_robdd.equiv_vars.m:
compiler/mode_robdd.implications.m:
compiler/mode_robdd.tfeirn.m:
library/robdd.m:
library/digraph.m:
    Avoid using predicates that are now marked obsolete.
2019-09-14 00:03:44 +10:00
Zoltan Somogyi
95f8f56716 Delete unneeded $module args from calls to expect/unexpected. 2019-07-03 22:37:19 +02: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
Peter Wang
f580a90c33 Use uints to represent bit vectors.
library/fat_sparse_bitset.m
library/sparse_bitset.m:
library/tree_bitset.m:
    Use uints to represent bit vectors in these modules.
2018-04-15 17:03:56 +10:00
Zoltan Somogyi
74a7a8345c Fix too-long lines. 2017-12-30 19:59:59 +11:00
Zoltan Somogyi
0027db99fe Fix more warnings from --warn-inconsistent-pred-order-clauses. 2017-05-04 02:17:42 +10:00
Zoltan Somogyi
ba53e90cab Delete some unused predicates. 2016-01-02 01:39:02 +11:00
Zoltan Somogyi
f0ffbbc13c Convert (C->T;E) to (if C then T else E). 2015-12-01 05:35:29 +11:00
Zoltan Somogyi
62ec97d443 Report imports shadowed by other imports.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.

compiler/hlds_module.m:
    We used to record the set of imported/used modules, and the set of
    modules imported/used in the interface of the current module. However,
    these sets

    - did not record the distinction between imports and uses;
    - did not allow distinction between single and multiple imports/uses;
    - did not record the locations of the imports/uses.

    The first distinction was needed only by module_qual.m, which *did*
    pay attention to it; the other two were not needed at all.

    To generate messages for imports/uses shadowing other imports/uses,
    we need all three, so change the data structure storing such information
    for *direct* imports to one that records all three of the above kinds
    of information. (For imports made by read-in interface and optimization
    files, the old set of modules approach is fine, and this diff leaves
    the set of thus *indirectly* imported module names alone.)

compiler/unused_imports.m:
    Use the extra information now available to generate a
    severity_informational message about any import or use that is made
    redundant by an earlier, more general import or use.

    Fix two bugs in the code that generated warnings for just plain unused
    modules.

    (1) It did not consider that a use of the builtin type char justified
    an import of char.m, but without that import, the type is not visible.

    (2) It scanned cons_ids in goals in procedure bodies, but did not scan
    cons_ids that have been put into the const_struct_db. (I did not update
    the code here when I added the const_struct_db.)

    Also, add a (hopefully temporary) workaround for a bug in
    make_hlds_passes.m, which is noted below.

    However, there are at least three problems that prevent us from enabling
    --warn-unused-imports by default.

    (1) In some places, the import of a module is used only by clauses for
    a predicate that also has foreign procs. When compiled in a grade that
    selects one of those foreign_procs as the implementation of the predicate,
    the clauses are discarded *without* being added to the HLDS at all.
    This leads unused_imports.m to generate an uncalled-for warning in such
    cases. To fix this, we would need to preserve the Mercury clauses for
    *all* predicates, even those with foreign procs, and do all the semantic
    checks on them before throwing them away. (I tried to do this once, and
    failed, but the task should be easier after the item list change.)

    (2) We have two pieces of code to generate import warnings. The one in
    unused_imports.m operates on the HLDS after type and mode checking,
    while module_qual.m operates on the parse tree before the creation of
    the HLDS. The former is more powerful, since it knows e.g. what types and
    modes are used in the bodies of predicates, and hence can generate warnings
    about an import being unused *anywhere* in a module, as opposed to just
    unused in its interface.

    If --warn-unused-imports is enabled, we will get two separate set of
    reports about an interface import being unused in the interface,
    *unless* we get a type or mode error, in which case unused_imports.m
    won't be invoked. But in case we do get such errors, we don't want to
    throw away the warnings from module_qual.m. We could store them and
    throw them away only after we know we won't need them, or just get
    the two modules to generate identical error_specs for each warning,
    so that the sort_and_remove_dups of the error specs will do the
    throwing away for us for free, if we get that far.

    (3) The valid/bug100.m test case was added as a regression test for a bug
    that was fixed in module_qual.m. However the bug is still present in
    unused_imports.m.

compiler/make_hlds_passes.m:
    Give hlds_module.m the extra information it now needs for each item_avail.

    Add an XXX for a bug that cannot be fixed right now: the setting of
    the status of abstract instances to abstract_imported. (The "abstract"
    part is correct; the "imported" part may not be.)

compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
    Conform to the change in hlds_module.m.

compiler/module_qual.m:
    Update the documentation of the relationship of this module
    with unused_imports.m.

compiler/hlds_data.m:
    Document a problem with the status of instance definitions.

compiler/hlds_out_module.m:
    Update the code that prints out the module_info to conform to the change
    to hlds_module.m.

    Print status information about instances, which was needed to diagnose
    one of the bugs in unused_imports.m. Format the output for instances
    nicer.

compiler/prog_item.m:
    Add a convenience predicate.

compiler/prog_data.m:
    Remove a type synonym that makes things harder to understand, not easier.

compiler/modules.m:
    Delete an XXX that asks for the feature this diff implements.
    Add another XXX about how that feature could be improved.

compiler/Mercury.options.m:
    Add some more modules to the list of modules on which the compiler
    should be invoked with --no-warn-unused-imports.

compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
    Delete unneeded imports. Many of these shadow other imports, and some
    are just plain unneeded, as shown by --warn-unused-imports. In a few
    modules, there were a *lot* of unneeded imports, but most had just
    one or two.

    In a few cases, removing an import from a module, because it *itself*
    does not need it, required adding that same import to those of its
    submodules which *do* need it.

    In a few cases, conform to other changes above.

tests/invalid/Mercury.options:
    Test the generation of messages about import shadowing on the existing
    import_in_parent.m test case (although it was also tested very thoroughly
    when giving me the information needed for the deletion of all the
    unneeded imports above).

tests/*/*.{m,*exp}:
    Delete unneeded imports, and update any expected error messages
    to expect the now-smaller line numbers.
2015-08-25 00:38:49 +10: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
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
Peter Wang
72d7422eda Implement `tree_bitset.delete' directly instead of using the more
Branches: main

library/tree_bitset.m:
	Implement `tree_bitset.delete' directly instead of using the more
	general `difference' operation.

tests/hard_coded/test_tree_bitset.exp:
tests/hard_coded/test_tree_bitset.m:
	Extend test case to cover `delete'.
2012-04-23 00:19:26 +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
a0bc277d60 Fix a performance problem in liveness. Liveness makes many calls to
Estimated hours taken: 12
Branches: main

Fix a performance problem in liveness. Liveness makes many calls to
divide_by_set, but the existing implementation of that predicate in
tree_bitset.m did not exploit the structure of its operands.
After this diff, it now does so, though not yet to the fullest extent
possible. However, even this is enough to reduce the time needed
to compile a variant of the zm_rcpsp_cpx.m stress test from 66 seconds
to 15, with liveness analysis no longer being the bottleneck.
On tools/speedtest, we get about a 0.4% speedup, which is just
above the noise threshold.

library/tree_bitset.m:
	Specialize the implementation of divide_by_set for many of
	the possible cases. Leave XXXs where further specialization
	is possible.

	Put some predicate definitions in a more logical order.

compiler/test_bitset.m:
	This module has long been used (initially by Simon Taylor, later
	by me) to test the correctness of the implementation of first
	sparse_bitset.m and later tree_bitset.m. However, since it
	slows down all set operations a lot (by doing them twice, once using
	a bitset module and once using set_ordlist, and then comparing
	the results), it is never enabled in production compilers,
	and since it is usually not imported by any ordinary compiler
	modules, it is rarely even compiled. It has thus tended to
	get bitrot; changes in the set modules it uses need corresponding
	changes in this module, but it has not been getting them.

	To fix this, move this module from the compiler directory to the
	library directory. By including the moved version in the library,
	it will always be compiled, and anyone who breaks it will have
	to fix the breakage before checking in their change.

	The cost is about 16 kilobytes in the Mercury library's .so file,
	which is well worth it.

library/test_bitset.m:
	The moved module. It had to be updated to compile and work
	with the current versions of tree_bitset.m and set_ordlist.m.

library/library.m:
	Include the moved module in the library.

doc/Mmakefile:
	Since the moved module is only for the implementors of the bitset
	modules, do not include it in the documentation.

	Sort the names of the modules that are not included in the
	documentation.

tests/hard_coded/test_tree_bitset.{m,exp}:
	Make this module, which tests the operation of tree_bitset.m,
	both more thorough and more controllable.

	Make it more thorough by testing it not just with some toy sets
	and some small random sets as inputs, but also with some inputs
	specifically designed to be stress tests. These are taken from
	the old tree_bitset_difference test case.

	Make it more thorough in another way by also testing the divide_by_set
	operation.

	Make it more controllable by making it easy to test just one operation
	(for me now, that was of course divide_by_set), without the distraction
	of outputs from tests of other operations.

tests/hard_coded/tree_bitset_tester.m:
	This module used to do the job of test_bitset.m for test_tree_bitset.m.
	This was needed while test_bitset.m was in the compiler directory,
	but it is not needed now, and keeping it presents a double maintenance
	problem. This diff therefore deletes it, and makes test_tree_bitset.m
	use test_bitset.m from the library.

tests/hard_coded/tree_bitset_difference.{m,exp}:
	Delete this test case. The stress test inputs it used to test the
	difference operation with are now in test_tree_bitset.m, which
	uses them to test not just the difference operation, but other
	operations as well.

tests/hard_coded/test_bitset.{m,exp}:
	Delete this test case, since it seems to be a duplicate of an early
	version of tree_bitset_tester.m. Despite its name, it was NOT a copy
	of the identically named module that used to be in the compiler
	directory.

tests/hard_coded/Mmakefile:
	Remove the now unneeded tree_bitset_difference and test_bitset
	test cases from the list of test cases.
2012-03-29 04:03:12 +00:00
Zoltan Somogyi
d7cf20938d Speed up tree_bitset.difference by tailoring its actions to the forms
Estimated hours taken: 4
Branches: main

library/tree_bitset.m:
	Speed up tree_bitset.difference by tailoring its actions to the forms
	of the input operands, instead of its previous approach of transforming
	every operand into the same general form.
2011-09-03 01:43:38 +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
9cf01fa147 Fix two more problems with tree_bitset.difference.
Estimated hours taken: 5
Branches: main

Fix two more problems with tree_bitset.difference.

The first problem, fixed by Peter Wang, was a stray "+1". This was in code
that tried to figure out the difference between two lists of nodes that could
be at different levels, and occurred when the level of the first operand
was lower than the level of the second.

The second problem occurred when the level of the first operand was greater
than the level of the second. The code tried to handle this case, but did not
do so correctly, mainly because it assumed that raising by one level is always
enough.

The underlying cause of both problems was that the predicate involved
(interiorlist_difference) tried to do too much: compute the difference AND
match the levels of the input operands. The overall fix is to get the caller
to ensure that the two operands are at the same level.

This diff was tested with
- set_of_var using test_bitset instead of tree_bitset, to test the results
  of every set_of_var operation,
- with tree_bitset's bits_per_level set to 1, to force the execution of code
  dealing with different levels of nodes much more frequently than the usual
  bits_per_level=5 (with the latter setting, only enormous sets ever have more
  than one level of interior node), and
- with integrity tests on tree_bitset.m enabled.

library/tree_bitset.m:
	Make the above change.

tests/hard_coded/tree_bitset_difference.{m,exp}:
	Update the test case to test all the operand pairs listed in the Mantis
	bug report, in two forms: one that showed the bug on 32-bit systems,
	and one that showed the bug on 64-bit systems. (The word size matters
	because one leaf node contains one word's worth of bits.)

	Since we now generate much more output, checking the equivalence
	of the results generated by tree_bitset.m and by set.m by eye is no
	longer trivial. Make the code do the check itself, and print output
	only if there is a mismatch.
2011-08-04 02:01:39 +00:00
Zoltan Somogyi
cf7ae8adad Put all the assertions into trace goals that can be switched on or off
Estimated hours taken: 0.5
Branches: main

library/tree_bitset.m:
	Put all the assertions into trace goals that can be switched on or off
	at will.

	If the assertions are disabled, we get a speedup of more than 7%
	on tools/speedtest.

library/Mercury.options:
	Given the recently discovered bugs in the tree_bitset module,
	enable the assertions for now.
2011-08-01 07:10:29 +00:00
Zoltan Somogyi
72150350f9 Fix Mantis bug 207.
Estimated hours taken: 2
Branches: main

library/tree_bitset.m:
	Fix Mantis bug 207.

	Update the assertions in this module to use the latest updates
	to require.m.

tests/hard_coded/tree_bitset_difference.{m,exp}:
	A regression test for the bug. This is the bug in the Mantis bug
	report, modified to also fail on 64 bit systems without the fix.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2011-07-28 04:52:54 +00:00
Peter Wang
b6c0aaa164 Fix argument ordering in documentation for
Branches: main, 11.07

Fix argument ordering in documentation for
`sparse_bitset.member/2' and `tree_bitset.member/2'.

library/sparse_bitset.m:
library/tree_bitset.m:
	As above.
2011-07-22 01:25:52 +00:00
Zoltan Somogyi
7487590f2d Predicates with many variables, such as some of those in zm_enums.m,
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).
2011-07-21 06:58:34 +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
d751977fca Change the argument order of predicates in the tree_bitset module to make it
Branches: main

Change the argument order of predicates in the tree_bitset module to make it
more conducive to the use of state variable notation.

library/tree_bitset.m:
	As above.

	Add the usual modes with (mostly-)unique accumulators
	to foldl/4.

compiler/quantification.m:
	Conform to the above change.

NEWS:
	Announce the above change.
2011-05-19 16:20:55 +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
Zoltan Somogyi
b8cf13cf81 Add two new predicates: divide and divide_by_set.
Estimated hours taken: 4
Branches: main

library/tree_bitset.m:
	Add two new predicates: divide and divide_by_set.

NEWS:
	Mention the additions.
2010-11-01 05:45:06 +00:00
Zoltan Somogyi
28301fd9ad Make the documentation a bit more consistent.
Estimated hours taken: 0.1
Branches: main

library/tree_bitset.m:
	Make the documentation a bit more consistent.
2009-10-19 23:55:59 +00:00
Peter Wang
1e9bcf2a2a Fix an unintended duplicate `:- pragma type_spec'.
Branches: main

library/svmap.m:
	Fix an unintended duplicate `:- pragma type_spec'.

library/tree_bitset.m:
	Delete duplicate `:- pragma type_spec' lines.
2008-08-07 04:57:19 +00:00
Julien Fischer
bbb7f9edf9 Turn the commented-out integrity checking code for tree_bitsets into
Estimated hour taken: 0.4
Branches: main

Turn the commented-out integrity checking code for tree_bitsets into
trace goals with a compile time condition.

library/tree_bitset.m:
	Make the above change.
2007-10-13 13:34:32 +00:00
Zoltan Somogyi
33d93b0062 Compile sparse_bitset.m and tree_bitset.m with
Estimated hours taken: 1
Branches: main

library/Mercury.options:
	Compile sparse_bitset.m and tree_bitset.m with
	--optimize-constant-propagation, which enables the optimizations
	in simplify.m for operations involving bits_per_int, which were
	designed for this purpose.

	Compile them also with --use-atomic-cells, to enables to use plain
	Mercury code instead of foreign procs to allocate nodes containing
	bitsets.

	These changes lead to a speedup of about 1.5% in compiling
	training_cars_full.m, from 97.3 seconds to 95.8 seconds.

library/sparse_bitset.m:
library/tree_bitset.m:
	Use Mercury code instead of foreign_procs to allocate nodes containing
	bitsets.

	I tried commenting out the sanity checks still left in tree_bitset.m,
	but this lead to a speedup of only 0.1%, so I left them in.
2006-12-27 03:59:28 +00:00
Zoltan Somogyi
0724668056 Add to the library a new module called tree_bitset.m, which is a version
Estimated hours taken: 32
Branches: main

Add to the library a new module called tree_bitset.m, which is a version
of sparse_bitset.m modified to allow algorithms (for union, intersection etc)
that do not require scanning the entire list of bitmaps.

Use this module as the set representation in quantification.

This reduces the time to compile training_cars_full.m from 250 seconds
to 110 seconds (a reduction of about 56%). As for compiling ordinary files,
the time taken for our usual speedtest (compiling the six largest files
of the compiler itself) is reduced from 20.2 seconds to 19.5 (a reduction
of about 3.5%).

library/tree_bitset.m:
	Add the new module.

library/library.m:
	Include the new module in the library.

library/int.m:
	Improve the formatting of some comments.

library/sparse_bitset.m:
	Fix a bug in a comment.

compiler/quantification.m:
	Use the new module in the library.

	Avoid using predicates that exist in sparse_bitset.m and in set.m
	but are available only as functions in tree_bitset.m.

	Rename a predicate to avoid ambiguity.

compiler/hlds_out.m:
	Output the number of variables in a predicate or procedure when
	printing the set of variables and their types.

tests/hard_coded/test_tree_bitset.{m,exp}:
tests/hard_coded/tree_bitset_tester.m:
	Two modules of a new test case, modelled on the test case that tests
	sparse_bitsets, for testing tree_bitsets.

tests/hard_coded/Mmakefile:
	Don't enable the new test case yet, since the .exp file is only a dummy
	so far.
2006-12-22 05:44:29 +00:00