Commit Graph

9 Commits

Author SHA1 Message Date
Zoltan Somogyi
f0ffbbc13c Convert (C->T;E) to (if C then T else E). 2015-12-01 05:35:29 +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
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
79cac2cafa Update the code that throws exceptions.
Estimated hours taken: 0.1
Branches: main

library/digraph.m:
	Update the code that throws exceptions.
2012-11-15 00:02:00 +00:00
Julien Fischer
9480a49274 Change the argument order of predicates in the sparse_bitset modules to make
Branches: main

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

Group function clauses together with the clauses for the corresponding
predicates.

library/sparse_bitset.m:
	As above.

library/digraph.m:
compiler/make.dependencies.m:
compiler/mode_robdd.equiv_vars.m:
compiler/mode_robdd.implications.m:
compiler/mode_robdd.tfeirn.m:
tests/hard_coded/bitset_tester.m:
tests/hard_coded/pprint_test.m:
tests/valid/loop_inv_bug.m:
	Conform to the above change.

library/digraph.m:
library/getopt.m:
library/getopt_io.m:
library/map.m:
	Remove dependencies on the svset module.

NEWS:
	Announce the above change.
2011-05-19 13:11:47 +00:00
Julien Fischer
4de4664e14 Use state variable field update syntax in a couple of spots.
Branches: main

library/digraph.m:
	Use state variable field update syntax in a couple of spots.
2011-05-06 06:04:56 +00:00
Julien Fischer
9f68c330f0 Change the argument order of many of the predicates in the map, bimap, and
Branches: main

Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.

Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.

library/bimap.m:
library/map.m:
library/multi_map.m:
	As above.
NEWS:
	Announce the change.

	Separate out the "highlights" from the "detailed listing" for
	the post-11.01 NEWS.

	Reorganise the announcement of the Unicode support.

benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
	Conform to the above change.

	Remove any dependencies on the sv{bimap,map,multi_map} modules.
2011-05-03 04:35:04 +00:00
Zoltan Somogyi
a2cd0da5b3 The existing representation of goal_paths is suboptimal for several reasons.
Estimated hours taken: 80
Branches: main

The existing representation of goal_paths is suboptimal for several reasons.

- Sometimes we need forward goal paths (e.g. to look up goals), and sometimes
  we need reverse goal paths (e.g. when computing goal paths in the first
  place). We had two types for them, but

  - their names, goal_path and goal_path_consable, were not expressive, and
  - we could store only one of them in goal_infos.

- Testing whether goal A is a subgoal of goal B is quite error-prone using
  either form of goal paths.

- Using a goal path as a key in a map, which several compiler passes want to
  do, requires lots of expensive comparisons.

This diff replaces most uses of goal paths with goal ids. A goal id is an
integer, so it can be used as a key in faster maps, or even in arrays.
Every goal in the body of a procedure gets its id allocated in a depth first
search. Since we process each goal before we dive into is descendants,
the goal representing the whole body of a procedure always gets goal id 0.
The depth first traversal also builds up a map (the containing goal map)
that tells us the parent goal of ever subgoal, with the obvious exception
of the root goal itself. From the containing goal map, one can compute
both reverse and forward goal paths. It can also serve as the basis of an
efficient test of whether the goal identified by goal id A is an ancestor
of another goal identified by goal id B. We don't yet use this test,
but I expect we will in the future.

mdbcomp/program_representation.m:
	Add the goal_id type.

	Replace the existing goal_path and goal_path_consable types
	with two new types, forward_goal_path and reverse_goal_path.
	Since these now have wrappers around the list of goal path steps
	that identify each kind of goal path, it is now ok to expose their
	representations. This makes several compiler passes easier to code.

	Update the set of operations on goal paths to work on the new data
	structures.

	Add a couple of step types to represent lambdas and try goals.
	Their omission prior to this would have been a bug for constraint-based
	mode analysis, or any other compiler pass prior to the expansion out
	of lambda and try goals that wanted to use goal paths to identify
	subgoals.

browser/declarative_tree.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
slice/mcov.m:
deep_profiler/*.m:
	Conform to the changes in goal path representation.

compiler/hlds_goal:
	Replace the goal_path field with a goal_id field in the goal_info,
	indicating that from now on, this should be used to identify goals.

	Keep a reverse_goal_path field in the goal_info for use by RBMM and
	CTGC. Those analyses were too hard to convert to using goal_ids,
	especially since RBMM uses goal_paths to identify goals in multi-pass
	algorithms that should be one-pass and should not NEED to identify
	any goals for later processing.

compiler/goal_path:
	Add predicates to fill in goal_ids, and update the predicates
	filling in the now deprecated reverse goal path fields.

	Add the operations needed by the rest of the compiler
	on goal ids and containing goal maps.

	Remove the option to set goal paths using "mode equivalent steps".
	Constraint based mode analysis now uses goal ids, and can now
	do its own equivalent optimization quite simply.

	Move the goal_path module from the check_hlds package to the hlds
	package.

compiler/*.m:
	Conform to the changes in goal path representation.

	Most modules now use goal_ids to identify goals, and use a containing
	goal map to convert the goal ids to goal paths when needed.
	However, the ctgc and rbmm modules still use (reverse) goal paths.

library/digraph.m:
library/group.m:
library/injection.m:
library/pprint.m:
library/pretty_printer.m:
library/term_to_xml.m:
	Minor style improvements.
2010-12-20 07:47:49 +00:00
Mark Brown
0dfb9c4874 New module for directed graphs. This is essentially the relation
Estimated hours taken: 12
Branches: main

library/digraph.m:
	New module for directed graphs.  This is essentially the relation
	module but with more consistent terminology, and with argument
	ordering that suits state variables.  Other differences with the
	relation module:

	- The digraph_key type has a phantom type parameter, which helps to
	  ensure that keys from one digraph are not used with another digraph.

	- Exports a version of digraph.reduced which also returns the mapping
	  between the original digraph keys and the new ones.

	- The implementation of compose/3 doesn't try to use the "domain" and
	  "range" of the graphs (which is meaningless in the relation module
	  anyway).

	- New, more efficient algorithm for is_dag/1.  Correctness proof is
	  documented.

	- components/2 uses a more efficient data representation, and avoids
	  some intermediate data structures.

	- reduced/{2,3} avoids some intermediate data structures.

	- tc/2 avoids some intermediate data structures.

library/library.m:
	Add the new module.

library/relation.m:
	Document that this module is deprecated in favour of digraph.

	Flag relation.init/{0,1} as obsolete (it would be better to flag
	the entire module, or the relation/1 type as obsolete, but Mercury
	does not support this).

NEWS:
	Mention that the new module supersedes relation.m and svrelation.m.

compiler/*.m:
profiler/*.m:
	Use the digraph module rather than the relation module.
2007-09-07 15:08:21 +00:00